/* ── Reset & tokens ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; top: -40px; left: 0; padding: 8px 16px; background: var(--bg); color: var(--text); border: 1px solid var(--text); z-index: 9999; text-decoration: none; font-size: 14px; }
.skip-link:focus { top: 0; }

:root {
  /* Depth through layering — no gradients, no heavy shadows */
  --bg:       #0b0c10;
  --surface:  #111318;
  --surface2: #1a1d25;
  --border:   #2a2f3a;

  /* Accent — Babble teal-blue */
  --accent:       #45b8e3;
  --accent-hover: #2f9dc7;
  --accent-tint:  rgba(69,184,227,.12);  /* active row background */
  --accent-tint2: rgba(69,184,227,.15);  /* badges / source-badge */

  /* Semantic */
  --success: #5bd6a0;
  --danger:  #ff8a8a;
  --warning: #ffcf6b;
  --success-tint: rgba(91,214,160,.12);
  --danger-tint:  rgba(255,138,138,.12);

  /* Text */
  --text:           #e6e8ec;
  --text-muted:     #9aa3b2;
  --text-faint:     #8b90a0;
  --text-secondary: #6b7585;

  /* Type — Inter for body, Space Grotesk for headings */
  --font:         'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Space Grotesk', system-ui, sans-serif;
  --mono:         'Space Mono', ui-monospace, monospace;

  /* Shape */
  --radius:    8px;
  --radius-sm: 5px;
  --radius-xs: 3px;

  /* Theme-sensitive helpers */
  --sidebar-border:    rgba(255,255,255,.08);
  --hover-overlay:     rgba(255,255,255,.06);
  --card-hover:        rgba(69,184,227,.04);
  --surface3-hover:    #252a35;
  --input-bg:          #111318;
  --input-border:      #2a2f3a;
  --input-autofill-bg: #111318;
  --login-panel-bg:    #000;
  --login-hero-bg:     #0a0c10;
  --divider-line:      #1e2330;
  --divider-text:      #4a5162;
  --overlay-bg:        rgba(0,0,0,.55);
  --modal-overlay-bg:  rgba(10,12,16,.92);
  --plan-card-hover:   rgba(255,255,255,.18);
  --demo-row-bg:       rgba(255,255,255,.04);
  --demo-row-border:   rgba(255,255,255,.07);
  --demo-row-active-bg:     rgba(69,184,227,.08);
  --demo-row-active-border: rgba(69,184,227,.35);
  --editor-tab-active-bg:    #0d5c5a;
  --editor-tab-active-border:#0d7a78;
  --editor-tab-active-text:  #c8f5f3;
  --btn-editor-open-bg:      #0d7a78;
  --btn-editor-open-text:    #e0faf9;
  --btn-editor-open-hover:   #0a6160;

  --sidebar-w: 248px;
  --df-gradient: linear-gradient(120deg, #00a8e8 0%, #7c3aed 50%, #e8198c 100%);
}

/* ── Shared light-mode token overrides ── */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --_light: 1; }
}
:root[data-theme="light"] { --_light: 1; }

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:       #f4f5f8;
    --surface:  #ffffff;
    --surface2: #eef0f5;
    --border:   #d0d5e3;
    --accent:       #0891b2;
    --accent-hover: #0e7490;
    --accent-tint:  rgba(8,145,178,.1);
    --accent-tint2: rgba(8,145,178,.15);
    --success: #16a34a;
    --danger:  #dc2626;
    --warning: #d97706;
    --success-tint: rgba(22,163,74,.1);
    --danger-tint:  rgba(220,38,38,.1);
    --text:           #0f172a;
    --text-muted:     #565e6e;
    --text-faint:     #9ca3af;
    --text-secondary: #6b7280;
    --sidebar-border:    rgba(0,0,0,.08);
    --hover-overlay:     rgba(0,0,0,.04);
    --card-hover:        rgba(8,145,178,.04);
    --surface3-hover:    #e4e7ef;
    --input-bg:          #ffffff;
    --input-border:      #d0d5e3;
    --input-autofill-bg: #ffffff;
    --login-panel-bg:    #f4f5f8;
    --login-hero-bg:     #eef0f5;
    --divider-line:      #d0d5e3;
    --divider-text:      #9ca3af;
    --overlay-bg:        rgba(15,23,42,.4);
    --modal-overlay-bg:  rgba(15,23,42,.6);
    --plan-card-hover:   rgba(0,0,0,.12);
    --demo-row-bg:       rgba(0,0,0,.03);
    --demo-row-border:   rgba(0,0,0,.08);
    --demo-row-active-bg:     rgba(8,145,178,.08);
    --demo-row-active-border: rgba(8,145,178,.35);
    --editor-tab-active-bg:    #0891b2;
    --editor-tab-active-border:#0e7490;
    --editor-tab-active-text:  #ffffff;
    --btn-editor-open-bg:      #0891b2;
    --btn-editor-open-text:    #ffffff;
    --btn-editor-open-hover:   #0e7490;
  }
}

