:root {
  --bg: #0d1014;
  --panel: #161b22;
  --panel-2: #1d232c;
  --line: #2b333d;
  --ink: #e6edf3;
  --dim: #90a0b0;
  --accent: #4ea1ff;
  --s1: #3fb950;
  --s2: #d9a441;
  --s3: #f0616d;
  --off: #39414c;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif; }
body { padding: 0 0 env(safe-area-inset-bottom); }

header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
header h1 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: .2px; }
header .spacer { flex: 1; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--off); flex: none; }
.dot.on { background: var(--s1); box-shadow: 0 0 8px var(--s1); }
.dot.warn { background: var(--s2); }
.dot.err { background: var(--s3); }

/* minmax(0,1fr), not the default auto: a grid item refuses to shrink below its
   content's min-content width, so one nowrap guest URL widened every card and
   pushed the page into horizontal scroll. */
main { padding: 1px 12px 12px; max-width: 720px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }

/* Controls beside the picture, not under it: the whole point is to watch the
   image change while dragging. The stage takes 70% so the frame fits on screen. */
.camwrap { display: flex; gap: 8px; align-items: flex-start; }
.camwrap .stage { flex: 0 0 70%; min-width: 0; }   /* exactly 70%, gap comes off the controls */
.camctl { flex: 1 1 auto; min-width: 0; display: block; }
.camctl .lbl { margin: 3px 0 0; font-size: 10px; }
.camctl .lbl:first-child { margin-top: 0; }
.camctl .single { gap: 5px; }
/* a range input carries an intrinsic minimum width; without min-width:0 the
   column refuses to shrink and the readouts slide under the picture. */
.camctl .single input { height: 22px; min-width: 0; }
.camctl .single output { min-width: 26px; font-size: 10px; }

/* Exact entry for a control whose range spans five orders of magnitude. */
.nudge { margin-top: 5px; }
.nudge input {
  width: 100%; background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 4px;
  font-size: 14px; font-variant-numeric: tabular-nums; text-align: center;
  -moz-appearance: textfield;
}
.nudge input::-webkit-outer-spin-button,
.nudge input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.nudge-btns { display: flex; gap: 4px; margin-top: 4px; }
button.btn.nb { flex: 1; padding: 8px 2px; font-size: 12px; min-width: 0; }
button.btn.nb:active { background: var(--accent); border-color: var(--accent); color: #04121f; }
/* .lbl and .single set display, which beats the UA rule for [hidden] - without
   this, a control the phone does not support would still be drawn. */
[hidden] { display: none !important; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.card h2 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--dim); font-weight: 600; }

