/* Tuber — phased workflow layout */

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--canvas);
  font-size: 16px;
  line-height: 1.5;
}

/* ── Top bar ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-6) calc(var(--sp-4) + 4px);
  background: var(--ink);
  color: var(--shell);
  position: sticky;
  top: 0;
  z-index: 50;
}
/* Six-color brand stripe across the bottom of the topbar */
.topbar::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 4px;
  background: var(--brand-stripe);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  font-size: 22px;
  color: var(--shell);
  text-decoration: none;
  cursor: pointer;
}
.topbar .brand:hover .word { opacity: 0.85; }
.topbar .brand .mark { height: 34px; width: auto; display: inline-block; }
.topbar .brand .word { color: var(--shell); }
.topbar .brand .word .accent { color: var(--surf); }
.topbar .brand .tagline {
  font-family: var(--font-body);
  font-style: normal;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  padding-left: var(--sp-3);
  margin-left: var(--sp-2);
  border-left: 1px solid rgba(255,255,255,0.18);
  max-width: 480px;
  line-height: 1.35;
}
@media (max-width: 800px) {
  .topbar .brand .tagline { display: none; }
}
.topbar .actions { display: flex; gap: var(--sp-3); align-items: center; }
.topbar button.icon {
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.32);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 16px;
  line-height: 1;
  color: var(--shell);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.topbar button.icon:hover {
  background: var(--surf);
  border-color: var(--surf);
  color: var(--shell);
}
.topbar .build {
  font-family: var(--font-mono);
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.04em;
}

/* ── Main column ─────────────────────────────────────────────────────── */
.main {
  max-width: 1480px;
  margin: 0 auto;
  padding: var(--sp-6);
}

/* ── Drop zone ───────────────────────────────────────────────────────── */
.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--paper);
  padding: var(--sp-7);
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
  overflow: hidden;
}
.dropzone::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--surf);
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--surf);
  background: rgba(47, 158, 151, 0.04);
}
.dropzone h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  font-size: 38px;
  letter-spacing: -1px;
  margin: 0 0 var(--sp-2) 0;
  color: var(--ink);
}
.dropzone h1 .accent { color: var(--surf); }
.dropzone p { color: var(--muted); margin: 0; max-width: 560px; margin: 0 auto; }
.dropzone input[type=file] { display: none; }
.dropzone .uploading {
  margin-top: var(--sp-4);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--surf);
}
.dropzone .progress {
  width: 100%;
  height: 6px;
  background: var(--muted-bg);
  border-radius: 3px;
  margin-top: var(--sp-3);
  overflow: hidden;
}
.dropzone .progress > .bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--surf), var(--sun));
  transition: width 0.2s;
}
.dropzone-alt {
  text-align: center;
  margin-top: var(--sp-3);
  font-size: 13px;
  color: var(--muted);
}
.dropzone-alt .link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--surf);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.dropzone-alt .link-btn:hover { color: var(--ink); }
.dropzone-alt .link-btn:disabled { opacity: 0.6; cursor: wait; }

/* ── Workspace: thin context bar on top, phase area below ────────────── */
.workspace {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  margin-top: var(--sp-6);
}
.workspace[hidden] { display: none; }

/* ── Context bar (always visible: video + chosen title + transcript) ─── */
.context-bar {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: var(--sp-4);
  padding: var(--sp-3);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  position: sticky;
  top: 76px; /* sits below the sticky topbar */
  z-index: 30;
}
@media (max-width: 800px) {
  .context-bar { grid-template-columns: 1fr; }
}
.ctx-video {
  min-width: 0;
}
.ctx-video video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  display: block;
  background: #000;
}
.ctx-meta {
  margin-top: var(--sp-2);
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}
.ctx-meta .label { font-weight: 600; color: var(--ink); }

.ctx-info {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}
.ctx-title-strip {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--canvas);
  border: 1px solid var(--border);
  border-left: 3px solid var(--surf);
  border-radius: var(--radius-sm);
}
.ctx-title-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
}
.ctx-title-text {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.35;
  color: var(--ink);
  word-wrap: break-word;
  min-width: 0;
}
.ctx-title-text.placeholder {
  font-weight: 400;
  font-style: italic;
  color: var(--muted);
}

