/* ==========================================================================================================
   Sentinel components — shared by every view. Tokens only (css/tokens.css). Owned by lib: a view that needs
   a new variant ASKS for it (public/DESIGN.md) instead of re-styling a component in its own stylesheet.

   BUTTONS      .btn (secondary)  .btn-primary|.pri  .btn-danger|.danger  .btn-ok|.ok  .btn-ghost  .btn-icon
                sizes .btn-sm|.sm  .btn-lg · loading: aria-busy="true" (+ disabled) · disabled: [disabled]
                <button class="btn pri" id="ack">Acknowledge</button>   <a class="btn sm" href="#/sites">Sites</a>
   FIELDS       input / select / textarea are styled as elements; <label> stacks its caption above the
                control; label.inline puts it beside (checkboxes).  .form = auto-fit grid of labelled fields.
                Toggle: <input type="checkbox" class="switch">.  Error text: .form-error (role=alert).
   CHIPS        .chip (.badge is the same component, legacy name). Tones: .tone-danger|.red .tone-warn
                .tone-caution|.amber .tone-info|.blue .tone-ok|.green .tone-ai.  Meaning-bearing chips:
                alarm state .state-new .state-acked .state-closed · AI .ai-verified .ai-unverified
                .ai-pending .ai-error · arm .armed .disarmed · entry direction .dir-in .dir-out .dir-inside
                .dir-unknown .dir-unsure.  Build them with lib/ui.js (stateBadge, verBadge) where one exists.
   SEVERITY     .sev .sev-1…5 — colour + SHAPE (ring, circle, square, triangle, diamond) + "P#" label.
                Always via lib/ui.js sevChip(p). .p1…p5 = bare severity fills (the queue's side bar).
   STATUS DOT   .dot .online|.offline|.stale|.unknown — circle / square / triangle / ring (shape + colour).
                .conn (.ok) = the live-connection dot.
   CARD         .card (panel), .cards (auto-fill grid), .card-head. Never nest cards.
   TABLE        .table (+ .table-wrap for horizontal scroll on phones); bare <table> gets the same base.
                .row-link = a clickable row that ALSO contains a real link for keyboard users.
   TABS         .tabs > button|a (.on or aria-current / aria-selected) — underline tabs.
   SEGMENTED    .seg > label>input[type=radio] (radiogroup) · .seg.seg-buttons > button[aria-pressed]
   PAGE HEAD    .page-head (.page-head-main > h1.page-title + .page-meta, .page-actions) — lib/ui.js pageHead()
   DRAWER/SHEET .sheet — side panel on desktop, bottom sheet under 900 px (.sheet-head, .sheet-body).
   CONFIRM      .confirm — inline, modal-free confirmation (window.confirm is blocked in some viewers):
                <div class="confirm"><b>Delete …?</b><p class="dim">…</p><label>Reason<input></label>
                <div class="row"><button class="btn danger">Delete</button><button class="btn">Cancel</button></div></div>
   CALLOUT      .callout (.warn .danger .info) — a tinted note; .secret = shown-once secret (token/password).
   TOASTS       lib/toast.js toast(msg, err) → .toasts > .toast(.err).  Never build toasts by hand.
   EMPTY        .empty > .empty-title + .empty-body — lib/ui.js emptyState(title, body).
   SKELETON     .skel (.skel-line, .skel-block) — placeholder while loading; static under reduced motion.
   TOOLTIP      [data-tip="…"] — CSS-only, on hover/focus; supplementary only (never the sole label).
   MEDIA        .media (16:9 black stage, .off placeholder, .ov overlay row), .iv-* (imageview overlays), .tv-* (trackview video boxes), .fage (frame age; .stale),
                .fstrip (frame strip; button.on = picked, i.hit = has detections), .lightbox.
   CAMERA TILE  .camtile (.camtile-below | .camtile-over; .is-offline/.is-unknown/.is-disabled) > .camtile-media, .camtile-top
                (.camtile-flags + .camtile-mute | .camtile-tags), .camtile-bar (.camtile-dot .camtile-name .camtile-st + actions).
                Build it with lib/camtile.js camTile() — wall, site grid and portal share it.
   LISTS        .log (timeline lines), .contact (a name/actions row), .kpis > .kpi (stat tiles).
   DIALOG       dialog.dialog (.dialog-head) — native <dialog> + showModal() only (shortcuts help).
   TIME         .age (quiet mono age) · .sla .sla-due|.sla-soon|.sla-late (time pressure: neutral → warn → danger).
   NOISE        .chip.mute (bell-off + "until 05:30") · .selbar (list selection bar: count + summary + actions) ·
                .actionbar (sticky action row inside a scroller) · .mutebox (lib/mute.js panel) · .countpill.
   ========================================================================================================== */

