/* Studio — Theme-aware Stylesheet
   Design system: Light/Dark themes, purple accent, Inter font
   Layout: 3-column CSS Grid (sidebar | main | settings panel) */

/* ── Reset + Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; line-height: 1.5; }
a { text-decoration: none; }
button { font-family: inherit; }

/* ── CSS Custom Properties — Light Theme (default) ──────── */
:root {
  --bg-base:        #F8F9FA;
  --bg-surface:     #FFFFFF;
  --bg-surface-2:   #F3F4F6;
  --bg-surface-3:   #E9EAEC;
  --bg-header:      #FFFFFF;
  --bg-sidebar:     #FFFFFF;
  --bg-panel:       #FFFFFF;
  --border:         #E5E7EB;
  --border-strong:  #D1D5DB;
  --text-primary:   #111827;
  --text-secondary: #374151;
  --text-muted:     #6B7280;
  --text-faint:     #9CA3AF;
  --accent:         #7C5CFF;
  --accent-hover:   #6D28D9;
  --accent-muted:   rgba(124,92,255,0.10);
  --accent-border:  rgba(124,92,255,0.30);
  --amber:          #7C5CFF;
  --amber-hover:    #6D28D9;
  --amber-muted:    rgba(124,92,255,0.10);
  --amber-border:   rgba(124,92,255,0.30);
  --green-bg:       #DCFCE7;
  --green-text:     #166534;
  --red-bg:         #FEE2E2;
  --red-text:       #991B1B;
  --blue-bg:        #DBEAFE;
  --blue-text:      #1E40AF;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg:      0 12px 32px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
  --radius-sm:      6px;
  --radius-md:      8px;
  --radius-lg:      12px;
  --radius-xl:      16px;
  --transition:     0.2s ease;
}

/* ── CSS Custom Properties — Dark Theme ─────────────────── */
html.dark {
  --bg-base:        #0A0A0B;
  --bg-surface:     #18181C;
  --bg-surface-2:   #111114;
  --bg-surface-3:   #1E1E23;
  --bg-header:      #0F0F12;
  --bg-sidebar:     #111114;
  --bg-panel:       #111114;
  --border:         #2D2D33;
  --border-strong:  #3D3D44;
  --text-primary:   #F1F1F4;
  --text-secondary: #D1D1D8;
  --text-muted:     #A1A1AA;
  --text-faint:     #6B7280;
  --accent:         #7C5CFF;
  --accent-hover:   #6D28D9;
  --accent-muted:   rgba(124,92,255,0.14);
  --accent-border:  rgba(124,92,255,0.40);
  --amber:          #7C5CFF;
  --amber-hover:    #A78BFA;
  --amber-muted:    rgba(124,92,255,0.14);
  --amber-border:   rgba(124,92,255,0.40);
  --green-bg:       rgba(20,83,45,0.6);
  --green-text:     #4ADE80;
  --red-bg:         rgba(127,29,29,0.6);
  --red-text:       #FCA5A5;
  --blue-bg:        rgba(30,58,95,0.6);
  --blue-text:      #60A5FA;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg:      0 12px 40px rgba(0,0,0,0.6);
}

/* ── CSS Custom Properties — Obsidian Theme (purple, default) ─
   Layered on top of html.dark: inherits accent/status colors,
   overrides only surfaces/borders/text/shadows for a premium
   purple-tinted dark. Selected via Settings → Appearance. */
html.dark.theme-obsidian {
  --bg-base:        #0A0812;
  --bg-surface:     #171227;
  --bg-surface-2:   #120E20;
  --bg-surface-3:   #221B3A;
  --bg-header:      #0C0918;
  --bg-sidebar:     #0C0918;
  --bg-panel:       #0C0918;
  --border:         #262042;
  --border-strong:  #342A57;
  --text-primary:   #F1EEFA;
  --text-secondary: #CFC9E4;
  --text-muted:     #A39CC2;
  --text-faint:     #6E6790;
  --accent-muted:   rgba(124,92,255,0.16);
  --accent-border:  rgba(124,92,255,0.42);
  --amber-muted:    rgba(124,92,255,0.16);
  --amber-border:   rgba(124,92,255,0.42);
  --shadow-sm:      0 1px 2px rgba(0,0,0,0.45);
  --shadow-md:      0 6px 18px rgba(0,0,0,0.5);
  --shadow-lg:      0 20px 55px rgba(0,0,0,0.7);
}

/* ── Base element styles ─────────────────────────────────── */
body { background: var(--bg-base); color: var(--text-primary); }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
.text-muted { color: var(--text-muted); }

