/* ============================================================
   BACKLOT — Living Storyboard design system (mockup)
   Dark-room editorial: near-black matte canvas, artifacts glow.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;450;500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Courier+Prime:ital,wght@0,400;0,700;1,400&display=swap');

:root {
  --bg: #0a0a0c;
  --surface: #101013;
  --surface-2: #16161a;
  --surface-3: #1c1c21;
  --border: #232329;
  --border-soft: #1a1a1f;
  --text: #ececef;
  --text-2: #a0a0a9;
  --text-3: #5f5f68;
  --amber: #f0a83c;
  --amber-dim: rgba(240, 168, 60, 0.14);
  --green: #4fc283;
  --green-dim: rgba(79, 194, 131, 0.12);
  --red: #e5544b;
  --red-dim: rgba(229, 84, 75, 0.12);
  --blue: #6aa1ff;
  --cream: #f2e9d5;
  --cream-shade: #e5d9be;
  --cream-ink: #29231a;
  --cream-ink-2: #6b5f4a;
  --sans: 'Inter', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --screenplay: 'Courier Prime', 'Courier New', monospace;

  /* Global type scale. Every font-size is calc(<px> * var(--fs-scale)), so this
     one number scales all text proportionally for readability. 1 = original. */
  --fs-scale: 1.16;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { color-scheme: dark; }
::-webkit-scrollbar { width: 10px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #26262e; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #34343e; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: calc(14px * var(--fs-scale));
  line-height: 1.5;
  min-height: 100vh;
  /* faint vignette so media pops */
  background-image: radial-gradient(1200px 600px at 50% -100px, #111116 0%, var(--bg) 70%);
}

.wrap { max-width: 1440px; margin: 0 auto; padding: 0 28px 80px; }

/* film grain — barely-there, keeps the dark room from feeling flat */
body::after {
  content: ''; position: fixed; inset: -50%; pointer-events: none; z-index: 90;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: .035; animation: grain 1.2s steps(4) infinite;
}
@keyframes grain {
  0%, 100% { transform: translate(0,0); }
  25% { transform: translate(-1.5%, 1%); }
  50% { transform: translate(1%, -1.5%); }
  75% { transform: translate(-1%, -1%); }
}

/* everything enters like a story unfolding */
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.slate { animation: rise .5s cubic-bezier(.2,.7,.3,1) backwards; }
.rail .stage { animation: rise .5s cubic-bezier(.2,.7,.3,1) backwards; }
.rail .stage:nth-child(1) { animation-delay: .06s } .rail .stage:nth-child(2) { animation-delay: .11s }
.rail .stage:nth-child(3) { animation-delay: .16s } .rail .stage:nth-child(4) { animation-delay: .21s }
.rail .stage:nth-child(5) { animation-delay: .26s } .rail .stage:nth-child(6) { animation-delay: .31s }
.rail .stage:nth-child(7) { animation-delay: .36s } .rail .stage:nth-child(8) { animation-delay: .41s }
.script-card, .notice { animation: rise .6s cubic-bezier(.2,.7,.3,1) .25s backwards; }
aside .panel { animation: rise .6s cubic-bezier(.2,.7,.3,1) backwards; }
aside .panel:nth-of-type(1) { animation-delay: .32s } aside .panel:nth-of-type(2) { animation-delay: .42s }
.scene-card { animation: rise .65s cubic-bezier(.2,.7,.3,1) backwards; }
.scene-card:nth-child(1) { animation-delay: .35s } .scene-card:nth-child(2) { animation-delay: .43s }
.scene-card:nth-child(3) { animation-delay: .51s } .scene-card:nth-child(4) { animation-delay: .59s }
.scene-card:nth-child(5) { animation-delay: .67s } .scene-card:nth-child(6) { animation-delay: .75s }
.scene-card:nth-child(7) { animation-delay: .83s } .scene-card:nth-child(8) { animation-delay: .91s }
.scene-card:nth-child(9) { animation-delay: .99s } .scene-card:nth-child(10) { animation-delay: 1.07s }
.scene-card:nth-child(11) { animation-delay: 1.15s } .scene-card:nth-child(12) { animation-delay: 1.23s }
.lib-card { animation: rise .6s cubic-bezier(.2,.7,.3,1) backwards; }
.lib-card:nth-child(1) { animation-delay: .08s } .lib-card:nth-child(2) { animation-delay: .15s }
.lib-card:nth-child(3) { animation-delay: .22s } .lib-card:nth-child(4) { animation-delay: .29s }
.lib-card:nth-child(5) { animation-delay: .36s } .lib-card:nth-child(6) { animation-delay: .43s }
.lib-card:nth-child(7) { animation-delay: .50s } .lib-card:nth-child(8) { animation-delay: .57s }

/* ---------- header slate ---------- */
.slate {
  display: flex; align-items: center; gap: 18px;
  padding: 18px 0 16px;
  border-bottom: 1px solid var(--border-soft);
}
.clapper {
  width: 34px; height: 26px; border-radius: 4px; flex: none;
  background: repeating-linear-gradient(-45deg, #2c2c33 0 6px, #101013 6px 12px);
  border: 1px solid var(--border);
}
.slate h1 {
  font-family: var(--mono); font-size: calc(17px * var(--fs-scale)); font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.slate .wordmark {
  font-family: var(--mono); font-size: calc(11px * var(--fs-scale)); letter-spacing: 0.22em;
  color: var(--text-3); text-transform: uppercase; margin-right: 2px;
}
.chip {
  font-family: var(--mono); font-size: calc(10.5px * var(--fs-scale)); letter-spacing: 0.06em;
  padding: 3px 9px; border-radius: 99px;
  border: 1px solid var(--border); color: var(--text-2);
  white-space: nowrap;
}
.chip.warn { border-color: rgba(240,168,60,.4); color: var(--amber); background: var(--amber-dim); }
.slate .spacer { flex: 1; }

.live {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: calc(11px * var(--fs-scale)); letter-spacing: 0.14em;
  color: var(--amber);
}
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); animation: pulse 1.6s ease-in-out infinite; }
.live.idle { color: var(--text-3); }
.live.idle .dot { background: var(--text-3); animation: none; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240,168,60,.5); opacity: 1; }
  50% { box-shadow: 0 0 0 7px rgba(240,168,60,0); opacity: .75; }
}