/* ---- buttons ------------------------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface-2); --btn-ink: var(--ink); --btn-line: var(--line-strong); --btn-hover: var(--surface-3);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 34px; padding: 6px 14px; border-radius: var(--r-sm);
  background: var(--btn-bg); color: var(--btn-ink); border: 1px solid var(--btn-line);
  font-weight: var(--fw-medium); line-height: 1.2; white-space: nowrap; text-decoration: none;
  transition: background-color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.btn:hover { background: var(--btn-hover); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: default; }
/* A disabled primary/ok must not read as "active" or "done": neutral, full opacity, disabled ink. */
.btn.pri:disabled, .btn-primary:disabled, .btn.ok:disabled, .btn-ok:disabled { --btn-bg: var(--surface-2); --btn-ink: var(--ink-disabled); --btn-line: var(--line); opacity: 1; }
.btn.pri, .btn-primary { --btn-bg: var(--accent); --btn-ink: var(--on-accent); --btn-line: var(--accent); --btn-hover: var(--accent-hover); font-weight: var(--fw-semibold); }
.btn.danger, .btn-danger { --btn-bg: var(--danger-soft); --btn-ink: var(--danger-ink); --btn-line: var(--danger-line); --btn-hover: var(--danger-soft); }
.btn.danger:hover, .btn-danger:hover { border-color: var(--danger); }
.btn.ok, .btn-ok { --btn-bg: var(--ok-soft); --btn-ink: var(--ok-ink); --btn-line: var(--ok-line); --btn-hover: var(--ok-soft); font-weight: var(--fw-semibold); }
.btn.ok:hover, .btn-ok:hover { border-color: var(--ok); }
.btn-ghost { --btn-bg: transparent; --btn-line: transparent; --btn-ink: var(--ink-2); }
.btn-ghost:hover { --btn-ink: var(--ink); }
.btn.sm, .btn-sm { min-height: 28px; padding: 3px 10px; font-size: var(--fs-sm); gap: var(--sp-1); }
.btn-lg { min-height: 44px; padding: 10px 20px; font-size: var(--fs-lg); }
.btn-icon { padding: 0; width: 34px; min-width: 34px; }
/* padding: 0 again — .btn.sm (two classes) would otherwise keep its side padding and squash the glyph to ~6 px */
.btn-icon.sm, .btn-icon.btn-sm { padding: 0; width: 28px; min-width: 28px; }
/* A shortcut hint inside a filled button reads in the button's own ink. */
.btn.pri kbd, .btn.danger kbd { background: transparent; border-color: currentColor; box-shadow: none; color: inherit; opacity: .7; }
/* A button that reads as a link, inside running text ("Select all 14", "include"). */
.linkbtn { padding: 0; border: 0; background: none; color: var(--accent-ink); font: inherit; font-weight: var(--fw-semibold); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
/* Loading: the label stays (width doesn't jump), a spinner leads it. */
.btn[aria-busy="true"] { cursor: progress; opacity: .85; }
.btn[aria-busy="true"]::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%; flex: none;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (pointer: coarse), (max-width: 900px) { .btn, .btn.sm, .btn-sm { min-height: 40px; } .btn-icon, .btn-icon.sm, .btn-icon.btn-sm { width: 40px; min-width: 40px; } }

/* ---- fields ------------------------------------------------------------------------------------------------ */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select, textarea {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 6px 9px; min-height: 34px; min-width: 0;
  transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
}
input:hover:not(:disabled):not([readonly]), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: var(--ink-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }
/* A field the form rejected: aria-invalid="true" (clear it when the value changes). */
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
input[aria-invalid="true"]:focus-visible, select[aria-invalid="true"]:focus-visible, textarea[aria-invalid="true"]:focus-visible { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
input[readonly] { background: var(--surface-2); }
input:disabled, select:disabled, textarea:disabled { opacity: .55; }
::placeholder { color: var(--ink-3); opacity: 1; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat;
}
textarea { width: 100%; resize: vertical; line-height: var(--lh); }
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; margin: 0; flex: none; }
@media (pointer: coarse), (max-width: 900px) { input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select { min-height: 40px; font-size: 16px; } }   /* same specificity as the base rule, or it never wins */
label { display: flex; flex-direction: column; gap: var(--sp-1); font-size: var(--fs-xs); color: var(--ink-2); font-weight: var(--fw-medium); }
label.inline { flex-direction: row; align-items: center; gap: var(--sp-2); color: var(--ink); font-size: var(--fs-sm); font-weight: var(--fw-regular); }
.inline-field { flex-direction: row; align-items: center; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sp-3); align-items: end; }
.form-error { color: var(--danger-ink); font-size: var(--fs-sm); min-height: 1.2em; }
/* Toggle switch: <input type="checkbox" class="switch"> */
input[type="checkbox"].switch {
  appearance: none; -webkit-appearance: none; width: 34px; height: 20px; border-radius: var(--r-pill);
  background: var(--surface-3); border: 1px solid var(--line-strong); position: relative; cursor: pointer;
  transition: background-color var(--dur-2) var(--ease-out);
}
input[type="checkbox"].switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--ink-2); transition: transform var(--dur-2) var(--ease-out), background-color var(--dur-2);
}
input[type="checkbox"].switch:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"].switch:checked::after { transform: translateX(14px); background: var(--on-accent); }
@media (pointer: coarse), (max-width: 900px) {
  input[type="checkbox"].switch { width: 46px; height: 28px; }
  input[type="checkbox"].switch::after { top: 3px; left: 3px; width: 20px; height: 20px; }
  input[type="checkbox"].switch:checked::after { transform: translateX(18px); }
}