:root[data-theme="light"] {
  --bg:       #f4f5f8;
  --surface:  #ffffff;
  --surface2: #eef0f5;
  --border:   #d0d5e3;
  --accent:       #0891b2;
  --accent-hover: #0e7490;
  --accent-tint:  rgba(8,145,178,.1);
  --accent-tint2: rgba(8,145,178,.15);
  --success: #16a34a;
  --danger:  #dc2626;
  --warning: #d97706;
  --success-tint: rgba(22,163,74,.1);
  --danger-tint:  rgba(220,38,38,.1);
  --text:           #0f172a;
  --text-muted:     #565e6e;
  --text-faint:     #9ca3af;
  --text-secondary: #6b7280;
  --sidebar-border:    rgba(0,0,0,.08);
  --hover-overlay:     rgba(0,0,0,.04);
  --card-hover:        rgba(8,145,178,.04);
  --surface3-hover:    #e4e7ef;
  --input-bg:          #ffffff;
  --input-border:      #d0d5e3;
  --input-autofill-bg: #ffffff;
  --login-panel-bg:    #f4f5f8;
  --login-hero-bg:     #eef0f5;
  --divider-line:      #d0d5e3;
  --divider-text:      #9ca3af;
  --overlay-bg:        rgba(15,23,42,.4);
  --modal-overlay-bg:  rgba(15,23,42,.6);
  --plan-card-hover:   rgba(0,0,0,.12);
  --demo-row-bg:       rgba(0,0,0,.03);
  --demo-row-border:   rgba(0,0,0,.08);
  --demo-row-active-bg:     rgba(8,145,178,.08);
  --demo-row-active-border: rgba(8,145,178,.35);
  --editor-tab-active-bg:    #0891b2;
  --editor-tab-active-border:#0e7490;
  --editor-tab-active-text:  #ffffff;
  --btn-editor-open-bg:      #0891b2;
  --btn-editor-open-text:    #ffffff;
  --btn-editor-open-hover:   #0e7490;
}

:root[data-theme="dark"] {
  --bg:       #0b0c10;
  --surface:  #111318;
  --surface2: #1a1d25;
  --border:   #2a2f3a;
  --accent:       #45b8e3;
  --accent-hover: #2f9dc7;
  --accent-tint:  rgba(69,184,227,.12);
  --success: #5bd6a0;
  --danger:  #ff8a8a;
  --warning: #ffcf6b;
  --text:           #e6e8ec;
  --text-muted:     #9aa3b2;
  --text-faint:     #8b90a0;
  --text-secondary: #6b7585;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* ── App shell (sidebar + content flex row) ─────────────────────────── */
#app-shell {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */
#app-header {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
}

/* Force btn-back invisible — it lives in DOM for JS compat only */
#btn-back { display: none !important; }

.sidebar-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 20px 14px 16px;
}

/* Brand area (non-interactive, matches Babble DFLockup+ProductWordmark div) */
.sidebar-brand-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding: 0 0 4px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: var(--text);
}

/* DFLockup: mark + "Deep Fusion" text block */
.sidebar-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 20px;
  width: 100%;
  min-width: 0;
}
.sidebar-df-mark { flex-shrink: 0; }
.sidebar-df-text { min-width: 0; }

.sidebar-brand-label {
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-heading);
  color: var(--text);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand-tagline {
  font-size: 8.5px;
  font-family: var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ProductWordmark: app name in DF gradient */
.sidebar-app-name {
  display: block;
  padding: 0 12px 0;
  font-size: 26px;
  font-weight: 700;
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  background: var(--df-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sidebar-app-sub {
  display: block;
  padding: 4px 12px 14px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.sidebar-script-title {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  margin-top: 2px;
}
.sidebar-script-title:empty { display: none; }

/* Navigation sections */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-nav-label {
  font-size: 11px;
  font-weight: 400;
  font-family: var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 8px 12px 6px;
  margin: 0;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-faint);
  width: 100%;
  min-width: 0;
  max-width: 100%;
  text-align: left;
  transition: background .12s, color .12s;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-nav-item:hover {
  background: var(--hover-overlay);
  color: var(--text-muted);
}
.sidebar-nav-item.active {
  background: rgba(69,184,227,.12);
  color: var(--accent);
  font-weight: 500;
  border-radius: 10px;
}
.sidebar-nav-item.active .sidebar-nav-icon { color: var(--accent); }

.sidebar-nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-faint);
  transition: color .12s;
}
.sidebar-nav-item:hover .sidebar-nav-icon { color: var(--text-muted); }

/* Sidebar footer */
.sidebar-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 8px 12px;
}

.sidebar-usage-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-usage-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.sidebar-usage-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.sidebar-usage-count {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.sidebar-usage-count.low  { color: var(--warning); }
.sidebar-usage-count.none { color: var(--danger); }
.sidebar-usage-meter {
  height: 3px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}
.sidebar-usage-fill {
  display: block;
  height: 100%;
  background: var(--df-gradient);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.sidebar-usage-fill.low  { background: var(--warning); }
.sidebar-usage-fill.none { background: var(--danger); }
.sidebar-usage-topup {
  font-size: 12px;
  color: var(--danger);
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
  transition: opacity .15s;
}
.sidebar-usage-topup:hover { opacity: .75; }

.sidebar-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px;
  margin-top: 2px;
}

.sidebar-logout-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-muted);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}
.sidebar-logout-btn:hover { color: var(--text); background: var(--hover-overlay); }

