/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  color-scheme: light dark;
  --sans: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --radius: 6px;
  --topbar: 56px;
  --jobs-w: 340px;

  /* light (paper) */
  --bg: #f3f0e9;
  --bg-2: #ebe7de;
  --panel: #faf8f3;
  --panel-2: #f1ede4;
  --line: #e2dcd0;
  --line-2: #cfc7b8;
  --ink: #1f1c18;
  --ink-dim: #5d564d;
  --ink-mute: #948b7f;
  --amber: #c9780f;
  --amber-2: #a86206;
  --amber-soft: rgba(201, 120, 15, 0.14);
  --amber-ink: #fff8ec;
  --teal: #1f8c73;
  --teal-dim: #9fd3c3;
  --blue: #2f6fd0;
  --red: #c4432c;
  --log-bg: #f6f3ec;
  --shadow: 0 10px 30px rgba(40, 30, 10, 0.12);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12100e;
    --bg-2: #0d0b0a;
    --panel: #1a1714;
    --panel-2: #221e1a;
    --line: #2a2521;
    --line-2: #3a332c;
    --ink: #ebe4d8;
    --ink-dim: #a69c8f;
    --ink-mute: #6f665c;
    --amber: #e9a23a;
    --amber-2: #f6bd64;
    --amber-soft: rgba(233, 162, 58, 0.16);
    --amber-ink: #2a1a04;
    --teal: #4fcfae;
    --teal-dim: #2b6d60;
    --blue: #7ab6ff;
    --red: #e8634d;
    --log-bg: #0d0b0a;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  }
}
/* Pinned themes also tell the browser which scrollbars, form controls and dialogs to draw. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12100e;
  --bg-2: #0d0b0a;
  --panel: #1a1714;
  --panel-2: #221e1a;
  --line: #2a2521;
  --line-2: #3a332c;
  --ink: #ebe4d8;
  --ink-dim: #a69c8f;
  --ink-mute: #6f665c;
  --amber: #e9a23a;
  --amber-2: #f6bd64;
  --amber-soft: rgba(233, 162, 58, 0.16);
  --amber-ink: #2a1a04;
  --teal: #4fcfae;
  --teal-dim: #2b6d60;
  --blue: #7ab6ff;
  --red: #e8634d;
  --log-bg: #0d0b0a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* ── Base ────────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: background 0.2s, color 0.2s;
}
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--amber); color: var(--amber-ink); }
a { color: var(--amber-2); }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; }
.mono { font-family: var(--mono); }

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-weight: 600; font-size: 16px; }
.brand-sub { font-family: var(--mono); font-size: 11px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: 0.14em; }
.tally {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--line-2);
  transition: background 0.3s;
}
.tally.on {
  background: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-soft);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 6px transparent; } }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; margin-left: 6px;
  background: var(--amber); color: var(--amber-ink); font-size: 11px; font-weight: 600;
  display: inline-grid; place-content: center;
}
.badge:empty { display: none; }

/* ── Buttons & controls ──────────────────────────────────────────────────── */
.btn {
  border: 1px solid var(--line-2); background: var(--panel); color: var(--ink);
  padding: 7px 12px; border-radius: var(--radius); cursor: pointer;
  font-size: 13px; font-weight: 500;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
  white-space: nowrap; text-decoration: none;
  display: inline-flex; align-items: center;
}
.btn:hover { background: var(--panel-2); border-color: var(--ink-mute); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); font-weight: 600; }
.btn.primary:hover { background: var(--amber-2); border-color: var(--amber-2); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.active { border-color: var(--amber); background: var(--amber-soft); }
.seg-ctl { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; }
.seg-ctl button {
  border: 0; background: transparent; color: var(--ink-dim); padding: 6px 10px; cursor: pointer;
  font-size: 12px; font-weight: 500; border-right: 1px solid var(--line-2); transition: background 0.15s, color 0.15s;
}
.seg-ctl button:last-child { border-right: 0; }
.seg-ctl button:hover { background: var(--panel-2); color: var(--ink); }
.seg-ctl button.on { background: var(--amber); color: var(--amber-ink); font-weight: 600; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-dim); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--amber); }
input[type="search"], input[type="text"], input:not([type]), input[type="password"], select, textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 8px 10px; outline: none; transition: border-color 0.15s; color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--amber); }
textarea { resize: vertical; }