/* ---- chips / badges ------------------------------------------------------------------------------------------ */
.chip, .badge {
  --chip-bg: var(--neutral-soft); --chip-ink: var(--neutral-ink); --chip-line: var(--neutral-line);
  display: inline-flex; align-items: center; gap: 5px; vertical-align: middle;
  font-size: var(--fs-xs); font-weight: var(--fw-semibold); line-height: 1.35; letter-spacing: .01em;
  padding: 1px 8px; border-radius: var(--r-pill); white-space: nowrap;
  background: var(--chip-bg); color: var(--chip-ink); border: 1px solid var(--chip-line);
}
.tone-danger, .badge.red, .chip.red { --chip-bg: var(--danger-soft); --chip-ink: var(--danger-ink); --chip-line: var(--danger-line); }
.tone-warn { --chip-bg: var(--warn-soft); --chip-ink: var(--warn-ink); --chip-line: var(--warn-line); }
.tone-caution, .badge.amber, .chip.amber { --chip-bg: var(--caution-soft); --chip-ink: var(--caution-ink); --chip-line: var(--caution-line); }
.tone-info, .badge.blue, .chip.blue { --chip-bg: var(--info-soft); --chip-ink: var(--info-ink); --chip-line: var(--info-line); }
.tone-ok, .badge.green, .chip.green { --chip-bg: var(--ok-soft); --chip-ink: var(--ok-ink); --chip-line: var(--ok-line); }
.tone-ai { --chip-bg: var(--ai-soft); --chip-ink: var(--ai-ink); --chip-line: var(--ai-line); }
/* alarm state: NEW is the one filled chip — it must win the glance */
.state-new { --chip-bg: var(--danger); --chip-ink: var(--on-danger); --chip-line: var(--danger); letter-spacing: .04em; }
.state-acked { --chip-bg: var(--caution-soft); --chip-ink: var(--caution-ink); --chip-line: var(--caution-line); }
.state-closed { --chip-bg: var(--neutral-soft); --chip-ink: var(--neutral-ink); --chip-line: var(--neutral-line); }
/* AI verification: violet is reserved for the verifier */
.ai-verified { --chip-bg: var(--ai); --chip-ink: var(--on-ai); --chip-line: var(--ai); }
.ai-unverified { --chip-bg: transparent; --chip-ink: var(--ink-2); --chip-line: var(--line-strong); }
.ai-pending { --chip-bg: var(--info-soft); --chip-ink: var(--info-ink); --chip-line: var(--info-line); }
.ai-error { --chip-bg: var(--caution-soft); --chip-ink: var(--caution-ink); --chip-line: var(--caution-line); }
/* arm state — calm: at 3 am nearly every site is armed, so armed is the NORMAL state (ink + a filled shield, never red).
   Red stays for NEW / late / offline-while-armed. .arm-warn = "should be armed by now" / "armed but nothing connected". */
