/* ===== CaptionFit App v2 — Design System ===== */

:root {
  --bg: #07070d;
  --bg-grad-1: #0b0b18;
  --bg-grad-2: #07070d;
  --surface: #10101c;
  --surface-2: #15162a;
  --surface-3: #1c1e36;
  --border: rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.12);
  --text: #ecedf6;
  --text-2: #b8b9cc;
  --muted: #6e7088;
  --muted-2: #4b4d63;
  --indigo: #6366f1;
  --indigo-2: #818cf8;
  --indigo-3: #4f46e5;
  --indigo-soft: rgba(99,102,241,0.12);
  --indigo-glow: rgba(99,102,241,0.45);
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --radius-xl: 32px;
  --shadow-lg: 0 30px 80px -30px rgba(99,102,241,0.45), 0 12px 40px -10px rgba(0,0,0,0.6);
  --font-sans: "Geist", "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", ui-monospace, monospace;
  --font-serif: "Instrument Serif", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.005em;
  font-feature-settings: "ss01","ss02","cv11";
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }
h1,h2,h3,h4 { margin: 0; }

/* ===== App root layout ===== */
.app-root {
  min-height: 100vh;
  max-width: 1300px;
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-rows: 64px auto;
  background:
    radial-gradient(900px 500px at 50% -200px, rgba(99,102,241,0.12), transparent 60%),
    linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2));
}

/* ===== Topbar (matches landing site-header sizing) ===== */
.tb {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 0 22px;
  height: 64px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  background: rgba(8,8,14,0.7);
  border-bottom: 1px solid var(--border);
}
.tb-left  { display: flex; align-items: center; gap: 18px; min-width: 0; flex: 1 1 auto; }
.tb-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.tb-logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 18px; letter-spacing: -0.02em;
  color: var(--text);
}
.tb-logo .logo-mark { width: 28px; height: 28px; flex-shrink: 0; }
.tb-beta {
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px;
  line-height: 1.4;
  background: var(--indigo-soft); color: var(--indigo-2);
  border: 1px solid rgba(99,102,241,0.25);
  white-space: nowrap;
}
.tb-beta-ver { opacity: 0.7; font-weight: 400; margin-left: 2px; }
.tb-divider { width: 1px; height: 22px; background: var(--border-strong); }
.tb-crumb {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-2); font-size: 13.5px;
  min-width: 0; flex: 1 1 auto; overflow: hidden;
}
.tb-crumb[hidden] { display: none; }
.tb-crumb .sep { color: var(--muted-2); flex-shrink: 0; }
.tb-crumb .crumb-home { flex-shrink: 0; }
.tb-crumb .crumb-proj {
  color: var(--text); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
  /* Hard cap so a long title can never crowd out the right-side buttons.
     JS in updateBreadcrumb() already truncates to ~55 chars + tooltip;
     this is the visual-width belt-and-suspenders for narrower viewports. */
  max-width: min(60ch, 50vw);
}
.tb-status {
  display: none; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px;
  background: rgba(52,211,153,0.08);
  border: 1px solid rgba(52,211,153,0.18);
}
.tb-status.visible { display: inline-flex; }
.tb-status .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 8px rgba(52,211,153,0.7);
}
.tb-account {
  position: relative;
  display: flex; align-items: center; gap: 9px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,0.025);
  font-size: 12.5px; color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}
.tb-account:hover { background: rgba(255,255,255,0.05); }
.tb-account.no-user { padding: 6px 14px; border-radius: 999px; }
.tb-email { font-size: 12.5px; color: var(--text-2); }
.tb-chevron { color: var(--muted); flex-shrink: 0; display: block; }
.tb-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo-2), var(--indigo-3));
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600; color: white; flex-shrink: 0;
}
.tb-dropdown {
  display: none;
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 160px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  overflow: hidden;
  z-index: 200;
}
.tb-account.open .tb-dropdown { display: block; }
.tb-dd-item {
  display: block; width: 100%;
  padding: 10px 14px;
  background: none; border: none;
  color: var(--text-2); font-size: 13px;
  text-align: left; cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.tb-dd-item:hover { background: var(--surface-3); color: var(--text); }
.tb-dd-signout:hover { color: var(--red); }

/* ===== Topbar responsive ===== */
@media (max-width: 999px) {
  .tb { padding: 0 14px; }
  .tb-left { gap: 10px; }
  .tb-right { gap: 8px; }
  .tb-divider { display: none; }
  .tb-crumb { display: none; }            /* hide breadcrumb entirely on mobile */
  .tb-email { display: none; }
  .tb-account { padding: 4px; }
  .tb-chevron { display: none; }
}
@media (max-width: 480px) {
  .tb { padding: 0 10px; }
  .tb-brand { display: none; }
  .tb-logo { gap: 8px; }
}

/* ===== Body (canvas only — no sidebar) ===== */
.app-body { display: block; }

/* ===== Project / Render list scrollbars (used inside .side-card-list) ===== */
.rail-list::-webkit-scrollbar { width: 4px; }
.rail-list::-webkit-scrollbar-track { background: transparent; }
.rail-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }
.rail-list::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }
.rail-list { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.08) transparent; }
.rail-list { display: flex; flex-direction: column; padding: 4px 10px 12px; gap: 2px; }
.rail-count { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted-2); margin-left: 6px; }

/* ===== List row: Projects + Renders side-by-side (at bottom of canvas) ===== */
.list-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
/* ===== Side cards (Projects, Renders) ===== */
.side-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.2));
  display: flex; flex-direction: column;
  height: 440px;
  overflow: hidden;
}
.side-card[hidden] { display: none; }
.side-card-empty {
  padding: 20px 14px;
  font-family: var(--font-mono); font-size: 11px;
  color: var(--muted-2); letter-spacing: 0.04em;
  text-align: center;
}
.side-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.side-card-head h4 {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted);
}
.side-card-list { flex: 1; overflow-y: auto; padding: 6px 10px 10px; }

/* "+ New transcription" button in the topbar */
.tb-new-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; font-size: 12.5px; font-weight: 500; border-radius: 8px;
  background: linear-gradient(180deg, var(--indigo-2), var(--indigo-3));
  color: white; border: none;
  box-shadow: 0 4px 12px -6px var(--indigo-glow), 0 0 0 1px rgba(255,255,255,0.08) inset;
  transition: transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
}
.tb-new-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px -8px var(--indigo-glow), 0 0 0 1px rgba(255,255,255,0.15) inset; }

/* ===== Work row: Player + Editor side-by-side (60/40) ===== */
.work-row {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 22px;
  align-items: start;
}
/* JS mirrors the player-card's height onto .editor-card via --player-h.
   The caption list inside then flexes to fill the remaining space. */
.work-row > .editor-card {
  display: flex; flex-direction: column;
  height: var(--player-h, auto);
  min-height: 0;
}
.work-row > .editor-card > .cap-preview-list,
.work-row > .editor-card > .cap-list {
  flex: 1;
  height: auto;
  min-height: 0;
}

/* ===== Responsive: collapse to single column ===== */
@media (max-width: 1100px) {
  .list-row { grid-template-columns: 1fr; }
  .work-row { grid-template-columns: 1fr; }
  .side-card { height: 400px; }
  /* When stacked, let the editor card size to its own content; restore the
     original fixed caption-list height so it stays usable on mobile. */
  .work-row > .editor-card { height: auto; }
  .work-row > .editor-card > .cap-preview-list,
  .work-row > .editor-card > .cap-list { flex: none; height: 435px; }
}

/* ===== Transcribe card responsive =====
   On tablet portrait and below: selects side-by-side, button full-width below.
   On phones: every field on its own row. */
@media (max-width: 768px) {
  .transcribe-card { padding: 20px 18px; }
  .step1-options {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "lang chars"
      "btn  btn";
    gap: 12px;
  }
  #elevenLangRow         { grid-area: lang; }
  .step1-field--chars    { grid-area: chars; }
  .step1-field--btn      { grid-area: btn; align-items: stretch; }
  .step1-field--btn .lang-label { display: none; }
  #elevenBtn { width: 100%; padding: 13px 20px; font-size: 15px; }
}

@media (max-width: 640px) {
  .canvas { padding: 18px 14px 40px; }
  .side-card { height: 360px; }
  .upload-drop { padding: 36px 18px; }
}

@media (max-width: 480px) {
  .transcribe-card { padding: 16px 14px; }
  .step1-options {
    grid-template-columns: 1fr;
    grid-template-areas: "lang" "chars" "btn";
  }
}