/* ── Shell ───────────────────────────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 0;
  height: calc(100vh - var(--topbar));
  transition: grid-template-columns 0.2s ease;
}
body.jobs-open .shell { grid-template-columns: 270px minmax(0, 1fr) var(--jobs-w); }
.index, .jobs { background: var(--panel); overflow: hidden; display: flex; flex-direction: column; }
.index { border-right: 1px solid var(--line); }
.jobs { border-left: 1px solid var(--line); visibility: hidden; }
body.jobs-open .jobs { visibility: visible; }
.stage { overflow-y: auto; padding: 28px 32px 80px; }

.index-head { display: flex; align-items: center; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.count { font-family: var(--mono); font-size: 11px; color: var(--ink-mute); white-space: nowrap; }
.story-list, .job-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.story-item {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer;
  border-left: 2px solid transparent; transition: background 0.12s;
}
.story-item:hover { background: var(--panel-2); }
.story-item.active { background: var(--panel-2); border-left-color: var(--amber); }
.story-item .id { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); letter-spacing: 0.04em; display: flex; align-items: center; gap: 6px; }
.story-item .topic { grid-column: 1 / -1; font-weight: 500; font-size: 14px; line-height: 1.3; color: var(--ink); }
.story-item .topic:empty::before { content: "Untitled"; color: var(--ink-mute); }
.bars { grid-column: 1 / -1; display: flex; gap: 4px; margin-top: 4px; }
.bar { flex: 1; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--teal); width: var(--w, 0%); transition: width 0.4s; }
.bar.img > i { background: var(--blue); }
.pill {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  padding: 2px 6px; border-radius: 3px; border: 1px solid var(--line-2); color: var(--ink-dim);
}
.pill.hidden { border-style: dashed; color: var(--ink-mute); }
.status-ctl button.hidden.on { background: var(--ink-dim); color: var(--panel); }

/* Story list: one chip per status; on = stories with that status are listed */
.status-filter { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.status-filter:empty { display: none; }
.status-chip {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--line-2); background: transparent; color: var(--ink-mute); cursor: pointer;
}
.status-chip .n { opacity: 0.7; }
.status-chip:hover { color: var(--ink); }
.status-chip.on { background: var(--panel-2); color: var(--ink); border-color: var(--ink-mute); }
.status-chip.picked.on { border-color: var(--teal); color: var(--teal); }
.status-chip.processed.on { border-color: var(--blue); color: var(--blue); }
.status-chip:not(.on) { text-decoration: line-through; }
.list-note { padding: 16px 12px; font-size: 13px; color: var(--ink-mute); }

.status-ctl button { text-transform: capitalize; padding: 6px 12px; }
.style-sel {
  width: auto; max-width: 240px; padding: 5px 26px 5px 10px; font-family: var(--sans); font-size: 12px; font-weight: 500;
  border: 1px solid var(--line-2); border-radius: var(--radius); background-color: var(--panel); color: var(--ink); cursor: pointer;
}
.style-sel:hover { border-color: var(--ink-mute); }
.style-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.style-row input { flex: 1; min-width: 220px; }
.char-note.shared { color: var(--amber-2); }
.status-ctl button.picked.on { background: var(--teal); color: #fff; }
.status-ctl button.processed.on { background: var(--blue); color: #fff; }
.status-ctl button.no.on { background: var(--ink-mute); color: #fff; }
.status-ctl button:disabled { cursor: wait; opacity: 0.7; }
.pill.picked { border-color: var(--teal-dim); color: var(--teal); }
.pill.processed { border-color: var(--blue); color: var(--blue); }
.pill.running { border-color: var(--amber); color: var(--amber); display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); animation: pulse 1.6s infinite; }

/* ── Stage: empty ────────────────────────────────────────────────────────── */
.empty { height: 100%; display: grid; place-content: center; text-align: center; color: var(--ink-mute); }
.empty-title { font-size: 22px; font-weight: 600; margin: 0 0 6px; color: var(--ink-dim); }
.empty-sub { margin: 0; }
.loading { color: var(--ink-mute); font-family: var(--mono); font-size: 12px; padding: 40px 0; }

/* ── Stage: story header ─────────────────────────────────────────────────── */
.story-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 24px; align-items: end; margin-bottom: 20px; }
.eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; font-family: var(--mono); font-size: 12px; color: var(--ink-dim); }
.story-title { font-size: clamp(22px, 2.4vw, 30px); line-height: 1.2; margin: 6px 0 0; }
.story-meta { grid-column: 1 / -1; margin: 0; color: var(--ink-dim); }
.source-text { grid-column: 1 / -1; font-size: 13px; color: var(--ink-dim); }
.source-text summary { cursor: pointer; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-mute); }
.source-text p { margin: 8px 0 0; white-space: pre-wrap; padding: 10px 12px; border-left: 2px solid var(--amber); background: var(--panel); border-radius: 0 6px 6px 0; }
.story-meta b { color: var(--ink); font-weight: 600; }
.head-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.head-actions .row { display: flex; gap: 6px; }