.armed { --chip-bg: var(--surface-2); --chip-ink: var(--ink); --chip-line: var(--line-strong); }
.armed::before, .arm-warn::before { content: ""; width: 9px; height: 10px; background: currentColor; flex: none;
  clip-path: polygon(50% 0, 100% 18%, 100% 55%, 50% 100%, 0 55%, 0 18%); }
.disarmed { --chip-bg: transparent; --chip-ink: var(--ink-2); --chip-line: var(--line-strong); }
.arm-warn { --chip-bg: var(--warn-soft); --chip-ink: var(--warn-ink); --chip-line: var(--warn-line); }
/* entry direction */
.dir-in { --chip-bg: var(--ok-soft); --chip-ink: var(--ok-ink); --chip-line: var(--ok-line); }
.dir-out { --chip-bg: var(--info-soft); --chip-ink: var(--info-ink); --chip-line: var(--info-line); }
.dir-inside { --chip-bg: var(--caution-soft); --chip-ink: var(--caution-ink); --chip-line: var(--caution-line); }
.dir-at-door { --chip-bg: var(--warn-soft); --chip-ink: var(--warn-ink); --chip-line: var(--warn-line); }
.dir-unknown, .dir-unsure { --chip-bg: transparent; --chip-ink: var(--ink-2); --chip-line: var(--line-strong); }
.dir-unsure { border-style: dashed; }          /* a guess reads as a guess without relying on colour */

/* ---- severity: colour + shape + label ---------------------------------------------------------------------- */
.sev {
  display: inline-flex; align-items: center; gap: 5px; vertical-align: middle; white-space: nowrap;
  font: var(--fw-bold) var(--fs-xs)/1.35 var(--font-mono); letter-spacing: .02em;
  padding: 1px 8px 1px 6px; border-radius: var(--r-xs);
  background: var(--sev-bg); color: var(--sev-ink);
}
.sev i { width: 8px; height: 8px; background: currentColor; flex: none; }
.sev .sev-name { font-family: var(--font-ui); font-weight: var(--fw-semibold); }
.sev-5 { --sev-bg: var(--sev-5); --sev-ink: var(--on-sev-5); } .sev-5 i { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); width: 10px; height: 10px; }
.sev-4 { --sev-bg: var(--sev-4); --sev-ink: var(--on-sev-4); } .sev-4 i { clip-path: polygon(50% 0, 100% 100%, 0 100%); width: 10px; height: 9px; }
.sev-3 { --sev-bg: var(--sev-3); --sev-ink: var(--on-sev-3); } .sev-3 i { border-radius: 1px; }
.sev-2 { --sev-bg: var(--sev-2); --sev-ink: var(--on-sev-2); } .sev-2 i { border-radius: 50%; }
.sev-1 { --sev-bg: var(--sev-1); --sev-ink: var(--on-sev-1); } .sev-1 i { border-radius: 50%; background: none; box-shadow: inset 0 0 0 2px currentColor; }
.p5 { background: var(--sev-5); } .p4 { background: var(--sev-4); } .p3 { background: var(--sev-3); } .p2 { background: var(--sev-2); } .p1 { background: var(--sev-1); }