.sidebar-settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}
.sidebar-settings-btn:hover { color: var(--text); background: var(--hover-overlay); }

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  display: inline-block;
  transition: background .3s;
}
.status-dot.ok    { background: var(--success); }
.status-dot.error { background: var(--danger); }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
  text-decoration: none;
  background: var(--surface2);
  color: var(--text);
}
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); }

.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--surface2); border-color: transparent; }

.btn-icon {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 18px; line-height: 1;
  padding: 4px 8px; border-radius: var(--radius-sm);
  transition: color .15s;
}
.btn-icon:hover { color: var(--text); }

.btn-xs {
  padding: 4px 9px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

/* ── List view ───────────────────────────────────────────────────────── */
#list-view {
  flex: 1;
  padding: 48px 40px;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Header row */
.lv-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
}
.lv-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.lv-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.lv-upload-btn { font-size: 13px; }

/* Script cards list */
.scripts-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
  margin-bottom: 12px;
}
.scripts-list .script-card:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}
.scripts-list .script-card:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
  border-bottom: none;
}
.scripts-list .script-card:only-child {
  border-radius: var(--radius);
}
.scripts-list:empty { display: none; }

.script-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.script-card:last-child { border-bottom: none; }
.script-card:hover { background: var(--card-hover); }

.script-card-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.script-card-body {
  flex: 1;
  min-width: 0;
}
.script-card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  padding: 0;
  text-align: left;
  width: 100%;
  display: block;
}
.script-card-title:hover { color: var(--accent); }

.script-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}
.script-card-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}
.script-card-dot.analysing {
  background: var(--accent);
  animation: dot-blink 1.2s ease-in-out infinite;
}
.script-card-status {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}
.script-card-scenes {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--mono);
}

.script-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-open-editor {
  font-size: 12px;
  font-weight: 600;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  background: var(--btn-editor-open-bg);
  color: var(--btn-editor-open-text);
  font-family: inherit;
  transition: background .12s;
  white-space: nowrap;
}
.btn-open-editor:hover { background: var(--btn-editor-open-hover); }

.btn-card-more {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  position: relative;
  transition: background .12s, color .12s;
}
.btn-card-more:hover { background: var(--surface2); color: var(--text); }

/* Kebab / more menu */
.card-menu-wrap { position: relative; }
.card-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 0;
  min-width: 120px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.card-menu button {
  display: block;
  width: 100%;
  padding: 7px 14px;
  text-align: left;
  font-size: 13px;
  font-family: inherit;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.card-menu button:hover { background: var(--surface2); }
.card-menu button.danger { color: var(--danger); }

/* Drop zone */
.lv-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-top: 4px;
}
.lv-dropzone:hover,
.lv-dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--text);
}
.lv-dropzone strong { color: var(--text); font-weight: 600; }

/* Empty state inside list */
.lv-empty {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.lv-onboard {
  max-width: 640px;
  margin: 24px auto;
  padding: 0 16px;
}
.lv-onboard-title { font-size: 18px; margin: 0 0 6px; }
.lv-onboard-lead { color: var(--text-muted); font-size: 14px; margin: 0 0 16px; }
.lv-onboard-steps {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.5;
}
.lv-onboard-steps li { margin-bottom: 10px; }
.lv-onboard-steps li::marker { color: var(--accent); font-weight: 600; }

/* Keep toolbar label for compat */
.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.list-toolbar h2 { font-size: 18px; font-weight: 600; }

/* ── Upload progress ─────────────────────────────────────────────────── */
.upload-progress {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.upload-progress[hidden] { display: none; }
.upload-progress-bar {
  flex: 1; height: 3px; background: var(--border); border-radius: 2px;
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%; width: 0%; background: var(--accent);
  border-radius: 2px; transition: width .3s;
}

/* ── Scripts table ───────────────────────────────────────────────────── */
.scripts-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.scripts-table th, .scripts-table td {
  padding: 10px 14px;
  text-align: left;
}
.scripts-table th {
  background: var(--surface2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  font-weight: 600;
}
.scripts-table td { border-top: 1px solid var(--border); vertical-align: middle; }
.scripts-table tr:hover td { background: var(--card-hover); }
.scripts-table .col-actions { text-align: right; }
.script-row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.script-title-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  font-size: inherit;
  font-family: inherit;
  padding: 0;
}
.script-title-link:hover { color: var(--accent); }

/* ── Format badge ────────────────────────────────────────────────────── */
.format-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ── Empty state ─────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state p { font-size: 14px; }

/* ── Detail view layout ──────────────────────────────────────────────── */
#detail-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── Babble-style two-row editor header ──────────────────────────────── */
.editor-header {
  flex-shrink: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

/* Row 1 — title bar */
.editor-titlebar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 20px 8px;
  gap: 12px;
}
.editor-titlebar-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.editor-back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  letter-spacing: .01em;
  transition: color .12s;
  width: fit-content;
}
.editor-back-link:hover { color: var(--text); }
.editor-main-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.editor-titlebar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding-top: 2px;
}

