/* Dark is the default palette (also applied when JS sets data-theme="dark" or
   when JS is unavailable). Light overrides live in [data-theme="light"]. */
:root, [data-theme="dark"] {
  --bg: #0f1115; --panel: #181b22; --panel2: #1f2530; --line: #2a313d;
  --text: #e6e9ef; --muted: #8b95a7; --accent: #5b8cff; --accent2: #2dd4a7;
  --warn: #f4b740; --danger: #ff6b6b;
  --code-bg: #0b0d11; --code-text: #d6deeb; --mermaid-bg: #0e1219;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f4f6fb; --panel: #ffffff; --panel2: #eef1f7; --line: #d8dee9;
  --text: #1c2230; --muted: #5c6678; --accent: #3b6cf6; --accent2: #12a67f;
  --warn: #b7791f; --danger: #d64545;
  --code-bg: #f4f6fb; --code-text: #1c2230; --mermaid-bg: #ffffff;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); font-size: 13px; }

.topbar { display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; font-size: 16px; }
.topbar nav { display: flex; gap: 18px; align-items: center; }
.inline { display: inline; margin: 0; }
button.link { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 14px; }

/* Theme toggle (system / light / dark) */
.theme-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px;
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 7px; cursor: pointer; font-size: 13px; line-height: 1; }
.theme-toggle:hover { border-color: var(--accent); filter: none; }
.theme-toggle .ico { font-size: 14px; }
.theme-toggle .lbl { color: var(--muted); }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px; margin-bottom: 18px; }
h1, h2, h3 { margin: 0 0 12px; }

input, textarea, select, button { font: inherit; color: var(--text);
  background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; }
textarea { width: 100%; resize: vertical; }
button { background: var(--accent); border-color: var(--accent); color: #fff; cursor: pointer; }
button:hover { filter: brightness(1.08); }
button.secondary { background: var(--panel2); color: var(--text); border-color: var(--line); }
button.danger { background: var(--danger); border-color: var(--danger); }

.row { display: flex; gap: 12px; align-items: end; margin: 10px 0; flex-wrap: wrap; }
.row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.row .grow { flex: 1; }
.row input { min-width: 80px; }

.centered { display: grid; place-items: center; min-height: 100vh; }
.login { width: 320px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login input, .login button { width: 100%; }

/* Deploy overrides table */
.overrides { margin: 12px 0; }
.phase-table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.phase-table th, .phase-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.phase-table select { width: 100%; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); }
.badge.override { background: #2a3550; color: var(--accent); border-color: var(--accent); }

/* Board */
.board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-height: 200px; }
.col h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cards { display: flex; flex-direction: column; gap: 8px; }
.jobcard { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; cursor: pointer; position: relative; }
.jobcard:hover { border-color: var(--accent); }
.jobcard .t { font-weight: 600; font-size: 13px; padding-right: 18px; }
.jobcard .s { font-size: 11px; color: var(--muted); }
.discard-btn { position: absolute; top: 6px; right: 6px; width: 20px; height: 20px;
  padding: 0; line-height: 18px; text-align: center; border-radius: 5px; font-size: 12px;
  background: transparent; color: var(--muted); border: 1px solid transparent;
  cursor: pointer; opacity: 0; transition: opacity .12s; }
.jobcard:hover .discard-btn { opacity: 1; }
.discard-btn:hover { color: #fff; background: var(--danger); border-color: var(--danger); }
.job-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* In-progress card: gentle pulsing glow to signal active work. */
.jobcard.active { border-color: rgba(45, 212, 167, 0.55); animation: card-pulse 1.8s ease-in-out infinite; }
/* Review-pending card: persistent amber highlight to draw the eye. */
.jobcard.review-pending {
  border-color: var(--warn);
  background: linear-gradient(180deg, rgba(244, 183, 64, 0.10), rgba(244, 183, 64, 0.03));
  box-shadow: 0 0 0 1px rgba(244, 183, 64, 0.35), 0 0 14px rgba(244, 183, 64, 0.18);
  animation: review-glow 2s ease-in-out infinite;
}
@keyframes card-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(45, 212, 167, 0.0); }
  35%      { box-shadow: 0 0 0 3px rgba(45, 212, 167, 0.28); }
  60%      { box-shadow: 0 0 0 6px rgba(45, 212, 167, 0.0); }
}
@keyframes review-glow {
  0%, 100% { box-shadow: 0 0 0 1px rgba(244, 183, 64, 0.30), 0 0 10px rgba(244, 183, 64, 0.12); }
  50%      { box-shadow: 0 0 0 1px rgba(244, 183, 64, 0.55), 0 0 18px rgba(244, 183, 64, 0.30); }
}
@media (prefers-reduced-motion: reduce) {
  .jobcard.active, .jobcard.review-pending { animation: none; }
}