/* Project rows */
.proj {
  position: relative;
  display: grid; grid-template-columns: 28px 1fr auto;
  align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px;
  border: 1px solid transparent; cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.proj:hover { background: rgba(255,255,255,0.03); }
.proj.active { background: rgba(99,102,241,0.08); border-color: rgba(99,102,241,0.22); }
.proj-icon {
  width: 28px; height: 28px; border-radius: 7px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  color: var(--muted); display: grid; place-items: center; flex-shrink: 0;
  font-size: 13px;
}
.proj.active .proj-icon { background: var(--indigo-soft); border-color: rgba(99,102,241,0.3); color: var(--indigo-2); }
.proj-body { min-width: 0; }
.proj-name {
  font-size: 13px; color: var(--text); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.proj-meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.proj-del {
  width: 22px; height: 22px; border-radius: 5px;
  display: grid; place-items: center;
  color: var(--muted); opacity: 0; font-size: 13px;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.proj:hover .proj-del { opacity: 1; }
.proj-del:hover { background: rgba(248,113,113,0.12); color: var(--red); }

/* Render rows in rail */
.render-row-r {
  display: grid; grid-template-columns: 22px 1fr auto auto;
  align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  transition: background 0.12s;
}
.render-row-r:hover { background: rgba(255,255,255,0.03); }
.render-row-r .r-icon {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(52,211,153,0.12); color: var(--green);
  display: grid; place-items: center; font-size: 12px;
}
.render-row-r .r-icon.busy { background: var(--indigo-soft); color: var(--indigo-2); }
.render-row-r .r-icon.fail { background: rgba(248,113,113,0.12); color: var(--red); }
.render-row-r .r-ts { font-family: var(--font-mono); font-size: 11px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px;
}
.rs-pill.done  { color: var(--green); background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.18); }
.rs-pill.busy  { color: var(--indigo-2); background: var(--indigo-soft); border: 1px solid rgba(99,102,241,0.22); }
.rs-pill.fail  { color: var(--red); background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.18); }
.rs-spin {
  width: 9px; height: 9px; border-radius: 50%;
  border: 1.5px solid rgba(129,140,248,0.25); border-top-color: var(--indigo-2);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.r-dl {
  width: 24px; height: 24px; border-radius: 6px;
  display: grid; place-items: center; color: var(--muted);
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
}
.r-dl:hover { background: rgba(255,255,255,0.06); color: var(--text); }

/* ===== Canvas ===== */
.canvas-scroll {
  min-height: calc(100vh - 64px);
}
.canvas {
  padding: 26px 32px 60px;
  display: flex; flex-direction: column; gap: 22px;
  max-width: 1380px; margin: 0 auto; width: 100%;
}

#resultPanel {
  display: flex; flex-direction: column; gap: 22px;
}
#resultPanel[hidden], #step1Panel[hidden] { display: none; }

/* Stepper */
.stepper {
  display: flex; align-items: center;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 4px; align-self: flex-start;
}
.step-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; font-size: 12.5px; border-radius: 8px;
  color: var(--muted); font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.step-pill .num {
  font-family: var(--font-mono); font-size: 10px;
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--border-strong); color: var(--muted);
  background: rgba(255,255,255,0.02);
}
.step-pill.done { color: var(--text-2); }
.step-pill.done .num { background: rgba(52,211,153,0.12); color: var(--green); border-color: rgba(52,211,153,0.25); }
.step-pill.active { background: var(--indigo-soft); color: var(--text); }
.step-pill.active .num {
  background: linear-gradient(180deg, var(--indigo-2), var(--indigo-3));
  color: white; border-color: transparent;
  box-shadow: 0 0 12px var(--indigo-glow);
}
.step-sep { width: 18px; height: 1px; background: var(--border-strong); }

/* Project header */
.proj-head {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 7px;
}
.proj-head h1 {
  font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15;
  display: flex; align-items: center; gap: 12px;
}
.proj-head h1 .file-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.04em; padding: 5px 10px; border-radius: 6px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border); color: var(--text-2);
}
.proj-head-meta {
  display: flex; align-items: center; gap: 18px;
  color: var(--muted); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em;
}
.proj-head-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted-2); flex-shrink: 0; }

/* ===== Player card ===== */
.player-card {
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.25));
  padding: 18px;
  box-shadow: 0 20px 60px -30px rgba(0,0,0,0.6);
  position: relative; overflow: visible;
}

/* Mobile-only desktop-experience notice above the player.
   Hidden by default (desktop); shown via media query below. */
.mobile-desktop-notice { display: none; }
@media (max-width: 768px) {
  .mobile-desktop-notice {
    display: flex; align-items: flex-start; gap: 10px;
    margin: 0 0 14px;
    padding: 10px 12px;
    border: 1px solid rgba(99,102,241,0.35);
    border-radius: 10px;
    background: rgba(99,102,241,0.10);
    color: var(--text);
    font-size: 13px; line-height: 1.4;
  }
  .mobile-desktop-notice .mdn-icon { font-size: 16px; line-height: 1.4; flex-shrink: 0; }
  .mobile-desktop-notice .mdn-text { flex: 1; }
}
.player-card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(900px 350px at 50% 0%, rgba(99,102,241,0.10), transparent 70%);
  pointer-events: none;
}
.player-card > * { position: relative; z-index: 1; }

/* Player stage — always 16:9, defines the height */
/* Host always occupies 16:9 height — stage morphs inside it */
.player-stage-host {
  width: 100%;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-stage {
  position: relative;
  height: 100%;
  width: 100%;
  aspect-ratio: 16/9;
  background: #04040a;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  transition: width 0.3s, aspect-ratio 0.3s;
}
.player-stage.portrait {
  width: auto;
  aspect-ratio: 9/16;
}

/* Video wrapper — always fills the stage */
.video-wrapper {
  position: relative;
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.scene {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 70% at 30% 35%, rgba(96,165,250,0.55), transparent 60%),
    radial-gradient(50% 80% at 75% 30%, rgba(56,189,248,0.5), transparent 60%),
    radial-gradient(80% 50% at 50% 100%, rgba(15,23,42,1), transparent 70%),
    linear-gradient(180deg, #061029 0%, #020410 100%);
}
.video-wrapper.has-video .scene { display: none; }
.scene-rays {
  position: absolute; inset: 0;
  background:
    linear-gradient(85deg, transparent 30%, rgba(186,230,253,0.18) 32%, transparent 34%),
    linear-gradient(95deg, transparent 35%, rgba(186,230,253,0.12) 37%, transparent 39%),
    linear-gradient(80deg, transparent 55%, rgba(186,230,253,0.15) 57%, transparent 59%),
    linear-gradient(100deg, transparent 60%, rgba(186,230,253,0.10) 62%, transparent 64%);
  mix-blend-mode: screen; opacity: 0.9;
}
.scene-stage-light {
  position: absolute; left: 50%; top: 22%;
  width: 70%; height: 8%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.9), rgba(255,255,255,0.15) 40%, transparent 70%);
  filter: blur(4px);
}
.scene-silhouettes {
  position: absolute; left: 0; right: 0; bottom: 0; height: 55%;
  background:
    linear-gradient(180deg, transparent 0%, rgba(2,4,16,0.7) 40%, rgba(2,4,16,1) 100%),
    radial-gradient(ellipse at 50% 100%, rgba(0,0,0,1) 30%, transparent 70%);
}
.scene-silhouettes::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 15% 80%, rgba(0,0,0,0.9) 6px, transparent 8px),
    radial-gradient(circle at 22% 75%, rgba(0,0,0,0.9) 5px, transparent 7px),
    radial-gradient(circle at 32% 82%, rgba(0,0,0,0.9) 7px, transparent 9px),
    radial-gradient(circle at 45% 78%, rgba(0,0,0,0.9) 6px, transparent 8px),
    radial-gradient(circle at 58% 80%, rgba(0,0,0,0.9) 5px, transparent 7px),
    radial-gradient(circle at 68% 76%, rgba(0,0,0,0.9) 7px, transparent 9px),
    radial-gradient(circle at 78% 81%, rgba(0,0,0,0.9) 6px, transparent 8px),
    radial-gradient(circle at 88% 78%, rgba(0,0,0,0.9) 5px, transparent 7px);
}
.scene-mid-figures {
  position: absolute; left: 50%; top: 38%;
  width: 24%; height: 28%; transform: translateX(-50%);
  background:
    radial-gradient(ellipse at 30% 70%, #04040a 18%, transparent 35%),
    radial-gradient(ellipse at 60% 70%, #04040a 18%, transparent 35%),
    radial-gradient(ellipse at 45% 50%, #04040a 12%, transparent 28%);
  filter: blur(1.5px);
}
.scene-grain {
  position: absolute; inset: 0; opacity: 0.06; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.6' numOctaves='2'/></filter><rect width='120' height='120' filter='url(%23n)' opacity='0.8'/></svg>");
}

/* Video/audio elements inside wrapper */
.video-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  filter: blur(24px) brightness(0.5);
  transform: scale(1.1);
}
#audioEl {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  z-index: 1;
}
.video-wrapper:not(.has-video) #audioEl { opacity: 0; }
/* Hide the original video's visual when a cover is active — audio still plays. */
.video-wrapper.has-cover #audioEl { opacity: 0; }
.cover-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  z-index: 2;
}
.player-stage.portrait .cover-img {
  object-fit: cover;
}