/* Tabbed context: chosen description (default) | transcript. Lives below
   the working-title strip and stays visible across all phases. */
.ctx-tabs-wrap {
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
.ctx-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--paper);
}
.ctx-tab {
  appearance: none;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 8px var(--sp-3);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ctx-tab:hover { color: var(--ink); background: var(--muted-bg); }
.ctx-tab.active {
  color: var(--ink);
  background: var(--canvas);
  border-bottom-color: var(--surf);
}
.ctx-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: var(--sp-2);
}
.ctx-panel[hidden] { display: none; }
.ctx-desc-textarea {
  width: 100%;
  min-height: 100px;
  max-height: 220px;
  resize: vertical;
  padding: var(--sp-3);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--muted-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
}
.ctx-desc-textarea:focus { outline: 2px solid var(--surf); outline-offset: 0; border-color: var(--surf); }
.ctx-section-count { color: var(--muted); font-size: 11px; font-family: var(--font-mono); font-weight: 500; letter-spacing: 0.04em; }
.ctx-empty {
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}
.transcript-body {
  margin: 0;
  background: var(--muted-bg);
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.55;
  overflow: auto;
  max-height: 220px;
}
/* Each speaker turn is a single flowing paragraph, with an inline header
   that combines speaker + timestamp. Far more space-efficient than the
   prior one-row-per-utterance layout. */
.transcript-body .seg-group {
  margin: 0 0 var(--sp-3);
  color: var(--ink);
}
.transcript-body .seg-group:last-child { margin-bottom: 0; }
.transcript-body .seg-head {
  display: inline;
  margin-right: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.transcript-body .seg-head .speaker {
  color: var(--ink);
  font-weight: 700;
}
.transcript-body .seg-head .speaker + .ts::before {
  content: ' · ';
  color: var(--muted);
  font-weight: 400;
}
.transcript-body .seg-head .ts {
  color: var(--muted);
  font-weight: 500;
}
.transcript-body .seg-text { display: inline; }

/* ── Phase area ──────────────────────────────────────────────────────── */
.phase-area {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-width: 0;
}

/* Stepper — pill bar of all phases. Wraps onto a second row instead of
   horizontally scrolling when there isn't room for all 9 phases. */
.stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 0 8px;
  border-bottom: 1px solid var(--border);
}
.stepper button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.stepper button:hover { background: var(--muted-bg); color: var(--ink); }
.stepper button.done {
  color: var(--ink);
  background: var(--paper);
  border-color: var(--border);
}
.stepper button.done .step-num {
  background: var(--algae);
  color: white;
}
.stepper button.active {
  color: white;
  background: var(--abyss);
  border-color: var(--abyss);
}
.stepper button.active .step-num { background: var(--sun); color: var(--ink); }
.stepper button.locked {
  color: #bbb;
  cursor: not-allowed;
  background: transparent;
}
.stepper button.locked:hover { background: transparent; color: #bbb; }
.stepper .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted-bg);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

/* Phase body — common scaffolding for each phase */
.phase-body {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-5);
  min-height: 320px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  overflow: hidden;
}
.phase-body::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--surf);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

.phase-head h2 {
  font-family: var(--font-display);
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  font-size: 26px;
  margin: 0 0 var(--sp-1) 0;
  letter-spacing: -0.5px;
}
.phase-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 640px;
}
/* Title-row variant: heading on the left, primary action (Continue) on the
   right. Subhead/topline below spans full width. */
.phase-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.phase-head-row h2 { margin: 0; }