/* ── Stage strip ─────────────────────────────────────────────────────────── */
.strip {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
  margin: 8px 0 28px;
}
.seg {
  min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; min-height: 92px; display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
  transition: border-color 0.2s;
}
.seg.done { border-color: var(--teal-dim); }
.seg.running { border-color: var(--amber); }
.seg-label { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-dim); display: flex; justify-content: space-between; }
.seg-label .n { color: var(--ink-mute); }
.seg-val { font-size: 24px; font-weight: 600; line-height: 1; }
.seg-val small { font-size: 13px; color: var(--ink-mute); font-family: var(--mono); font-weight: 400; margin-left: 4px; }
.seg.done .seg-val { color: var(--teal); }
.seg-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.seg-foot .hint { min-width: 0; font-size: 12px; color: var(--ink-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Sections ────────────────────────────────────────────────────────────── */
.section { margin-top: 30px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.section-head h3 { margin: 0; font-size: 16px; }
.section-head .sub { font-family: var(--mono); font-size: 11px; color: var(--ink-mute); }
.section-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.section-tools .seg-ctl button { padding: 4px 10px; }

/* ── Scene details list ──────────────────────────────────────────────────── */
.scene-list { display: grid; gap: 10px; }
.scene-row {
  display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px;
  padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  opacity: 0; transform: translateY(6px); animation: reveal 0.35s ease-out forwards; animation-delay: calc(var(--i, 0) * 25ms);
  transition: border-color 0.15s;
}
.scene-row:hover { border-color: var(--amber); }
.scene-row-thumb { position: relative; aspect-ratio: 9 / 16; border-radius: 6px; overflow: hidden; background: var(--bg-2); border: 1px solid var(--line); }
.scene-row-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scene-row-thumb .ph { position: absolute; inset: 0; display: grid; place-content: center; color: var(--ink-mute); font-family: var(--mono); font-size: 10px; text-align: center; }
.scene-row-thumb .play { position: absolute; inset: 0; display: grid; place-content: center; pointer-events: none; }
.scene-row-thumb .play span { width: 28px; height: 28px; border-radius: 50%; background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.3); color: #fff; display: grid; place-content: center; font-size: 10px; padding-left: 2px; }
.scene-row-body { display: grid; gap: 8px; align-content: start; min-width: 0; }
.scene-row-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.scene-row-head .fr { font-size: 18px; font-weight: 600; line-height: 1; }
.scene-row-head .ts { font-size: 11px; color: var(--ink-dim); }
.scene-row-head .model { font-size: 11px; color: var(--ink-mute); margin-left: auto; }
.flags-inline { display: inline-flex; gap: 4px; }
.flags-inline .flag { background: var(--bg-2); color: var(--ink-mute); border: 1px solid var(--line); }
.flags-inline .flag.on { color: #fff; border-color: transparent; }
.scene-row-story { margin: 0; font-size: 15px; font-weight: 500; line-height: 1.4; }
.scene-row .kv { grid-template-columns: 96px 1fr; }

/* ── Scene grid ──────────────────────────────────────────────────────────── */
.scenes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.scene {
  position: relative; aspect-ratio: 9 / 16; border-radius: 8px; overflow: hidden; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--line);
  opacity: 0; transform: translateY(8px);
  animation: reveal 0.4s ease-out forwards;
  animation-delay: calc(var(--i, 0) * 35ms);
  transition: border-color 0.15s, transform 0.15s;
}
@keyframes reveal { to { opacity: 1; transform: none; } }
.scene:hover { border-color: var(--amber); transform: translateY(-2px); }
.scene img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scene .ph { position: absolute; inset: 0; display: grid; place-content: center; color: var(--ink-mute); font-family: var(--mono); font-size: 11px; text-align: center; padding: 12px; }
.scene .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 8px 8px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.8));
  display: flex; justify-content: space-between; align-items: flex-end; gap: 6px; color: #fff;
}
.scene .fr { font-size: 18px; font-weight: 600; line-height: 1; }
.scene .ts { font-family: var(--mono); font-size: 10px; color: rgba(255,255,255,0.75); }
.flags { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.flag { width: 18px; height: 18px; border-radius: 4px; display: grid; place-content: center; font-family: var(--mono); font-size: 10px; font-weight: 600; background: rgba(0,0,0,0.55); color: rgba(255,255,255,0.5); }
.flag.on { color: #0b0908; }
.flag.img.on { background: var(--blue); }
.flag.vid.on { background: var(--teal); }
.scene .play { position: absolute; inset: 0; display: grid; place-content: center; pointer-events: none; }
.scene .play span { width: 36px; height: 36px; border-radius: 50%; background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.3); color: #fff; display: grid; place-content: center; font-size: 12px; padding-left: 3px; }

/* ── Narrative & characters ──────────────────────────────────────────────── */
.narr { display: grid; gap: 8px; }
.narr-row { display: grid; grid-template-columns: 76px 1fr 1fr; gap: 14px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.narr-row .t { font-family: var(--mono); font-size: 12px; color: var(--amber-2); }
.narr-row .zh { color: var(--ink-dim); }
.chars { display: flex; flex-wrap: wrap; gap: 10px; }
.char {
  display: flex; align-items: center; gap: 12px; padding: 6px 14px 6px 6px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: var(--ink);
  transition: border-color 0.15s, transform 0.15s;
}
.char:hover { border-color: var(--amber); transform: translateY(-1px); }
.char img, .char-ph { width: 44px; height: 64px; border-radius: 6px; object-fit: cover; background: var(--bg-2); }
.char-ph { display: grid; place-content: center; color: var(--ink-mute); font-family: var(--mono); }
.char .nm { font-weight: 500; }
.char-media { background: #000; border-radius: 8px; overflow: hidden; border: 1px solid var(--line-2); display: grid; place-content: center; min-height: 320px; max-height: calc(100vh - 120px); }
.char-media img { width: 100%; height: 100%; max-height: calc(100vh - 120px); object-fit: contain; display: block; }
.char-media .ph { color: var(--ink-mute); font-family: var(--mono); font-size: 12px; padding: 20px; }
.char-body { grid-template-columns: minmax(0, 1fr) 320px; }
.char-note { margin: 0; color: var(--ink-dim); line-height: 1.55; }

/* ── Jobs ────────────────────────────────────────────────────────────────── */
.jobs-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-dim); }
.jobs-head .btn { text-transform: none; letter-spacing: 0; font-family: var(--sans); }
.job-list { max-height: 42%; border-bottom: 1px solid var(--line); }
.job-item { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 8px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 12px; border-left: 2px solid transparent; }
.job-item:hover { background: var(--panel-2); }
.job-item.active { background: var(--panel-2); border-left-color: var(--amber); }
.job-item .st { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-mute); }
.job-item .st.running { background: var(--amber); animation: pulse 1.6s infinite; box-shadow: 0 0 0 3px var(--amber-soft); }
.job-item .st.succeeded { background: var(--teal); }
.job-item .st.partial { background: var(--amber-2); }
.job-item .st.failed { background: var(--red); }
.job-item .stage { color: var(--ink); font-weight: 500; }
.job-item .story { color: var(--ink-dim); grid-column: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 11px; }
.job-item .when { color: var(--ink-mute); text-align: right; font-family: var(--mono); font-size: 11px; }
.log { flex: 1; overflow: auto; padding: 12px 14px; font-family: var(--mono); font-size: 11.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; color: var(--ink-dim); background: var(--log-bg); }
.log-empty { color: var(--ink-mute); margin: 0; }
.log .ln { display: block; }
.log .ln.err { color: var(--red); }
.log .ln.warn { color: var(--amber-2); }
.log .ln b { color: var(--ink); font-weight: 500; }
.log .summary { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line-2); color: var(--ink); }