/* ---- status dots --------------------------------------------------------------------------------------------- */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: none; box-shadow: inset 0 0 0 2px var(--cam-unknown); vertical-align: middle; flex: none; }
.dot.online { background: var(--cam-online); box-shadow: none; }
.dot.offline { background: var(--cam-offline); box-shadow: none; border-radius: 1px; }
.dot.standby { background: none; box-shadow: inset 0 0 0 2px var(--cam-unknown); opacity: .55; }   /* not deployed (follow.js) */
.dot.stale { background: var(--cam-stale); box-shadow: none; border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.conn { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex: none; }
.conn.ok, .ok > .conn { background: var(--ok); }

/* ---- cards ----------------------------------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-4); min-width: 0; }
a.card { color: inherit; text-decoration: none; transition: border-color var(--dur-2) var(--ease-out), background-color var(--dur-2) var(--ease-out); }
a.card:hover { border-color: var(--line-strong); background: var(--surface-2); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.cards { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); align-items: start; }

/* ---- tables ---------------------------------------------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: var(--fs-xs); color: var(--ink-2); text-transform: uppercase; letter-spacing: var(--tracking-caps); font-weight: var(--fw-semibold); white-space: nowrap; }
.table tbody tr { transition: background-color var(--dur-1) var(--ease-out); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--sp-1)); padding: 0 var(--sp-1); }
.row-link { cursor: pointer; }

/* ---- tabs ------------------------------------------------------------------------------------------------------ */
.tabs::-webkit-scrollbar { display: none; }
/* The base line is an inset shadow, not a border: the active tab's 2px underline then sits over it INSIDE the box,
   so a tab bar that scrolls sideways on a phone (overflow-x) doesn't clip it (a -1px margin trick would). */
.tabs { display: flex; align-items: stretch; gap: var(--sp-1); box-shadow: inset 0 -1px 0 var(--line); margin-bottom: var(--sp-2); overflow-x: auto; scrollbar-width: none; }
.tabs > button, .tabs > a:not(.btn) {
  flex: none; white-space: nowrap;
  background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--ink-2); padding: 7px 12px; font-weight: var(--fw-medium); text-decoration: none;
  transition: color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out);
}
.tabs > button:hover, .tabs > a:not(.btn):hover { color: var(--ink); }
/* :not(.btn) keeps this above `.tabs > a:not(.btn)` (0,2,1) — link tabs (audit) never showed their underline. */
.tabs > :is(.on, [aria-current="page"], [aria-selected="true"]):not(.btn) { color: var(--ink); border-bottom-color: var(--accent); }

/* ---- segmented control ----------------------------------------------------------------------------------------- */
.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.seg > label, .seg > button {
  flex-direction: row; align-items: center; justify-content: center; gap: 6px; flex: 1;
  padding: 5px 10px; border-radius: var(--r-sm); border: 0; background: none; color: var(--ink-2);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); cursor: pointer; white-space: nowrap;
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}
.seg > label:hover, .seg > button:hover { color: var(--ink); }
.seg > label input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.seg > label:has(input:checked), .seg > button[aria-pressed="true"], .seg > button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--line-strong); }
.seg > label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }
.seg-buttons > button { text-transform: capitalize; }
@media (pointer: coarse), (max-width: 900px) { .seg > label, .seg > button { min-height: 38px; } }   /* + the track's 2 px padding = 40 px */

/* ---- page head -------------------------------------------------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4); }
.page-head-main { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); min-width: 0; }
.page-title { font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.page-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.page .page-head + .stack, .stack > .page-head + * { margin-top: 0; }

/* ---- drawer / sheet --------------------------------------------------------------------------------------------- */
.sheet { background: var(--surface); border-left: 1px solid var(--line); overflow: auto; display: flex; flex-direction: column; }
.sheet-head { position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); background: var(--surface); border-bottom: 1px solid var(--line); }
.sheet-body { padding: var(--sp-4); }
@media (max-width: 900px) {
  .sheet { position: fixed; left: 0; right: 0; bottom: var(--shell-bottom); max-height: calc(100dvh - var(--shell-top) - var(--shell-bottom)); z-index: var(--z-drawer);
    border-left: 0; border-top: 1px solid var(--line-strong); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--shadow-3); }
}

/* ---- inline confirm --------------------------------------------------------------------------------------------- */
.confirm { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3); border-radius: var(--r-md); background: var(--danger-soft); border: 1px solid var(--danger-line); }
.confirm > b { color: var(--ink); }

/* ---- callouts ---------------------------------------------------------------------------------------------------- */
.callout, .secret { padding: var(--sp-3); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line-strong); }
.callout.warn { background: var(--caution-soft); border-color: var(--caution-line); }
.callout.danger { background: var(--danger-soft); border-color: var(--danger-line); }
.callout.info { background: var(--info-soft); border-color: var(--info-line); }
.secret { background: var(--caution-soft); border: 1px dashed var(--caution-line); word-break: break-all; }

