:root {
  /* Palette chosen for WCAG 2.2 AA contrast on the surfaces below. */
  --bg: #0b1020;
  --surface: #ffffff;
  --text: #1a1d29; /* ~13:1 on white */
  --text-muted: #4a4f5e; /* ~8:1 on white */
  --primary: #1a4fd6; /* ~5.3:1 on white, white text ~5.3:1 */
  --primary-text: #ffffff;
  --primary-hover: #1540ad;
  --focus: #ffbf47;
  --online: #0a7d33;
  --offline: #8a0f1a;
  --border: #c9ccd6;
  --error-bg: #fdecec;
  --error-text: #8a0f1a;
  --ok-bg: #e8f6ee;
  --ok-text: #0a5c2a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -10%, #16204a, transparent),
    var(--bg);
}

.card {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.brand-badge {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--primary); color: var(--primary-text);
  font-weight: 700; letter-spacing: 0.5px; font-size: 13px;
}
.brand-name { font-weight: 600; color: var(--text-muted); }

h1 { font-size: 1.6rem; margin: 0 0 10px; }
h2.section-h { font-size: 1.05rem; margin: 20px 0 8px; }
.lead { color: var(--text); margin: 0 0 16px; }
.note { color: var(--text-muted); font-size: 0.92rem; background: #f3f4f8; border-radius: 10px; padding: 12px 14px; }
.fineprint { color: var(--text-muted); font-size: 0.85rem; margin-top: 14px; }
.hint { display: block; color: var(--text-muted); font-weight: 400; font-size: 0.88rem; margin-top: 4px; }

label { display: block; font-weight: 600; margin: 16px 0 6px; }

input[type="email"], input[type="text"] {
  width: 100%;
  font-size: 1rem;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: #fff;
}
input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-color: var(--primary); }

#code { letter-spacing: 0.4em; font-variant-numeric: tabular-nums; text-align: center; font-size: 1.3rem; }

.btn {
  display: inline-block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  padding: 13px 18px;
  border-radius: 10px;
  border: 2px solid transparent;
  margin-top: 20px;
}
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); }
.btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn[disabled] { opacity: 0.6; cursor: progress; }

.secondary-action { margin-top: 18px; color: var(--text-muted); font-size: 0.95rem; }
.linklike {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--primary); font: inherit; font-weight: 600; text-decoration: underline;
}
.linklike:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