.phase-actions {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  margin-top: auto;
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.phase-actions .spacer { flex: 1; }
.phase-actions .hint {
  color: var(--muted);
  font-size: 12px;
}

/* Functional UI buttons. Body font (Inter) keeps action labels legible —
   the heavy-condensed display italic was getting squashed at small sizes,
   especially white-on-surf. */
.btn {
  padding: 10px 18px;
  font-family: var(--font-body);
  font-style: normal;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 0.06em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { background: var(--muted-bg); }
.btn.primary {
  background: var(--surf);
  color: white;
  border-color: var(--surf);
}
.btn.primary:hover { background: var(--abyss); border-color: var(--abyss); }
.btn.primary:disabled {
  background: var(--muted-bg);
  color: var(--muted);
  border-color: var(--border);
  cursor: not-allowed;
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn.ghost:hover { color: var(--ink); background: var(--muted-bg); }

/* ── "Your chosen X" callout — keeps the upstream pick visible on later phases */
.chosen-context {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--canvas);
  border: 1px solid var(--border);
  border-left: 3px solid var(--surf);
  border-radius: var(--radius-sm);
}
.chosen-context-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
}
.chosen-context-text {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
}

/* ── Choice cards (used by descriptions / titles / thumb-title pickers) */
.choice-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.choice-list--two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}
@media (max-width: 720px) {
  .choice-list--two-col { grid-template-columns: minmax(0, 1fr); }
}
/* Auto-fitting grid — fits as many columns as the viewport allows.
   Used by the thumb-title picker, where there are many short options and
   the eye should be able to scan them all at once. */
.choice-list--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-items: start;
}
.choice-card {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--card-bg, var(--canvas));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  align-items: start;
}
.choice-card:hover { background: var(--muted-bg); }
.choice-card.selected {
  background: var(--paper);
  border-color: var(--surf);
  box-shadow: 0 0 0 2px rgba(47, 158, 151, 0.18);
}
.choice-card .radio {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--paper);
  margin-top: 3px;
  flex-shrink: 0;
}
.choice-card.selected .radio {
  border-color: var(--surf);
  background: radial-gradient(var(--surf) 40%, var(--paper) 45%);
}
.choice-card .body { min-width: 0; }
.choice-card .title,
.choice-card .title-edit {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
  word-wrap: break-word;
}
.choice-card .title-edit {
  width: 100%;
  font-family: inherit;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  outline: none;
}
.choice-card .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 2px;
}
.choice-card .preview {
  margin-top: var(--sp-2);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-low);
  white-space: pre-wrap;
  background: var(--muted-bg);
  border-radius: var(--radius-sm);
  padding: var(--sp-3);
  max-height: 200px;
  overflow: auto;
  font-family: var(--font-body);
}