/* ── Studio Layout (3-column grid) ───────────────────────── */
.studio-layout {
  display: grid;
  grid-template-columns: 220px 1fr 300px;
  min-height: 100vh;
}
@media (max-width: 1024px) {
  .studio-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.open {
    display: flex; position: fixed; top: 0; left: 0; z-index: 100;
    width: 220px;
    height: 100vh;            /* fallback for older browsers */
    height: 100dvh;           /* iOS: real visible height so bottom items are reachable */
    max-height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    box-shadow: var(--shadow-lg);
  }
  .settings-panel { display: none; }
  .user-name-label { display: none; }
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
/* Brand: P. logo + Studio */
.sidebar-brand {
  padding: 4px 16px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
/* P logo — matches Connect's connect_login.ejs:28-31 structure exactly.
   Dark gradient bg, white bold P, orange blinking dot (Connect uses green). */
.sidebar-p-logo {
  position: relative;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #1f2937, #111827);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-p-letter {
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
}
.sidebar-p-dot {
  position: absolute;
  bottom: 3px;
  right: 2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fb923c, #f59e0b);
  box-shadow: 0 0 4px rgba(251, 146, 60, 0.6);
  animation: dot-ping 1.8s infinite ease-in-out;
}
@keyframes dot-ping {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}
.sidebar-brand-text {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--accent);
  letter-spacing: -0.3px;
}
.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-md);
  color: var(--text-muted); font-size: 14px; font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.nav-item.active { background: var(--accent-muted); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-border); }
.nav-item.active svg { color: var(--accent); }
html.dark .nav-item.active { color: var(--accent); }
.nav-item.disabled { opacity: 0.4; pointer-events: none; }
.sidebar-bottom {
  border-top: 1px solid var(--border);
  padding: 12px 8px 0;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ── Main Content ────────────────────────────────────────── */
.main-content {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: 100vh;
}

/* ── Top Header ──────────────────────────────────────────── */
.top-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  height: 72px;
  min-height: 72px;      /* lock height */
  flex-shrink: 0;        /* never let the flex column compress the header on tall pages */
  border-bottom: 1px solid var(--border);
  background: var(--bg-header);
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.header-left { display: flex; align-items: center; gap: 14px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.hamburger {
  display: none; background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 4px; border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.hamburger:hover { color: var(--text-primary); }
@media (max-width: 1024px) { .hamburger { display: flex; } }

/* Header logo */
.header-logo { display: flex; align-items: center; text-decoration: none; color: inherit; gap: 8px; }
.header-logo-text {
  font-weight: 600; font-size: 15px;
  color: var(--text-primary);
  transition: color var(--transition);
}
.header-logo:hover .header-logo-text { color: var(--accent); }

/* Credit badge */
.credit-badge {
  display: flex; align-items: center; gap: 6px;
  background: var(--amber-muted);
  border: 1px solid var(--amber-border);
  padding: 5px 10px 5px 12px; border-radius: 20px;
  font-size: 13px; font-weight: 600; color: var(--amber);
  transition: background var(--transition);
}
.buy-credits-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--amber); color: #fff;
  border: none; cursor: pointer;
  font-size: 14px; font-weight: 700; line-height: 1;
  margin-left: 2px; transition: background var(--transition), transform var(--transition);
}
.buy-credits-btn:hover { background: var(--amber-hover); transform: scale(1.1); }

/* Launch promo banner — appears at the top of the dashboard for
   unfunded users. Auto-hidden by updateLaunchBanner() once the user
   funds their wallet (credits > 0). Uses the accent (purple) palette
   to match the "Buy credits" CTA on the same page. */
.launch-promo-banner {
  margin: 12px 20px 0;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--accent-muted);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.4;
}
.launch-promo-banner-content {
  display: flex; align-items: center; gap: 12px;
  justify-content: space-between; flex-wrap: wrap;
}
.launch-promo-banner-copy { flex: 1 1 auto; min-width: 240px; }
.launch-promo-banner-copy b { color: var(--accent); }
.launch-promo-banner-cta { flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 640px) {
  .launch-promo-banner { margin: 8px 12px 0; padding: 10px 12px; font-size: 13px; }
  .launch-promo-banner-content { gap: 8px; }
}

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 6px;
  cursor: pointer; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: border-color var(--transition), color var(--transition);
}
.theme-toggle:hover { border-color: var(--amber); color: var(--amber); }
.icon-moon { display: none; }
html.dark .icon-sun { display: none; }
html.dark .icon-moon { display: block; }

/* User avatar */
.user-avatar-wrap { position: relative; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  user-select: none;
}
.user-avatar:hover { box-shadow: 0 0 0 3px var(--accent-muted); }

/* User dropdown menu */
.user-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 180px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 200;
  animation: menuIn 0.15s ease-out;
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.user-menu-name {
  padding: 12px 14px 8px;
  font-size: 13px; font-weight: 600;
  color: var(--text-primary);
}
.user-menu-divider { height: 1px; background: var(--border); margin: 0; }
.user-menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer; width: 100%;
  background: none; border: none; text-align: left;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.user-menu-item:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.user-menu-logout { color: var(--text-muted); }