/* "Clean up" gradient CTA button */
.editor-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  background: var(--df-gradient);
  color: #fff;
  transition: opacity .15s;
  white-space: nowrap;
}
.editor-cta-btn:hover { opacity: .88; }
.editor-cta-btn:disabled { opacity: .45; cursor: not-allowed; }

/* Row 2 — sub-bar */
.editor-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 0;
  height: 38px;
  gap: 12px;
  border-top: 1px solid var(--border);
}
.editor-subbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.editor-subbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.editor-format-chip {
  font-size: 10px;
  padding: 2px 8px;
}
.editor-subbar-sep {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--text-faint);
  text-transform: uppercase;
  user-select: none;
}
.editor-version-tabs {
  display: flex;
  gap: 2px;
}
.editor-version-tab {
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  padding: 3px 10px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.editor-version-tab:hover { color: var(--text); background: var(--surface2); }
.editor-version-tab.active {
  background: var(--editor-tab-active-bg);
  border-color: var(--editor-tab-active-border);
  color: var(--editor-tab-active-text);
}

.btn-sm {
  font-size: 12px;
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Legacy selectors kept so any remaining JS refs don't break */
.detail-toolbar { display: none; }
.detail-toolbar-left, .detail-toolbar-right { display: flex; align-items: center; gap: 8px; }
.editor-topbar { display: none; }

/* ── Job banner ──────────────────────────────────────────────────────── */
.job-banner {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  flex-shrink: 0;
}
.job-banner-text {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-muted);
  margin-bottom: 5px;
}
.job-progress-label { font-variant-numeric: tabular-nums; }
.job-progress-track {
  height: 3px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.job-progress-fill {
  height: 100%; width: 0%; background: var(--accent); border-radius: 2px;
  transition: width .3s;
}

/* ── Detail body: breakdown (left) + scene panel (right) ─────────────── */
.detail-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* LEFT: Breakdown panel */
.breakdown-panel {
  flex: 1;
  overflow-y: auto;
  padding: 22px 28px;
  min-width: 0;
}

/* RIGHT: Scene sidebar — Babble captions panel style */
.scene-sidebar {
  width: 380px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.scene-sidebar-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 14px 16px 10px;
  flex-shrink: 0;
}
.scene-sidebar-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.scene-sidebar-count {
  font-size: 13px;
  color: var(--text-muted);
}

/* Search row */
.scene-search-row {
  padding: 0 12px 8px;
  flex-shrink: 0;
}
.scene-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.scene-search-icon {
  position: absolute;
  left: 9px;
  color: var(--text-faint);
  pointer-events: none;
}
.scene-search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  padding: 6px 10px 6px 28px;
  outline: none;
  transition: border-color .15s;
}
.scene-search-input:focus { border-color: var(--accent); }
.scene-search-input::placeholder { color: var(--text-faint); }

/* Filter tabs */
.scene-filter-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding: 0 4px;
}
.scene-filter-tab {
  flex: 1;
  padding: 7px 4px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .12s, border-color .12s;
}
.scene-filter-tab:hover { color: var(--text); }
.scene-filter-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Scene list */
.scene-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

/* Scene list items — Babble caption row style */
.scene-list-item {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.scene-list-item:hover { background: var(--surface); }
.scene-list-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.scene-list-item.active { background: var(--accent-tint); }
.scene-list-item.hidden-by-filter { display: none; }
.scene-list-empty { padding: 16px; color: var(--text-muted, #8b8f98); font-size: 0.85rem; text-align: center; list-style: none; }

.scene-item-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.scene-item-num {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-muted);
  flex-shrink: 0;
}
.scene-item-sep { color: var(--text-faint); font-size: 11px; }
.scene-item-heading {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
}

/* Scene state dot */
.scene-state-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.scene-state-dot.draft    { background: var(--text-faint); }
.scene-state-dot.complete { background: var(--success); }
.scene-state-dot.error    { background: var(--danger); }
.scene-state-dot.running  { background: var(--accent); }

/* Scene meta */
.scene-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.scene-meta-item { display: flex; flex-direction: column; gap: 2px; }
.scene-meta-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  font-weight: 600;
}
.scene-meta-value { font-size: 13px; color: var(--text); }

/* Scene body text toggle */
.scene-body-block { margin-bottom: 18px; }
.scene-body-toggle {
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); font-size: 12px; padding: 5px 10px;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color .15s, color .15s;
}
.scene-body-toggle:hover { border-color: var(--accent); color: var(--accent); }
.scene-body-text {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-muted);
  line-height: 1.5;
  max-height: 280px;
  overflow-y: auto;
}

