:root {
  --bg: #14161a;
  --panel: #1c1f26;
  --line: #2c313b;
  --fg: #e6e9ef;
  --muted: #8b93a3;
  --accent: #4da3ff;
  --todo: #ff5470;       /* unlabeled: high attention, "make the red go away" */
  --done: #3ddc84;
  --interp: #ffb020;
  --warn: #ffb020;
  --sel: #ffffff;
}

* { box-sizing: border-box; }

/* The `hidden` attribute sets display:none from the UA stylesheet, which any
   author rule setting `display` silently beats. #app and .modal both do, so
   without this a "hidden" full-viewport modal still swallows every click. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.45 ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
}

.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

button {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 11px;
  font: inherit;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.ghost { background: none; }
button.wide { width: 100%; margin-top: 8px; }
button.warn { border-color: var(--warn); color: var(--warn); }

kbd {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
}

/* ---------------------------------------------------------------- picker */

/* The picker is a work queue at day scale, so it scrolls and the page does not. */
.picker { padding: 28px 32px; max-width: 960px; height: 100vh;
          display: flex; flex-direction: column; }
.picker h1 { margin: 0 0 8px; font-size: 20px; flex: 0 0 auto; }
.daystats { flex: 0 0 auto; color: var(--muted); line-height: 1.7;
            border: 1px solid var(--line); border-radius: 8px;
            padding: 10px 13px; background: var(--panel); }
.daystats b { color: var(--fg); }
.pickctl { flex: 0 0 auto; display: flex; gap: 16px; align-items: center;
           margin: 14px 0 10px; }
.pickctl select { background: var(--panel); color: var(--fg);
                  border: 1px solid var(--line); border-radius: 5px;
                  padding: 3px 6px; font: inherit; }
.picker ul { list-style: none; padding: 0; margin: 0; overflow-y: auto; flex: 1; }
.picker li {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-size: 13px;
}
.picker li:hover { border-color: var(--accent); }
.picker li.done { opacity: .45; }
.picker li .cid { min-width: 168px; }
.pill { font-size: 11px; padding: 1px 7px; border-radius: 999px;
        border: 1px solid var(--line); color: var(--muted); }
.pill.submitted { border-color: var(--done); color: var(--done); }
.pill.in_progress { border-color: var(--warn); color: var(--warn); }

/* ---------------------------------------------------------------- shell */

#app { display: flex; flex-direction: column; height: 100vh; }

header {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex: 0 0 auto;
}

main { flex: 1; display: flex; min-height: 0; }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 10px;
  gap: 8px;
}

.video-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}
.video-wrap video { max-width: 100%; max-height: 100%; display: block; }

/* The SVG sits exactly over the rendered video box, not the container --
   letterboxing would otherwise offset every box. app.js keeps it aligned. */
#overlay { position: absolute; pointer-events: none; }
#overlay .hit { pointer-events: all; cursor: pointer; fill: transparent; }

#overlay rect.box { fill: none; stroke-width: 2.5; vector-effect: non-scaling-stroke; }
#overlay rect.box.todo { stroke: var(--todo); }
#overlay rect.box.done { stroke: var(--done); stroke-opacity: .55; }
#overlay rect.box.interp { stroke-dasharray: 6 4; }
#overlay rect.box.sel { stroke: var(--sel); stroke-width: 4; }
#overlay rect.zone { fill: none; stroke: var(--accent); stroke-opacity: .5;
                     stroke-dasharray: 3 5; stroke-width: 1.5;
                     vector-effect: non-scaling-stroke; }
#overlay text { font: 600 13px ui-monospace, Menlo, monospace; paint-order: stroke;
                stroke: #000; stroke-width: 3px; }
#overlay text.todo { fill: var(--todo); }
#overlay text.done { fill: var(--done); }

.transport { display: flex; gap: 10px; align-items: center; flex: 0 0 auto; }
.transport input[type=range] { flex: 1; accent-color: var(--accent); }
.toggle { display: flex; gap: 5px; align-items: center; color: var(--muted); font-size: 12px; }

