/* CUE — the gallery. Studio grey, paper rundown, three tally colours that each mean one thing.
   Two type sizes: the clock (condensed, large) and everything else (14 px). Rank is weight, case, tally. */
@font-face { font-family: 'Barlow Condensed'; font-weight: 500; font-display: swap; src: url('assets/fonts/barlow-condensed-normal-500.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-display: swap; src: url('assets/fonts/barlow-condensed-normal-700.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-weight: 100 900; font-display: swap; src: url('assets/fonts/archivo-var.woff2') format('woff2'); }

:root {
  --wall: #1c1f24; --desk: #2a2e35; --desk-hi: #343943; --seam: #0e1013;
  --paper: #f4f1ea; --paper-rule: #d9d3c4; --ink: #141414; --ink-2: #5a564d;
  --chalk: #e9e6df; --chalk-2: #a9adb6; --chalk-3: #6b7079;
  --red: #e3262b; --green: #22b35a; --amber: #f0b429;
  --clock: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --text: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fs: 14px; --fs-clock: 34px;
  --mon-ratio: 16 / 9;
}
* { box-sizing: border-box; }
html { background: var(--wall); color: var(--chalk); font-family: var(--text); font-size: var(--fs); line-height: 1.4; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
::selection { background: var(--amber); color: var(--ink); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
button, input, textarea { font: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }
b { font-weight: 700; }

/* ---------- desk header ---------- */
.desk { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 20px; padding: 14px 22px; border-bottom: 1px solid var(--seam); background: var(--desk); }
.desk__name { margin: 0; font-family: var(--clock); font-weight: 700; font-size: var(--fs-clock); line-height: 1; letter-spacing: .06em; color: var(--chalk); }
.desk__line { margin: 0; color: var(--chalk-2); }
.desk__setup { justify-self: end; }
.desk .key { height: 44px; min-width: 44px; }

/* ---------- keys (desk buttons): square, labelled, lit when active ---------- */
.key { height: 40px; padding: 0 16px; border: 1px solid var(--chalk-3); border-radius: 3px; background: var(--desk-hi); color: var(--chalk); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
.key:hover { background: #3e4450; border-color: var(--chalk-2); }
.key:active { background: var(--seam); }
.key:disabled { opacity: .45; cursor: not-allowed; }
.key--ghost { background: transparent; }
.key--hot { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.key--hot:hover { background: #ffc54a; border-color: #ffc54a; }
.key--hot small { font-weight: 600; letter-spacing: .02em; text-transform: none; font-variant-numeric: tabular-nums; opacity: .85; }
.key--xport { width: 92px; padding: 0 10px; justify-content: center; gap: 6px; }
.key--xport .lbl { display: inline; }
.key--xport .ico-pause { display: none; }
.key--xport.is-on { background: var(--red); border-color: var(--red); color: #fff; }
.key--xport.is-on .ico-pause { display: block; }
.key--xport.is-on .ico-play { display: none; }

/* ---------- gallery layout ---------- */
.gallery { display: grid; grid-template-rows: auto auto 1fr auto; gap: 1px; background: var(--seam); }
.gallery > section { background: var(--wall); }

/* ---------- monitor wall ---------- */
.wall { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 14px; padding: 14px 22px; min-width: 0; }
.wall > * { min-width: 0; }
.mon { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto; gap: 0; min-width: 0; }
.mon__tally { display: flex; align-items: center; gap: 10px; min-width: 0; height: 28px; padding: 0 10px; background: var(--desk); border: 1px solid var(--chalk-3); border-bottom: 0; border-radius: 3px 3px 0 0; font-size: 14px; letter-spacing: .1em; text-transform: uppercase; color: var(--chalk-2); }
.mon__tally b { color: var(--chalk); }
.mon__tally span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mon__screen { position: relative; width: 100%; aspect-ratio: var(--mon-ratio); background: #000; border: 1px solid var(--chalk-3); overflow: hidden; }
.mon__screen canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; max-width: 100%; }
.mon__cap { display: flex; justify-content: space-between; gap: 10px; height: 28px; align-items: center; padding: 0 10px; background: var(--desk); border: 1px solid var(--chalk-3); border-top: 0; border-radius: 0 0 3px 3px; font-size: 14px; color: var(--chalk-2); font-variant-numeric: tabular-nums; }
.mon__cap span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* tally: the border is the state. red = on air, green = next. Instant, no transition: a cut is a cut. */
.mon.is-air .mon__screen, .mon.is-air .mon__tally, .mon.is-air .mon__cap { border-color: var(--red); }
.mon.is-air .mon__tally b { color: var(--red); }
.mon.is-next .mon__screen, .mon.is-next .mon__tally, .mon.is-next .mon__cap { border-color: var(--green); }
.mon__tally b::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--chalk-3); margin-right: 6px; vertical-align: 0; }
.mon.is-air .mon__tally b::before { background: var(--red); }
.mon.is-next .mon__tally b::before { background: var(--green); }
.mon.is-next .mon__tally b { color: var(--green); }
.pvw { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 10px; }
.mon--pvw { grid-template-rows: auto minmax(0, 1fr) auto; }
.mon--pvw .mon__screen { aspect-ratio: auto; height: 100%; }
.mon--pvw .mon__tally, .mon--pvw .mon__cap { height: 26px; padding: 0 8px; }
.mon--pvw .mon__cap span:last-child { white-space: nowrap; flex: 0 0 auto; }

/* colour bars + NO SOURCE */
.bars { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(7, 1fr); }
.bars i { display: block; }
.bars i:nth-child(1) { background: #c0c0c0; } .bars i:nth-child(2) { background: #c0c000; } .bars i:nth-child(3) { background: #00c0c0; } .bars i:nth-child(4) { background: #00c000; } .bars i:nth-child(5) { background: #c000c0; } .bars i:nth-child(6) { background: #c00000; } .bars i:nth-child(7) { background: #0000c0; }
body:not([data-state="nosource"]) .bars { display: none; }
.mon__nosrc { position: absolute; inset: 0; display: grid; place-content: center; gap: 14px; background: rgba(14,16,19,.82); text-align: center; }
body:not([data-state="nosource"]) .mon__nosrc { display: none; }
.load { display: grid; gap: 6px; padding: 22px 34px; border: 1px dashed var(--chalk-2); border-radius: 3px; cursor: pointer; background: rgba(42,46,53,.6); }
.load:hover, .is-dropping .load { border-color: var(--amber); background: rgba(42,46,53,.9); }
.load__big { font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--chalk); }
.load__small { color: var(--chalk-2); }
.mon__nosrc .key { justify-self: center; }
.key--resume { border-color: var(--amber); color: var(--amber); }
.key--resume:hover { background: rgba(255,176,32,.12); }
.mon__strobe { position: absolute; left: 10px; top: 10px; padding: 4px 8px; background: var(--amber); color: var(--ink); font-weight: 700; letter-spacing: .08em; border-radius: 2px; }

/* ---------- clock strip ---------- */
.clock { display: flex; align-items: center; gap: 22px; padding: 12px 22px; background: var(--desk); }
.tc { display: grid; grid-template-rows: auto auto; gap: 0; min-width: 0; }
.tc__k { letter-spacing: .12em; color: var(--chalk-2); text-transform: uppercase; }
.tc b { font-family: var(--clock); font-weight: 700; font-size: var(--fs-clock); line-height: 1; letter-spacing: .02em; color: var(--chalk); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tc--next b { color: var(--amber); }
.tc--sec { flex: 1 1 0; }
.tc--sec b { font-weight: 500; letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; }
.tc--prog { flex: 1 1 0; }
.tc--prog[hidden] { display: none; }
.prog { display: block; height: 10px; margin-top: 12px; background: var(--seam); border: 1px solid var(--chalk-3); border-radius: 2px; overflow: hidden; }
.prog b { display: block; height: 100%; width: 0; background: var(--amber); transition: width .25s linear; }
.clock__right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.switch { display: inline-flex; align-items: center; gap: 8px; letter-spacing: .08em; color: var(--chalk); cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 34px; height: 18px; margin: 0; border-radius: 9px; background: var(--seam); border: 1px solid var(--chalk-3); position: relative; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--chalk-2); }
.switch input:checked { background: var(--chalk); border-color: var(--chalk); }
.switch input:checked::after { left: 18px; background: var(--ink); }

/* ---------- running order (paper) ---------- */
.rundown { background: var(--paper) !important; color: var(--ink); padding: 18px 22px 26px; }
.rundown__head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 10px 22px; margin-bottom: 14px; }
.rundown__title { margin: 0; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink); line-height: 40px; }
.renderdesk .rundown__title, .setup .rundown__title { color: var(--chalk); }
.rundown__treat { margin: 4px 0 0; color: var(--ink-2); max-width: 72ch; }
.rundown__treat:empty { display: none; }
.rundown__tools { display: flex; gap: 8px; }
.rundown .key--ghost { border-color: var(--ink-2); color: var(--ink); }
.rundown .key--ghost:hover { background: rgba(20,20,20,.06); }
.lyrics { display: grid; gap: 10px; padding: 14px; margin-bottom: 14px; border: 1px solid var(--paper-rule); background: #fbf9f4; }
.lyrics label { color: var(--ink-2); }
.lyrics textarea { width: 100%; min-height: 260px; padding: 10px 12px; border: 1px solid var(--paper-rule); background: #fff; color: var(--ink); resize: vertical; line-height: 1.5; }
.lyrics .direction { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--paper-rule); background: #fff; color: var(--ink); }
.lyrics .direction::placeholder, .lyrics textarea::placeholder { color: var(--ink-2); opacity: .7; }
.lyrics__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lyrics__count { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ro { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ro th { text-align: left; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; padding: 0 10px 8px; border-bottom: 1px solid var(--ink); }
.ro td { padding: 9px 10px; border-bottom: 1px solid var(--paper-rule); vertical-align: top; }
.ro tr.ro__section td { padding: 22px 10px 6px; border-bottom: 1px solid var(--ink); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink); }
.ro tr.ro__section td small { font-family: var(--text); font-size: 14px; font-weight: 500; letter-spacing: .04em; text-transform: none; color: var(--ink-2); margin-left: 12px; white-space: nowrap; }
.ro__n { width: 44px; } .ro__in { width: 120px; } .ro__src { width: 64px; } .ro__dur { width: 110px; text-align: right; white-space: nowrap; } .ro__tally { width: 36px; }
.ro td.ro__dur { text-align: right; }
.ro .in-t { font-weight: 700; } .ro .in-b { color: var(--ink-2); display: block; }
.ro .cue { line-height: 1.45; }
.ro .cue[contenteditable]:focus { outline: 2px solid var(--amber); outline-offset: 2px; background: #fff; }
.ro .anchor { display: block; color: var(--ink-2); margin-top: 2px; }
/* per-scene re-render: a ghost key beside the VT chip, same height as the chip, only while a render desk is open;
   the SRC column widens for it so every row keeps one line and one height */
.ro .redo { display: none; height: 24px; margin-left: 6px; padding: 0 7px; border: 1px solid var(--paper-rule); border-radius: 2px; background: transparent; color: var(--ink-2); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; cursor: pointer; vertical-align: top; }
body[data-state="render"] .ro .redo { display: inline-block; }
body[data-state="render"] .ro .ro__src { width: 150px; }
.ro td.ro__src { white-space: nowrap; }
.ro .redo:hover { background: rgba(20,20,20,.06); color: var(--ink); border-color: var(--ink-2); }
.ro .redo:disabled { opacity: .45; cursor: not-allowed; }
.ro .src { display: inline-block; min-width: 40px; height: 24px; line-height: 18px; padding: 2px 7px; border: 1px solid var(--ink); border-radius: 2px; font-weight: 700; letter-spacing: .08em; text-align: center; vertical-align: top; }
.ro .src--vt { background: var(--ink); color: var(--paper); }
.ro .tally { display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--paper-rule); margin: 4px auto 0; }
.ro tr.is-air .tally { background: var(--red); }
.ro tr.is-next .tally { background: var(--green); }
.ro tr.is-done .tally { background: var(--chalk-2); }
.ro tr.is-air td { background: #fff; }
.ro tr.is-air td:first-child { box-shadow: inset 1px 0 0 var(--red); color: var(--red); }
.ro .seg { display: inline-block; margin-left: 8px; letter-spacing: .04em; color: var(--ink-2); }
.ro__empty { margin: 24px 0 0; color: var(--ink-2); }
body[data-state="onair"] .ro__empty, body[data-state="render"] .ro__empty { display: none; }

/* ---------- render desk ---------- */
.renderdesk { padding: 18px 22px 26px; }
.renderdesk__head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 22px; margin-bottom: 14px; }
.renderdesk__line { margin: 0; color: var(--chalk-2); }
/* the reason a clip failed, whole, on its own line under the status: amber, never truncated */
.renderdesk__why { grid-column: 1 / -1; margin: 0; color: var(--amber); }
.renderdesk__fmt, .setup__mode { display: inline-flex; gap: 0; border: 1px solid var(--chalk-3); border-radius: 3px; overflow: hidden; padding: 0; margin: 0; }
.fmt { position: relative; }
.fmt input { position: absolute; opacity: 0; pointer-events: none; }
.fmt span { display: inline-flex; align-items: center; height: 40px; padding: 0 14px; letter-spacing: .08em; color: var(--chalk-2); cursor: pointer; white-space: nowrap; border-right: 1px solid var(--chalk-3); }
.fmt:last-child span { border-right: 0; }
.fmt input:checked + span { background: var(--chalk); color: var(--ink); }
.fmt input:focus-visible + span { outline: 2px solid var(--amber); outline-offset: -2px; }
.jobs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.job { display: grid; grid-template-rows: auto auto; border: 1px solid var(--chalk-3); border-radius: 3px; overflow: hidden; background: var(--desk); }
.job__thumb { aspect-ratio: 16 / 9; background: #000; position: relative; }
.job__thumb video, .job__thumb canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.job__meta { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 7px 8px; font-variant-numeric: tabular-nums; }
.job__n { font-weight: 700; }
.job__state { color: var(--chalk-2); letter-spacing: .04em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job.is-running .job__state { color: var(--amber); }
.job.is-done .job__state { color: var(--green); }
.job.is-failed .job__state { color: var(--amber); }
.job__bar { grid-column: 1 / -1; height: 3px; background: var(--seam); }
.job__bar b { display: block; height: 100%; width: 0; background: var(--amber); }
.job.is-done .job__bar b { background: var(--green); width: 100%; }
/* every tile carries its RETAKE key so tiles stay one height; it lights only once the scene is done or failed */
.job__redo { grid-column: 1 / -1; height: 28px; margin: 2px 0 0; padding: 0 8px; border: 1px solid var(--chalk-3); border-radius: 2px; background: transparent; color: var(--chalk); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; }
.job__redo:hover:not(:disabled) { background: var(--desk-hi); border-color: var(--chalk-2); }
.job__redo:disabled { opacity: .35; cursor: default; }
.renderdesk__row { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.renderdesk__note { color: var(--chalk-2); }

/* ---------- footer, setup, toast, dropzone ---------- */
.foot { display: flex; justify-content: space-between; gap: 16px; padding: 12px 22px; border-top: 1px solid var(--seam); background: var(--desk); color: var(--chalk-2); }
.foot a { color: var(--chalk); }
.setupdlg { border: 1px solid var(--chalk-3); border-radius: 3px; background: var(--desk); color: var(--chalk); padding: 0; width: min(720px, 94vw); }
.setupdlg::backdrop { background: rgba(14,16,19,.8); }
.setup { display: grid; gap: 14px; padding: 22px; }
.setup__line { margin: 0; color: var(--chalk-2); }
.setup__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.setup__grid label { display: grid; gap: 4px; letter-spacing: .06em; text-transform: uppercase; color: var(--chalk-2); }
.setup__grid input, .setup__grid select { height: 38px; padding: 0 10px; border: 1px solid var(--chalk-3); border-radius: 3px; background: var(--seam); color: var(--chalk); font-size: 14px; letter-spacing: 0; text-transform: none; font: inherit; }
.setup__grid select { appearance: auto; }
.setup__grid[data-engine] { display: none; }
.setup__grid[data-engine].is-on { display: grid; }
.setup__h { margin: 18px 0 8px; font: 700 13px/1 'Barlow Condensed', sans-serif; letter-spacing: .14em; color: var(--amber); }
.setup__h:first-child { margin-top: 0; }
.setup__note { margin: 6px 0 10px; color: var(--chalk-2); font-variant-numeric: tabular-nums; min-height: 1.2em; }
.setup__hint { grid-column: 1 / -1; color: var(--chalk-2); font-size: 13px; line-height: 1.45; letter-spacing: 0; }
.setup__hint code { color: var(--chalk); }
.setup__probe { margin: 0; min-height: 1.4em; color: var(--chalk-2); font-variant-numeric: tabular-nums; }
.setup__row { display: flex; gap: 10px; justify-content: flex-end; }
.toast { position: fixed; right: 22px; bottom: 22px; transform: translateY(12px); opacity: 0; width: fit-content; max-width: min(92vw, 460px); padding: 10px 14px; background: var(--desk-hi); color: var(--chalk); border: 1px solid var(--chalk-2); border-radius: 3px; pointer-events: none; z-index: 50; }
.toast.is-on { opacity: 1; transform: translateY(0); }
.toast.is-warn { border-color: var(--amber); }
.dropzone { position: fixed; inset: 0; display: none; place-items: center; background: rgba(14,16,19,.85); z-index: 40; pointer-events: none; }
.dropzone span { font-family: var(--clock); font-weight: 700; font-size: var(--fs-clock); letter-spacing: .08em; color: var(--chalk); }
.is-dropping .dropzone { display: grid; }

/* ---------- motion rules ---------- */
@media (prefers-reduced-motion: reduce) {
  .prog b { transition: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .wall { grid-template-columns: 1fr; }
  .pvw { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  :root { --fs-clock: 28px; }
  .desk { grid-template-columns: auto 1fr; gap: 12px; padding: 10px 14px; }
  .toast { right: 4vw; left: 4vw; max-width: none; }
  .desk__line { display: none; }
  .wall, .clock, .rundown, .renderdesk, .foot { padding-left: 14px; padding-right: 14px; }
  .wall { gap: 10px; }
  .pvw { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .pvw { grid-template-rows: auto; }
  .mon--pvw { grid-template-rows: auto auto auto; }
  .mon--pvw .mon__screen { aspect-ratio: 16 / 9; height: auto; }
  .mon--pvw .mon__tally b { display: none; }
  .mon--pvw .mon__tally span, .mon--pvw .mon__cap span:last-child { display: block; }
  .mon--pvw .mon__cap span:first-child { display: none; }
  .mon--pvw .mon__tally, .mon--pvw .mon__cap { padding: 0 6px; justify-content: center; }
  .mon--pvw .mon__tally span { font-size: 0; }
  .mon--pvw .mon__tally span::before { content: attr(data-short); font-size: 14px; font-weight: 700; color: var(--chalk); }
  .foot { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .clock { flex-wrap: wrap; gap: 10px 16px; }
  .tc--sec { flex-basis: 100%; order: 10; min-width: 0; }
  .tc--sec b { white-space: normal; }
  .clock__right { margin-left: 0; flex-basis: 100%; order: 11; justify-content: space-between; }
  .rundown__head, .renderdesk__head { grid-template-columns: 1fr; }
  .rundown__tools { flex-wrap: wrap; }
  .ro thead { display: none; }
  .ro, .ro tbody, .ro tr, .ro td { display: block; width: auto; }
  .ro tr { display: grid; grid-template-columns: 44px minmax(0, 1fr) 36px; gap: 2px 8px; padding: 10px 0; border-bottom: 1px solid var(--paper-rule); }
  .ro td { padding: 0; border: 0; }
  .ro td.ro__n { grid-row: 1 / 3; font-weight: 700; }
  .ro td.ro__in { grid-column: 2; }
  .ro td.ro__cue { grid-column: 2; }
  .ro td.ro__src, .ro td.ro__dur { grid-column: 2; display: inline-block; margin-right: 10px; text-align: left; }
  .ro td.ro__tally { grid-column: 3; grid-row: 1 / 3; }
  .ro tr.ro__section { display: block; padding: 18px 0 6px; }
  .ro tr.ro__section td { padding: 0; border: 0; }
  .ro tr.ro__section td small { display: block; margin-left: 0; margin-top: 2px; }
  .ro .in-b { display: inline; margin-left: 6px; }
  .foot { flex-direction: column; gap: 4px; }
  .setup__grid { grid-template-columns: 1fr; }
}
