/* RB Video Studio: a dark rack. Every layer has an accent; a node borrows it as --acc. */
@property --a { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

:root {
  --bg: #05070c; --bg-2: #0a0e17;
  --panel: rgba(255,255,255,.035); --panel-2: rgba(255,255,255,.07);
  --line: rgba(255,255,255,.08); --line-2: rgba(255,255,255,.16);
  --ink: #e9edf6; --ink-2: #9aa3b8; --ink-3: #5d6679;
  --l0: #ffb454; --l1: #3ddcff; --l2: #ff4fd8; --l3: #9b6bff; --l4: #4dffa6; --l5: #f3f6ff;
  --ok: #4dffa6; --warn: #ffb454; --err: #ff5470;
  --font: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --r: 14px; --r-s: 9px;
  --transport-h: 62px; --console-h: 36px; --rack-w: 268px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg);
  /* One column that is never wider than the window: body hides what overflows, and a long log line in the console used to widen the whole page and push "+ New run" out of reach. */
  display: grid; grid-template-rows: var(--transport-h) 1fr var(--console-h); grid-template-columns: minmax(0, 1fr); overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:disabled, button[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
input, textarea { font: inherit; color: var(--ink); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.dim { color: var(--ink-3); }
.small { font-size: 12px; }
.eyebrow { font: 600 10.5px/1 var(--mono); letter-spacing: .14em; color: var(--ink-3); }

/* backdrop */
.bg { position: fixed; inset: 0; z-index: -1; background:
  radial-gradient(900px 600px at 8% -10%, rgba(61,220,255,.09), transparent 60%),
  radial-gradient(900px 700px at 100% 110%, rgba(255,79,216,.08), transparent 60%),
  radial-gradient(rgba(255,255,255,.045) 1px, transparent 1.2px) 0 0 / 26px 26px,
  linear-gradient(180deg, var(--bg-2), var(--bg));
}
.bg::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55)); }

/* ---------- transport ---------- */
.transport {
  display: grid; grid-template-columns: var(--rack-w) minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 0 18px 0 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.025)); border-bottom: 1px solid var(--line-2);
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 12px 30px rgba(0,0,0,.35);
}
.brand { display: flex; align-items: center; gap: 12px; }
.mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; font: 800 14px var(--font); color: #1a0c00;
  background: linear-gradient(135deg, #ffd08a, var(--l0) 55%, #e87511); box-shadow: 0 0 22px rgba(255,180,84,.35), inset 0 1px 0 rgba(255,255,255,.5); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; letter-spacing: .12em; font-size: 13px; }
.brand-sub { font-size: 11px; color: var(--ink-3); }

.deck { display: flex; align-items: center; gap: 8px; justify-self: center; padding: 6px 8px 6px 6px; border-radius: 999px; background: rgba(0,0,0,.35); border: 1px solid var(--line); box-shadow: inset 0 1px 0 rgba(255,255,255,.04); }
.tbtn { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); border: 1px solid transparent; transition: .15s; }
.tbtn:hover { color: var(--ink); background: var(--panel-2); }
.tplay { width: 40px; height: 40px; color: var(--ink); background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.16), rgba(255,255,255,.03)); border-color: var(--line-2); }
.tplay .i-pause, .tplay.playing .i-play { display: none; }
.tplay.playing .i-pause { display: block; }
.tplay.playing { color: var(--acc, var(--l2)); border-color: var(--acc, var(--l2)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--acc, var(--l2)) 14%, transparent), 0 0 24px color-mix(in srgb, var(--acc, var(--l2)) 35%, transparent); }
.readout { display: flex; flex-direction: column; min-width: 220px; max-width: 320px; padding: 0 10px; line-height: 1.15; }
.readout-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout-time { font-size: 12px; color: var(--ink-2); letter-spacing: .04em; }
.vu { border-radius: 6px; background: rgba(0,0,0,.4); border: 1px solid var(--line); }

