:root {
  /* Deep indigo-black rather than flat grey-black — a header/text color
     with some hue to it, not a generic charcoal. */
  --ink: #1f1a2e;
  /* Deep teal-black for the topbar specifically — paired with the warm
     paper body and the brick-red/ochre accents below, this is the
     classic teal-orange film-grade combination, not a generic dark header. */
  --topbar-bg: #12302c;
  --topbar-badge-bg: #1d4642;
  --topbar-badge-fg: #cfe8e0;
  /* Warm-paper family, layered by lightness so the page reads with depth
     instead of one flat off-white everywhere: sand (page) < sheet
     (storyboard) < card (content surfaces), lightest on top. */
  --sand: #f1e7d0;
  --paper: #f9f2e3;
  --card-bg: #fffcf6;
  --line: #ddd0b5;
  --muted: #8a7a63;
  /* Two-color accent system, pulled from film/darkroom rather than a
     single generic "brand blue": a vivid brick-red for CTAs and key
     actions, a deep ochre-gold for secondary/"done" accents. */
  --accent: #cc3a1f;
  --accent-hover: #a82d17;
  --accent-2: #8f6018;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  background: var(--sand);
  color: var(--ink);
}

.topbar {
  background: var(--topbar-bg);
  color: #fff;
}
/* Padding lives on -inner (not .topbar) so its content edge lines up exactly
   with .wizard's content edge below — both are a max-width:1200px box with
   its own 24px horizontal padding, centered the same way. */
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px 24px;
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.topbar h1 {
  font-size: 24px;
  letter-spacing: 0.01em;
  margin: 0;
}
.badge {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 10px;
  background: var(--topbar-badge-bg);
  color: var(--topbar-badge-fg);
}
.badge.live { background: #234d20; color: #b7f0ae; }
.badge.mock { background: #4d3a20; color: #f0d8ae; }

.wizard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.steps {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.step-btn {
  border: 1px solid var(--line);
  background: var(--card-bg);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
}
.step-btn.active { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.step-btn.done { color: var(--accent-2); }
.step-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.hidden { display: none; }

h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 28px 0 10px;
}
h2:first-child { margin-top: 0; }

.hint { color: var(--muted); font-size: 13px; }

textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  resize: vertical;
}

input[type="url"], input[type="text"] {
  flex: 1;
  font-family: inherit;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }

.file-label {
  border: 1px dashed var(--line);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  background: var(--card-bg);
}
.file-label:hover { border-color: var(--ink); }

.actions { margin-top: 18px; display: flex; gap: 10px; }

button.primary, button.secondary {
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--ink);
}
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.secondary { background: var(--card-bg); color: var(--ink); }
button.secondary:hover { background: var(--line); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.error { color: var(--accent); font-size: 13px; margin-top: 10px; min-height: 1em; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  font-size: 14px;
  line-height: 1.5;
}
.card dl { margin: 0; }
.card dt { font-weight: 600; color: var(--muted); margin-top: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.card dt:first-child { margin-top: 0; }
.card dd { margin: 2px 0 0; }

.territory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.territory-card {
  background: var(--card-bg);
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
  font-size: 13px;
}
.territory-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.territory-card h3 { margin: 0 0 8px; font-size: 14px; }
.territory-card .recommended-tag {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  background: var(--accent);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 8px;
}
.territory-card dt { font-weight: 600; color: var(--muted); margin-top: 6px; font-size: 11px; }
.territory-card dd { margin: 1px 0 0; }

/* --- Script --- */
.shot-row {
  display: grid;
  grid-template-columns: 90px 100px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.shot-row:last-child { border-bottom: none; }
.shot-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.shot-beat { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--accent); font-weight: 600; }
.shot-video { font-size: 14px; }
.shot-audio { font-size: 12px; color: var(--muted); margin-top: 4px; }
.shot-audio b { color: var(--ink); }

/* --- Storyboard sheet (mimics the printed template) --- */
.storyboard-sheet {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}
.sheet-header {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 12px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 10px;
  margin-bottom: 20px;
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
}
.sheet-header span.value { font-weight: 400; text-transform: none; color: var(--muted); margin-left: 4px; }

.frame-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
}
.frame-cell { font-size: 12px; }
.frame-cell-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 4px;
}
.frame-box {
  border: 2px solid var(--ink);
  aspect-ratio: 16 / 9;
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.frame-box img { width: 100%; height: 100%; object-fit: contain; }
.frame-box .placeholder {
  color: var(--line);
  font-size: 11px;
  text-align: center;
  padding: 8px;
}
.frame-render-btn {
  position: absolute;
  bottom: 6px;
  right: 6px;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--ink);
  background: var(--card-bg);
  cursor: pointer;
}
.frame-audio {
  border-top: 1px solid var(--ink);
  margin-top: 6px;
  padding-top: 4px;
  min-height: 3em;
  font-size: 11px;
  color: var(--muted);
}
.frame-details {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}
.frame-details b { color: var(--ink); }
.frame-details summary { cursor: pointer; color: var(--ink); font-size: 11px; }

/* --- Review --- */
.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.score-tile {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  text-align: center;
}
.score-tile .num { font-size: 22px; font-weight: 700; }
.score-tile .num.low { color: var(--accent); }
.score-tile .label { font-size: 11px; color: var(--muted); text-transform: uppercase; }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