/* Breakdown grid */
.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 10px;
}

/* Category cards — Babble caption card style */
.category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .12s;
}
.category-card.empty { opacity: .5; }
.category-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: background .12s;
}
.category-card-header:hover { background: var(--surface3-hover); }
.category-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.category-count {
  font-size: 11px;
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 1px 8px;
  font-weight: 500;
}
.category-body { padding: 8px 12px; }

/* Breakdown items */
.breakdown-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.breakdown-item:last-of-type { border-bottom: none; }

.item-body { flex: 1; min-width: 0; }
.item-value { font-size: 13px; color: var(--text); font-weight: 500; cursor: text; }
.item-value:hover { color: var(--accent); }
.item-value-edit {
  font-size: 13px; font-weight: 500; font-family: var(--font);
  color: var(--text); background: var(--surface2);
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  padding: 1px 4px; width: 100%; outline: none;
}
.item-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.item-confidence {
  display: inline-block;
  width: 36px; height: 3px;
  background: var(--border);
  border-radius: 2px;
  vertical-align: middle;
  position: relative;
  margin-right: 4px;
}
.item-confidence-fill {
  position: absolute; inset-block: 0; left: 0;
  background: var(--accent);
  border-radius: 2px;
}
.source-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: var(--surface2);
  color: var(--text-muted);
}
.source-badge.manual { background: var(--accent-tint2); color: var(--accent); }

.item-remove {
  flex-shrink: 0;
  background: none; border: none;
  color: var(--text-muted); font-size: 14px;
  cursor: pointer; padding: 2px 4px;
  border-radius: var(--radius-xs); line-height: 1;
  transition: color .15s;
}
.item-remove:hover { color: var(--danger); }

/* Add item form */
.add-item-form {
  display: flex; gap: 6px; margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.add-item-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  padding: 5px 8px;
  outline: none;
  min-width: 0;
  transition: border-color .15s;
}
.add-item-input:focus { border-color: var(--accent); }
.add-item-input::placeholder { color: var(--text-secondary); }

/* ── Toast ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 18px;
  font-size: 13px;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}
.toast.show { opacity: 1; }
.toast.error   { border-color: var(--danger);  color: var(--danger); }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.warning { border-color: var(--warning); color: var(--warning); }

.draft-banner {
  position: fixed;
  bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--warning);
  color: var(--warning);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 480px;
}
.draft-banner-text { flex: 1; }
.draft-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Login ───────────────────────────────────────────────────────────── */
#login-view { min-height: 100vh; background: var(--login-panel-bg); }

.login-split { display: flex; min-height: 100vh; }

/* ── Hero panel (left) ── */
.login-hero-panel {
  position: relative;
  flex: 1;
  display: none;
  overflow: hidden;
  background: var(--login-hero-bg);
}
@media (min-width: 900px) { .login-hero-panel { display: flex; } }

/* Glow — upper-center, cinematic purple-blue bloom */
.login-hero-glow {
  position: absolute;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 700px;
  background: radial-gradient(ellipse at 50% 30%,
    rgba(100, 60, 220, 0.22) 0%,
    rgba(76, 141, 255, 0.10) 40%,
    transparent 70%);
  pointer-events: none;
  animation: hero-pulse 8s ease-in-out infinite;
}
@keyframes hero-pulse {
  0%, 100% { opacity: 0.75; }
  50%       { opacity: 1; }
}

/* Body: centers main content, strapline pinned to bottom */
.login-hero-body {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px 52px 80px;
}

.login-hero-inner { max-width: 420px; }

.login-hero-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 24px;
}
.login-hero-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: dot-blink 2.4s ease-in-out infinite;
}
@keyframes dot-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}

.login-hero-headline {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.18;
  color: var(--text);
  margin-bottom: 36px;
}
.login-hero-accent { color: var(--accent); }

/* Demo rows — like Babble's subtitle rows */
.login-hero-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 52px; }

.login-demo-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--demo-row-bg);
  border: 1px solid var(--demo-row-border);
  border-radius: 6px;
  padding: 10px 14px;
  opacity: 0.45;
  overflow: hidden;
}
.login-demo-row--active {
  opacity: 1;
  background: var(--demo-row-active-bg);
  border-color: var(--demo-row-active-border);
}
.login-demo-row--dim { opacity: 0.28; }