.user-menu-logout:hover { color: #EF4444; background: rgba(239,68,68,0.06); }

/* ── Prompt Composer ─────────────────────────────────────── */
.prompt-composer { padding: 24px 24px 32px; flex: 1; }
.prompt-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px 24px 32px;
  box-shadow: var(--shadow-sm);
  min-height: 320px;
}
.format-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary); padding: 8px 13px; border-radius: 12px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.chip svg { width: 15px; height: 15px; flex: none; }
.chip-meta { color: var(--text-faint); font-weight: 500; font-size: 12px; }
.chip:hover { border-color: var(--border-strong); color: var(--text-primary); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent); color: #fff;
}
.chip.active svg { color: #fff !important; }
.chip.active .chip-meta { color: rgba(255,255,255,0.85); }

.prompt-textarea {
  width: 100%;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px 16px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 14px; line-height: 1.6; resize: vertical;
  min-height: 120px;
  transition: border-color var(--transition);
}
.prompt-textarea:focus { outline: none; border-color: var(--accent); }
.prompt-textarea::placeholder { color: var(--text-faint); }
.prompt-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.meta-hint { font-size: 12px; color: var(--text-faint); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px; border-radius: var(--radius-md);
  font-size: 14px; font-weight: 600;
  border: none; cursor: pointer;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition);
}
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-hover)); color: #fff; box-shadow: 0 2px 12px var(--accent-muted); }
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 6px 20px var(--accent-border); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; filter: none; transform: none; }
.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-surface-2); color: var(--text-primary); border-color: var(--border-strong); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 26px; font-size: 15px; }

/* ── Scene Board ─────────────────────────────────────────── */
.scene-board { padding: 24px; flex: 1; }
.project-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 20px;
}
.project-title { font-size: 21px; font-weight: 700; color: var(--text-primary); }
.project-meta { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.meta-tag {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  padding: 2px 10px; border-radius: 12px;
  font-size: 12px; color: var(--text-muted);
}
.project-actions { display: flex; gap: 8px; }

/* Generation Progress */
.generation-progress {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 16px; margin-bottom: 20px;
}
.progress-info { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; color: var(--text-muted); }
.progress-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s ease; }

/* Scene Cards — Adaptive Layout */
.scenes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.scenes-grid.vertical-stack {
  display: flex; flex-direction: column; gap: 12px;
}

.scene-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.scene-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.scene-card[data-status="generating"] { border-color: var(--accent); }
.scene-card[data-status="completed"] { border-color: rgba(34,197,94,0.4); }
.scene-card[data-status="failed"] { border-color: rgba(239,68,68,0.4); }

/* Vertical stack layout */
.vertical-stack .scene-card {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  align-items: start;
}
.vertical-stack .scene-card-header { grid-column: 1 / -1; }
.vertical-stack .scene-preview {
  grid-row: 2; grid-column: 1;
  aspect-ratio: 16/9; max-height: 100px;
  border-radius: var(--radius-sm);
  margin: 8px 0 8px 12px;
}
.vertical-stack .scene-card-body { grid-row: 2; grid-column: 2; }
.vertical-stack .scene-card-actions { grid-row: 2; grid-column: 3; flex-direction: column; padding: 8px 12px; }

