:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e8eaef;
  --muted: #8b93a3;
  --ok: #3ccf6e;
  --warn: #f5b631;
  --over: #ff5a5a;
  --accent: #4c8dff;
  --early: #5ab0ff;
  --on-accent: #fff;
  --current-bg: #1b2a1f;
  --ok-soft: #183a26;
  --over-soft: #451c1c;
  --early-soft: #16304a;
  --ok-line: #24563a;
  --warn-line: #5a4a1c;
  --over-line: #5a2424;
  --scrim: rgba(0, 0, 0, .6);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

/* Themes (picked per device; see theme.js). "Match device" = no data-theme. */
:root[data-theme="light"] {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --panel-2: #eceef2;
  --line: #d6dae1;
  --text: #14171c;
  --muted: #5d6573;
  --ok: #12813a;
  --warn: #a96400;
  --over: #cf2626;
  --accent: #2f6fe0;
  --early: #1c66c0;
  --on-accent: #fff;
  --current-bg: #e1f3e6;
  --ok-soft: #dcf2e3;
  --over-soft: #fbe3e3;
  --early-soft: #dfeafb;
  --ok-line: #9fd6b2;
  --warn-line: #e6c48a;
  --over-line: #eeaaaa;
  --scrim: rgba(20, 23, 28, .45);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f3f4f6;
    --panel: #ffffff;
    --panel-2: #eceef2;
    --line: #d6dae1;
    --text: #14171c;
    --muted: #5d6573;
    --ok: #12813a;
    --warn: #a96400;
    --over: #cf2626;
    --accent: #2f6fe0;
    --early: #1c66c0;
    --on-accent: #fff;
    --current-bg: #e1f3e6;
    --ok-soft: #dcf2e3;
    --over-soft: #fbe3e3;
    --early-soft: #dfeafb;
    --ok-line: #9fd6b2;
    --warn-line: #e6c48a;
    --over-line: #eeaaaa;
    --scrim: rgba(20, 23, 28, .45);
    color-scheme: light;
  }
}
:root[data-theme="contrast"] {
  --bg: #000;
  --panel: #000;
  --panel-2: #121212;
  --line: #5a5a5a;
  --text: #fff;
  --muted: #d0d0d0;
  --ok: #2bff7a;
  --warn: #ffd21f;
  --over: #ff4040;
  --accent: #4d94ff;
  --early: #5cc8ff;
  --on-accent: #000;
  --current-bg: #00321a;
  --ok-soft: #00321a;
  --over-soft: #3d0000;
  --early-soft: #002640;
  --ok-line: #2bff7a;
  --warn-line: #ffd21f;
  --over-line: #ff4040;
  --scrim: rgba(0, 0, 0, .8);
  color-scheme: dark;
}
.link-btn { background: none; border: 0; padding: 6px 8px; color: var(--muted); font-size: 14px; }
.link-btn:hover { color: var(--text); }
.card.release { width: min(560px, 94vw); max-height: 86vh; overflow: auto; gap: 10px; }
.release-head { display: flex; justify-content: space-between; align-items: center; }
.release-head .close { background: none; border: 0; color: var(--muted); padding: 4px 8px; }
.card.release h2 { font-size: 20px; margin: 0; }
.card.release ul { margin: 10px 0 0; padding-left: 18px; display: grid; gap: 8px; line-height: 1.4; }
.card.release section { background: none; border: 0; padding: 0; border-radius: 0; }
.card.release .rel.older { border-top: 1px solid var(--line); padding-top: 10px; opacity: .8; }
/* Intercom message banner (all screens) and the Control composer */
section.msg { background: var(--early-soft); border-color: var(--early); }
section.msg p { margin: 4px 0 0; font-size: clamp(20px, 2.6vw, 40px); font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
section.msg .label { color: var(--early); }
section.msg.urgent { background: var(--over-soft); border-color: var(--over); animation: msg-pulse 1.2s ease-in-out infinite; }
section.msg.urgent .label { color: var(--over); }
@keyframes msg-pulse { 50% { box-shadow: 0 0 0 4px var(--over); } }
@media (prefers-reduced-motion: reduce) { section.msg.urgent { animation: none; box-shadow: 0 0 0 3px var(--over); } }
body.stage section.msg p { font-size: min(5vw, 8vh); }
section.msg .msg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
section.msg .ack { padding: 6px 16px; font-weight: 700; background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
section.msg .seen-tag { color: var(--ok); font-weight: 700; font-size: 14px; }
body.stage section.msg .ack { font-size: min(2vw, 3.5vh); }
.send-msg .seen { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; font-size: 13px; }
.send-msg .seen-sum { flex: 1 1 100%; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.tag.st-live { color: var(--ok); border-color: var(--ok-line); }
.tag.st-paused { color: var(--muted); }
.set-row input { min-width: 170px; }
.send-msg { display: grid; gap: 6px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.send-msg #msgText { flex: 1 1 200px; min-width: 0; }
.send-msg .urgent-pick { display: flex; align-items: center; gap: 4px; color: var(--over); white-space: nowrap; }
.send-msg .quick button { padding: 4px 10px; font-size: 13px; }
.send-msg .row { margin: 0; }
.send-msg .live-msg { padding-top: 6px; border-top: 1px solid var(--line); }
/* Monitor mix requests (Dodi / Alex) */
body.mix-page { min-height: 100%; }
.mix { flex: 1; display: grid; grid-template-columns: minmax(110px, 16vw) 1fr; gap: 14px; padding: 14px; min-height: 0; }
.mix-side { display: grid; grid-template-rows: 1fr 1fr; gap: 14px; }
.mix-side.alex { grid-template-rows: auto auto; align-content: start; }
.mix .mode { font-size: clamp(22px, 3vw, 40px); font-weight: 800; border-width: 3px; border-radius: 16px; line-height: 1.2; }
.mix .mode.more { color: var(--ok); border-color: var(--ok-line); }
.mix .mode.less { color: var(--over); border-color: var(--over-line); }
.mix .mode.more.on { background: var(--ok); color: var(--bg); border-color: var(--ok); }
.mix .mode.less.on { background: var(--over); color: var(--bg); border-color: var(--over); }
.mix-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.mix-hint { margin: 0; color: var(--muted); font-size: 16px; min-height: 1.4em; }
.mix-hint.warn { color: var(--warn); font-weight: 700; }
.mix-grid { flex: 1; display: grid; grid-template-rows: 1fr 1fr; gap: 12px; min-height: 0; }
.mix-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.mix .ch { min-height: 96px; border-radius: 14px; border-width: 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 8px; font-size: clamp(16px, 2vw, 26px); font-weight: 700; text-align: center; }
.mix .ch .badge { font-size: .7em; font-weight: 800; white-space: nowrap; padding: 2px 10px; border-radius: 999px; background: var(--bg); }
.mix .ch.req-more { background: var(--ok-soft); border-color: var(--ok); }
.mix .ch.req-more .badge { color: var(--ok); }
.mix .ch.req-less { background: var(--over-soft); border-color: var(--over); }
.mix .ch.req-less .badge { color: var(--over); }
.mix .ch.just-done { border-color: var(--early); }
.mix .ch.just-done .badge { color: var(--early); }
.mix .ch.spare { opacity: .35; }
.mix-count { font-size: 22px; font-weight: 800; }
.mix-queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mix-queue li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 18px; }
.mix-queue li.req-more strong { color: var(--ok); }
.mix-queue li.req-less strong { color: var(--over); }
/* Alex: the service card beside the request buttons, in a compact size */
.mix.alex-layout { grid-template-columns: minmax(110px, 13vw) minmax(0, 1fr) minmax(280px, 30vw); }
.mix-board { min-width: 0; }
.board.compact { padding: 0; gap: 10px; overflow: visible; }
.board.compact section { padding: 12px 14px; }
.board.compact .now h1 { font-size: clamp(18px, 1.8vw, 28px); }
.board.compact .count { font-size: clamp(40px, 4.5vw, 72px); }
.board.compact .now-main { gap: 10px; }
.board.compact .next h2 { font-size: clamp(16px, 1.5vw, 22px); }
.board.compact .totals { grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.board.compact .totals .v { font-size: 18px; }
.board.compact .totals > div:last-child { grid-column: 1 / -1; }
.board.compact section.msg p { font-size: clamp(18px, 1.8vw, 26px); }
@media (max-width: 1100px) {
  .mix.alex-layout { grid-template-columns: minmax(110px, 16vw) minmax(0, 1fr); }
  .mix.alex-layout .mix-board { grid-column: 1 / -1; order: -1; }
  .board.compact { display: grid; grid-template-columns: 2fr 1fr; align-items: start; }
  .board.compact section.msg, .board.compact .totals { grid-column: 1 / -1; }
  .board.compact .totals { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
  .board.compact .totals > div:last-child { grid-column: auto; }
}
@media (max-width: 700px) {
  .mix.alex-layout { grid-template-columns: 1fr; }
  .board.compact { grid-template-columns: 1fr; }
}
.beep-pick { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; }
@media (orientation: portrait) and (min-width: 701px) and (max-width: 1100px) {
  body[data-page="dodi"] .mix { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  body[data-page="dodi"] .mix-side { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
  body[data-page="dodi"] .mix .mode { padding: 22px; }
  body[data-page="dodi"] .mix-row { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 1fr; }
}
@media (max-width: 700px) {
  .mix { grid-template-columns: 1fr; }
  .mix-side { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
  .mix .mode { padding: 14px; }
  .mix-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mix-grid { grid-template-rows: none; }
  .mix .ch { min-height: 76px; }
}

/* Placeholder views (Dodi, Alex) */
.empty-view { flex: 1; display: grid; place-content: center; text-align: center; padding: 24px; }
.empty-view h1 { margin: 0; font-size: clamp(32px, 6vw, 64px); }
.empty-view p { margin: 8px 0 0; font-size: 18px; }

/* Settings window and the per-device options it drives */
html[data-text="large"] .board, html[data-text="large"] .sheet { zoom: 1.15; }
html[data-text="xl"] .board, html[data-text="xl"] .sheet { zoom: 1.32; }
html[data-hide-notes] .notes { display: none; }
.card.settings { width: min(520px, 94vw); max-height: 88vh; overflow: auto; gap: 6px; }
.card.settings h2 { margin: 0; font-size: 20px; }
.card.settings > p { margin: 0 0 4px; font-size: 13px; }
.card.settings h3 { margin: 14px 0 4px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.set-row > span:first-child { display: grid; gap: 2px; }
.set-row small { color: var(--muted); font-size: 12px; }
.set-row select { min-width: 170px; }
.card.settings .row { margin-top: 12px; }
.stage-gear { position: fixed; top: 8px; left: 8px; z-index: 5; background: var(--panel); border-color: var(--line); color: var(--muted); font-size: 18px; padding: 4px 10px; opacity: 0; transition: opacity .3s; }
body.show-gear .stage-gear, .stage-gear:focus-visible { opacity: 1; }
.theme-pick { padding: 4px 6px; font-size: 13px; color: var(--muted); background: var(--panel-2); }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; touch-action: manipulation;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.danger { color: var(--over); }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
a { color: var(--early); }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0; }
.err { color: var(--over); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }

/* header */
.top {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.top nav { display: flex; gap: 6px; align-items: center; }
.top nav a { padding: 6px 10px; text-decoration: none; color: var(--muted); }
.top .tab { background: none; border-color: transparent; color: var(--muted); }
.top .tab.active { color: var(--text); border-color: var(--line); background: var(--panel-2); }
.wall { font-variant-numeric: tabular-nums; color: var(--muted); }
.conn { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); flex: none; }
.conn.on { background: var(--ok); }
.conn.off { background: var(--over); }
.conn.paused { background: var(--muted); }

/* layout */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.board, .ctl-col { padding: 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0; overflow: auto; }
.ctl-col .board { padding: 0; overflow: visible; }
.sheet-wrap { overflow: auto; border-left: 1px solid var(--line); }
/* board */
section { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; }
.label { font-size: 13px; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.now-main { display: flex; align-items: baseline; gap: 20px; justify-content: space-between; flex-wrap: wrap; }
.now h1 { font-size: clamp(28px, 4vw, 52px); margin: 4px 0; line-height: 1.1; overflow-wrap: anywhere; }
.count { font-size: clamp(56px, 9vw, 120px); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.count.ok { color: var(--ok); }
.count.warn { color: var(--warn); }
.count.over { color: var(--over); }
.count.muted { color: var(--muted); }
.bar { height: 8px; background: var(--panel-2); border-radius: 4px; margin: 14px 0 10px; overflow: hidden; }
.bar > div { height: 100%; background: var(--ok); transition: width .25s linear; }
.bar > div.over { background: var(--over); }
.now-meta, .next-meta { color: var(--muted); font-variant-numeric: tabular-nums; }
.notes:empty { display: none; }
.notes { margin-top: 12px; display: grid; gap: 6px; }
.note { display: grid; grid-template-columns: minmax(80px, max-content) 1fr; gap: 12px; background: var(--panel-2); border-radius: 8px; padding: 8px 12px; }
.note span { color: var(--muted); }
.note p { margin: 0; white-space: pre-wrap; }
.next h2 { font-size: clamp(22px, 3vw, 36px); margin: 4px 0; }
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; align-items: center; }
.totals .k { display: block; color: var(--muted); font-size: 13px; }
.totals .v.elapsed { color: var(--early); }
.totals .v { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.totals .v.delta { white-space: nowrap; }
.totals .v.delta.ok { color: var(--ok); }
.totals .v.delta.late { color: var(--over); }
.totals .v.delta.early { color: var(--early); }
.chip { display: inline-block; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 18px; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.late { background: var(--over-soft); color: var(--over); }
.chip.early { background: var(--early-soft); color: var(--early); }

/* run sheet */
.sheet { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sheet th { position: sticky; top: 0; background: var(--panel); text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); }
.sheet td { padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.sheet td.title { white-space: normal; width: 100%; }
.sheet .num { text-align: right; }
.sheet .adj { color: var(--warn); font-size: 12px; margin-left: 4px; }
.sheet .t { color: var(--muted); }
.sheet tr.hdr td { background: var(--panel-2); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 13px; color: var(--muted); }
.sheet tr.done td { color: var(--muted); }
.sheet tr.done .title { text-decoration: line-through; text-decoration-color: var(--line); }
.sheet tr.skipped td { color: var(--muted); opacity: .5; }
.sheet tr.current td { background: var(--current-bg); color: var(--text); }
.sheet tr.current td:first-child { box-shadow: inset 4px 0 0 var(--ok); }
.sheet td.actual.over { color: var(--over); }
.control .sheet tbody tr:not(.hdr) { cursor: pointer; }
.control .sheet tbody tr:not(.hdr):hover td { background: var(--panel-2); }

/* control */
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; }
.switch span { width: 44px; height: 24px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); position: relative; flex: none; transition: background .15s; }
.switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); background: var(--on-accent); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.controls { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.controls.small { grid-template-columns: repeat(4, 1fr); }
.controls .big { font-size: 22px; padding: 18px; border-radius: 12px; }
@media (max-width: 600px) { .controls.small { grid-template-columns: repeat(2, 1fr); } }
.pane { flex: 1; overflow: auto; padding: 16px; max-width: 1200px; width: 100%; margin: 0 auto; }
.edit-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.edit-head input { min-width: 280px; margin-left: 6px; }
.editor { width: 100%; border-collapse: collapse; }
.editor th { text-align: left; color: var(--muted); font-size: 12px; padding: 4px 6px; }
.editor td { padding: 4px 6px; vertical-align: top; }
.editor input, .editor textarea { width: 100%; }
.editor textarea { resize: vertical; min-height: 34px; }
.editor .len { width: 80px; }
.editor .bad { border-color: var(--over); }
.editor tr.hdr input[data-f="title"] { font-weight: 700; text-transform: uppercase; }
.editor .mv { white-space: nowrap; }
.plan-bar { padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.plan-bar select { margin-left: 6px; min-width: 260px; }
#activePlan { max-width: 340px; }
#activePlan:disabled { opacity: .7; }
.editor .mv button, .editor td:last-child button { padding: 4px 8px; }
.overlay { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: var(--bg); display: grid; place-items: center; z-index: 10; }
/* control stays hidden until the login is confirmed */
body.locked main, body.locked .top > :not(.conn):not(strong) { visibility: hidden; }
.overlay[hidden] { display: none; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: grid; gap: 12px; width: min(360px, 92vw); }
.card h2 { margin: 0; }
.card p { margin: 0; font-size: 18px; }
.overlay.dim { background: var(--scrim); z-index: 15; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 8px; z-index: 20; }

/* stage: one big confidence display */
body.stage { padding: 2vh 3vw; height: 100vh; height: 100dvh; overflow: hidden; }
body.stage > .conn { position: fixed; top: 10px; right: 10px; }
body.stage .stage-clock { text-align: center; font-size: min(4vw, 7vh); font-size: clamp(18px, min(4vw, 7vh), 64px); font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1; margin-bottom: 1.5vh; }
/* Sized by the smaller of width and height so any screen shape works; the fit
   check in stage.html then shrinks it further if it still doesn't fit. */
body.stage .stage-fit { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
body.stage .board { flex: none; padding: 0; overflow: visible; gap: 2vh; }
html body.stage .board { zoom: 1; } /* the fit check sets zoom, not the Text size rule */
body.stage .now h1 { font-size: min(6vw, 9vh); }
body.stage .count { font-size: min(18vw, 30vh); }
body.stage .notes { display: none; }
body.stage .next h2 { font-size: min(4vw, 6.5vh); }
body.stage .totals .v { font-size: min(3vw, 5vh); }
body.stage .chip { font-size: min(2.4vw, 4vh); }

/* Tablets upright and phones: run sheet as two-line cards
   (title + length, then start → end + actual) */
@media (max-width: 1000px) {
  .sheet, .sheet tbody { display: block; }
  .sheet thead { display: none; }
  .sheet tr { display: grid; grid-template-columns: auto auto 1fr auto; grid-template-areas: "title title title len" "start end . actual"; column-gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .sheet tr.hdr { display: block; padding: 0; }
  .sheet td { padding: 0; border: 0; background: none !important; box-shadow: none !important; }
  .sheet tr.hdr td { display: block; padding: 8px 12px; background: var(--panel-2) !important; }
  .sheet tr.current { background: var(--current-bg); box-shadow: inset 4px 0 0 var(--ok); }
  .sheet td.sched { display: none; }
  .sheet td.title { grid-area: title; font-size: 16px; }
  .sheet td.len { grid-area: len; }
  .sheet td.start { grid-area: start; font-size: 13px; }
  .sheet td.end { grid-area: end; font-size: 13px; }
  .sheet td.end:not(:empty)::before { content: '→ '; }
  .sheet td.actual { grid-area: actual; font-size: 13px; }
}
/* Tablets upright: keep two columns (timer/controls left, run sheet right) */
@media (min-width: 641px) and (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
  .control .top .wall { display: none; }
  .board .count { font-size: clamp(56px, 11vw, 110px); }
  .controls.small button { padding: 8px 6px; font-size: 14px; }
}

/* phones */
@media (max-width: 640px) {
  html, body { height: auto; }
  body { display: block; }
  .top { position: sticky; top: 0; z-index: 5; padding: 8px 12px; gap: 4px 8px; flex-wrap: wrap; }
  .top strong { flex: 1 1 0; }
  body:not(.control) .top nav { flex: 1 1 100%; order: 3; margin: 0 -8px; }
  .top strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .top [data-st], .top .wall { display: none; }
  .link-btn { font-size: 13px; padding: 6px 4px; white-space: nowrap; }
  .top nav { gap: 0; flex: none; }
  .top nav a, .top .tab { padding: 6px 8px; font-size: 14px; }
  .layout { display: block; overflow: visible; }
  .board, .ctl-col { padding: 12px; gap: 10px; overflow: visible; }
  section { padding: 14px 16px; border-radius: 10px; }
  .now-main { display: block; }
  .now h1 { font-size: 26px; }
  .count { font-size: 72px; margin-top: 4px; }
  .now-meta { font-size: 13px; }
  .note { grid-template-columns: 1fr; gap: 2px; }
  .next h2 { font-size: 20px; }
  .totals { grid-template-columns: 1fr 1fr; gap: 10px 12px; }
  .totals .v { font-size: 20px; }
  .totals > div:last-child { grid-column: 1 / -1; }
  .chip { font-size: 16px; }

  .sheet-wrap { border: 0; overflow: visible; }

  /* control: big Prev/Next pinned to the bottom of the screen */
  .control .ctl-col { padding-bottom: 96px; }
  .control .controls:first-child { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
  .control .controls .big { padding: 14px; font-size: 20px; }
  .controls.small { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .controls.small button { padding: 8px 4px; font-size: 13px; }
  .control .hint { display: none; }
  .pane { padding: 12px; }
  .edit-head input { min-width: 0; width: 100%; margin: 4px 0 0; }
  .edit-head label { flex: 1 1 100%; }
  .editor thead { display: none; }
  .editor, .editor tbody { display: block; }
  .editor tr { display: grid; grid-template-columns: auto 1fr 80px auto; grid-template-areas: 'mv type len del' 'title title title title' 'notes notes notes notes'; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .editor td { padding: 0; }
  .editor td:nth-child(1) { grid-area: mv; }
  .editor td:nth-child(2) { grid-area: type; }
  .editor td:nth-child(3) { grid-area: title; }
  .editor td:nth-child(4) { grid-area: len; }
  .editor td:nth-child(5) { grid-area: notes; }
  .editor td:nth-child(6) { grid-area: del; }
  .plan-bar select { min-width: 0; width: 100%; margin: 4px 0 0; }
  .plan-bar label { flex: 1 1 100%; }
  #activePlan { max-width: 55vw; }
  .editor .len { width: 70px; }
/* control header: title + service time, then a scrollable tab row */
  .control .top { flex-wrap: wrap; }
  .control .top .spacer { display: none; }
  .control .top nav { flex: 1 1 100%; overflow-x: auto; }
  .control .top nav a { display: none; }
  .control .top select { margin-left: auto; }

  /* stage on a phone */
  body.stage { padding: 12px; }
  body.stage .now h1 { font-size: 28px; }
  body.stage .count { font-size: 18vw; }
  body.stage .next h2 { font-size: 22px; }
  body.stage .totals .v { font-size: 20px; }
  body.stage .chip { font-size: 16px; }
}