/* Inline edit-in-place for the chosen card */
.choice-card .edit-area {
  margin-top: var(--sp-3);
}
.choice-card .edit-area textarea,
.choice-card .edit-area input {
  width: 100%;
  font: inherit;
  font-size: 14px;
  line-height: 1.55;
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
  background: var(--paper);
}
.choice-card .edit-area textarea { min-height: 160px; }
.choice-card .edit-area .help {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Title-picker mode groups (phase 3) ────────────────────────────────── */
.title-group + .title-group { margin-top: var(--sp-4); }
.title-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 13px;
  color: var(--ink);
  margin: 0 0 var(--sp-2) 0;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.title-group-head .group-avg {
  font-family: inherit;
  font-style: normal;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}
/* Thumbnail-style picker on the title phase: one-sided vs two-sided. The
   choice routes the background phase (which now runs ahead of foreground)
   onto the right canvas. */
.thumb-layout-pick {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin: var(--sp-3) 0 var(--sp-4);
  padding: var(--sp-2) var(--sp-3);
  background: var(--canvas);
  border: 1px solid var(--border);
  border-left: 3px solid var(--surf);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}
.thumb-layout-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
}
.thumb-layout-options {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.thumb-layout-opt {
  appearance: none;
  background: var(--paper);
  border: none;
  border-right: 1px solid var(--border);
  padding: 6px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.thumb-layout-opt:last-child { border-right: none; }
.thumb-layout-opt:hover { background: var(--muted-bg); }
.thumb-layout-opt.selected {
  background: var(--surf);
  color: white;
}
.thumb-layout-hint {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  flex: 1;
  min-width: 0;
}

/* One-line server rationale on the picker head, sits under the explainer */
.rank-topline {
  margin-top: 4px;
  color: var(--ink-low);
  font-size: 13px;
  line-height: 1.45;
  font-style: italic;
  max-width: none;
}
/* Per-card score + rationale */
.choice-card .title-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
}
.choice-card .title-row .title,
.choice-card .title-row .title-edit {
  flex: 1 1 auto;
  min-width: 0;
}
.choice-card .rationale {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  font-style: italic;
}
.choice-card .rationale-score {
  font-style: normal;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  cursor: help;
}
.choice-card.selected .rationale-score { color: var(--surf); }

/* ── Description-picker tabs (phase 2) ─────────────────────────────────── */
.desc-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.desc-tab {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  flex: 1 1 220px;
  min-width: 0;
  max-width: 360px;
  text-align: left;
  padding: var(--sp-3);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.desc-tab:hover { background: var(--muted-bg); }
.desc-tab.selected {
  background: var(--paper);
  border-color: var(--surf);
  box-shadow: 0 0 0 2px rgba(47, 158, 151, 0.18);
}
.desc-tab-letter {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  font-size: 16px;
  line-height: 1;
  color: var(--surf);
  flex-shrink: 0;
  padding-top: 1px;
}
.desc-tab-summary {
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
}
.desc-edit textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  line-height: 1.55;
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
  background: var(--paper);
  overflow: hidden;
  min-height: 160px;
}
.desc-edit .help {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* Thumb-title preview — one block per LINE, stacked vertically. Mirrors the
   server SVG composition: heavy condensed italic, hard offset shadow, accent
   block on the highlight line. See Examples/Published.png for the target. */
.tt-preview {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  font-size: 26px;
  letter-spacing: -0.5px;
  text-transform: uppercase;
  line-height: 0.92;
  padding: 4px 6px 8px 2px;
}
.tt-preview .tt-line {
  display: inline-block;
  background: white;
  color: var(--ink);
  padding: 3px 9px 5px;
  box-shadow: 3px 5px 0 rgba(0, 0, 0, 0.20);
  white-space: nowrap;
}
.tt-preview .tt-line.hi { background: var(--sun-bright); }

/* Splash-title picker — each card shows the candidate composited onto the
   user's actual background + foreground (a backdrop fetched once per phase
   entry from /api/compose with text omitted). The overlay uses the same
   brand-block treatment as the server composer; sizes are in cqw so the
   text scales with the card width and the overlay matches what /api/compose
   would bake in for a 1280×720 canvas (LAYOUT.simple.text in brand.js).
   Wider minmax than .choice-list--grid so each thumbnail reads at glance-size. */
.choice-list--thumbs {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--sp-4);
}
.choice-card--thumb .body { display: flex; flex-direction: column; gap: 6px; }
.tt-backdrop-status {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: var(--sp-3);
  font-style: italic;
}
.tt-on-image {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 4px;
  background: #1f1f1f;
  container-type: inline-size;
  margin-top: 2px;
}
.tt-on-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tt-on-image-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
/* Title overlay — positioned to mirror Brand.LAYOUT.simple.text:
   leftMargin=20/1280=1.56cqw, verticalCenterY=360 (50%). Font sizes mirror
   LAYOUT.simple.text.sizes scaled to canvas width. Block padding, line-gap,
   letter-spacing, and drop-shadow all in cqw so the preview reads the same
   regardless of card width. */
.tt-on-image-overlay {
  position: absolute;
  left: 1.56cqw;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.56cqw;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.08cqw;
  line-height: 0.92;
  max-width: 56.25cqw; /* matches server maxWidth=720 → 720/1280 */
}
.tt-on-image-overlay[data-lines="1"] { font-size: 12.5cqw; }
.tt-on-image-overlay[data-lines="2"] { font-size: 10.94cqw; }
.tt-on-image-overlay[data-lines="3"] { font-size: 9.38cqw; }
.tt-on-image-overlay[data-lines="4"] { font-size: 8.2cqw; }
.tt-on-image-overlay .tt-line {
  display: inline-block;
  background: white;
  color: var(--ink);
  padding: 0.47cqw 1.09cqw 0.78cqw;
  box-shadow: 0.39cqw 0.55cqw 0 rgba(0, 0, 0, 0.22);
  white-space: nowrap;
  /* Subtle vertical letter gradient mirrors server TEXT_STYLE.fillTop/Bottom. */
  background-clip: padding-box;
}
.tt-on-image-overlay .tt-line.hi { background: var(--sun-bright); }

/* ── Background-status strip (visible after auto-advance) ────────────── */
.pipeline-status {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 6px var(--sp-4);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
  margin-bottom: var(--sp-2);
}
.pipeline-status[hidden] { display: none; }
.pipeline-status .ps-label {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
  color: var(--ink);
}
.pipeline-status .ps-stages {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}
.pipeline-status .ps-spacer { flex: 1; }
.pipeline-status .ps-help {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}
.pipeline-status .ps-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
}
.pipeline-status .ps-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex: 0 0 auto;
}
.pipeline-status .ps-pill.running .ps-dot {
  background: var(--surf);
  animation: ps-pulse 1.4s infinite;
}
.pipeline-status .ps-pill.done .ps-dot   { background: var(--algae); }
.pipeline-status .ps-pill.failed .ps-dot { background: var(--coral); }
.pipeline-status .ps-pill.pending { color: var(--muted); }
.pipeline-status .ps-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
@keyframes ps-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(47, 158, 151, 0.5); }
  70%  { box-shadow: 0 0 0 6px rgba(47, 158, 151, 0);   }
  100% { box-shadow: 0 0 0 0   rgba(47, 158, 151, 0);   }
}