/* ---- toasts -------------------------------------------------------------------------------------------------------- */
.toasts { position: fixed; left: 50%; bottom: calc(var(--shell-bottom) + var(--sp-4) + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: var(--z-toast); display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); width: max-content; max-width: min(92vw, 480px); pointer-events: none; }
.toast {
  pointer-events: auto; cursor: pointer; padding: 10px 16px; border-radius: var(--r-md);
  background: var(--ink); color: var(--bg); font-weight: var(--fw-medium); box-shadow: var(--shadow-3);
  animation: toast-in var(--dur-3) var(--ease-out);
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
}
.toast.err { background: var(--danger); color: var(--on-danger); }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---- empty states ---------------------------------------------------------------------------------------------------- */
.empty { color: var(--ink-2); padding: var(--sp-8) var(--sp-4); text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.empty-title { color: var(--ink); font-weight: var(--fw-semibold); font-size: var(--fs-lg); }
.empty-body { max-width: 44ch; font-size: var(--fs-sm); }

/* ---- skeleton ------------------------------------------------------------------------------------------------------- */
.skel { background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: skel 1.4s var(--ease-in-out) infinite; border-radius: var(--r-sm); }
.skel-line { height: 12px; margin: 6px 0; }
.skel-block { aspect-ratio: 16 / 9; }
@keyframes skel { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; background: var(--surface-2); } }

/* ---- tooltip (CSS only) ------------------------------------------------------------------------------------------- */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%);
  z-index: var(--z-tooltip); padding: 4px 8px; border-radius: var(--r-sm); white-space: nowrap; pointer-events: none;
  background: var(--ink); color: var(--bg); font: var(--fw-medium) var(--fs-xs)/1.3 var(--font-ui); box-shadow: var(--shadow-2);
}

/* ---- filter chips (a set of toggle buttons) ------------------------------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--sp-3); }
.chips > button { background: none; border: 1px solid var(--line-strong); color: var(--ink-2); padding: 4px 12px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.chips > button:hover { color: var(--ink); border-color: var(--ink-3); }
.chips > button.on, .chips > button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }

/* ---- media stage, frame strip, frame age, lightbox ---------------------------------------------------------------------- */
.media { background: var(--media-bg); border-radius: var(--r-md); overflow: hidden; aspect-ratio: 16/9; position: relative; }
.media img, .media video { width: 100%; height: 100%; object-fit: contain; display: block; background: var(--media-bg); }
.media .ov { position: absolute; left: 8px; top: 8px; display: flex; gap: 6px; }
.media .off, .lightbox .off { position: absolute; inset: 0; display: grid; place-items: center; color: var(--media-ink-2); padding: var(--sp-3); text-align: center; }
/* lib/imageview.js overlays: the image + AI boxes + zones in one SVG. Box/zone colours are the signal tokens. */
.iv-svg { width: 100%; height: 100%; display: block; background: var(--media-bg); }
.iv-person { --iv: var(--danger); --iv-on: var(--on-danger); }
.iv-other { --iv: var(--warn); --iv-on: var(--on-warn); }
.iv-box { stroke: var(--iv); }
.iv-tag { fill: var(--iv); }
.iv-hit text { fill: var(--iv-on); font-family: var(--font-ui); font-weight: var(--fw-semibold); }
.iv-watch { stroke: var(--ok); stroke-opacity: .9; }
.iv-ignore { stroke: var(--neutral); stroke-opacity: .7; }
.iv-hatch { stroke: var(--neutral); stroke-opacity: .5; }
/* lib/trackview.js: a video with footage-analysis boxes over it (the SVG uses the video's pixel viewBox, like .iv-svg). */
.tv-wrap { position: relative; width: 100%; height: 100%; background: var(--media-bg); }
.tv-wrap video { width: 100%; height: 100%; object-fit: contain; display: block; }
.tv-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }   /* same box as the video, so "meet" letterboxes alike */
.tv-out { opacity: .55; }   /* standing outside every watch zone */
.fage { position: absolute; left: 8px; top: 8px; padding: 2px 7px; border-radius: var(--r-xs); background: var(--media-scrim); font: var(--fs-2xs)/1.4 var(--font-mono); color: var(--media-ink); }
.fage.live { background: var(--accent); color: var(--on-accent); }
.fage.stale { background: var(--danger); color: var(--on-danger); }   /* after .live: a live view gone quiet shows red */
.live-od { position: absolute; right: 8px; bottom: 8px; z-index: 2; }
.frames .fstrip, .fstrip { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0 8px; scrollbar-width: thin; }
.fstrip button { flex: 0 0 104px; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; background: var(--media-bg); text-align: left; transition: border-color var(--dur-2) var(--ease-out); }
.fstrip button:hover { border-color: var(--ink-3); }
.fstrip button.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.fstrip img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.fstrip span { display: flex; align-items: center; gap: 4px; font: var(--fs-2xs) var(--font-mono); padding: 2px 5px; background: var(--surface-2); color: var(--ink-2); }
.fstrip .hit { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); flex: none; }
.lightbox { position: fixed; inset: 0; z-index: var(--z-modal); background: var(--scrim); display: grid; place-items: center; padding: var(--sp-4); animation: fade-in var(--dur-2) var(--ease-out); }
.lightbox .lbin { width: min(900px, 100%); box-shadow: var(--shadow-3); }
@keyframes fade-in { from { opacity: 0; } }