/* Caption burnin */
.caption-overlay {
  position: absolute;
  left: 50%; transform: translateX(-50%) translateY(-50%);
  z-index: 16; /* above pause-veil (15) so drag events reach it */
  width: 85%; text-align: center;
  /* Portrait override is below — kept here so the 16:9 default stays explicit. */
  color: white; font-weight: 700;
  text-shadow: 0 2px 6px rgba(0,0,0,0.7), 0 0 12px rgba(0,0,0,0.4);
  letter-spacing: -0.01em; line-height: 1.25;
  white-space: pre-wrap;
  outline: 1px dashed rgba(255,255,255,0.28);
  border-radius: 3px;
  padding: 4px 0;
  /* Vertically centre the text inside the box.  Without this, a one-line
     caption smaller than min-height sat pinned to the TOP of the box, with
     all the extra space at the bottom — so the visual text centre was
     ABOVE the element centre (which is what `top:Y%` actually positions),
     making the preview show text higher than libass renders it at the same
     captionY%.  Flexbox splits any leftover height symmetrically. */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* Halved (was 44px) so the box hugs the text more tightly even at small
     font sizes — keeps the touch target reasonable while reducing the
     asymmetric-space window before flex-centering would have kicked in. */
  min-height: 22px;
  transition: font-size 0.15s, color 0.15s;
  pointer-events: auto;
  cursor: grab;
  /* touch drag without the browser hijacking it as a page scroll */
  touch-action: none;
}
.caption-overlay.dragging {
  cursor: grabbing;
  user-select: none;
  outline-color: rgba(99,102,241,0.7);
  transition: none;
}
/* 9:16 — social platforms (TikTok / Reels / Shorts) overlay their own
   UI icons on the sides and bottom of portrait video.  Double the
   horizontal margin (85% → 70%) so captions stay clear of those icons. */
.player-stage.portrait .caption-overlay { width: 70%; }

/* Aspect ratio + fit overlay pill */
.player-overlay-pill {
  position: absolute; top: 12px; left: 12px; z-index: 20;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 999px;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: rgba(255,255,255,0.85); pointer-events: none;
}

/* Pause veil */
.pause-veil {
  position: absolute; inset: 0; z-index: 15;
  cursor: pointer;
}

/* Transport bar */
.transport {
  display: flex; align-items: center; gap: 14px;
  margin-top: 14px;
}
.transport-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(180deg, var(--indigo-2), var(--indigo-3));
  color: white; display: grid; place-items: center;
  box-shadow: 0 6px 18px -6px var(--indigo-glow), 0 0 0 1px rgba(255,255,255,0.1) inset;
  flex-shrink: 0; transition: transform 0.1s; font-size: 14px;
}
.transport-btn:hover { transform: scale(1.04); }
.transport-time {
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--text-2); letter-spacing: 0.04em; min-width: 36px;
}
.transport-track {
  flex: 1; position: relative; height: 28px;
  display: flex; align-items: center; cursor: pointer;
  touch-action: none;
}
.transport-track-rail {
  position: absolute; left: 0; right: 0; height: 6px;
  background: rgba(255,255,255,0.06); border-radius: 3px;
}
.transport-track-fill {
  position: absolute; left: 0; height: 6px;
  background: linear-gradient(90deg, var(--indigo-3), var(--indigo-2));
  border-radius: 3px; box-shadow: 0 0 12px rgba(99,102,241,0.5);
}
.transport-track-seg {
  position: absolute; top: 50%;
  width: 1.5px; height: 10px;
  background: rgba(255,255,255,0.18);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.transport-track-head {
  position: absolute; top: 50%;
  width: 14px; height: 14px; background: white; border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.35), 0 0 16px rgba(255,255,255,0.45);
  pointer-events: none;
}

/* Style toolbar */
.style-bar {
  margin-top: 14px;
  display: flex; align-items: center; gap: 8px;
  padding: 8px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border); border-radius: 12px;
  flex-wrap: wrap; position: relative; z-index: 2;
}
.style-label {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); padding: 0 8px 0 4px;
}
.style-group {
  display: flex; align-items: center; gap: 2px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border); border-radius: 8px; padding: 3px;
  position: relative;
}
.style-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 6px; font-size: 12px;
  color: var(--text-2); transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.style-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.style-btn.active { background: var(--indigo-soft); color: var(--indigo-2); }
.style-btn.icon-only { padding: 6px 8px; }
.style-color-dot { width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid rgba(255,255,255,0.5); }
.style-bar-right { margin-left: auto; display: flex; align-items: center; }

/* Style popover (font / color) */
.style-popover {
  position: absolute; top: calc(100% + 4px); left: 0;
  background: rgba(20,21,38,0.98);
  border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 8px; min-width: 180px;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,0.7);
  backdrop-filter: blur(20px); z-index: 50;
}
.style-popover.color-pop { min-width: 0; padding: 10px; }
.pop-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 6px;
  font-size: 13px; color: var(--text-2); cursor: pointer;
  transition: background 0.1s;
}
.pop-row:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.pop-row.selected { background: var(--indigo-soft); color: var(--indigo-2); }
.color-grid { display: grid; grid-template-columns: repeat(4, 28px); gap: 6px; }
.color-swatch {
  width: 28px; height: 28px; border-radius: 6px; cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s, border-color 0.15s;
}
.color-swatch:hover { transform: scale(1.06); }
.color-swatch.active { border-color: var(--indigo-2); }

/* ===== Editor card ===== */
.editor-card {
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.2));
  padding: 4px; overflow: hidden;
}
.editor-head {
  display: flex; flex-direction: column;
  padding: 14px 22px 12px; border-bottom: 1px solid var(--border);
  gap: 8px;
}
.editor-top-row {
  display: flex; align-items: center; gap: 8px;
}
/* Save edits lives in the top row alongside the Preview/Edit toggle.
   margin-left:auto pushes it to the right edge of that line so the
   primary controls (Preview/Edit) stay left-anchored. */
.editor-top-row .editor-top-save { margin-left: auto; }
.editor-title { display: flex; align-items: center; gap: 12px; }
.editor-title h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.editor-title .count {
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 5px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border); color: var(--muted);
}
.editor-actions {
  display: flex; align-items: center; gap: 4px;
  /* Wrap to a second row when needed instead of horizontal scroll.
     The previous overflow-x:auto also implicitly clipped overflow-y,
     which made the Captions popover (which sits ABOVE the button)
     invisible.  flex-wrap: wrap fixes both issues at once. */
  flex-wrap: wrap;
  row-gap: 6px;
}
.editor-mode-toggle {
  display: inline-flex;
  background: rgba(255,255,255,0.025); border: 1px solid var(--border);
  border-radius: 8px; padding: 3px;
}
.editor-mode-toggle button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; font-size: 12px; font-weight: 500;
  color: var(--muted); border-radius: 5px;
  transition: background 0.12s, color 0.12s; white-space: nowrap;
}
.editor-mode-toggle button:hover { color: var(--text-2); }
.editor-mode-toggle button.on { background: var(--indigo-soft); color: var(--indigo-2); }

/* Help icon — sits right after the Preview/Edit toggle. */
.editor-help-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%; color: var(--muted);
  background: transparent; border: 1px solid var(--border);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.editor-help-btn:hover { color: var(--indigo-2); border-color: var(--indigo); background: var(--indigo-soft); }

/* Editor help modal — wider, scrollable body. */
/* ── Plans & billing modal ── */
.auth-box.billing-box { max-width: 680px; max-height: 88vh; overflow-y: auto; text-align: left; }
.billing-period-toggle {
  display: inline-flex; gap: 2px; margin: 10px 0 14px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: 8px; padding: 3px;
}
.billing-period-toggle button {
  padding: 6px 16px; font-size: 13px; font-weight: 500;
  color: var(--muted); border-radius: 5px; transition: background .12s, color .12s;
}
.billing-period-toggle button.on { background: var(--indigo-soft); color: var(--indigo-2); }
.billing-plans {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px;
}
.billing-plan {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px;
  display: flex; flex-direction: column; gap: 6px;
}
/* Featured/Popular plan: the "POPULAR" badge alone signals it — no border
   highlight, otherwise it competes with the current-plan card's highlight. */
.billing-plan.is-current { border-color: var(--indigo); background: var(--indigo-soft); }
.billing-plan-head { display: flex; align-items: center; gap: 8px; }
.billing-plan-name { font-weight: 600; font-size: 0.98rem; }
.billing-plan-badge {
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  background: var(--indigo-soft); color: var(--indigo-2); border-radius: 4px; padding: 1px 6px;
}
.billing-plan-price {
  font-size: 1.35rem; font-weight: 700;
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.billing-plan-price small { font-size: 0.8rem; font-weight: 500; color: var(--muted); }
/* "Save N%" pill — only rendered on the Yearly tab when yearly < 12 × monthly. */
.billing-plan-save {
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  background: rgba(74, 222, 128, 0.14); color: #4ade80;
  border-radius: 4px; padding: 2px 7px; line-height: 1.4;
}
.billing-plan-tokens { font-size: 0.82rem; color: var(--text-2); font-weight: 500; }
/* Concrete "what you can do" bullets — derived from service_prices. */
.billing-plan-equivs {
  list-style: none; padding: 0; margin: 4px 0 2px;
  display: flex; flex-direction: column; gap: 3px;
  font-size: 0.78rem; color: var(--text-2); line-height: 1.4;
}
.billing-plan-equivs li {
  position: relative; padding-left: 16px;
}
.billing-plan-equivs li::before {
  content: ""; position: absolute; left: 2px; top: 7px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--indigo-2); opacity: 0.7;
}
.billing-plan-equivs b { font-weight: 600; color: var(--text); }
.billing-plan-desc { font-size: 0.78rem; color: var(--muted); margin: 4px 0 0; line-height: 1.45; font-style: italic; }
.billing-plan button { margin-top: auto; width: 100%; padding: 9px; }
/* Reassurance fineprint under the CTA on paid cards: "Cancel anytime · Stripe-secured". */
.billing-plan-fineprint {
  margin: 6px 0 0; text-align: center;
  font-size: 0.7rem; color: var(--muted); line-height: 1.4;
}
/* "All plans include..." footer beneath the card grid. */
.billing-plans-footer {
  margin: 14px 0 0; padding: 10px 12px;
  font-size: 0.78rem; color: var(--muted); text-align: center; line-height: 1.5;
  border-top: 1px dashed var(--border);
}