/* ── Pipeline phase: status feed + step list ─────────────────────────── */
.pipeline-stage {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  align-items: center;
}
.pipeline-stage + .pipeline-stage { margin-top: var(--sp-2); }
.pipeline-stage .marker {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--muted);
}
.pipeline-stage.running .marker {
  border-color: var(--surf);
  border-top-color: transparent;
  animation: tuber-spin 0.9s linear infinite;
}
.pipeline-stage.done .marker {
  background: var(--algae);
  border-color: var(--algae);
  color: white;
}
.pipeline-stage.failed .marker {
  background: var(--coral);
  border-color: var(--coral);
  color: white;
}
.pipeline-stage .label { font-weight: 600; color: var(--ink); font-size: 15px; }
.pipeline-stage .hint { color: var(--muted); font-size: 12px; }
.pipeline-stage .timing {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
@keyframes tuber-spin { to { transform: rotate(360deg); } }

/* ── A/B variants setup phase ────────────────────────────────────────── */
.ax-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--sp-3);
}
.ax-card {
  padding: var(--sp-4);
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.ax-card:hover { background: var(--muted-bg); }
.ax-card.checked {
  border-color: var(--surf);
  background: var(--paper);
  box-shadow: 0 0 0 2px rgba(47, 158, 151, 0.15);
}
.ax-card .ax-head {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: 4px;
}
.ax-card input[type=checkbox] { accent-color: var(--surf); width: 16px; height: 16px; }
.ax-card .ax-title { font-weight: 600; font-size: 15px; }
.ax-card .ax-desc { font-size: 13px; color: var(--muted); }

/* ── Variant building phase: editor + summary ─────────────────────────── */
.variant-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  font-size: 13px;
  color: var(--muted);
}
.variant-summary .chip {
  background: var(--muted-bg);
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--ink);
}
.variant-summary .chip strong {
  font-weight: 600;
  color: var(--muted);
  margin-right: 4px;
}

/* ── Modal (settings, prompts, sessions, youtube upload) ─────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  max-width: 560px;
  width: 90%;
  max-height: 90vh;
  overflow: auto;
}
.modal h3 {
  margin: 0 0 var(--sp-3) 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
}
.modal .field { margin: var(--sp-3) 0; }
.modal label {
  display: block;
  font-size: 13px;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: var(--sp-1);
  color: var(--muted);
}
.modal input, .modal select, .modal textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
}
.modal textarea { min-height: 120px; resize: vertical; }
.modal .row {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
  justify-content: flex-end;
}

/* ── Variant editor (single card from below.js) ──────────────────────── */
/* Wrapper that hosts the per-variant card inside a phase body. */
.variant-editor-host { display: block; }
.variant-editor-host .refine-card { border-top: none; padding: 0; }

