@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg-main: #090d16;
  --bg-surface: rgba(17, 24, 39, 0.7);
  --bg-surface-solid: #0f172a;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #6366f1;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --sidebar-width: 400px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  background-image:
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(168, 85, 247, 0.08) 0px, transparent 50%);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Custom Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.1); }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* Header */
header {
  min-height: 65px;
  height: auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  border-bottom: 1px solid var(--border-color);
  background-color: rgba(9, 13, 22, 0.8);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.logo-section { display: flex; align-items: center; gap: 12px; }

.logo-icon {
  width: 32px; height: 32px;
  background: var(--primary-gradient);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-family: var(--font-title); color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

h1 {
  font-family: var(--font-title); font-size: 1.25rem; font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #ffffff, #e0e7ff);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }

/* =============================================
   BUTTON STYLES
   ============================================= */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 8px;
  font-family: var(--font-body); font-size: 0.875rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); border: none;
}
.btn-primary {
  background: var(--primary-gradient); color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35); filter: brightness(1.05); }
.btn-secondary { background: rgba(255, 255, 255, 0.05); color: var(--text-main); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.2); }
.btn-success { background: var(--success); color: white; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2); }
.btn-success:hover { filter: brightness(1.05); transform: translateY(-1px); }

/* BUG 5 FIX: btn-sm was missing */
.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
  border-radius: 6px;
}

/* App Main Container */
.app-container { display: flex; flex: 1; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  border-right: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  backdrop-filter: blur(16px);
  display: flex; flex-direction: column;
  overflow-y: auto; z-index: 5;
}

/* Context switcher */
.context-switcher {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0,0,0,0.15);
  flex-shrink: 0;
}

/* Tab Navigation */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-surface-solid); /* Made opaque to prevent text from showing through when scrolling */
  position: sticky;
  top: 0;
  z-index: 2;
  flex-shrink: 0;
  /* Prevent tabs from being squished smaller than their content */
  overflow: hidden;
}
.tab-btn {
  flex: 1;
  min-width: 0;           /* allow flex children to shrink */
  padding: 12px 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.75rem;     /* slightly smaller so all 4 fit */
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  letter-spacing: -0.01em;
}
.tab-btn:hover { color: var(--text-main); background: rgba(255, 255, 255, 0.03); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(99, 102, 241, 0.06);
  font-size: 0.75rem;
}

/* Tab Content */
.tab-content { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.tab-panel { display: none; }
.tab-panel.active { display: flex; flex-direction: column; gap: 12px; }

/* =============================================
   COLLAPSIBLE SECTIONS (Accordion)
   ============================================= */
.collapsible-section {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.15);
}

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  transition: background 0.2s;
  user-select: none;
  gap: 8px;
}
.collapsible-header:hover { background: rgba(255, 255, 255, 0.04); }

.collapsible-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.collapsible-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.25s ease;
}
.collapsible-section.open .collapsible-icon { transform: rotate(180deg); }

.collapsible-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s ease;
  padding: 0 14px;
}
.collapsible-section.open .collapsible-body {
  max-height: 1800px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Form Groups */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1;
}

input[type="text"], input[type="url"], select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.875rem;
  transition: all 0.2s;
  line-height: 1.4;
}
input[type="text"]:focus, input[type="url"]:focus, select:focus {
  outline: none;
  border-color: var(--border-focus);
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

/* =============================================
   CUSTOM FONT PICKER (Dropdown)
   ============================================= */
.custom-font-select {
  position: relative;
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}
.custom-font-select:focus, .custom-font-select.active {
  outline: none;
  border-color: var(--border-focus);
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.custom-font-select::after {
  content: '▼';
  font-size: 0.6rem;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.cfs-value {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 16px;
}
.cfs-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  max-height: 250px;
  overflow-y: auto;
  background: var(--bg-surface-solid);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  z-index: 100;
  display: none;
  flex-direction: column;
}
.custom-font-select.active .cfs-dropdown {
  display: flex;
}
.cfs-option {
  padding: 8px 12px;
  font-size: 1rem;
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.15s;
}
.cfs-option:hover {
  background: rgba(99, 102, 241, 0.15);
}
.cfs-option.selected {
  background: rgba(99, 102, 241, 0.25);
  color: var(--primary);
}

/* =============================================
   RANGE SLIDER (Custom dark theme)
   ============================================= */
.range-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.range-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.range-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1;
}
.range-value {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  font-family: monospace;
  min-width: 36px;
  text-align: right;
  flex-shrink: 0;
}

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--primary); border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
  cursor: pointer; transition: transform 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--primary); border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
  cursor: pointer;
}