.cost { text-align: right; }
.cost .nums { font-family: var(--mono); font-size: calc(13px * var(--fs-scale)); }
.cost .nums b { color: var(--text); font-weight: 600; }
.cost .nums span { color: var(--text-3); }
.cost .bar { width: 150px; height: 3px; background: var(--surface-3); border-radius: 3px; margin-top: 5px; overflow: hidden; }
.cost .bar i { display: block; height: 100%; background: var(--green); border-radius: 3px; }
.cost .bar i.warn { background: var(--amber); }
.cost .label { font-size: calc(10px * var(--fs-scale)); color: var(--text-3); letter-spacing: .08em; text-transform: uppercase; margin-top: 3px; }

/* ---------- stage rail ---------- */
.rail { display: flex; align-items: flex-start; padding: 26px 0 22px; }
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; min-width: 0; }
.stage .node {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(12px * var(--fs-scale)); z-index: 2; position: relative;
  background: var(--surface-2); border: 1.5px solid var(--border);
  color: var(--text-3);
}
.stage .line {
  position: absolute; top: 13px; left: calc(-50% + 13px); right: calc(50% + 13px);
  height: 1.5px; background: var(--border);
}
.stage:first-child .line { display: none; }
.stage .name {
  margin-top: 10px; font-family: var(--mono); font-size: calc(11px * var(--fs-scale));
  letter-spacing: 0.05em; color: var(--text-3);
}
.stage .sub { font-size: calc(10.5px * var(--fs-scale)); color: var(--text-3); margin-top: 3px; text-align: center; max-width: 150px; }