/* ---- camera tile (lib/camtile.js): one tile for the wall, the site grid and the portal ------------------------------- */
.camtile { position: relative; isolation: isolate; display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.camtile.is-offline { border-color: var(--danger-line); }
.camtile.is-disabled { opacity: .6; }
.camtile-media { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0; border-radius: 0; overflow: hidden;
  background: var(--media-bg); color: var(--media-ink-2); }
button.camtile-media { cursor: zoom-in; }
button.camtile-media:focus-visible { outline: 2px solid var(--focus); outline-offset: -3px; }
.camtile-media img, .camtile-media video { width: 100%; height: 100%; object-fit: contain; display: block; }
.camtile-media .off { position: absolute; inset: 0; display: grid; place-items: center; padding: var(--sp-3); text-align: center; font-size: var(--fs-sm); color: var(--media-ink-2); }
.camtile.is-offline .camtile-media img { filter: grayscale(1) brightness(0.6); }
.camtile-top { position: absolute; top: 8px; left: 8px; right: 8px; z-index: 4; display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-1); pointer-events: none; }
.camtile-flags { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1); min-width: 0; }
.camtile-mute:empty, .camtile-tags:empty { display: none; }
.camtile-tags { display: inline-flex; gap: var(--sp-1); margin-left: auto; }
.camtile .chip.mute { background: var(--surface); box-shadow: var(--shadow-1); max-width: 100%; }   /* on imagery: an opaque chip */
.camtile .fage { z-index: 1; }
.camtile:has(.camtile-mute:not(:empty)) .camtile-media .fage { top: 40px; }   /* the mute chip owns the top-left */
.camtile-bar { display: flex; align-items: center; gap: var(--sp-2); min-height: 40px; padding: 4px var(--sp-1) 4px var(--sp-2); min-width: 0; font-size: var(--fs-sm); }
.camtile-dot { display: inline-flex; flex: none; }
.camtile-name { flex: 1 1 auto; min-width: 5ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--fw-semibold); }
.camtile-st { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: var(--fs-xs); white-space: nowrap; color: var(--ink-2); }
.camtile-st:empty { display: none; }
.camtile.is-offline .camtile-st { color: var(--danger-ink); font-weight: var(--fw-semibold); }
/* over: the picture is the tile; the bar is a caption on a scrim (the view decides when it shows) */
.camtile-over { border: 0; background: var(--media-bg); }
.camtile-over .camtile-media { position: absolute; inset: 0; height: 100%; aspect-ratio: auto; }
.camtile-over .camtile-bar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; min-height: 0; padding: var(--sp-5) var(--sp-2) 6px var(--sp-3);
  background: linear-gradient(transparent, var(--media-scrim-strong)); color: var(--media-ink); pointer-events: none; }
.camtile-over .camtile-st, .camtile-over.is-offline .camtile-st { color: var(--media-ink-2); font-weight: var(--fw-regular); }
@media (pointer: coarse), (max-width: 900px) { .camtile-bar { gap: var(--sp-1); } }