.scene-card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.scene-number { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.scene-duration { font-size: 12px; color: var(--text-faint); }
.scene-status {
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; text-transform: uppercase; letter-spacing: 0.5px;
}
.status-ready { background: var(--bg-surface-2); color: var(--text-muted); }
.status-queued { background: var(--blue-bg); color: var(--blue-text); }
.status-generating { background: var(--accent-muted); color: var(--accent); animation: pulse 1.5s infinite; }
.status-completed { background: var(--green-bg); color: var(--green-text); }
.status-failed { background: var(--red-bg); color: var(--red-text); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.scene-preview {
  aspect-ratio: 9/16; max-height: 200px;
  background: var(--bg-surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--border-strong); overflow: hidden;
}
.scene-preview video { width: 100%; height: 100%; object-fit: cover; }
.scene-preview .placeholder-icon { font-size: 40px; }

.scene-card-body { padding: 12px 16px; }
.scene-prompt-input {
  width: 100%; background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px;
  color: var(--text-primary);
  font-size: 12px; line-height: 1.5; resize: vertical; min-height: 60px;
  font-family: inherit;
  transition: border-color var(--transition);
}
.vertical-stack .scene-prompt-input { min-height: 40px; font-size: 13px; }
.scene-prompt-input:focus { outline: none; border-color: var(--accent); }
.scene-voiceover-input {
  width: 100%; background: transparent;
  border: none; border-bottom: 1px solid var(--border);
  padding: 6px 0; color: var(--text-muted);
  font-size: 12px; font-style: italic; margin-top: 8px;
  transition: border-color var(--transition);
}
.scene-voiceover-input:focus { outline: none; border-color: var(--accent); }
.scene-voiceover-input::placeholder { color: var(--text-faint); }
.scene-field-label {
  display: block; font-size: 11px; font-weight: 500;
  color: var(--text-faint); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.scene-onscreen-input {
  width: 100%; background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px;
  color: var(--accent); font-size: 13px;
  font-weight: 600; margin-bottom: 8px;
  font-family: inherit;
  transition: border-color var(--transition);
}
.scene-onscreen-input:focus { outline: none; border-color: var(--accent); }
.scene-onscreen-input::placeholder { color: var(--text-faint); font-weight: 400; }
.scene-options-toggle {
  display: block; width: 100%; margin-top: 8px; padding: 6px 0;
  background: none; border: none; color: var(--text-faint);
  font-size: 11px; font-weight: 500; cursor: pointer;
  text-align: left; letter-spacing: 0.3px; text-transform: uppercase;
  transition: color var(--transition);
}
.scene-options-toggle:hover { color: var(--text-muted); }
.scene-options {
  padding: 8px 0 0; border-top: 1px solid var(--border);
  margin-top: 8px; display: flex; flex-direction: column; gap: 6px;
}
.scene-checkbox {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted); cursor: pointer;
}
.scene-checkbox input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer;
}
.scene-card-actions {
  display: flex; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.scene-card-actions .btn { flex: 1; }

/* Scene Board Bottom Actions */
.scene-board-actions {
  display: flex; gap: 16px; justify-content: center;
  padding: 20px 0; border-top: 1px solid var(--border);
}

/* ── Final Movie ─────────────────────────────────────────── */
.final-movie { padding: 24px; }
.movie-player-container { max-width: 400px; margin: 0 auto; }
.video-player-full {
  width: 100%; border-radius: var(--radius-lg);
  background: var(--bg-surface-2);
  box-shadow: var(--shadow-md);
}
.movie-actions { display: flex; gap: 12px; justify-content: center; margin-top: 20px; }
.movie-meta { text-align: center; margin-top: 16px; color: var(--text-faint); font-size: 13px; }

/* ── Settings Panel (right rail) ─────────────────────────── */
.settings-panel {
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  padding: 24px 20px;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.settings-panel h3 {
  font-size: 11px; font-weight: 600;
  color: var(--text-faint); margin-bottom: 20px;
  text-transform: uppercase; letter-spacing: 0.8px;
}
.settings-panel h4 {
  font-size: 12px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 12px;
}
.setting-group { margin-bottom: 20px; }
.setting-group label {
  display: block; font-size: 11px; color: var(--text-faint);
  margin-bottom: 8px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px;
}
.select-input {
  width: 100%;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px;
  color: var(--text-primary); font-size: 13px;
  font-family: inherit;
  transition: border-color var(--transition);
}
.select-input:focus { outline: none; border-color: var(--accent); }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* Tier Selector */
.tier-selector { display: flex; flex-direction: column; gap: 8px; }
.tier-card {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 10px 12px; cursor: pointer;
  text-align: left; transition: border-color var(--transition), background var(--transition);
  display: block; width: 100%;
}
.tier-card:hover { border-color: var(--accent); }
.tier-card.active { border-color: var(--accent); background: var(--accent-muted); box-shadow: 0 0 0 1px var(--accent-border), var(--shadow-sm); }
.tier-card.disabled { opacity: 0.4; pointer-events: none; }
.tier-name { display: block; font-size: 13px; font-weight: 600; color: var(--text-primary); }
.tier-price { display: block; font-size: 16px; font-weight: 700; color: var(--accent); }
.tier-desc { display: block; font-size: 11px; color: var(--text-faint); }

/* Credits Panel */
.credits-panel { text-align: center; }
.credits-display { padding: 12px 0 16px; }
.credits-amount { display: block; font-size: 28px; font-weight: 700; color: var(--accent); }
.credits-label { font-size: 12px; color: var(--text-faint); }

/* Tips */
.tips-list { list-style: none; }
.tips-list li {
  font-size: 12px; color: var(--text-faint);
  padding: 4px 0 4px 14px; position: relative;
}
.tips-list li::before {
  content: ""; position: absolute; left: 0; top: 11px;
  width: 4px; height: 4px;
  background: var(--border-strong); border-radius: 50%;
}

/* ── Showcase Gallery ────────────────────────────────────── */
.showcase-page { padding: 24px; }
.showcase-header { margin-bottom: 24px; }
.showcase-header h2 { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.showcase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.showcase-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.showcase-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(139, 92, 246, 0.15);
  border-color: var(--accent);
}
.showcase-video {
  position: relative;
  width: 100%;
  aspect-ratio: 9/16;
  max-height: 360px;
  overflow: hidden;
  background: var(--bg-surface-3);
}
.showcase-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.showcase-play-icon {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.2s, transform 0.2s;
  backdrop-filter: blur(4px);
}
.showcase-card:hover .showcase-play-icon {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.8);
}
.showcase-info {
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.showcase-title {
  font-size: 14px; font-weight: 600; color: var(--text-primary);
}
.showcase-meta {
  font-size: 12px; color: var(--text-faint);
}
@media (max-width: 1024px) {
  .showcase-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
  .showcase-video { max-height: 280px; }
}

/* ── Recent Projects ─────────────────────────────────────── */
.recent-projects { margin-top: 32px; }
.recent-projects h3 {
  font-size: 15px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 16px;
}
.projects-grid { }

/* Projects list (table-style with thumbnail) */
.projects-list { width: 100%; }
.projects-list-header {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 96px 132px 74px 74px 88px 92px;
  gap: 14px; padding: 6px 16px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-faint); border-bottom: 1px solid var(--border);
  align-items: center;
}
/* PROMPT header flush-left, spanning the thumbnail column */
.projects-list-header .pl-col-thumb { display: none; }
.projects-list-header .pl-col-prompt { grid-column: 1 / 3; padding-left: 0; text-align: left; }
.projects-list-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 96px 132px 74px 74px 88px 92px;
  gap: 14px; padding: 10px 16px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  cursor: default;
}
.projects-list-row:hover { background: var(--bg-surface-2); }
.pl-col { font-size: 13px; color: var(--text-secondary); }
/* Thumbnail column */
.pl-col-thumb { width: 56px; height: 36px; flex-shrink: 0; }
.pl-thumb {
  width: 56px; height: 36px; border-radius: 4px; overflow: hidden;
  background: var(--bg-surface-3); display: flex; align-items: center; justify-content: center;
}
.pl-thumb video { width: 100%; height: 100%; object-fit: cover; }
.pl-thumb-placeholder {
  width: 56px; height: 36px; border-radius: 4px;
  background: var(--bg-surface-3); display: flex; align-items: center; justify-content: center;
}
.pl-thumb-placeholder svg { width: 18px; height: 18px; color: var(--text-faint); }
/* Prompt column */
.pl-col-prompt { overflow: hidden; min-width: 0; }
.pl-prompt-text {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 13px; color: var(--text-primary); line-height: 1.5;
}
.pl-tier-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600; text-transform: capitalize;
  background: var(--accent-muted); color: var(--accent);
}
.pl-col-date { font-size: 12px; color: var(--text-faint); text-align: right; }
.pl-col-duration { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; text-align: right; }
.pl-col-size { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; text-align: right; }
.pl-col-actions { display: flex; gap: 6px; justify-content: flex-end; }
.btn-xs { padding: 4px 6px; font-size: 11px; border-radius: 4px; }
@media (max-width: 1024px) {
  .projects-list-header { display: none; }
  .projects-list-row {
    grid-template-columns: 56px 1fr auto;
    grid-template-rows: auto auto;
  }
  .pl-col-prompt { grid-column: 2 / -1; }
  .pl-col-tier, .pl-col-date, .pl-col-duration, .pl-col-size { display: none; }
  .pl-col-actions { grid-column: 2 / -1; }
}