/* Job detail page: in-progress card glow + pulsing live dot in the meta line. */
#job-detail.active {
  border-color: rgba(45, 212, 167, 0.55);
  animation: card-pulse 1.8s ease-in-out infinite;
}
.live-dot {
  display: inline-block; width: 8px; height: 8px; margin: 0 6px -1px 0;
  border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 rgba(45, 212, 167, 0.5);
  animation: dot-pulse 1.4s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(45, 212, 167, 0.5); opacity: 1; }
  50%      { box-shadow: 0 0 0 5px rgba(45, 212, 167, 0); opacity: 0.6; }
}
@media (prefers-reduced-motion: reduce) {
  #job-detail.active { animation: none; }
  .live-dot { animation: none; }
}
.pill { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; }
.pill.review { background: #3a3115; color: var(--warn); }
.pill.run { background: #15303a; color: var(--accent2); }

/* Ops page status pills */
.pill.online { background: #15321f; color: #4ade80; }
.pill.stale { background: #3a3115; color: var(--warn); }
.pill.offline { background: #3a1f1f; color: #f87171; }
.pill.pending, .pill.queued { background: #1f2937; color: var(--muted); }
.pill.leased, .pill.running { background: #15303a; color: var(--accent2); }
.pill.failed, .pill.changes_requested { background: #3a1f1f; color: #f87171; }
.ops-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ops-controls { display: flex; align-items: center; gap: 16px; }

/* Toggle switch (checkbox styled as a sliding switch). */
.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 12px;
  color: var(--muted); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { position: relative; width: 32px; height: 18px; border-radius: 9px;
  background: var(--line); transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%; background: #cbd5e1; transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); background: #fff; }
.switch input:focus-visible + .track { box-shadow: 0 0 0 2px rgba(45, 212, 167, 0.5); }

/* History (archived-short) rows are dimmed to set them apart from live work. */
tr.archived { opacity: 0.55; }
tr.archived:hover { opacity: 1; }

/* Heartbeat animation for the in-progress "running" status. */
.pill.running {
  position: relative;
  animation: pill-heartbeat 1.4s ease-in-out infinite;
}
.pill.running::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--accent2);
  vertical-align: middle;
  animation: dot-pulse 1.4s ease-in-out infinite;
}
@keyframes pill-heartbeat {
  0%, 100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.0); }
  20%      { box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.35); }
  40%      { box-shadow: 0 0 0 5px rgba(56, 189, 248, 0.0); }
}
@keyframes dot-pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.7; }
  25%      { transform: scale(1.35); opacity: 1; }
  45%      { transform: scale(0.95); opacity: 0.85; }
}
@media (prefers-reduced-motion: reduce) {
  .pill.running, .pill.running::before { animation: none; }
}

/* Per-checkpoint progress line + queue meta */
.prog { font-size: 11px; margin-top: 2px; }

/* Ops queue action button: keep cancel explicit and easy to spot. */
.danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
  padding: 4px 10px;
  font-size: 12px;
}
.danger-outline:hover { background: rgba(255, 107, 107, 0.14); }

/* Live auto-refresh indicator */
.live-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
}
.live-dot.on { background: #4ade80; animation: dot-pulse 1.8s ease-in-out infinite; }
.live-dot.off { background: #f87171; animation: none; }

/* Models page */
.models-table, .phase-table { width: 100%; border-collapse: collapse; }
.models-table th, .models-table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 10px; }
.grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.grid .chk { flex-direction: row; align-items: center; gap: 6px; }
.grid button { grid-column: 1 / -1; }
.add-model { margin-top: 14px; }

/* Review */
.review-block { margin-top: 16px; }
.review-block textarea { min-height: 220px; font-family: ui-monospace, monospace; }
/* Deck preview: decks are authored on a fixed logical canvas whose short side is
   1080 — 9:16 Short → 1080x1920, 16:9 full video → 1920x1080. We can't rely on the
   deck scaling itself (different generations produce different CSS; some don't
   self-scale at all). So the preview owns the scaling: pin the iframe to the exact
   deck canvas (--deck-w × --deck-h, set inline by deckReview() from job.pixel_ratio),
   then transform-scale the whole iframe down to fit. The wrapper is sized to the
   scaled dimensions and clips the overflow. Defaults keep the 9:16 Short unchanged. */
.deck-stage {
  --deck-w: 1080px;
  --deck-h: 1920px;
  --deck-scale: 0.32; /* 1080 * 0.32 = 345.6px wide preview */
  width: calc(var(--deck-w) * var(--deck-scale));
  height: calc(var(--deck-h) * var(--deck-scale));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #000;
}
.deck-stage .deck-frame {
  width: var(--deck-w);
  height: var(--deck-h);
  border: 0;
  display: block;
  transform: scale(var(--deck-scale));
  transform-origin: top left;
}
.open-full { font-size: 12px; font-weight: 400; margin-left: 8px; }
video { max-width: 360px; border-radius: 10px; }
.actions { display: flex; gap: 10px; margin-top: 10px; align-items: center; }
.target-phase-wrap { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; margin-left: 4px; }
.target-phase-wrap select { width: auto; padding: 4px 8px; }

/* Deck review: one block per scene. Each shows the deck (auto-advanced to the
   scene's first slide) beside that scene's narration, with per-scene stepping and
   a per-scene change-request box. The deck preview is scaled by JS to fill its
   column, so it gets the maximum available width. */
.deck-scenes { display: flex; flex-direction: column; gap: 22px; margin: 14px 0; }
.deck-scene-block { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--panel, #fff); }
.deck-scene-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; cursor: pointer; user-select: none; }
.deck-scene-head b { font-size: 15px; }
.deck-scene-head .scene-count { font-size: 12px; font-variant-numeric: tabular-nums; }
.deck-scene-head .scene-collapse-toggle { font-size: 12px; color: var(--muted, #888); transition: transform .15s ease; align-self: center; }
.deck-scene-block.collapsed .deck-scene-head { margin-bottom: 0; }
.deck-scene-block.collapsed .scene-collapse-toggle { transform: rotate(-90deg); }
.deck-scene-block.collapsed .deck-scene-body,
.deck-scene-block.collapsed .scene-section { display: none; }
.deck-scene-body { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.deck-scenes.landscape .deck-col { flex: 1 1 640px; min-width: 320px; }
.deck-scenes.landscape .narration-col { flex: 1 1 260px; min-width: 240px; }
.deck-scenes.portrait .deck-col { flex: 1 1 360px; min-width: 260px; max-width: 420px; }
.deck-scenes.portrait .narration-col { flex: 2 1 320px; min-width: 260px; }
.deck-col { min-width: 0; }
.deck-nav { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.deck-nav button { width: auto; padding: 7px 16px; }
.narration-col h4 { margin: 0 0 8px; }
.scene-narration {
  border: 1px solid var(--line); border-radius: 10px; padding: 6px;
  background: var(--panel, #fff); max-height: 320px; overflow-y: auto;
}
.narr-line { display: flex; gap: 8px; padding: 6px 8px; border-radius: 8px; font-size: 14px; line-height: 1.45; }
.narr-line + .narr-line { margin-top: 2px; }
.narr-line.active { background: rgba(255, 176, 32, 0.16); }
.narr-step { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); min-width: 20px; text-align: right; }
.narr-text { flex: 1; }
.scene-note { width: 100%; font-size: 13px; margin-top: 10px; }
.scene-edit-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.scene-edit-actions .approve-right { margin-left: auto; }
.scene-edit-btn { font-size: 13px; padding: 5px 10px; }
.scene-edit-status { font-size: 12px; }
.scene-edit-status.err { color: var(--danger, #c0392b); }
.sp-edit-btn { font-size: 13px; padding: 5px 10px; }
.sp-edit-status { font-size: 12px; }
.sp-edit-status.err { color: var(--danger, #c0392b); }
.deck-final-head { margin: 16px 0 4px; }

/* Screenplay-review scene block: stacked Voiceover / Direction / Deck sections. */
.sp-scene-body { display: flex; flex-direction: column; gap: 12px; }
.scene-section h4 { margin: 0 0 6px; }
.scene-direction {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  background: var(--panel, #fff); font-size: 14px; line-height: 1.45;
}
.scene-visual { margin-bottom: 6px; }
.scene-beats { margin: 0; padding-left: 18px; }
.scene-beats li { margin: 2px 0; padding: 2px 6px; border-radius: 6px; }
.scene-beats li.active { background: rgba(255, 176, 32, 0.16); }
.scene-direction-full { margin-top: 12px; }
.beat-reveal {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-variant-numeric: tabular-nums;
}
.deck-placeholder {
  border: 1px dashed var(--line); border-radius: 10px; padding: 14px;
  text-align: center; font-size: 13px;
}

.script-tools { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.discuss-opt { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 14px; }
.discuss-opt input { width: auto; }
.mascot-opt { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 12px 0; font-size: 14px; }
.mascot-opt input { width: auto; }
.mascot-opt .muted { flex: 1 1 100%; font-size: 12px; margin-left: 24px; }
.phase-config { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }

/* Final-review render variants (mascot/voice takes) */
.variant-list { display: flex; flex-direction: column; gap: 14px; margin: 12px 0; }
.variant-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--panel2); }
.variant-card[data-state="running"], .variant-card[data-state="queued"] { border-style: dashed; }
.variant-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.variant-card video { width: 100%; max-width: 420px; border-radius: 8px; display: block; }
.variant-badge.sel { color: #2e7d32; font-weight: 600; font-size: 12px; }
.variant-state { font-size: 12px; }
.variant-state.err { color: var(--danger, #c0392b); }
.variant-actions { margin-top: 10px; }
.variant-placeholder { padding: 24px; text-align: center; border: 1px dashed var(--line); border-radius: 8px; }
.rebuild-box { margin: 18px 0; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.rebuild-box h4 { margin: 0 0 10px; }
.rebuild-controls { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.rebuild-controls label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.rebuild-controls select { min-width: 160px; }
.rebuild-box textarea.comment { margin-top: 10px; min-height: 60px; }
details.send-back { margin-top: 16px; }
details.send-back summary { cursor: pointer; color: var(--muted, #888); font-size: 13px; }

/* Artifacts browser (job detail): always-available script / deck / video list */
.artifacts-section { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 16px; }
.artifacts-section > h3 { margin: 0 0 10px; }
details.artifact { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; background: var(--panel2); }
details.artifact > summary { cursor: pointer; padding: 10px 12px; font-weight: 600; list-style: none; }
details.artifact > summary::-webkit-details-marker { display: none; }
details.artifact > summary::before { content: "▸"; display: inline-block; margin-right: 8px; color: var(--muted); transition: transform .15s; }
details.artifact[open] > summary::before { transform: rotate(90deg); }
.artifact-body { padding: 4px 12px 12px; }
.artifact-body textarea { width: 100%; min-height: 220px; font-family: ui-monospace, monospace; }

/* Accounts page */
.acct { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 10px 0; background: var(--panel2); }
.acct-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.acct-meta { font-size: 12px; margin-top: 4px; }
.acct-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.btn { display: inline-block; font-size: 13px; padding: 6px 12px; border-radius: 6px;
  background: var(--accent); color: #fff; border: 0; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn.secondary, button.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.file-btn { background: var(--panel); color: var(--text); border: 1px solid var(--line); }

/* Per-account schedule editor */
.sched-edit { margin-top: 10px; font-size: 13px; }
.sched-edit > summary { cursor: pointer; color: var(--accent); }
.sched-grid { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.sched-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.sched-grid input { width: 130px; }
.slot-editor { margin: 8px 0; }
.slot-editor.full { grid-column: 1 / -1; }
.slot-editor-head { font-size: 12px; margin-bottom: 6px; }
.slot-list { display: flex; flex-direction: column; gap: 8px; }
.slot-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: var(--panel); }
.slot-time { width: 110px; }
.slot-days { display: flex; gap: 8px; flex-wrap: wrap; }
.day-chk { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; }
.slot-del { padding: 2px 8px; }
.slot-add { margin-top: 8px; }
.sched-save { margin-top: 8px; }

/* Workflows page */
.grid .full { grid-column: 1 / -1; }
.wf-fs { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 12px; margin: 12px 0; }
.wf-fs legend { font-size: 12px; font-weight: 600; color: var(--accent); padding: 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.wf-fs .muted { margin: 4px 0 0; }
.ckpt-grid { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.ckpt-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; background: var(--panel); }
.ckpt-row .chk { font-size: 13px; min-width: 120px; }
.ckpt-cutoff { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.ckpt-cutoff input { width: 160px; }
.wf-weekdays { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.wf-actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.wf-runs { margin-top: 8px; font-size: 13px; }
.wf-runs > summary { cursor: pointer; color: var(--accent); }
.wf-runs-body { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.wf-run-row { display: flex; align-items: center; gap: 8px; }
.wf-jobs { margin-top: 8px; font-size: 13px; }
.wf-jobs > summary { cursor: pointer; color: var(--accent); }
.wf-jobs-body { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.wf-job-row { display: flex; align-items: center; gap: 8px; }

/* Publish form upload status */
.upload-status { margin-top: 10px; font-size: 13px; }
.upload-status .pill { margin-left: 6px; }
.upload-status.failed { color: var(--danger); }

/* OAuth connect result banner (Accounts page) */
.oauth-banner { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; font-size: 14px; border: 1px solid var(--line); }
.oauth-banner.ok { background: rgba(45, 212, 167, 0.10); border-color: rgba(45, 212, 167, 0.45); color: var(--accent2); }
.oauth-banner.err { background: rgba(248, 113, 113, 0.10); border-color: rgba(248, 113, 113, 0.45); color: #f87171; }

/* ── Series planning page ──────────────────────────────────────────────── */
[hidden] { display: none !important; }  /* `display:flex` rules below must not override the hidden attribute */
.plan-start textarea { width: 100%; margin-bottom: 8px; }
.chat-panel { display: flex; flex-direction: column; gap: 10px; }
.chat-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.chat-head h3 { margin: 0 0 2px; font-size: 15px; }
.chat-actions { display: flex; gap: 8px; align-items: center; }
.transcript {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 420px; overflow-y: auto; padding: 10px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.bubble {
  max-width: 80%; padding: 8px 12px; border-radius: 10px; font-size: 14px;
  white-space: pre-wrap; word-wrap: break-word; line-height: 1.45;
}
.bubble.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 3px; }
.bubble.assistant { align-self: flex-start; background: var(--panel2); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.bubble.error { align-self: flex-start; background: #3a1f1f; color: #f87171; border: 1px solid #5a2a2a; }
.turn-form { display: flex; gap: 8px; }
.turn-form input { flex: 1; }
.plan-result { border-top: 1px solid var(--line); padding-top: 12px; }
.plan-result h4 { margin: 0 0 6px; }
.plan-shorts { margin: 8px 0 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.plan-short { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.plan-short .n { font-size: 11px; color: var(--accent2); font-weight: 600; margin-right: 8px; }
.plan-short .wt { font-weight: 600; font-size: 14px; }
.plan-short .kp { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.series-cards { display: flex; flex-direction: column; gap: 10px; }
.series-card { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.series-card .st { font-weight: 600; margin-bottom: 4px; }
.series-shorts { margin: 8px 0 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.series-shorts li { display: flex; align-items: center; gap: 8px; }
.autopub { font-size: 12px; color: var(--muted); font-weight: 500; display: inline-flex; align-items: center; gap: 5px; margin-left: 8px; cursor: pointer; }
.autopub input { margin: 0; vertical-align: middle; }

/* ── Docs viewer ───────────────────────────────────────────────────────── */
.docs-wrap { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: start; }
.docs-nav { position: sticky; top: 20px; }
.docs-nav h2 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.docs-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.docs-list a { display: block; padding: 7px 10px; border-radius: 7px; color: var(--text); font-size: 13px; }
.docs-list a:hover { background: var(--panel2); text-decoration: none; }
.docs-list a.active { background: #2a3550; color: var(--accent); }
.docs-group { list-style: none; }
.docs-group + .docs-group { margin-top: 12px; }
.docs-group-h { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 4px 10px; }
.docs-sublist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.docs-body { min-width: 0; }  /* let wide tables / code blocks scroll instead of overflow the grid */

/* Markdown prose (server-rendered docs) */
.prose { line-height: 1.65; }
.prose > :first-child { margin-top: 0; }
.prose h1 { font-size: 26px; margin: 4px 0 16px; }
.prose h2 { font-size: 20px; margin: 30px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.prose h3 { font-size: 16px; margin: 22px 0 8px; }
.prose h4 { font-size: 14px; margin: 18px 0 6px; color: var(--muted); }
.prose p, .prose li { color: var(--text); }
.prose code { background: var(--panel2); border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 5px; font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.prose pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 9px;
  padding: 14px 16px; overflow-x: auto; margin: 14px 0; }
.prose pre code { background: none; border: 0; padding: 0; font-size: 12.5px; color: var(--code-text); }
.prose blockquote { margin: 14px 0; padding: 6px 14px; border-left: 3px solid var(--accent);
  background: var(--panel2); border-radius: 0 8px 8px 0; color: var(--muted); }
.prose table { border-collapse: collapse; width: 100%; margin: 14px 0; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--panel2); }
.prose ul, .prose ol { padding-left: 22px; }
.prose img { max-width: 100%; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 26px 0; }
.prose .mermaid { background: var(--mermaid-bg); border: 1px solid var(--line); border-radius: 9px;
  padding: 14px; margin: 14px 0; text-align: center; overflow-x: auto; }
.prose h1[id], .prose h2[id], .prose h3[id], .prose h4[id] { scroll-margin-top: 16px; }
.prose .raw-md { white-space: pre-wrap; }

@media (max-width: 820px) {
  .docs-wrap { grid-template-columns: 1fr; }
  .docs-nav { position: static; }
}


/* ── Scout tab ─────────────────────────────────────────────────────────────── */
#scout-form input[type="text"] { width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel2); color: var(--text); font-size: 14px; }
#scout-form .row { margin: 10px 0; gap: 18px; }
.scout-result-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.scout-opportunities { display: grid; gap: 12px; }
.opp-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: var(--panel2); }
.opp-head { display: flex; align-items: baseline; gap: 10px; }
.opp-head h4 { margin: 0; font-size: 15px; flex: 1; }
.opp-rank { color: var(--muted); font: 12px ui-monospace, Menlo, monospace; }
.opp-score { font-weight: 600; color: var(--accent); }
.opp-metrics { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { font-size: 11.5px; padding: 2px 8px; border-radius: 20px; border: 1px solid var(--line);
  color: var(--muted); background: var(--panel); }
.chip-rising, .chip-done { color: #1a7f37; border-color: #1a7f3755; }
.chip-declining, .chip-failed { color: #c5352b; border-color: #c5352b55; }
.chip-queued, .chip-running { color: #9a6700; border-color: #9a670055; }
.opp-angle { margin: 8px 0 4px; }
.opp-reasoning { margin: 4px 0; font-size: 13px; }
.opp-sources summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.opp-sources ul { margin: 6px 0 0; padding-left: 20px; }
.opp-actions { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.create-short-btn { display: inline-block; font-size: 13px; font-weight: 600; padding: 6px 12px;
  border-radius: 8px; border: 1px solid var(--accent); color: var(--accent); background: transparent;
  text-decoration: none; cursor: pointer; }
.create-short-btn:hover { background: var(--accent); color: #fff; }
.create-full-btn { border-color: var(--muted); color: var(--muted); }
.create-full-btn:hover { background: var(--muted); color: #fff; }
.scout-history { display: grid; gap: 6px; }
.history-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2);
  color: var(--text); cursor: pointer; }
.history-row:hover { border-color: var(--accent); }
.history-domain { flex: 1; font-weight: 500; }