/* ── Dialogs ─────────────────────────────────────────────────────────────── */
.dialog { border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel); color: var(--ink); padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(20, 15, 5, 0.45); backdrop-filter: blur(2px); }
.dialog form, .dialog .scene-body { padding: 22px 24px; display: grid; gap: 12px; }
.dialog-head h2 { margin: 0; font-size: 20px; }
.dialog-head p { margin: 4px 0 0; color: var(--ink-dim); }
.dialog label { display: grid; gap: 4px; font-size: 12px; color: var(--ink-dim); font-family: var(--mono); }
.dialog label input, .dialog label select, .dialog label textarea { font-family: var(--sans); font-size: 14px; }
.dialog label.toggle { display: flex; flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-family: var(--sans); font-size: 13px; }
.draft-box { display: grid; gap: 8px; padding: 12px; border: 1px dashed var(--line-2); border-radius: 8px; background: var(--amber-soft); }
.draft-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.draft-hint { font-size: 12px; color: var(--ink-dim); flex: 1 1 200px; }
.draft-buttons { display: flex; align-items: center; gap: 8px; }
.dialog label.inline-select { display: flex; align-items: center; gap: 6px; }
.dialog label.inline-select select { font-size: 13px; padding: 4px 6px; }

/* New idea dialog: "One video" vs "Series" */
.dialog-title-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.dialog-title-row .seg-ctl button { padding: 4px 10px; }
.idea-form:not([data-mode="series"]) .series-only { display: none; }
.idea-form[data-mode="series"] .single-only { display: none; }
.single-fields { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 12px; }
#series-panel:empty { display: none; }
#series-panel { display: grid; gap: 10px; }
.series-head { display: grid; gap: 6px; }
.series-title { display: flex; align-items: baseline; gap: 8px; font-size: 16px; }
.series-key { font-family: var(--mono); font-size: 11px; color: var(--ink-mute); }
.series-reason { margin: 0; font-size: 13px; color: var(--ink-dim); }
.cast-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cast-chip { font-size: 12px; padding: 2px 8px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--ink-dim); cursor: help; }
.episode-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.episode { display: grid; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.episode.off { opacity: 0.45; }
.episode-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.episode-top label.toggle { white-space: nowrap; }
.episode-id { width: 9em; font-family: var(--mono); font-size: 12px; }
.episode input, .episode textarea { font-family: var(--sans); font-size: 14px; }
.episode-meta { margin: 0; font-size: 12px; color: var(--ink-mute); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.edit-dialog { width: min(760px, calc(100vw - 32px)); }
.edit-field textarea { font-size: 13px; line-height: 1.5; }
.edit-hint { color: var(--ink-mute); font-family: var(--sans); font-size: 11px; }
.req { color: var(--amber); }
.more summary { cursor: pointer; font-family: var(--mono); font-size: 12px; color: var(--ink-dim); margin-bottom: 8px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.scene-dialog { width: min(1040px, calc(100vw - 32px)); }
.scene-body { grid-template-columns: 300px minmax(0, 1fr); gap: 22px; }
.scene-media { aspect-ratio: 9 / 16; background: #000; border-radius: 8px; overflow: hidden; border: 1px solid var(--line-2); display: grid; place-content: center; }
.scene-media img, .scene-media video { width: 100%; height: 100%; object-fit: contain; display: block; outline: none; }
.scene-media .ph { color: var(--ink-mute); font-family: var(--mono); font-size: 12px; text-align: center; padding: 20px; }
.scene-info { display: grid; gap: 12px; align-content: start; }
.scene-info h2 { margin: 0; font-size: 20px; line-height: 1.3; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13px; margin: 0; }
.kv dt { font-family: var(--mono); font-size: 11px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: 0.08em; padding-top: 2px; }
.kv dd { margin: 0; color: var(--ink-dim); }
.kv dd.prompt { font-size: 12.5px; line-height: 1.55; }
.kv dd .mono { color: var(--ink); font-size: 12px; }
.scene-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* ── Toasts ──────────────────────────────────────────────────────────────── */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 1000; }
.toast { background: var(--panel); border: 1px solid var(--line-2); border-left: 3px solid var(--amber); padding: 10px 14px; border-radius: 6px; font-size: 13px; box-shadow: var(--shadow); animation: reveal 0.25s ease-out; max-width: min(520px, calc(100vw - 32px)); }
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--teal); }

/* ── Motion preference ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .scene { opacity: 1; transform: none; }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  body { overflow: auto; }
  .shell, body.jobs-open .shell { grid-template-columns: 1fr; height: auto; }
  .index { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .jobs { border-left: 0; border-top: 1px solid var(--line); min-height: 320px; display: none; }
  body.jobs-open .jobs { display: flex; }
  .job-list { max-height: 160px; }
  .stage { padding: 20px 16px 40px; }
  .strip { grid-template-columns: repeat(2, 1fr); }
  .story-head { grid-template-columns: 1fr; }
  .head-actions { align-items: flex-start; }
  .narr-row { grid-template-columns: 60px 1fr; }
  .narr-row .zh { grid-column: 2; }
  .scene-body, .char-body { grid-template-columns: 1fr; }
  .scene-row { grid-template-columns: 72px minmax(0, 1fr); }
  .scene-row .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .scene-row .kv dd { margin-bottom: 6px; }
  .scene-media { max-width: 320px; margin: 0 auto; }
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { padding: 8px 12px; height: auto; min-height: var(--topbar); flex-wrap: wrap; }
  .topbar-actions { flex-wrap: wrap; }
  .brand-name { white-space: nowrap; }
  .brand-sub { display: none; }
}
@media (max-width: 480px) {
  .strip { grid-template-columns: 1fr; }
}