/* =============================================
   3x3 POSITION GRID
   ============================================= */
.position-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: 100px;
  aspect-ratio: 1;
}
.position-grid-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.position-grid-btn:hover { background: rgba(99, 102, 241, 0.15); border-color: var(--primary); }
.position-grid-btn.active {
  background: var(--primary); border-color: var(--primary);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
}
.position-grid-btn .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
}
.position-grid-btn.active .dot { background: white; }

.position-control {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 8px;
}
.position-sliders {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

/* =============================================
   CHECKBOX TOGGLE
   ============================================= */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  gap: 12px;
  /* thin separator between consecutive toggles */
  border-top: 1px solid rgba(255,255,255,0.04);
}
.toggle-row:first-of-type { border-top: none; }
.toggle-label {
  font-size: 0.8rem;
  color: var(--text-main);
  font-weight: 500;
  line-height: 1.3;
  flex: 1;
}
.toggle-switch {
  position: relative; width: 36px; height: 20px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px; transition: 0.2s;
}
.toggle-slider:before {
  position: absolute; content: ""; height: 14px; width: 14px;
  left: 3px; bottom: 3px;
  background: var(--text-muted); border-radius: 50%; transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(16px); background: white;
}

/* Color Picker Grid */
.color-picker-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.color-input-wrapper {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0, 0, 0, 0.2); border: 1px solid var(--border-color);
  padding: 6px 10px; border-radius: 8px;
}
.color-input-wrapper input[type="color"] {
  -webkit-appearance: none; border: none;
  width: 28px; height: 28px; border-radius: 6px; cursor: pointer; background: none;
}
.color-input-wrapper input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-input-wrapper input[type="color"]::-webkit-color-swatch {
  border: 1px solid rgba(255,255,255,0.15); border-radius: 6px;
}
.color-val-text {
  font-size: 0.85rem; font-family: monospace; color: var(--text-main); text-transform: uppercase;
}

/* Dropzone */
.image-upload-wrapper { display: flex; flex-direction: column; gap: 6px; }
.dropzone {
  border: 1.5px dashed var(--border-color);
  border-radius: 8px;
  padding: 14px 12px;
  text-align: center;
  background: rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.06);
  transform: scale(1.005);
}
.dropzone-icon { color: var(--text-muted); line-height: 1; }
.dropzone-text { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.dropzone-hint { font-size: 0.7rem; color: rgba(156, 163, 175, 0.55); margin-top: 1px; }

.image-preview-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  padding: 7px 10px;
  border-radius: 8px;
  margin-top: 4px;
}
.image-preview-thumb {
  width: 34px;
  height: 34px;
  border-radius: 4px;
  object-fit: contain;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}
.image-preview-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.image-preview-name {
  font-size: 0.73rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}
.btn-remove-image {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0;
  opacity: 0.7;
}
.btn-remove-image:hover { transform: scale(1.15); opacity: 1; }

/* =============================================
   CTA VARIANT VISUAL PICKER
   ============================================= */
.cta-variant-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.cta-variant-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: rgba(0,0,0,0.2);
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  padding: 7px 3px 6px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 0;
}
.cta-variant-btn:hover {
  border-color: rgba(99,102,241,0.5);
  background: rgba(99,102,241,0.06);
}
.cta-variant-btn.active {
  border-color: var(--primary);
  background: rgba(99,102,241,0.12);
  box-shadow: 0 0 0 1px var(--primary);
}