.meters { display: flex; align-items: center; gap: 18px; }
.meter { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.meter-k { font: 600 10px var(--mono); letter-spacing: .14em; color: var(--ink-3); }
.meter-v { font-size: 15px; font-weight: 600; color: var(--l0); }
.engines { display: flex; gap: 12px; font: 600 10.5px var(--mono); letter-spacing: .12em; color: var(--ink-2); }
.engine { display: inline-flex; align-items: center; gap: 6px; }

.led { --c: var(--ok); display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #262c3a; box-shadow: inset 0 1px 2px rgba(0,0,0,.6); flex: none; }
.led.on { background: var(--c); box-shadow: 0 0 6px var(--c), 0 0 16px color-mix(in srgb, var(--c) 45%, transparent); }
.led.busy { background: var(--c); animation: blink 1s ease-in-out infinite; }
.led.err { --c: var(--err); background: var(--c); box-shadow: 0 0 8px var(--c); }
@keyframes blink { 50% { opacity: .25; box-shadow: none; } }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); font-weight: 600; font-size: 13px; transition: .15s; white-space: nowrap; }
.btn:hover { background: rgba(255,255,255,.11); border-color: rgba(255,255,255,.25); }
.btn.accent { color: #1a0c00; border-color: transparent; background: linear-gradient(135deg, #ffd08a, var(--l0) 60%, #f08a2a); box-shadow: 0 6px 20px rgba(255,180,84,.25); }
.btn.accent:hover { filter: brightness(1.06); box-shadow: 0 8px 26px rgba(255,180,84,.38); }
.btn.big { padding: 12px 20px; font-size: 15px; border-radius: 12px; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn.danger:hover { color: var(--err); border-color: var(--err); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--rack-w) 1fr; min-height: 0; }
.rack { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: rgba(0,0,0,.22); }
.rack-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 10px; font: 600 11px var(--mono); letter-spacing: .16em; color: var(--ink-2); }
.rack-count { color: var(--ink-3); }
.runs { flex: 1; overflow: auto; padding: 0 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.run { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 10px 12px; border-radius: 11px; border: 1px solid transparent; text-align: left; transition: .15s; position: relative; }
.run:hover { background: var(--panel); border-color: var(--line); }
.run.on { background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.04)); border-color: var(--line-2); box-shadow: inset 3px 0 0 var(--l0); }
.run-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-meta { grid-column: 1; font-size: 11px; color: var(--ink-3); }
.run-leds { grid-column: 2; grid-row: 1 / 3; display: flex; gap: 4px; align-items: center; }
.run-leds .led { width: 6px; height: 6px; }
.run-x { position: absolute; right: 8px; bottom: 6px; font-size: 11px; color: var(--ink-3); opacity: 0; padding: 2px 5px; border-radius: 6px; }
.run:hover .run-x { opacity: 1; }
.run-x:hover { color: var(--err); background: rgba(255,84,112,.12); }
.rack-foot { padding: 12px 16px 14px; border-top: 1px solid var(--line); }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font: 500 10.5px var(--mono); color: var(--ink-3); letter-spacing: .04em; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 7px; height: 7px; border-radius: 2px; background: var(--c); box-shadow: 0 0 6px var(--c); }