/* ── Cover chooser modal ─────────────────────────────────────────────────── */
.auth-box.cover-modal-box { max-width: 560px; text-align: left; }

.cover-modal-tabs {
  display: inline-flex; gap: 2px; margin: 12px 0 16px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: 8px; padding: 3px;
}
.cover-tab {
  padding: 7px 14px; font-size: 13px; font-weight: 500;
  color: var(--muted); border-radius: 5px; background: none; border: 0;
  cursor: pointer; transition: background .12s, color .12s; white-space: nowrap;
}
.cover-tab:hover { color: var(--text-2); }
.cover-tab.on { background: var(--indigo-soft); color: var(--indigo-2); }
.cover-tab-soon {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; opacity: 0.55; margin-left: 4px;
}

.cover-pane { display: block; }
.cover-pane[hidden] { display: none; }

.cover-upload-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 28px 20px; text-align: center;
  border: 2px dashed rgba(255,255,255,0.18); border-radius: 12px;
  background: rgba(255,255,255,0.02);
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.cover-upload-zone:hover,
.cover-upload-zone.drag-over { border-color: var(--indigo); background: var(--indigo-soft); }
.cover-upload-icon { font-size: 1.6rem; margin-bottom: 2px; }
.cover-upload-title { font-size: 0.95rem; color: var(--text); margin: 0; font-weight: 500; }
.cover-upload-sub { font-size: 0.78rem; color: var(--muted); margin: 0; }

.cover-gen-label {
  display: block; font-size: 0.78rem; font-weight: 600;
  color: var(--text-2); letter-spacing: 0.04em; text-transform: uppercase;
  margin-bottom: 6px;
}
.cover-gen-prompt {
  width: 100%; resize: vertical; min-height: 80px;
  padding: 10px 12px; font: inherit; font-size: 0.92rem;
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-sizing: border-box;
}
.cover-gen-prompt:focus { outline: none; border-color: var(--indigo); }
.cover-gen-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.78rem; color: var(--muted); margin: 6px 0 0;
}
.cover-gen-count::after { content: " / 4000"; opacity: 0.6; }
.cover-gen-cost { font-variant-numeric: tabular-nums; }

.cover-modal-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px;
}

.cover-gen-soon {
  text-align: center; padding: 32px 20px;
  border: 1px dashed rgba(255,255,255,0.16); border-radius: 12px;
  background: rgba(255,255,255,0.02);
}
.cover-gen-soon-icon { font-size: 2rem; opacity: 0.6; margin-bottom: 8px; }
.cover-gen-soon-title { font-size: 1rem; font-weight: 600; color: var(--text-2); margin: 0 0 4px; }
.cover-gen-soon-sub { font-size: 0.85rem; color: var(--muted); margin: 0; }

/* ── Cover library grid ──────────────────────────────────────────────────── */
.cover-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  max-height: 56vh;
  overflow-y: auto;
  padding: 4px 2px;
}
.cover-library-empty {
  grid-column: 1 / -1; text-align: center; padding: 40px 16px;
  color: var(--muted); font-size: 0.92rem;
}
.cover-library-tile {
  position: relative; aspect-ratio: 1 / 1; border-radius: 10px;
  overflow: hidden; background: rgba(255,255,255,0.04);
  border: 2px solid transparent; cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.cover-library-tile:hover { transform: translateY(-1px); border-color: var(--indigo); }
.cover-library-tile img,
.cover-library-tile video {
  width: 100%; height: 100%; object-fit: cover; display: block;
  pointer-events: none;
}
.cover-library-tile .tile-badge {
  position: absolute; top: 6px; left: 6px;
  background: rgba(0,0,0,0.55); color: #fff;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; padding: 2px 6px; border-radius: 4px;
}
.cover-library-tile .tile-actions {
  position: absolute; top: 6px; right: 6px;
  display: flex; gap: 4px; opacity: 0; transition: opacity .12s;
}
.cover-library-tile:hover .tile-actions,
.cover-library-tile:focus-within .tile-actions { opacity: 1; }
.cover-library-tile .tile-btn {
  width: 26px; height: 26px; border-radius: 6px;
  background: rgba(0,0,0,0.7); color: #fff; border: 0;
  font-size: 0.85rem; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: background .12s;
}
.cover-library-tile .tile-btn.danger:hover { background: rgba(220,38,38,0.9); }
.cover-library-tile .tile-video-icon {
  position: absolute; bottom: 6px; right: 6px;
  background: rgba(0,0,0,0.6); color: #fff; padding: 2px 6px;
  border-radius: 4px; font-size: 0.7rem;
}
.cover-library-tile.is-busy { pointer-events: none; opacity: 0.55; }

/* ── Cost chip + busy/shimmer ────────────────────────────────────────────── */
.cover-gen-cost {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  background: var(--indigo-soft); color: var(--indigo-2);
  font-size: 0.74rem; font-weight: 600;
}
.cover-gen-cost:empty { display: none; }

.cover-busy {
  margin-top: 14px; padding: 18px;
  border-radius: 10px; background: rgba(255,255,255,0.03);
  border: 1px solid var(--border); text-align: center;
}
.cover-busy[hidden] { display: none; }
.cover-busy-shimmer {
  height: 6px; width: 100%; border-radius: 3px; margin-bottom: 12px;
  background: linear-gradient(90deg,
    rgba(255,255,255,0.05) 0%,
    var(--indigo) 50%,
    rgba(255,255,255,0.05) 100%);
  background-size: 200% 100%;
  animation: coverBusyShimmer 1.4s ease-in-out infinite;
}
@keyframes coverBusyShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.cover-busy-label {
  margin: 0; font-size: 0.92rem; color: var(--text); font-weight: 500;
}
.cover-busy-sub {
  font-size: 0.78rem; color: var(--muted); font-weight: 400;
}

/* ── Edit-with-AI pane ───────────────────────────────────────────────────── */
.cover-edit-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}
.cover-edit-back {
  background: rgba(255,255,255,0.06); color: var(--text-2);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.82rem; padding: 4px 10px; cursor: pointer;
}
.cover-edit-back:hover { background: rgba(255,255,255,0.1); color: var(--text); }
.cover-edit-title { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.cover-edit-source {
  display: flex; align-items: center; gap: 14px;
  padding: 10px; margin-bottom: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border); border-radius: 10px;
}
.cover-edit-source img {
  width: 88px; height: 88px; object-fit: cover;
  border-radius: 8px; flex-shrink: 0;
}
.cover-edit-source-meta { flex: 1; min-width: 0; }
.cover-edit-source-label {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--indigo-2); margin: 0 0 4px;
}
.cover-edit-source-hint {
  font-size: 0.82rem; color: var(--muted); margin: 0;
}

.auth-box.editor-help-box { max-width: 620px; max-height: 85vh; overflow-y: auto; text-align: left; }
.editor-help-body { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.editor-help-body section { display: flex; flex-direction: column; gap: 4px; }
.editor-help-body h3 {
  font-size: 0.95rem; font-weight: 600; color: var(--text);
  margin: 0; letter-spacing: -0.005em;
}
.editor-help-body p, .editor-help-body li {
  font-size: 0.875rem; color: var(--text-2); line-height: 1.5; margin: 0;
}
.editor-help-body ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.editor-help-body b { color: var(--text); font-weight: 600; }

/* Action buttons */
.act-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; border-radius: 7px; font-size: 12px; font-weight: 500;
  color: var(--text-2); background: rgba(255,255,255,0.025);
  border: 1px solid var(--border);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.act-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); border-color: var(--border-strong); }
.act-btn.primary {
  background: linear-gradient(180deg, var(--indigo-2), var(--indigo-3));
  color: white; border-color: transparent;
  box-shadow: 0 6px 18px -8px var(--indigo-glow), 0 0 0 1px rgba(255,255,255,0.08) inset;
}
.act-btn.primary:hover { box-shadow: 0 10px 24px -8px var(--indigo-glow), 0 0 0 1px rgba(255,255,255,0.15) inset; }
.act-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.act-btn.saved {
  color: var(--green);
  border-color: rgba(52,211,153,0.35);
  background: rgba(52,211,153,0.08);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.act-btn.rendering { opacity: 0.85; }
.act-btn.rendering .btn-spinner {
  width: 11px; height: 11px; border-radius: 50%;
  border: 1.8px solid rgba(255,255,255,0.25);
  border-top-color: white;
  animation: btn-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}
.save-status-inline {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--green); letter-spacing: 0.04em;
}

/* Preview mode caption list */
.cap-preview-list {
  padding: 14px 22px 18px; height: 435px; overflow-y: auto;
  display: flex; flex-direction: column;
}
.cap-preview-list::-webkit-scrollbar { width: 8px; }
.cap-preview-list::-webkit-scrollbar-track { background: transparent; }
.cap-preview-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }
.cap-pv {
  display: grid; grid-template-columns: 48px 1fr;
  align-items: baseline; gap: 16px;
  padding: 9px 14px; border-radius: 8px;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s; cursor: pointer;
}
.cap-pv:hover { background: rgba(255,255,255,0.02); }
.cap-pv.playing { background: rgba(99,102,241,0.10); border-color: rgba(99,102,241,0.25); }
.cap-pv-time { font-family: var(--font-mono); font-size: 11px; color: var(--muted-2); letter-spacing: 0.04em; text-align: right; }
.cap-pv.playing .cap-pv-time { color: var(--indigo-2); }
.cap-pv-text { font-size: 15px; line-height: 1.55; color: var(--text-2); letter-spacing: -0.005em; }
.cap-pv.playing .cap-pv-text { color: white; font-weight: 500; }

