/* ============================================================================
   Clipper Studio — application stylesheet
   ----------------------------------------------------------------------------
   Contents (bands appear in this order):
     1.  Design tokens
     2.  Base & reset
     3.  Sidebar / navigation shell
     4.  Layout primitives (shell, panels, headings)
     5.  Buttons & interactive controls
     6.  Forms & fields
     7.  Status badges & alerts
     8.  Dashboard / projects / uploads
     9.  Project detail & clips
     10. Editor (preview, timeline chrome, cue list)
     11. Covers / render config
     12. Story workflow
     13. Ranking / compilation
     14. Clip asset library
     15. Job progress (SSE panel)
     16. Publishing hub
     17. Editor timeline (nodes generated by editor-timeline.js)
   Responsive breakpoints live inside their bands; 820px is the primary
   mobile switch (sidebar off-canvas).
   ========================================================================== */

/* 1. DESIGN TOKENS --------------------------------------------------------- */

:root {
  color-scheme: dark;

  /* Surfaces (zinc scale, Opus-style): the page is near-black with a hint of
     blue (#0E1015), the editor canvas drops to zinc-950, and panels lift
     through greyscale steps. Borders are 1px zinc-800 -- surfaces are
     separated by shade steps, not heavy outlines. */
  --bg: #0e1015;
  --canvas: #09090b;
  --sidebar: #101114;
  --surface: #18181b;
  --surface-2: #202024;
  --surface-3: #27272a;
  --hover: #2f2f2f;
  --border: #27272a;
  --border-strong: #3f3f46;

  /* Text. Muted ≈ zinc-400, subtle ≈ zinc-500; both ≥ 4.5:1 on --surface. */
  --text: #fafafa;
  --muted: #9b9ea3;
  --subtle: #8b8b96;

  /* The signature Opus move: the PRIMARY CTA is WHITE with near-black text.
     The chrome stays greyscale and color appears only in small accents.
     --primary* remain as aliases because older component rules below still
     speak that name; new rules should use --cta* / --accent*. */
  --cta-bg: #fafafa;
  --cta-fg: #18181b;
  --cta-hover: #e4e4e7;
  --accent: #fafafa;
  --accent-strong: #ffffff;
  --accent-soft: rgba(255, 255, 255, .07);
  --accent-glow: rgba(255, 255, 255, .18);
  --primary: var(--accent);
  --primary-strong: var(--accent-strong);
  --primary-soft: var(--accent-soft);

  /* Functional colors. Status rules must pair each with an icon/label, never
     color alone (WCAG 1.4.1). Green doubles as the transcript keyword hue. */
  --keyword: #3dd68c;
  --cyan: #58b6ff;
  --success: #3dd68c;
  --warning: #f5b942;
  --danger: #ff6b7d;

  /* Typography. Geist Sans carries the UI; Poppins (display) is reserved for
     big headings and wordmark moments. All vendored locally so the studio
     look survives offline; the stacks degrade cleanly to system faces. */
  --font-sans: "Geist Sans", "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Poppins", "Geist Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  /* 4/8-based spacing scale. Used for PANEL-level rhythm (padding, section
     gaps); the many small one-off paddings are left alone deliberately --
     panel rhythm is what reads as structure, a 2px difference on a chip is
     not. */
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;
  /* One padding for every panel in the app, so nothing has to remember a
     number. Scales down on narrow viewports where 1.6rem of inset costs too
     much of the usable width. */
  --panel-pad: clamp(1.1rem, 2.2vw, 1.6rem);

  /* Opus radius language: restrained 6px on controls and cards, 4px on
     inner chips, ~10px only on large panels/modals. Not pill-shaped. */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, .3);
  --sidebar-width: 64px;

  /* Form-control boundaries are non-text UI and need 3:1 against their own
     fill (WCAG 1.4.11). The decorative --border above is far below that on
     the input background, so fields get their own token rather than
     borrowing it. */
  --field-border: #5d5d66;          /* ≈3:1 on the zinc input fill */
  --field-border-hover: #7c7c86;

  /* One motion rhythm for the whole app: micro-interactions land in the
     150-300ms band, and exits run shorter than entrances so the UI feels
     responsive rather than sticky. */
  --dur-fast: 120ms;
  --dur: 180ms;
  --dur-slow: 260ms;
  --ease-out: cubic-bezier(.22, .8, .3, 1);
  --ease-in: cubic-bezier(.5, 0, .8, .4);

  /* A declared layer scale, so a new overlay never has to guess a number. */
  --z-base: 1;
  --z-raised: 10;
  --z-sticky: 80;
  --z-nav: 100;
  --z-overlay: 900;
  --z-modal: 1000;
  --z-toast: 1500;
  --z-skip: 2000;
}

/* JS toggles `hidden` on grid/flex children all over the app; without this,
   any display other than the default defeats the attribute. One global rule
   replaces the old per-class rescue rules. */
[hidden] { display: none !important; }

/* Vendored typefaces. Geist Sans (UI) is served as two static weights; the
   500 face also covers the 560-680 weight range this sheet requests via
   synthesis-free nearest-match. Poppins is the display voice for big
   headings only. Inter remains vendored as the first fallback. All are
   latin-subset woff2, font-display: swap keeps first paint on the fallback. */
@font-face {
  font-family: "Geist Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/geist-sans-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Geist Sans";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("../fonts/geist-sans-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/poppins-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/poppins-latin-700-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-var.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* 2. BASE & RESET ---------------------------------------------------------- */

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
}

button, input, select, textarea { font: inherit; }
button, a { touch-action: manipulation; }
/* Links read as near-white rather than colored -- the chrome is greyscale
   and affordance comes from underline + hover brightening. */
a { color: #d4d4d8; text-underline-offset: 3px; }
a:hover { color: var(--text); }
svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3, p { margin-top: 0; }
/* Display voice: Poppins carries the big page titles; section headings stay
   in the UI face so panels read calm (Opus pattern). */
h1 { margin-bottom: .6rem; font-family: var(--font-display); font-weight: 700; font-size: clamp(1.9rem, 3.6vw, 2.8rem); line-height: 1.08; letter-spacing: -.03em; }
h2 { margin-bottom: .45rem; font-size: clamp(1.3rem, 2vw, 1.7rem); line-height: 1.2; letter-spacing: -.025em; font-weight: 650; }
h3 { margin-bottom: .35rem; font-size: 1.05rem; line-height: 1.3; font-weight: 600; }
code { padding: .1rem .3rem; border: 1px solid var(--border); border-radius: 5px; background: #131316; }

.sr-only, .skip-link:not(:focus) { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.skip-link:focus { position: fixed; z-index: var(--z-skip); left: 1rem; top: 1rem; padding: .75rem 1rem; border-radius: var(--radius-sm); background: var(--text); color: var(--bg); }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }

/* 3. NAVIGATION RAIL --------------------------------------------------------
   Desktop (≥820px): a permanent 64px icon-only rail in the Opus manner --
   greyscale chrome, tooltips instead of labels, active state = raised zinc.
   Below 820px the same markup becomes an off-canvas drawer WITH labels. */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: var(--z-nav);
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: .9rem .65rem;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
}
.brand { display: inline-flex; align-items: center; gap: .7rem; color: var(--text); font-weight: 700; letter-spacing: -.02em; text-decoration: none; }
/* White mark with a near-black glyph: the one bright element in an otherwise
   greyscale chrome (Opus pattern -- color lives in tiny accents only). */
.brand-mark { display: grid; width: 2rem; height: 2rem; flex: none; place-items: center; border-radius: 6px; background: var(--cta-bg); color: var(--cta-fg); }
.brand-mark svg { width: 1.05rem; fill: currentColor; stroke: none; }
.desktop-brand { justify-content: center; gap: 0; margin: .1rem 0 1.4rem; font-size: 1.05rem; }
.primary-nav { display: grid; gap: .3rem; }
.primary-nav a { display: flex; width: 40px; min-height: 40px; align-items: center; justify-content: center; gap: .75rem; margin-inline: auto; padding: 0; border-radius: 6px; color: var(--muted); font-size: .94rem; font-weight: 550; text-decoration: none; transition: color 160ms ease, background 160ms ease; }
.primary-nav a svg { flex: none; }
.primary-nav a:hover { background: var(--surface-2); color: var(--text); }
.primary-nav a.active { background: var(--surface-3); color: var(--text); }
/* Source Clipping and Story Generation are separate products (§24); the
   hairline separators keep the rail readable as sections without labels. */
.nav-group { margin-top: .9rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.nav-label, .eyebrow { margin: 0 0 .45rem; color: var(--subtle); font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.sidebar-bottom { display: grid; gap: .3rem; margin-top: auto; }
.mobile-topbar { display: none; }
.nav-scrim { position: fixed; inset: 0; z-index: var(--z-overlay); background: rgba(0,0,0,.72); backdrop-filter: blur(4px); }

/* Rail tooltips: generated from each link's data-tip and rendered to the
   right of the rail. Labels are absent by design, so hover AND focus must
   name the destination. Scoped to the rail -- page-level data-tip controls
   keep their own layouts. */
@media (min-width: 820px) {
  .sidebar .nav-text, .sidebar .nav-label { display: none; }
  .sidebar [data-tip] { position: relative; }
  .sidebar [data-tip]:hover::after,
  .sidebar [data-tip]:focus-visible::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 14px);
    top: 50%;
    transform: translateY(-50%);
    z-index: calc(var(--z-nav) + 1);
    padding: .38rem .65rem;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: #131316;
    box-shadow: var(--shadow-sm);
    color: var(--text);
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
  }
}

/* Mobile: the rail becomes a labelled off-canvas drawer. */
@media (max-width: 819px) {
  .sidebar { width: 262px; padding: 1.25rem 1rem; transform: translateX(-102%); transition: transform 220ms ease; }
  .nav-open .sidebar { transform: translateX(0); }
  .primary-nav a { width: auto; margin-inline: 0; justify-content: flex-start; padding: .65rem .75rem; }
  .desktop-brand { justify-content: flex-start; gap: .7rem; margin: .15rem .55rem 1.6rem; }
}

.app-main { min-height: 100dvh; margin-left: var(--sidebar-width); }
.content-shell { width: min(100%, 1240px); margin: 0 auto; padding: 2.25rem clamp(1.25rem, 4vw, 3.5rem) 5rem; }
/* A panel separates from the page via a crisp border plus a lifted fill.
   The fill is kept deliberately dark: brightening it far enough to carry the
   separation on its own pushed --subtle text below 4.5:1 on that panel, and
   readable text outranks a decorative fill difference. */
.surface { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: 0 1px rgba(255,255,255,.03) inset; }
/* THE panel primitive. Compound selector on purpose: `.section-block` alone
   stays a pure spacing wrapper, and `.surface` cards that set their own
   padding are untouched. */
.surface.section-block { padding: var(--panel-pad); }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; margin-bottom: 2rem; }
.page-heading > div { max-width: 780px; }
.page-subtitle { max-width: 680px; margin: 0; color: var(--muted); font-size: 1.02rem; }
.section-block { margin-top: var(--space-6); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); padding-bottom: var(--space-3); border-bottom: 1px solid var(--border); }
.section-heading p { margin: .35rem 0 0; color: var(--muted); }
.section-heading h2 { margin: 0; }
.section-intro { margin: 2rem 0 1.5rem; }
.section-intro p:not(.eyebrow) { max-width: 720px; color: var(--muted); }
.hint { color: var(--muted); font-size: .88rem; }
.empty { color: var(--muted); }

.button, button.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: .5rem; padding: .65rem 1rem; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-weight: 670; line-height: 1.1; text-decoration: none; touch-action: manipulation; transition: transform var(--dur) var(--ease-out), background var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out); }
.button:hover { transform: translateY(-1px); }
/* Pressed feedback: hover alone tells a touch or keyboard user nothing, and
   an action with no acknowledgement reads as a dropped click. Faster than the
   hover transition so the press feels immediate. */
.button:active { transform: translateY(0) scale(.985); transition-duration: var(--dur-fast); }
/* THE signature Opus pattern: the primary call to action is white with
   near-black text. No gradient, no glow -- the button itself is the color. */