/* Pagination */
.pl-pagination {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 12px 4px; margin-top: 8px;
  border-top: 1px solid var(--border);
}
.pl-page-info { font-size: 12px; color: var(--text-faint); }
.pl-page-buttons { display: flex; align-items: center; gap: 8px; }
.pl-page-num { font-size: 12px; color: var(--text-muted); min-width: 80px; text-align: center; }
.pl-page-buttons .btn-xs { display: flex; align-items: center; gap: 4px; }
.pl-page-buttons .btn-xs:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Toast ────────────────────────────────────────────────── */
#toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 1000; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500;
  animation: slideIn 0.25s ease-out;
  pointer-events: auto;
  box-shadow: var(--shadow-md);
}
.toast-success { background: var(--green-bg); color: var(--green-text); }
.toast-error { background: var(--red-bg); color: var(--red-text); }
.toast-info { background: var(--blue-bg); color: var(--blue-text); }
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Loading Overlay ─────────────────────────────────────── */
#loading-overlay {
  position: fixed; inset: 0;
  background: rgba(10,10,11,0.85);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 999; backdrop-filter: blur(4px);
}
html:not(.dark) #loading-overlay { background: rgba(248,249,250,0.85); }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { margin-top: 16px; color: var(--text-muted); font-size: 14px; }