.stage { position: relative; background: #000; border-radius: 12px; overflow: hidden; line-height: 0; }
.stage video { width: 100%; display: block; background: #000; }
.stage .badge { position: absolute; top: 8px; left: 8px; z-index: 2;
  background: rgba(0,0,0,.62); border-radius: 6px; padding: 3px 8px;
  font-size: 11px; letter-spacing: .04em; line-height: 1.6; }
.stage .badge.right { left: auto; right: 8px; }
.stage.hit { outline: 3px solid var(--s3); outline-offset: -3px; }
.stage .stagedot { position: absolute; left: 8px; bottom: 8px; z-index: 2;
  box-shadow: 0 0 0 2px rgba(0,0,0,.5); }

button.btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  border-radius: 9px; padding: 11px 16px; font-size: 15px; font-weight: 600; cursor: pointer;
}
button.btn.primary { background: var(--accent); border-color: var(--accent); color: #04121f; }
button.btn:disabled { opacity: .45; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.meter { height: 6px; background: var(--off); border-radius: 3px; overflow: hidden; margin: 6px 0 2px; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .08s linear; }
.kv { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); }
.kv b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---- dual slider ---- */
.dual { margin: 14px 0 4px; }
.dual-track { position: relative; height: 34px; touch-action: none; outline: none; }
.dual-seg { position: absolute; top: 11px; height: 12px; background: var(--off);
  border-radius: 3px; transition: background .15s, box-shadow .15s; }
.dual-seg span { position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  font-size: 10px; color: var(--dim); letter-spacing: .06em; white-space: nowrap; }
.dual-seg.s1.on { background: var(--s1); box-shadow: 0 0 10px var(--s1); }
.dual-seg.s2.on { background: var(--s2); box-shadow: 0 0 10px var(--s2); }
.dual-seg.s3.on { background: var(--s3); box-shadow: 0 0 10px var(--s3); }
.dual-seg.on span { color: var(--ink); }
.dual-handle { position: absolute; top: 3px; width: 28px; height: 28px; margin-left: -14px;
  border-radius: 50%; border: 2px solid var(--ink); background: var(--panel-2);
  touch-action: none; cursor: grab; padding: 0; }
.dual-handle:active { cursor: grabbing; transform: scale(1.08); }
.dual-marker { position: absolute; top: 6px; width: 2px; height: 22px; margin-left: -1px;
  background: #fff; border-radius: 1px; pointer-events: none; box-shadow: 0 0 6px #fff; }
.dual-readout { display: flex; justify-content: space-between; font-size: 11px; color: var(--dim);
  font-variant-numeric: tabular-nums; }

/* ---- single slider ---- */
.single { display: flex; align-items: center; gap: 10px; }
.single input { flex: 1; accent-color: var(--accent); height: 30px; }
.single.off { opacity: .4; }
.single input:disabled { cursor: not-allowed; }
.single output { font-size: 12px; color: var(--dim); min-width: 46px; text-align: right;
  font-variant-numeric: tabular-nums; }

label.lbl { font-size: 12px; color: var(--dim); display: block; margin: 10px 0 0; }

/* ---- log ---- */
.log { max-height: 300px; overflow: auto; margin: 0; padding: 0; list-style: none;
  font-variant-numeric: tabular-nums; }
.log li { display: flex; gap: 8px; align-items: center; padding: 7px 2px;
  border-bottom: 1px solid var(--line); font-size: 12.5px; }
.log li:last-child { border-bottom: 0; }
.tag { font-weight: 700; font-size: 11px; border-radius: 5px; padding: 2px 7px; flex: none; color: #04121f; }
.tag.A, .tag.D { background: var(--s1); }
.tag.B, .tag.E { background: var(--s2); }
.tag.C, .tag.F { background: var(--s3); }
.log .t { color: var(--dim); flex: none; }
.log .sc { margin-left: auto; color: var(--dim); flex: none; }
.log img { width: 46px; height: 34px; object-fit: cover; border-radius: 4px; flex: none; }
.log a { color: var(--accent); text-decoration: none; flex: none; }

.note { font-size: 12px; color: var(--dim); margin: 8px 0 0; }
.err { color: var(--s3); }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---- segmented buttons (focus mode) ---- */
button.btn.seg { flex: 1; padding: 10px 8px; font-size: 14px; }
button.btn.seg.on { background: var(--accent); border-color: var(--accent); color: #04121f; }
button.btn.seg:disabled { opacity: .3; }

/* ---- blackout ---- */
#blackout {
  position: fixed; inset: 0; z-index: 9999; background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; touch-action: none; -webkit-user-select: none; user-select: none;
}
#blackout[hidden] { display: none; }
#blackout .bo-dot {
  width: 5px; height: 5px; border-radius: 50%; background: #f0616d;
  animation: bo-pulse 3.5s ease-in-out infinite;
}
#blackout .bo-hint { color: #333; font-size: 12px; animation: bo-fade 6s forwards; }
@keyframes bo-pulse { 0%, 100% { opacity: .06; } 50% { opacity: .3; } }
@keyframes bo-fade  { 0% { opacity: .8; } 70% { opacity: .8; } 100% { opacity: 0; } }

/* ---- guest client rows ---- */
.clients { list-style: none; margin: 0; padding: 0; }
.clients li { border-bottom: 1px solid var(--line); padding: 12px 2px; }
.clients li:last-child { border-bottom: 0; }
.cl-top { display: flex; align-items: center; gap: 9px; }
.cl-name { font-weight: 600; }
.cl-state { font-size: 11px; border-radius: 5px; padding: 2px 8px; flex: none;
  background: var(--off); color: var(--dim); }
.cl-state.on { background: var(--s1); color: #04121f; }
/* muted is a state worth spotting from across the list, like stopped is */
.cl-state.muted { background: var(--s3); color: #04121f; }
.btn.muted { border-color: var(--s3); color: var(--s3); }
.cl-live { margin-left: auto; font-size: 11px; color: var(--dim); }
.cl-live.on { color: var(--s1); }
.cl-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.cl-actions .btn { padding: 6px 11px; font-size: 13px; font-weight: 500; }
.cl-segs { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 9px; align-items: center; }
.cl-segs .lab { font-size: 11px; color: var(--dim); margin-right: 3px;
  min-width: 38px; }
/* the owner is not a guest: no link, no remove, and it reads as its own block */
.clients li.owner { background: var(--panel-2); border-radius: 10px; padding: 12px;
  margin-bottom: 6px; border-bottom: 0; }
.seg-chip { font-size: 11px; font-weight: 700; border-radius: 5px; padding: 4px 9px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--dim); cursor: pointer; }
.seg-chip.on { color: #04121f; border-color: transparent; }
.seg-chip.on[data-seg="A"], .seg-chip.on[data-seg="D"] { background: var(--s1); }
.seg-chip.on[data-seg="B"], .seg-chip.on[data-seg="E"] { background: var(--s2); }
.seg-chip.on[data-seg="C"], .seg-chip.on[data-seg="F"] { background: var(--s3); }

input.txt { flex: 1; min-width: 120px; background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: 15px; }
input.txt::placeholder { color: var(--dim); }

/* ---- guest notification feed ---- */
.notes { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
.notes li { display: flex; gap: 9px; align-items: center; padding: 9px 2px;
  border-bottom: 1px solid var(--line); font-size: 13px; font-variant-numeric: tabular-nums; }
.notes li:last-child { border-bottom: 0; }
.notes li.fresh { animation: note-in .5s ease; }
@keyframes note-in { from { background: rgba(78,161,255,.16); } to { background: transparent; } }
.paused { display: flex; align-items: center; justify-content: center; position: absolute;
  inset: 0; background: rgba(0,0,0,.86); color: var(--dim); font-size: 14px; text-align: center;
  padding: 20px; z-index: 3; }

.cl-link { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.cl-link code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 9px; font-size: 11.5px; color: var(--accent);
  -webkit-user-select: all; user-select: all; }
.cl-link .copy { flex: none; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--dim); border-radius: 7px; padding: 7px 11px; font-size: 12px; cursor: pointer; }

/* ---- diagnostics ---- */
.verdict { font-size: 15px; line-height: 1.5; margin: 0 0 14px; }
.verdict.good { color: var(--s1); }
.verdict.warn { color: var(--s2); }
.verdict.bad  { color: var(--s3); }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 2px;
  border-bottom: 1px solid var(--line); font-size: 13.5px; }
.checks li:last-child { border-bottom: 0; }
.checks .mark { flex: none; width: 18px; font-weight: 700; }
.checks .ok   { color: var(--s1); }
.checks .warn { color: var(--s2); }
.checks .bad  { color: var(--s3); }
.checks .run  { color: var(--dim); }
.checks .what { flex: 1; }
.checks .what small { display: block; color: var(--dim); margin-top: 3px; font-size: 12px; }
pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 11px; font-size: 11px; color: var(--dim); overflow-x: auto; white-space: pre-wrap;
  word-break: break-all; margin: 0; }

.stage img#relayImg { width: 100%; display: block; background: #000; }
.stage img#relayImg[hidden] { display: none; }
.badge.relay { color: var(--s2); }

/* ==========================================================================
   The phone: a transmitter with five controls
   Held sideways an Oppo A80 gives about 785x393 CSS pixels, and everything
   here is about that. No page-width cap: 720px left an empty gutter down both
   sides. The controls take a column of their own width, and the picture is
   bounded by the *height* of the screen instead of 70% of its width - sized
   off the width it swallows the screen and still forces a scroll.
   ========================================================================== */
button.btn.wide { width: 100%; }
.camerapage main { max-width: none; padding: 6px 10px 8px; gap: 8px; }
/* sideways the display cutout is on one side: keep clear of it */
body.camerapage {
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.camerapage button.btn.wide { margin: 5px 0 0; padding: 9px 12px; }
.camerapage .camctl { flex: 0 0 auto; width: 190px; }
/* the stage hugs the picture, so a 4:3 frame leaves no black margin */
.camerapage .camwrap .stage { flex: 0 1 auto; min-width: 0; }
.camerapage .stage video {
  width: auto; height: auto;
  max-width: 100%;
  max-height: calc(100dvh - 68px);   /* the focus row and the padding */
}

/* Upright there is width to spare and height to fill, so the controls go back
   to a full-width column above the picture. */
@media (orientation: portrait) {
  .camerapage .camwrap { display: block; }
  .camerapage .camctl { width: auto; }
  .camerapage .stage { margin-top: 8px; }
  .camerapage .stage video { max-height: 50dvh; margin: 0 auto; }
}

/* ==========================================================================
   The panel: a control room that fits one screen
   Cards are packed into columns rather than laid out in a single tall stack,
   every label sits beside its control instead of above it, and the prose lives
   in the drawer - so nothing here needs scrolling to reach.
   ========================================================================== */
.panelpage header { padding: 6px 12px; }
.panelpage header h1 { font-size: 13px; }
/* the connection line belongs next to the lamp, and must never widen the bar */
.panelpage .status { flex: 0 1 auto; min-width: 0; margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main.compact { display: block; max-width: 1400px; padding: 8px 10px 36px; }
.panelgrid { column-count: 3; column-gap: 8px; }
@media (max-width: 1040px) { .panelgrid { column-count: 2; } }
@media (max-width: 700px)  { .panelgrid { column-count: 1; } }
/* a card split across two columns would put its slider out of reach of its label */
.panelgrid .card { break-inside: avoid; padding: 8px 10px; margin: 0 0 8px; }

.compact .card h2 { margin: 0 0 6px; font-size: 11px; }
.compact label.lbl { margin: 5px 0 0; font-size: 11px; }
.compact .kv { font-size: 11px; }
.compact .meter { margin: 3px 0 1px; }
.compact .row { gap: 6px; }
.compact button.btn { padding: 7px 12px; font-size: 13px; }
.compact button.btn.seg { padding: 7px 4px; font-size: 12px; }
.compact button.btn.wide { margin-top: 6px; }
.compact .single input { height: 24px; }
.compact .single output { min-width: 40px; font-size: 11px; }
.compact .dual { margin: 12px 0 0; }
.compact .dual-track { height: 30px; }
.compact .dual-readout { font-size: 10px; }
.compact .note { font-size: 11px; margin: 5px 0 0; }
/* the one line of status left on the surface: it may be a whole sentence long */
.compact .note.line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* label beside its control, not above it */
.srow, .nrow { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.srow > .lbl, .nrow > .lbl { flex: 0 0 62px; margin: 0; }
.srow > .single { flex: 1; min-width: 0; }
.compact .nudge { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; margin: 0; }
.compact .nudge input { flex: 1; min-width: 0; padding: 5px 4px; font-size: 12px; }
.compact .nudge-btns { flex: none; margin: 0; }
.compact button.btn.nb { padding: 5px 7px; font-size: 11px; }

/* ---- the drawer everything wordy moved into ---- */
.infolink {
  position: fixed; right: 10px; bottom: 8px; z-index: 30; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); color: var(--dim);
  border-radius: 8px; padding: 5px 10px; font-size: 11px;
}
.infolink:hover { color: var(--ink); border-color: var(--accent); }
.infolink[hidden] { display: none; }
.infodrawer {
  position: fixed; inset: auto 0 0 0; z-index: 40; max-height: 84vh;
  display: flex; flex-direction: column;
  background: var(--panel); border-top: 1px solid var(--line);
  box-shadow: 0 -12px 30px rgba(0, 0, 0, .55);
}
.infodrawer[hidden] { display: none; }
.infohead { display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-bottom: 1px solid var(--line); }
.infohead h2 { margin: 0; font-size: 12px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--dim); font-weight: 600; }
.infohead .spacer { flex: 1; }
.infobody { overflow: auto; columns: 2; column-gap: 24px;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); }
.infobody section { break-inside: avoid; margin: 0 0 13px; }
.infobody h3 { margin: 0; font-size: 12px; font-weight: 600; color: var(--accent); }
@media (max-width: 700px) { .infobody { columns: 1; } }