/* Edit mode caption list */
.cap-list {
  padding: 6px; height: 435px; overflow-y: auto;
}
.cap-list[hidden] { display: none; }
.cap-preview-list[hidden] { display: none; }
.cap-list::-webkit-scrollbar { width: 8px; }
.cap-list::-webkit-scrollbar-track { background: transparent; }
.cap-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }

.cap-row {
  display: grid;
  grid-template-columns: 24px 152px 1fr 60px;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.cap-row:hover { background: rgba(255,255,255,0.025); }
.cap-row.playing { background: rgba(99,102,241,0.07); border-color: rgba(99,102,241,0.18); }
.cap-row.selected { background: rgba(99,102,241,0.14); border-color: rgba(99,102,241,0.45); }
.cap-row.selected.playing { background: rgba(99,102,241,0.2); }
.cap-idx {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--muted); text-align: right;
  /* Clickable: jumps the player to this segment's start. */
  cursor: pointer;
  transition: color 0.12s;
}
.cap-idx:hover { color: var(--indigo-2); }
.cap-row.selected .cap-idx,
.cap-row.playing .cap-idx { color: var(--indigo-2); }

.cap-times { display: flex; align-items: center; gap: 6px; }
.cap-time-group { display: flex; flex-direction: column; align-items: stretch; gap: 3px; }
.cap-time {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 11px; color: var(--text-2);
  padding: 4px 7px; border-radius: 5px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  min-width: 56px; cursor: text;
  appearance: none; -webkit-appearance: none;
  white-space: nowrap; outline: none;
  user-select: text; -webkit-user-select: text;
}
.cap-time:hover { background: rgba(255,255,255,0.06); }
.cap-time:focus,
.cap-time.editing {
  background: rgba(99,102,241,0.18); color: white;
  border-color: rgba(99,102,241,0.5);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
  outline: none;
}
.cap-time-set {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 9px; font-weight: 600;
  letter-spacing: 0.06em; color: var(--muted);
  padding: 3px 7px; border-radius: 5px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  cursor: pointer;
}
.cap-time-set:hover {
  background: rgba(99,102,241,0.15); color: var(--indigo-2);
  border-color: rgba(99,102,241,0.3);
}
.cap-time-set:active { background: rgba(99,102,241,0.25); color: white; }
.cap-arr { color: var(--muted-2); font-size: 11px; align-self: center; }

.cap-text-wrap { min-width: 0; }
.cap-text {
  font-size: 14px; color: var(--text); letter-spacing: -0.005em;
  outline: none; padding: 2px 0; border-radius: 4px;
}
.cap-row.selected .cap-text { color: white; font-weight: 500; }
.cap-text[contenteditable="true"]:focus { background: rgba(255,255,255,0.03); }

.cap-row-actions {
  display: flex; align-items: center; gap: 4px;
  justify-self: end; opacity: 0; transition: opacity 0.12s;
}
.cap-row:hover .cap-row-actions,
.cap-row.selected .cap-row-actions { opacity: 1; }
.cap-act {
  width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 6px; color: var(--muted);
  transition: background 0.12s, color 0.12s;
}
.cap-act:hover { background: rgba(255,255,255,0.07); color: var(--text); }
.cap-act.danger:hover { background: rgba(248,113,113,0.12); color: var(--red); }

/* ===== Caption controls / style toolbar (existing UI adapted) ===== */
.caption-controls {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 16px;
  background: rgba(0,0,0,0.3); border: 1px solid var(--border);
  border-radius: 12px;
}
.caption-row {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.font-picker-wrap { position: relative; }
.font-picker-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 6px; font-size: 12px;
  color: var(--text-2); background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  transition: background 0.12s, color 0.12s;
  /* Fixed width prevents toolbar jumping when long font names are selected */
  width: 170px; justify-content: space-between;
}
/* Truncate long font labels with ellipsis instead of resizing the button */
#fontPickerLabel {
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  min-width: 0; flex: 1;
}
.font-picker-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.font-picker-btn.open { background: var(--indigo-soft); color: var(--indigo-2); border-color: rgba(99,102,241,0.3); }
.font-picker-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50;
  background: rgba(20,21,38,0.98); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 6px;
  min-width: 200px; max-height: 320px; overflow-y: auto;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,0.7); backdrop-filter: blur(20px);
}
.font-picker-dropdown::-webkit-scrollbar { width: 6px; }
.font-picker-dropdown::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.font-group-label {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted-2);
  padding: 8px 10px 4px; pointer-events: none;
}
.font-picker-option {
  display: flex; align-items: center; width: 100%;
  padding: 7px 10px; border-radius: 6px;
  font-size: 13px; color: var(--text-2); cursor: pointer;
  transition: background 0.1s;
  text-align: left;
}
.font-picker-option:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.font-picker-option.active { background: var(--indigo-soft); color: var(--indigo-2); }
.font-size-btn {
  padding: 6px 9px; border-radius: 6px; font-size: 12px;
  color: var(--text-2); background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  transition: background 0.12s, color 0.12s;
}
.font-size-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }
/* Push the trailing pair (9:16 + Reset) to the right edge of the toolbar */
#ratioBtn { margin-left: auto; }
.reset-prefs-btn:hover { background: rgba(255,80,80,0.12) !important; color: #f87171 !important; border-color: rgba(248,113,113,0.3) !important; }
.color-swatch-wrap { position: relative; }
.color-swatch-btn {
  width: 28px; height: 28px; border-radius: 7px;
  border: 2px solid rgba(255,255,255,0.3); cursor: pointer;
  transition: transform 0.1s;
}
.color-swatch-btn:hover { transform: scale(1.06); }
.color-popover {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  z-index: 50;
  background: rgba(20,21,38,0.98); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 10px;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,0.7); backdrop-filter: blur(20px);
}
.color-presets {
  display: grid; grid-template-columns: repeat(7, 28px); gap: 6px; margin-bottom: 8px;
}
.color-preset {
  width: 28px; height: 28px; border-radius: 6px; cursor: pointer;
  border: 2px solid transparent; transition: transform 0.1s, border-color 0.15s;
}
.color-preset:hover { transform: scale(1.06); }
.color-preset.active { border-color: var(--indigo-2); }
.color-custom-row {
  display: flex; align-items: center; gap: 8px;
  padding-top: 8px; border-top: 1px solid var(--border);
}
.caption-color-picker {
  width: 28px; height: 28px; border-radius: 6px; border: 2px solid rgba(255,255,255,0.2);
  background: none; cursor: pointer; padding: 0; flex-shrink: 0;
}
.caption-color-hex {
  flex: 1; background: rgba(255,255,255,0.07); border: 1px solid var(--border);
  border-radius: 6px; color: var(--fg); font-family: var(--font-mono); font-size: 12px;
  padding: 4px 8px; min-width: 0; outline: none; text-transform: uppercase;
}
.caption-color-hex:focus { border-color: var(--indigo-2); background: rgba(255,255,255,0.1); }
.caption-color-hex::placeholder { color: var(--muted); }
.color-eyedropper-btn {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border); background: rgba(255,255,255,0.07);
  color: var(--muted); cursor: pointer; display: flex; align-items: center;
  justify-content: center; transition: background 0.15s, color 0.15s;
}
.color-eyedropper-btn:hover { background: rgba(255,255,255,0.15); color: var(--fg); }
.color-eyedropper-btn:disabled { opacity: 0.35; cursor: default; }

/* ===== Lyrics result header (save/edit/download/render) ===== */
.lyrics-result-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px 14px; border-bottom: 1px solid var(--border);
  gap: 16px; flex-wrap: wrap;
}
.lyrics-result-header h2 {
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--text);
}
.header-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.save-status {
  font-family: var(--font-mono); font-size: 11px; color: var(--green);
  padding: 0 8px; letter-spacing: 0.04em;
}

.cover-upload-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--indigo-2);
  padding: 0 6px;
}
.cover-upload-status[hidden] { display: none; }

/* ===== Captions download — combo button + popover ===== */
/* Mirrors .viz-popover so visuals match the rest of the editor toolbar. */
.download-wrap   { position: relative; display: inline-flex; }
#downloadBtn .chev {
  display: inline-block; margin-left: 2px;
  font-size: 10px; opacity: 0.85;
  transform: translateY(-1px);
}
.download-popover {
  position: absolute;
  /* Open DOWNWARDS — the button sits in editor-card's top region and
     editor-card has overflow:hidden, which would clip an upward popover. */
  top: calc(100% + 8px);
  left: 50%; transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  z-index: 200;
  width: 240px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  display: flex; flex-direction: column; gap: 2px;
}
.download-popover[hidden] { display: none; }
.dl-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 7px 10px;
  background: none; border: none; border-radius: 6px;
  color: var(--text); cursor: pointer; text-align: left;
  transition: background 0.12s;
}
.dl-opt:hover  { background: rgba(99,102,241,0.10); }
.dl-opt b      { font-size: 12px; font-weight: 600; }
.dl-opt em     { font-style: normal; font-size: 11px; color: var(--text-muted); }
.dl-opt:disabled { opacity: 0.55; cursor: progress; }