/* Waiting state shown when variantA is reached before rankedFrames are ready */
.variant-wait {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-7) var(--sp-4);
  color: var(--muted);
}
.variant-wait-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--surf);
  border-radius: 50%;
  animation: tuber-spin 0.9s linear infinite;
}
.variant-wait-text {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  text-transform: uppercase;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.refine-card { padding: var(--sp-4) 0; }
/* Thumb gets the lion's share of available width so the user can actually
   see what they're editing; meta column stays tight at 260px since it only
   carries the variant badge + chosen title. */
.refine-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: var(--sp-4);
  align-items: flex-start;
}
@media (max-width: 1100px) {
  .refine-head { grid-template-columns: minmax(0, 1fr) 220px; }
}
@media (max-width: 800px) {
  .refine-head { grid-template-columns: 1fr; }
}
.refine-head .thumb-wrap { position: relative; width: 100%; }
.refine-head .thumb-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  background: var(--muted-bg);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.refine-head .thumb-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: var(--muted-bg);
  transition: opacity 120ms ease;
  pointer-events: none;
}
.refine-card.rendering .thumb-preview { opacity: 0.55; }

/* Cutout placement editor — overlays the thumb-stage */
.cut-overlay { position: absolute; inset: 0; pointer-events: none; }
.cut-bbox {
  position: absolute;
  pointer-events: auto;
  cursor: move;
  border: 1.5px dashed rgba(255, 255, 255, 0.9);
  outline: 1px solid rgba(0, 0, 0, 0.55);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.cut-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: white;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  pointer-events: auto;
  z-index: 3;
}
.cut-handle.nw { top: 0;    left: 0;    transform: translate(-50%, -50%); cursor: nwse-resize; }
.cut-handle.ne { top: 0;    right: 0;   transform: translate( 50%, -50%); cursor: nesw-resize; }
.cut-handle.sw { bottom: 0; left: 0;    transform: translate(-50%,  50%); cursor: nesw-resize; }
.cut-handle.se { bottom: 0; right: 0;   transform: translate( 50%,  50%); cursor: nwse-resize; }
.cut-edge {
  position: absolute;
  background: white;
  border: 1px solid var(--ink);
  pointer-events: auto;
  z-index: 3;
}
.cut-edge.top    { left: 50%; width: 22px; height: 4px; transform: translate(-50%, -50%); cursor: ns-resize; }
.cut-edge.bottom { left: 50%; width: 22px; height: 4px; transform: translate(-50%,  50%); cursor: ns-resize; }
.cut-edge.left   { top:  50%; height: 22px; width: 4px; transform: translate(-50%, -50%); cursor: ew-resize; }
.cut-edge.right  { top:  50%; height: 22px; width: 4px; transform: translate( 50%, -50%); cursor: ew-resize; }
.cut-crop {
  position: absolute;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
  z-index: 1;
}

.cut-toolbar { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.cut-toolbar button {
  padding: 4px 8px;
  font: inherit;
  font-size: 11px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.cut-toolbar button:hover { background: var(--muted-bg); }
.cut-toolbar button:disabled { opacity: 0.6; cursor: progress; }
.cut-toolbar button.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
.cut-hint {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

.refine-head .thumb-spinner {
  position: absolute;
  top: 50%; left: 50%;
  width: 28px; height: 28px;
  margin: -14px 0 0 -14px;
  border: 3px solid rgba(255,255,255,0.5);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: refine-spin 0.8s linear infinite;
  pointer-events: none;
}
@keyframes refine-spin { to { transform: rotate(360deg); } }
.refine-head .render-error {
  font-size: 12px;
  color: #b00020;
  background: #fde7ea;
  border: 1px solid #f4c4cb;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin-top: 4px;
}
.refine-head .meta { display: flex; flex-direction: column; gap: var(--sp-2); }
.refine-head .badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 3px;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  font-size: 12px;
  text-transform: uppercase;
  width: fit-content;
}
.refine-head .badge.variant-a { background: var(--sun); color: var(--ink); }
.refine-head .badge.variant-b { background: var(--surf); color: white; }
.refine-head .badge.variant-c { background: var(--algae); color: white; }
.refine-head .meta .title { font-weight: 600; line-height: 1.4; }
.refine-head .meta .actions { display: none; } /* hide per-card pin/edit; phase-actions drives it */

.spec {
  margin-top: var(--sp-4);
  padding: var(--sp-4);
  background: var(--canvas);
  border-radius: var(--radius-sm);
  display: block !important; /* always visible inside a phase */
}
.spec[hidden] { display: block !important; }
.spec .row-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.spec .row-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
}
.spec select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper);
  font: inherit;
  font-size: 14px;
  text-transform: none;
  font-weight: 400;
  color: var(--ink);
}
.src-block {
  background: var(--paper);
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: var(--sp-3);
}
.src-block summary { font-weight: 600; cursor: pointer; padding: 2px 0; }
.scoped-more-btn { margin-top: var(--sp-2); font-size: 13px; }