.stage { position: relative; overflow: auto; min-height: 0; }
.net { position: relative; min-width: max-content; min-height: 100%; }
.wires { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.wire { fill: none; stroke: rgba(255,255,255,.09); stroke-width: 1.5; transition: stroke .3s; }
.wire.on { stroke: var(--c); stroke-opacity: .75; filter: url(#glow); }
.wire.flow { stroke: var(--c); stroke-opacity: .9; stroke-dasharray: 5 9; animation: flow .9s linear infinite; filter: url(#glow); }
@keyframes flow { to { stroke-dashoffset: -14; } }

.layers { position: relative; display: flex; gap: 84px; padding: 34px 56px 120px 48px; align-items: flex-start; }
.layer { width: 372px; flex: none; display: flex; flex-direction: column; gap: 16px; --acc: var(--l1); }
.layer.l0 { --acc: var(--l0); width: 300px; }
.layer.l2 { --acc: var(--l2); width: 660px; }
.layer.l3 { --acc: var(--l3); width: 440px; }
.layer.l4 { --acc: var(--l4); width: 340px; }
.layer.l5 { --acc: var(--l5); width: 460px; }
.layer-head { display: flex; flex-direction: column; gap: 3px; padding: 0 2px 6px; border-bottom: 1px solid var(--line); position: relative; }
.layer-head::after { content: ''; position: absolute; left: 0; bottom: -1px; width: 46px; height: 2px; background: var(--acc); box-shadow: 0 0 10px var(--acc); }
.layer-name { font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.layer-status { font-size: 12px; color: var(--ink-3); }
.layer-status b { color: var(--acc); font-weight: 600; }

/* ---------- nodes ---------- */
.node {
  position: relative; border-radius: var(--r); padding: 14px 16px 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.025));
  border: 1px solid var(--line); box-shadow: 0 14px 34px rgba(0,0,0,.38), inset 0 1px 0 rgba(255,255,255,.07);
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.node:hover { border-color: var(--line-2); }
.node.lit { border-color: color-mix(in srgb, var(--acc) 55%, var(--line-2)); box-shadow: 0 14px 34px rgba(0,0,0,.38), 0 0 0 1px color-mix(in srgb, var(--acc) 18%, transparent), 0 0 30px color-mix(in srgb, var(--acc) 12%, transparent), inset 0 1px 0 rgba(255,255,255,.08); }
.node.ghost { opacity: .5; border-style: dashed; box-shadow: none; background: transparent; }
.node.err { border-color: color-mix(in srgb, var(--err) 55%, var(--line-2)); }
.node.firing::before {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; padding: 1.5px; pointer-events: none;
  background: conic-gradient(from var(--a), transparent 0 62%, var(--acc) 84%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: spin 1.5s linear infinite;
}
@keyframes spin { to { --a: 360deg; } }
.port { position: absolute; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%; background: #1b2130; border: 1px solid var(--line-2); }
.port.in { left: -5px; } .port.out { right: -5px; }
.node.lit .port, .node.firing .port { background: var(--acc); border-color: var(--acc); box-shadow: 0 0 8px var(--acc); }

.node-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.badge { flex: none; display: grid; place-items: center; min-width: 28px; height: 22px; padding: 0 6px; border-radius: 6px; font: 700 11px var(--mono); letter-spacing: .06em; color: var(--acc); background: color-mix(in srgb, var(--acc) 14%, transparent); border: 1px solid color-mix(in srgb, var(--acc) 35%, transparent); }
.node-title { font-weight: 700; font-size: 15px; line-height: 1.2; flex: 1; min-width: 0; }
.node-sub { font-size: 12px; color: var(--ink-2); }
.chip { display: inline-flex; align-items: center; gap: 5px; font: 500 10.5px var(--mono); letter-spacing: .04em; color: var(--ink-2); padding: 3px 7px; border-radius: 6px; background: rgba(0,0,0,.3); border: 1px solid var(--line); white-space: nowrap; }
.chip.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.chip.ok { color: var(--ok); }

.skel { height: 10px; border-radius: 6px; margin: 9px 0; background: linear-gradient(90deg, rgba(255,255,255,.05), rgba(255,255,255,.13), rgba(255,255,255,.05)); background-size: 220% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -220% 0; } }
.node-err { color: var(--err); font-size: 12.5px; margin: 6px 0 2px; }

/* brief node */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-size: 12.5px; }
.kv dt { color: var(--ink-3); font: 600 10.5px var(--mono); letter-spacing: .1em; padding-top: 2px; }
.kv dd { margin: 0; }
.brief-topic { font-size: 13px; color: var(--ink); margin: 2px 0 10px; }

/* script node */
.angle { font-size: 12.5px; color: var(--ink-2); font-style: italic; margin: 0 0 10px; }
.lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.lines li { display: grid; grid-template-columns: 24px 1fr; gap: 2px 8px; }
.lines .n { font: 600 10.5px var(--mono); color: var(--acc); opacity: .8; padding-top: 3px; }
.lines .t { font-size: 13.5px; line-height: 1.4; }
.lines .v { grid-column: 2; font-size: 11.5px; color: var(--ink-3); }
.lines .v::before { content: '⌐ '; color: var(--ink-3); }
.tone { margin-top: 10px; font-size: 12px; color: var(--ink-2); padding: 8px 10px; border-radius: 8px; background: rgba(0,0,0,.25); border-left: 2px solid var(--acc); }
.node-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.spacer { flex: 1; }
.ibtn { display: inline-flex; align-items: center; gap: 5px; padding: 6px 9px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--ink-2); border: 1px solid transparent; transition: .15s; }
.ibtn:hover { color: var(--ink); background: var(--panel-2); border-color: var(--line); }
.ibtn svg { width: 13px; height: 13px; }

/* the LED toggle: a checkbox that looks like a rack switch */
.toggle { display: inline-flex; align-items: center; gap: 8px; padding: 6px 11px 6px 8px; border-radius: 999px; border: 1px solid var(--line-2); background: rgba(0,0,0,.3); font: 700 11px var(--mono); letter-spacing: .1em; color: var(--ink-2); transition: .15s; user-select: none; }
.toggle:hover { border-color: rgba(255,255,255,.3); color: var(--ink); }
.toggle .led { --c: var(--acc); }
.toggle.on { color: var(--acc); border-color: var(--acc); background: color-mix(in srgb, var(--acc) 12%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--acc) 30%, transparent), 0 0 18px color-mix(in srgb, var(--acc) 22%, transparent); }
.toggle.on .led { background: var(--c); box-shadow: 0 0 6px var(--c), 0 0 14px var(--c); }
.toggle.ok { --acc: var(--ok); }

/* script editor */
.editor { display: flex; flex-direction: column; gap: 8px; }
.editor .row { display: grid; grid-template-columns: 22px 1fr 24px; gap: 4px 6px; align-items: start; }
.editor .row .n { font: 600 10.5px var(--mono); color: var(--acc); padding-top: 9px; }
.editor .row .fields { display: flex; flex-direction: column; gap: 4px; }
.editor input, .editor textarea { width: 100%; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line-2); background: rgba(0,0,0,.35); outline: none; }
.editor input:focus, .editor textarea:focus { border-color: var(--acc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 15%, transparent); }
.editor input.vis { font-size: 11.5px; color: var(--ink-2); }
.editor .rm { color: var(--ink-3); padding-top: 6px; font-size: 13px; }
.editor .rm:hover { color: var(--err); }
.editor .title { font-weight: 700; font-size: 15px; }

/* layer 2 banks */
.bank { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 18px; border: 1px solid var(--line); background: rgba(0,0,0,.18); }
.bank-head { display: flex; align-items: center; gap: 10px; padding: 2px 4px 4px; }
.bank-title { font-weight: 700; font-size: 13.5px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group { display: flex; flex-direction: column; gap: 8px; }
.group-head { display: flex; align-items: baseline; gap: 8px; padding: 6px 4px 0; }
.group-name { font: 700 11px var(--mono); letter-spacing: .14em; color: var(--acc); }
.group-hint { font-size: 11px; color: var(--ink-3); }
.clip { padding: 12px 14px 12px; }
.clip .node-head { margin-bottom: 8px; }
.clip-name { font-weight: 700; font-size: 14px; }
.clip-label { font-size: 12px; color: var(--ink-2); }
.wave { display: block; width: 100%; height: 48px; border-radius: 8px; background: rgba(0,0,0,.3); border: 1px solid var(--line); cursor: pointer; }
.clip-ctl { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.play { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center; color: var(--ink);
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.14), rgba(255,255,255,.02)); transition: .15s; }
.play:hover { border-color: var(--acc); color: var(--acc); }
.play svg { width: 14px; height: 14px; }
.play .i-pause, .play.playing .i-play { display: none; }
.play.playing .i-pause { display: block; }
.play.playing { color: var(--acc); border-color: var(--acc); box-shadow: 0 0 0 4px color-mix(in srgb, var(--acc) 14%, transparent), 0 0 22px color-mix(in srgb, var(--acc) 35%, transparent); animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--acc) 8%, transparent), 0 0 30px color-mix(in srgb, var(--acc) 45%, transparent); } }
.clip-time { font: 500 11.5px var(--mono); color: var(--ink-2); letter-spacing: .04em; }
.clip.lit { background: linear-gradient(180deg, color-mix(in srgb, var(--acc) 10%, rgba(255,255,255,.06)), rgba(255,255,255,.025)); }