/* ===== Script / lyrics box ===== */
.script-modal-box {
  max-width: 600px; width: 100%;
  display: flex; flex-direction: column; gap: 12px;
}
.script-modal-box h2 { font-size: 1.1rem; }
#lyricsInput {
  width: 100%; background: rgba(0,0,0,0.3); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px;
  font-family: var(--font-mono); font-size: 12.5px; color: var(--text);
  resize: vertical; min-height: 320px; outline: none;
  transition: border-color 0.15s;
}
#lyricsInput:focus { border-color: rgba(99,102,241,0.4); }
#lyricsInput::placeholder { color: var(--muted-2); }
.script-modal-foot {
  display: flex; justify-content: space-between; align-items: center;
}
.script-modal-actions { display: flex; gap: 8px; }
#alignBtn, #resegBtn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 6px; font-size: 12px; font-weight: 500;
  color: var(--indigo-2); background: var(--indigo-soft);
  border: 1px solid rgba(99,102,241,0.25); font-family: var(--font-sans);
  transition: background 0.12s; cursor: pointer;
}
#alignBtn:hover, #resegBtn:hover { background: rgba(99,102,241,0.18); }
#alignBtn:disabled, #resegBtn:disabled { opacity: 0.5; cursor: not-allowed; }
.align-anim { display: none; align-items: center; gap: 3px; }
.align-anim i { display: block; width: 5px; height: 5px; border-radius: 50%; background: var(--indigo-2); animation: align-bounce 1s ease-in-out infinite; font-style: normal; }
.align-anim i:nth-child(2) { animation-delay: 0.15s; }
.align-anim i:nth-child(3) { animation-delay: 0.3s; }
@keyframes align-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%            { transform: scale(1);   opacity: 1; }
}
#alignBtn.aligning .align-label, #resegBtn.aligning .align-label { display: none; }
#alignBtn.aligning .align-anim,  #resegBtn.aligning .align-anim  { display: inline-flex; }
.align-status {
  font-family: var(--font-mono); font-size: 11px; color: var(--indigo-2);
}

/* ===== Upload card ===== */
.upload-card {
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.2));
  padding: 36px;
}
.transcribe-card {
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.2));
  padding: 24px 36px;
}
.upload-drop {
  border: 2px dashed var(--border-strong); border-radius: 16px;
  padding: 50px 30px; text-align: center;
  background: rgba(255,255,255,0.012);
  transition: background 0.15s, border-color 0.15s; cursor: pointer;
}
.upload-drop:hover, .upload-drop.drag-over {
  border-color: rgba(99,102,241,0.4); background: rgba(99,102,241,0.04);
}
.upload-drop .drop-icon {
  font-size: 36px; margin-bottom: 14px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--indigo-soft); color: var(--indigo-2);
  display: grid; place-items: center; margin: 0 auto 14px;
  border: 1px solid rgba(99,102,241,0.25);
}
.upload-drop .drop-text {
  font-size: 16px; color: var(--text-2); margin: 0;
  font-weight: 400;
}
.upload-drop .drop-text span { color: var(--indigo-2); text-decoration: underline; cursor: pointer; }
.file-status { font-family: var(--font-mono); font-size: 12px; color: var(--green); margin-top: 12px; }
.upload-formats {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted-2); margin-top: 16px;
}

/* SRT import area */
.srt-import-row { margin-top: 12px; }
.srt-toggle-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-2); padding: 6px 0;
  transition: color 0.15s;
}
.srt-toggle-btn:hover { color: var(--indigo-2); }
.srt-toggle-icon { font-size: 16px; color: var(--indigo-2); }
.srt-import-area { margin-top: 10px; }
.srt-drop-zone {
  border: 1px dashed var(--border-strong); border-radius: 10px;
  padding: 18px 24px; display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: var(--text-2); cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.srt-drop-zone:hover, .srt-drop-zone.drag-over { border-color: rgba(99,102,241,0.4); background: rgba(99,102,241,0.04); }
.srt-drop-zone.has-file { border-color: rgba(52,211,153,0.35); background: rgba(52,211,153,0.05); }
.srt-drop-icon { font-size: 18px; }
.srt-file-status { font-family: var(--font-mono); font-size: 12px; color: var(--green); margin-top: 8px; }

/* Upload options */
.step1-options {
  display: grid; grid-template-columns: 1fr 1fr auto;
  gap: 16px; align-items: end;
}
.step1-field { display: flex; flex-direction: column; gap: 7px; }
.lang-label {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.lang-label .hint { font-family: var(--font-sans); font-weight: 400; color: var(--muted-2); margin-left: 6px; letter-spacing: 0; text-transform: none; font-size: 10px; }
.lang-select, select.lang-select {
  appearance: none; -webkit-appearance: none;
  background: rgba(0,0,0,0.3) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M3 4.5l3 3 3-3' stroke='%236e7088' stroke-width='1.4' fill='none' stroke-linecap='round'/></svg>") no-repeat right 12px center;
  background-size: 12px;
  border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 32px 10px 12px; color: var(--text);
  font-size: 13.5px; font-family: var(--font-sans); outline: none; cursor: pointer;
  transition: border-color 0.15s;
}
.lang-select:hover { border-color: var(--border-strong); }
.lang-select:focus { border-color: rgba(99,102,241,0.4); }
.lang-select option { background: #15162a; }
.step1-field--btn .lang-select { display: none; }

/* Caption-length slider — replaces the old dropdown.  10..120 step 5;
   max tick = "Auto" (rendered by JS via the #maxCharsLabel hint).
   The thumb is a circular indigo handle; the track is two segments: filled
   indigo up to the thumb, dim past it.  WebKit + Firefox need their own
   pseudo-elements (no shorthand covers both). */
.length-slider {
  appearance: none; -webkit-appearance: none;
  width: 100%;
  height: 40px;                 /* match the height of .lang-select */
  background: transparent;
  cursor: pointer;
  outline: none;
  --thumb-frac: 50%;            /* set in JS for the gradient split */
}
/* The thumb position can be derived from `value` purely in CSS: the indigo
   fill ends where the thumb is.  We use a linear gradient on the track and
   compute the stop via the `--thumb-frac` custom property the JS sets on
   `input`.  No JS-driven stylesheet writes. */
.length-slider::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(to right,
    var(--indigo) 0,
    var(--indigo) var(--thumb-frac),
    rgba(255,255,255,0.08) var(--thumb-frac),
    rgba(255,255,255,0.08) 100%);
}
.length-slider::-moz-range-track {
  height: 6px; border-radius: 999px;
  background: rgba(255,255,255,0.08);
}
.length-slider::-moz-range-progress {
  height: 6px; border-radius: 999px;
  background: var(--indigo);
}
.length-slider::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo-2), var(--indigo-3));
  border: 2px solid var(--surface);
  margin-top: -6px;             /* center on the 6px track */
  box-shadow: 0 2px 8px rgba(99,102,241,0.45);
  transition: transform 0.12s;
}
.length-slider::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo-2), var(--indigo-3));
  border: 2px solid var(--surface);
  box-shadow: 0 2px 8px rgba(99,102,241,0.45);
  transition: transform 0.12s;
}
.length-slider:hover::-webkit-slider-thumb,
.length-slider:active::-webkit-slider-thumb { transform: scale(1.08); }
.length-slider:hover::-moz-range-thumb,
.length-slider:active::-moz-range-thumb     { transform: scale(1.08); }
.length-slider:focus-visible::-webkit-slider-thumb,
.length-slider:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px var(--indigo-soft); }
#elevenBtn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 9px; font-size: 14px; font-weight: 500;
  background: linear-gradient(180deg, var(--indigo-2), var(--indigo-3));
  color: white; border: none; cursor: pointer;
  box-shadow: 0 8px 24px -8px var(--indigo-glow), 0 0 0 1px rgba(255,255,255,0.1) inset;
  transition: transform 0.1s; white-space: nowrap;
}
#elevenBtn:hover { transform: translateY(-1px); }
#elevenBtn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Token-cost suffix on billable buttons (e.g. "Transcribe · 3 tok"). */
.btn-cost {
  font-weight: 400; font-size: 0.85em;
  opacity: 0.75;
  margin-left: 1px;
}

/* Transcribe + Upload SRT side-by-side. */
.transcribe-btn-group { display: inline-flex; align-items: center; gap: 8px; }
.upload-srt-btn {
  display: inline-flex; align-items: center;
  padding: 10px 14px; border-radius: 9px; font-size: 13px; font-weight: 500;
  background: rgba(255,255,255,0.04); color: var(--text-2);
  border: 1px solid var(--border); cursor: pointer; white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.upload-srt-btn:hover { background: rgba(255,255,255,0.07); color: var(--text); border-color: var(--border-strong); }
.upload-srt-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.upload-srt-btn[hidden] { display: none; }

/* Empty captions state — shown after upload, before transcription. */
.cap-empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 32px; text-align: center; gap: 8px;
  color: var(--muted);
}
.cap-empty-state[hidden] { display: none; }
.cap-empty-icon { color: var(--muted); opacity: 0.55; margin-bottom: 4px; }
.cap-empty-title { font-size: 1rem; font-weight: 600; color: var(--text-2); margin: 0; }
.cap-empty-sub { font-size: 0.875rem; line-height: 1.55; color: var(--muted); margin: 0; max-width: 420px; }
.cap-empty-sub b { color: var(--text-2); font-weight: 600; }