/* Background-source picker — single column for simple, two columns for two-panel. */
.bg-picker-host.bg-picker-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  align-items: start;
}
.bg-picker-col { min-width: 0; }
.bg-panel-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: var(--sp-2) 0 0;
}
@media (max-width: 720px) {
  .bg-picker-host.bg-picker-cols {
    grid-template-columns: 1fr;
  }
}

/* ── Background tune block (background phase) ────────────────────────── */
.bg-tune-block { padding-top: var(--sp-2); }
.bg-tune-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink);
  margin: 0 0 var(--sp-2) 0;
  text-transform: uppercase;
}
.bg-tune-block hr.bg-section-rule {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--sp-4) 0 var(--sp-3) 0;
}
.bg-tune-block .bg-control-grid {
  display: grid;
  grid-template-columns: 90px 220px 64px 1fr;
  align-items: start;
  column-gap: 12px;
  row-gap: 10px;
  margin-top: var(--sp-2);
}
.bg-tune-block .ctrl-label { display: contents; }
.bg-tune-block .ctrl-label > span:first-child {
  padding-top: 18px;
  font-size: 13px;
  color: var(--ink);
}
.bg-tune-block .slider-wrap {
  position: relative;
  width: 220px;
}
.bg-tune-block .slider-wrap input[type=range] {
  width: 100%;
  display: block;
  accent-color: var(--surf);
}
.bg-tune-block .slider-scale {
  position: relative;
  height: 12px;
  font-size: 10px;
  color: var(--muted);
  line-height: 1;
}
.bg-tune-block .slider-scale-top {
  margin-bottom: 2px;
  font-weight: 600;
  color: var(--ink);
}
.bg-tune-block .slider-scale-bottom { margin-top: 2px; }
.bg-tune-block .slider-scale > span {
  position: absolute;
  top: 0;
  white-space: nowrap;
}
.bg-tune-block .slider-scale .scale-min     { left: 0; }
.bg-tune-block .slider-scale .scale-max     { right: 0; }
.bg-tune-block .slider-scale .scale-default { left: 50%; transform: translateX(-50%); }
.bg-tune-block .slider-num {
  width: 64px;
  margin-top: 14px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  background: var(--paper);
  color: var(--ink);
}
.bg-tune-block .slider-desc {
  font-size: 11px;
  color: var(--muted);
  margin: 0;
  padding: 16px 0 0 4px;
  line-height: 1.4;
}
.bg-tune-block select.bgt-direction {
  margin-top: 14px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--paper);
  font-size: 13px;
  width: 220px;
}
.bg-tune-block .grade-mode-row {
  display: flex;
  gap: 6px;
  margin-bottom: var(--sp-2);
}
.bg-tune-block .grade-mode-btn {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.bg-tune-block .grade-mode-btn:hover { border-color: var(--surf); }
.bg-tune-block .grade-mode-btn.active {
  background: var(--abyss, #0E4A53);
  color: #fff;
  border-color: var(--abyss, #0E4A53);
}
.bg-tune-block .grade-custom-details.hidden { display: none; }
.bg-tune-block .bg-presets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: var(--sp-2) 0;
}
.bg-tune-block .bg-preset-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}
.bg-tune-block .bg-preset-btn:hover { border-color: var(--surf); }
.bg-tune-block .bg-preset-btn.active {
  background: var(--abyss, #0E4A53);
  color: #fff;
  border-color: var(--abyss, #0E4A53);
}
.bg-tune-block .preset-description {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  margin: 0 0 var(--sp-2) 0;
}

/* ── Upscale block (foreground phase) ─────────────────────────────────── */
.upscale-body { padding-top: var(--sp-2); }
.upscale-desc { color: var(--muted); font-size: 13px; margin: 0 0 var(--sp-2) 0; }
.upscale-row {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  flex-wrap: wrap;
}
.upscale-status {
  font-size: 12px;
  color: var(--muted);
}

/* ── A/B axes chips (variants phase) ──────────────────────────────────── */
.ab-axes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.ab-axis {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "cb label"
    ".  desc";
  column-gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.ab-axis input { grid-area: cb; align-self: start; margin-top: 2px; }
.ab-axis-label { grid-area: label; font-weight: 600; font-size: 14px; }
.ab-axis-desc { grid-area: desc; font-size: 12px; color: var(--muted); }
.ab-axis.on { border-color: var(--surf); background: rgba(47,158,151,0.06); }

/* ── Variants grid (combined A/B/C view) ──────────────────────────────── */
.variants-grid {
  display: grid;
  gap: var(--sp-5);
}
.variant-slab {
  border-top: 1px solid var(--border);
  padding-top: var(--sp-3);
}
.variant-slab:first-child { border-top: none; padding-top: 0; }
.variant-slab .refine-card { padding: 0; }
.tabs {
  display: flex;
  gap: var(--sp-1);
  margin: var(--sp-3) 0;
  flex-wrap: wrap;
}
.tabs button {
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--paper);
  border-radius: 999px;
  cursor: pointer;
}
.tabs button.active { background: var(--ink); color: white; border-color: var(--ink); }
.tab-body { min-height: 60px; }
.frame-grid, .bg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: var(--sp-2);
}
.frame-tile {
  position: relative;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--muted-bg);
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  font: inherit;
}
.frame-tile img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.frame-tile span {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.55);
  color: white;
  font-size: 10px;
  padding: 2px 4px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.frame-tile.selected { border-color: var(--surf); box-shadow: 0 0 0 2px rgba(47,158,151,0.18); }

/* Click-to-enlarge — display thumbnails (no other click role) */
.refine-head .thumb-preview { cursor: zoom-in; }

.frame-tile .zoom-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
  opacity: 0.7;
  transition: opacity 120ms ease, background 120ms ease;
  z-index: 2;
  user-select: none;
}
.frame-tile:hover .zoom-btn,
.frame-tile:focus-within .zoom-btn { opacity: 1; }
.frame-tile .zoom-btn:hover { background: rgba(0, 0, 0, 0.8); }

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: var(--sp-5);
  cursor: zoom-out;
}
.lightbox-overlay[hidden] { display: none; }
.lightbox-img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: var(--paper);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
  cursor: default;
}
.lightbox-close {
  position: absolute;
  top: 12px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-size: 24px;
  line-height: 1;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.3); }