.speeds { display: flex; gap: 2px; }
.speeds button {
  padding: 2px 7px; font-size: 11px; border-radius: 4px;
  font-family: ui-monospace, Menlo, monospace;
}
.speeds button.on { border-color: var(--accent); color: var(--accent); background: #16232f; }
/* Fixed width so a fluctuating measurement does not shift the controls around. */
.rate { font-size: 11px; width: 92px; text-align: right; }
.rate.bad { color: var(--warn); }

/* ------------------------------------------------------------ labelbar */

/* Every value is on screen with its key beside it. Clicking works, so a first
   run needs no instructions; the key sits next to the thing it does, so the
   same surface teaches the keyboard path instead of hiding it behind help. */
.labelbar {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--panel);
}
.labelbar .hint { color: var(--muted); padding: 6px 2px; }
.labelbar .who { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.labelbar .who b { color: var(--fg); }
.labelbar .row { display: flex; align-items: center; gap: 5px; margin: 3px 0; }
.labelbar .rowname {
  width: 58px; flex: 0 0 auto; text-align: right;
  font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em;
}
.labelbar button.val { padding: 3px 8px; font-size: 12px; line-height: 1.3; }
.labelbar button.val kbd { margin-left: 6px; opacity: .6; padding: 0 3px; }
.labelbar button.val.on {
  border-color: var(--done); color: var(--done); background: #11301e;
}
.labelbar button.val.on kbd { opacity: .85; }

/* --------------------------------------------------------------- lanes */

.lanes { flex: 0 0 auto; max-height: 62px; overflow-y: auto; position: relative; }
.lane { display: flex; align-items: center; gap: 8px; height: 15px; }
.lane .name { width: 30px; font-size: 10px; text-align: right; }
.lane .bar { position: relative; flex: 1; height: 7px; background: #000; border-radius: 3px; }
.lane .seg { position: absolute; top: 0; bottom: 0; border-radius: 3px; opacity: .75; }
/* One cursor for all lanes. transform (not left) so moving it does not
   invalidate layout — it stays on the compositor. */
.lanecursor {
  position: absolute; top: 0; bottom: 0; width: 2px; background: var(--sel);
  pointer-events: none; will-change: transform;
}

/* --------------------------------------------------------------- roster */

#roster {
  flex: 0 0 348px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  padding: 10px;
}
.roster-head { display: flex; justify-content: space-between; align-items: baseline;
               margin-bottom: 8px; }
#cards { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 7px; }

.card {
  display: flex;
  gap: 9px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--todo);
  border-radius: 7px;
  padding: 7px;
  cursor: pointer;
  background: #171a20;
}
.card.done { border-left-color: var(--done); }
.card.sel { border-color: var(--sel); }
.card.drop { border-color: var(--accent); background: #1d2634; }
.card img { width: 46px; height: 62px; object-fit: cover; border-radius: 4px;
            background: #000; flex: 0 0 auto; }
.card .meta { min-width: 0; flex: 1; }
.card .who { display: flex; justify-content: space-between; font-size: 11px; }
.card .vals { font-size: 12px; margin-top: 3px; }
.card .vals .v { display: inline-block; margin-right: 6px; }
.card .vals .unset { color: var(--todo); }
.card .tracks { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* --------------------------------------------------------------- modal */

.modal { position: fixed; inset: 0; background: #000b; display: flex;
         align-items: center; justify-content: center; z-index: 50; }
.modal-body { background: var(--panel); border: 1px solid var(--line);
              border-radius: 10px; padding: 22px; max-width: 560px; }
.modal-body table { border-collapse: collapse; margin: 10px 0; }
.modal-body td { padding: 3px 14px 3px 0; }
.modal-body h2 { margin: 0 0 10px; font-size: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal-body ul { margin: 8px 0; padding-left: 18px; color: var(--muted); }
.modal-body ul b { color: var(--fg); }

#submit-btn.submitted { border-color: var(--done); color: var(--done); }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: #000d; border: 1px solid var(--line); border-radius: 7px;
  padding: 8px 16px; z-index: 60;
}
.toast.err { border-color: var(--todo); color: var(--todo); }

.card .tracks .unmerge {
  padding: 0 5px; font-size: 10px; margin-left: 6px;
  border-color: var(--warn); color: var(--warn); background: none;
}

/* --------------------------------------------------------- filmstrip */

/* A single best-frame crop cannot show an identity switch — it is one moment.
   Several across the span can: the strip simply stops looking like the same
   person. Cards become vertical so the strip gets the full panel width. */
.card { flex-direction: column; gap: 6px; }
.card .strip { display: flex; gap: 2px; overflow-x: auto; padding-bottom: 2px; }
.card .strip::-webkit-scrollbar { height: 4px; }
.card .strip::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }
.card .strip .sf {
  height: 46px; width: auto; flex: 0 0 auto; border-radius: 3px;
  object-fit: cover; background: #000;
}
.card .meta { width: 100%; }

/* ------------------------------------------------- context menu + picker */

.ctxmenu {
  position: fixed; z-index: 70; min-width: 176px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 7px; padding: 4px; box-shadow: 0 8px 24px #000a;
}
.ctxmenu button {
  display: block; width: 100%; text-align: left; border: none;
  background: none; padding: 6px 10px; border-radius: 5px; font-size: 13px;
}
.ctxmenu button:hover { background: #263042; border: none; }
.ctxmenu button.danger { color: var(--todo); }
.ctxmenu .sep { height: 1px; background: var(--line); margin: 4px 2px; }
.ctxmenu .who { padding: 5px 10px 7px; font-size: 11px; color: var(--muted); }

.pickbody { width: 520px; max-width: 92vw; }
#tp-input {
  width: 100%; background: #000; color: var(--fg); font: inherit;
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
}
#tp-input:focus { outline: none; border-color: var(--accent); }
.tp-list { max-height: 320px; overflow-y: auto; margin-top: 8px; }
.tp-row {
  display: flex; gap: 9px; align-items: center; padding: 5px 7px;
  border-radius: 6px; cursor: pointer; border: 1px solid transparent;
}
.tp-row.on { background: #1d2634; border-color: var(--accent); }
.tp-row img { height: 40px; width: auto; border-radius: 3px; background: #000; }
.tp-row .tid { font-family: ui-monospace, Menlo, monospace; min-width: 46px; }
.tp-row .att { color: var(--muted); font-size: 12px; }
.tp-row .rng { margin-left: auto; color: var(--muted); font-size: 11px; }
.tp-hint { font-size: 11px; margin: 10px 0 0; }

/* Pre-auth gate. Deliberately plain: it is the only thing an anonymous visitor
   sees, and it should not advertise anything about what is behind it. */
.gate {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 70vh; gap: 0.75rem; text-align: center;
}
.gate p { opacity: 0.7; }
.gate p.err { opacity: 1; color: #ff6b6b; max-width: 46rem; }