/* "Transcribe" / "Upload SRT" inline links inside the empty state.
   Styled to look like a link but actually buttons so click handlers + a11y
   are correct. */
.cap-empty-link {
  background: transparent; border: 0; padding: 0;
  color: var(--indigo-2); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: underline;
  text-decoration-color: rgba(129, 140, 248, 0.45);
  text-underline-offset: 3px;
}
.cap-empty-link:hover { color: var(--indigo); text-decoration-color: currentColor; }

/* Editor toolbar is meaningless before captions exist — hide it when the
   editor card is in its empty state. */
.editor-card.is-empty .editor-head { display: none; }

/* Card-wide highlight used to draw the user's eye to the transcribe card
   after they click an inline link in the empty state.  A soft indigo glow
   that swells and fades — feels less alarming than a hard outline at this
   size, and works at the card's existing rounded corners. */
@keyframes capCardHighlight {
  0%   {
    box-shadow:
      0 0 0  0   rgba(129, 140, 248, 0.0),
      0 0 0  0   rgba(129, 140, 248, 0.0) inset;
    border-color: var(--border);
  }
  25%  {
    box-shadow:
      0 0 28px 6px rgba(129, 140, 248, 0.45),
      0 0 0    1px rgba(129, 140, 248, 0.55) inset;
    border-color: rgba(129, 140, 248, 0.8);
  }
  100% {
    box-shadow:
      0 0 0  0 rgba(129, 140, 248, 0.0),
      0 0 0  0 rgba(129, 140, 248, 0.0) inset;
    border-color: var(--border);
  }
}
.transcribe-card.cap-highlight {
  animation: capCardHighlight 1.8s ease-out;
}

/* ===== Progress bar ===== */
.progress-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border-radius: 10px;
  background: rgba(0,0,0,0.3); border: 1px solid var(--border);
}
.progress-bar[hidden] { display: none; }
.progress-track {
  flex: 1; height: 6px; background: rgba(255,255,255,0.06);
  border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--indigo-3), var(--indigo-2));
  border-radius: 3px; width: 0;
  box-shadow: 0 0 12px rgba(99,102,241,0.5);
}
.progress-fill.determinate { transition: width 0.3s ease; }
.progress-label { font-family: var(--font-mono); font-size: 11px; color: var(--text-2); white-space: nowrap; }

/* ===== Renders panel (in canvas, legacy) ===== */
.renders-rail-list {
  max-height: 260px;
  overflow-y: auto;
}
.renders-rail-list::-webkit-scrollbar { width: 4px; }
.renders-rail-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }
.render-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 8px;
  background: rgba(255,255,255,0.02); border: 1px solid var(--border);
  font-size: 12px;
}
.render-item .render-ratio { flex-shrink: 0; }
.render-item .render-spacer { flex: 1; }
.render-date {
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--muted); letter-spacing: 0.02em;
  margin-left: 4px; flex-shrink: 0;
}
.render-ratio {
  font-family: var(--font-mono); font-size: 9.5px; color: var(--muted);
  padding: 2px 6px; border-radius: 4px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
}
.render-badge {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 4px; font-weight: 500;
}
.render-badge.done { color: var(--green); background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.18); }
.render-badge.processing, .render-badge.pending { color: var(--indigo-2); background: var(--indigo-soft); border: 1px solid rgba(99,102,241,0.22); }
.render-dots { display: inline-flex; align-items: center; gap: 3px; padding: 2px 2px; }
.render-dots span {
  display: block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--indigo-2);
  animation: render-dot-bounce 1.1s ease-in-out infinite;
}
.render-dots span:nth-child(2) { animation-delay: 0.18s; }
.render-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes render-dot-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%            { transform: scale(1);   opacity: 1; }
}
.render-badge.error { color: var(--red); background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.18); }
.render-badge-btn { cursor: pointer; font: inherit; transition: background 0.12s, border-color 0.12s; }
.render-badge-btn:hover { background: rgba(248,113,113,0.18); border-color: rgba(248,113,113,0.35); }
.render-error-box { max-width: 560px; text-align: left; }
.render-error-body {
  margin: 12px 0 16px; padding: 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  font-family: var(--font-mono); font-size: 12px; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
  max-height: 50vh; overflow: auto;
}
/* Render-row action buttons.  Same indigo chip styling; flex so the icon
   and label sit nicely on one row.  Width is intrinsic (sizes to content). */
.render-download,
.render-preview-btn {
  height: 24px; padding: 0 8px; border-radius: 5px;
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--indigo-2);
  background: var(--indigo-soft); border: 1px solid rgba(99,102,241,0.25);
  text-decoration: none; cursor: pointer;
  font-size: 11px; font-weight: 600; line-height: 1;
  transition: background 0.12s;
  flex-shrink: 0;
}
.render-download:hover,
.render-preview-btn:hover { background: rgba(99,102,241,0.2); }
.render-delete {
  width: 22px; height: 22px; border-radius: 4px;
  display: grid; place-items: center; color: var(--muted);
  font-size: 13px; transition: background 0.12s, color 0.12s; flex-shrink: 0;
}
.render-delete:hover { background: rgba(248,113,113,0.12); color: var(--red); }
.render-error-msg { font-family: var(--font-mono); font-size: 10px; color: var(--red); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Render preview modal ── */
.render-preview-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}
/* Landscape 16:9 — match preview player width so font sizes compare 1:1 */
.render-preview-box.landscape {
  width: min(90vw, 702px);
}
.render-preview-box.landscape #renderPreviewVideo {
  width: 100%; height: auto;
  aspect-ratio: 16/9;
}
/* Portrait 9:16 — constrain by height, let width follow */
.render-preview-box.portrait {
  width: auto;
}
.render-preview-box.portrait #renderPreviewVideo {
  height: min(78vh, 640px); width: auto;
  aspect-ratio: 9/16;
}
.render-preview-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-right: 32px; /* leave room for the absolute close button */
}
.render-preview-title {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  letter-spacing: 0.05em; text-transform: uppercase;
}
.render-preview-actions { display: flex; align-items: center; gap: 8px; }
.render-preview-dl {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; color: var(--indigo-2);
  padding: 5px 10px; border-radius: 6px;
  background: var(--indigo-soft); border: 1px solid rgba(99,102,241,0.25);
  text-decoration: none; transition: background 0.12s;
}
.render-preview-dl:hover { background: rgba(99,102,241,0.2); }
#renderPreviewVideo {
  border-radius: 10px;
  background: #000; display: block;
  outline: none; cursor: pointer;
}
.rp-transport { margin-top: 0; }

/* ===== Modals ===== */
.auth-modal {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-modal[hidden] { display: none; }
.auth-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 40px 32px;
  max-width: 400px; width: 100%;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
.auth-box.script-modal-box { max-width: 600px; }
.auth-box h2 { font-size: 1.3rem; font-weight: 700; color: var(--text); margin: 0; }
.auth-sub { font-size: 0.88rem; color: var(--muted); line-height: 1.5; margin: 0; }
.auth-legal { font-size: 0.72rem; color: var(--muted); line-height: 1.5; margin: 16px 0 0; text-align: center; }
.auth-legal a { color: var(--text-2); text-decoration: underline; text-underline-offset: 2px; }
.auth-legal a:hover { color: var(--text); }
.auth-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none;
  color: var(--muted); font-size: 1rem;
  cursor: pointer; line-height: 1; padding: 4px;
  transition: color 0.15s;
}
.auth-close:hover { color: var(--text); }

/* Admin impersonation banner — sticky amber bar shown at the top of /app-v2
   when /auth/me reports impersonating=true. */