/* Status feed (used in pipeline phase + youtube upload modal) */
.status-feed {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  background: var(--muted-bg);
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  max-height: 180px;
  overflow: auto;
}
.status-feed .ok { color: var(--algae); }
.status-feed .err { color: var(--coral); }

/* Upload phase summary block */
.upload-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}
@media (max-width: 800px) {
  .upload-summary { grid-template-columns: 1fr; }
}
.upload-summary .col {
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--sp-4);
}
.upload-summary .col h4 {
  margin: 0 0 var(--sp-2) 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  text-transform: uppercase;
  font-size: 14px;
}
.upload-summary .col img { width: 100%; border-radius: var(--radius-sm); display: block; }
.upload-summary pre {
  white-space: pre-wrap;
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
  background: var(--paper);
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  max-height: 240px;
  overflow: auto;
}
.upload-thumbs-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
}
.upload-thumbs-row .col img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: var(--radius-sm); }
.upload-thumbs-row .col .label {
  margin-top: 4px;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
}

/* ── Backend-restart toast ───────────────────────────────────────────── */
/* Fixed pill that appears whenever any in-flight fetch is retrying. */
.backend-toast {
  position: fixed;
  left: 50%;
  bottom: var(--sp-5);
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--ink);
  color: var(--shell);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
.backend-toast::before {
  content: '';
  display: inline-block;
  width: 10px; height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--surf);
  vertical-align: middle;
  animation: backend-toast-pulse 1.2s ease-in-out infinite;
}
@keyframes backend-toast-pulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}