.login-demo-sc {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  font-family: "Space Mono", "Courier New", monospace;
  flex-shrink: 0;
  min-width: 38px;
}
.login-demo-heading {
  font-size: 13px;
  color: var(--text);
  font-family: "Space Mono", "Courier New", monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.login-demo-heading--action { color: var(--text-muted); font-style: italic; }

.login-hero-strapline {
  position: absolute;
  bottom: 40px;
  left: 52px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ── Form panel (right) ── */
.login-form-panel {
  flex: 0 0 42%;
  display: flex;
  flex-direction: column;
  background: var(--login-panel-bg);
}
@media (max-width: 899px) { .login-form-panel { flex: 1; } }
@media (min-width: 1400px) { .login-form-panel { flex: 0 0 520px; } }

/* Form body fills space and positions card toward upper-center */
.login-form-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 40px 20px;
}

.login-card { width: 100%; max-width: 340px; }

.login-app-name {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 18px;
}

.login-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 5px;
}

.login-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.login-form { display: flex; flex-direction: column; gap: 1rem; }

.login-field { display: flex; flex-direction: column; gap: 0.4rem; }

.login-field label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.login-field input {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.6rem 0.75rem;
  outline: none;
  transition: border-color .15s;
  font-family: var(--font);
}
.login-field input:focus { border-color: var(--accent); }
.login-field input:-webkit-autofill,
.login-field input:-webkit-autofill:hover,
.login-field input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--input-autofill-bg) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  border-color: var(--border) !important;
  transition: background-color 9999s ease-in-out 0s;
}

.login-error { color: var(--danger); font-size: 0.82rem; margin: 0; }

.login-forgot { margin: 0.75rem 0 0; text-align: center; }
.login-text-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.login-text-btn:hover { color: var(--text); }

.login-tabs {
  display: flex;
  border-bottom: 1px solid var(--divider-line);
  margin-bottom: 1.5rem;
}
.login-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0;
  margin-right: 1.5rem;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.login-tab:hover { color: var(--text); }
.login-tab--active { color: var(--text); border-bottom-color: var(--accent); }

.signup-success {
  color: var(--success, #4caf7d);
  font-size: 0.88rem;
  margin: 0.5rem 0 0;
  line-height: 1.5;
}

.login-submit { margin-top: 0.5rem; width: 100%; justify-content: center; }

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0 0.25rem;
  color: var(--divider-text);
  font-size: 0.8rem;
}
.login-divider::before,
.login-divider::after { content: ''; flex: 1; height: 1px; background: var(--divider-line); }

/* Footer */
.login-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 16px 40px;
  font-size: 12px;
  color: var(--text-faint);
}
.login-footer-link {
  color: var(--text-faint);
  text-decoration: none;
  transition: color .15s;
}
.login-footer-link:hover { color: var(--text-muted); }

/* ── Subscription prompt modal ───────────────────────────────────────── */
.sub-prompt-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 380px;
  margin: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: center;
}
.sub-prompt-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.sub-prompt-body {
  font-size: .9rem;
  color: var(--text-muted);
  margin: 0;
}
.sub-prompt-actions {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  margin-top: .5rem;
}
.sub-prompt-card--plans {
  max-width: 640px;
  text-align: left;
}
.sub-prompt-plans {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
  margin-top: .5rem;
}
@media (max-width: 580px) {
  .sub-prompt-plans { grid-template-columns: 1fr; }
}
/* Compact plan cards inside the modal */
.sub-prompt-plans .plan-card {
  position: relative;
  padding: 16px;
  border-radius: 12px;
  width: auto;
}
.sub-prompt-plans .plan-name { font-size: 15px; margin-bottom: 4px; }
.sub-prompt-plans .plan-scripts { font-size: 11px; margin-bottom: 8px; }
.sub-prompt-plans .plan-price { font-size: 1.8rem; margin-bottom: 12px; }
.sub-prompt-plans .plan-period { font-size: 13px; }
.sub-prompt-plan-btn {
  width: 100%;
  justify-content: center;
  margin-top: auto !important;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}
.sub-prompt-plan-btn:disabled { opacity: .5; cursor: not-allowed; }
.sub-prompt-plan-btn--gradient {
  background: var(--df-gradient);
  border: 1px solid transparent;
  color: #fff;
  font-weight: 600;
}
.sub-prompt-plan-btn--gradient:hover { opacity: .88; }
.sub-prompt-later-btn {
  width: 100%;
  justify-content: center;
  margin-top: .25rem;
  font-size: 13px;
}

/* ── Terms modal ─────────────────────────────────────────────────────── */
.terms-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px 16px;
  overflow-y: auto;
}

.terms-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  margin: auto;
  flex-shrink: 0;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.terms-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.terms-card-intro {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}
.terms-card-intro a { color: var(--accent); }

.terms-scroll-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  max-height: 220px;
  overflow-y: auto;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.terms-scroll-box p strong { color: var(--text); }
.terms-scroll-box a { color: var(--accent); }

.terms-checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.terms-checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.terms-error {
  color: var(--danger);
  font-size: 12px;
  margin: 0;
}

.terms-accept-btn { width: 100%; justify-content: center; padding: 10px 14px; }

/* ── Cookie banner ───────────────────────────────────────────────────── */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface2);
  border-top: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 300;
  flex-wrap: wrap;
}