/* ── Modal (Billing) ─────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 20px;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 28px;
  width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.modal-header h3 { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-faint); padding: 4px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: color var(--transition), background var(--transition);
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-surface-2); }
.modal-sub { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }
.modal-note { font-size: 12px; color: var(--text-faint); text-align: center; margin-top: 16px; }

/* Billing tier cards */
.billing-tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 480px) { .billing-tiers { grid-template-columns: 1fr; } }
.billing-tier-card {
  background: var(--bg-surface-2);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 12px;
  cursor: pointer; text-align: center;
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  position: relative;
}
.billing-tier-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
  transform: translateY(-2px);
}
.billing-tier-featured {
  border-color: var(--accent);
  background: var(--accent-muted);
}
.billing-tier-badge {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 2px 10px; border-radius: 10px;
  text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap;
}
.billing-tier-name { font-size: 14px; font-weight: 700; color: var(--text-primary); margin-top: 6px; }
.billing-tier-price { font-size: 24px; font-weight: 800; color: var(--accent); }
.billing-tier-credits { font-size: 12px; font-weight: 600; color: var(--amber); }
.billing-tier-desc { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

/* ── Auth page styles ────────────────────────────────────── */
.auth-container { width: 100%; max-width: 400px; padding: 20px; }
.auth-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 32px;
  background: var(--bg-surface);
  box-shadow: var(--shadow-md);
}
.auth-tabs {
  display: flex; gap: 0; margin-bottom: 20px;
  border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden;
}
.auth-tab {
  flex: 1; padding: 10px; background: transparent;
  border: none; color: var(--text-muted);
  font-size: 14px; font-weight: 500; cursor: pointer; font-family: inherit;
  transition: background var(--transition), color var(--transition);
}
.auth-tab.active { background: var(--amber); color: #fff; }
.auth-error { color: #EF4444; font-size: 13px; text-align: center; margin-top: 12px; display: none; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 4px 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.auth-divider span { font-size: 11px; color: var(--text-faint); text-transform: uppercase; }
.btn-social {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 12px 16px; border-radius: 10px;
  font-size: 14px; font-weight: 600; border: none; cursor: pointer;
  font-family: inherit; background: #111827; color: #fff;
  transition: opacity var(--transition);
}
.btn-social:hover { opacity: 0.9; }
.btn-social-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-social-outline:hover { border-color: var(--amber); }
.btn-guest {
  background: none; border: none; color: var(--text-faint);
  font-size: 14px; cursor: pointer; padding: 8px; font-family: inherit;
  transition: color var(--transition);
}
.btn-guest:hover { color: var(--amber); }
.btn-back {
  display: block; width: 100%; margin-top: 12px; padding: 8px;
  background: none; border: none; color: var(--text-faint);
  font-size: 13px; cursor: pointer; font-family: inherit; text-align: center;
}
.btn-back:hover { color: var(--amber); }

/* ── Settings Page ───────────────────────────────────────── */
.settings-page-content { padding: 32px 40px; flex: 1; max-width: 680px; }
.settings-page-header { margin-bottom: 32px; }
.settings-page-header h2 { font-size: 24px; font-weight: 700; color: var(--text-primary); }
.settings-page-header p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.settings-sections { display: flex; flex-direction: column; gap: 20px; }
.settings-section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px;
  box-shadow: var(--shadow-sm);
}
.settings-section-card h3 {
  font-size: 13px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 16px;
  text-transform: uppercase; letter-spacing: 0.6px;
}
.settings-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row label { font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.settings-value { font-size: 14px; color: var(--text-muted); }

/* ── Landing page nav ────────────────────────────────────── */
.landing-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 40px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-header);
  position: sticky; top: 0; z-index: 50;
}
.nav-links { display: flex; gap: 16px; align-items: center; }
.nav-links a { font-size: 14px; color: var(--text-muted); transition: color var(--transition); }
.nav-links a:hover { color: var(--text-primary); }
.logo-text { font-size: 16px; font-weight: 700; color: var(--text-primary); }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Mobile & Tablet
   Progressive enhancement: desktop layout is the base;
   these queries simplify for smaller screens.
   DO NOT change desktop styles above — only add overrides.
   ═══════════════════════════════════════════════════════════ */

/* Sidebar backdrop overlay (created by JS toggleSidebar) */
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; z-index: 99;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);
  opacity: 0; transition: opacity 0.2s;
}
.sidebar-backdrop.visible { display: block; opacity: 1; }

/* ── Tablet (768–1024px) ────────────────────────────────── */
@media (max-width: 1024px) {
  /* Settings panel moves below main content instead of disappearing */
  .settings-panel {
    display: block !important;
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 16px;
    max-height: none;
  }
  .studio-layout {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto 1fr auto;
  }
}

