/* LVC Control — design: ../DESIGN.md. Tally colours mean one thing each: red on program, amber next,
   green in view / healthy. No web fonts (venue networks). */

:root {
  color-scheme: dark;
  --bg: #0e1319;
  --surface: #161d26;
  --surface-2: #1f2833;
  --surface-3: #283342;
  --line: #2e3a47;
  --line-strong: #4a5869;
  --text: #f4f7fa;
  --dim: #a9b6c4;
  --accent: #5cb8ff;
  --accent-ink: #031627;
  --red: #ff453a;
  --red-ink: #ffffff;
  --red-fill: #d92b20; /* red behind white text: 4.9:1 (the bright --red is for borders and tally) */
  --red-text: #ff8a80;
  --red-soft: rgba(255, 69, 58, 0.16);
  --amber: #ffb224;
  --amber-line: #ffb224; /* amber as a line or mark on the page background */
  --amber-ink: #1f1300;
  --amber-soft: rgba(255, 178, 36, 0.16);
  --green: #30d158;
  --green-ink: #03170a;
  --cut: #f4f7fa;
  --cut-ink: #0e1319;
  --plate: #ffffff;
  --plate-ink: #000000;
  --plate-line: transparent;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
  --bar-bg: rgba(14, 19, 25, 0.94);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --pad: 16px;
  --tap: 44px;
  --dock-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

/* Daylight: white, black ink, saturated tally — for snow glare */
:root[data-theme="daylight"] {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #edf1f5;
  --surface-3: #dde3ea;
  --line: #b8c2cd;
  --line-strong: #5e6b79;
  --text: #05090d;
  --dim: #3b4652;
  --accent: #0050b3;
  --accent-ink: #ffffff;
  --red: #d70015;
  --red-ink: #ffffff;
  --red-fill: #d70015;
  --red-text: #b00012;
  --red-soft: rgba(215, 0, 21, 0.1);
  --amber: #ffb224;
  --amber-line: #a15c00; /* 5.2:1 on white; the bright amber is 1.8:1 */
  --amber-ink: #1f1300;
  --amber-soft: rgba(255, 178, 36, 0.22);
  --green: #00873c;
  --green-ink: #ffffff;
  --cut: #05090d;
  --cut-ink: #ffffff;
  --plate: #ffffff;
  --plate-ink: #000000;
  --plate-line: #05090d;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  --bar-bg: rgba(255, 255, 255, 0.96);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 500 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 800; }
h2 { font-size: 16px; font-weight: 800; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
h3 { font-size: 13px; font-weight: 700; color: var(--dim); }
p { margin: 0; }
code { font-size: 12px; word-break: break-all; color: var(--dim); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ico { display: block; flex: none; }
.spacer { flex: 1; }
.muted { color: var(--dim); }
.small { font-size: 13px; }
.err { color: var(--red-text); font-weight: 600; }
.count { font-size: 13px; font-weight: 600; color: var(--dim); }
.hint { font-size: 13px; color: var(--dim); }
.num { text-align: right; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- layout ---- */
.wrap { padding: 20px max(var(--pad), var(--safe-r)) 32px max(var(--pad), var(--safe-l)); max-width: 1480px; margin: 0 auto; }
.grid { display: grid; gap: 16px; min-width: 0; }
.cols { display: grid; gap: 16px; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
@media (max-width: 1000px) { .cols { grid-template-columns: minmax(0, 1fr); } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; min-height: var(--tap); }
.page-head h1 { flex: 1; }

/* ---- top bar ---- */
.bar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px;
  padding: calc(6px + var(--safe-t)) max(12px, var(--safe-r)) 6px max(12px, var(--safe-l));
  background: var(--bar-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.01em; margin-right: 8px; }
.nav { display: flex; gap: 2px; min-width: 0; }
.nav button {
  background: none; border: 0; min-height: var(--tap); padding: 0 14px; border-radius: 10px;
  color: var(--dim); font-weight: 700; cursor: pointer; white-space: nowrap;
}
.nav button.on { color: var(--text); background: var(--surface-2); }
.bar-user { color: var(--dim); font-size: 14px; }
@media (max-width: 599px) {
  .brand-name, .bar-user { display: none; }
  .brand { margin-right: 0; }
  .nav { flex: 1; justify-content: space-around; }
  .nav button { padding: 0 10px; }
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: var(--tap); min-height: var(--tap);
  padding: 0 8px; background: none; border: 0; border-radius: 10px; color: var(--text); cursor: pointer; font-weight: 700;
}
.icon-btn:active { background: var(--surface-2); }

/* menu */
.menu { position: relative; }
.menu-scrim { position: fixed; inset: 0; z-index: 40; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 41; width: min(300px, calc(100vw - 24px));
  display: grid; gap: 4px; padding: 8px; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r); box-shadow: var(--shadow);
}
.menu-user { padding: 8px 10px; color: var(--dim); font-size: 14px; }
.menu-user b { color: var(--text); }
.menu-item { justify-content: flex-start; padding: 0 10px; border-radius: 10px; }
.menu .menu-item.btn { width: 100%; justify-content: flex-start; }

/* ---- status bits ---- */
.dot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--dim); vertical-align: middle; }
.dot.green { background: var(--green); } .dot.red { background: var(--red); }
.tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--dim);
  padding: 3px 10px; border: 1px solid var(--line-strong); border-radius: 99px; white-space: nowrap; line-height: 1.3;
}
.tag.live { color: var(--red-ink); background: var(--red-fill); border-color: var(--red-fill); letter-spacing: 0.04em; }
.tag.in { color: var(--green-ink); background: var(--green); border-color: var(--green); }
.tag.ok { color: var(--green); border-color: var(--green); }
.tag.bad { color: var(--red-text); border-color: var(--red); }
.tag.next { color: var(--amber-ink); background: var(--amber); border-color: var(--amber); }
.tally { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.tally.red { background: var(--red); } .tally.amber { background: var(--amber); box-shadow: 0 0 0 1.5px var(--amber-line); }

/* the bib plate: a race bib, the one decorative element */
.bib {
  display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 32px; padding: 0 6px;
  background: var(--plate); color: var(--plate-ink); border: 1.5px solid var(--plate-line); border-radius: 6px;
  font-weight: 900; font-size: 17px; letter-spacing: -0.02em; line-height: 1;
}
.bib.sm { min-width: 30px; height: 22px; font-size: 13px; border-radius: 4px; padding: 0 4px; vertical-align: 1px; }

.notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 14px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface-2);
}
.notice.err { border-color: var(--red); background: var(--red-soft); }
.notice.off-air { justify-content: space-between; }
.empty { color: var(--dim); padding: 14px; border: 1px dashed var(--line-strong); border-radius: var(--r); text-align: center; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 16px;
  border: 1.5px solid var(--line-strong); background: var(--surface-2); color: var(--text); border-radius: var(--r);
  font-size: 15px; font-weight: 700; cursor: pointer; white-space: nowrap; touch-action: manipulation; user-select: none;
}
.btn:active:not([disabled]) { transform: translateY(1px); filter: brightness(1.1); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red-text); }
.btn.danger:active:not([disabled]) { background: var(--red-fill); color: var(--red-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.ghost.danger-text, .danger-text { color: var(--red-text); }
.btn.go { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.btn.stop { background: var(--surface); border-color: var(--red); border-width: 2px; color: var(--red-text); }
.btn.lg { min-height: 56px; font-size: 17px; padding: 0 22px; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
@media (pointer: coarse) { .btn.sm { min-height: var(--tap); } }
.btn[disabled] { opacity: 0.4; cursor: default; }

/* switch: a checkbox drawn as a toggle */
input[type="checkbox"] { width: 24px; height: 24px; margin: 0; accent-color: var(--accent); flex: none; }
input.switch {
  appearance: none; -webkit-appearance: none; position: relative; width: 52px; height: 32px; border-radius: 99px;
  background: var(--surface-3); border: 1.5px solid var(--line-strong); cursor: pointer; transition: background 0.15s;
}
input.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 23px; height: 23px; border-radius: 50%;
  background: var(--text); transition: transform 0.15s;
}
input.switch:checked { background: var(--accent); border-color: var(--accent); }
input.switch:checked::after { transform: translateX(20px); background: var(--accent-ink); }
input.switch.big { width: 64px; height: 38px; }
input.switch.big::after { width: 29px; height: 29px; }
input.switch.big:checked::after { transform: translateX(26px); }

/* ---- forms ---- */
label { color: var(--dim); min-width: 0; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 700; }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); color: var(--text); font-size: 15px; cursor: pointer; }
input:not([type="checkbox"]):not([type="range"]):not([type="file"]), select {
  width: 100%; min-height: var(--tap); background: var(--surface-2); border: 1.5px solid var(--line-strong); color: var(--text);
  border-radius: 10px; padding: 0 12px; font-size: 16px; font-weight: 500; min-width: 0;
}
select { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
textarea {
  width: 100%; min-height: calc(var(--tap) * 2); background: var(--surface-2); border: 1.5px solid var(--line-strong); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 16px; font-weight: 500; min-width: 0; resize: vertical;
}
input::placeholder, textarea::placeholder { color: var(--dim); opacity: 0.8; }
.split-row { padding: 10px 0; border-top: 1px solid var(--line); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.file input { width: 100%; font-size: 15px; color: var(--dim); }
.file input::file-selector-button {
  min-height: var(--tap); margin-right: 12px; padding: 0 16px; border-radius: var(--r); border: 1.5px solid var(--line-strong);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 700; cursor: pointer;
}
.fields { display: grid; gap: 12px 14px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); align-items: end; }
.fields.wide { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.fields .span2 { grid-column: span 2; }
@media (max-width: 420px) {
  .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fields.wide { grid-template-columns: minmax(0, 1fr); }
  .split-row > .row { grid-column: 1 / -1; justify-content: flex-end; }
}

/* ---- cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px;
  display: grid; gap: 12px; min-width: 0; align-content: start;
}
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head h2 { flex: 1; }
.add-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; }
.add-form:has(> .field:only-of-type) { grid-template-columns: minmax(0, 420px) auto; justify-content: start; }
@media (max-width: 699px) { .add-form, .add-form:has(> .field:only-of-type) { grid-template-columns: minmax(0, 1fr); } }

/* ---- login ---- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px max(var(--pad), var(--safe-r)) 24px max(var(--pad), var(--safe-l)); }
.login-card { width: min(400px, 100%); display: grid; gap: 16px; }
.login-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.login-head h1 { font-size: 26px; }
.login .btn { width: 100%; margin-top: 4px; }
.center { display: grid; place-items: center; min-height: 70vh; padding: 24px; }

/* ---- events list ---- */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list-row {
  width: 100%; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 12px 10px 16px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); color: var(--text); cursor: pointer;
}
.list-row:active { background: var(--surface-2); }
@media (hover: hover) { .list-row:hover { border-color: var(--line-strong); background: var(--surface-2); } }
.lr-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.lr-title { font-weight: 800; font-size: 16px; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.lr-sub { color: var(--dim); font-size: 14px; }
.list-row .ico { color: var(--dim); }

/* ---- event header + tabs ---- */
.ev-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ev-head .back { margin-left: -8px; color: var(--accent); }
.ev-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; }
.ev-title h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.ev-sub { color: var(--dim); font-size: 14px; }
.media { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--dim);
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; white-space: nowrap; }
.media-state { font-weight: 500; }
.ev-menu { display: none; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: var(--r); overflow-x: auto; scrollbar-width: none; width: max-content; max-width: 100%; }
.tabs button {
  background: none; border: 0; color: var(--dim); min-height: 40px; padding: 0 18px; border-radius: 9px;
  font-size: 15px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.tabs button.on { color: var(--text); background: var(--surface); box-shadow: 0 1px 0 var(--line-strong), 0 0 0 1px var(--line); }

/* ---- tables ---- */
.tbl-wrap { overflow-x: auto; margin: 0 -4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--dim); font-weight: 700; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl .c-act { text-align: right; white-space: nowrap; }
.tbl .c-act .btn + .btn { margin-left: 6px; }
.tbl .who { width: 100%; }
.tbl.ranks td { padding: 5px 8px; }
.tbl.ranks .rank { width: 1%; font-weight: 800; white-space: nowrap; }
.tbl tr.muted td { color: var(--dim); }
.tbl tr.invalid td { color: var(--dim); }
.runs .c-time { font-weight: 800; font-size: 15px; }
.tbl.runs .c-who { min-width: 7em; overflow-wrap: anywhere; } /* a long name wraps: the table must fit a tablet */
.sheet-who { font-size: 0.8em; font-weight: 700; color: var(--dim); overflow-wrap: anywhere; }
.standing { display: grid; gap: 4px; }

/* tables become cards on a phone */
@media (max-width: 899px) {
  .tbl.cards thead { display: none; }
  .tbl.cards, .tbl.cards tbody { display: block; }
  .tbl.cards tr {
    display: grid; gap: 4px 12px; padding: 12px; margin-bottom: 8px; align-items: center;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
  }
  .tbl.cards td { display: block; padding: 0; border: 0; min-width: 0; text-align: left; }
  .tbl.cards td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 700; color: var(--dim); }
  .tbl.cards td:empty { display: none; }
  .tbl.cards .c-act { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-start; }
  .tbl.cards .c-act .btn + .btn { margin-left: 0; }
  .tbl.cards .c-act .btn { flex: 1 1 auto; }

  .tbl.cards.runs tr { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "bib who act" "bib time act" "bib start act" "bib finish act" "bib splits act"; gap: 0 12px; padding: 10px 12px; }
  .tbl.cards.runs .c-who { grid-area: who; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tbl.cards.runs .c-bib { grid-area: bib; align-self: start; }
  .tbl.cards.runs .c-time { grid-area: time; font-size: 20px; line-height: 1.2; }
  .tbl.cards.runs .c-status { grid-area: time; justify-self: start; align-self: center; }
  .tbl.cards.runs tr:has(.c-time:not(:empty)) .c-status { justify-self: end; }
  .tbl.cards.runs .c-start, .runs .c-finish, .runs .c-splits { font-size: 13px; color: var(--dim); }
  .tbl.cards.runs .c-start { grid-area: start; }
  .tbl.cards.runs .c-finish { grid-area: finish; }
  .tbl.cards.runs .c-splits { grid-area: splits; }
  .tbl.cards.runs td[data-label]::before { display: inline-block; min-width: 46px; font-size: 12px; }
  .tbl.cards.runs .c-act { grid-area: act; align-self: center; flex-direction: column; }
  .tbl.cards.runs .c-act .btn { flex: 0 0 auto; min-width: 76px; }
  .tbl.cards.tags tr { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "bib tag status" "bib from secs" "act act act"; }
  .tbl.cards.tags .c-bib { grid-area: bib; align-self: start; }
  .tbl.cards.tags .c-tag { grid-area: tag; font-weight: 700; }
  .tbl.cards.tags .c-status { grid-area: status; justify-self: end; }
  .tbl.cards.tags .c-from { grid-area: from; }
  .tbl.cards.tags .c-secs { grid-area: secs; text-align: right; }
  .tbl.cards.tags .c-act { grid-area: act; margin-top: 6px; }

  .tbl.cards.cams-tbl tr { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .tbl.cards.cams-tbl .c-name { font-size: 17px; }
  .tbl.cards.cams-tbl .c-event { overflow-wrap: anywhere; }

  .tbl.cards.users-tbl tr { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "name name" "created by" "act act"; }
  .tbl.cards.users-tbl .c-name { grid-area: name; font-size: 17px; }
  .tbl.cards.users-tbl .c-created { grid-area: created; }
  .tbl.cards.users-tbl .c-by { grid-area: by; }
  .tbl.cards.users-tbl .c-act { grid-area: act; margin-top: 6px; }
}
.users-tbl .c-name .tag, .c-name .tag { margin-left: 8px; }
.c-online { white-space: nowrap; }
.c-settings div { white-space: nowrap; }

.entries .c-bib { width: 1%; }
/* athlete photos (FIS) in the start list: a 40 px round thumbnail, an empty ring without one */
.entries .c-photo { width: 1%; padding-right: 0; }
.athlete-photo { display: block; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; object-position: 50% 15%; background: var(--surface-2); border: 1px solid var(--line); }
.athlete-photo.none { border-style: dashed; }
.athlete-photo.pending { border-color: var(--accent); border-style: solid; }
.entries .c-fis { font-variant-numeric: tabular-nums; color: var(--dim); white-space: nowrap; }
.entries .c-act { width: 1%; white-space: nowrap; }
.photo-bar { margin-bottom: 10px; }
.name-note { font-size: 13px; font-weight: 600; }
.ph-only { display: none; }
@media (max-width: 899px) {
  /* the stored start list as cards: bib and photo left, name over category · nation · FIS code, re-check right */
  .tbl.cards.roster tr { grid-template-columns: auto auto auto auto minmax(0, 1fr) auto; grid-template-areas: "bib photo who who who act" "bib photo cat nat fis act"; gap: 2px 10px; padding: 10px 12px; }
  .tbl.cards.roster .c-bib { grid-area: bib; }
  .tbl.cards.roster .c-photo { grid-area: photo; }
  .tbl.cards.roster .who { grid-area: who; font-weight: 700; font-size: 16px; }
  .tbl.cards.roster .c-cat { grid-area: cat; color: var(--dim); }
  .tbl.cards.roster .c-nat { grid-area: nat; color: var(--dim); }
  .tbl.cards.roster .c-fis { grid-area: fis; }
  .tbl.cards.roster .c-act { grid-area: act; }
  .tbl.cards.roster .c-act .btn { flex: 0 0 auto; }
  .ph-only { display: inline; }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- timing stats ---- */
.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 2px; align-content: start; }
.stat-k { font-size: 13px; font-weight: 700; color: var(--dim); }
.stat-v { font-size: 28px; font-weight: 800; line-height: 1.1; }
.stat-v.sm { font-size: 20px; }
.stat-n { font-size: 13px; color: var(--dim); }
@media (max-width: 699px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat.wide { grid-column: 1 / -1; }
}

/* ---- settings form ---- */
.settings { display: grid; gap: 16px; }
.fs { gap: 14px; }
.slot { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.slot-head { display: flex; align-items: center; gap: 8px; }
.slot-head b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-head .spacer { display: none; }
.slot-n {
  display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 8px;
  background: var(--surface-3); font-weight: 800;
}
.slot-n.wide { font-size: 13px; }
.danger-zone { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); }
.save-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; gap: 10px;
  margin: 0 calc(-1 * var(--pad)); padding: 12px var(--pad) calc(12px + var(--safe-b));
  background: var(--bar-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.save-bar .btn.primary { min-width: 160px; }
@media (max-width: 599px) { .save-bar .btn { flex: 1; } }

/* ---- sheets (pairing QR, remote setting) ---- */
.sheet-back {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, 0.6);
}
.sheet {
  width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow: auto; display: grid; gap: 14px; justify-items: stretch;
  padding: 20px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 20px; box-shadow: var(--shadow);
}
.sheet h2 { font-size: 20px; }
.sheet .qr { justify-self: center; }
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; }
@media (max-width: 599px) {
  .sheet-back { place-items: end stretch; padding: 0; }
  .sheet { width: 100%; border-radius: 20px 20px 0 0; padding: 20px max(var(--pad), var(--safe-r)) calc(20px + var(--safe-b)) max(var(--pad), var(--safe-l)); }
  .sheet-actions .btn { flex: 1; }
}
/* result corrections (Timing tab): the run editor sheet */
.sheet.wide { width: min(640px, 100%); }
.sheet-actions .grow { flex: 1; }
.field.invalid input { border-color: var(--red); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; font-weight: 500; }
.chip {
  min-height: 36px; padding: 0 10px; border: 1px dashed var(--line-strong); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; font-variant-numeric: tabular-nums; cursor: pointer;
}
.c-status .tag + .tag { margin-left: 6px; }
.tbl.corrections td { font-size: 13px; vertical-align: top; }
@media (max-width: 599px) {
  .sheet-actions { flex-wrap: wrap; }
  .sheet-actions .grow { display: none; }
  .sheet-actions .btn.danger { flex-basis: 100%; order: 3; }
  .tbl.corrections tr { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .tbl.corrections td { padding: 0; border: 0; }
  .tbl.corrections td:nth-child(3), .tbl.corrections td:nth-child(4) { grid-column: 1 / -1; }
}
.qr { background: #fff; width: max-content; max-width: 100%; padding: 8px; border-radius: 12px; }
.qr svg { display: block; width: min(260px, 70vw); height: auto; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + var(--safe-b)); transform: translateX(-50%); z-index: 200;
  max-width: calc(100% - 32px); width: max-content; padding: 12px 18px; border-radius: var(--r);
  background: var(--text); color: var(--bg); font-weight: 700; font-size: 15px; box-shadow: var(--shadow);
}
body:has(.dock) .toast { bottom: calc(var(--dock-h) + 16px + var(--safe-b)); }

/* ---- cockpit ---- */
.cockpit { display: grid; gap: 16px; }
.ck-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 12px 14px; }
.ck-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ck-group + .ck-group { padding-left: 16px; border-left: 1px solid var(--line); }
.stream-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stream-btns.big { display: grid; grid-template-columns: minmax(0, 1fr); }
.stream-btns.big .force { margin-top: 20px; }
.auto { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: var(--tap); }
.auto-label { font-size: 18px; font-weight: 800; color: var(--text); }
.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); }
.seg button { min-height: 38px; padding: 0 16px; border: 0; border-radius: 9px; background: none; color: var(--dim); font-weight: 700; cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
@media (pointer: coarse) { .seg button { min-height: var(--tap); } }
.sheet .seg { display: flex; }
.sheet .seg button { flex: 1; }
.signals { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sig-row { display: flex; gap: 8px; min-width: 0; }
.sig-row .sig { width: 200px; }

.ck-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
@media (max-width: 1180px) { .ck-grid { grid-template-columns: minmax(0, 1fr) 320px; } }
.ck-main, .ck-side { display: grid; gap: 16px; min-width: 0; align-content: start; }
.ck-side { position: sticky; top: 72px; }
/* tablet landscape, small laptop: the program takes two of three columns and the first camera sits
   beside it, the others in rows below, so the first Cut button is above the fold */
@media (min-width: 900px) and (max-width: 1279px) {
  .ck-main { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .ck-main > .tile.pgm { grid-column: span 2; }
  .ck-main > .cams { display: contents; }
  .ck-main > :not(.tile):not(.cams) { grid-column: 1 / -1; }
  /* a tighter frame: the second row of Cut buttons fits a 768 px tall screen too */
  .wrap { padding-top: 12px; }
  .grid.event, .cockpit, .ck-grid { gap: 12px; }
  .ck-bar { padding: 8px 12px; gap: 8px 14px; }
}
@media (min-width: 1100px) and (max-width: 1279px) {
  .ck-main { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* wide: program left, the cameras beside it in two columns, every Cut button above the fold */
@media (min-width: 1280px) {
  .ck-main { grid-template-columns: minmax(0, 5fr) minmax(0, 4fr); align-items: start; }
  .ck-main > .tile.pgm { width: 100%; grid-column: 1; grid-row: 1; }
  .ck-main > .cams { grid-column: 2; grid-row: 1 / span 3; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .ck-main > :not(.tile):not(.cams) { grid-column: 1; }
}

/* tiles */
.tile { position: relative; background: #000; border: 3px solid #000; outline: 1px solid var(--line); border-radius: var(--r); overflow: hidden; aspect-ratio: 16 / 9; color: #fff; }
.tile video { width: 100%; height: 100%; display: block; object-fit: cover; background: #000; }
.tile .ph { width: 100%; height: 100%; display: grid; place-items: center; color: #8d99a6; font-size: 13px; text-align: center; padding: 8px; }
.tile.pgm { border-color: var(--red); outline: 0; }
.tile.pgm.idle { border-color: #000; outline: 1px solid var(--line); }
.badges { position: absolute; z-index: 2; top: 8px; left: 8px; right: 8px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.badge { font-size: 12px; font-weight: 800; letter-spacing: 0.05em; padding: 4px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.7); color: #fff; line-height: 1.2; }
.badge.pgm { background: var(--red-fill); color: #fff; }
.badge.armed { background: var(--amber); color: var(--amber-ink); }
.badge.inview { background: var(--green); color: #03170a; }
.badge.conn { position: absolute; top: 8px; right: 8px; background: rgba(0, 0, 0, 0.75); color: #ffd0cc; letter-spacing: 0; font-weight: 700; }
.tile .lost { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.85); color: #ff8a80; font-weight: 900; letter-spacing: 0.08em; font-size: 15px; }
.tile .cap {
  position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px; padding: 18px 10px 8px;
  font-size: 14px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
}
.cap .cam-n { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 5px; background: rgba(255, 255, 255, 0.92); color: #000; font-weight: 900; font-size: 13px; }
.cap .name { font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cap .st { color: #c5ced8; font-size: 12px; }
.pgm-info {
  position: absolute; left: 10px; right: 10px; bottom: 26px; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; background: rgba(0, 0, 0, 0.72);
}
.pgm-who { flex: 1; min-width: 0; display: grid; font-size: 14px; }
.pgm-who b { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pgm-who span { color: #c5ced8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pgm-info .clock { font-size: 40px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.pgm-info .bib { --plate-line: transparent; }
.pgm-vu { position: absolute; left: 10px; right: 10px; bottom: 8px; display: flex; align-items: center; gap: 8px; }
.pgm-vu .vu { flex: 1; }
.pgm-vu .st { font-size: 12px; color: #c5ced8; white-space: nowrap; }

.cams { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.cam { display: grid; gap: 8px; align-content: start; }
.cam.onair .tile { border-color: var(--red); outline: 0; }
.cam.next .tile { border-color: var(--amber); outline: 2px solid var(--amber-line); outline-offset: -1px; }
.btn.cut { min-height: 52px; font-size: 18px; font-weight: 900; background: var(--cut); border-color: var(--cut); color: var(--cut-ink); letter-spacing: 0.01em; }
.cam.onair .btn.cut[disabled] { opacity: 1; background: var(--red-fill); border-color: var(--red); color: #fff; }
.cam.next .btn.cut:not([disabled]) { box-shadow: 0 0 0 3px var(--amber-line); }
.btn.cut.pip-btn { background: var(--surface-2); border-color: var(--line-strong); color: var(--text); font-size: 16px; }
.cam.pip.onair .btn.cut.pip-btn { border-color: var(--red); }

/* mixer */
.mixer-row { display: grid; grid-template-columns: auto minmax(0, 1fr) 44px; grid-template-areas: "mute slider vol" "vu vu vu"; gap: 6px 10px; align-items: center; }
.mixer-row .mixer-name { grid-area: name; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mixer-row:has(.mixer-name) { grid-template-columns: auto minmax(0, 1fr) 44px; grid-template-areas: "name name name" "mute slider vol" "vu vu vu"; padding: 10px 0; border-top: 1px solid var(--line); }
.mixer-row.prog { grid-template-columns: 112px minmax(0, 1fr); grid-template-areas: "name vu"; border-top: 0; padding: 0; }
.mixer-row.prog.bus { border-top: 1px solid var(--line); padding-top: 10px; }
.mixer-row .mute { grid-area: mute; min-width: var(--tap); padding: 0 10px; }
.mixer-row .mute.on { background: var(--red-fill); border-color: var(--red-fill); color: #fff; }
.mixer-row input[type="range"] { grid-area: slider; width: 100%; height: var(--tap); margin: 0; accent-color: var(--accent); }
.mixer-vol { grid-area: vol; text-align: right; font-size: 13px; color: var(--dim); }
.mixer-row .vu { grid-area: vu; }
.mixer-row.muted-row .vu { opacity: 0.5; }
.vu { height: 8px; border-radius: 4px; background: #05080b; border: 1px solid var(--line); overflow: hidden; }
.vu-fill { height: 100%; background: linear-gradient(90deg, var(--green) 70%, var(--amber) 88%, var(--red)); }
.vu-fill.clip { background: var(--red); }

/* race panels */
.run {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 10px; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.run .who { display: grid; min-width: 0; }
.run .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run .sub { color: var(--dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run .sub:empty { display: none; }
.run .clock { font-weight: 800; font-size: 20px; letter-spacing: -0.01em; }
.run .rank { font-weight: 900; font-size: 17px; min-width: 32px; }
.run .gap { color: var(--dim); font-size: 13px; min-width: 44px; text-align: right; }
.run.fin .clock { font-size: 16px; }
.run.out { grid-template-columns: auto minmax(0, 1fr) auto; }
.run.followed { margin: 0 -10px; padding: 8px 10px; border-radius: 10px; border-top-color: transparent; background: var(--red-soft); box-shadow: inset 4px 0 0 var(--red); }
.run.followed + .run { border-top-color: transparent; }
.btn.dnf { min-height: 48px; min-width: 72px; font-weight: 900; }
.btn.undo { min-height: var(--tap); }
.next-starter { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.log { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 14px; color: var(--dim); }
.details summary { cursor: pointer; font-weight: 700; padding: 11px 0; line-height: 22px; margin: -11px 0; }
.details { font-size: 14px; gap: 6px; }

/* ---- phone & tablet portrait ---- */
@media (max-width: 899px) {
  .wrap { padding-top: 12px; }
  .shell.in-event .bar { display: none; }
  .ev-menu { display: block; margin-right: -8px; }
  .back-label { display: none; }
  .ev-head { gap: 6px; }
  .ev-title { display: grid; gap: 0; }
  .ev-title h1 { font-size: 17px; line-height: 1.2; white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
  .ev-sub { font-size: 13px; }
  .media-state { display: none; }
  .media { padding: 4px 8px; }
  .tabs { width: 100%; }
  .tabs button { flex: 1; padding: 0 8px; min-height: var(--tap); }
}
@media (max-width: 380px) { .tabs button { font-size: 14px; padding: 0 4px; } }
/* five tabs (Cockpit, Timing, Start list, Scenes, Settings) on a 320 px phone */
/* six tabs (Recordings, 2026-11-29): the tight tabs from 419 px down, not only below 360 */
@media (max-width: 419px) { .tabs { gap: 2px; } .tabs button { font-size: 13px; padding: 0 2px; letter-spacing: -0.01em; } }
@media (max-width: 359px) { .media-label { display: none; } }
@media (max-width: 599px) { .ev-head.running .media-label { display: none; } }

/* the phone cockpit: sticky strip, panes, dock */
.cockpit.phone { gap: 12px; padding-bottom: calc(var(--dock-h) + 12px + var(--safe-b)); }
.ck-strip {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  margin: 0 calc(-1 * var(--pad)); padding: calc(8px + var(--safe-t)) var(--pad) 8px;
  background: var(--bar-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.strip-info { flex: 1; min-width: 0; display: grid; font-size: 14px; font-weight: 700; line-height: 1.35; }
.strip-info > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strip-info .muted { font-weight: 500; }
.strip-info .short, .tabs .short { display: none; }
/* six event tabs fit a phone only with the Recordings tab short */
@media (max-width: 599px) { .tabs .long { display: none; } .tabs .short { display: inline; } }
@media (max-width: 419px) { .strip-info .long { display: none; } .strip-info .short { display: inline; } }
.onair-pill {
  min-height: var(--tap); min-width: 72px; padding: 0 12px; border-radius: 10px; border: 1.5px solid var(--line-strong);
  background: var(--surface-2); color: var(--dim); font-weight: 800; cursor: pointer; white-space: nowrap;
}
.onair-pill.live { background: var(--red-fill); border-color: var(--red-fill); color: #fff; letter-spacing: 0.06em; }
.pane { display: grid; gap: 12px; min-width: 0; }
.cockpit.phone .cams { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
/* tablet portrait: three cameras across, so every camera's Cut button is above the fold (768x1024) */
@media (min-width: 600px) and (min-height: 501px) { .cockpit.phone .cams { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.cockpit.phone .tile .cap { padding: 14px 6px 5px; font-size: 13px; gap: 6px; }
.cockpit.phone .tile .cap { flex-wrap: wrap; row-gap: 0; }
.cockpit.phone .tile .cap .st { order: -1; flex-basis: 100%; text-align: right; font-size: 11px; line-height: 1.3; }
.cockpit.phone .badges { top: 5px; left: 5px; right: 5px; gap: 4px; }
.cockpit.phone .badge { font-size: 11px; padding: 3px 6px; }
.cockpit.phone .lost { font-size: 13px; }
.cockpit.phone .pgm-info { left: 6px; right: 6px; bottom: 20px; padding: 6px 8px; gap: 8px; }
.cockpit.phone .pgm-info .clock { font-size: 30px; }
.cockpit.phone .pgm-who b { font-size: 15px; }
.cockpit.phone .pgm-who span { font-size: 12px; }
.cockpit.phone .pgm-vu { left: 6px; right: 6px; bottom: 6px; }
.cockpit.phone .btn.cut { font-size: 17px; }
.cockpit.phone .notice.off-air .btn { width: 100%; }
.cockpit.phone .signals { display: grid; grid-template-columns: minmax(0, 1fr); }
.cockpit.phone .sig-row .sig { width: auto; flex: 1; }
.cockpit.phone .seg { display: flex; }
.cockpit.phone .seg button { flex: 1; min-height: var(--tap); }
.cockpit.phone .run { gap: 8px; padding: 10px 0; }
.cockpit.phone .run .clock { font-size: 22px; }
.cockpit.phone .run.fin .clock { font-size: 16px; }
.cockpit.phone .run.followed { margin: 0 -8px; padding: 10px 8px; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l); min-height: calc(var(--dock-h) + var(--safe-b));
  background: var(--bar-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line-strong);
}
.dock button {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--dock-h); background: none; border: 0; color: var(--dim); font-size: 12px; font-weight: 800; cursor: pointer;
}
.dock button.on { color: var(--accent); }
.dock button.on::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
.dock-badge {
  position: absolute; top: 7px; left: calc(50% + 6px); min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 12px; line-height: 20px; text-align: center;
}
.dock-live { position: absolute; top: 9px; left: calc(50% + 10px); width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--bg); }

/* phone in landscape: the event header and the tabs share a row, the program sits left of the
   cameras (three across), so the first row of Cut buttons is on screen */
@media (max-width: 899px) and (max-height: 500px) and (orientation: landscape) {
  .wrap { padding-top: 6px; }
  .event { grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 8px; }
  .event > :not(.ev-head):not(.tabs) { grid-column: 1 / -1; }
  .event > .tabs { width: auto; }
  .event > .tabs button { flex: none; padding: 0 12px; }
  .ev-sub { display: none; }
  .cockpit.phone { --dock-h: 52px; gap: 8px; }
  .ck-strip { padding-top: calc(4px + var(--safe-t)); padding-bottom: 4px; }
  .dock button { flex-direction: row; gap: 8px; font-size: 13px; }
  .dock-badge, .dock-live { position: static; }
  .cams-pane { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); align-items: start; gap: 10px; }
  .cams-pane > :not(.tile):not(.cams) { grid-column: 1 / -1; }
  .cockpit.phone .cams-pane > .cams { grid-column: 2; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .cockpit.phone .cams-pane .btn.cut { min-height: 48px; font-size: 16px; }
  .cockpit.phone .pgm-info .clock { font-size: 22px; }
  .cockpit.phone .pgm-info .bib { min-width: 32px; height: 26px; font-size: 14px; }
  .cockpit.phone .pgm-who b { font-size: 13px; }
}

/* D21: the start replay planned, in the cockpit's director card */
.replay-plan { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0; padding: 6px 8px; border-radius: 6px; background: var(--amber-soft); border: 1px solid var(--amber-line); }

/* Cameras table on a small laptop or tablet landscape (900-1099 px): the actions wrap inside their cell instead of pushing the
   table past the screen (it overflowed by 69 px) */
@media (min-width: 900px) and (max-width: 1099px) {
  .tbl.cams-tbl .c-act, .tbl.cams-tbl th, .tbl.cams-tbl .c-online { white-space: normal; }
  .tbl.cams-tbl .c-event { overflow-wrap: anywhere; }
  .tbl.cams-tbl .c-act .btn { margin: 3px 0 3px 6px; }
}

/* ---- scenes on the stream (the race, start list, results, advertising) ---- */
/* the scene on air is the program: red, as every on-program tally */
.seg.scenes button.on { background: var(--red-fill); color: var(--red-ink); }
.cockpit.phone .seg.scenes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cockpit.phone .seg.scenes button { padding: 0 6px; line-height: 1.15; }

/* ---- Scenes tab: uploads, background, advertising queue, next start ---- */
.media-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.media-item { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.media-item .thumb { width: 64px; height: 36px; border-radius: 6px; background: #000; overflow: hidden; display: grid; place-items: center; color: var(--dim); font-size: 12px; font-weight: 700; }
.media-item .thumb img, .media-item .thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-item .mi-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.media-item .mi-sub { display: block; font-weight: 500; font-size: 13px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-item .mi-act { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.media-item.off { opacity: 0.55; }
/* a video's name on a button: never wider than the screen */
.btn.add-media { max-width: 100%; overflow: hidden; text-overflow: ellipsis; display: inline-block; line-height: 40px; }
.media-item.on-bg { border-color: var(--accent); }
.upload-bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.upload-bar i { display: block; height: 100%; background: var(--accent); }
@media (max-width: 599px) {
  .media-item { grid-template-columns: 56px minmax(0, 1fr); }
  .media-item .thumb { width: 56px; height: 32px; }
  .media-item .mi-act { grid-column: 1 / -1; justify-content: flex-start; }
}

/* ---- cockpit: Commentary card ---- */
.cc-link { display: block; padding: 10px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; overflow-wrap: anywhere; }
.cc-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.cc-list li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.cc-list li.muted-voice { opacity: 0.65; }
.cc-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--line-strong); }
.cc-dot.on { background: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 25%, transparent); }
.cc-name { min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.cc-sub { display: block; font-size: 13px; font-weight: 500; color: var(--dim); }
.dest-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.dest-list li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.dest-name { min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.dest-dot { width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; background: var(--line-strong); }
.dest-dot.sending { background: var(--green); }
.dest-dot.starting { background: var(--amber); }
.dest-dot.retrying { background: var(--red); }
.settings .dest { display: grid; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line); }
.settings h3.sub { margin: 14px 0 4px; font-size: 15px; }
.cc-meters { grid-column: 1 / -1; display: grid; gap: 4px; }
.cc-meter { display: grid; grid-template-columns: 9.5em minmax(0, 1fr); gap: 8px; align-items: center; font-size: 13px; color: var(--dim); }
.cc-bus { margin: 2px 0 8px; font-weight: 700; color: var(--text); }
.cc-act { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cc-act input[type=range] { flex: 1 1 140px; min-width: 0; accent-color: var(--accent); min-height: var(--tap); }

/* ---- recordings (recordings.tsx): status, runs × cameras, downloads, delete ---- */
.err-text { color: var(--red-text); }
.warn-text { color: var(--amber-line); }
.ok-text { color: var(--green); }
.rec-status { display: grid; gap: 6px; }
.rec-summary { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; font-weight: 600; }
.rec-summary .dot { margin-right: 4px; }
.rec-cams { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.rec-cams li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.rec-cam-name { font-weight: 700; }
.rec-controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; margin: 4px 0 12px; }
.rec-cam-picks { display: flex; flex-wrap: wrap; gap: 0 16px; }
.rec-margins { display: flex; gap: 12px; }
.rec-margins .field input { width: 7em; }
.rec-runs .c-pick { width: 1%; }
.rec-runs .c-pick .check { min-height: 0; }
.rec-runs .c-bib { width: 1%; }
.rec-runs .c-start, .rec-runs .c-end, .rec-runs .c-run, .rec-runs .c-cov { white-space: nowrap; font-variant-numeric: tabular-nums; }
.rec-runs tr.muted .c-who { color: var(--dim); }
.rec-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 12px -16px -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line); border-radius: 0 0 var(--r) var(--r);
}
.rec-sum { flex: 1 1 14em; min-width: 0; }
.rec-del-preview { display: grid; gap: 10px; margin-top: 10px; }
.rec-delete .fields { margin-top: 8px; }
@media (max-width: 899px) {
  /* a run as a card: choose, bib and name on top, then run · start · end, then one cell per camera */
  .tbl.cards.rec-runs tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
  .tbl.cards.rec-runs .c-pick { flex: none; width: auto; }
  .tbl.cards.rec-runs .c-pick .check { min-height: var(--tap); }
  .tbl.cards.rec-runs .c-bib { flex: none; width: auto; }
  .tbl.cards.rec-runs .c-who { flex: 1 1 50%; font-weight: 700; overflow-wrap: anywhere; }
  .tbl.cards.rec-runs .c-run { flex: 0 0 auto; }
  .tbl.cards.rec-runs .c-start, .tbl.cards.rec-runs .c-end { flex: 1 1 28%; }
  .tbl.cards.rec-runs .c-cov { flex: 1 1 40%; }
  .rec-bar .btn { flex: 1 1 auto; }
  .rec-bar { margin: 12px -12px -12px; padding-left: 12px; padding-right: 12px; }
}

/* ---- what is wrong right now (FAILURES.md P0-2, P0-3, P0-5): above everything in the cockpit ----
   Floating at the bottom of the screen, over the page, not in its flow (2026-12-02): an alert that
   comes or goes must not move the scene, Cut and Finish buttons under the operator's pointer, and
   clicks go through it to whatever is underneath. The cockpit leaves room below its last card. */
.ck-alerts { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(960px, calc(100vw - 32px)); z-index: 50; display: grid; gap: 8px; pointer-events: none; }
.ck-alert { padding: 10px 14px; border-radius: var(--r-sm); font-weight: 700; line-height: 1.35; border: 2px solid; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45); }
.ck-alert.red { background: var(--red-fill); border-color: var(--red-fill); color: var(--red-ink); }
.ck-alert.amber { background: linear-gradient(var(--amber-soft), var(--amber-soft)), var(--surface); border-color: var(--amber-line); color: var(--text); }
.cockpit:has(.ck-alerts) { padding-bottom: 140px; }
.cockpit.phone .ck-alerts { bottom: 8px; width: calc(100vw - 16px); }
.onair-pill.broken { background: var(--surface); border-color: var(--red); color: var(--red-text); animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .onair-pill.broken { animation: none; } }
.pgm-vu .st.out { white-space: nowrap; }
.pgm-vu .st.out.red { color: var(--red-text); font-weight: 800; }
.pgm-vu .st.out.amber { color: var(--amber); }
.timer-age { font-size: 13px; margin: -4px 0 4px; }
.run.oncourse { grid-template-columns: auto minmax(0, 1fr) auto auto auto; }
.run .fin-btn { min-height: 36px; padding: 0 10px; }

/* hold-to-stop: a fill runs across while held; letting go early does nothing */
.btn.hold { position: relative; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.btn.hold .hold-fill { position: absolute; inset: 0; width: 0; background: var(--red-fill); }
.btn.hold.holding .hold-fill { width: 100%; transition: width var(--hold-ms, 1500ms) linear; }
.btn.hold .hold-text { position: relative; }
.btn.hold.holding { color: var(--red-ink); }

/* the output stage on the slate (FAILURES.md P1-2): said on the program tile, where the operator looks */
.tile .badge.slate-on { position: absolute; left: 8px; bottom: 34px; background: var(--amber); color: var(--amber-ink); font-weight: 900; }

/* Start list: "From FIS live timing" under the file picker (fis-live.ts) */
.row.fis-live { align-items: end; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.row.fis-live .field { flex: 1 1 260px; margin: 0; }
.row.fis-live .field.run { flex: 0 0 110px; }
.row.fis-live .field.run select { min-width: 100px; }