/* Progress steps */
.steps { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0 0 18px; }
.step {
  flex: 1; display: flex; align-items: center; gap: 6px;
  font-size: 0.82rem; color: var(--text-muted); font-weight: 600;
}
.step-dot {
  display: inline-grid; place-items: center; width: 22px; height: 22px;
  border-radius: 50%; background: #e4e6ee; color: var(--text-muted); font-size: 0.78rem;
}
.step.is-current .step-dot { background: var(--primary); color: #fff; }
.step.is-done .step-dot { background: var(--online); color: #fff; }
.step.is-current { color: var(--text); }

/* Status + errors — never color alone; always text. */
.status { margin: 0 0 14px; padding: 0; min-height: 0; }
.status[data-kind="error"] { background: var(--error-bg); color: var(--error-text); padding: 12px 14px; border-radius: 10px; }
.status[data-kind="ok"] { background: var(--ok-bg); color: var(--ok-text); padding: 12px 14px; border-radius: 10px; }

.demo-code {
  background: #fff7e6; color: #6b4b00; border: 1px dashed #c99a00;
  padding: 10px 14px; border-radius: 10px; font-size: 0.9rem;
}
.demo-code strong { font-size: 1.1rem; letter-spacing: 0.15em; }

/* Confirmation */
.success-mark {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--ok-bg); color: var(--ok-text);
  display: grid; place-items: center; margin: 0 0 14px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ── Spinner (link processing) ─────────────────────────────────────────── */
.spinner {
  width: 40px; height: 40px; margin: 24px auto 0;
  border: 4px solid #e4e6ee; border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════════════════════════════
   App shell / dashboard — expo-grade visual design
   ════════════════════════════════════════════════════════════════════════ */
:root {
  --app-bg: #0a0e1a;
  --panel: #121829;
  --panel-2: #171e33;
  --panel-border: #26304d;
  --ink: #eef1f8;
  --ink-muted: #9aa3bd;
  --accent: #4d7cff;
  --accent-2: #22d3ee;
}

body.app {
  display: block;
  min-height: 100vh;
  padding: 0;
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(77,124,255,0.18), transparent),
    radial-gradient(700px 500px at 0% 0%, rgba(34,211,238,0.10), transparent),
    var(--app-bg);
}

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: rgba(10,14,26,0.82);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--panel-border);
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar .brand-badge {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; box-shadow: 0 6px 18px rgba(77,124,255,0.4);
}
.brand-wordmark { display: flex; flex-direction: column; line-height: 1.15; }
.topbar .brand-name { font-weight: 700; color: var(--ink); font-size: 0.98rem; }
.brand-tagline { font-size: 0.72rem; color: var(--ink-muted); letter-spacing: 0.03em; }

.dashboard { max-width: 1080px; margin: 0 auto; padding: 32px 28px 72px; }

/* Toast / linked banner */
.toast {
  display: flex; align-items: center; gap: 10px;
  background: rgba(34,211,238,0.12); color: #a9f0ff;
  border: 1px solid rgba(34,211,238,0.35);
  padding: 13px 16px; border-radius: 12px; margin: 0 0 24px; font-weight: 600;
}
.toast svg { color: var(--accent-2); flex-shrink: 0; }

/* Hero */
.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 28px 30px;
  background: linear-gradient(135deg, var(--panel), var(--panel-2));
  border: 1px solid var(--panel-border);
  border-radius: 20px; margin-bottom: 22px;
  position: relative; overflow: hidden;
}
.eyebrow {
  display: inline-block; font-size: 0.74rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-2);
  margin-bottom: 8px;
}
.hero h1 { font-size: 1.9rem; margin: 0 0 10px; color: var(--ink); letter-spacing: -0.01em; }
.hero .lead { color: var(--ink-muted); margin: 0; max-width: 54ch; }

.hero-pulse { position: relative; width: 92px; height: 92px; flex-shrink: 0; }
.pulse-core {
  position: absolute; inset: 36px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent-2), var(--accent));
  box-shadow: 0 0 24px rgba(34,211,238,0.7);
}
.pulse-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(34,211,238,0.5); animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(0.5); opacity: 0.9; }
  100% { transform: scale(1); opacity: 0; }
}

/* Summary stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 30px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 16px; padding: 18px 20px; display: flex; flex-direction: column; gap: 4px;
}
.stat-value { font-size: 1.9rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-value.stat-live { color: var(--accent-2); font-size: 1.5rem; }
.stat-label { font-size: 0.82rem; color: var(--ink-muted); font-weight: 600; }

/* Section head */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 16px; }
.section-head .section-h { font-size: 1.15rem; margin: 0; color: var(--ink); }
/* The HTML `hidden` attribute must win over any explicit `display` below.
   Without this, `.btn-ghost { display: inline-flex }` overrides `hidden` and
   buttons meant to be hidden (e.g. the Elite-only grid-view switcher on a
   single-camera device) stay visible. */
[hidden] { display: none !important; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--panel-border);
  border-radius: 10px; padding: 8px 14px; font: inherit; font-weight: 600; font-size: 0.88rem; cursor: pointer;
}
.btn-ghost:hover { background: var(--panel-2); border-color: var(--accent); }
/* Page-level demo-mode switch (top bar). Green dot + "Live" normally, amber
   dot + "Demo" with an amber chip treatment when the resilient demo loop is on. */