.impersonation-banner {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(90deg, rgba(251,191,36,0.18), rgba(251,191,36,0.10));
  border-bottom: 1px solid rgba(251,191,36,0.45);
  color: #fde68a;
  font-size: 13px;
}
.impersonation-banner .ib-icon { font-size: 16px; }
.impersonation-banner .ib-text { flex: 1; }
.impersonation-banner .ib-text b { color: #fef3c7; font-weight: 600; }
.impersonation-banner .ib-revert {
  background: rgba(251,191,36,0.18);
  color: #fde68a;
  border: 1px solid rgba(251,191,36,0.55);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.impersonation-banner .ib-revert:hover {
  background: rgba(251,191,36,0.30);
  border-color: rgba(251,191,36,0.85);
}
.impersonation-banner .ib-revert:disabled { opacity: 0.6; cursor: progress; }

/* "blocking" mode forces sign-in: heavier backdrop, no close button.
   JS already hides the button + ignores click-outside, but enforcing it in
   CSS too means a momentary JS slip can't expose the dismiss path. */
.auth-modal.blocking { backdrop-filter: blur(6px); background: rgba(0,0,0,0.65); }
.auth-modal.blocking .auth-close { display: none; }
/* Vertical stack between the email/code input and its submit button.
   Targets both the legacy IDs (inline modal in app-v2.html) AND the new
   class-based selectors used by the <auth-modal> Web Component so spacing
   is identical in both. */
#authStep1, #authStep2, .am-step1, .am-step2 {
  display: flex; flex-direction: column; gap: 12px;
}
#authStep1[hidden], #authStep2[hidden],
.am-step1[hidden], .am-step2[hidden] { display: none; }
.auth-box input[type="email"],
.auth-box input[type="text"] {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: 1rem;
  padding: 11px 14px; outline: none;
  transition: border-color 0.15s; width: 100%;
  box-sizing: border-box;
}
.auth-box input:focus { border-color: var(--indigo); }
.auth-box input[type="text"] {
  letter-spacing: 0.2em;
  font-family: var(--font-mono);
  text-align: center; font-size: 1.3rem;
}
.auth-email-label { font-size: 0.84rem; color: var(--muted); text-align: center; margin: 0; }
.auth-error { font-size: 0.84rem; color: var(--red); text-align: center; margin: 0; }

/* Google Sign-In wrap inside the auth modal.  Hidden by default; shown
   only after GIS library loads + a non-empty client_id is fetched. */
.google-signin-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  margin-bottom: 4px;
}
.google-signin-wrap[hidden] { display: none; }
.google-signin-btn { display: flex; justify-content: center; width: 100%; }
.auth-or {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  color: var(--muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
}
.auth-or::before,
.auth-or::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 9px; font-size: 14px; font-weight: 500;
  background: linear-gradient(180deg, var(--indigo-2), var(--indigo-3));
  color: white; border: none; cursor: pointer;
  box-shadow: 0 6px 18px -8px var(--indigo-glow);
  transition: transform 0.1s;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.auth-box .btn-primary { width: 100%; padding: 12px; }
.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 9px; font-size: 14px; font-weight: 500;
  color: var(--text-2); background: rgba(255,255,255,0.04);
  border: 1px solid var(--border); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-secondary:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.btn-danger {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 16px; border-radius: 9px; font-size: 14px; font-weight: 500;
  color: white; background: rgba(248,113,113,0.8); border: none; cursor: pointer;
  transition: background 0.15s;
}
.btn-danger:hover { background: var(--red); }
.btn-link {
  background: none; border: none; cursor: pointer;
  color: var(--indigo-2); font-size: 0.85rem;
  text-decoration: underline; text-underline-offset: 2px;
  padding: 0; transition: opacity 0.15s; text-align: left;
}
.btn-link:hover { opacity: 0.75; }

/* Confirm dialog */
.confirm-box { max-width: 360px; text-align: center; padding: 28px 24px; }
.confirm-msg { font-size: 15px; color: var(--text); margin: 0 0 20px; line-height: 1.5; }
.confirm-actions { display: flex; justify-content: center; gap: 10px; }

/* Feedback modal */
.feedback-box { max-width: 460px; }
.feedback-textarea {
  width: 100%; background: rgba(0,0,0,0.3); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; font-size: 14px; color: var(--text);
  resize: vertical; min-height: 120px; outline: none;
  transition: border-color 0.15s; margin-bottom: 8px;
}
.feedback-textarea:focus { border-color: rgba(99,102,241,0.4); }
.feedback-textarea::placeholder { color: var(--muted); }
.feedback-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* Feedback bubble + CTA peek */
.feedback-wrap {
  position: fixed; bottom: 24px; right: 24px; z-index: 80;
  display: flex; align-items: center; gap: 12px;
  pointer-events: none;
}
.feedback-bubble {
  pointer-events: auto;
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(180deg, var(--indigo-2), var(--indigo-3));
  color: white; display: grid; place-items: center;
  box-shadow: 0 8px 24px -6px var(--indigo-glow);
  border: none; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
.feedback-bubble:hover { transform: scale(1.06); box-shadow: 0 12px 30px -6px var(--indigo-glow); }

.feedback-peek {
  position: relative;
  max-width: 260px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  font-size: 12.5px; line-height: 1.4; color: var(--text);
  box-shadow: 0 10px 28px -8px rgba(0,0,0,0.55);
  opacity: 0; transform: translateX(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.feedback-peek::after {
  content: "";
  position: absolute; right: -6px; top: 50%;
  width: 10px; height: 10px;
  transform: translateY(-50%) rotate(45deg);
  background: var(--surface-2);
  border-right: 1px solid var(--border-strong);
  border-top: 1px solid var(--border-strong);
}
/* Reveal on hover/focus of the chat bubble */
/* Only trigger when the mouse is over the bubble itself — the wrap also
   covers the (invisible) peek area + gap, which would feel like the message
   was triggering itself on an empty hit box. :has() targets the wrap when
   its child bubble is hovered/focused. */
.feedback-wrap:has(.feedback-bubble:hover) .feedback-peek,
.feedback-wrap:has(.feedback-bubble:focus) .feedback-peek {
  opacity: 1; transform: translateX(0);
}
@media (max-width: 640px) {
  .feedback-peek { display: none; }    /* keep the bubble compact on phones */
}

/* ===== Selection ===== */
::selection { background: var(--indigo-soft); color: var(--text); }

/* ===== Audio Visualizer ===== */
.viz-el {
  position: absolute;
  display: flex;
  align-items: center;          /* bars centred — grow up AND down from midline */
  justify-content: center;
  gap: 3px;
  z-index: 20;
  pointer-events: none;
  overflow: hidden;
  border-radius: 4px;
}
.viz-el.draggable { pointer-events: all; cursor: move; touch-action: none; }

.viz-bar {
  flex: 1;
  border-radius: 50px;           /* fully rounded caps */
  transform-origin: center;      /* scale from middle so bars expand both ways */
  transform: scaleY(0.07);
  transition: transform 0.25s ease;
  background: var(--viz-color, #60a5fa);
}

/* When audio is loud enough, animate */
.viz-el.active .viz-bar {
  transition: none;
  animation: viz-bounce var(--vd, 0.65s) ease-in-out infinite alternate;
}

@keyframes viz-bounce {
  from { transform: scaleY(0.12); }
  to   { transform: scaleY(1); }
}

.viz-resize-handle {
  position: absolute;
  height: 10px;
  cursor: s-resize;
  z-index: 21;
  pointer-events: all;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viz-resize-handle::after {
  content: '';
  display: block;
  width: 32px; height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.55);
}

/* Right-edge handle for width resize */
.viz-width-handle {
  position: absolute;
  width: 10px;
  cursor: ew-resize;
  z-index: 21;
  pointer-events: all;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viz-width-handle::after {
  content: '';
  display: block;
  width: 4px; height: 28px;
  border-radius: 2px;
  background: rgba(255,255,255,0.55);
}

.viz-wrap { position: relative; height: 38px; display: flex; align-items: center; }
.viz-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%; transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  z-index: 200;
  width: 252px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.viz-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-bottom: 10px;
}
.viz-type-btn {
  padding: 5px 3px;
  font-size: 0.73rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.viz-type-btn.active { border-color: var(--accent); color: var(--accent); }
.viz-type-btn:hover:not(.active):not(:disabled) { border-color: rgba(255,255,255,0.25); }
.viz-type-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.viz-opacity-row {
  padding: 8px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.viz-opacity-header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.78rem; color: var(--muted); margin-bottom: 6px;
}
.viz-opacity-header span:last-child {
  font-family: var(--font-mono); color: var(--fg);
}
.viz-opacity-slider {
  width: 100%; height: 4px; cursor: pointer;
  accent-color: var(--accent); border-radius: 2px;
}
/* ── Karaoke controls (same visual language as viz) ── */
.karaoke-wrap { position: relative; }
#karaokeBtn.active { border-color: var(--accent); color: var(--accent); }
.karaoke-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%; transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  z-index: 200;
  width: 252px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.karaoke-toggle-row {
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 8px; margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem; color: var(--text);
  cursor: pointer;
}
.karaoke-toggle-row input[type="checkbox"] { cursor: pointer; }
.karaoke-style-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
  margin-bottom: 10px;
}
.karaoke-style-btn {
  padding: 5px 3px;
  font-size: 0.73rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.karaoke-style-btn.active { border-color: var(--accent); color: var(--accent); }
.karaoke-style-btn:hover:not(.active) { border-color: rgba(255,255,255,0.25); }
#karaokeColorMount, #vizColorMount {
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}
.karaoke-status {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem; color: var(--muted);
  font-family: var(--font-mono);
}
.karaoke-status.error { color: var(--red); }

/* Active word in the live preview caption */
.karaoke-active {
  transition: color 0.08s, background 0.08s;
}
.karaoke-active[data-style="color"] {
  color: var(--karaoke-color, #ffd700);
}
/* Stroke = thick colored stroke around each letter, fill keeps caption color.
   Matches the libass \bord render: each letter gets a thick colored outline. */
.karaoke-active[data-style="stroke"] {
  -webkit-text-stroke: 0.18em var(--karaoke-color, #ffd700);
  paint-order: stroke fill;
}

/* ===== Responsive overrides — kept at end so source order wins
   against base rules later in the file (e.g. .proj-head h1). ===== */
@media (max-width: 999px) {
  .proj-head h1 { font-size: 18px; }
  .proj-head h1 .file-pill { font-size: 10px; padding: 3px 7px; }
}
@media (max-width: 640px) {
  .proj-head h1 { font-size: 15px; }
  .proj-head h1 .file-pill { font-size: 9.5px; padding: 2px 6px; }
}
@media (max-width: 480px) {
  .proj-head h1 { font-size: 13px; }
}