.cookie-banner-text {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  flex: 1;
  min-width: 200px;
}
.cookie-banner-text a { color: var(--accent); text-decoration: none; }
.cookie-banner-text a:hover { text-decoration: underline; }

.cookie-banner-btn { flex-shrink: 0; }

/* ── Mobile sidebar ──────────────────────────────────────────────────── */
.mobile-topbar {
  display: none;
}

.sidebar-overlay {
  display: none;
}

@media (max-width: 767px) {
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 52px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 200;
  }

  .sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: background .12s, color .12s;
  }
  .sidebar-toggle-btn:hover {
    background: var(--hover-overlay);
    color: var(--text);
  }

  .mobile-topbar-title {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    background: var(--df-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #app-shell {
    flex-direction: column;
  }

  #app-header {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform .22s cubic-bezier(.4,0,.2,1);
    z-index: 300;
  }

  #app-header.sidebar-open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 299;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s;
  }

  .sidebar-overlay.sidebar-open {
    opacity: 1;
    pointer-events: auto;
  }

  #main-content {
    width: 100%;
  }
}

/* ── Site footer ─────────────────────────────────────────────────────── */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  font-size: 12px;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.site-footer-sep { color: var(--border); }
.site-footer a { color: var(--text-faint); text-decoration: none; }
.site-footer a:hover { color: var(--text-muted); }

/* ── Main content wrapper ────────────────────────────────────────────── */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}


/* ── Billing / Account / Support views ──────────────────────────────── */
#billing-view,
#account-view,
#support-view {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 24px;
  overflow-y: auto;
}

#account-view-content {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

#support-view {
  align-items: flex-start;
}
#support-view .paywall-wrap {
  align-items: flex-start;
  max-width: 760px;
}
#support-view .plans-header {
  text-align: left;
  margin-bottom: 24px;
}
#support-view .plans-heading {
  font-size: 36px;
}
#support-view .paywall-sub {
  font-size: 14px;
  text-align: left;
}

#support-iframe {
  width: 100%;
  border: 1px solid var(--border);
  display: block;
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
}

.paywall-wrap {
  width: 100%;
  max-width: 860px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.plans-header {
  text-align: center;
  margin-bottom: 8px;
}

.plans-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

.plans-heading {
  font-family: var(--font-heading);
  font-size: 68px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.15;
}

.plans-heading-gradient {
  background: var(--df-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.paywall-sub {
  color: var(--text-muted);
  font-size: 16px;
  text-align: center;
  margin-bottom: 8px;
}

#billing-view .paywall-wrap { max-width: 1040px; }

.plans-section-label {
  margin: 20px 0 4px;
  text-align: left;
}
.plans-section-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.plans-section-note {
  font-size: 12px;
  color: var(--text-muted);
}

.paywall-plans {
  display: flex;
  gap: 16px;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
  margin: 8px 0 8px;
  padding-top: 16px;
}

.plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px 24px;
  width: 305px;
  min-width: 0;
  flex-shrink: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: border-color .2s, transform .2s, box-shadow .2s;
}

@media (max-width: 680px) {
  .plan-card { width: 100%; max-width: 380px; }
}
.plan-card:hover {
  border-color: var(--plan-card-hover);
  transform: translateY(-4px);
  box-shadow: 0 12px 32px color-mix(in srgb, var(--accent) 12%, transparent);
}

.plan-card--featured {
  border: 1px solid transparent;
  background: linear-gradient(var(--surface2), var(--surface2)) padding-box,
              var(--df-gradient) border-box;
}
.plan-card--featured:hover {
  border-color: transparent;
  box-shadow: 0 12px 36px color-mix(in srgb, var(--accent) 22%, transparent);
}

.plan-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--df-gradient);
  color: #fff;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  font-weight: 700;
  padding: 3px 14px;
  border-radius: 99px;
  white-space: nowrap;
}

.plan-name {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.plan-scripts {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  margin-bottom: 16px;
}

.plan-price {
  font-family: var(--font-heading);
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 20px;
}
.plan-period {
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 4px;
}

.plan-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  margin-bottom: 24px;
}
.plan-features li {
  font-size: 13px;
  color: var(--text-muted);
  padding-left: 20px;
  position: relative;
}
.plan-features li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.paywall-plan-btn,
.active-switch-btn,
.billing-topup-btn {
  width: 100%;
  justify-content: center;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}
.paywall-plan-btn:disabled,
.active-switch-btn:disabled { opacity: .5; cursor: not-allowed; }

.paywall-plan-btn--gradient,
.active-switch-btn--gradient {
  background: var(--df-gradient);
  border: 1px solid transparent;
  color: #fff;
  font-weight: 600;
}
.paywall-plan-btn--gradient:hover,
.active-switch-btn--gradient:hover { opacity: .88; }

.paywall-error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
}

.paywall-extra-note {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
}
.btn-link:hover { color: var(--accent-hover); }