.topbar-right { display: inline-flex; align-items: center; gap: 14px; margin-left: 32px; }
.demo-switch {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--panel-border); border-radius: 999px;
  padding: 8px 14px; font: inherit; font-weight: 700; font-size: 0.85rem; cursor: pointer;
}
.demo-switch:hover { background: var(--panel-2); border-color: var(--accent); }
.demo-switch:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.demo-dot { width: 9px; height: 9px; border-radius: 50%; background: #7ff0a6; display: inline-block; }
.demo-switch.is-demo { border-color: #ffbf47; background: rgba(255,191,71,0.14); color: #ffd98a; }
.demo-switch.is-demo .demo-dot { background: #ffbf47; }
@media (max-width: 520px) {
  .demo-switch { padding: 7px 11px; }
}
/* When demo mode is active, tint the whole page subtly so it's unmistakable at
   a glance that the booth is running the demo loop (affects the entire view,
   not just the live tile). */
body.demo-active { box-shadow: inset 0 0 0 2px rgba(255,191,71,0.5); }

/* ── Doorbell-press full-page popup live view ─────────────────────────────── */
.ding-popup {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column;
  background: #04070d;
  animation: ding-pop-in 0.28s ease-out;
}
@keyframes ding-pop-in { from { opacity: 0; transform: scale(1.02); } to { opacity: 1; transform: none; } }
.ding-popup-head {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; background: #0b1120; border-bottom: 1px solid #1b2740; color: #e6edf6;
}
.ding-popup-badge {
  font-weight: 800; font-size: 1rem; color: #06121a;
  background: #ffbf47; border-radius: 999px; padding: 6px 14px;
}
.ding-popup-title { font-weight: 700; font-size: 1.05rem; }
.ding-popup-timer { margin-left: auto; font-variant-numeric: tabular-nums; color: #9fb0c6; font-size: 0.95rem; }
.ding-popup-stage { position: relative; flex: 1; min-height: 0; background: #000; display: grid; place-items: center; }
.ding-popup-stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.ding-popup-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ding-popup-placeholder {
  position: absolute; inset: 0; display: grid; place-items: center; gap: 14px;
  color: #9fb0c6; text-align: center;
}
.ding-live-badge { position: absolute; top: 16px; left: 16px; }

/* ── Booth passcode gate ──────────────────────────────────────────────────── */
/* While locked, hide the dashboard chrome entirely so nothing flashes behind
   the gate (incl. the floating perf toggle). */
body.locked .topbar,
body.locked .dashboard,
body.locked .perf-toggle,
body.locked .perf-hud { display: none !important; }
.gate {
  position: fixed; inset: 0; z-index: 2000;
  display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #10213b 0%, #04070d 60%);
}
body:not(.locked) .gate { display: none; }
.gate-card {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: #0b1120; border: 1px solid #1b2740; border-radius: 18px;
  padding: 40px 36px; width: min(92vw, 380px); text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.gate-badge { font-size: 2.2rem; }
.gate-title { margin: 0; font-size: 1.4rem; color: #e6edf6; }
.gate-sub { margin: 0 0 6px; font-size: 0.88rem; color: #9fb0c6; }
.gate-input {
  width: 100%; font: inherit; font-size: 1.1rem; text-align: center; letter-spacing: 0.12em;
  padding: 13px 14px; border-radius: 11px; background: #121c30; color: #e6edf6;
  border: 1px solid #27354f;
}
.gate-input:focus { outline: 3px solid #4da3ff; outline-offset: 2px; border-color: #4da3ff; }
.gate-submit {
  width: 100%; font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer;
  padding: 13px 14px; border-radius: 11px; border: none;
  background: linear-gradient(135deg, #4da3ff, #7c5cff); color: #fff;
}
.gate-submit:hover { filter: brightness(1.07); }
.gate-error { margin: 2px 0 0; font-size: 0.85rem; color: #ff9ba3; }
.gate-card.shake { animation: gate-shake 0.4s; }
@keyframes gate-shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-8px); }
  40%,80% { transform: translateX(8px); }
}
.btn-ghost:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn-ghost.is-spinning svg { animation: spin 0.8s linear infinite; }

/* Device grid of cards */
.device-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px;
}
.device-card {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 18px; overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.device-card:not(.is-offline):hover {
  transform: translateY(-3px); border-color: var(--accent);
  box-shadow: 0 14px 40px rgba(0,0,0,0.4);
}
.device-thumb {
  position: relative; aspect-ratio: 16 / 10;
  display: grid; place-items: center; color: #46527a;
  background:
    radial-gradient(400px 200px at 50% 120%, rgba(77,124,255,0.18), transparent),
    repeating-linear-gradient(45deg, #0e1424, #0e1424 10px, #111931 10px, #111931 20px);
}
.device-card.is-offline .device-thumb { filter: grayscale(1) brightness(0.7); }
.status-pill {
  position: absolute; top: 12px; left: 12px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 700;
  backdrop-filter: blur(4px);
}
.status-pill.online { background: rgba(10,125,51,0.25); color: #7ff0a6; border: 1px solid rgba(10,125,51,0.5); }
.status-pill.offline { background: rgba(138,15,26,0.25); color: #ff9ba3; border: 1px solid rgba(138,15,26,0.5); }
.status-pill .dot { width: 8px; height: 8px; }
.status-pill.online .dot { background: #19c45c; box-shadow: 0 0 8px #19c45c; }
.status-pill.offline .dot { background: #ff6b74; }
.live-badge {
  position: absolute; top: 12px; right: 12px;
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.06em; color: #ff5b6b;
  background: rgba(0,0,0,0.4); padding: 4px 9px; border-radius: 6px;
  animation: blink 1.6s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: 0.45; } }

.device-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.device-name { font-size: 1.05rem; font-weight: 700; color: var(--ink); margin: 0; }
.btn-view {
  width: 100%; margin: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; font-size: 0.95rem; font-weight: 700; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #3a66e0); color: #fff; border: none; cursor: pointer;
}
.btn-view:hover:not([disabled]) { filter: brightness(1.08); }
.btn-view:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn-view[disabled] { background: #1c2338; color: #69728f; cursor: not-allowed; }

/* Skeleton loading */
.device-card.is-skeleton { pointer-events: none; }
.skel-thumb { aspect-ratio: 16 / 10; background: linear-gradient(100deg, #141b2e 30%, #1b2440 50%, #141b2e 70%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.skel-line { height: 16px; margin: 18px; border-radius: 6px; background: linear-gradient(100deg, #141b2e 30%, #1b2440 50%, #141b2e 70%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.device-note {
  grid-column: 1 / -1; list-style: none; text-align: center;
  padding: 20px 16px; color: var(--ink-muted); font-size: 0.9rem;
  background: var(--panel); border: 1px dashed var(--panel-border); border-radius: 12px;
}

.dashboard .note {
  margin-top: 28px; color: var(--ink-muted);
  background: var(--panel); border: 1px solid var(--panel-border);
}

/* Account pulldown (top-right) */
.account-menu { position: relative; }
.account-trigger {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 999px;
  padding: 6px 14px 6px 6px; cursor: pointer; font: inherit; color: var(--ink);
}
.account-trigger:hover { background: var(--panel-2); border-color: var(--accent); }
.account-trigger:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 0.95rem;
}
.account-email { font-weight: 600; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-label { font-weight: 600; color: var(--ink); }
.caret { color: var(--ink-muted); }

.account-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0;
  min-width: 250px; list-style: none; margin: 0; padding: 7px;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.5); z-index: 40;
}
.dropdown-header { padding: 10px 12px 12px; border-bottom: 1px solid var(--panel-border); margin-bottom: 6px; }
.dropdown-label { display: block; font-size: 0.72rem; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.dropdown-email { display: block; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-item {
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  font: inherit; color: var(--ink); padding: 11px 12px; border-radius: 9px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 10px;
}
.dropdown-item svg { color: var(--ink-muted); }
.dropdown-item:hover { background: var(--panel-2); }
.dropdown-item:focus-visible { outline: 3px solid var(--focus); outline-offset: -2px; }

@media (max-width: 720px) {
  .hero { flex-direction: column; align-items: flex-start; }
  .hero-pulse { display: none; }
  .stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .account-email { max-width: 130px; }
  .account-label { display: none; }
  .topbar .brand-name { display: none; }
  .brand-tagline { display: none; }
  .dashboard { padding: 24px 16px 60px; }
}

/* ── Live view ─────────────────────────────────────────────────────────── */
.backlink {
  text-decoration: none; color: var(--text); font-size: 1.3rem; font-weight: 700;
  width: 32px; height: 32px; display: inline-grid; place-items: center;
  border-radius: 8px;
}
.backlink:hover { background: #f3f4f8; }
.backlink:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.live-page .section-head { margin-bottom: 6px; }
.live-page h1 { font-size: 1.5rem; color: var(--ink); margin: 0; }

.live-stage {
  position: relative;
  margin: 14px 0 18px;
  aspect-ratio: 16 / 9;
  background: #060a14;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  display: grid; place-items: center;
  overflow: hidden;
}
.live-stage video {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: contain; background: #060a14;
}
.live-stage canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: contain; pointer-events: none;
}
.live-placeholder {
  position: relative; z-index: 2;
  text-align: center; color: #c9ccd6; max-width: 380px; padding: 24px;
}
.live-placeholder p { margin-top: 16px; }
.stage-live {
  position: absolute; top: 14px; right: 14px; z-index: 3;
  font-size: 0.78rem; background: rgba(0,0,0,0.5);
}

.live-controls { display: flex; gap: 12px; }
.live-controls .btn { width: auto; margin: 0; min-width: 150px; }
.btn-ghost-lg {
  width: auto; margin: 0; min-width: 110px;
  padding: 13px 18px; border-radius: 10px; font-weight: 700; cursor: pointer;
  background: var(--panel); color: var(--ink); border: 1px solid var(--panel-border);
}
.btn-ghost-lg:hover { background: var(--panel-2); border-color: var(--accent); }
.btn-ghost-lg:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Header chips (detection count + countdown) */
.live-meta { display: flex; align-items: center; gap: 10px; }
.detect-chip, .timer-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px; font-size: 0.82rem; font-weight: 700;
  background: var(--panel); border: 1px solid var(--panel-border); color: var(--ink);
}
.detect-chip .dot { width: 8px; height: 8px; background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); }
.timer-chip { color: var(--accent-2); font-variant-numeric: tabular-nums; }

/* ════════════════════════════════════════════════════════════════════════
   Focus-mode dashboard: device pulldown + live (left) + CV clip grid (right)
   ════════════════════════════════════════════════════════════════════════ */

/* Embedded live view (inside the dashboard iframe) — hide page chrome. */
body.embed .topbar,
body.embed .live-controls,
body.embed .note,
body.embed .section-head { display: none !important; }
body.embed .dashboard { padding: 0; max-width: none; }
body.embed .live-stage { margin: 0; border-radius: 0; height: 100%; }

/* Elite 360 carousel: a strip of all 6 lenses, 3 visible, stepping one lens at
   a time. The track transform is animated by a CSS transition (set in JS) so
   the slide runs on the compositor and stays smooth. */
.pano-viewport { position: absolute; inset: 0; overflow: hidden; background: #060a14; z-index: 2; }
.pano-track { display: flex; height: 100%; gap: 14px; padding: 0 7px; box-sizing: border-box; will-change: transform; }
.pano-cell {
  position: relative; height: 100%; background: #0b1020;
  border-radius: 10px; overflow: hidden; box-sizing: border-box;
}
.pano-cell video { width: 100%; height: 100%; object-fit: cover; display: block; background: #060a14; }
.pano-cell canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pano-cell-connecting { position: absolute; inset: 0; display: grid; place-items: center; }

/* Grid mode: all 6 lenses at once in a 2x3 grid (no horizontal scroll). */
.pano-viewport.grid-mode { padding: 7px; box-sizing: border-box; }
.pano-viewport.grid-mode .pano-track {
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr);
  gap: 10px; padding: 0; transform: none !important; width: 100%; height: 100%;
}
.pano-viewport.grid-mode .pano-cell { width: auto !important; height: auto; }
.multi-label {
  position: absolute; left: 8px; bottom: 8px; z-index: 3;
  background: rgba(0,0,0,0.6); color: #fff; font-size: 0.74rem; font-weight: 700;
  padding: 3px 10px; border-radius: 999px;
}
.multi-err { color: var(--ink-muted); font-size: 0.8rem; }

/* Fullscreen live stage: fill the screen, keep the overlay aligned. */
.live-stage:fullscreen,
.live-stage.is-fullscreen {
  width: 100vw; height: 100vh; margin: 0; border-radius: 0;
  background: #000; background-image: none !important;
}
.live-stage:fullscreen video,
.live-stage:fullscreen canvas { object-fit: contain; }
body.embed, body.embed .dashboard { height: 100%; }

.focus-layout { max-width: 1400px; }

/* Selector row */
.selector-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.selector-left { display: flex; align-items: center; gap: 12px; }
.selector-label { font-weight: 700; color: var(--ink-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; margin: 0; }
.stat-inline { color: var(--ink-muted); font-size: 0.9rem; }
.stat-inline strong { color: var(--ink); }

/* Visual device list — each camera shows its live snapshot thumbnail. */
.device-list {
  list-style: none; margin: 0 0 22px; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px;
}
.device-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px;
  cursor: pointer; transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.device-card:hover { border-color: #2d3a63; transform: translateY(-1px); }
.device-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.device-card.active { border-color: var(--brand, #1e6fff); box-shadow: 0 0 0 2px rgba(30,111,255,0.35); }
.device-card.offline { opacity: 0.6; cursor: not-allowed; }
.device-card.is-skeleton { pointer-events: none; min-height: 180px; background: linear-gradient(100deg,#141b2e 30%,#1b2440 50%,#141b2e 70%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border: 1px solid var(--panel-border); }

.device-thumb {
  position: relative; aspect-ratio: 16 / 9; width: 100%;
  max-height: 86px; /* keep the product image compact (~half previous size) */
  background: #0c1120 center/cover no-repeat;
  display: flex; align-items: center; justify-content: center;
}
.device-thumb.has-img .device-thumb-fallback { display: none; }
.device-thumb-fallback { color: #39456e; }
/* Ring product image (attributes.image_url) — a transparent PNG, so contain it
   with a little padding rather than cropping like a photo. */
.device-prod-img { width: 100%; height: 100%; object-fit: contain; padding: 6px; box-sizing: border-box; display: block; }

.device-info { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; }
.device-name { font-weight: 700; color: var(--ink); font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; white-space: nowrap; }
.device-badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.device-badge.online { background: rgba(10,125,51,0.22); color: #7ff0a6; border: 1px solid rgba(10,125,51,0.5); }
.device-badge.online .dot { background: #19c45c; box-shadow: 0 0 8px #19c45c; }
.device-badge.offline { background: rgba(138,15,26,0.22); color: #ff9ba3; border: 1px solid rgba(138,15,26,0.5); }
.device-badge.offline .dot { background: #ff6b74; }
.comp-badge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 0.66rem; font-weight: 700; background: rgba(34,211,238,0.15); color: var(--accent-2); border: 1px solid rgba(34,211,238,0.4); vertical-align: middle; }

/* Two-column focus */
.focus { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; align-items: start; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head h2 { font-size: 1.1rem; margin: 0; color: var(--ink); }
.panel-head-right { display: inline-flex; align-items: center; gap: 10px; }

.focus-live { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 18px; padding: 16px; min-width: 0; }
.live-frame-wrap { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #060a14; }
.live-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.live-note { margin-top: 12px; }

/* Performance HUD (client-side load monitor). */
.perf-toggle {
  position: fixed; top: 10px; right: 12px; z-index: 200;
  background: rgba(10,14,26,0.85); color: var(--accent-2); border: 1px solid var(--panel-border);
  border-radius: 999px; padding: 4px 11px; font-size: 0.72rem; font-weight: 700; cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.perf-toggle:hover { border-color: var(--accent-2); }
.perf-hud {
  position: fixed; top: 44px; right: 12px; z-index: 200; width: 190px;
  background: rgba(10,14,26,0.92); border: 1px solid var(--panel-border); border-radius: 12px;
  padding: 10px 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5); backdrop-filter: blur(4px);
}
.perf-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.74rem; padding: 2px 0; color: var(--ink-muted); }
.perf-row strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.perf-hint { margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--panel-border); font-size: 0.68rem; color: var(--ink-muted); }

/* Detected-people filmstrip (newest first) under the live tile. Fixed-size
   tiles + reserved row height so adding a snapshot never reflows the page. */
.people-strip { margin: 12px 0 4px; max-width: 100%; min-width: 0; }
.people-strip-label { display: block; font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-muted); margin-bottom: 8px; }
.people-strip-items {
  display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding-bottom: 4px;
  min-height: 128px; align-items: flex-start; /* reserve height even when empty */
  width: 100%; max-width: 100%; min-width: 0; /* contain the scroll; don't grow the column */
}
.person-thumb {
  position: relative; flex: 0 0 auto; width: 84px; height: 120px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--panel-border); background: #0b1120;
  animation: personPop 0.3s ease;
}
.person-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
.person-ts {
  position: absolute; bottom: 0; left: 0; right: 0; text-align: center;
  font-size: 0.6rem; font-weight: 700; color: #fff; background: rgba(0,0,0,0.55);
  padding: 1px 0; font-variant-numeric: tabular-nums;
}
@keyframes personPop { from { opacity: 0; transform: translateX(-6px) scale(0.96); } to { opacity: 1; transform: none; } }

.focus-clips { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 18px; padding: 16px; min-width: 0; }
.clips-sub { color: var(--ink-muted); font-size: 0.86rem; margin: 0 0 14px; }
.clips-sub strong { color: var(--accent-2); }

/* Toggle switch: "Show empty events" */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: relative; width: 38px; height: 22px; border-radius: 999px;
  background: #2a3550; border: 1px solid var(--panel-border); transition: background 0.15s;
  flex-shrink: 0;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #cdd4ea; transition: transform 0.15s, background 0.15s;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch-label { font-size: 0.82rem; font-weight: 600; color: var(--ink-muted); white-space: nowrap; }

/* 2 x 10 grid of clip tiles */
.clip-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  max-height: 70vh; overflow-y: auto;
}
.clip-tile {
  background: #0e1526; border: 1px solid var(--panel-border); border-radius: 12px;
  overflow: hidden; cursor: pointer; transition: border-color 0.15s, transform 0.15s;
}
.clip-tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.clip-tile:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.clip-thumb { position: relative; aspect-ratio: 16 / 9; background: #060a14; display: grid; place-items: center; overflow: hidden; }
.clip-thumb video, .clip-thumb .clip-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.clip-del {
  position: absolute; top: 6px; right: 6px; z-index: 4;
  width: 26px; height: 26px; border-radius: 7px; border: none; cursor: pointer;
  background: rgba(0,0,0,0.55); color: #ff9ba3; font-size: 13px; line-height: 1;
  opacity: 0; transition: opacity 0.15s;
}
.clip-tile:hover .clip-del { opacity: 1; }
.clip-del:hover { background: rgba(138,15,26,0.8); color: #fff; }
.clip-more { grid-column: 1 / -1; display: flex; justify-content: center; padding: 6px 0; }
.clip-more .btn-ghost { width: auto; }
.clip-play {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; font-size: 1.6rem; text-shadow: 0 2px 8px rgba(0,0,0,0.7);
  background: rgba(0,0,0,0.15); opacity: 0; transition: opacity 0.15s;
}
.clip-tile:hover .clip-play { opacity: 1; }
.clip-thumb.pending, .clip-thumb.failed { color: var(--ink-muted); font-size: 1.5rem; }
.clip-raw { width: 100%; height: 100%; object-fit: cover; display: block; }
.analyzing-badge {
  position: absolute; top: 6px; left: 6px; z-index: 3; display: inline-flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,0.6); color: var(--accent-2); font-size: 0.68rem; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
}
.spinner-xs { width: 10px; height: 10px; border: 2px solid rgba(34,211,238,0.3); border-top-color: var(--accent-2); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
.clip-thumb.norec { color: #5b6a8e; background: #0b1120; position: relative; }
.norec-lens { position: absolute; bottom: 6px; left: 6px; font-size: 0.68rem; font-weight: 700; color: var(--accent-2); background: rgba(0,0,0,0.5); padding: 1px 7px; border-radius: 999px; }
.clip-meta { padding: 7px 9px; display: flex; flex-direction: column; gap: 2px; }
.clip-time { font-size: 0.74rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.clip-labels { font-size: 0.8rem; color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip-tile.is-skeleton { aspect-ratio: auto; }
.clip-tile.is-skeleton::before { content: ""; display: block; aspect-ratio: 16 / 9; background: linear-gradient(100deg,#141b2e 30%,#1b2440 50%,#141b2e 70%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.clip-empty { grid-column: 1 / -1; text-align: center; padding: 36px 16px; color: var(--ink-muted); display: flex; flex-direction: column; gap: 6px; }
.clip-empty strong { color: var(--ink); font-size: 1rem; }
.clip-empty em { color: var(--accent-2); font-style: normal; font-weight: 700; }

.spinner-sm { width: 24px; height: 24px; border: 3px solid #2a3550; border-top-color: var(--accent-2); border-radius: 50%; animation: spin 0.9s linear infinite; }

/* ── "Show raw API" button + inspector modal (demo) ───────────────────────── */
.api-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(34,211,238,0.1); color: var(--accent-2);
  border: 1px solid rgba(34,211,238,0.4); border-radius: 8px;
  padding: 4px 9px; font: inherit; font-weight: 700; font-size: 0.74rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.02em; cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.api-btn:hover { background: rgba(34,211,238,0.2); border-color: var(--accent-2); }
.api-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.api-card { max-width: min(900px, 94vw); width: 900px; max-height: 86vh; display: flex; flex-direction: column; }
.api-sub { color: var(--ink-muted); font-size: 0.85rem; margin: 0 0 12px; }
.api-trace-body { overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.api-empty { color: var(--ink-muted); text-align: center; padding: 28px 12px; }

.api-entry { border: 1px solid var(--panel-border); border-radius: 12px; overflow: hidden; }
.api-entry-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 13px; background: #0e1526; color: var(--ink); font-weight: 700; font-size: 0.9rem;
  border-bottom: 1px solid var(--panel-border);
}
.api-tag { background: rgba(255,191,71,0.18); color: var(--focus); border: 1px solid rgba(255,191,71,0.4); border-radius: 999px; padding: 1px 8px; font-size: 0.66rem; font-weight: 700; }
.api-ms { margin-left: auto; color: var(--ink-muted); font-size: 0.74rem; font-variant-numeric: tabular-nums; }
.api-col { padding: 10px 13px; }
.api-col + .api-col { border-top: 1px dashed var(--panel-border); }
.api-col-label { display: block; font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-muted); margin-bottom: 6px; }
.api-status { border-radius: 6px; padding: 1px 7px; font-size: 0.72rem; font-weight: 800; margin-left: 6px; }
.api-status.s2 { background: rgba(10,125,51,0.25); color: #7ff0a6; }
.api-status.s4, .api-status.s5 { background: rgba(138,15,26,0.25); color: #ff9ba3; }
.api-pre {
  margin: 0; padding: 11px 12px; border-radius: 9px; background: #060a14; color: #cde8ee;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow-y: auto;
}
.api-pre.req { color: #bfe3ff; }

/* Clip modal */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.modal[hidden] { display: none; }  /* [hidden] must win over display:grid */
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.7); }
.modal-card {
  position: relative; z-index: 1; width: min(820px, 92vw);
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 16px; padding: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal-head h3 { margin: 0; font-size: 1rem; color: var(--ink); }
.icon-btn { background: none; border: none; color: var(--ink-muted); font-size: 1.1rem; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }
.modal-video { width: 100%; border-radius: 12px; background: #000; max-height: 60vh; }
.modal-narration { color: var(--ink); margin: 12px 0 8px; font-size: 0.95rem; }
.modal-labels { display: flex; flex-wrap: wrap; gap: 6px; }
.label-chip { background: rgba(34,211,238,0.14); color: var(--accent-2); border: 1px solid rgba(34,211,238,0.4); border-radius: 999px; padding: 3px 10px; font-size: 0.78rem; font-weight: 700; }

@media (max-width: 900px) {
  .focus { grid-template-columns: 1fr; }
  .clip-grid { max-height: none; }
}