/* ---- lists ---------------------------------------------------------------------------------------------------------- */
.log { font-size: var(--fs-sm); }
.log > div { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.log > div:last-child { border-bottom: 0; }
.contact { display: flex; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); }
.contact:last-child { border-bottom: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-3); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4); }
.kpi b { display: block; font-size: var(--fs-2xl); font-weight: var(--fw-bold); line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--ink-2); font-size: var(--fs-sm); }

/* ---- dialog (native <dialog>) --------------------------------------------------------------------------------------- */
.dialog {
  width: min(520px, calc(100vw - 32px)); max-height: min(80dvh, 720px); padding: var(--sp-5); border: 0; border-radius: var(--r-xl);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3);
}
.dialog[open] { animation: dialog-in var(--dur-3) var(--ease-out); }
.dialog::backdrop { background: var(--scrim); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.dialog h3 { margin: var(--sp-4) 0 var(--sp-2); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.kbd-list { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-2) var(--sp-4); margin: 0; font-size: var(--fs-sm); align-items: baseline; }
.kbd-list dt { white-space: nowrap; color: var(--ink-2); }
.kbd-list dd { margin: 0; }

/* ---- time pressure: ages are quiet; SLA goes neutral → warn → danger ------------------------------------------------ */
.age { font-family: var(--font-mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.age.late { color: var(--danger-ink); font-weight: var(--fw-semibold); }
.sla { --chip-bg: transparent; --chip-ink: var(--ink-2); --chip-line: var(--line-strong); font-variant-numeric: tabular-nums; }
.sla .mono { font-size: var(--fs-xs); }
.sla-soon { --chip-bg: var(--warn-soft); --chip-ink: var(--warn-ink); --chip-line: var(--warn-line); }
.sla-late { --chip-bg: var(--danger-soft); --chip-ink: var(--danger-ink); --chip-line: var(--danger-line); }

/* ---- noise: mute chip, selection bar, action bar, mute panel, count pill --------------------------------------------- */
.chip.mute { --chip-bg: var(--neutral-soft); --chip-ink: var(--ink-2); --chip-line: var(--line-strong); }
.chip.mute .icon { flex: none; }
.selbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md); background: var(--accent-soft); border: 1px solid var(--accent); }
.selbar-n { font-weight: var(--fw-bold); }
.selbar-sum { flex: 1 1 100%; min-width: 0; font-size: var(--fs-sm); color: var(--ink-2); }
.selbar-actions { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-left: auto; }
.actionbar { position: sticky; z-index: var(--z-sticky); display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) 0; background: var(--surface); }
.mutebox { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-3); border-radius: var(--r-md); background: var(--surface);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow-2); }
.mutebox-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); }
.mutebox fieldset { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.mutebox legend { padding: 0; margin-bottom: var(--sp-1); font-size: var(--fs-xs); color: var(--ink-2); font-weight: var(--fw-semibold); }
.mutebox .seg { flex-wrap: wrap; }
.mutebox .seg-buttons > button { text-transform: none; }
.mutebox-note { font-size: var(--fs-sm); color: var(--ink-2); }
.mutebox-warn { font-size: var(--fs-sm); }
.countpill { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 28px; padding: 2px 12px; border-radius: var(--r-pill);
  background: var(--danger); color: var(--on-danger); font: var(--fw-bold) var(--fs-sm)/1.2 var(--font-ui); text-decoration: none; border: 0; }
.countpill:hover { text-decoration: none; background: var(--danger); filter: brightness(1.06); }
@media (pointer: coarse), (max-width: 900px) { .countpill { min-height: 40px; min-width: 40px; } }

/* toast with an action (Undo): the toast stays a button-free click-to-dismiss area; the action is its own button */
.toast.has-action { display: flex; align-items: center; gap: var(--sp-3); cursor: default; padding-right: 8px; }
.toast-act { padding: 4px 12px; border-radius: var(--r-sm); border: 1px solid currentColor; background: transparent; color: inherit; font-weight: var(--fw-bold); min-height: 30px; }
.toast-act:hover { background: color-mix(in oklch, currentColor 12%, transparent); }
.toast-t { font: var(--fs-xs) var(--font-mono); opacity: .75; }
@media (pointer: coarse), (max-width: 900px) { .toast-act { min-height: 40px; } }