/* placeholder layers */
.ghost-text { font-size: 12.5px; color: var(--ink-2); margin: 0; }
.ghost-text b { color: var(--ink); font-weight: 600; }

/* empty state */
.empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 40px; }
.empty[hidden] { display: none; }
.empty-card { max-width: 520px; text-align: center; padding: 40px 36px; border-radius: 22px; background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02)); border: 1px solid var(--line-2); box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.empty-card h1 { font-size: 26px; margin: 18px 0 8px; letter-spacing: -.01em; }
.empty-card p { color: var(--ink-2); margin: 0 0 22px; font-size: 14px; }
.empty-glyph { display: inline-flex; gap: 14px; }
.empty-glyph span { width: 14px; height: 14px; border-radius: 50%; background: var(--l1); box-shadow: 0 0 16px var(--l1); animation: blink 2.4s ease-in-out infinite; }
.empty-glyph span:nth-child(2) { background: var(--l2); box-shadow: 0 0 16px var(--l2); animation-delay: .8s; }
.empty-glyph span:nth-child(3) { background: var(--l3); box-shadow: 0 0 16px var(--l3); animation-delay: 1.6s; }

/* console */
.console { display: flex; align-items: center; gap: 12px; padding: 0 16px; border-top: 1px solid var(--line-2); background: rgba(0,0,0,.4); font: 500 11.5px var(--mono); }
.log { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.log .t { color: var(--ink-3); margin-right: 8px; }
.log .warn { color: var(--warn); } .log .error { color: var(--err); }
.console-hint { letter-spacing: .04em; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; background: rgba(3,5,10,.62); backdrop-filter: blur(10px); }
.modal[hidden] { display: none; }
.modal-card { width: min(720px, 100%); max-height: 100%; overflow: auto; padding: 26px 28px 24px; border-radius: 20px;
  background: linear-gradient(180deg, #131a28, #0d1220); border: 1px solid var(--line-2); box-shadow: 0 40px 100px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.08); animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.modal-head h2 { margin: 4px 0 0; font-size: 22px; letter-spacing: -.01em; }
.xbtn { width: 32px; height: 32px; border-radius: 8px; color: var(--ink-3); }
.xbtn:hover { color: var(--ink); background: var(--panel-2); }
.brief { display: flex; flex-direction: column; gap: 14px; }
.f { display: flex; flex-direction: column; gap: 6px; }
.f > span { font: 600 11px var(--mono); letter-spacing: .12em; color: var(--ink-2); }
.f > span em { font-style: normal; color: var(--l0); margin-left: 6px; }
.f input, .f textarea { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: rgba(0,0,0,.35); outline: none; resize: vertical; transition: .15s; }
.f input:focus, .f textarea:focus { border-color: var(--l0); box-shadow: 0 0 0 3px rgba(255,180,84,.15); }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: rgba(0,0,0,.35); border: 1px solid var(--line-2); }
.seg button { padding: 7px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.seg button.on { color: #1a0c00; background: linear-gradient(135deg, #ffd08a, var(--l0)); box-shadow: 0 2px 10px rgba(255,180,84,.3); }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 6px; }

/* toasts */
.toasts { position: fixed; right: 18px; top: calc(var(--transport-h) + 12px); z-index: 30; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 14px; border-radius: 10px; font-size: 13px; background: #1a1220; border: 1px solid color-mix(in srgb, var(--err) 50%, transparent); color: #ffd7de; box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: rise .2s ease-out; max-width: 380px; }
.toast.ok { background: #0f1a16; border-color: color-mix(in srgb, var(--ok) 40%, transparent); color: #d5ffe9; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.22); background-clip: padding-box; }

/* The transport gives way from the middle as the window narrows, so Guide and
   "+ New run" stay on screen: first the room around the clip name, then the
   level meter, then the engine lights. (At 1280 px the spend meter used to
   fold into a 104 px block, and below 1290 px "+ New run" left the window.) */
.meter-k, .meter-v { white-space: nowrap; }
@media (max-width: 1400px) { .readout { min-width: 160px; } }
@media (max-width: 1330px) { .vu { display: none; } }
@media (max-width: 1160px) { .engines { display: none; } }
@media (max-width: 980px) {
  :root { --rack-w: 0px; }
  .rack { display: none; }
  /* with the rack gone the stage is the only column (it used to land in the rack's empty 0 px column, so the page was blank) */
  .shell { grid-template-columns: minmax(0, 1fr); }
  .transport { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; padding: 0 12px; }
  .brand-text, .readout, .engines { display: none; }
}
/* phones: the transport keeps play, the spend figure, Guide and "+ New run" */
@media (max-width: 560px) {
  #t-prev, #t-stop, .meter-k, .console-hint { display: none; }
  .meters { gap: 10px; }
  .layers { padding: 24px 20px 100px 16px; gap: 56px; }
  /* the storyboard, edit and film layers are no wider than the phone, so each node is read without scrolling sideways inside it */
  .layer.l3, .layer.l4, .layer.l5 { width: min(440px, calc(100vw - 36px)); }
}
@media (max-width: 430px) { #spend-btn { display: none; } }

/* visuals fold away by default so a script node stays one screen tall */
.lines .v { display: none; }
.lines.with-vis .v { display: block; }
.ibtn.on { color: var(--acc); border-color: color-mix(in srgb, var(--acc) 35%, transparent); background: color-mix(in srgb, var(--acc) 10%, transparent); }
/* voice and music side by side inside a bank */
.bank-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.chip.long { margin-left: -2px; }

/* the gate: shown when the service says this account may not use the studio yet */
.gate { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 24px; background: rgba(3,5,10,.78); backdrop-filter: blur(14px); }
.gate-card { max-width: 460px; text-align: center; padding: 40px 36px; border-radius: 22px; background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.02)); border: 1px solid var(--line-2); box-shadow: 0 30px 80px rgba(0,0,0,.6); animation: rise .25s ease-out; }
.gate-title { font-size: 30px; margin: 18px 0 8px; letter-spacing: -.01em; background: linear-gradient(90deg, var(--l1), var(--l2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.gate:not(.soon) .gate-title { font-size: 20px; }
.gate-card p { color: var(--ink-2); margin: 0 0 22px; }

/* ingredients: the drop zone in the brief form and the list on the Input node */
.f > span em.soft { color: var(--ink-3); }
.drop { border: 1.5px dashed var(--line-2); border-radius: 12px; padding: 16px 18px; text-align: center; cursor: pointer; background: rgba(0,0,0,.25); color: var(--ink-2); transition: .15s; font-size: 13px; outline: none; }
.drop b { color: var(--ink); }
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--l0); background: rgba(255,180,84,.06); color: var(--ink); box-shadow: 0 0 0 3px rgba(255,180,84,.12); }
.drop-hint { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.files, .ings { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.files li, .ing { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: rgba(0,0,0,.25); border: 1px solid var(--line); font-size: 12.5px; }
.kbadge { --c: var(--ink-2); flex: none; font: 700 9.5px var(--mono); letter-spacing: .1em; padding: 3px 6px; border-radius: 5px; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); }
.kbadge.video { --c: var(--l3); } .kbadge.audio { --c: var(--l2); } .kbadge.image { --c: var(--l1); } .kbadge.document { --c: var(--l0); } .kbadge.font { --c: var(--l4); }
.ing-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ing-meta { color: var(--ink-3); font: 500 10.5px var(--mono); white-space: nowrap; }
.ing-x { color: var(--ink-3); padding: 2px 5px; border-radius: 5px; font-size: 12px; }
.ing-x:hover { color: var(--err); background: rgba(255,84,112,.12); }
.layer.l0 .group-head { margin-top: 12px; }
/* on the narrow Input node the details sit under the name instead of beside it */
.ing { display: grid; grid-template-columns: auto 1fr auto; gap: 1px 8px; align-items: center; }
.ing .ing-meta { grid-column: 2; grid-row: 2; }
/* the remove button is given its column: with only its rows set it was placed first, in the badge's column, the badge took the wide one and the file name was cut to a few letters */
.ing .ing-x { grid-column: 3; grid-row: 1 / 3; }

/* spend against the monthly cap: the transport readout and the dashboard */
.meter { align-items: flex-end; text-align: right; border-radius: 8px; padding: 4px 8px; margin: -4px -8px; transition: .15s; }
.meter:hover { background: var(--panel-2); }
.meter-v.warn { color: var(--warn); }
.meter-v.over { color: var(--err); }
.meter-bar { display: block; width: 100%; height: 3px; margin-top: 4px; border-radius: 2px; background: rgba(255,255,255,.1); overflow: hidden; }
.meter-bar i { display: block; height: 100%; width: 0; border-radius: 2px; background: var(--l0); box-shadow: 0 0 6px var(--l0); transition: width .4s; }
.meter-bar i.warn { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.meter-bar i.over { background: var(--err); box-shadow: 0 0 6px var(--err); }
.modal-card.wide { width: min(980px, 100%); }
.cap-card { padding: 18px 20px 12px; border-radius: 14px; border: 1px solid var(--line-2); background: rgba(0,0,0,.25); margin-bottom: 18px; }
.cap-card.warn { border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.cap-card.over { border-color: color-mix(in srgb, var(--err) 60%, transparent); }
.cap-top { display: flex; align-items: baseline; gap: 10px; }
.cap-big { font-size: 34px; font-weight: 600; color: var(--l0); letter-spacing: -.02em; }
.cap-card.warn .cap-big { color: var(--warn); } .cap-card.over .cap-big { color: var(--err); }
.cap-of { color: var(--ink-2); }
.cap-left { color: var(--ink-2); font-size: 12px; }
.cap-bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,.08); overflow: hidden; margin: 12px 0 10px; }
.cap-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--l1), var(--l0)); box-shadow: 0 0 10px var(--l0); }
.cap-card.warn .cap-bar i { background: linear-gradient(90deg, var(--l0), var(--warn)); }
.cap-card.over .cap-bar i { background: var(--err); box-shadow: 0 0 10px var(--err); }
.cgrid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; margin-bottom: 8px; }
#costs-body h3 { font: 600 11px var(--mono); letter-spacing: .14em; color: var(--ink-2); margin: 14px 0 8px; text-transform: uppercase; }
.ctable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ctable th { text-align: left; font: 600 10.5px var(--mono); letter-spacing: .08em; color: var(--ink-3); padding: 6px 8px; border-bottom: 1px solid var(--line-2); }
.ctable td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ctable td.b { font-weight: 600; color: var(--ink); }
.ctable td.trunc { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 800px) { .cgrid { grid-template-columns: 1fr; } }

/* links inside the rack, and the way to the guide */
a.btn { text-decoration: none; color: var(--ink); }
.ghost-text a, .empty-guide a { color: var(--l1); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--l1) 40%, transparent); }
.ghost-text a:hover, .empty-guide a:hover { border-bottom-color: var(--l1); }
.ghost-text + .ghost-text { margin-top: 8px; }
.empty-card .empty-guide { margin: 18px 0 0; font-size: 13px; }

/* ---------- the look picker in the brief form ---------- */
.f3 { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-start; }
.seg-hint { font-size: 11.5px; color: var(--ink-3); }

/* keyboard focus is always visible; the ring takes the layer's accent */
:is(button, a, video):focus-visible { outline: 2px solid var(--acc, var(--l0)); outline-offset: 2px; }

/* Words the page did not write (a script line, a brief, an error from ffmpeg
   with a file path in it) can hold a run of letters with nowhere to break:
   it breaks anywhere sooner than run out of its node and over the next layer. */
.lines .t, .lines .v, .brief-topic, .kv dd, .angle, .tone, .node-err, .ghost-text, .shot-line .t, .warns li { overflow-wrap: anywhere; }
/* a node the keyboard was left on when its button went away (see refocus in app.js) */
.node:focus-visible { outline: 2px solid var(--acc, var(--l0)); outline-offset: 2px; }
/* a node brought into view (see reveal in app.js) keeps a little air between it and the edge of the stage */
.node { scroll-margin: 24px; }

/* ---------- layers 3 to 5: storyboard, edit, film ---------- */
/* a stage node names its script under its own title */
.head-text { flex: 1; min-width: 0; }
.head-text .node-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the chip that points on from layer 2 is a button */
.chip.go { cursor: pointer; transition: .15s; }
.chip.go:hover { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }

/* storyboard: one row a line */
.board .group-head { padding: 2px 0 0; }
.shots { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.shot { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: start; padding: 8px; border-radius: 10px; background: rgba(0,0,0,.22); border: 1px solid var(--line); }
.shot.open { border-color: color-mix(in srgb, var(--acc) 50%, var(--line-2)); }
.shot-skel { height: 58px; border-radius: 10px; margin: 8px 0 0; }
.pic-btn { display: block; border-radius: 7px; }
.pic-btn:disabled { opacity: .6; }
/* a picture frame in the film's own shape, so a 9:16 run shows tall thumbs */
.pic { --ar: 16 / 9; position: relative; display: block; width: 104px; aspect-ratio: var(--ar); border-radius: 7px; overflow: hidden; background: #0b0d10; border: 1px solid var(--line-2); }
.board.tall .pic { --ar: 9 / 16; width: 58px; }
.pic img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .2s; }
.pic[data-state="ready"] img { opacity: 1; }
.pic[data-state="loading"] { background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.12), rgba(255,255,255,.04)); background-size: 220% 100%; animation: shimmer 1.4s linear infinite; }
.pic[data-state="error"]::after { content: 'no preview'; position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font: 600 9px var(--mono); letter-spacing: .08em; color: var(--ink-3); }
/* the text card wears the brand: near-black with RB orange */
.pic.card { display: grid; place-items: center; text-align: center; background: #0b0d10; border-color: color-mix(in srgb, #e87511 55%, transparent); box-shadow: inset 0 -3px 0 #e87511; }
.pic.card b { font: 700 9.5px/1.3 var(--mono); letter-spacing: .12em; color: #e87511; padding: 0 4px; }
.pic.card.gone { border-color: color-mix(in srgb, var(--warn) 45%, transparent); box-shadow: none; }
.pic.card.gone b { color: var(--warn); }
.pic-tag { position: absolute; left: 3px; bottom: 3px; padding: 1px 4px; border-radius: 4px; font: 700 8.5px var(--mono); letter-spacing: .08em; color: #fff; background: rgba(0,0,0,.72); }
.shot-body { min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.shot-line { display: flex; align-items: baseline; gap: 8px; }
.shot-line .n { flex: none; font: 600 10.5px var(--mono); color: var(--acc); opacity: .85; }
.shot-line .t { flex: 1; min-width: 0; font-size: 12px; line-height: 1.4; color: var(--ink-2); }
.shot-ctl { display: flex; align-items: center; gap: 6px; }
.os { flex: 1; min-width: 0; padding: 6px 9px; border-radius: 8px; border: 1px solid var(--line-2); background: rgba(0,0,0,.35); outline: none; font-weight: 600; font-size: 13px; transition: border-color .15s, box-shadow .15s; }
.os::placeholder { font-weight: 400; color: var(--ink-3); }
.os:focus { border-color: var(--acc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 18%, transparent); }
.os.saved { border-color: var(--ok); }
.os.unsaved { border-color: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 14%, transparent); }
.os:disabled { opacity: .55; cursor: not-allowed; }
.shot-ctl .ibtn { border-color: var(--line); }

/* the picture picker opens under its row */
.picker { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; max-height: 236px; overflow: auto; padding: 8px; border-radius: 9px; background: rgba(0,0,0,.32); border: 1px solid var(--line); }
.board.tall .picker { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); max-height: 260px; }
.picker .ghost-text { grid-column: 1 / -1; }
.tile { display: block; padding: 2px; border-radius: 9px; border: 1.5px solid transparent; transition: .15s; }
.tile .pic { width: 100%; }
.tile:hover { border-color: var(--line-2); }
.tile.on { border-color: var(--acc); box-shadow: 0 0 14px color-mix(in srgb, var(--acc) 35%, transparent); }

/* edit: the five steps of the job, the facts of the last render */
.steps { list-style: none; margin: 4px 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.steps li { display: flex; align-items: center; gap: 9px; font: 600 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.steps .led { --c: var(--acc); }
.steps li.done { color: var(--ink-2); }
.steps li.done .led { background: var(--c); opacity: .5; }
.steps li.on { color: var(--acc); }
.steps li.on .led { background: var(--c); box-shadow: 0 0 6px var(--c), 0 0 14px var(--c); animation: blink 1s ease-in-out infinite; }
.pbar { height: 6px; margin: 0 0 10px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; }
.pbar i { display: block; height: 100%; border-radius: 3px; background: var(--acc); box-shadow: 0 0 10px var(--acc); }
.note { margin: -2px 0 10px; }
.cost { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.kv.facts dd .warn { color: var(--warn); }
.warns { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.warns li { font-size: 12px; line-height: 1.4; color: var(--warn); padding: 6px 9px; border-radius: 8px; background: color-mix(in srgb, var(--warn) 8%, transparent); border-left: 2px solid var(--warn); }

/* film: the player keeps the film's own shape; a 9:16 film stands tall, capped by --maxh, which gives way on a short window (a 768 px laptop) so the Download button stays in view */
.film-frame { --maxh: clamp(260px, calc(100vh - 380px), 470px); position: relative; width: min(100%, calc(var(--maxh) * var(--w) / var(--h))); aspect-ratio: var(--w) / var(--h); margin: 2px auto 0; border-radius: 10px; overflow: hidden; background: #000; border: 1px solid var(--line-2); }
.film-frame video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.film-msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 14px; text-align: center; font-size: 12.5px; color: var(--ink-2); background: #05070c; }
.film-frame[data-state="ready"] .film-msg, .film-frame[data-state="loading"] .when-error, .film-frame[data-state="error"] .when-loading { display: none; }
.film-frame[data-state="loading"] .film-msg { background: linear-gradient(90deg, rgba(255,255,255,.03), rgba(255,255,255,.09), rgba(255,255,255,.03)) #05070c; background-size: 220% 100%; animation: shimmer 1.4s linear infinite; }
.when-error { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.film-msg .ibtn { border-color: var(--line-2); }

/* files the storyboard could not use, with the reason */
.skipped { margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.skipped summary { cursor: pointer; color: var(--warn); }
.skipped ul { margin: 6px 0 0; padding-left: 16px; }
.skipped li { margin: 3px 0; overflow-wrap: anywhere; }
.skipped b { color: var(--ink); font-weight: 600; }

/* pictures made by the image model */
.pic-tag.ai { background: color-mix(in srgb, var(--l3) 80%, #000); color: #fff; }
.pic.card.gen { border-style: dashed; border-color: color-mix(in srgb, var(--l3) 70%, transparent); box-shadow: none; }
.pic.card.gen b { color: var(--l3); }
.pic.card.making { border-color: color-mix(in srgb, var(--l3) 70%, transparent); box-shadow: none; background: linear-gradient(90deg, rgba(155,107,255,.06), rgba(155,107,255,.22), rgba(155,107,255,.06)); background-size: 220% 100%; animation: shimmer 1.4s linear infinite; }
.pic.card.making b { color: var(--l3); }
.tile.gen:disabled { opacity: .45; }
.gen-foot { margin-top: 10px; padding-top: 10px; }
.gen-foot .ghost-text { margin: 0; }

.library-search { grid-column: 1 / -1; min-width: 0; padding: 12px; border: 1px solid var(--line, #444); margin: 10px 0; }
.library-search label { display: block; margin: 6px 0; }
.library-search .library-query { width: 100%; box-sizing: border-box; padding: 8px; background: rgba(0,0,0,.35); border: 1px solid var(--line-2); border-radius: 8px; }
.library-search .picker { max-height: 380px; overflow-y: auto; }