.button-primary { background: var(--cta-bg); color: var(--cta-fg); }
.button-primary:hover { background: var(--cta-hover); }
.button-secondary { border-color: var(--border-strong); background: var(--surface-3); color: var(--text); }
.button-secondary:hover { border-color: #52525b; color: white; background: var(--hover); }
.button:disabled, .button[aria-disabled='true'] { cursor: not-allowed; opacity: .5; transform: none; box-shadow: none; }
/* A button awaiting a response IS busy -- that is a different state and
   gets the waiting cursor plus a live region elsewhere. */
.button[data-busy] { cursor: progress; opacity: .7; }
.button-row, .metadata-actions, .clip-primary-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
/* Help text belongs under the controls, not wedged between them. */
.button-row > p { flex: 1 0 100%; margin: 0; }
.clip-primary-actions form { margin: 0; }
.icon-button { display: inline-grid; width: 44px; min-width: 44px; height: 44px; padding: 0; place-items: center; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none; }
.icon-button:hover, .icon-button.copied { border-color: var(--primary); color: var(--text); background: var(--primary-soft); }
.text-button { min-height: 40px; padding: .35rem .2rem; border: 0; background: transparent; color: #d4d4d8; cursor: pointer; font-weight: 600; }
.text-button:hover { color: var(--text); }

input, select, textarea { width: 100%; min-height: 44px; padding: .65rem .75rem; border: 1px solid var(--field-border); border-radius: 6px; background: #101013; color: var(--text); font-size: 1rem; transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out); }
input:hover, select:hover, textarea:hover { border-color: var(--field-border-hover); }
/* The global focus ring stays; this adds the field's own state so the active
   control is obvious even where an outline is visually tight. */
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input::placeholder, textarea::placeholder { color: var(--subtle); opacity: 1; }
input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .55; }
textarea { min-height: 78px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #69758a; }
label { color: #dce3ef; font-size: .88rem; font-weight: 620; }
label > input, label > select, label > textarea { display: block; margin-top: .35rem; }
.field-label { display: block; margin-bottom: .45rem; color: #dce3ef; font-size: .88rem; font-weight: 620; }
.switch-label { display: inline-flex; min-height: 44px; align-items: center; gap: .65rem; cursor: pointer; }
.switch-label input { width: 1.1rem; min-height: 1.1rem; margin: 0; accent-color: var(--primary); }

.status, .count-badge { display: inline-flex; min-height: 26px; align-items: center; padding: .18rem .55rem; border: 1px solid var(--border); border-radius: 999px; background: rgba(255,255,255,.025); color: var(--muted); font-size: .72rem; font-weight: 720; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }

/* Icon macro primitives (components/icons.html). Inline-block so the svg
   sits on a text baseline inside buttons and headings without extra
   wrappers. */
svg.icon { display: inline-block; flex: none; vertical-align: -0.18em; }

/* Filter chip row (components/ui.html filter_chips). Chips read as one
   segmented group; the active chip takes the accent tint. */
.chip-row { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip { display: inline-flex; min-height: 30px; align-items: center; padding: .22rem .7rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .78rem; font-weight: 640; text-decoration: none; transition: border-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out), background var(--dur) var(--ease-out); }
a.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }

/* Right-hand side of section headings / page headers (components/ui.html):
   badges, counts, and actions align to the heading baseline. */
.section-heading-side { display: inline-flex; align-items: center; gap: .6rem; flex-wrap: wrap; justify-content: flex-end; }
.page-heading-actions { display: inline-flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.status-ready, .status-completed, .status-rendered { border-color: rgba(69,213,151,.35); background: rgba(69,213,151,.09); color: #83eab9; }
.status-processing, .status-analyzing, .status-uploading, .status-downloading, .status-uploaded { border-color: rgba(69,216,255,.35); background: rgba(69,216,255,.08); color: #7ae6ff; }
.status-pending, .status-created, .status-queued, .status-planned { border-color: rgba(245,185,66,.35); background: rgba(245,185,66,.08); color: #ffd177; }
/* Story Video Generation stages (§24) reuse the same palette as clipping. */
.status-generating_story, .status-finalizing_story, .status-analyzing_emotion, .status-generating_tts, .status-narrating, .status-rendering { border-color: rgba(69,216,255,.35); background: rgba(69,216,255,.08); color: #7ae6ff; }
.status-story_ready, .status-story_approved, .status-voice_selected, .status-tts_ready, .status-narrated { border-color: rgba(69,213,151,.35); background: rgba(69,213,151,.09); color: #83eab9; }
.status-awaiting_story_approval, .status-awaiting_voice_selection { border-color: rgba(250,196,92,.4); background: rgba(250,196,92,.09); color: #ffd681; }
.status-failed, .status-missing_file { border-color: rgba(255,107,125,.38); background: rgba(255,107,125,.09); color: #ff9aa7; }
.status-published { border-color: rgba(69,213,151,.35); background: rgba(69,213,151,.09); color: #83eab9; }
.status-generating, .status-publishing { border-color: rgba(69,216,255,.35); background: rgba(69,216,255,.08); color: #7ae6ff; }
.status-none, .status-scheduled, .status-partially_published { border-color: rgba(245,185,66,.35); background: rgba(245,185,66,.08); color: #ffd177; }
.status-manual { border-color: rgba(167,139,250,.4); background: rgba(167,139,250,.1); color: #c4b5fd; }
.alert { margin-bottom: 1.25rem; padding: .85rem 1rem; border-radius: 6px; }
.alert-error, .inline-error { border: 1px solid rgba(255,107,125,.45); background: rgba(255,107,125,.09); color: #ffc2ca; }
.alert-success { border: 1px solid rgba(69,213,151,.42); background: rgba(69,213,151,.09); color: #baf5d8; }
.inline-error { margin: .75rem 0 0; padding: .55rem .7rem; border-radius: 6px; font-size: .85rem; }

/* Workflow entry doors live on the studio dashboard band (create-choice);
   the legacy .workflow-* / .create-panel rules were removed in Phase G. */
.project-grid { display: grid; gap: .75rem; }
.project-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--space-4); align-items: center; padding: var(--space-4); }
/* minmax(0,1fr) above and min-width:0 here: a `1fr` track still floors at the
   item's min-content, so a long project name kept the card wider than a phone
   screen. */
.project-card-body { min-width: 0; }
.project-card h3 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-card-icon, .empty-icon { display: grid; width: 44px; height: 44px; place-items: center; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-3); color: #a1a1aa; }
.project-card-icon svg { fill: currentColor; stroke: none; }
.project-card h3, .project-card p { margin: 0; }
.project-card h3 a { color: var(--text); text-decoration: none; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

/* Studio dashboard hero: the Opus-style submit card. One field, one white
   CTA, and a giant faint wordmark behind it. */
.submit-hero { position: relative; display: grid; justify-items: center; gap: 1.6rem; margin: .5rem 0 var(--space-6); }
.hero-wordmark { position: absolute; top: 34%; left: 50%; z-index: 0; margin: 0; transform: translate(-50%, -50%); color: rgba(255,255,255,.05); font-family: var(--font-display); font-weight: 700; font-size: clamp(5rem, 16vw, 13rem); letter-spacing: -.05em; line-height: 1; pointer-events: none; user-select: none; white-space: nowrap; }
.submit-card { position: relative; z-index: 1; display: grid; width: min(100%, 560px); gap: .8rem; padding: 1.1rem; }
.submit-alert { position: relative; z-index: 1; width: min(100%, 560px); margin: 0; }
.url-row { display: flex; align-items: center; gap: .55rem; padding: .35rem .35rem .35rem .85rem; border: 1px solid var(--field-border); border-radius: var(--radius); background: #101013; transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out); }
.url-row:focus-within { border-color: rgba(255,255,255,.5); box-shadow: 0 0 0 3px var(--accent-soft); }
.link-glyph { display: grid; flex: none; place-items: center; color: var(--muted); }
.url-row input[type="text"] { flex: 1; min-width: 0; min-height: 40px; padding: .35rem .15rem; border: 0; background: transparent; font-size: .98rem; }
/* The row owns the focus ring; the naked input inside must not draw a
   second one. */
.url-row input[type="text"]:focus { box-shadow: none; }
.url-row input[type="text"].is-file { color: var(--keyword); font-weight: 600; }
.upload-chip { flex: none; }

/* Feature shortcut chips (Opus pattern): circular gradient icon + label.
   These are the only saturated elements on the dashboard -- one hue per
   destination so each reads as its own door. */
.feature-chips { position: relative; z-index: 1; display: flex; flex-wrap: wrap; justify-content: center; gap: 1.2rem 1.35rem; padding-top: .25rem; }
.feature-chip { display: inline-flex; flex-direction: column; align-items: center; gap: .45rem; color: var(--muted); font-size: .78rem; font-weight: 600; text-decoration: none; transition: color var(--dur) var(--ease-out), transform var(--dur) var(--ease-out); }
.feature-chip:hover { color: var(--text); transform: translateY(-2px); }
.fi-icon { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 50%; color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.09); }
.fi-clips .fi-icon { background: linear-gradient(135deg, #ff7a59, #ff4d6d); }
.fi-story .fi-icon { background: linear-gradient(135deg, #a78bfa, #6366f1); }
.fi-ranking .fi-icon { background: linear-gradient(135deg, #fbbf24, #f97316); }
.fi-media .fi-icon { background: linear-gradient(135deg, #38bdf8, #3b82f6); }
.fi-voices .fi-icon { background: linear-gradient(135deg, #34d399, #059669); }
.fi-branding .fi-icon { background: linear-gradient(135deg, #f472b6, #db2777); }
.fi-publish .fi-icon { background: linear-gradient(135deg, #94a3b8, #475569); }

/* The create modal's doors reuse .choice-icon (base.html); sized by
   .modal-choice below. */
.choice-icon { display: grid; flex: none; width: 44px; height: 44px; place-items: center; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-3); color: #a1a1aa; }

.library-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: var(--space-4); padding-bottom: var(--space-3); border-bottom: 1px solid var(--border); }
.library-head h2 { margin: 0; }
.view-toggle { flex: none; }

.studio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
/* List view keeps every card's data; it only changes the geometry. */
[data-studio-grid][data-view="list"] { grid-template-columns: 1fr; }
.studio-card { overflow: hidden; padding: 0; transition: border-color var(--dur) var(--ease-out), transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out); }
.studio-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.card-thumb { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; background: #0f0f11; text-decoration: none; }
.card-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb-placeholder { position: absolute; inset: 0; display: grid; place-items: center; background: linear-gradient(160deg, #1c1c1f, #101013); color: #52525b; }
.thumb-veil { position: absolute; inset: 0; opacity: 0; background: linear-gradient(to top, rgba(5, 8, 14, .78), transparent 45%); transition: opacity var(--dur) var(--ease-out); }
.studio-card:hover .thumb-veil, a.card-thumb:focus-visible .thumb-veil { opacity: 1; }
.thumb-duration { position: absolute; right: .5rem; bottom: .5rem; padding: .12rem .45rem; border-radius: 6px; background: rgba(4, 7, 12, .82); color: #e7ecf6; font-family: var(--font-mono); font-size: .72rem; letter-spacing: .02em; }
.thumb-status { position: absolute; top: .5rem; left: .5rem; backdrop-filter: blur(6px); }
.thumb-open { position: absolute; inset: 0; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; color: white; font-size: .86rem; font-weight: 720; letter-spacing: .01em; opacity: 0; transform: scale(.96); transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out); text-shadow: 0 2px 16px rgba(0, 0, 0, .6); }
.thumb-open svg.icon { width: 1.05rem; height: 1.05rem; fill: currentColor; stroke: none; }
.studio-card:hover .thumb-open, a.card-thumb:focus-visible .thumb-open { opacity: 1; transform: scale(1); }
.card-meta { padding: .8rem .95rem .9rem; }
.card-meta h3 { overflow: hidden; margin: 0; font-size: .95rem; text-overflow: ellipsis; white-space: nowrap; }
.card-meta h3 a { color: var(--text); text-decoration: none; }
.card-meta h3 a:hover { color: #e4e4e7; }
.card-sub { display: flex; gap: .4rem; margin: .25rem 0 0; color: var(--subtle); font-size: .78rem; }
/* List view: thumb docks left at a fixed size, meta fills the row. */
[data-view="list"] .card-thumb { flex: none; width: 200px; }
[data-view="list"] .studio-card { display: flex; align-items: stretch; }
[data-view="list"] .card-meta { display: flex; flex: 1; align-items: center; justify-content: space-between; gap: 1rem; }
/* Meta row with a trailing action (ranking MP4 download). */
.card-meta-copy { min-width: 0; }
@media (max-width: 640px) {
  [data-view="list"] .card-thumb { width: 132px; }
  /* Chips wrap to a tighter grid on phones. */
  .feature-chips { gap: .9rem .8rem; }
  .feature-chip { width: 4.6rem; }
}

.breadcrumbs { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: 1.5rem; color: var(--subtle); font-size: .84rem; }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.project-tabs { display: flex; gap: .25rem; overflow-x: auto; margin-bottom: 1.5rem; padding: .35rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(14,14,17,.7); scrollbar-width: none; }
.project-tabs a { display: inline-flex; min-height: 44px; align-items: center; gap: .45rem; padding: .65rem .85rem; border-radius: 6px; color: var(--muted); font-size: .9rem; font-weight: 650; text-decoration: none; white-space: nowrap; }
.project-tabs a.active { background: var(--surface-2); color: var(--text); box-shadow: 0 4px 12px rgba(0,0,0,.14); }
.project-tabs a span { display: inline-grid; min-width: 1.35rem; height: 1.35rem; place-items: center; border-radius: 999px; background: rgba(255,255,255,.06); font-size: .68rem; }

.source-choice { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; }
.source-option { padding: 1.4rem; }
.source-option h3 { margin-top: 1rem; }
.source-option p { color: var(--muted); }
.source-option form { display: grid; gap: .75rem; }
/* Drop zone. The bare control renders as a raw platform chip ("Choose Files
   / No file chosen") that ignores the theme entirely, so the real input is
   kept for behaviour and accessibility while the label carries the visuals. */
.file-input { display: grid; justify-items: center; gap: var(--space-2); min-height: 108px; padding: var(--space-5) var(--space-4); border: 1px dashed var(--field-border); border-radius: var(--radius-sm); background: rgba(10,10,12,.28); color: var(--muted); text-align: center; cursor: pointer; transition: border-color var(--dur) var(--ease-out), background var(--dur) var(--ease-out), color var(--dur) var(--ease-out); }
.file-input:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }
/* The input is focusable, not the label -- so the label reflects its state. */
.file-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); color: var(--text); }
.file-input .glyph, .file-input svg.icon { width: 1.6rem; height: 1.6rem; color: var(--primary); }
.file-input strong { color: var(--text); font-weight: 650; }
.file-input small { color: var(--subtle); font-size: .8rem; }
/* The real control covers the zone but is invisible: clicking anywhere opens
   the picker, it stays keyboard-focusable, and the platform's own "Choose
   Files / No file chosen" chip stops competing with the label's own call to
   action. The chosen filename is reported back by app.js. */
.file-input { position: relative; }
.file-input input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.file-input [data-file-name] { color: var(--text); font-size: .84rem; font-weight: 650; }

/* 8a. Create modal + focused source step (Phase C).
   The chooser is a native <dialog>: Esc closes it, no dependency needed.
   The dropzone variant stretches the shared .file-input primitive instead of
   replacing it -- browse, keyboard focus, and filename readout all inherit. */
dialog.create-modal, dialog.export-modal, dialog.help-modal { width: min(660px, calc(100vw - 2rem)); padding: var(--panel-pad); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: #131316; color: var(--text); box-shadow: var(--shadow); }
dialog.create-modal::backdrop, dialog.export-modal::backdrop, dialog.help-modal::backdrop { background: rgba(6, 6, 8, .72); backdrop-filter: blur(6px); }
.create-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: var(--space-5); }
.create-modal-head h2 { margin: 0; font-size: 1.25rem; }
.create-modal-choices { display: grid; gap: .7rem; }
.modal-choice { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: var(--space-4); row-gap: .15rem; padding: var(--space-4); color: var(--text); text-decoration: none; transition: border-color var(--dur) var(--ease-out), transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out); }
.modal-choice:hover, .modal-choice:focus-visible { border-color: var(--accent-glow); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.modal-choice .choice-icon { grid-row: span 2; width: 40px; height: 40px; }
.modal-choice strong { font-weight: 680; font-size: .98rem; }
.modal-choice small { color: var(--muted); font-size: .84rem; }

.create-source .source-option { display: flex; flex-direction: column; }
.source-form { flex: 1; display: grid; gap: var(--space-3); align-content: start; }
.source-form > strong { display: block; font-size: 1rem; }
.dropzone-icon { display: grid; width: 46px; height: 46px; place-items: center; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-3); color: #a1a1aa; justify-self: start; }
.dropzone-icon svg { width: 1.7rem; height: 1.7rem; }
.file-input.dropzone { min-height: 200px; justify-content: center; border-width: 1.5px; border-color: var(--border-strong); }
.file-input.dropzone strong { font-size: 1rem; }
.file-input.is-dragging { border-style: solid; border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--accent-soft); color: var(--text); }
.button-wide { width: 100%; }
.source-note { margin-top: var(--space-4); }
/* Bare inputs not wrapped in a .file-input label still get a themed button
   instead of the platform default. */
input[type="file"] { padding: .5rem; color: var(--muted); font-size: .9rem; cursor: pointer; }
input[type="file"]::file-selector-button { margin-right: .75rem; padding: .5rem .9rem; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface-2); color: var(--text); font: inherit; font-weight: 650; cursor: pointer; transition: background var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out); }
input[type="file"]::file-selector-button:hover { border-color: var(--primary); background: var(--primary-soft); }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: .75rem; margin-bottom: 1rem; }
.metric { padding: 1rem; }
.metric span { display: block; color: var(--muted); font-size: .78rem; }
.metric strong { display: block; margin-top: .3rem; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.overview-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 1rem; }
.overview-source, .processing-panel { padding: var(--panel-pad); }
.definition-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .8rem; margin: 0 0 1.25rem; }
.definition-grid div { min-width: 0; padding: .75rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(10,10,12,.22); }
.definition-grid dt { color: var(--muted); font-size: .75rem; }
.definition-grid dd { overflow: hidden; margin: .25rem 0 0; font-weight: 630; text-overflow: ellipsis; }
.job-list { display: grid; gap: .85rem; margin: 0; padding: 0; list-style: none; }
.job-list li { display: grid; grid-template-columns: auto 1fr; gap: .7rem; }
.job-dot { width: 10px; height: 10px; margin-top: .45rem; border-radius: 50%; background: var(--subtle); }
.job-dot.status-completed { background: var(--success); }
.job-dot.status-processing, .job-dot.status-pending { background: var(--cyan); box-shadow: 0 0 0 5px rgba(69,216,255,.08); }
.job-dot.status-failed { background: var(--danger); }
.job-list strong, .job-list span { display: block; }
.job-list strong { font-size: .86rem; }
.job-list span { color: var(--muted); font-size: .76rem; }
.transcript-panel { margin-top: var(--space-4); padding: var(--panel-pad); }
.transcript-panel summary, .upload-panel summary, .advanced-settings summary { cursor: pointer; font-weight: 680; }
.transcript-panel summary span { margin-left: .5rem; color: var(--muted); font-size: .8rem; font-weight: 500; }
.transcript-segments { max-height: 420px; overflow: auto; margin-top: 1rem; padding-right: .5rem; }
.transcript-segments p { margin: 0 0 .65rem; color: #d6ddea; }
.transcript-timestamp { display: inline-block; min-width: 4rem; color: var(--subtle); font-family: var(--font-mono); font-size: .82em; font-variant-numeric: tabular-nums; }

/* Results sub-header (Opus pattern): count on the left, search/sort/filter
   as borderless inline controls on the right -- a toolbar, not a panel.
   The template's label text doubles as the count slot. */
.clip-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .7rem 1.2rem; margin-bottom: 1rem; padding: .1rem 0 .8rem; border-bottom: 1px solid var(--border); }
.clip-tools label { display: inline-flex; min-height: 40px; align-items: center; gap: .5rem; color: var(--muted); font-size: .78rem; }
.clip-tools input, .clip-tools select { width: auto; min-height: 38px; padding: .35rem .6rem; font-size: .86rem; }
.clip-tools input[data-clip-search] { width: 220px; }
.tools-count { display: inline-flex; align-items: baseline; gap: .55rem; margin: 0; }
.tools-count strong { font-size: .95rem; }
.tools-count span { display: inline-grid; min-width: 1.35rem; height: 1.35rem; place-items: center; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: .68rem; font-weight: 700; }
.clip-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; align-items: start; }
.clip-card { overflow: hidden; }
/* Results grid (spec Phase 5): the frame dominates; meta stacks beneath.
   2 columns with 16:9 boxes per direction. */
.clip-thumb { position: relative; aspect-ratio: 16 / 9; background: #04060a; }
.clip-thumb .clip-video { width: 100%; height: 100%; object-fit: cover; background: #04060a; border-radius: 0; }
.clip-thumb .video-placeholder { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: .4rem; color: var(--subtle); font-size: .82rem; }
.clip-thumb::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(to top, rgba(4,6,10,.55), transparent 38%); }
.clip-thumb .thumb-duration { position: absolute; right: .5rem; bottom: .5rem; z-index: 1; padding: .12rem .45rem; border-radius: 6px; background: rgba(4,7,12,.85); color: #e7ecf6; font-family: var(--font-mono); font-size: .72rem; }
.clip-thumb .clip-kind { position: absolute; left: .5rem; top: .5rem; z-index: 1; padding: .18rem .5rem; border-radius: 999px; background: rgba(4,7,12,.78); backdrop-filter: blur(4px); font-size: .68rem; }
.clip-thumb .thumb-status { position: absolute; right: .5rem; top: .5rem; z-index: 1; }
.clip-kind { display: inline-flex; align-items: center; gap: .45rem; font-size: .76rem; font-weight: 740; text-transform: uppercase; }
.clip-kind svg { width: 1rem; height: 1rem; }
.clip-kind-viral { color: #ff9aab; }
.clip-kind-part { color: #8ce9ff; }
.export-card video { display: block; width: 100%; aspect-ratio: 16/9; background: #020305; object-fit: contain; }
.video-placeholder { display: grid; min-height: 210px; place-items: center; align-content: center; gap: .5rem; background: #03050a; color: var(--muted); }
.video-placeholder svg { width: 2rem; height: 2rem; fill: currentColor; stroke: none; opacity: .7; }
.clip-card-content { padding: 1rem; }
.clip-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.clip-title-row h3 { font-size: 1.13rem; }
.clip-meta { display: flex; flex-wrap: wrap; gap: .75rem; color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
/* Virality-style score badge. Neutral zinc by default; the clip_card macro
   adds a tier class so the number reads green/amber/red at a glance, the
   only saturated element on an otherwise greyscale card (Opus pattern).
   On result cards it rides ON the thumbnail, top-right, like Opus's chip. */
.score-ring { display: grid; width: 54px; height: 54px; flex: 0 0 54px; place-content: center; border: 2px solid var(--border-strong); border-radius: 50%; background: var(--surface-3); text-align: center; }
.score-ring.is-high { border-color: rgba(61,214,140,.55); color: var(--keyword); }
.score-ring.is-mid { border-color: rgba(245,185,66,.5); color: var(--warning); }
.score-ring.is-low { border-color: rgba(255,107,125,.5); color: var(--danger); }
.score-ring strong { line-height: 1; }
.score-ring span { color: var(--muted); font-size: .58rem; text-transform: uppercase; }
.thumb-score { position: absolute; top: .5rem; right: .5rem; z-index: 1; width: 44px; height: 44px; flex: none; place-content: center; border-width: 2px; background: rgba(10,10,12,.82); backdrop-filter: blur(4px); font-size: 1rem; }
.hook-preview { margin: .9rem 0; padding: .8rem; border-left: 3px solid var(--keyword); border-radius: 0 6px 6px 0; background: rgba(61,214,140,.06); }
.hook-preview span { color: var(--keyword); font-size: .68rem; font-weight: 750; text-transform: uppercase; }
.hook-preview p { margin: .25rem 0 0; color: #edf0f7; font-size: .91rem; }
.clip-reason-block { color: var(--muted); font-size: .84rem; }
.download-link { display: inline-block; margin-top: .8rem; font-size: .8rem; }
.upload-panel { border-top: 1px solid var(--border); background: rgba(10,10,12,.18); }
.upload-panel summary { display: flex; min-height: 50px; align-items: center; justify-content: space-between; padding: .75rem 1rem; list-style: none; }
.upload-panel summary::-webkit-details-marker { display: none; }
.metadata-ready { color: var(--success); font-size: .72rem; }
.metadata-form, .metadata-empty { display: grid; gap: .55rem; padding: 0 1rem 1rem; }
.copy-field { display: grid; grid-template-columns: 1fr auto; gap: .4rem; align-items: start; }
.copy-field .icon-button { height: 44px; }
.variant-select { min-height: 40px; margin-bottom: .25rem; font-size: .82rem; }
.regenerate-form { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: 0 1rem 1rem; }
.empty-state { display: grid; justify-items: center; padding: 3rem 1.25rem; text-align: center; }
.empty-state p { max-width: 480px; color: var(--muted); }
.empty-state.compact { padding: 1.5rem; }
.spinner { width: 32px; height: 32px; margin-bottom: 1rem; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 900ms linear infinite; }
.export-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.export-card { overflow: hidden; }
.export-card > div { padding: 1rem; }

/* Old two-column editor layout (.editor-workspace/.preview-column/
   .controls-column) replaced by the studio workspace in band 18. */
.preview-card { padding: .8rem; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .7rem; margin-bottom: .8rem; }
.segmented-control { display: inline-flex; padding: .2rem; border: 1px solid var(--border); border-radius: 6px; background: #101013; }
.segmented-control button { min-height: 38px; padding: .45rem .65rem; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; font-size: .78rem; }
.segmented-control button.active { background: var(--surface-3); color: var(--text); }
.preview-toolbar .switch-label { font-size: .75rem; }
/* Capped by viewport height so the timeline stays on screen without
   scrolling past a full 16:10-tall phone frame. */
.phone-preview { position: relative; overflow: hidden; width: min(100%, 390px, calc((100dvh - 360px) * 9 / 16)); min-width: 240px; margin: 0 auto; aspect-ratio: 9/16; border: 1px solid var(--border-strong); border-radius: 6px; background: #04060a; box-shadow: var(--shadow); }
.preview-background-video { display: none; position: absolute; z-index: 0; inset: -6%; width: 112%; height: 112%; object-fit: cover; filter: blur(18px) brightness(.48) saturate(.7); transform: scale(1.06); }
.tiktok-mode[data-frame-background="blurred_video"] .preview-background-video { display: block; }
.preview-video-area { position: absolute; inset: 0; display: grid; place-items: center; transition: inset 180ms ease; }
.preview-video-area { z-index: 1; }
.preview-video-area video { width: 100%; height: 100%; object-fit: cover; }
.tiktok-mode .preview-video-area { inset: var(--frame-top) 0 var(--frame-bottom); }
.tiktok-mode[data-frame-mode="fill"] .preview-video-area { inset: 0; }
.tiktok-mode .preview-video-area video { object-fit: cover; }
.safe-overlay { position: absolute; z-index: 2; inset: 0; display: none; pointer-events: none; font-size: .56rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.show-safe-zones .safe-overlay { display: block; }
.safe-overlay span { position: absolute; display: grid; place-items: center; color: rgba(255,255,255,.76); }
.unsafe-top { inset: 0 0 auto; height: var(--safe-top); background: rgba(255,107,125,.18); }
.unsafe-bottom { inset: auto 0 0; height: var(--safe-bottom); background: rgba(255,107,125,.22); }
.unsafe-right { inset: var(--safe-top) 0 var(--safe-bottom) auto; width: var(--safe-right); background: rgba(245,185,66,.18); writing-mode: vertical-rl; }
.subtitle-safe { left: max(var(--safe-left),var(--safe-right)); right: max(var(--safe-left),var(--safe-right)); top: auto; bottom: calc(var(--safe-bottom) + 2.5%); height: 12%; border: 1px dashed rgba(69,216,255,.8); background: rgba(69,216,255,.09); color: #a9f0ff !important; }
[data-subtitle-position="lower_middle"] .subtitle-safe { top: 55%; bottom: auto; height: 15%; }
[data-subtitle-position="middle"] .subtitle-safe { top: 42.5%; bottom: auto; height: 15%; }
[data-subtitle-position="top"] .subtitle-safe { top: calc(var(--safe-top) + 2.5%); bottom: auto; height: 12%; }
.preview-note { margin: .8rem 0 0; text-align: center; }
/* align-content:start is load-bearing. As a grid child of an equal-height
   column (.source-input-grid), the default `stretch` spreads this form's rows
   to fill the TALLER sibling column -- which is what put a screen of dead
   space around the upload control. */
.editor-form { display: grid; align-content: start; gap: var(--space-4); }
.editor-section { padding: var(--panel-pad); scroll-margin-top: var(--space-4); }
.editor-section > label { display: block; margin-top: .8rem; }
.form-grid { display: grid; gap: .75rem; }
.two-columns { grid-template-columns: repeat(2,minmax(0,1fr)); }
.four-columns { grid-template-columns: repeat(4,minmax(0,1fr)); }
.range-label { margin-top: 1rem; }
.range-label > span { display: flex; justify-content: space-between; }
.range-label input { min-height: 28px; padding: 0; accent-color: var(--primary); }
.range-label output { color: var(--text); font-variant-numeric: tabular-nums; }
.advanced-settings { margin-top: 1rem; padding: .75rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(10,10,12,.2); }
.advanced-settings > *:not(summary) { margin-top: .8rem; }
.option-row { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .65rem; }
.choice-card { display: flex; min-height: 66px; align-items: center; gap: .7rem; padding: .7rem; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.choice-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice-card input { width: 1rem; min-height: 1rem; margin: 0; accent-color: var(--primary); }
.choice-card span, .choice-card small { display: block; }
.choice-card small { color: var(--muted); font-weight: 450; }
.option-row.compact { display: flex; flex-wrap: wrap; margin: .8rem 0; }
.option-row.compact label { min-height: 44px; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.option-row.compact input { width: auto; min-height: auto; accent-color: var(--primary); }
.sticky-save { position: sticky; bottom: 1rem; z-index: var(--z-raised); display: flex; align-items: center; gap: .8rem; padding: .75rem; border: 1px solid var(--border-strong); border-radius: 6px; background: rgba(14,14,17,.94); box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.full-width { margin-top: 1rem; }
.subtitle-cue-list { display: grid; gap: .55rem; }
.subtitle-cue { display: grid; grid-template-columns: 36px 90px 90px 1fr auto; gap: .5rem; align-items: center; }
.subtitle-cue input { min-width: 0; }
.cue-number { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 6px; background: var(--surface-3); color: var(--muted); font-size: .75rem; }
.editor-metadata-form { grid-template-columns: minmax(0,1fr); padding: 0; }

/* Cover suggestions: candidate frames, one of them chosen. */
.cover-intro { margin: 0 0 var(--space-4); }
.cover-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.cover-card { display: grid; gap: .55rem; margin: 0; padding: .6rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(10,10,12,.22); }
/* The selected card is outlined rather than tinted: the point of the strip
   is comparing the images, and a tint would change how they read. */
.cover-card.is-selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.cover-card img { display: block; width: 100%; border-radius: 5px; aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface-3); }
.cover-card figcaption { display: grid; gap: .1rem; }
.cover-time { font-family: var(--font-mono); font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cover-reason { color: var(--muted); font-size: .78rem; }
.cover-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.config-layout { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(260px,.7fr); gap: 1rem; align-items: start; }
.config-form { min-width: 0; }
.config-summary { position: sticky; top: 1rem; padding: 1.25rem; }
.config-summary h2 { margin-bottom: 1rem; }
.config-stack { display: grid; gap: .55rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.config-stack li { display: grid; gap: .15rem; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(10,10,12,.22); }
.config-stack li.active { border-color: #52525b; background: var(--surface-3); }
.config-stack span { color: var(--muted); font-size: .75rem; }
.config-scope { margin-bottom: 1rem; }
.is-inherited [data-config-value] { border-color: rgba(126,143,171,.32); }
.toast { position: fixed; z-index: var(--z-toast); right: 1.25rem; bottom: 1.25rem; padding: .75rem 1rem; border: 1px solid rgba(69,213,151,.4); border-radius: 6px; background: #11271f; color: #a8f3cf; box-shadow: var(--shadow); }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .clip-grid { grid-template-columns: 1fr; }
}

@media (max-width: 819px) {
  .mobile-topbar { position: sticky; top: 0; z-index: var(--z-sticky); display: flex; height: 62px; align-items: center; gap: .75rem; padding: .55rem 1rem; border-bottom: 1px solid var(--border); background: rgba(10,10,12,.9); backdrop-filter: blur(16px); }
  .app-main { margin-left: 0; }
  .content-shell { padding: 1.4rem 1rem 4rem; }
  .page-heading { align-items: flex-start; }
  .overview-grid, .config-layout { grid-template-columns: 1fr; }
  .config-summary { position: static; }
  .phone-preview { max-height: 72dvh; }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .clip-tools input[data-clip-search] { width: 150px; }
}

@media (max-width: 580px) {
  h1 { font-size: 2rem; }
  .page-heading { display: grid; gap: 1rem; margin-bottom: 1.4rem; }
  .page-heading > .button, .page-heading > form, .page-heading > form .button { width: 100%; }
  .source-choice, .export-grid, .two-columns, .four-columns, .option-row { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .tools-controls { flex: 1 0 100%; justify-content: space-between; }
  .clip-card-content { padding: .85rem; }
  .preview-toolbar { align-items: flex-start; flex-direction: column; }
  .definition-grid { grid-template-columns: 1fr; }
  .sticky-save { align-items: stretch; flex-direction: column; }
}

/* --- Story workflow (CLAUDE.md §69) -------------------------------------
   A 7-step rail so the user always knows the stage, what is already
   generated, and what is still pending. */

.voice-grid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.voice-card { padding: .9rem; }
.voice-card.is-default { border-color: rgba(69,213,151,.4); }
.voice-card.is-unusable { opacity: .65; }
.voice-preview { width: 100%; margin-top: .6rem; height: 36px; }

/* Story source/review/emotion workflow. */
.story-index-heading, .story-composer, .story-index-section { width: min(100%, 920px); margin-right: auto; margin-left: auto; }
.story-index-heading { align-items: flex-start; margin-bottom: 0; }
.story-index-heading > div { max-width: 720px; }
.story-index-heading .page-subtitle { max-width: 62ch; }
.story-composer { margin-top: 1.5rem; padding: clamp(1.1rem, 2.5vw, 1.6rem); scroll-margin-top: 1rem; }
.story-composer-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 0 .15rem 1.25rem; border-bottom: 1px solid var(--border); }
.story-composer-heading h2 { margin-bottom: .35rem; font-size: clamp(1.45rem, 2.5vw, 1.9rem); }
.story-composer-heading p:last-child { max-width: 62ch; margin-bottom: 0; color: var(--muted); }
.composer-step-count { display: inline-flex; min-height: 30px; flex: 0 0 auto; align-items: center; padding: .25rem .6rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: .74rem; font-weight: 700; }
.story-create-form { gap: .85rem; padding-top: 1rem; }
.story-form-group { min-width: 0; margin: 0; padding: var(--panel-pad); border: 1px solid var(--border); border-radius: 6px; background: rgba(8, 12, 20, .34); }
.story-form-group-heading { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: .75rem; align-items: start; margin-bottom: 1rem; }
.story-form-group-heading h3 { margin: .05rem 0 .18rem; font-size: 1rem; }
.story-form-group-heading p { max-width: 62ch; margin: 0; color: var(--muted); font-size: .82rem; }
.story-form-index { display: grid; width: 32px; height: 32px; place-items: center; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface-3); color: #a1a1aa; font-size: .78rem; font-weight: 780; }
.source-mode-fieldset { margin: 0; padding: 1.1rem; border: 1px solid var(--border); }
.source-mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.source-mode-card { min-height: 92px; align-items: flex-start; padding: .9rem; }
.source-mode-card input { margin-top: .18rem; }
.source-mode-card span { margin-bottom: .18rem; font-weight: 680; }
.source-mode-card small { max-width: 44ch; line-height: 1.45; }
.source-mode-card:has(input:checked) { border-color: var(--primary); background: var(--accent-soft); }
.story-basics-grid { grid-template-columns: minmax(0, 1.4fr) minmax(210px, .6fr); }
.story-concept-field, .existing-story-block:not([hidden]), .story-support-grid, .auto-narration-note { margin-top: 1rem; }
.story-concept-field textarea { min-height: 132px; }
.existing-story-block:not([hidden]) { display: grid; gap: .55rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.existing-story-block .field-label:not(:first-child) { margin-top: .6rem; }
.story-direction-grid, .story-support-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.story-create-form .hint { margin: .35rem 0 0; line-height: 1.45; }
.story-create-form input, .story-create-form select, .story-create-form textarea { background: rgba(12, 12, 14, .78); }
.story-create-form input:hover, .story-create-form select:hover, .story-create-form textarea:hover { border-color: #52627c; }
.input-with-suffix { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.input-with-suffix input { border-radius: 6px 0 0 6px; }
.input-with-suffix > span { display: flex; min-height: 44px; align-items: center; padding: 0 .75rem; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 6px 6px 0; background: var(--surface-2); color: var(--muted); font-size: .8rem; }
.required-label { margin-left: .35rem; color: #d4d4d8; font-size: .68rem; font-weight: 650; text-transform: uppercase; }
.optional-label { margin-left: .35rem; color: var(--subtle); font-size: .72rem; font-weight: 560; }
.auto-narration-note { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: .85rem; align-items: center; padding: 1rem; border: 1px solid rgba(69,216,255,.28); border-radius: 6px; background: var(--surface-2); }
.auto-narration-note p { max-width: 74ch; margin: .15rem 0 0; color: var(--muted); font-size: .85rem; }
.auto-narration-icon, .delivery-identity-icon, .voice-match-icon { display: grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; border: 1px solid rgba(69,216,255,.25); border-radius: 6px; background: rgba(69,216,255,.08); color: var(--cyan); }
.auto-pill { display: inline-flex; min-height: 30px; align-items: center; padding: .3rem .6rem; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface-3); color: #d4d4d8; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.story-source-editor, .story-review-text { min-height: 22rem; resize: vertical; line-height: 1.65; }
.review-gate-note { min-height: 100%; padding: .85rem .9rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.review-gate-note .field-label { margin-bottom: .2rem; }
.story-submit-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .35rem .15rem 0; }
.story-submit-row .button { min-width: 160px; }
.story-submit-row .hint { max-width: 48ch; margin: 0; text-align: right; }
.version-history { display: flex; flex-wrap: wrap; gap: .5rem; }
.version-badge, .emotion-chip { padding: .35rem .6rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: .75rem; }
.version-badge.is-selected { border-color: var(--primary); color: var(--text); background: var(--accent-soft); }
.emotion-plan-list { display: grid; gap: .75rem; padding-top: .2rem; }
.emotion-plan-row { overflow: hidden; border: 1px solid var(--border); border-radius: 6px; background: rgba(12,12,14,.24); }
.emotion-plan-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem .8rem; border-bottom: 1px solid var(--border); }
.emotion-plan-heading > span { color: var(--subtle); font-size: .72rem; }
.emotion-plan-row ol { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.emotion-plan-row li { display: grid; grid-template-columns: 118px minmax(0,1fr); gap: .75rem; align-items: start; padding: .7rem .8rem; }
.emotion-plan-row li + li { border-top: 1px solid rgba(41,53,74,.72); }
.emotion-plan-row li p { margin: .08rem 0 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.emotion-chip span { color: var(--text); font-weight: 700; }
.delivery-support { margin: .6rem 0 .9rem; padding: .65rem .8rem; border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: 6px; background: rgba(12,12,14,.3); color: var(--muted); font-size: .82rem; line-height: 1.55; }
.delivery-support strong { color: var(--text); }
.delivery-support.is-off { border-left-color: var(--subtle); }
.cue-tag { color: #c4b5fd; font-weight: 700; font-size: .76rem; white-space: nowrap; }
.expressive-script-note { margin: .4rem 0 .8rem; color: var(--subtle); font-size: .78rem; line-height: 1.55; }
.expressive-script-list { display: grid; gap: .75rem; }
.expressive-script-part { overflow: hidden; border: 1px solid var(--border); border-radius: 6px; background: rgba(12,12,14,.24); }
.expressive-script { margin: 0; padding: .8rem; max-height: 22rem; overflow: auto; color: var(--muted); font-family: inherit; font-size: .82rem; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.auto-detected-badge { display: inline-flex; min-height: 32px; align-items: center; gap: .4rem; padding: .35rem .65rem; border: 1px solid rgba(69,213,151,.4); border-radius: 999px; background: rgba(69,213,151,.1); color: #9cebc4; font-size: .78rem; font-weight: 720; }
.auto-detected-badge svg { width: 1rem; height: 1rem; }
.vibe-tags { display: flex; flex-wrap: wrap; gap: .45rem; }
.vibe-tags span { padding: .3rem .55rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .78rem; }
.delivery-arc { grid-column: 1 / -1; padding-top: .9rem; border-top: 1px solid var(--border); }
.delivery-arc ol { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; margin: 0; padding: 0; list-style: none; }
.delivery-arc li { display: flex; align-items: center; gap: .55rem; color: var(--text); font-size: .88rem; font-weight: 650; }
.delivery-arc li:not(:last-child)::after { content: "→"; color: var(--primary); }

@media (max-width: 800px) {
.source-mode-grid, .story-basics-grid, .story-direction-grid, .story-support-grid, .story-comparison-grid { grid-template-columns: 1fr; }
  .story-source-editor, .story-review-text { min-height: 18rem; }
  .story-composer { padding: 1rem; }
}

@media (max-width: 580px) {
  .story-composer-heading { display: grid; }
  .composer-step-count { justify-self: start; }
  .story-form-group, .source-mode-fieldset { padding: .9rem; }
  .story-submit-row { align-items: stretch; flex-direction: column; }
  .story-submit-row .button { width: 100%; }
  .story-submit-row .hint { max-width: none; text-align: left; }
}

/* A failed voice preview must explain itself, not just say "Error" -- the
   causes (API-key scope, plan restrictions) are all user-actionable. */
.voice-status { display: block; margin: .5rem 0 0; font-size: .8rem; }
.voice-card .button, .voice-card .text-button { margin-top: .5rem; }

/* Story cover images: shown small, downloadable at full size. */

/* Story workspace redesign: a sequential editor, not a dashboard wall. */
.story-workspace { display: grid; width: min(100%, 1080px); margin: 0 auto; gap: 1.25rem; }
.story-workspace .breadcrumbs { margin-bottom: 0; }
.story-page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 2rem; padding: .25rem 0 .5rem; }
.story-page-header h1 { max-width: 20ch; margin-bottom: .45rem; font-size: clamp(2rem, 3.4vw, 3rem); }
.story-page-header > div > p:last-child { max-width: 70ch; margin: 0; color: var(--muted); }
.story-page-header > .status { flex: 0 0 auto; margin-top: .25rem; }

.story-progress { display: flex; overflow-x: auto; margin: 0; padding: 0 0 .75rem; border-bottom: 1px solid var(--border); list-style: none; scrollbar-width: thin; }
.story-progress li { position: relative; flex: 1 0 auto; min-width: 112px; }
.story-progress li:not(:last-child)::after { position: absolute; top: 17px; right: -1px; left: 44px; height: 1px; background: var(--border); content: ""; }
.story-progress a { position: relative; z-index: 1; display: inline-flex; min-height: 44px; align-items: center; gap: .55rem; padding: .35rem .65rem .35rem 0; color: var(--subtle); font-size: .78rem; font-weight: 680; text-decoration: none; white-space: nowrap; }
.story-progress a > span { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border: 1px solid var(--border); border-radius: 50%; background: var(--bg); color: var(--subtle); font-size: .72rem; }
.story-progress .is-done a { color: var(--muted); }
.story-progress .is-done a > span { border-color: rgba(69,213,151,.4); background: rgba(69,213,151,.1); color: #9cebc4; }
.story-progress .is-current a { color: var(--text); }
.story-progress .is-current a > span { border-color: var(--primary); background: var(--primary); color: white; box-shadow: 0 0 0 4px var(--primary-soft); }

.story-next-action { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 1rem; align-items: center; padding: 1rem 1.15rem; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-2); }
.story-next-action.has-error { border-color: rgba(255,107,125,.5); background: linear-gradient(120deg, rgba(255,107,125,.12), rgba(22,22,26,.86)); }
.story-next-action h2 { margin: 0 0 .2rem; font-size: 1.1rem; }
.story-next-action p:last-child { margin: 0; color: var(--muted); font-size: .9rem; }
.story-next-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 6px; background: var(--primary-soft); color: var(--cyan); }
.story-next-action.has-error .story-next-icon { background: rgba(255,107,125,.12); color: #ff9aa7; }
.story-next-icon svg { width: 1.2rem; height: 1.2rem; }
.story-next-cta { justify-self: end; }
.story-working { display: inline-flex; min-height: 44px; align-items: center; gap: .6rem; color: var(--muted); font-size: .85rem; }
.story-working .spinner, .story-detection-state .spinner { width: 20px; height: 20px; margin: 0; border-width: 2px; }

.story-summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(22,22,26,.72); }
.story-stat { padding: 1rem 1.1rem; border-right: 1px solid var(--border); }
.story-stat strong { display: block; overflow: hidden; font-size: 1.15rem; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.story-stat span { color: var(--muted); font-size: .72rem; }
.story-summary-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .5rem; padding: .7rem 1rem; border-top: 1px solid var(--border); }
.story-summary-meta span { padding: .25rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .72rem; }
.story-summary-note { grid-column: 1 / -1; margin: 0; padding: .7rem 1rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .8rem; }
.story-extend-form { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(240px,1fr) auto 110px auto; gap: .65rem; align-items: center; padding: .75rem 1rem; border-top: 1px solid var(--border); }
.story-extend-form > span { color: var(--muted); font-size: .8rem; }
.story-extend-form label { color: var(--muted); font-size: .75rem; }

.story-stage { padding: 1.4rem; border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(155deg, rgba(32,32,36,.82), rgba(19,19,22,.92)); scroll-margin-top: 1rem; }
.story-stage-heading, .story-subheading, .story-version-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.story-stage-heading { margin-bottom: 1.1rem; }
.story-stage-heading h2, .story-subheading h2, .story-version-heading h3 { margin: 0; }
.story-stage-heading > div > p:last-child { max-width: 68ch; margin: .25rem 0 0; color: var(--muted); font-size: .9rem; }
.story-approved-badge { display: inline-flex; min-height: 34px; align-items: center; padding: .35rem .65rem; border: 1px solid rgba(69,213,151,.38); border-radius: 999px; background: rgba(69,213,151,.1); color: #9cebc4; font-size: .76rem; font-weight: 700; }

.story-comparison-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: stretch; margin: 0; }
.story-version-panel { display: flex; min-width: 0; flex-direction: column; padding: 1rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(12,12,14,.38); }
.story-version-panel.is-recommended { border-color: #52525b; background: var(--surface-2); }
.story-version-panel .story-review-text { flex: 1; margin-top: .8rem; }
.story-version-panel form { margin-top: .8rem; }
.story-version-panel form .button { width: 100%; }
.story-single-version { max-width: 850px; margin: 0 auto; }
.story-review-text { width: 100%; min-height: 20rem; padding: 1rem; resize: vertical; border-color: var(--border); border-radius: 6px; background: #101013; color: var(--text); font-family: ui-serif, Georgia, serif; font-size: .95rem; line-height: 1.75; }
.story-inline-details { margin-top: 1rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(12,12,14,.28); }
.story-inline-details > summary { display: flex; min-height: 48px; align-items: center; padding: .75rem .9rem; cursor: pointer; font-weight: 680; }
.story-inline-details > :not(summary) { margin: 0 1rem 1rem; }
.story-inline-details > form { padding-top: .25rem; }
.story-inline-details ul { color: var(--muted); }
.story-empty-state { display: flex; min-height: 150px; align-items: center; justify-content: center; gap: 1rem; padding: 1.5rem; border: 1px dashed var(--border-strong); border-radius: 6px; background: rgba(12,12,14,.28); text-align: left; }
.story-empty-state.has-error { border-color: rgba(255,107,125,.38); }
.story-empty-state svg { width: 2rem; height: 2rem; flex: 0 0 auto; color: var(--subtle); }
.story-empty-state h3 { margin-bottom: .25rem; }
.story-empty-state p { max-width: 56ch; margin: 0; color: var(--muted); }

.story-part-list { display: grid; gap: .6rem; }
.story-part-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto auto; gap: .85rem; align-items: center; padding: .8rem; border: 1px solid var(--border); border-radius: 6px; }
.story-part-number { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 6px; background: var(--surface-3); color: var(--muted); font-size: .78rem; font-weight: 750; }
.story-part-copy > div { display: flex; align-items: center; gap: .6rem; }
.story-part-copy h3, .story-part-copy p { margin: 0; }
.story-part-copy p, .story-part-copy small { color: var(--muted); }
.story-part-row > details > summary { min-height: 44px; padding: .6rem; cursor: pointer; color: var(--cyan); font-size: .8rem; font-weight: 680; }
.story-part-row > details[open] { grid-column: 2 / -1; width: 100%; }
.story-part-actions { display: flex; align-items: center; gap: .5rem; }
.story-preview-link { display: inline-flex; align-items: center; gap: .3rem; }
.story-preview-link svg { width: 1rem; height: 1rem; }

.story-locked-stage { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: .85rem; align-items: center; min-height: 86px; padding: 1rem 1.2rem; border: 1px dashed var(--border); border-radius: var(--radius); background: rgba(22,22,26,.38); scroll-margin-top: 1rem; }
.story-locked-stage > span { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--border); border-radius: 50%; color: var(--subtle); font-size: .75rem; font-weight: 720; }
.story-locked-stage h2 { margin: 0; color: var(--muted); font-size: 1rem; }
.story-locked-stage p { margin: .15rem 0 0; color: var(--subtle); font-size: .82rem; }
.story-locked-stage svg { color: var(--subtle); }

.story-selected-note { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin: 0 0 1rem; padding: .65rem .8rem; border: 1px solid rgba(69,213,151,.2); border-radius: 6px; background: rgba(69,213,151,.08); color: #baf5d8; font-size: .84rem; }
.story-selected-note span { color: var(--muted); font-size: .72rem; text-transform: uppercase; }
.story-voice-match { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: .75rem; align-items: center; margin-bottom: 1rem; padding: .8rem; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-2); }
.story-voice-match strong, .story-voice-match span { display: block; }
.story-voice-match div > span { margin-top: .12rem; color: var(--muted); font-size: .78rem; }
.story-preview-options { margin-bottom: 1rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(12,12,14,.22); }
.story-preview-options > summary { display: flex; min-height: 46px; align-items: center; justify-content: space-between; gap: 1rem; padding: .65rem .8rem; color: var(--muted); cursor: pointer; font-size: .82rem; font-weight: 680; }
.story-preview-options > summary span { color: var(--subtle); font-size: .7rem; font-weight: 560; }
.story-preview-toolbar { display: grid; grid-template-columns: minmax(220px,.7fr) minmax(280px,1.3fr); gap: 1rem; margin: 0; padding: .2rem .8rem .8rem; }
.story-preview-toolbar label > span { display: block; margin-bottom: .35rem; color: var(--muted); font-size: .75rem; font-weight: 650; }
.story-preview-toolbar output, .story-delivery-controls output { float: right; color: var(--text); font-variant-numeric: tabular-nums; }
.story-preview-toolbar input[type="range"] { width: 100%; min-height: 44px; padding: 0; }
.story-voice-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(220px,1fr)); gap: .7rem; max-height: 360px; overflow-y: auto; padding: .15rem .3rem .15rem .15rem; }
.story-voice-card { min-height: 128px; padding: .75rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(12,12,14,.25); transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease; }
.story-voice-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px rgba(255,255,255,.12); }
.story-voice-choice { display: flex; min-height: 52px; align-items: flex-start; gap: .65rem; cursor: pointer; }
.story-voice-choice input { width: 1.1rem; min-width: 1.1rem; min-height: 1.1rem; margin: .2rem 0 0; accent-color: var(--primary); }
.story-voice-copy, .story-voice-copy > span, .story-voice-copy > small { display: block; min-width: 0; }
.story-voice-copy { flex: 1; }
.story-voice-copy > span { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.story-voice-copy > span small { padding: .15rem .4rem; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: .65rem; }
.story-voice-copy > small { margin-top: .15rem; color: var(--muted); font-size: .74rem; }
.story-voice-preview-actions { display: flex; min-height: 40px; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .35rem; border-top: 1px solid var(--border); }
.story-voice-card .text-button { display: inline-flex; min-height: 40px; align-items: center; gap: .3rem; padding-right: .5rem; }
.story-voice-card .text-button svg { width: .95rem; height: .95rem; }
.story-voice-card .voice-status { margin: 0; color: var(--muted); }
.story-voice-card .voice-preview { margin-top: .4rem; }
.story-voice-card.is-unusable { opacity: .55; cursor: not-allowed; }
.story-stage-actions { display: flex; align-items: center; gap: .8rem; margin-top: 1rem; }
.story-stage-actions > span { color: var(--muted); font-size: .78rem; }

.story-delivery-stage { position: relative; overflow: hidden; }
.story-delivery-stage::before { position: absolute; width: 260px; height: 260px; top: -150px; right: -100px; border-radius: 50%; background: rgba(255,255,255,.035); filter: blur(10px); content: ""; pointer-events: none; }
.story-delivery-profile { position: relative; display: grid; grid-template-columns: minmax(220px,.85fr) minmax(320px,1.15fr); gap: 1rem; padding: 1rem; border: 1px solid var(--border-strong); border-radius: 6px; background: linear-gradient(145deg, rgba(255,255,255,.04), rgba(9,9,11,.4) 52%); }
.delivery-identity { display: flex; gap: .8rem; align-items: flex-start; }
.delivery-identity h3 { margin-bottom: .55rem; font-size: clamp(1.3rem,2vw,1.7rem); }
.story-delivery-profile dl { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .55rem; margin: 0; }
.story-delivery-profile dl > div { padding: .65rem; border-radius: 6px; background: var(--surface-2); }
.story-delivery-profile dt { color: var(--subtle); font-size: .68rem; text-transform: uppercase; }
.story-delivery-profile dd { margin: .2rem 0 0; font-weight: 680; }
.energy-meter { display: block; height: 5px; overflow: hidden; margin-top: .55rem; border-radius: 999px; background: rgba(255,255,255,.07); }
.energy-meter i { display: block; width: var(--energy); height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--cyan)); }
.delivery-note, .story-delivery-profile .delivery-arc { grid-column: 1 / -1; padding-top: .85rem; border-top: 1px solid var(--border); }
.delivery-note p:last-child { max-width: 78ch; margin: 0; color: #d9e0ec; font-size: .92rem; }
.story-delivery-profile .delivery-arc > ol { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0; padding: 0; list-style: none; }
.story-delivery-profile .delivery-arc li { display: inline-flex; align-items: center; gap: .38rem; min-height: 32px; padding: .3rem .55rem; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface-3); color: #d4d4d8; font-size: .74rem; font-weight: 650; }
.story-delivery-profile .delivery-arc li > span { display: grid; width: 18px; height: 18px; place-items: center; border-radius: 50%; background: rgba(255,255,255,.08); color: #a1a1aa; font-size: .6rem; }
.delivery-application-note { display: flex; align-items: center; gap: .75rem; margin-top: .75rem; padding: .75rem .85rem; border-left: 3px solid var(--cyan); border-radius: 0 6px 6px 0; background: rgba(69,216,255,.055); }
.delivery-application-note svg { flex: 0 0 auto; color: var(--cyan); }
.delivery-application-note strong { display: block; font-size: .85rem; }
.delivery-application-note p { margin: .12rem 0 0; color: var(--muted); font-size: .76rem; }
.story-detection-state { display: flex; align-items: center; gap: .8rem; padding: 1rem; border: 1px dashed var(--border); border-radius: 6px; }
.story-detection-state p { margin: .15rem 0 0; color: var(--muted); }
.story-delivery-tuning > summary, .story-inline-details > summary { justify-content: space-between; gap: 1rem; }
.story-delivery-tuning > summary span, .story-inline-details > summary span { color: var(--subtle); font-size: .7rem; font-weight: 560; }
.story-delivery-controls { display: grid; grid-template-columns: minmax(220px,.8fr) minmax(280px,1.2fr) auto; gap: 1rem; align-items: center; padding-top: .25rem; }
.story-delivery-controls > label:first-child { display: flex; min-height: 62px; align-items: center; gap: .7rem; padding: .65rem .75rem; border: 1px solid var(--border); border-radius: 6px; }
.story-delivery-controls .adaptive-toggle input { width: 1.1rem; min-width: 1.1rem; min-height: 1.1rem; margin: 0; accent-color: var(--primary); }
.story-delivery-controls label > span, .story-delivery-controls label small { display: block; }
.story-delivery-controls label small { color: var(--muted); }
.story-delivery-controls input[type="range"] { width: 100%; min-height: 40px; }

.story-settings-group, .story-activity { border: 1px solid var(--border); border-radius: var(--radius); background: rgba(22,22,26,.62); }
.story-settings-group > summary, .story-activity > summary { display: flex; min-height: 70px; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1.1rem; cursor: pointer; list-style: none; }
.story-settings-group > summary::-webkit-details-marker, .story-activity > summary::-webkit-details-marker { display: none; }
.story-settings-group > summary > span:first-child, .story-activity > summary > span:first-child { display: grid; }
.story-settings-group > summary small, .story-activity > summary small { color: var(--subtle); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.story-settings-group > summary > span:last-child { color: var(--muted); font-size: .8rem; }
.story-settings-stack { display: grid; gap: 1rem; padding: 1rem; border-top: 1px solid var(--border); }
.story-settings-stack > section { min-width: 0; padding: 1rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(12,12,14,.2); }
.story-subheading > div > p:last-child { max-width: 64ch; margin: .25rem 0 0; color: var(--muted); font-size: .82rem; }
.story-settings-form { padding: 1rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(12,12,14,.28); }
.story-settings-form > .button { width: auto; min-width: 150px; justify-self: start; }
.story-settings-form-heading { padding-bottom: .75rem; border-bottom: 1px solid var(--border); }
.story-settings-form-heading strong, .story-settings-form-heading small { display: block; }
.story-settings-form-heading small { margin-top: .12rem; color: var(--muted); font-size: .75rem; }
.story-branding-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .8rem; margin-top: 1rem; align-items: start; }
.field-optional { margin-left: .25rem; color: var(--subtle); font-size: .7rem; font-weight: 560; }
.story-field-meta { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; margin-top: -.55rem; color: var(--muted); }
.story-field-meta small { max-width: 48ch; font-size: .72rem; line-height: 1.45; }
.story-field-meta output { flex: 0 0 auto; color: var(--subtle); font-size: .68rem; font-variant-numeric: tabular-nums; }

.story-cover-studio { margin-top: 1rem; padding: 1rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(12,12,14,.28); }
.story-cover-studio-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: .85rem; border-bottom: 1px solid var(--border); }
.story-cover-studio-heading strong, .story-cover-studio-heading small { display: block; }
.story-cover-studio-heading small { margin-top: .12rem; color: var(--muted); font-size: .76rem; }
.story-cover-guide-toggle { display: inline-flex; min-height: 44px; align-items: center; gap: .55rem; padding: .45rem .65rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(255,255,255,.02); cursor: pointer; white-space: nowrap; }
.story-cover-guide-toggle input { width: 1rem; min-width: 1rem; min-height: 1rem; margin: 0; accent-color: var(--primary); }
.story-cover-preview-grid { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(250px,.65fr); gap: 1rem; margin-top: 1rem; align-items: start; }
.story-cover-platform-card { min-width: 0; padding: .85rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(22,22,26,.72); }
.story-cover-platform-card > header { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.story-cover-platform-card > header > div { display: flex; min-width: 0; align-items: center; gap: .65rem; }
.story-cover-platform-card > header strong, .story-cover-platform-card > header small { display: block; }
.story-cover-platform-card > header strong { color: var(--text); font-size: .86rem; }
.story-cover-platform-card > header small { margin-top: .08rem; color: var(--muted); font-size: .68rem; }
.story-platform-icon { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: #c9bbff; }
.story-platform-icon svg { width: 1.05rem; height: 1.05rem; }
.story-cover-frame { position: relative; overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius); background: linear-gradient(145deg,#232326,#09090b 72%); }
.story-cover-frame-youtube { width: 100%; aspect-ratio: 16/9; }
.story-cover-frame-tiktok { width: min(100%,230px); margin: 0 auto; aspect-ratio: 9/16; }
.story-cover-frame > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.story-cover-placeholder { display: grid; width: 100%; height: 100%; align-content: end; gap: .25rem; padding: 9%; background: linear-gradient(160deg,rgba(255,255,255,.07),transparent 46%), linear-gradient(15deg,#0b0b0d,#17171a); }
.story-cover-placeholder span { color: var(--muted); font-size: .7rem; font-weight: 760; letter-spacing: .08em; text-transform: uppercase; }
.story-cover-placeholder strong { overflow-wrap: anywhere; font-size: clamp(1rem,2.4vw,1.8rem); line-height: 1.08; }
.story-cover-placeholder small { color: var(--muted); font-size: .68rem; }
.story-cover-platform-tiktok .story-cover-placeholder { padding: 16% 12%; }
.story-cover-platform-tiktok .story-cover-placeholder strong { font-size: 1.05rem; }
.story-cover-safe-guide { display: none; position: absolute; z-index: 2; border: 1px dashed rgba(69,216,255,.88); border-radius: 6px; box-shadow: 0 0 0 999px rgba(6,6,8,.10); pointer-events: none; }
.story-cover-safe-guide i { position: absolute; top: 6px; left: 7px; padding: .12rem .3rem; border-radius: 4px; background: rgba(2,8,14,.72); color: #8ce9ff; font-size: .56rem; font-style: normal; font-weight: 720; letter-spacing: .04em; text-transform: uppercase; }
.story-cover-frame-youtube .story-cover-safe-guide { inset: 7.5% 8% 10% 6%; }
.story-cover-frame-tiktok .story-cover-safe-guide { inset: 12.5% 16% 12.5% 7%; }
.story-cover-duration-zone, .story-cover-tiktok-rail, .story-cover-tiktok-caption { display: none; position: absolute; z-index: 3; border-radius: 4px; background: rgba(255,107,125,.74); color: white; font-size: .55rem; pointer-events: none; }
.story-cover-duration-zone { right: 2%; bottom: 3%; padding: .16rem .28rem; text-transform: uppercase; }
.story-cover-tiktok-rail { top: 29%; right: 3%; width: 9%; height: 43%; border: 1px dashed rgba(255,255,255,.6); background: rgba(255,107,125,.36); }
.story-cover-tiktok-caption { right: 3%; bottom: 3%; left: 3%; height: 9%; border: 1px dashed rgba(255,255,255,.6); background: rgba(255,107,125,.30); }
.show-cover-guides .story-cover-safe-guide, .show-cover-guides .story-cover-duration-zone, .show-cover-guides .story-cover-tiktok-rail, .show-cover-guides .story-cover-tiktok-caption { display: block; }
.story-cover-platform-card > p { margin: .65rem 0 0; color: var(--muted); font-size: .71rem; line-height: 1.45; }
.story-cover-part-picker { display: flex; overflow-x: auto; gap: .4rem; margin-top: .65rem; padding-bottom: .15rem; scrollbar-width: thin; }
.story-cover-part-picker button { min-width: 58px; min-height: 40px; padding: .4rem .55rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(12,12,14,.35); color: var(--muted); cursor: pointer; font-size: .68rem; font-weight: 680; white-space: nowrap; }
.story-cover-part-picker button:hover, .story-cover-part-picker button.active { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }

.story-output-stage { overflow: hidden; }
.story-output-form { display: grid; min-width: 0; gap: .75rem; }
.story-output-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.story-output-options { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .65rem; }
.story-output-options label { display: grid; grid-template-columns: auto auto minmax(0,1fr); min-height: 92px; align-items: center; gap: .7rem; padding: .85rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(12,12,14,.25); cursor: pointer; transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease; }
.story-output-options label:hover { border-color: var(--border-strong); background: rgba(32,32,36,.72); }
.story-output-options label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px rgba(255,255,255,.12); }
.story-output-options input { width: 1.1rem; min-width: 1.1rem; min-height: 1.1rem; margin: 0; padding: 0; flex: 0 0 auto; accent-color: var(--primary); }
.story-output-icon { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.story-output-icon svg { width: 1.1rem; height: 1.1rem; }
.story-output-options label:has(input:checked) .story-output-icon { border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.12); color: var(--text); }
.story-output-copy, .story-output-copy strong, .story-output-copy small { display: block; min-width: 0; overflow-wrap: anywhere; }
.story-output-copy strong { margin-bottom: .12rem; color: var(--text); font-size: .88rem; }
.story-output-copy small { color: var(--muted); font-size: .75rem; line-height: 1.4; }
.story-output-save { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(12,12,14,.2); }
.story-output-save span, .story-output-save small { display: block; min-width: 0; }
.story-output-save strong { font-size: .82rem; }
.story-output-save small { margin-top: .08rem; color: var(--muted); font-size: .72rem; }
.story-output-save .button { flex: 0 0 auto; }
.story-generate-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; padding: 1rem; border-radius: 6px; background: var(--surface-2); }
.story-generate-row p { margin: .15rem 0 0; color: var(--muted); font-size: .8rem; }
.story-output-preview { margin-top: 1rem; padding: 1rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(12,12,14,.24); }
.story-output-preview-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.story-output-preview-heading h3, .story-output-preview-heading p { margin-bottom: 0; }
.story-output-preview-heading > div > p:last-child { margin-top: .18rem; color: var(--muted); font-size: .8rem; }
.story-output-preview > video { display: block; width: min(100%, 720px); max-height: 405px; margin: 0 auto; aspect-ratio: 16/9; border: 1px solid var(--border); border-radius: 6px; background: #03050a; object-fit: contain; }
.story-cover-download { display: inline-flex; margin-top: .45rem; }
.story-part-preview-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(210px,260px)); justify-content: start; gap: .8rem; align-items: start; }
.story-part-preview-card { overflow: hidden; border: 1px solid var(--border); border-radius: 6px; background: rgba(12,12,14,.38); scroll-margin-top: 1rem; }
.story-part-preview-card video { display: block; width: 100%; max-height: 420px; aspect-ratio: 9/16; border-bottom: 1px solid var(--border); background: #03050a; object-fit: contain; }
.story-part-preview-copy { display: grid; gap: .75rem; padding: .85rem; }
.story-part-preview-copy span, .story-part-preview-copy small { color: var(--muted); font-size: .7rem; }
.story-part-preview-copy span { font-weight: 720; letter-spacing: .07em; text-transform: uppercase; }
.story-part-preview-copy h4 { overflow: hidden; margin: .12rem 0; color: var(--text); font-size: .95rem; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.story-part-preview-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.story-part-preview-actions .button { flex: 1; }

.story-activity > .job-list, .story-activity > .empty { margin: 0; padding: 0 1rem 1rem; }
.story-activity > .job-list { border-top: 1px solid var(--border); padding-top: 1rem; }
.story-activity-alert { padding: .25rem .5rem; border-radius: 999px; background: rgba(255,107,125,.12); color: #ff9aa7; font-size: .72rem; font-weight: 700; }
.job-error { margin-top: .35rem; }
.job-error summary { min-height: 36px; cursor: pointer; color: #ff9aa7; font-size: .72rem; }
.job-error code { display: block; overflow: auto; max-height: 120px; padding: .6rem; white-space: pre-wrap; word-break: break-word; }

.story-workspace .button:disabled { opacity: .5; }

@media (max-width: 980px) {
  .story-progress li { min-width: 104px; }
  .story-comparison-grid, .story-branding-grid, .story-delivery-profile, .story-cover-preview-grid { grid-template-columns: 1fr; }
  .story-cover-frame-youtube { width: min(100%,720px); }
}

@media (max-width: 700px) {
  .auto-narration-note, .story-voice-match { grid-template-columns: auto minmax(0,1fr); }
  .auto-narration-note .auto-pill, .story-voice-match .auto-pill { grid-column: 2; justify-self: start; }
  .story-page-header { display: grid; gap: .75rem; }
  .story-next-action { grid-template-columns: auto minmax(0,1fr); }
  .story-next-cta { grid-column: 1 / -1; justify-self: stretch; }
  .story-next-cta .button, .story-next-cta form, .story-next-cta form .button { width: 100%; }
  .story-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .story-stat:nth-child(2) { border-right: 0; }
  .story-stat:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .story-stage { padding: 1rem; }
  .story-settings-stack { gap: .75rem; padding: .75rem; }
  .story-settings-stack > section, .story-settings-form, .story-output-preview { padding: .85rem; }
  .story-cover-studio { padding: .85rem; }
  .story-cover-studio-heading { align-items: stretch; flex-direction: column; }
  .story-cover-guide-toggle { align-self: flex-start; }
  .story-field-meta { align-items: stretch; flex-direction: column; gap: .25rem; }
  .story-stage-heading, .story-subheading { align-items: stretch; flex-direction: column; }
  .story-preview-toolbar, .story-delivery-controls, .story-output-options { grid-template-columns: 1fr; }
  .story-stage-actions, .story-generate-row, .story-output-save, .story-output-preview-heading { align-items: stretch; flex-direction: column; }
  .story-stage-actions .button, .story-generate-row .button, .story-generate-row form { width: 100%; }
  .story-part-row { grid-template-columns: auto minmax(0,1fr); }
  .story-part-row > details, .story-part-row > .button { grid-column: 2; }
  .story-part-actions { grid-column: 2; }
  .story-part-row > details[open] { grid-column: 1 / -1; }
  .story-extend-form { grid-template-columns: 1fr; }
  .story-delivery-profile dl { grid-template-columns: 1fr; }
  .emotion-plan-row li { grid-template-columns: 1fr; gap: .4rem; }
  .story-settings-form > .button, .story-output-save .button, .story-output-preview-heading .button { width: 100%; }
  .story-output-preview > video { width: 100%; height: auto; max-height: none; }
  .story-part-preview-grid { grid-template-columns: minmax(0, 300px); justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .button:hover { transform: none; }
}

/* ---------------------------------------------------------------------
   Ranking / Compilation Videos (CLAUDE.md §97).
   Only the components the other two workflows had no equivalent for: a
   stage jump-list, a source table, the cut-candidate rows, and the
   reorder list. Everything else reuses the shared surface/button/status
   vocabulary above.
   --------------------------------------------------------------------- */
.button-danger { border-color: rgba(255,107,125,.38); color: #ff9aa7; }
.button-danger:hover { border-color: #ff6b7d; color: #fff; background: rgba(255,107,125,.14); }

.tab-nav { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: 1.5rem; padding: .35rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(14,14,17,.7); }
.tab-nav a { padding: .5rem .8rem; border-radius: 6px; color: var(--muted); font-size: .88rem; font-weight: 620; text-decoration: none; white-space: nowrap; }
.tab-nav a:hover { background: var(--surface-2); color: var(--text); }

/* A table is the one element that legitimately needs to be wider than a
   phone. Give it its own scroll container so it never pushes the PAGE
   sideways -- body overflow-x:hidden would otherwise just clip it. */
.table-scroll { overflow-x: auto; margin: 1.25rem 0; -webkit-overflow-scrolling: touch; }
.table-scroll .data-table { margin: 0; }
.data-table { width: 100%; min-width: 34rem; margin: 1.25rem 0; border-collapse: collapse; font-size: .92rem; }
.data-table th { padding: .55rem .6rem; border-bottom: 1px solid var(--border); color: var(--muted); font-size: .76rem; font-weight: 720; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
.data-table td { padding: .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table form { margin: 0; }

/* Ranking library cards reuse .studio-card (dashboard band); the index's old
   panel rules were removed in Phase I. The DETAIL page's per-entry cut cards
   still speak this name and keep their padding here. */
.ranking-card { padding: var(--panel-pad); }
.ranking-card > * + * { margin-top: 1rem; }

/* Sources are landscape; a tall preview box would letterbox them badly. */
.clip-preview { width: 100%; max-height: 320px; border: 1px solid var(--border); border-radius: 6px; background: #05090f; }

.candidate-list { display: grid; gap: .5rem; }
.candidate-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(10,10,12,.22); }
.candidate-row .score { color: var(--muted); font-size: .82rem; font-weight: 700; }
.candidate-row .reason { flex: 1 1 16rem; min-width: 0; color: var(--muted); font-size: .86rem; }

.reorder-list { display: grid; gap: .5rem; margin: 0 0 1rem; padding: 0; list-style: none; }
/* min-width:0 on the ROW, not just on the truncating text inside it: the
   row is a grid item, and a grid item defaults to min-width:auto, so it
   sizes to its max-content and overflows its track no matter how well
   its children truncate. */
.reorder-row { display: flex; min-width: 0; align-items: center; gap: var(--space-3); padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 6px; background: rgba(10,10,12,.22); }
.reorder-position { min-width: 1.75rem; color: var(--muted); font-weight: 760; }
.reorder-name { flex: 1 1 auto; }
.reorder-controls { display: flex; gap: .35rem; }
.reorder-controls .button { min-height: 34px; padding: .3rem .7rem; }

.checkbox-grid { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; }
.checkbox-label { display: inline-flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .9rem; }
.checkbox-label input { width: auto; min-height: 0; }
.error-text { display: block; margin-top: .25rem; color: #ff9aa7; font-size: .8rem; }

/* Two source inputs side by side: upload a file, or paste YouTube links. */
.source-input-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); }
/* Two ways in, one row of actions. Flex column with the action row pushed to
   the bottom aligns both submit buttons even though the columns hold a
   different number of lines -- without stretching the content between them,
   which is what caused the original dead space. */
.source-input-grid > .editor-form { display: flex; flex-direction: column; gap: var(--space-3); }
.source-input-grid > .editor-form .button-row { margin-top: auto; padding-top: var(--space-2); }
.source-input-grid .file-input { flex: 1; }
.source-input-grid textarea { min-height: 7rem; font-size: .9rem; }
.source-pending { color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }

/* Overlay style picker: two visual choices, not a dropdown. */
.style-picker { border: 0; margin: 0 0 .5rem; padding: 0; }
.style-picker legend { padding: 0; }
.style-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); margin-top: .75rem; }
.style-card { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .9rem; padding: .85rem; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface-2); cursor: pointer; transition: border-color 150ms ease, background 150ms ease; }
.style-card:hover { border-color: #53637e; background: var(--surface-3); }
.style-card.is-selected, .style-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.style-card input { width: auto; min-height: 0; margin: 0; position: absolute; opacity: 0; }
.style-copy { display: grid; gap: .25rem; min-width: 0; }
.style-copy strong { font-weight: 700; }
.style-copy small { color: var(--muted); font-size: .84rem; line-height: 1.35; }
.style-preview svg { display: block; width: 54px; height: 96px; border-radius: 4px; }
.style-preview .sp-band { fill: #05070c; }
.style-preview .sp-video { fill: #3f3f46; }
.style-preview .sp-text { fill: #ffffff; opacity: .92; }
.style-preview .sp-accent { fill: #ffd400; }
.style-preview text { font-size: 9px; font-weight: 800; font-family: system-ui, sans-serif; }
.style-preview .sp-rank { fill: #ffffff; font-size: 13px; }
.style-preview .sp-n { fill: #ffffff; }
.style-preview .sp-n1 { fill: #ffd400; }
.style-preview .sp-n2 { fill: #ff8a00; }
.style-preview .sp-n3 { fill: #ff3b5c; }

/* Output gallery: every rendered style side by side. */
.render-launcher { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); padding: var(--panel-pad); }
.render-launcher-copy h3 { margin: 0 0 .2rem; }
.render-launcher-copy p { margin: 0; }
.render-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(21rem, 1fr)); }
.render-card { display: grid; gap: var(--space-3); align-content: start; padding: var(--panel-pad); }
.render-card h3 { margin: 0 0 .15rem; }
.render-card .clip-preview { max-height: 420px; }
.render-card .definition-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.render-placeholder { display: grid; place-items: center; padding: 2.5rem 1rem; border: 1px dashed var(--border-strong); border-radius: 6px; color: var(--muted); }
.render-placeholder p { margin: 0; }
.timeline-details { padding: var(--panel-pad); }
.timeline-details summary { cursor: pointer; font-weight: 650; }
.label-launcher { padding: var(--panel-pad); margin-bottom: var(--space-4); }
.label-launcher .hint { flex-basis: 100%; margin: 0; }

/* Upload suggestions: one edited set, two platform-shaped paste formats. */
.platform-copy { display: grid; gap: .5rem; padding: 0 1rem 1rem; border-top: 1px solid var(--border); margin-top: .25rem; padding-top: .9rem; }
.platform-copy .hint { margin: 0; }

/* Clip Asset Library: reusable source clips. */
.asset-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.asset-card { display: grid; grid-template-rows: auto 1fr; overflow: hidden; }
/* The image is absolutely positioned so the box's height comes from
   `aspect-ratio` ALONE. With a normally-flowed `img { height: 100% }` the
   percentage resolves against an auto height, falls back to the intrinsic
   size, and a portrait thumbnail (320x570) inflates the tile to ~1500px --
   which pushed the card body off screen. */
.asset-thumb { position: relative; display: grid; place-items: center; aspect-ratio: 16/9; overflow: hidden; background: #05090f; color: var(--muted); text-decoration: none; }
.asset-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.asset-thumb-empty { font-size: 1.5rem; }
.asset-duration { position: absolute; right: .4rem; bottom: .4rem; padding: .1rem .35rem; border-radius: 5px; background: rgba(0,0,0,.72); color: #fff; font-size: .72rem; font-weight: 700; }
.asset-body { display: grid; gap: .5rem; align-content: start; padding: .85rem; }
.asset-body h3 { margin: 0; font-size: .98rem; }
.asset-body .hint { margin: 0; }
.asset-rename { display: flex; gap: .4rem; }
.asset-rename input { min-height: 36px; font-size: .88rem; }
.asset-rename .button { min-height: 36px; padding: .3rem .7rem; }

.library-picker { margin: var(--space-4) 0; padding: var(--space-4); border: 1px solid var(--border); border-radius: 6px; background: rgba(10,10,12,.22); }
.library-picker summary { cursor: pointer; font-weight: 650; }
.library-picker form { margin-top: .85rem; }
.library-grid { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); margin-bottom: .85rem; }
.library-item { position: relative; display: grid; gap: .4rem; padding: .45rem; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface-2); cursor: pointer; }
.library-item:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.library-item input { width: auto; min-height: 0; margin: 0; }
.library-thumb { position: relative; display: grid; place-items: center; aspect-ratio: 16/9; overflow: hidden; border-radius: 6px; background: #05090f; color: var(--muted); }
/* Same reason as .asset-thumb above: keep the tile's height governed by
   aspect-ratio, not by a portrait source's intrinsic height. */
.library-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.library-name { font-size: .8rem; }

/* Clip Library filters: workflow on one axis, content on the other. */
.filter-bar { display: grid; gap: .7rem; padding: var(--panel-pad); margin-bottom: var(--space-4); }
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.filter-label { min-width: 5.5rem; color: var(--subtle); font-size: .72rem; font-weight: 760; letter-spacing: .1em; text-transform: uppercase; }
.filter-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .65rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: .84rem; font-weight: 600; text-decoration: none; text-transform: capitalize; }
.filter-chip:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-2); }
.filter-chip.is-active { border-color: var(--primary); color: var(--text); background: var(--primary-soft); }
.filter-count { padding: 0 .3rem; border-radius: 999px; background: rgba(255,255,255,.08); font-size: .74rem; }

.asset-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin: 0; }
.tag { padding: .12rem .45rem; border: 1px solid var(--border); border-radius: 6px; font-size: .72rem; font-weight: 700; letter-spacing: .02em; text-transform: capitalize; }
.tag-clipping { border-color: rgba(69,216,255,.4); background: rgba(69,216,255,.1); color: #7ae6ff; }
.tag-story { border-color: rgba(155,124,255,.45); background: rgba(155,124,255,.12); color: #c3aeff; }
.tag-ranking { border-color: rgba(255,196,92,.42); background: rgba(255,196,92,.1); color: #ffd681; }
.tag-library { border-color: var(--border-strong); color: var(--muted); }
.tag-category { border-color: rgba(69,213,151,.35); background: rgba(69,213,151,.09); color: #83eab9; }
.asset-rename select { min-height: 36px; font-size: .85rem; }

/* Library picker: filter bar, wider cards, inline preview. */
.library-controls { display: grid; gap: .6rem; margin-bottom: .9rem; }
.library-search { max-width: 22rem; min-height: 38px; font-size: .9rem; }
.library-picker .filter-chip { border: 1px solid var(--border); background: transparent; cursor: pointer; font: inherit; font-size: .84rem; font-weight: 600; }
.library-play { position: absolute; inset: 0; display: grid; place-items: center; width: 100%; height: 100%; padding: 0; border: 0; background: rgba(0,0,0,.28); color: #fff; cursor: pointer; font-size: 1.1rem; opacity: 0; transition: opacity 140ms ease; }
.library-thumb:hover .library-play, .library-play:focus-visible { opacity: 1; }
.library-play:hover { background: rgba(0,0,0,.5); }
/* Once a preview is open the button becomes the close control, so it must
   stay visible and out of the video's own controls. */
.library-thumb:has(video) .library-play { inset: auto .25rem .25rem auto; width: 26px; height: 26px; border-radius: 6px; background: rgba(0,0,0,.7); opacity: 1; font-size: .8rem; }
.library-preview { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; object-fit: contain; }
.library-select { display: flex; min-width: 0; align-items: center; gap: .4rem; cursor: pointer; }
.library-select input { width: auto; min-height: 0; margin: 0; flex: none; }
.library-item .tag-category { justify-self: start; }

/* Truncation needs `min-width: 0`: a flex or grid child defaults to
   min-width:auto, so it refuses to shrink below its text and pushes the whole
   column wider instead -- which is how long clip names blew the library grid
   past its panel. */
.truncate, .library-name, .asset-body h3, .reorder-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------
   Icon system. One family, one stroke weight, sized by token — replacing
   the text glyphs (▶ ✕ ↑ ↓ ★) that used to stand in for icons. Those are
   font-dependent: they render differently per platform and cannot be
   themed, which is what made them read as unfinished.
   --------------------------------------------------------------------- */
.glyph { width: 1.05em; height: 1.05em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* Filled marks (play, star) read better solid at small sizes than as outlines. */
.glyph-fill, svg.icon.glyph-fill { fill: currentColor; stroke: none; }
.default-mark { display: inline-flex; align-items: center; color: var(--warning); vertical-align: -.12em; }
.thumb-fallback, .asset-thumb-empty { display: grid; place-items: center; color: var(--subtle); }
.thumb-fallback .glyph, .asset-thumb-empty .glyph, .asset-thumb-empty svg.icon { width: 1.6rem; height: 1.6rem; }
.reorder-controls .button .glyph { width: 1.15rem; height: 1.15rem; }
.library-play .glyph { width: 1.35rem; height: 1.35rem; }

/* Interaction states the app previously only expressed on hover. A pointer
   user gets hover; touch and keyboard users get nothing unless press and
   focus are styled too. */
.filter-chip:active, .style-card:active, .library-item:active { transform: scale(.99); }
.filter-chip { transition: border-color var(--dur) var(--ease-out), background var(--dur) var(--ease-out), color var(--dur) var(--ease-out); }
.icon-button:active { transform: scale(.94); }
.library-item:has(input:checked) .library-name { color: var(--text); font-weight: 650; }
/* The card is a click target, so it says so. */
.style-card, .library-item, .filter-chip { touch-action: manipulation; }

/* Keyboard parity: the picker's play control is hover-revealed, which hides
   it from anyone tabbing through. Focus brings it back. */
.library-item:focus-within .library-play { opacity: 1; }

/* ── Live processing panel (§6/§10/§18) ─────────────────────────────────
   Design tokens only -- no new colours. Status vocabulary is reused from
   the existing .status-* / .job-dot rules above so a processing state looks
   the same here as it does anywhere else in the app. */
.job-panel { display: grid; gap: var(--space-4); padding: var(--panel-pad); }
.job-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.job-panel-head h2 { margin: .15rem 0 0; font-size: 1.05rem; }

/* The bar transitions toward the confirmed value; it never runs ahead of
   the server. `--progress` is set from JS. */
.job-bar { position: relative; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.job-bar > i {
  display: block; height: 100%; width: var(--progress, 0%);
  border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--cyan));
  transition: width var(--dur-slow) var(--ease-out);
}
/* An unmeasurable stage says so with motion instead of a fake percentage. */
.job-panel[data-indeterminate="true"] .job-bar > i {
  width: 35%; background: linear-gradient(90deg, transparent, var(--primary), transparent);
  animation: job-sweep 1.5s ease-in-out infinite;
}
@keyframes job-sweep { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }

.job-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.job-metrics > div { display: grid; gap: .15rem; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.job-metrics span { color: var(--subtle); font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; }
.job-metrics strong { font-size: .95rem; font-variant-numeric: tabular-nums; }
.job-current { margin: 0; color: var(--muted); font-size: .85rem; }

.pipeline-stages { display: grid; gap: .45rem; margin: 0; padding: 0; list-style: none; }
.pipeline-stage { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .6rem; font-size: .84rem; }
/* Checklist presentation (§26/Phase F): ✓ done, pulsing dot running,
   hollow pending. The stage STATUSES come from the worker over SSE; this
   only decides how each state reads. */
.pipeline-stage.is-pending { color: var(--subtle); }
.pipeline-stage.is-pending .job-dot { width: 9px; height: 9px; margin-top: .5rem; border: 1.5px solid var(--border-strong); background: transparent; box-shadow: none; }
.pipeline-stage.is-running strong { color: var(--text); }
.pipeline-stage.is-running .job-dot { background: var(--accent); animation: pipeline-pulse 1.6s ease-in-out infinite; }
.pipeline-stage.is-completed { color: var(--muted); }
.pipeline-stage.is-completed .job-dot { display: inline-grid; place-items: center; width: 15px; height: 15px; margin-top: .25rem; background: var(--success); color: #06130d; }
.pipeline-stage.is-completed .job-dot::after { content: "✓"; font-size: .58rem; font-weight: 800; line-height: 1; }
@keyframes pipeline-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(250, 250, 250, .4); }
  50% { box-shadow: 0 0 0 6px rgba(250, 250, 250, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .pipeline-stage.is-running .job-dot { animation: none; box-shadow: 0 0 0 3px rgba(250, 250, 250, .18); }
}
.pipeline-stage-pct { color: var(--muted); font-size: .76rem; font-variant-numeric: tabular-nums; }

/* Clips become playable one at a time, while the rest still render (§4). */
.clip-progress-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--space-3); }
.clip-progress-card { display: grid; gap: .5rem; padding: .7rem; }
.clip-progress-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.clip-progress-head strong { font-size: .82rem; }
.clip-progress-video { width: 100%; border-radius: var(--radius-sm); background: #000; aspect-ratio: 9 / 16; object-fit: contain; }

.job-details > summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--muted); font-size: .85rem; }
.activity-feed { display: grid; gap: .3rem; margin: .5rem 0 0; padding: 0; list-style: none; font-size: .78rem; }
.activity-feed li { display: grid; grid-template-columns: auto 1fr; gap: .55rem; color: var(--muted); }
.activity-time { color: var(--subtle); font-variant-numeric: tabular-nums; }

/* Cancelled had no rule: it fell through to the neutral base, so a
   cancelled job looked identical to a queued one. */
.status-cancelling { border-color: rgba(245,185,66,.35); background: rgba(245,185,66,.08); color: #ffd177; }
.status-cancelled { border-color: rgba(164,175,193,.35); background: rgba(164,175,193,.08); color: var(--muted); }
.job-dot.status-cancelled { background: var(--subtle); }

@media (max-width: 720px) {
  /* Priority on narrow screens: progress and current operation first. */
  .job-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .job-panel-head { flex-direction: column; gap: var(--space-2); }
}

/* Publishing Hub. Cards are grouped by what produced them: one story can be a
   dozen parts, and flat they would bury everything else. */
.filter-bar { display: grid; gap: .7rem; padding: var(--panel-pad); margin-bottom: var(--space-4); }
.filter-bar .filter-row { align-items: center; }
.filter-bar input[type="search"] { min-width: 16rem; }
.publish-group { padding: var(--panel-pad); margin-bottom: var(--space-4); }
.publish-group-head { display: flex; align-items: center; gap: 1rem; margin-bottom: .9rem; padding-bottom: .8rem; border-bottom: 1px solid var(--border); }
.publish-group-head h2 { margin: 0; font-size: 1.05rem; }
.publish-group-head .hint { margin: .15rem 0 0; }
.publish-group-thumb { width: 64px; height: 64px; border-radius: 6px; object-fit: cover; background: var(--surface-3); }
.publish-group-thumb.is-empty { border: 1px dashed var(--border-strong); }
.publish-list { display: grid; gap: .35rem; margin: 0; padding: 0; list-style: none; }
.publish-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem .7rem; border-radius: 6px; background: rgba(10,10,12,.22); }
.publish-row:hover { background: rgba(10,10,12,.4); }
.publish-row.is-blocked { opacity: .62; }
.publish-row-main { display: grid; gap: .1rem; min-width: 0; text-decoration: none; color: inherit; }
.publish-row-name { font-weight: 620; }
.publish-row-meta { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.publish-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 1rem; align-items: start; }
@media (max-width: 1100px) { .publish-layout { grid-template-columns: minmax(0, 1fr); } }
.publish-generate { padding: var(--panel-pad); margin-bottom: var(--space-4); }
.publish-generate .hint { flex-basis: 100%; margin: 0; }
.publish-tabs { display: grid; gap: var(--space-3); }
.publish-panel { padding: var(--panel-pad); }
.publish-panel-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .3rem; }
.publish-panel-head h3 { margin: 0; }
.publish-regen { padding: 0 .2rem; }

/* Editor timeline (app/static/js/editor-timeline.js). One waveform track
   with IN/OUT handles over the raw source video. The striped background is
   the no-waveform fallback: extraction can fail or be skipped, and the
   trim handles must stay fully usable without it. */
[data-editor-timeline] {
  --timeline-wave-color: rgba(228, 228, 231, .5);
  position: relative;
  outline: none;
}
[data-editor-timeline]:focus-visible .timeline-track { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* editor-timeline.js toggles .is-playing while the source video runs: the
   playhead brightens and the selection edge glows so "rolling" is legible
   at a glance without watching the video itself. */
[data-editor-timeline].is-playing .timeline-playhead { background: var(--cyan); box-shadow: 0 0 10px rgba(76, 201, 255, .65); }
[data-editor-timeline].is-playing .timeline-selection { border-inline-color: rgba(250, 250, 250, .85); }
.timeline-track {
  --track-h: 84px;
  position: relative;
  height: var(--track-h);
  border: 1px solid var(--border);
  border-radius: 6px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 2px, transparent 2px 14px),
    #0f0f12;
  cursor: crosshair;
  touch-action: none;
  overflow: hidden;
}
.timeline-wave { position: absolute; inset: 0; width: 100%; height: 100%; }
.timeline-selection {
  position: absolute; top: 0; bottom: 0;
  background: rgba(255, 255, 255, .14);
  border-inline: 1px solid rgba(255, 255, 255, .5);
  pointer-events: none;
}
.timeline-playhead {
  position: absolute; top: 0; bottom: 0; width: 2px;
  margin-left: -1px;
  background: #ff6b7d;
  pointer-events: none;
  z-index: 3;
}
.timeline-playhead::before {
  content: "";
  position: absolute; top: 0; left: 50%;
  width: 9px; height: 9px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: #ff6b7d;
}
.timeline-handle {
  position: absolute; top: 0; bottom: 0;
  width: 22px;
  margin-left: -11px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: ew-resize;
  touch-action: none;
  z-index: 4;
}
.timeline-handle::before {
  content: "";
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 5px;
  transform: translateX(-50%);
  border-radius: 3px;
  background: var(--cyan);
  transition: background var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.timeline-handle:hover::before,
.timeline-handle:focus-visible::before { background: #7ce6ff; box-shadow: 0 0 0 4px rgba(69,216,255,.25); }
.timeline-handle:focus-visible { outline: none; }
.timeline-handle span {
  position: absolute; bottom: 4px; left: 50%;
  transform: translateX(-50%);
  padding: .05rem .28rem;
  border-radius: 4px;
  background: rgba(8,15,24,.85);
  color: var(--cyan);
  font-size: .58rem;
  font-weight: 750;
  letter-spacing: .06em;
  pointer-events: none;
}
.timeline-readout {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  margin-top: .45rem;
  font-size: .78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.timeline-time { min-width: 3.6rem; color: var(--text); font-weight: 700; font-family: var(--font-mono); font-size: .8rem; font-variant-numeric: tabular-nums; }
.timeline-hint kbd {
  display: inline-block;
  min-width: 1.1rem;
  padding: .08rem .3rem;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .66rem;
  text-align: center;
}
@media (max-width: 720px) {
  .timeline-track { --track-h: 64px; }
  .timeline-hint { display: none; }
  /* Too cramped to be useful on a phone. */
  .timeline-filmstrip { display: none; }
  .zoom-control { position: static; }
  .transport-row { flex-wrap: wrap; gap: .6rem; }
}

/* Ranking cut editor: the same component appears per item, so the source
   video gets a fixed-height frame instead of its natural size. */
.ranking-source-video { width: 100%; max-height: 320px; border-radius: 6px; background: #000; }

/* Clip editor trim section: the raw source above the timeline. */
#trim [data-timeline-video] {
  display: block;
  width: 100%;
  max-height: 420px;
  margin-bottom: .7rem;
  border-radius: 6px;
  background: #000;
}

/* 18. EDITOR WORKSPACE (Phase D) ------------------------------------------
   Toolbar / rail / center / inspector. The inspector stacks its panels in
   one grid cell -- form#edit and the standalone cue/AI forms stay siblings,
   so nothing is ever nested inside another form. Below 1100px the inspector
   becomes a right-hand drawer toggled from the toolbar. */
/* Editor anatomy (Opus): transcript LEFT · canvas+rail RIGHT · full-stage
   timeline BELOW both. The transcript column scrolls independently so a long
   cue list never stretches the canvas row. */
.editor-shell { display: grid; gap: var(--space-4); }
.editor-toolbar { position: sticky; top: .75rem; z-index: var(--z-sticky); display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: .7rem .9rem; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(14, 14, 17, .92); backdrop-filter: blur(14px); box-shadow: var(--shadow-sm); }
.toolbar-side { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.toolbar-title { min-width: 0; margin-right: auto; }
.toolbar-title .eyebrow { margin: 0; }
.toolbar-title h1 { overflow: hidden; margin: 0; font-family: var(--font-sans); font-weight: 650; font-size: 1rem; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
.save-chip { display: inline-flex; flex: none; align-items: center; gap: .45rem; padding: .28rem .7rem; border: 1px solid var(--border); border-radius: 999px; color: var(--subtle); font-size: .74rem; font-weight: 650; white-space: nowrap; }
.save-chip::before { content: ""; width: .5rem; height: .5rem; border-radius: 999px; background: var(--success); box-shadow: 0 0 8px rgba(61, 214, 140, .5); }
.save-chip[data-state="dirty"]::before { background: var(--warning); box-shadow: 0 0 8px rgba(245, 185, 66, .5); }
.save-chip[data-state="saving"]::before { background: var(--cyan); box-shadow: 0 0 8px rgba(88, 182, 255, .5); }
.save-chip[data-state="error"] { color: var(--danger, #ff6b6b); border-color: var(--danger, #ff6b6b); }
.save-chip[data-state="error"]::before { background: var(--danger, #ff6b6b); box-shadow: 0 0 8px rgba(255, 107, 107, .5); }
/* Cue rows flash while their autosave is in flight. */
form.subtitle-cue.is-saving { opacity: .65; }
/* The cue under the playhead, while the source video plays. */
form.subtitle-cue.is-active { border-color: var(--cyan); background: rgba(88, 182, 255, .08); }
form.subtitle-cue.is-active .cue-number { color: var(--cyan); }

/* Two-column top region + full-width bottom row (grid rows, not nested). */
.editor-grid { display: grid; gap: var(--space-4); grid-template-columns: minmax(300px, 34%) minmax(0, 1fr); align-items: start; }
.editor-stage { display: grid; gap: var(--space-4); min-width: 0; }
.editor-columns { display: grid; grid-template-columns: minmax(0, 1fr) 64px minmax(280px, 320px); gap: var(--space-4); align-items: start; }

/* ── Left transcript column ─────────────────────────────────────────── */
.editor-transcript { position: sticky; top: 72px; display: grid; gap: .8rem; align-content: start; max-height: calc(100dvh - 96px); padding: var(--panel-pad); overflow-y: auto; scrollbar-width: thin; }
.transcript-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.cue-search input { min-height: 38px; font-size: .88rem; background: #101013; }

/* ── Center canvas ──────────────────────────────────────────────────── */
.canvas-strip { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .8rem; margin-bottom: .75rem; }
.aspect-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .42rem .65rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-3); color: var(--muted); font-size: .76rem; font-weight: 700; letter-spacing: .02em; }
.aspect-chip svg { width: .95rem; height: .95rem; }
.layout-chip { display: inline-flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .76rem; font-weight: 650; }
.layout-chip select { width: auto; min-height: 36px; padding: .3rem .55rem; font-size: .82rem; }
.strip-spacer { flex: 1 0 auto; }

.editor-center { display: grid; gap: var(--space-4); min-width: 0; }
.preview-card { padding: .8rem; }
.segmented-control { display: inline-flex; padding: .2rem; border: 1px solid var(--border); border-radius: 6px; background: #101013; }
.segmented-control button { min-height: 36px; padding: .4rem .6rem; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; font-size: .76rem; }
.segmented-control button.active { background: var(--surface-3); color: var(--text); }
.canvas-strip .switch-label { font-size: .75rem; }
.cue-chip { position: absolute; top: 4px; bottom: 4px; overflow: hidden; padding: 0 .4rem; border: 1px solid rgba(255,255,255,.22); border-radius: 6px; background: rgba(255,255,255,.08); color: #e4e4e7; cursor: pointer; font-size: .68rem; line-height: 24px; text-align: left; text-overflow: ellipsis; white-space: nowrap; transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
.cue-chip:hover { background: var(--accent-soft); color: white; }

/* Rail + inspector keep their names, now inside .editor-columns. */
.editor-rail { position: sticky; top: 72px; display: grid; gap: .4rem; padding: .5rem .35rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.rail-button { display: grid; justify-items: center; gap: .3rem; min-height: 56px; padding: .5rem .2rem; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: .68rem; font-weight: 660; transition: color var(--dur) var(--ease-out), background var(--dur) var(--ease-out); }
.rail-button:hover { background: var(--surface-2); color: var(--text); }
.rail-button.active { background: var(--accent-soft); color: var(--text); }
.rail-button svg.icon { width: 1.15rem; height: 1.15rem; }

/* ── Bottom timeline stage ──────────────────────────────────────────── */
.timeline-card { padding: var(--panel-pad); grid-column: 1 / -1; }
.timeline-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; }
.timeline-head .eyebrow { margin: 0; }
#trim [data-timeline-video] { max-height: 220px; }

/* Transport (Opus): centered controls + mono timecode, zoom parked right.
   Play state on the CARD lets the button glyph swap via CSS. */
.transport-row { position: relative; display: flex; align-items: center; justify-content: center; gap: 1rem; margin-bottom: .7rem; }
.transport-buttons { display: inline-flex; gap: .35rem; }
.transport-buttons .icon-button { width: 38px; min-width: 38px; height: 38px; }
.transport-play svg { fill: currentColor; stroke: none; }
.transport-play .glyph-pause { display: none; }
.timeline-card.is-playing .transport-play .glyph-play { display: none; }
.timeline-card.is-playing .transport-play .glyph-pause { display: block; fill: none; stroke: currentColor; stroke-width: 1.8; }
.transport-time { min-width: 9.5ch; color: var(--muted); font-family: var(--font-mono); font-size: .8rem; text-align: center; font-variant-numeric: tabular-nums; }
.zoom-control { position: absolute; right: 0; display: inline-flex; align-items: center; gap: .45rem; color: var(--subtle); font-size: .74rem; }
.zoom-control input[type="range"] { width: 110px; min-height: auto; padding: 0; accent-color: var(--primary); }
.timeline-zoom-wrap { overflow-x: auto; scrollbar-width: thin; border-radius: var(--radius-sm); }

/* Filmstrip: thumbnails on the SAME time axis as the waveform below them;
   JS positions each frame by source-absolute percentage. */
.timeline-filmstrip { position: relative; height: 46px; margin-bottom: 5px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #0f0f12; }
.timeline-filmstrip img { position: absolute; top: 0; height: 100%; object-fit: cover; border-right: 1px solid rgba(255,255,255,.06); filter: saturate(.92); }

.timeline-stage { margin-bottom: .6rem; }
.cue-track-row { display: grid; grid-template-columns: 72px 1fr; gap: .6rem; align-items: center; margin-top: .6rem; }
.track-label { color: var(--subtle); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.cue-track { position: relative; height: 34px; overflow: hidden; border-radius: var(--radius-sm); background: rgba(10, 10, 12, .5); }

/* Cue rows share the two-line layout whether they live in the inspector
   or in the left transcript column. */
.transcript-cues { max-height: none; }

/* Inspector: every panel occupies the same cell; [hidden] does the rest. */
.editor-inspector { position: relative; display: grid; align-content: start; }
.editor-inspector > * { grid-area: 1 / 1; min-width: 0; }
.inspector-panel { padding: var(--panel-pad); display: grid; gap: var(--space-3); align-content: start; max-height: calc(100dvh - 96px); overflow-y: auto; scrollbar-width: thin; }
.inspector-title { margin: 0; padding-top: .35rem; font-size: .95rem; letter-spacing: -.01em; }
.inspector-panel > .inspector-title:not(:first-child) { margin-top: .75rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.inspector-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.inspector-heading .inspector-title { padding-top: 0; border-top: 0; }
.inspector-cues { max-height: none; }
.inspector-cover-grid { grid-template-columns: 1fr; }
.export-facts { margin: 0 0 .25rem; }
/* Keyboard-shortcut sheet (Phase J): every row mirrors a real binding in
   editor-timeline.js. */
.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem 1.25rem; margin: 0 0 .5rem; padding: 0; }
.shortcut-grid div { display: flex; align-items: center; gap: .7rem; min-height: 36px; }
.shortcut-grid dt { flex: none; min-width: 86px; }
.shortcut-grid dd { margin: 0; color: var(--muted); font-size: .86rem; }
kbd { display: inline-block; min-width: 1.6rem; padding: .14rem .42rem; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; background: var(--surface-2); color: var(--text); font-family: var(--font-mono); font-size: .74rem; text-align: center; }

@media (max-width: 1240px) {
  .editor-columns { grid-template-columns: minmax(0, 1fr) 56px minmax(250px, 290px); }
}
@media (max-width: 1100px) {
  /* Stack: transcript above canvas; inspector becomes a drawer. */
  .editor-grid { grid-template-columns: 1fr; }
  .editor-transcript { position: static; max-height: none; overflow: visible; }
  .editor-columns { grid-template-columns: 1fr; }
  .editor-rail { position: static; grid-auto-flow: column; justify-content: start; overflow-x: auto; }
  .rail-button { grid-auto-flow: unset; }
  /* Drawer instead of a squeezed third column. */
  .editor-inspector { position: fixed; inset: 0 0 0 auto; z-index: var(--z-overlay); width: min(420px, 94vw); padding: 0; transform: translateX(105%); transition: transform var(--dur-slow) var(--ease-out); }
  .editor-shell.inspector-open .editor-inspector { transform: none; box-shadow: -30px 0 60px rgba(0, 0, 0, .45); }
  .toolbar-inspector-toggle { display: inline-grid; }
}
@media (min-width: 1101px) {
  .toolbar-inspector-toggle { display: none; }
}

/* 18b. UNIFIED STUDIO (media pool + swapped workspace) --------------------
   The rail is persistent chrome; #studio-workspace is the only region a
   clip switch replaces. The rail scrolls independently so long projects
   never stretch the canvas row. */
.studio-grid { display: grid; gap: var(--space-4); grid-template-columns: minmax(250px, 292px) minmax(0, 1fr); align-items: start; }
.clip-rail { position: sticky; top: 72px; display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: .6rem; max-height: calc(100dvh - 96px); padding: var(--panel-pad); overflow: hidden; }
.clip-rail-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.rail-count-chips { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
.rail-count-chip { padding: .16rem .55rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: .7rem; font-weight: 650; white-space: nowrap; }
.rail-chip-viral { color: #ff9aab; }

/* The studio tools bar is the same data-driven contract as the old results
   pages, compacted for the narrow column. */
.clip-rail .clip-tools { margin-bottom: 0; padding: 0; border-bottom: 0; gap: .4rem; }
.clip-rail .clip-tools label { min-height: 34px; font-size: .74rem; }
.clip-rail .clip-tools input, .clip-rail .clip-tools select { min-height: 34px; padding: .25rem .5rem; font-size: .8rem; max-width: 100%; }
.clip-rail .clip-tools > label:first-child { flex: 1 1 100%; }
.clip-rail .clip-tools input[data-clip-search] { width: 100%; }

.clip-rail-list { display: grid; gap: .45rem; align-content: start; overflow-y: auto; margin-right: -.35rem; padding: .1rem .3rem .1rem .05rem; scrollbar-width: thin; }
.clip-rail-item { position: relative; display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: .55rem; padding: .4rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: inherit; text-decoration: none; transition: background var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out); }
.clip-rail-item:hover { background: var(--surface-2); border-color: var(--border-strong); }
.clip-rail-item.is-active { border-color: var(--border-strong); background: var(--surface-3); box-shadow: inset 2px 0 0 var(--cta-bg); }
.rail-thumb { position: relative; aspect-ratio: 16 / 10; overflow: hidden; border-radius: 4px; background: #0a0a0c; }
.rail-thumb img { width: 100%; height: 100%; object-fit: cover; }
.rail-thumb-fallback { display: grid; width: 100%; height: 100%; place-content: center; color: var(--subtle); }
.rail-thumb .thumb-duration { right: .3rem; bottom: .3rem; padding: .08rem .35rem; font-size: .64rem; }
.rail-thumb .clip-kind { left: .3rem; top: .3rem; z-index: 1; padding: .12rem .4rem; font-size: .6rem; }
.rail-thumb .clip-kind svg { width: .8rem; height: .8rem; }
.rail-body { display: grid; gap: .22rem; align-content: start; min-width: 0; }
.rail-top-row { display: flex; align-items: center; justify-content: space-between; gap: .4rem; min-height: 20px; }
.score-ring-sm { width: 30px; height: 30px; flex: none; place-content: center; border-width: 2px; font-size: .72rem; }
.rail-render-dot { width: .55rem; height: .55rem; flex: none; border-radius: 999px; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border-strong); }
.rail-render-rendered { background: var(--success); box-shadow: 0 0 8px rgba(61, 214, 140, .45); }
.rail-render-processing { background: var(--cyan); box-shadow: 0 0 8px rgba(88, 182, 255, .45); }
.rail-render-failed { background: var(--danger); box-shadow: 0 0 8px rgba(255, 107, 125, .45); }
.rail-title { overflow: hidden; color: var(--text); font-size: .82rem; font-weight: 600; line-height: 1.3; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rail-sub { color: var(--subtle); font-family: var(--font-mono); font-size: .68rem; letter-spacing: .02em; }

/* Swap affordance: the workspace dims while a fragment is in flight. */
#studio-workspace.is-swapping { opacity: .55; pointer-events: none; transition: opacity var(--dur-fast) var(--ease-out); }

/* Merged-in card details (Media panel). */
.media-score-row { display: flex; align-items: center; gap: .7rem; margin-top: .85rem; }
.media-reason { margin-top: .85rem; }
.media-reason p { margin: .25rem 0 0; color: var(--muted); font-size: .86rem; line-height: 1.5; }

/* Captions panel body scrolls independently of the inspector column. */
.captions-body { display: grid; gap: .6rem; align-content: start; max-height: min(58dvh, 520px); overflow-y: auto; padding-right: .15rem; scrollbar-width: thin; }

@media (max-width: 1100px) {
  .studio-grid { grid-template-columns: 1fr; }
  /* Rail becomes a horizontal strip of fixed-width cards, like the editor
     rail does below this breakpoint. */
  .clip-rail { position: static; max-height: none; }
  .clip-rail-list { grid-auto-flow: column; grid-auto-columns: 240px; overflow-x: auto; overflow-y: hidden; padding-bottom: .3rem; }
  .clip-rail .clip-tools > label:first-child { flex: 1 1 auto; }
}

/* 19. RANKING STEPPER + DRAG REORDER (Phase E) ----------------------------
   The stage nav reads as one sequence; numbers are wayfinding, never fake
   completion states -- all stages stay independently accessible. */
.stage-stepper { gap: .3rem; }
.step-num { display: inline-grid; width: 1.35rem; height: 1.35rem; margin-right: .45rem; place-items: center; border: 1px solid var(--border-strong); border-radius: 999px; background: rgba(10, 10, 12, .4); color: var(--subtle); font-size: .7rem; font-weight: 720; transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out); }
.stage-stepper a:hover .step-num { border-color: var(--border-strong); background: var(--surface-3); color: var(--text); }

/* Reorder rows are draggable; the chevrons stay as the keyboard path and
   both write the same hidden order field. */
.reorder-row { cursor: grab; }
.reorder-row.is-dragging { opacity: .45; cursor: grabbing; }
.reorder-grip { display: inline-grid; flex: none; color: var(--subtle); }
.reorder-row.is-dragging .reorder-grip { color: var(--text); }

/* 20. EDITOR POLISH (Phase D feedback) ------------------------------------
   Cue rows become two-line -- text first at full panel width, times tucked
   underneath -- so nothing is crushed in the 384px inspector. Fit frames
   letterbox the preview; below-video captions preview inside the band. */
.inspector-cues .subtitle-cue, .transcript-cues .subtitle-cue { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "num text save" "num times save"; align-items: center; column-gap: .55rem; }
.inspector-cues .subtitle-cue, .transcript-cues .subtitle-cue .cue-number { align-self: start; margin-top: .8rem; grid-area: num; }
.inspector-cues .subtitle-cue, .transcript-cues .subtitle-cue .cue-text { grid-area: text; }
.inspector-cues .subtitle-cue, .transcript-cues .subtitle-cue .cue-times { grid-area: times; display: flex; gap: .45rem; margin-top: .4rem; }
.inspector-cues .subtitle-cue, .transcript-cues .subtitle-cue .cue-times input { font-family: var(--font-mono); font-size: .78rem; min-height: 34px; padding: .3rem .45rem; }
.inspector-cues .subtitle-cue, .transcript-cues .subtitle-cue button { grid-area: save; align-self: center; }

/* Frame mode "fit": whole picture visible, bars top and bottom. */
.tiktok-mode[data-frame-mode="fit"] .preview-video-area video { object-fit: contain; background: #04060a; }
/* Below-video captions: the safe indicator moves into the frame's own
   bottom band, mirroring where build_ass places them on the render. */
.tiktok-mode[data-subtitle-position="below_video"] .subtitle-safe { top: auto; bottom: .5%; height: calc(var(--frame-bottom) - 1%); border-color: rgba(74, 214, 160, .85); background: rgba(74, 214, 160, .10); }

/* 21. DEEP WORKSPACE POLISH (Phase L) -------------------------------------- */
/* Ranking cut cards: the entry's rank reads as a countdown badge, with the
   filename and current range beside it instead of one long hash-string. */
.rank-head { align-items: center; }
.rank-identity { display: flex; min-width: 0; align-items: center; gap: .75rem; }
.rank-badge { display: grid; width: 40px; height: 40px; flex: none; place-items: center; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface-3); color: #e4e4e7; font-family: var(--font-mono); font-size: 1.05rem; font-weight: 780; }
.rank-copy { min-width: 0; display: grid; gap: .1rem; }
.rank-copy h3 { overflow: hidden; margin: 0; font-size: .98rem; text-overflow: ellipsis; white-space: nowrap; }
.rank-sub { margin: 0; color: var(--subtle); font-size: .78rem; font-variant-numeric: tabular-nums; }

/* 22. REDUCED MOTION (UX P1) -------------------------------------------------
   One global escape hatch: users who ask for less motion get instant state
   changes instead of animated ones. Static end-states are identical -- only
   the movement goes away (spinners collapse to their resting frame). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