.cta-variant-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.58rem;
  font-weight: 700;
  padding: 3px 5px;
  border-radius: 4px;
  width: 100%;
  max-width: 62px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cta-variant-filled { background: #6366f1; color: white; }
.cta-variant-outlined { background: transparent; color: #6366f1; border: 1.5px solid #6366f1; }
.cta-variant-ghost { background: transparent; color: #6366f1; text-decoration: underline; }
.cta-variant-pill { background: #6366f1; color: white; border-radius: 999px; }
.cta-variant-name {
  font-size: 0.62rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.cta-variant-btn.active .cta-variant-name { color: var(--primary); }

/* =============================================
   ANIMATION EFFECT PICKER
   ============================================= */
.anim-effect-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.anim-effect-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: rgba(0,0,0,0.2);
  border: 1.5px solid var(--border-color);
  border-radius: 7px;
  padding: 7px 3px 6px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  min-width: 0;
}
.anim-effect-btn:hover {
  border-color: rgba(99,102,241,0.5);
  background: rgba(99,102,241,0.06);
}
.anim-effect-btn.active {
  border-color: var(--primary);
  background: rgba(99,102,241,0.14);
  box-shadow: 0 0 0 1px var(--primary);
}

.anim-effect-icon {
  font-size: 1.1rem;
  line-height: 1;
  color: var(--text-muted);
  transition: all 0.3s;
  display: block;
  min-height: 20px;
}
.anim-effect-btn.active .anim-effect-icon { color: var(--primary); }
.anim-effect-btn:hover .anim-effect-icon { color: var(--text-main); }

.anim-effect-label {
  font-size: 0.58rem;
  color: var(--text-muted);
  font-weight: 700;
  text-align: center;
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}
.anim-effect-btn.active .anim-effect-label { color: var(--primary); }

/* Hover animations on effect icons */
.anim-effect-btn:hover .anim-preview-fade { animation: previewFade 0.5s ease; }
.anim-effect-btn:hover .anim-preview-slide-up { animation: previewSlideUp 0.5s ease; }
.anim-effect-btn:hover .anim-preview-slide-down { animation: previewSlideDown 0.5s ease; }
.anim-effect-btn:hover .anim-preview-slide-left { animation: previewSlideLeft 0.5s ease; }
.anim-effect-btn:hover .anim-preview-slide-right { animation: previewSlideRight 0.5s ease; }
.anim-effect-btn:hover .anim-preview-zoom { animation: previewZoom 0.5s ease; }
.anim-effect-btn:hover .anim-preview-bounce { animation: previewBounce 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.anim-effect-btn:hover .anim-preview-type { animation: previewType 0.5s steps(4); }

@keyframes previewFade { 0% { opacity: 0; } 100% { opacity: 1; } }
@keyframes previewSlideUp { 0% { transform: translateY(8px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
@keyframes previewSlideDown { 0% { transform: translateY(-8px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
@keyframes previewSlideLeft { 0% { transform: translateX(-8px); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }
@keyframes previewSlideRight { 0% { transform: translateX(8px); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }
@keyframes previewZoom { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes previewBounce { 0% { transform: scale(0.3); } 60% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes previewType { 0% { clip-path: inset(0 100% 0 0); } 100% { clip-path: inset(0 0 0 0); } }

/* Animation controls box (used by shapes) */
.anim-controls-box {
  background: rgba(0,0,0,0.15);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* =============================================
   BAR ANIMATION ICON PICKER (compact 3-col)
   ============================================= */
.bar-anim-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.bar-anim-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: rgba(0,0,0,0.2);
  border: 1.5px solid var(--border-color);
  border-radius: 6px;
  padding: 5px 3px 4px;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 0;
}
.bar-anim-btn:hover {
  border-color: rgba(99,102,241,0.5);
  background: rgba(99,102,241,0.06);
}
.bar-anim-btn.active {
  border-color: var(--primary);
  background: rgba(99,102,241,0.14);
  box-shadow: 0 0 0 1px var(--primary);
}
.bar-anim-icon {
  font-size: 1rem;
  line-height: 1;
  color: var(--text-muted);
  display: block;
  min-height: 18px;
}
.bar-anim-btn.active .bar-anim-icon { color: var(--primary); }
.bar-anim-btn:hover .bar-anim-icon { color: var(--text-main); }

.bar-anim-label {
  font-size: 0.55rem;
  color: var(--text-muted);
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}
.bar-anim-btn.active .bar-anim-label { color: var(--primary); }

/* =============================================
   ANIMATION ELEMENT CARDS (new inline design)
   ============================================= */
.anim-element-card {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.15);
  transition: border-color 0.2s;
}
.anim-element-card:not(.anim-card-off) {
  border-color: rgba(99, 102, 241, 0.35);
}

.anim-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: default;
  background: rgba(255, 255, 255, 0.02);
  gap: 8px;
}
.anim-card-off .anim-card-header {
  opacity: 0.65;
}

.anim-card-header-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
  color: var(--text-muted);
}
.anim-card-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.anim-card-off .anim-card-name {
  color: var(--text-muted);
}

.anim-rename-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  line-height: 1;
  flex-shrink: 0;
}
.anim-card-header:hover .anim-rename-btn {
  opacity: 1;
}
.anim-rename-btn:hover {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
}

.anim-card-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.anim-card-status {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: monospace;
  transition: background 0.2s, color 0.2s;
}
.anim-status-on {
  background: rgba(99, 102, 241, 0.18);
  color: var(--primary);
}
.anim-status-off {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

/* Card body — hidden by default, shown when ON */
.anim-card-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.25s;
  padding: 0 14px;
  opacity: 0;
  pointer-events: none;
}
.anim-card-chevron {
  transition: transform 0.3s ease;
}
.anim-card-chevron.rotate {
  transform: rotate(180deg);
}

.anim-card-body.anim-card-body-open {
  max-height: 600px;
  padding: 12px 14px 14px;
  opacity: 1;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border-color);
}

/* =============================================
   VIEWPORT AREA
   ============================================= */
.viewport-area {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; background-color: #0b0f19; position: relative;
}
.viewport-toolbar {
  height: 50px; border-bottom: 1px solid var(--border-color);
  background: rgba(9, 13, 22, 0.4);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
}
.toolbar-info {
  font-size: 0.85rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 8px;
}
.toolbar-controls { display: flex; align-items: center; gap: 12px; }

.zoom-controls {
  display: flex; align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color); border-radius: 6px; padding: 2px;
}
.zoom-btn {
  background: transparent; border: none; color: var(--text-muted);
  width: 26px; height: 26px; cursor: pointer; border-radius: 4px;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.zoom-btn:hover { color: var(--text-main); background: rgba(255, 255, 255, 0.05); }
.zoom-text { font-size: 0.8rem; font-weight: 600; width: 48px; text-align: center; }

/* Preview Canvas */
.canvas-workspace {
  flex: 1; padding: 40px; overflow: auto;
  display: flex; align-content: flex-start; align-items: flex-start; justify-content: center;
  background-color: #080b12;
  background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 0);
  background-size: 20px 20px;
}
.canvas-grid {
  display: flex; flex-wrap: wrap; gap: 32px; justify-content: center;
  transform-origin: top center; transition: transform 0.2s ease-out;
}

/* Preview Cards */
.preview-card {
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-color); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  overflow: hidden; display: flex; flex-direction: column;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.preview-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 12px 36px rgba(99, 102, 241, 0.1);
}

/* BUG 6 FIX: unified card-header styles */
.card-header {
  padding: 10px 14px; border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,0.02);
  flex-wrap: wrap; gap: 6px;
}
.card-title {
  font-size: 0.8rem; font-weight: 700; color: var(--text-main); font-family: var(--font-title);
  display: flex; align-items: center; gap: 6px;
}
.card-size {
  font-size: 0.72rem; color: var(--text-muted); font-family: monospace; font-weight: 400;
}

.preview-frame-container { background: #000; position: relative; overflow: hidden; }
.preview-frame { border: none; width: 100%; height: 100%; background: #000; display: block; }

.card-size-tag {
  font-size: 0.7rem; padding: 2px 6px; border-radius: 4px;
  background: rgba(16, 185, 129, 0.1); color: var(--success); font-weight: 700;
}
.card-size-tag.warning { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* =============================================
   CHECKLIST
   ============================================= */
.checklist-panel {
  display: flex; flex-direction: column; gap: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color); border-radius: 10px;
  padding: 16px; margin-top: 10px;
}
.checklist-title {
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted);
}
.checklist-item { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; }
.checklist-indicator {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted); flex-shrink: 0;
}
.checklist-indicator.pass { background: var(--success); box-shadow: 0 0 6px var(--success); }
.checklist-indicator.warn { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.checklist-indicator.danger { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.checklist-text { color: var(--text-main); }

/* =============================================
   MODAL
   ============================================= */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(9, 13, 22, 0.8); backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.modal-card {
  width: 480px; background: #0f172a;
  border: 1px solid var(--border-color); border-radius: 16px;
  padding: 28px; display: flex; flex-direction: column; gap: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-title { font-family: var(--font-title); font-size: 1.2rem; font-weight: 700; }
.modal-close {
  background: transparent; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1.4rem; line-height: 1;
  padding: 0; flex-shrink: 0;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--text-main); }
.modal-body { font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; }

.progress-bar-container {
  width: 100%; height: 8px;
  background: rgba(255,255,255,0.05); border-radius: 4px; overflow: hidden;
}
.progress-bar-fill {
  width: 0%; height: 100%;
  background: var(--primary-gradient); transition: width 0.2s ease;
}

/* =============================================
   SECTION DIVIDER & MISC
   ============================================= */
.section-divider {
  height: 1px; background: var(--border-color); margin: 4px 0;
}

/* =============================================
   TEMPLATES MODAL — Rich Banner Previews
   ============================================= */
.templates-modal-card {
  width: 780px;
  max-width: 92vw;
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.templates-modal-card .modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 16px 0 0 0;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  padding: 4px 2px 16px;
}

.template-card {
  background: rgba(0,0,0,0.2);
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  padding: 0;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.template-card:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(99,102,241,0.15);
}

/* Mini banner preview inside template card */
.template-banner-preview {
  width: 100%;
  aspect-ratio: 4/3;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px;
  overflow: hidden;
}

.tpl-preview-logo-bar {
  display: flex;
  align-items: center;
  gap: 5px;
}
.tpl-preview-logo-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.tpl-preview-logo-line {
  height: 3px; border-radius: 2px;
  background: rgba(255,255,255,0.15);
  width: 28px;
}

.tpl-preview-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 4px 0;
}
.tpl-preview-headline {
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.tpl-preview-subline {
  font-size: 0.52rem;
  line-height: 1.2;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tpl-preview-cta {
  font-size: 0.55rem;
  font-weight: 700;
  padding: 3px 7px;
  display: inline-block;
  align-self: flex-start;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-info {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.template-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}
.template-font-badge {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: monospace;
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 3px;
}
.template-meta {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 3px;
}
.template-layout-badge {
  font-size: 0.6rem;
  color: var(--primary);
  background: rgba(99,102,241,0.12);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
}
.template-card:hover .template-name { color: var(--primary); }

/* =============================================
   TEMPLATE HOVER ANIMATION SYSTEM
   Elements briefly disappear then animate in
   on hover — creating a live preview effect.
   ============================================= */

/* Keyframes */
@keyframes tplSlideUp   { from { opacity: 0; transform: translateY(7px); }   to { opacity: 1; transform: translateY(0); } }
@keyframes tplSlideDown { from { opacity: 0; transform: translateY(-7px); }  to { opacity: 1; transform: translateY(0); } }
@keyframes tplSlideLeft { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }
@keyframes tplSlideRight{ from { opacity: 0; transform: translateX(8px); }  to { opacity: 1; transform: translateX(0); } }
@keyframes tplZoom      { from { opacity: 0; transform: scale(0.65); }       to { opacity: 1; transform: scale(1); } }
@keyframes tplBounce    { 0% { opacity: 0; transform: scale(0.5); } 65% { opacity: 1; transform: scale(1.1); } 100% { opacity: 1; transform: scale(1); } }
@keyframes tplFade      { from { opacity: 0; }                                to { opacity: 1; } }

/* Shared timing properties on hover */
.template-card:hover .tpl-preview-logo-bar  { animation-duration: 0.32s; animation-delay: 0.00s; animation-fill-mode: both; }
.template-card:hover .tpl-preview-headline  { animation-duration: 0.36s; animation-delay: 0.10s; animation-fill-mode: both; }
.template-card:hover .tpl-preview-subline   { animation-duration: 0.36s; animation-delay: 0.20s; animation-fill-mode: both; }
.template-card:hover .tpl-preview-cta       { animation-duration: 0.36s; animation-delay: 0.30s; animation-fill-mode: both; }

/* slide-up */
.template-card:hover .tpl-anim-slide-up .tpl-preview-logo-bar,
.template-card:hover .tpl-anim-slide-up .tpl-preview-headline,
.template-card:hover .tpl-anim-slide-up .tpl-preview-subline,
.template-card:hover .tpl-anim-slide-up .tpl-preview-cta       { animation-name: tplSlideUp; animation-timing-function: ease; }

/* slide-left */
.template-card:hover .tpl-anim-slide-left .tpl-preview-logo-bar,
.template-card:hover .tpl-anim-slide-left .tpl-preview-headline,
.template-card:hover .tpl-anim-slide-left .tpl-preview-subline,
.template-card:hover .tpl-anim-slide-left .tpl-preview-cta     { animation-name: tplSlideLeft; animation-timing-function: ease; }

/* slide-right */
.template-card:hover .tpl-anim-slide-right .tpl-preview-logo-bar,
.template-card:hover .tpl-anim-slide-right .tpl-preview-headline,
.template-card:hover .tpl-anim-slide-right .tpl-preview-subline,
.template-card:hover .tpl-anim-slide-right .tpl-preview-cta    { animation-name: tplSlideRight; animation-timing-function: ease; }

/* slide-down */
.template-card:hover .tpl-anim-slide-down .tpl-preview-logo-bar,
.template-card:hover .tpl-anim-slide-down .tpl-preview-headline,
.template-card:hover .tpl-anim-slide-down .tpl-preview-subline,
.template-card:hover .tpl-anim-slide-down .tpl-preview-cta     { animation-name: tplSlideDown; animation-timing-function: ease; }

/* bounce */
.template-card:hover .tpl-anim-bounce .tpl-preview-logo-bar,
.template-card:hover .tpl-anim-bounce .tpl-preview-headline,
.template-card:hover .tpl-anim-bounce .tpl-preview-subline,
.template-card:hover .tpl-anim-bounce .tpl-preview-cta         { animation-name: tplBounce; animation-timing-function: cubic-bezier(0.175,0.885,0.32,1.28); }

/* zoom */
.template-card:hover .tpl-anim-zoom .tpl-preview-logo-bar,
.template-card:hover .tpl-anim-zoom .tpl-preview-headline,
.template-card:hover .tpl-anim-zoom .tpl-preview-subline,
.template-card:hover .tpl-anim-zoom .tpl-preview-cta           { animation-name: tplZoom; animation-timing-function: cubic-bezier(0.34,1.56,0.64,1); }

/* fade */
.template-card:hover .tpl-anim-fade .tpl-preview-logo-bar,
.template-card:hover .tpl-anim-fade .tpl-preview-headline,
.template-card:hover .tpl-anim-fade .tpl-preview-subline,
.template-card:hover .tpl-anim-fade .tpl-preview-cta           { animation-name: tplFade; animation-timing-function: ease; }

/* cascade (extra slow stagger) */
.template-card:hover .tpl-anim-cascade .tpl-preview-logo-bar   { animation-name: tplSlideUp; animation-delay: 0.00s; }
.template-card:hover .tpl-anim-cascade .tpl-preview-headline   { animation-name: tplSlideUp; animation-delay: 0.18s; }
.template-card:hover .tpl-anim-cascade .tpl-preview-subline    { animation-name: tplSlideUp; animation-delay: 0.36s; }
.template-card:hover .tpl-anim-cascade .tpl-preview-cta        { animation-name: tplSlideUp; animation-delay: 0.54s; }

/* Slideshow simulation */
@keyframes previewSlideShowFade {
  0%, 45% { opacity: 0; }
  50%, 95% { opacity: 1; }
  100% { opacity: 0; }
}
.template-card:hover .template-banner-preview.tpl-anim-fade .tpl-bg-layer-2 {
  animation: previewSlideShowFade 4s infinite;
}

/* =============================================
   TEMPLATE PREVIEW LAYOUT HELPERS
   ============================================= */
.tpl-preview-logo-bar.tpl-centered  { justify-content: center; }
.tpl-preview-content.tpl-centered   { align-items: center; }
.tpl-preview-cta.tpl-cta-center     { align-self: center; }
.tpl-preview-content.tpl-content-fill { flex: 1; justify-content: center; }

/* Bold/large headline variant (no-subline layout) */
.tpl-preview-headline.tpl-headline-lg {
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.2;
  -webkit-line-clamp: 3;
}

/* Large italic subline (no-headline layout) */
.tpl-preview-subline.tpl-subline-lg {
  font-size: 0.6rem;
  line-height: 1.35;
  -webkit-line-clamp: 3;
  opacity: 1 !important;
  font-style: italic;
}

/* Full-width CTA */
.tpl-preview-cta.tpl-cta-wide {
  width: 100%;
  text-align: center;
  box-sizing: border-box;
}

/* code tag in modalbody */
/* Brand name separator inside logo section */
.brand-name-group {
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Checklist panel spacing */
.checklist-panel + .checklist-panel {
  margin-top: 0; /* gap handles it from tab-panel flex */
}

/* Section divider (used inline in template tabs) */
.section-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

code {
  background: rgba(99,102,241,0.12);
  color: var(--primary);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: monospace;
}

/* =============================================
   VISUAL GRID PICKERS (BG SIZE, OVERLAY ETC.)
   ============================================= */
.visual-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 4px;
}
.visual-picker-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: rgba(0,0,0,0.2);
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 4px 6px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-color);
  min-width: 0;
}
.visual-picker-btn:hover {
  border-color: rgba(99,102,241,0.5);
  background: rgba(99,102,241,0.06);
}
.visual-picker-btn.active {
  border-color: var(--primary);
  background: rgba(99,102,241,0.12);
  box-shadow: 0 0 0 1px var(--primary);
}
.visual-picker-btn svg {
  width: 24px;
  height: 24px;
  stroke: var(--text-color);
  fill: none;
  stroke-width: 1.5;
}
.visual-picker-btn svg .outer-rect {
  stroke-dasharray: 2 2;
}
.visual-picker-btn.active svg {
  stroke: var(--primary);
}
.visual-picker-name {
  font-size: 0.65rem;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

/* =============================================
   ICON BUTTON GROUPS (ALIGN & POSITION)
   ============================================= */
.icon-btn-group {
  display: flex;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  padding: 2px;
  margin-top: 4px;
}
.icon-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}
.icon-btn:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-color);
}
.icon-btn.active {
  background: var(--primary);
  color: white;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* Detailed colors collapsible styling */
.form-group-mini {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.color-reset-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 4px;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, transform 0.2s;
}
.color-reset-btn:hover {
  color: var(--primary);
  transform: rotate(-45deg);
}
.collapsible-icon-mini.active {
  transform: rotate(180deg);
}

/* =============================================
   LAYERS PANEL
   ============================================= */
.layer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  transition: border-color 0.2s, background 0.2s;
}
.layer-item:hover {
  border-color: rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.05);
}
.layer-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.layer-icon {
  color: var(--text-muted);
  display: flex;
  align-items: center;
}
.layer-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}
.layer-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
}
.layer-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}
.layer-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.layer-item.dragging {
  opacity: 0.5;
  background: rgba(99, 102, 241, 0.2);
  border-style: dashed;
}

.layer-item.drag-over-top {
  border-top-color: var(--primary);
  border-top-width: 2px;
  background: rgba(255, 255, 255, 0.05);
}

.layer-item.drag-over-bottom {
  border-bottom-color: var(--primary);
  border-bottom-width: 2px;
  background: rgba(255, 255, 255, 0.05);
}

.layer-item {
  cursor: grab;
}

.layer-item:active {
  cursor: grabbing;
}