.stage.done .node { background: var(--surface-3); border-color: #3a3a42; color: var(--green); }
.stage.done .line { background: #3a3a42; }
.stage.done .name { color: var(--text-2); }

.stage.active .node {
  border-color: var(--amber); color: var(--amber); background: var(--amber-dim);
  animation: ringpulse 1.8s ease-in-out infinite;
}
.stage.active .line { background: linear-gradient(90deg, #3a3a42, rgba(240,168,60,.55)); overflow: hidden; }
.stage.active .line::after { /* energy traveling toward the live stage */
  content: ''; position: absolute; top: 0; bottom: 0; width: 34px; left: -40px;
  background: linear-gradient(90deg, transparent, rgba(240,168,60,.95), transparent);
  animation: travel 1.7s ease-in-out infinite;
}
@keyframes travel { to { left: calc(100% + 6px); } }
.stage.active .name { color: var(--amber); font-weight: 600; }
.stage.active .sub { color: var(--text-2); }
@keyframes ringpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240,168,60,.45); }
  50% { box-shadow: 0 0 0 9px rgba(240,168,60,0); }
}

.stage.await .node { border-color: var(--amber); color: var(--amber); background: var(--amber-dim); box-shadow: 0 0 18px rgba(240,168,60,.25); }
.stage.await .line { background: linear-gradient(90deg, #3a3a42, var(--amber)); }
.stage.await .name { color: var(--amber); font-weight: 600; }
.stage.await .sub { color: var(--amber); }

.stage.failed .node { border-color: var(--red); color: var(--red); background: var(--red-dim); }
.stage.failed .name { color: var(--red); }

/* ---------- layout ---------- */
.board { display: grid; grid-template-columns: 1fr 320px; gap: 22px; align-items: start; }
.main-col { min-width: 0; }

.panel { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 12px; }
.panel + .panel { margin-top: 18px; }
.panel-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 13px 16px 11px; border-bottom: 1px solid var(--border-soft);
}
.panel-head h2 { font-family: var(--mono); font-size: calc(11px * var(--fs-scale)); font-weight: 600; letter-spacing: 0.18em; color: var(--text-2); text-transform: uppercase; }
.panel-head .meta { font-family: var(--mono); font-size: calc(10.5px * var(--fs-scale)); color: var(--text-3); margin-left: auto; }
.panel-body { padding: 14px 16px; }

/* ---------- screenplay card ---------- */
.script-card {
  background: linear-gradient(178deg, var(--cream) 0%, var(--cream-shade) 130%);
  color: var(--cream-ink);
  border-radius: 6px;
  padding: 34px 44px 26px;
  max-width: 700px;              /* screenplay pages are narrow — paper on a dark desk */
  margin: 0 auto;
  font-family: var(--screenplay);
  box-shadow: 0 18px 50px -18px rgba(0,0,0,.85), 0 1px 0 rgba(255,255,255,.06) inset;
  position: relative;
  cursor: pointer;
}
.script-card::after { /* page edge */
  content: ''; position: absolute; right: 7px; top: 7px; bottom: 7px; width: 1px;
  background: rgba(0,0,0,.07);
}
.script-card .sp-title {
  text-align: center; font-weight: 700; font-size: calc(16px * var(--fs-scale));
  letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 4px;
}
.script-card .sp-meta { text-align: center; font-size: calc(11.5px * var(--fs-scale)); color: var(--cream-ink-2); margin-bottom: 26px; }
.script-card .sp-slug {
  font-weight: 700; font-size: calc(12.5px * var(--fs-scale)); text-transform: uppercase;
  letter-spacing: 0.04em; margin: 18px 0 6px;
}
.script-card .sp-slug .tc { color: var(--cream-ink-2); font-weight: 400; float: right; font-size: calc(11px * var(--fs-scale)); }
.script-card .sp-action { font-size: calc(13px * var(--fs-scale)); line-height: 1.62; }
.script-card .sp-paren { font-size: calc(11.5px * var(--fs-scale)); font-style: italic; color: var(--cream-ink-2); margin: 4px 0 0 42px; }
.script-card .sp-cue {
  display: inline-block; font-family: var(--mono); font-size: calc(9.5px * var(--fs-scale)); font-style: normal;
  background: rgba(0,0,0,.06); border-radius: 3px; padding: 1px 6px; margin: 6px 0 0;
  color: #7d6f52; letter-spacing: .03em;
}
.script-card .sp-fade { text-align: right; font-size: calc(12px * var(--fs-scale)); font-weight: 700; margin-top: 20px; text-transform: uppercase; }
.script-card .sp-expand {
  position: absolute; right: 16px; bottom: 12px;
  font-family: var(--mono); font-size: calc(10px * var(--fs-scale)); color: var(--cream-ink-2); letter-spacing: .06em;
}
.script-approved {
  position: absolute; top: 20px; right: 26px;
  font-family: var(--mono); font-size: calc(10px * var(--fs-scale)); font-weight: 600; letter-spacing: .14em;
  color: #2c7a4b; border: 1.5px solid #2c7a4b; border-radius: 3px;
  padding: 3px 8px; transform: rotate(6deg); opacity: .8;
}

/* ---------- right rail: decisions & activity ---------- */
.decision { padding: 11px 0; border-bottom: 1px solid var(--border-soft); }
.decision:last-child { border-bottom: none; }
.decision .d-head { display: flex; gap: 8px; align-items: baseline; }
.decision .d-cat { font-family: var(--mono); font-size: calc(9.5px * var(--fs-scale)); color: var(--text-3); letter-spacing: .1em; text-transform: uppercase; }
.decision .d-revised { color: var(--amber); }
.decision .d-pick { font-size: calc(12.5px * var(--fs-scale)); font-weight: 600; margin-top: 3px; }
.decision .d-pick .arrow { color: var(--amber); font-weight: 400; }
.decision .d-why { font-size: calc(11.5px * var(--fs-scale)); color: var(--text-2); margin-top: 3px; line-height: 1.45; }
.decision .d-alt { font-size: calc(10.5px * var(--fs-scale)); color: var(--text-3); margin-top: 4px; }
.decision .d-alt s { opacity: .8; }

.act-row { display: flex; align-items: center; gap: 9px; padding: 7px 0; border-bottom: 1px solid var(--border-soft); font-family: var(--mono); font-size: calc(11px * var(--fs-scale)); }
.act-row:last-child { border-bottom: none; }
.act-row .t { color: var(--text-3); font-size: calc(10px * var(--fs-scale)); flex: none; }
.act-row .tool { color: var(--text-2); }
.act-row .target { color: var(--text-3); }
.act-row .status { margin-left: auto; flex: none; font-size: calc(10.5px * var(--fs-scale)); }
.act-row .status.ok { color: var(--green); }
.act-row .status.run { color: var(--amber); animation: blink 1.4s ease-in-out infinite; }
.act-row .status.err { color: var(--red); }
@keyframes blink { 50% { opacity: .45; } }

/* ---------- filmstrip ---------- */
.strip-outer { position: relative; }
.filmstrip {
  display: flex; gap: 12px; overflow-x: auto; padding: 26px 4px;
  /* sprocket holes */
  background:
    radial-gradient(circle 3.5px, #2e2e36 97%, transparent) 0 6px / 26px 10px repeat-x,
    radial-gradient(circle 3.5px, #2e2e36 97%, transparent) 0 calc(100% - 16px) / 26px 10px repeat-x;
}
.filmstrip { scrollbar-width: thin; scrollbar-color: #26262e transparent; }
.scene-card { flex: none; display: flex; flex-direction: column; position: relative; }
.scene-card .sc-slate {
  display: flex; align-items: baseline; gap: 8px;
  font-family: var(--mono); font-size: calc(10px * var(--fs-scale)); letter-spacing: .05em;
  color: var(--text-3); padding: 0 2px 6px;
}
.scene-card .sc-slate .num { color: var(--text-2); font-weight: 600; }
.scene-card .sc-slate .take { color: var(--amber); }
.scene-card .sc-slate .dur { margin-left: auto; }
.scene-card .sc-slate .hero { color: var(--amber); letter-spacing: .1em; }

.thumb {
  border-radius: 7px; overflow: hidden; position: relative;
  aspect-ratio: 16 / 9; background: var(--surface-2);
  border: 1px solid var(--border);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Videos must fill the thumb box exactly — without this the <video> renders at
   its intrinsic size, so the visible frame and the clickable box drift apart
   (clicking the picture did nothing; clicking below it toggled play). */
.thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.approved { cursor: pointer; }
/* bespoke/atelier scene placeholder */
.thumb.spec.bespoke { border-color: rgba(240,168,60,.4); }
.thumb.spec .bespoke-tag {
  font-family: var(--mono); font-size: calc(9px * var(--fs-scale)); letter-spacing: .1em;
  color: var(--amber); margin-bottom: 2px;
}
.thumb .badge {
  position: absolute; left: 7px; bottom: 7px;
  font-family: var(--mono); font-size: calc(9px * var(--fs-scale)); letter-spacing: .06em;
  background: rgba(8,8,10,.72); color: var(--text-2);
  padding: 2px 7px; border-radius: 3px; backdrop-filter: blur(4px);
}
.thumb .play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.85); font-size: calc(26px * var(--fs-scale)); text-shadow: 0 2px 12px rgba(0,0,0,.7);
  opacity: 0; transition: opacity .18s;
}
.thumb:hover .play { opacity: 1; }
.thumb.approved { border-color: rgba(79,194,131,.35); }

/* generating shimmer */
.thumb.generating { border-color: rgba(240,168,60,.45); }
.thumb.generating .shimmer {
  position: absolute; inset: 0;
  background: linear-gradient(100deg, var(--surface-2) 32%, #24242c 48%, var(--surface-2) 64%);
  background-size: 220% 100%;
  animation: shimmer 1.5s linear infinite;
}
@keyframes shimmer { to { background-position: -120% 0; } }
.thumb.generating .gen-label {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; padding: 0 14px; text-align: center;
  font-family: var(--mono); font-size: calc(10px * var(--fs-scale)); color: var(--amber); letter-spacing: .08em;
}
.thumb.generating .gen-label .sub { color: var(--text-3); font-size: calc(9.5px * var(--fs-scale)); letter-spacing: .03em; line-height: 1.5; }

/* pending spec card */
.thumb.spec { border-style: dashed; border-color: #2c2c34; background: transparent; }
.thumb.spec .spec-in {
  position: absolute; inset: 0; padding: 10px 12px;
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
}
.thumb.spec .spec-desc { font-size: calc(10.5px * var(--fs-scale)); color: var(--text-3); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.thumb.spec .spec-shot { font-family: var(--mono); font-size: calc(9px * var(--fs-scale)); color: #4a4a54; letter-spacing: .04em; }

/* missing asset */
.thumb.missing { border-color: rgba(240,168,60,.55); border-style: dashed; background: var(--amber-dim); }
.thumb.missing .spec-in { align-items: center; text-align: center; }
.thumb.missing .warn-ic { color: var(--amber); font-size: calc(15px * var(--fs-scale)); }
.thumb.missing .spec-desc { color: var(--amber); -webkit-line-clamp: 2; }

/* text-card scene (typographic placeholder) */
.thumb.textcard { display: flex; align-items: center; justify-content: center; background: #0d0d10; }
.thumb.textcard .tc-copy {
  font-family: var(--mono); font-weight: 500; text-align: center;
  letter-spacing: .2em; font-size: calc(11px * var(--fs-scale)); color: #d8d8de; padding: 0 10px;
}

.narr {
  padding: 8px 3px 0; font-size: calc(11px * var(--fs-scale)); color: var(--text-2); line-height: 1.45;
  font-style: italic; max-height: 52px; overflow: hidden; position: relative;
}
/* Long narration is clamped with a soft fade + expand glyph; click opens the
   full text in the modal instead of hard-cutting mid-word. */
.narr.clip {
  cursor: pointer;
  -webkit-mask-image: linear-gradient(180deg, #000 62%, transparent);
  mask-image: linear-gradient(180deg, #000 62%, transparent);
}
.narr .narr-more {
  position: absolute; right: 2px; bottom: 2px; font-style: normal;
  color: var(--text-3); font-size: calc(11px * var(--fs-scale));
}
.narr.clip:hover { color: var(--text-1); }
.narr.tc-note { color: var(--text-3); }

.wave { display: flex; align-items: flex-end; gap: 1.5px; height: 14px; padding: 6px 3px 0; }
.wave i { width: 2.5px; background: #3d3d47; border-radius: 1px; }
.wave.played i { background: #565664; }
.wave .wv-time { font-family: var(--mono); font-size: calc(9px * var(--fs-scale)); color: var(--text-3); margin-left: 6px; align-self: center; }

/* takes drawer */
.takes { display: flex; gap: 5px; padding: 8px 2px 0; align-items: center; }
.takes .tk { width: 44px; aspect-ratio: 16/9; border-radius: 3px; overflow: hidden; border: 1px solid var(--border); opacity: .55; position: relative; }
.takes .tk img { width: 100%; height: 100%; object-fit: cover; }
.takes .tk.active { opacity: 1; border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.takes .tk-label { font-family: var(--mono); font-size: calc(9px * var(--fs-scale)); color: var(--text-3); letter-spacing: .05em; }

/* ---------- empty state ---------- */
.empty {
  border: 1.5px dashed #26262e; border-radius: 10px; padding: 40px;
  text-align: center; color: var(--text-3);
}
.empty .big { font-family: var(--mono); font-size: calc(12px * var(--fs-scale)); letter-spacing: .12em; text-transform: uppercase; margin-bottom: 6px; color: #4a4a54; }

/* ---------- review findings ---------- */
.findings { display: flex; gap: 8px; align-items: center; font-family: var(--mono); font-size: calc(10.5px * var(--fs-scale)); }
.findings .f { padding: 2px 8px; border-radius: 99px; border: 1px solid var(--border); color: var(--text-3); }
.findings .f.crit { color: var(--red); border-color: rgba(229,84,75,.35); }
.findings .f.sugg { color: var(--amber); border-color: rgba(240,168,60,.3); }

/* ---------- modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(5,5,7,.82); backdrop-filter: blur(6px);
  display: none; align-items: flex-start; justify-content: center; overflow-y: auto;
  padding: 48px 20px; z-index: 50;
}
.modal-bg.open { display: flex; }
.modal-page { max-width: 640px; width: 100%; }
.modal-close {
  position: fixed; top: 18px; right: 26px; font-family: var(--mono);
  color: var(--text-2); font-size: calc(12px * var(--fs-scale)); cursor: pointer; letter-spacing: .1em;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 6px 14px;
}

/* ---------- library ---------- */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; padding-top: 24px; }
.lib-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 12px; overflow: hidden; transition: border-color .15s, transform .15s; }
.lib-card:hover { border-color: #34343e; transform: translateY(-2px); }
.lib-card.live-card { border-color: rgba(240,168,60,.4); }
.lib-poster { aspect-ratio: 16/9; background: var(--surface-2); position: relative; overflow: hidden; }
.lib-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-poster .lp-live {
  position: absolute; top: 9px; left: 9px; font-family: var(--mono); font-size: calc(9px * var(--fs-scale)); letter-spacing: .12em;
  color: var(--amber); background: rgba(8,8,10,.75); border: 1px solid rgba(240,168,60,.45);
  padding: 3px 8px; border-radius: 99px; display: flex; gap: 5px; align-items: center; backdrop-filter: blur(4px);
}
.lib-poster .lp-live .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--amber); animation: pulse 1.6s infinite; }
.lib-poster .lp-txt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--mono); letter-spacing: .16em; font-size: calc(12px * var(--fs-scale)); color: #3f3f4a; }
.lib-body { padding: 13px 15px 14px; }
.lib-body h3 { font-family: var(--mono); font-size: calc(12.5px * var(--fs-scale)); font-weight: 600; letter-spacing: .05em; }
.lib-body .lb-meta { display: flex; gap: 8px; margin-top: 5px; align-items: center; }
.lib-body .lb-meta .chip { font-size: calc(9.5px * var(--fs-scale)); padding: 2px 7px; }
.lib-body .lb-meta .when { font-size: calc(10.5px * var(--fs-scale)); color: var(--text-3); margin-left: auto; }
.mini-rail { display: flex; gap: 4px; margin-top: 11px; align-items: center; }
.mini-rail i { height: 4px; flex: 1; border-radius: 2px; background: var(--surface-3); }
.mini-rail i.d { background: #3d5c4b; }
.mini-rail i.a { background: var(--amber); animation: blink 1.4s infinite; }
.mini-rail i.w { background: var(--amber); }

/* ---------- misc ---------- */
.notice {
  display: flex; gap: 10px; align-items: center;
  border: 1px solid rgba(240,168,60,.3); background: var(--amber-dim);
  border-radius: 9px; padding: 11px 15px; font-size: calc(12.5px * var(--fs-scale)); color: var(--text-2); margin: 18px 0 4px;
}
.notice b { color: var(--amber); font-weight: 600; }
.section-title {
  font-family: var(--mono); font-size: calc(11px * var(--fs-scale)); font-weight: 600; letter-spacing: .18em;
  text-transform: uppercase; color: var(--text-2); padding: 26px 0 2px;
  display: flex; align-items: baseline; gap: 12px;
}
.section-title .meta { font-size: calc(10.5px * var(--fs-scale)); color: var(--text-3); font-weight: 400; letter-spacing: .05em; margin-left: auto; }
a.backlink { font-family: var(--mono); font-size: calc(10.5px * var(--fs-scale)); color: var(--text-3); text-decoration: none; letter-spacing: .08em; }
a.backlink:hover { color: var(--text-2); }

/* ============================================================
   Live-board additions (beyond the mockup design system)
   ============================================================ */

/* stage nodes are interactive on the real board */
.stage { cursor: pointer; border-radius: 8px; padding: 4px 2px; transition: background .15s; }
.stage:hover { background: rgba(255,255,255,.025); }
.stage.selected .name { text-decoration: underline; text-underline-offset: 4px; }

/* stage drawer */
.drawer {
  border: 1px solid var(--border-soft); background: var(--surface);
  border-radius: 12px; margin: 0 0 20px; overflow: hidden;
  animation: rise .35s cubic-bezier(.2,.7,.3,1);
}
.drawer .drawer-head {
  display: flex; gap: 10px; align-items: baseline;
  padding: 12px 16px; border-bottom: 1px solid var(--border-soft);
}
.drawer .drawer-head h3 { font-family: var(--mono); font-size: calc(12px * var(--fs-scale)); letter-spacing: .14em; text-transform: uppercase; }
.drawer .drawer-head .close { margin-left: auto; cursor: pointer; color: var(--text-3); font-family: var(--mono); font-size: calc(11px * var(--fs-scale)); }
.drawer .drawer-head .close:hover { color: var(--text-2); }
.drawer .drawer-body { padding: 14px 16px; }
.drawer pre {
  font-family: var(--mono); font-size: calc(11px * var(--fs-scale)); line-height: 1.55; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 8px;
  padding: 12px 14px; overflow: auto; max-height: 420px; white-space: pre-wrap;
}
.gate-chip {
  font-family: var(--mono); font-size: calc(9.5px * var(--fs-scale)); letter-spacing: .08em;
  padding: 2px 8px; border-radius: 99px; border: 1px solid rgba(229,84,75,.45);
  color: var(--red); background: var(--red-dim);
}
.ver-chip {
  font-family: var(--mono); font-size: calc(9.5px * var(--fs-scale)); letter-spacing: .06em;
  padding: 2px 8px; border-radius: 99px; border: 1px solid var(--border); color: var(--text-3);
}

/* render section */
.render-hero { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: #000; }
.render-hero video { width: 100%; display: block; max-height: 560px; }
.render-meta { font-family: var(--mono); font-size: calc(10.5px * var(--fs-scale)); color: var(--text-3); padding: 8px 2px; display: flex; gap: 14px; flex-wrap: wrap; }
.render-meta .v { color: var(--text-2); cursor: pointer; }
.render-meta .v.active { color: var(--amber); }

/* audio playback affordance */
.narr-audio { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text-3); }
.narr-audio:hover { color: var(--amber); }

/* found-media grids (degraded view) */
.found-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.found-grid .thumb { aspect-ratio: 16/9; }

/* replay bar (phase 3) */
.replay-bar {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--border-soft); background: var(--surface);
  border-radius: 10px; padding: 10px 16px; margin: 14px 0;
}
.replay-bar input[type=range] { flex: 1; accent-color: var(--amber); }
.replay-bar .rp-btn {
  font-family: var(--mono); font-size: calc(11px * var(--fs-scale)); letter-spacing: .08em; cursor: pointer;
  border: 1px solid var(--border); border-radius: 99px; padding: 4px 12px; color: var(--text-2);
  background: var(--surface-2);
}
.replay-bar .rp-btn:hover { color: var(--amber); border-color: rgba(240,168,60,.4); }
.replay-bar .rp-time { font-family: var(--mono); font-size: calc(10.5px * var(--fs-scale)); color: var(--text-3); min-width: 130px; text-align: right; }
body.replaying .live .dot { background: var(--blue); animation: none; }

/* filmstrip thumbs at fixed height (duration drives width) */
.filmstrip .thumb { height: 118px; aspect-ratio: auto; }

/* empty board hints */
.hint { font-size: calc(12px * var(--fs-scale)); color: var(--text-3); padding: 10px 2px; }

a { color: inherit; }

/* entrance choreography plays only on first paint, not on every SSE refresh */
body:not(.first) .slate, body:not(.first) .rail .stage,
body:not(.first) .script-card, body:not(.first) .notice,
body:not(.first) aside .panel, body:not(.first) .scene-card,
body:not(.first) .lib-card, body:not(.first) .drawer { animation: none; }

/* stages that ran but aren't declared by the pipeline manifest */
.stage.undeclared .node { border-style: dashed; opacity: .85; }
.stage.undeclared .name { font-style: italic; }

/* spend past 90% of budget */
.cost .bar i.crit { background: var(--red); }

/* in_progress stage with no filesystem activity for a while (F-05) */
.stage.stalled .node { border-color: var(--red); color: var(--red); background: var(--red-dim); animation: none; }
.stage.stalled .name { color: var(--red); }
.stage.stalled .sub { color: var(--red); }

/* responsive project board */
@media (max-width: 900px) {
  .wrap { max-width: none; width: 100%; padding: 0 18px 64px; overflow-x: clip; }
  .slate { flex-wrap: wrap; align-items: flex-start; gap: 10px 12px; }
  .slate > div:nth-child(2) { min-width: 0; flex: 1 1 240px; }
  .slate h1 { overflow-wrap: anywhere; }
  .slate .spacer { display: none; }
  .cost { text-align: left; }
  .cost .bar { width: min(150px, 38vw); }

  .rail {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 18px 0 16px;
    scrollbar-width: thin;
  }
  .stage { flex: 0 0 82px; }
  .stage .name { font-size: calc(10px * var(--fs-scale)); max-width: 76px; overflow-wrap: anywhere; text-align: center; }
  .stage .sub { max-width: 76px; font-size: calc(9.5px * var(--fs-scale)); }

  .board { display: block; }
  .main-col, aside { width: 100%; min-width: 0; }
  aside { margin-top: 20px; }
  aside .panel + .panel { margin-top: 14px; }

  .script-card {
    width: 100%;
    max-width: 700px;
    padding: 28px 32px 26px;
  }
  .filmstrip {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding-left: 4px;
    padding-right: 4px;
  }
  .section-title { flex-wrap: wrap; }
  .section-title .meta { margin-left: 0; }
}

@media (max-width: 520px) {
  .wrap { padding: 0 12px 52px; }
  .slate { padding-top: 14px; }
  .clapper { width: 30px; height: 23px; }
  .slate .wordmark { font-size: calc(10px * var(--fs-scale)); }
  .slate h1 { font-size: calc(15px * var(--fs-scale)); letter-spacing: .06em; }
  .chip { font-size: calc(9.5px * var(--fs-scale)); padding: 3px 7px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .live { font-size: calc(10px * var(--fs-scale)); letter-spacing: .1em; }
  .cost { width: 100%; }
  .cost .bar { width: 100%; }

  .rail { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
  .stage { flex-basis: 74px; }
  .stage .name, .stage .sub { max-width: 68px; }

  .script-card {
    padding: 24px 20px 28px;
    border-radius: 5px;
  }
  .script-approved { top: 14px; right: 16px; font-size: calc(9px * var(--fs-scale)); padding: 2px 6px; }
  .script-card .sp-title { font-size: calc(14px * var(--fs-scale)); padding-right: 58px; }
  .script-card .sp-meta { margin-bottom: 18px; }
  .script-card .sp-slug .tc { float: none; display: block; margin-top: 2px; }
  .script-card .sp-expand { right: 12px; bottom: 10px; }

  .panel-head { flex-wrap: wrap; }
  .panel-head .meta { margin-left: 0; }
  .drawer .drawer-head { flex-wrap: wrap; }
  .drawer pre { font-size: calc(10.5px * var(--fs-scale)); }
  .scene-card { max-width: calc(100vw - 42px); }
}