/* ── Mobile (<768px) ────────────────────────────────────── */
@media (max-width: 768px) {
  /* Layout: single column, full width */
  .studio-layout { grid-template-columns: 1fr !important; }

  /* Sidebar: slide-over overlay */
  .sidebar {
    position: fixed !important; top: 0; left: -260px;
    width: 260px; z-index: 100;
    height: 100vh;            /* fallback for older browsers */
    height: 100dvh;           /* iOS: real visible height */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    transition: left 0.25s ease;
    box-shadow: none;
  }
  .sidebar.open {
    left: 0; display: flex !important;
    box-shadow: var(--shadow-lg);
  }

  /* Header: compact */
  .top-header { height: 56px; padding: 0 12px; }
  .credit-badge { font-size: 12px; padding: 4px 10px; }
  .buy-credits-btn { width: 22px; height: 22px; font-size: 14px; }
  .user-name-label { display: none !important; }
  .user-avatar { width: 32px; height: 32px; }

  /* Prompt composer: full width, bigger tap targets */
  .prompt-composer { padding: 16px; }
  .prompt-card { padding: 16px; min-height: auto; }
  .format-chips { overflow-x: auto; flex-wrap: nowrap; gap: 6px; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .chip { white-space: nowrap; flex-shrink: 0; padding: 8px 14px; min-height: 44px; display: flex; align-items: center; }
  .composer-area, .prompt-textarea { font-size: 16px; /* prevents iOS zoom on focus */ }

  /* Buttons: full width, touch-friendly (44px min) */
  .prompt-card .btn-primary,
  .prompt-card .btn { width: 100%; min-height: 44px; font-size: 15px; }

  /* Scene cards: single column stack */
  .scenes-grid { grid-template-columns: 1fr !important; }
  .scene-card-actions { flex-direction: column; }
  .scene-card-actions .btn { width: 100%; min-height: 44px; }
  .scene-prompt-input { font-size: 16px; }

  /* Video player: viewport-constrained */
  .final-video-wrap video,
  .scene-preview video { max-width: 100%; height: auto; }
  .final-actions { flex-direction: column; gap: 8px; }
  .final-actions .btn { width: 100%; min-height: 44px; }

  /* Settings panel: below main, compact */
  .settings-panel {
    display: block !important; border-left: none;
    border-top: 1px solid var(--border);
    padding: 12px 16px;
  }
  .setting-group select,
  .setting-group .seg { width: 100%; }
  .tier-card { min-height: 44px; }

  /* Recent projects: simplified columns */
  .projects-list-header { display: none; }
  .projects-list-row {
    grid-template-columns: 48px 1fr auto !important;
    gap: 8px; padding: 10px 8px;
  }
  .pl-col-tier, .pl-col-status, .pl-col-duration, .pl-col-size, .pl-col-date { display: none; }
  .pl-col-prompt { grid-column: 2; }
  .pl-col-actions { grid-column: 3; }
  .pl-thumb, .pl-thumb-placeholder { width: 48px; height: 32px; }
  .pl-prompt-text { font-size: 13px; -webkit-line-clamp: 1; }
  .pl-pagination { flex-direction: column; gap: 8px; align-items: stretch; }
  .pl-page-buttons { display: flex; justify-content: space-between; }

  /* Showcase gallery: single column */
  .showcase-grid { grid-template-columns: 1fr !important; }

  /* Modals: full-width on mobile */
  .modal-box { width: 95vw; max-width: none; margin: 16px; }
  .billing-tiers { grid-template-columns: 1fr !important; }

  /* Toast: full width */
  #toast-container { left: 12px; right: 12px; }
  .toast { max-width: none; }
}

/* ── Small phones (<400px) ──────────────────────────────── */
@media (max-width: 400px) {
  .top-header { gap: 6px; }
  .credit-badge { font-size: 11px; padding: 3px 8px; }
  .hamburger svg { width: 20px; height: 20px; }
  .format-chips .chip { font-size: 12px; padding: 6px 10px; }
}

/* ── Appearance theme picker (Settings → Appearance) ─────── */
.theme-options { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-option {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 10px 12px; min-width: 84px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted); font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: border-color var(--transition), color var(--transition), box-shadow var(--transition);
}
.theme-option:hover { border-color: var(--border-strong); color: var(--text-primary); }
.theme-option.selected { border-color: var(--accent); color: var(--text-primary); box-shadow: 0 0 0 1px var(--accent-border); }
.theme-swatch { width: 100%; height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.theme-swatch-light    { background: linear-gradient(135deg, #FFFFFF, #E9EAEC); }
.theme-swatch-dark     { background: linear-gradient(135deg, #0A0A0B, #1E1E23); }
.theme-swatch-obsidian { background: linear-gradient(135deg, #171130, #6845D6); }

/* ── Premium polish (visual only) ────────────────────────── */
.projects-list-row { padding-top: 10px; padding-bottom: 10px; }
.pl-tier-badge { text-transform: capitalize; letter-spacing: 0.2px; }
.prompt-card { box-shadow: var(--shadow-md); }
::selection { background: var(--accent-muted); color: var(--text-primary); }
html.dark * { scrollbar-width: thin; scrollbar-color: var(--bg-surface-3) transparent; }
html.dark ::-webkit-scrollbar { width: 10px; height: 10px; }
html.dark ::-webkit-scrollbar-track { background: transparent; }
html.dark ::-webkit-scrollbar-thumb { background: var(--bg-surface-3); border-radius: 8px; border: 2px solid var(--bg-base); }
html.dark ::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ── Automation (UI placeholder — hidden until backend ready) ─
   Markup + Studio-team notes live in views/dashboard.ejs (#automation-card).
   Presentation only; the toggle is disabled and unwired. */
.automation-card {
  margin: 0 24px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.automation-card[hidden] { display: none; }   /* keep hidden even with the styles above */
.automation { display: flex; align-items: center; gap: 16px; }
.auto-icon {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  background: var(--accent-muted); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.auto-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.auto-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.auto-steps { display: flex; align-items: center; gap: 18px; margin-left: auto; color: var(--text-faint); font-size: 12px; }
.auto-steps span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.auto-steps b { color: var(--text-muted); font-weight: 600; }
.switch { position: relative; width: 44px; height: 25px; flex: none; cursor: not-allowed; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--bg-surface-3); border: 1px solid var(--border); border-radius: 999px; transition: background var(--transition); }
.switch .track::before { content: ""; position: absolute; width: 19px; height: 19px; left: 3px; top: 2px; background: #fff; border-radius: 50%; transition: transform var(--transition); box-shadow: var(--shadow-sm); }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::before { transform: translateX(19px); }
@media (max-width: 700px) {
  .automation { flex-wrap: wrap; }
  .auto-steps { margin-left: 0; width: 100%; flex-wrap: wrap; gap: 10px; }
}

/* ── Guided tour (Help & Docs → startTour) ───────────────── */
.tour-overlay { position: fixed; inset: 0; z-index: 900; display: none; pointer-events: none; }
.tour-overlay.is-open { display: block; }
.tour-ring {
  position: fixed; border-radius: 12px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.62), 0 0 0 2px var(--accent);
  transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease;
}
.tour-tooltip {
  position: fixed; z-index: 901; display: none;
  width: 320px; max-width: calc(100vw - 24px);
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 16px 18px;
}
.tour-tooltip.is-open { display: block; animation: fadeIn .2s ease; }
.tour-step { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); }
.tour-tooltip h4 { font-size: 15px; font-weight: 700; color: var(--text-primary); margin: 6px 0; }
.tour-tooltip p { font-size: 13px; color: var(--text-muted); line-height: 1.55; }
.tour-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.tour-nav { display: flex; gap: 8px; }
.tour-skip { background: none; border: none; color: var(--text-faint); font-size: 13px; cursor: pointer; font-family: inherit; }
.tour-skip:hover { color: var(--text-muted); }
.tour-back {
  background: var(--bg-surface-2); border: 1px solid var(--border); color: var(--text-secondary);
  padding: 7px 14px; border-radius: var(--radius-md); font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.tour-back:hover { border-color: var(--border-strong); color: var(--text-primary); }
.tour-next {
  background: var(--accent); border: none; color: #fff;
  padding: 7px 16px; border-radius: var(--radius-md); font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.tour-next:hover { background: var(--accent-hover); }
/* "Take a tour" launcher in the composer */
.prompt-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tour-launch { color: var(--accent); }
.tour-launch:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-muted); }

/* ── Help & FAQ page (accordion) ─────────────────────────── */
.faq-page { padding: 32px 40px; flex: 1; max-width: 760px; }
.faq-head { margin-bottom: 28px; }
.faq-head h2 { font-size: 24px; font-weight: 700; color: var(--text-primary); }
.faq-head p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.faq-list { display: flex; flex-direction: column; gap: 10px; }
.faq-item {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  transition: border-color var(--transition);
}
.faq-item[open] { border-color: var(--accent-border); }
.faq-item summary {
  list-style: none; cursor: pointer; padding: 16px 18px;
  font-size: 15px; font-weight: 600; color: var(--text-primary);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: ""; width: 9px; height: 9px; flex: none; margin-right: 2px;
  border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg); transition: transform var(--transition);
}
.faq-item[open] summary { color: var(--accent); }
.faq-item[open] summary::after { transform: rotate(-135deg); border-color: var(--accent); }
.faq-a { padding: 0 18px 18px; font-size: 14px; color: var(--text-muted); line-height: 1.6; }
.faq-a b { color: var(--text-secondary); font-weight: 600; }
@media (max-width: 768px) { .faq-page { padding: 24px 16px; } }