.paywall-logout {
  margin-top: 4px;
  color: var(--text-secondary);
}

/* ── Account page — Babble-style layout ─────────────────────────────── */
.acct-page-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
}
.acct-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 0;
}
.acct-heading {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}
.acct-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.acct-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}
.acct-stat-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 14px;
}
.acct-stat-value {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
}
.acct-stat-value--plan {
  font-family: var(--mono);
  font-size: 26px;
}
.acct-stat-value.low  { color: var(--warning); }
.acct-stat-value.none { color: var(--danger); }
.acct-details-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

/* ── Account card ────────────────────────────────────────────────────── */
.acct-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px 8px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.acct-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 12px;
}
.acct-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  gap: 16px;
}
.acct-info-label {
  font-size: 14px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.acct-info-value {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  text-align: right;
}
.acct-info-value--flex {
  display: flex;
  align-items: center;
  gap: 8px;
}
.acct-info-value--low  { color: var(--warning); }
.acct-info-value--none { color: var(--danger); }
.acct-info-value--normal { color: var(--text); }
.acct-divider {
  height: 1px;
  background: var(--border);
  margin: 0 -20px;
}
.acct-card-footer {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 14px;
  padding-bottom: 14px;
  justify-content: flex-end;
}

/* ── Billing status card ─────────────────────────────────────────────── */
.billing-active-content {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: 100%;
  max-width: 600px;
}

.billing-status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.acct-plan-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.acct-plan-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}
.acct-plan-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.acct-plan-badge--active {
  background: var(--success-tint);
  color: var(--success);
}
.acct-plan-badge--inactive {
  background: var(--danger-tint);
  color: var(--danger);
}
.acct-plan-badge--trial {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}
.acct-plan-badge--cancelling {
  background: color-mix(in srgb, var(--warning) 15%, transparent);
  color: var(--warning);
}
.acct-cancel-note {
  font-size: 13px;
  color: var(--warning);
}

/* Credits block */
.acct-credits-block { display: flex; flex-direction: column; gap: 8px; }
.acct-credits-header { display: flex; justify-content: space-between; align-items: baseline; }
.acct-credits-label { font-size: 13px; color: var(--text-muted); }
.acct-credits-label--loading { text-align: center; padding: 24px 0; }
.acct-credits-count { font-size: 14px; font-weight: 600; color: var(--text); }
.acct-credits-count.low  { color: var(--warning); }
.acct-credits-count.none { color: var(--danger); }
.acct-credits-sub { font-size: 12px; color: var(--text-muted); }
.acct-extra-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--accent-tint2);
  color: var(--accent);
  margin-left: 6px;
  vertical-align: middle;
}

/* Progress bar — Babble 3px style */
.acct-progress-track {
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.acct-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .3s;
}
.acct-progress-fill.low  { background: var(--warning); }
.acct-progress-fill.none { background: var(--danger); }

.acct-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Skip-trial toggle ───────────────────────────────────────────────── */
.skip-trial-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin-bottom: 20px;
  width: fit-content;
}
.skip-trial-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.skip-trial-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.skip-trial-thumb {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: var(--border);
  transition: background .2s;
}
.skip-trial-thumb::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform .2s;
}
.skip-trial-toggle input:checked + .skip-trial-thumb {
  background: var(--accent);
}
.skip-trial-toggle input:checked + .skip-trial-thumb::after {
  transform: translateX(18px);
}
.skip-trial-label {
  font-size: 14px;
  color: var(--text-muted);
  user-select: none;
}
.skip-trial-row:hover .skip-trial-label { color: var(--text); }

/* ── Billing-active (plans page for existing subscribers) ────────────── */
.topup-divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 32px 0 0;
}
.paywall-plans--topup {
  justify-content: center;
}

/* Current plan card highlight */
.plan-card--current {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}
.plan-card--current:hover {
  transform: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}
.plan-card--current::before {
  content: 'Current plan';
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.btn-current {
  opacity: .55;
  cursor: default;
  pointer-events: none;
}

/* ── Sub-prompt trial wait hint ──────────────────────────────────────── */
.sub-prompt-wait-hint {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin: 0 0 4px;
  line-height: 1.5;
}


/* ── Plan switch confirmation modal ──────────────────────────────────── */
#plan-switch-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#plan-switch-modal[hidden] { display: none; }
.psm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}
.psm-card {
  position: relative;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.psm-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0;
}
.psm-title {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}
.psm-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 16px;
}
.psm-plans {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 8px;
}
.psm-plan {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.psm-plan-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin: 0;
}
.psm-plan-name {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.psm-plan--to .psm-plan-name {
  background: var(--df-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.psm-plan-detail {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}
.psm-plan-price {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.psm-arrow {
  color: var(--text-faint);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.psm-note {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 12px;
  line-height: 1.5;
}
.psm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

/* Native controls and scrollbars follow the theme, not the browser default (light). */
:root { color-scheme: dark; scrollbar-color: var(--border) transparent; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { color-scheme: light; }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
