/* McD NVR. Color is a signal: red records, amber moves, blue is a person, violet a
   vehicle, green is manual or healthy. Chrome stays neutral so video and signals read
   at a glance at night. */

:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Roboto Mono", monospace;

  --bg: #0f1318;
  --bg-2: #151a21;
  --bg-3: #1b222b;
  --bg-4: #252e39;
  --line: #242c37;
  --line-2: #323d4b;
  --text: #e8ecf1;
  --text-2: #b4bdc8;
  --muted: #808b99;
  --primary: #e8ecf1;
  --on-primary: #0f1318;
  --focus: #8ab4ff;

  --rec: #ff4f45;
  --motion: #f5b82e;
  --person: #5aa8ff;
  --vehicle: #b38cff;
  --manual: #3ccf8e;
  --alert: #ff7096;
  --ok: #3ccf8e;
  --warn: #f5b82e;
  --err: #ff5d55;
  --band: #3a4757;
  --band-sub: #2c3644;
  --range: rgba(90, 168, 255, .16);
  --range-edge: #5aa8ff;

  --tile: #07090c;
  --shadow: 0 12px 40px rgba(0, 0, 0, .5);
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 14px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --ease-out: cubic-bezier(.23, 1, .32, 1);       /* strong ease-out: entering and leaving */
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);   /* moving across the screen */
  --top-h: 56px;
  --tab-h: 0px;
  --gut: 16px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #eef1f5;
  --bg-2: #ffffff;
  --bg-3: #f5f7fa;
  --bg-4: #e4e9ef;
  --line: #dce2e9;
  --line-2: #c6ced8;
  --text: #121821;
  --text-2: #3c4756;
  --muted: #667283;
  --primary: #121821;
  --on-primary: #ffffff;
  --focus: #2563eb;
  --rec: #e3342b;
  --motion: #c88a00;
  --person: #1f6fe0;
  --vehicle: #7a4ee0;
  --manual: #13985f;
  --alert: #d4376a;
  --ok: #13985f;
  --warn: #b97f00;
  --err: #d92d24;
  --band: #b4c0cd;
  --band-sub: #d0d8e1;
  --range: rgba(31, 111, 224, .12);
  --range-edge: #1f6fe0;
  --shadow: 0 12px 40px rgba(20, 30, 45, .18);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  font: 15px/1.45 var(--font);
  color: var(--text);
  background: var(--bg);
  overscroll-behavior: none;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; }
img { display: block; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

button, a, [role="button"], .tab, .chip, label.switch {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.ico {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}

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

#app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  height: calc(var(--top-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) max(var(--gut), env(safe-area-inset-right, 0px)) 0 max(var(--gut), env(safe-area-inset-left, 0px));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; min-height: 44px; flex: none;
  font-size: 17px; letter-spacing: -.01em;
}
.brand-name { font-weight: 500; }
.brand-name b { font-weight: 750; }

.status-dot {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: var(--muted);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--muted) 22%, transparent);
}
.status-dot.rec { background: var(--rec); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rec) 22%, transparent); }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 25%, transparent); }

.nav-top { display: flex; align-items: stretch; height: 100%; gap: 4px; }
.nav-top a {
  position: relative; display: flex; align-items: center; gap: 6px;
  padding: 0 12px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14.5px;
}
.nav-top a[aria-current="page"] { color: var(--text); }
.nav-top a[aria-current="page"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px;
  background: var(--text); border-radius: 2px 2px 0 0;
}

.nav-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--rec); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

.page-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.top-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.page-actions + .top-actions { margin-left: 0; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; z-index: 30;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-m);
  box-shadow: var(--shadow); padding: 6px;
}
.menu-head { padding: 8px 10px 10px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-head b { color: var(--text); font-weight: 650; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 10px;
  border: 0; background: none; border-radius: 8px; text-align: left; cursor: pointer;
}
.menu-item:active { background: var(--bg-4); }

#view {
  position: relative;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  outline: none;
}

.tabbar { display: none; }

@media (max-width: 759px) {
  :root { --top-h: 48px; --tab-h: 58px; }
  .topbar { gap: 10px; }
  .nav-top { display: none; }
  .brand { font-size: 16px; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    background: var(--bg); border-top: 1px solid var(--line);
    position: relative; z-index: 20;
  }
  .tab {
    height: var(--tab-h);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    text-decoration: none; color: var(--muted); font-size: 11.5px; font-weight: 600;
  }
  .tab-ico {
    position: relative; display: grid; place-items: center;
    width: 54px; height: 30px; border-radius: 15px; transition: background-color .15s var(--ease);
  }
  .tab[aria-current="page"] { color: var(--text); }
  .tab[aria-current="page"] .tab-ico { background: var(--bg-4); }
  .tab .nav-badge { position: absolute; top: -2px; right: 6px; }
  .nav-top .nav-badge { display: none; }
}

body[data-page="login"] .topbar .brand,
body[data-page="login"] .nav-top,
body[data-page="login"] .tabbar,
body[data-page="login"] .top-actions .menu-wrap { display: none !important; }

/* ---------- controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; min-width: 44px; padding: 0 14px;
  border-radius: var(--r-m); border: 1px solid var(--line-2);
  background: var(--bg-3); color: var(--text);
  font-weight: 600; font-size: 14.5px; line-height: 1; white-space: nowrap;
  cursor: pointer; text-decoration: none;
  transition: transform .1s var(--ease), background-color .12s, border-color .12s, opacity .12s;
}
.btn:active { transform: scale(.97); background: var(--bg-4); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.icon { padding: 0; width: 44px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:active { background: var(--bg-4); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.btn.primary:active { opacity: .85; }
.btn.danger { color: var(--err); }
.btn.danger-solid { background: var(--err); color: #fff; border-color: transparent; }
.btn.on { background: var(--text); color: var(--bg); border-color: transparent; }
.btn .ico { width: 20px; height: 20px; }

.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px;
  background: var(--bg-3); border: 1px solid var(--line);
}
.seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; min-width: 44px; padding: 0 12px; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted); font-weight: 650; font-size: 14px; cursor: pointer;
  transition: background-color .12s, color .12s;
}
.seg button[aria-pressed="true"] { background: var(--bg-4); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg button .ico { width: 18px; height: 18px; }

.chip {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  min-height: 40px; min-width: 44px; justify-content: center; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-2); background: transparent; color: var(--text-2);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: transparent; }
.chip .ico { width: 18px; height: 18px; }
.chip .swatch { width: 9px; height: 9px; border-radius: 50%; flex: none; }
@media (pointer: coarse) { .chip, .seg button { min-height: 44px; } .st-links a { min-height: 44px; } }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.input, select.input {
  min-height: 44px; width: 100%; padding: 0 12px;
  border-radius: var(--r-m); border: 1px solid var(--line-2); background: var(--bg-3);
}
select.input { padding-right: 32px; }

.switch { position: relative; display: inline-block; width: 50px; height: 30px; flex: none; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0; border-radius: 15px; background: var(--bg-4);
  box-shadow: inset 0 0 0 1px var(--line-2); transition: background-color .15s var(--ease);
  pointer-events: none;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--text-2); transition: transform .18s var(--ease), background-color .15s;
}
.switch input:checked + span { background: var(--ok); box-shadow: none; }
.switch input:checked + span::after { transform: translateX(20px); background: #fff; }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

input[type="range"] { width: 100%; accent-color: var(--text); min-height: 32px; }

.empty {
  display: grid; justify-items: center; align-content: center; gap: 10px; text-align: center;
  min-height: 50vh; padding: 32px var(--gut); color: var(--muted);
}
.empty h2 { color: var(--text); }
.empty .ico { width: 34px; height: 34px; }

.sk {
  background: linear-gradient(100deg, var(--bg-3) 30%, var(--bg-4) 50%, var(--bg-3) 70%);
  background-size: 300% 100%;
  animation: sk 1.6s ease-in-out infinite;
  border-radius: var(--r-s);
}
@keyframes sk { from { background-position: 100% 0; } to { background-position: 0 0; } }

#toast {
  position: fixed; left: 50%; z-index: 100;
  bottom: calc(20px + var(--tab-h) + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 460px); padding: 12px 16px; border-radius: var(--r-m);
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px; box-shadow: var(--shadow);
  transition: opacity .18s var(--ease), transform .18s var(--ease);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--err); color: #fff; }

.modal-back {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, .55);
}
.modal {
  width: min(420px, 100%); padding: 20px; border-radius: var(--r-l);
  background: var(--bg-2); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  display: grid; gap: 12px;
}
.modal p { color: var(--text-2); }
.install-steps { margin: 0; padding-left: 22px; display: grid; gap: 8px; color: var(--text-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* Panels that sit over video keep dark tokens in both themes. */
.on-dark {
  --bg-3: rgba(255, 255, 255, .09);
  --bg-4: rgba(255, 255, 255, .18);
  --line: rgba(255, 255, 255, .1);
  --line-2: rgba(255, 255, 255, .16);
  --text: #f2f5f8;
  --text-2: #c9d0d8;
  --muted: #a1abb7;
  --primary: #f2f5f8;
  --on-primary: #0b0e12;
  --rec: #ff4f45;
  --motion: #f5b82e;
  color: var(--text);
}

/* ---------- live wall ---------- */

.wall { position: relative; }

.tile {
  position: absolute; overflow: hidden; border-radius: 4px;
  background: var(--tile); color: #fff; text-decoration: none;
  contain: strict;
}
.tile .poster, .tile .mosaic, .tile nvr-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
}
.tile .poster { object-fit: cover; opacity: 0; transition: opacity .2s; }
.tile.has-poster .poster { opacity: 1; }
.tile.is-live .poster { opacity: 0; transition-delay: .1s; }
/* The tile's rectangle of the wall's joined video (wallmosaic.js), under its own stream. */
.tile .mosaic { display: block; object-fit: cover; opacity: 0; transition: opacity .2s; }
.tile.is-mosaic .mosaic { opacity: 1; }
.tile nvr-video { display: block; opacity: 0; transition: opacity .2s; }
.tile.is-live nvr-video { opacity: 1; }
/* The joined video itself: in the viewport, or Chrome on Android pauses it, but not seen. */
.wall-mosaic-src {
  position: fixed; left: 0; bottom: 0; width: 2px; height: 2px; overflow: hidden;
  opacity: .01; pointer-events: none;
}
.tile.loading:not(.has-poster):not(.is-mosaic) {
  background: linear-gradient(100deg, #0b0e12 30%, #161b22 50%, #0b0e12 70%);
  background-size: 300% 100%; animation: sk 1.6s ease-in-out infinite;
}
.tile::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 0 transparent; transition: box-shadow .12s;
}
.tile.is-motion::after { box-shadow: inset 0 0 0 2px #f5b82e, inset 0 0 18px rgba(245, 184, 46, .25); }

/* Top-left: every camera burns its clock into the bottom-left corner. */
.umd {
  position: absolute; left: 4px; top: 4px; max-width: calc(100% - 8px);
  display: flex; align-items: center; gap: 6px;
  padding: 3px 7px; border-radius: 5px;
  background: rgba(0, 0, 0, .58);
  font-size: 12.5px; font-weight: 650; line-height: 1.25;
  pointer-events: none;
}
.umd .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: #ff4f45; flex: none; box-shadow: 0 0 0 2px rgba(0, 0, 0, .35); }
.tile:not(.is-rec) .rec-dot { display: none; }
.umd .mo { display: none; color: #f5b82e; margin: -2px 0; }
.umd .mo .ico { width: 18px; height: 18px; stroke-width: 2.4; }
.tile.is-motion .umd .mo { display: inline-flex; }

.tile-state {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; color: rgba(255, 255, 255, .8); text-align: center; padding: 8px;
  pointer-events: none;
}
.tile-state:empty { display: none; }
.tile-state .ico { width: 22px; height: 22px; opacity: .8; }
.tile-state small { font-weight: 500; opacity: .75; }
.tile.is-offline { background: #101419; }
.tile { container-type: size; }
@container (max-height: 130px) { .tile-state { padding-top: 22px; } .tile-state small { display: none; } }
.tile.is-offline .poster { filter: grayscale(1) brightness(.35); }
.tile .badge-err {
  position: absolute; bottom: 6px; right: 6px; padding: 2px 6px; border-radius: 5px;
  background: rgba(0, 0, 0, .6); font-size: 11px; font-weight: 650; color: #ffd0cc;
}
.tile:not(.is-error) .badge-err, .tile.is-mosaic .badge-err { display: none; }

@media (hover: hover) and (pointer: fine) {
  .tile:hover::after { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .5); }
  .tile.is-motion:hover::after { box-shadow: inset 0 0 0 2px #f5b82e; }
  .btn:hover { background: var(--bg-4); }
  .btn.primary:hover { background: var(--primary); opacity: .9; }
  .btn.ghost:hover { background: var(--bg-3); }
  .chip:hover { border-color: var(--text-2); }
  .chip[aria-pressed="true"]:hover { border-color: transparent; }
  .seg button:hover { color: var(--text); }
  .menu-item:hover { background: var(--bg-3); }
  .nav-top a:hover { color: var(--text); }
}

/* ---------- live page: rail, groups, arrange ---------- */

.live { display: grid; grid-template-columns: minmax(0, 1fr); height: 100%; }
.live.rail-on { grid-template-columns: var(--rail-w, 280px) minmax(0, 1fr); }
@media (min-width: 1400px) { .live { --rail-w: 300px; } }
@media (max-width: 1099px) { .live { --rail-w: 264px; } }
.live-main { position: relative; overflow: auto; overscroll-behavior: contain; min-width: 0; padding: 3px; }
.live-rail { display: none; }
.live.rail-on .live-rail {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  border-right: 1px solid var(--line); background: var(--bg);
}
.rail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 12px 14px 8px; }
.rail-head h2 { font-size: 15px; }
.rail-all { color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; padding: 0 8px; margin: -12px -8px -8px 0; }
.live-rail .feed { flex: 1; min-height: 0; }
.live-rail .status-widget { border-top: 1px solid var(--line); }
/* Wide screens: an open camera (solo.js) covers the wall where it is scrolled to, and the rail
   lists the camera's alerts. The wall stays laid out under it (inert), so the camera can fade
   in over it and back out while its picture flies to and from its tile (hero.js). */
.live.has-solo .live-main { overflow: hidden; }
.hero-still { position: fixed; z-index: 45; transform-origin: 0 0; pointer-events: none; border-radius: 4px; }

.wall-groups {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 5px 4px 8px;
  overscroll-behavior-x: contain;
}
.wall-groups::-webkit-scrollbar { display: none; }

.alerts-btn { position: relative; }
.alerts-btn .nav-badge { position: absolute; top: 4px; right: 2px; }
.alerts-btn[aria-pressed="true"] { background: var(--bg-3); }
@media (min-width: 760px) and (max-width: 1099px) { .page-actions .btn .lbl { display: none; } .page-actions .btn { padding: 0; width: 44px; } }
@media (max-width: 759px) {
  .alerts-btn { display: none; }
  .page-actions .btn .lbl { display: none; }
  .page-actions .btn { padding: 0; width: 44px; }
  #theme-btn { display: none; }
}
@media (max-width: 399px) {
  .topbar { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
  .page-actions { gap: 2px; }
}
@media (max-width: 389px) {
  .topbar:has(.page-actions > :nth-child(2)) .brand-name { display: none; }
}

.arrange-bar {
  position: sticky; top: -3px; z-index: 6; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  margin: -3px -3px 6px; padding: 10px 12px; background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.arrange-bar p { flex: 1 1 320px; color: var(--text-2); font-size: 14px; }
.arrange-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.wall.arranging .tile { transition: left .18s var(--ease), top .18s var(--ease), width .18s var(--ease), height .18s var(--ease), opacity .15s; cursor: default; }
.wall.arranging .tile.dragging { transition: none; z-index: 10; box-shadow: 0 16px 40px rgba(0, 0, 0, .55); outline: 2px solid #fff; cursor: grabbing; }
.wall.arranging .tile.arr-is-hidden .poster, .wall.arranging .tile.is-mosaic.arr-is-hidden .mosaic { opacity: .25 !important; filter: grayscale(1); }
/* A hidden tile on the joined video dims its live picture; the snapshot under it stays out. */
.wall.arranging .tile.is-mosaic.arr-is-hidden .poster { opacity: 0 !important; }
.arr-ctl {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px;
  background: rgba(0, 0, 0, .28);
}
.arr-ctl .btn { background: rgba(10, 13, 17, .78); border-color: rgba(255, 255, 255, .22); color: #fff; }
.arr-grip { cursor: grab; touch-action: none; }
.arr-row { display: flex; gap: 6px; }
.arr-hidden {
  display: none; position: absolute; right: 6px; top: 6px; padding: 2px 7px; border-radius: 5px;
  background: rgba(0, 0, 0, .7); color: #fff; font-size: 12px; font-weight: 700;
}
.tile.arr-is-hidden .arr-hidden { display: block; }
.wall.arranging .badge-err, .wall.arranging .tile-state { display: none; }

/* ---------- alert feed ---------- */

.feed { display: flex; flex-direction: column; min-height: 0; }
.feed-scroll { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; flex: 1; min-height: 0; padding: 0 8px 10px; }
.feed-day { padding: 10px 6px 4px; color: var(--muted); font-size: 12.5px; font-weight: 650; }
.feed-item {
  display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 10px; align-items: center;
  width: 100%; padding: 6px; border: 0; border-radius: var(--r-m); background: none; text-align: left; cursor: pointer;
}
.feed-item:active { background: var(--bg-3); }
.feed-media { position: relative; aspect-ratio: 16 / 9; border-radius: 7px; overflow: hidden; background: var(--bg-3); }
.feed-media img, .feed-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.feed-media video { opacity: 0; transition: opacity .2s; }
.feed-media.playing video { opacity: 1; }
.feed-media .type {
  position: absolute; left: 4px; top: 4px; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px;
  background: rgba(0, 0, 0, .62);
}
.feed-media .type .ico { width: 15px; height: 15px; stroke-width: 2.2; }
.feed-media .type.t-person { color: #8cc4ff; }
.feed-media .type.t-vehicle { color: #cdb3ff; }
.feed-media .type.t-manual { color: #74e2b1; }
.feed-media .type.t-alert { color: #ff9fb8; }
.feed-media .dur, .feed-media .live-chip {
  position: absolute; right: 4px; bottom: 4px; padding: 1px 5px; border-radius: 4px; font-size: 11px; font-weight: 700;
  background: rgba(0, 0, 0, .66); color: #fff;
}
.feed-media .live-chip { background: #ff4f45; }
.feed-meta { display: grid; gap: 2px; min-width: 0; }
.feed-meta .l1 { display: flex; align-items: center; gap: 6px; font-weight: 650; font-size: 14px; min-width: 0; }
.feed-meta .l1 .cam { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-meta .l2 { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.feed-meta .swatch { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.feed-item.unseen .feed-meta .l1::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--person); margin-left: auto; flex: none; }
.feed-item.is-new { animation: feednew 1.4s var(--ease); }
@keyframes feednew { from { background: color-mix(in srgb, var(--motion) 22%, transparent); } to { background: transparent; } }
.feed-item.sk-item { pointer-events: none; }
.feed-empty { display: grid; justify-items: center; gap: 6px; padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13.5px; }
.feed-empty b { color: var(--text); }
.feed-empty .ico { width: 28px; height: 28px; }
.feed-end { padding: 8px; text-align: center; color: var(--muted); font-size: 12px; }
@media (hover: hover) and (pointer: fine) { .feed-item:hover { background: var(--bg-2); } }

/* Hover peek (feed.js): a bigger preview beside the item under the mouse. It grows out of the
   item (transform-origin set from JS), slides between items, and never takes the mouse. The
   global reduced-motion rule makes all of it instant. */
.feed-peek { position: fixed; left: 0; top: 0; z-index: 70; pointer-events: none; will-change: transform; }
.feed-peek.moving { transition: transform 180ms var(--ease-in-out); }
.peek-card {
  overflow: hidden; border-radius: var(--r-m); background: #0b0e12; color: #f2f5f8;
  border: 1px solid rgba(255, 255, 255, .12); box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
  opacity: 0; transform: scale(.96);
  transition: opacity 120ms var(--ease-out), transform 120ms var(--ease-out);
}
.feed-peek.open .peek-card { opacity: 1; transform: none; transition-duration: 160ms; }
.peek-frame { position: relative; background: #000; }
.peek-frame img, .peek-frame video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: contain; }
.peek-frame video { opacity: 0; transition: opacity 160ms var(--ease-out); }
.peek-frame.playing video { opacity: 1; }
.peek-cap { display: flex; align-items: center; gap: 12px; padding: 8px 11px; font-size: 12.5px; font-weight: 650; white-space: nowrap; }
.peek-cap > span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.peek-cap .ico { width: 15px; height: 15px; flex: none; }
.peek-type.t-person { color: #8cc4ff; }
.peek-type.t-vehicle { color: #cdb3ff; }
.peek-type.t-manual { color: #74e2b1; }
.peek-type.t-alert { color: #ff9fb8; }
.peek-cam { color: #e6ebf0; overflow: hidden; text-overflow: ellipsis; }
.peek-cam .swatch { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.peek-time { margin-left: auto; color: #a1abb7; font-variant-numeric: tabular-nums; }
.peek-dur { margin-left: 3px; padding: 1px 6px; border-radius: 5px; background: rgba(255, 255, 255, .1); color: #e6ebf0; font-size: 11.5px; }
.feed-media { transition: box-shadow 160ms var(--ease-out); }
.feed-item.peeking .feed-media { box-shadow: 0 0 0 2px rgba(255, 255, 255, .55); }

/* ---------- bottom sheet (phones) ---------- */

.sheet-back {
  position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, 0); transition: background-color .2s;
}
.sheet-back.open { background: rgba(0, 0, 0, .5); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; height: min(78dvh, 640px);
  display: flex; flex-direction: column; border-radius: 16px 16px 0 0;
  background: var(--bg); border-top: 1px solid var(--line-2); box-shadow: var(--shadow);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateY(100%); transition: transform .24s var(--ease);
}
.sheet-back.open .sheet { transform: translateY(0); }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 8px auto 2px; flex: none; touch-action: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 0 6px 4px 16px; touch-action: none; }
.sheet-head h2 { margin-right: auto; }
.sheet-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sheet-body .feed { flex: 1; }

/* ---------- server status ---------- */

.status-wrap { flex: none; }
.status-btn {
  display: grid; place-items: center; width: 44px; height: 44px; margin: 0 -17px 0 -5px; padding: 0;
  border: 0; background: none; cursor: pointer;
}
.status-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 25%, transparent); }
.status-dot.error { background: var(--err); box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 25%, transparent); }
.status-pop { left: 0; right: auto; width: 270px; padding: 0; }
body[data-page="login"] .status-wrap, body[data-page="setup"] .status-wrap,
body[data-page="setup"] .topbar .brand, body[data-page="setup"] .nav-top, body[data-page="setup"] .tabbar,
body[data-page="setup"] .top-actions .menu-wrap { display: none !important; }

.status-widget { display: grid; gap: 6px; padding: 12px 14px; font-size: 12.5px; }
.st-head { display: flex; align-items: center; gap: 8px; }
.st-head b { font-size: 13.5px; }
.st-count { margin-left: auto; color: var(--muted); font-weight: 600; }
.st-light { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.st-light.ok { background: var(--ok); }
.st-light.warn { background: var(--warn); }
.st-light.error { background: var(--err); }
.st-note { color: var(--text-2); font-size: 12.5px; }
.st-row { display: grid; grid-template-columns: 38px 1fr 52px; align-items: center; gap: 8px; }
.st-label { color: var(--muted); font-weight: 700; font-size: 11.5px; }
.st-bar { height: 6px; border-radius: 3px; background: var(--bg-4); overflow: hidden; }
.st-bar i { display: block; height: 100%; width: 0; background: var(--text-2); border-radius: 3px; transition: width .4s var(--ease); }
.st-bar i.warn { background: var(--warn); }
.st-bar i.err { background: var(--err); }
.st-val { text-align: right; font-weight: 650; color: var(--text-2); }

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

body.modal-open { overflow: hidden; }
.solo-back {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(3, 5, 8, .78); animation: fadein .16s var(--ease);
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.solo-back.closing { opacity: 0; transition: opacity .15s; }
@keyframes fadein { from { opacity: 0; } }
.solo-panel {
  position: relative; display: flex; flex-direction: column; max-width: 100vw; overflow: hidden;
  border-radius: var(--r-l); background: #0b0e12; box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
  animation: soloin .2s var(--ease); outline: none;
  transition: transform .2s var(--ease);
}
@keyframes soloin { from { opacity: 0; transform: translateY(14px) scale(.985); } }
@keyframes sheetup { from { transform: translateY(100%); } }
.solo-panel:fullscreen { width: 100% !important; height: 100%; border-radius: 0; }
.solo-panel { flex-direction: row; }
.solo-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.solo-grip { display: none; }
/* contain: size keeps a long alert list from setting the panel's height: the column takes the
   video column's height and its list scrolls (30 Driveway alerts pushed the header off screen). */
.solo-alerts { display: flex; flex-direction: column; width: 320px; flex: none; min-height: 0; contain: size; border-left: 1px solid rgba(255, 255, 255, .08); background: #0f1318; }
.solo-alerts-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 0 14px; }
.solo-alerts-head h2 { font-size: 15px; }
.solo-alerts-all { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; }
.solo-alerts .feed { flex: 1; min-height: 0; }
.solo-panel:fullscreen .solo-alerts { display: none; }
.solo-panel:fullscreen .solo-stage { height: auto !important; flex: 1; }
/* With the alerts beside the video, Close goes to the panel's top-right corner, over the
   alerts' head, not the corner of the video column. Full screen hides the alerts, so it
   goes back to the end of the top bar. */
@media (min-width: 760px) {
  .solo-close { position: absolute; top: 6px; right: 8px; }
  .solo-panel:fullscreen .solo-close { position: static; }
  .solo-alerts-head { padding-right: 56px; }
}
/* In the page (wide screens), the camera fills the wall's area: no backdrop or shadow, the
   video takes what the bars leave, and Close ends the top bar. */
.solo-inline {
  position: absolute; z-index: 5; left: 3px; right: 3px; top: calc(var(--wall-scroll, 0px) + 3px); height: calc(100% - 6px);
  max-width: none; border: 1px solid var(--line); border-radius: var(--r-m);
  box-shadow: none; animation: fadein .18s var(--ease-out);
}
.solo-panel.is-flying .zoomer { visibility: hidden; }
.solo-inline .solo-main { min-height: 0; }
.solo-inline .solo-stage { flex: 1; min-height: 0; }
.solo-panel.solo-inline .solo-close { position: static; }
.solo-top, .solo-bar { display: flex; align-items: center; gap: 6px; padding: 0 6px 0 14px; background: #0b0e12; }
.solo-top { min-height: 52px; }
.solo-bar { flex-wrap: wrap; row-gap: 6px; padding: 8px; }
.solo-title { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 700; font-size: 16px; }
.solo-title .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.solo-title .mo-chip {
  display: none; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px;
  background: rgba(245, 184, 46, .16); color: #f5b82e; font-size: 12px; font-weight: 700;
}
.solo-panel.is-motion .solo-title .mo-chip { display: inline-flex; }
.solo-title .rec-dot { display: none; }
.solo-panel.is-rec .solo-title .rec-dot { display: block; }
.spacer { flex: 1; }

/* Camera strip under the bar (solo.js): every wall camera, to jump straight to one. The
   current camera gets a background and a ring on its thumbnail, like a selected alert row;
   motion gets the wall tile's amber ring and the motion icon. Full screen hides it. */
.solo-cams {
  position: relative; display: flex; gap: 2px; padding: 0 5px 8px; overflow-x: auto; overscroll-behavior-x: contain;
  background: #0b0e12; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .18) transparent;
}
.solo-cams[hidden] { display: none; }
.solo-panel:fullscreen .solo-cams { display: none; }
/* A short screen (a phone turned sideways) keeps its height for the video: no camera row
   (Previous and Next in the top bar still switch cameras). */
@media (max-height: 520px) { .solo-cams { display: none; } }
.solo-cam {
  flex: none; display: grid; gap: 4px; width: 112px; padding: 3px; border: 0; border-radius: var(--r-m);
  background: transparent; color: var(--muted); font: inherit; text-align: left; cursor: pointer;
  transition: background-color .12s var(--ease-out), color .12s var(--ease-out);
}
.solo-cam[aria-current="true"] { background: rgba(255, 255, 255, .1); color: var(--text); cursor: default; }
.solo-cam:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.solo-cam-thumb { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: var(--r-s); overflow: hidden; background: #050709; }
.solo-cam-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .2s var(--ease-out); }
.solo-cam.has-img .solo-cam-thumb img { opacity: 1; }
.solo-cam-thumb::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
.solo-cam.is-motion .solo-cam-thumb::after { box-shadow: inset 0 0 0 2px var(--motion); }
.solo-cam[aria-current="true"] .solo-cam-thumb { box-shadow: 0 0 0 2px var(--text); }
.solo-cam-thumb .mo {
  position: absolute; top: 4px; right: 4px; display: none; place-items: center; width: 20px; height: 20px;
  border-radius: 5px; background: rgba(0, 0, 0, .7); color: var(--motion);
}
.solo-cam-thumb .mo .ico { width: 13px; height: 13px; }
.solo-cam.is-motion .solo-cam-thumb .mo { display: grid; }
.solo-cam-thumb .off { position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; color: var(--muted); display: none; }
.solo-cam.is-offline .solo-cam-thumb img { filter: grayscale(1) brightness(.35); }
.solo-cam.is-offline .solo-cam-thumb .off { display: block; }
.solo-cam-name { padding: 0 2px; font-size: 12.5px; font-weight: 650; line-height: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (hover: hover) and (pointer: fine) {
  .solo-cam:not([aria-current="true"]):hover { background: rgba(255, 255, 255, .06); color: var(--text-2); }
}

.solo-stage { position: relative; overflow: hidden; touch-action: none; background: #000; flex: none; }
.zoomer { position: relative; width: 100%; height: 100%; transform-origin: 0 0; will-change: transform; }
.zoomer .layer { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.zoomer .poster { object-fit: contain; }
.zoomer .frame { object-fit: contain; opacity: 0; }
.zoomer.has-frame .frame { opacity: 1; }
.zoomer .sub, .zoomer .full { opacity: 0; transition: opacity .2s var(--ease); }
.zoomer[data-show="sub"] .sub, .zoomer[data-show="full"] .full { opacity: 1; }
.zoomer[data-show="full"] .sub { opacity: 0; }
.q-chip {
  position: absolute; left: 10px; top: 10px; z-index: 2; min-height: 28px; padding: 0 9px; border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, .18); background: rgba(0, 0, 0, .55); color: #fff; font-size: 12px; font-weight: 700;
}
.q-chip::before { content: ""; position: absolute; inset: -8px; }
.q-chip:disabled { cursor: default; opacity: .85; }
.q-chip:not(:disabled) { cursor: pointer; border-color: #f5b82e; color: #f8cd6a; }
.solo-msg {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 2;
  max-width: calc(100% - 32px); padding: 8px 12px; border-radius: 8px;
  background: rgba(0, 0, 0, .7); color: #fff; font-size: 13px; font-weight: 600; text-align: center; pointer-events: none;
}
.solo-msg:empty { display: none; }
.zoom-hint {
  position: absolute; top: 10px; right: 10px; z-index: 2; padding: 4px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, .6); color: #fff; font-size: 12px; font-weight: 700; pointer-events: none;
}
/* A mouse click on the video goes back to the wall (solo.js); zoomed in, a drag pans. */
@media (hover: hover) and (pointer: fine) {
  .solo-stage { cursor: zoom-out; }
  .solo-stage.is-zoomed { cursor: grab; }
}
.solo-panel.ptz-mode .solo-stage { cursor: move; }

/* Rewind strip in the camera window's bar (rewind.js). It gets a row of its own when the bar is
   narrower than 1040 px (solo.js .rw-own-row) or less than 320 px is left beside the buttons. The window is always dark, so the strip pins the dark
   theme's colors even when the page is light. */
.zoomer .rec { object-fit: contain; opacity: 0; }
.zoomer[data-show="rec"] .rec { opacity: 1; }
/* The still covers the recording while a drag scrubs it and until playback starts. It swaps
   with no transition: it follows a finger. Over a gap in the recording it dims. */
.zoomer .rw-still { object-fit: contain; opacity: 0; pointer-events: none; }
.zoomer[data-show="rec"] .rw-still.is-on { opacity: 1; }
.zoomer .rw-still.is-gap { filter: brightness(.4) grayscale(.6); }
.rw {
  --rw-track: rgba(255, 255, 255, .07); --band: #3a4757; --person: #5aa8ff; --vehicle: #b38cff;
  --alert: #ff7096; --manual: #3ccf8e; --rec: #ff4f45;
  display: flex; align-items: center; gap: 6px; flex: 1 1 320px; min-width: 0;
}
.solo-bar.rw-own-row .rw { flex-basis: 100%; }
.rw-box { position: relative; flex: 1; min-width: 0; touch-action: none; }
/* Touch: the box takes touches 12 px above and below the drawn strip, so a finger slightly off
   it still drags or pinches the strip; the layout doesn't move. */
@media (pointer: coarse) {
  .rw-box { padding: 12px 0; margin: -12px 0; }
  .rw-tip { bottom: calc(100% - 8px); }
}
.rw-tape { display: block; width: 100%; height: 44px; cursor: pointer; touch-action: none; border-radius: 6px; }
.rw-tape:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.rw-tip {
  position: absolute; bottom: calc(100% + 4px); transform: translateX(-50%); z-index: 3;
  padding: 5px 9px; border-radius: 7px; background: rgba(0, 0, 0, .86); color: #fff;
  font-size: 12.5px; font-weight: 650; white-space: nowrap; pointer-events: none; font-variant-numeric: tabular-nums;
}
.rw-play { flex: none; }
.rw-live { flex: none; gap: 6px; }
.rw-live .ico { color: var(--rec); }
.rw.is-rec .rw-live { background: var(--rec); border-color: transparent; color: #fff; }
.rw.is-rec .rw-live .ico { color: #fff; }
.rw-clock {
  position: absolute; left: 10px; top: 10px; z-index: 2; display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 0 10px; border-radius: 7px; background: rgba(0, 0, 0, .62); color: #fff;
  font-size: 13px; font-weight: 650; pointer-events: none; font-variant-numeric: tabular-nums;
}
.rw-clock .ico { width: 15px; height: 15px; }

.ptz {
  position: absolute; right: 10px; bottom: 10px; z-index: 3; display: flex; align-items: flex-end; gap: 8px;
  padding: 8px; border-radius: 14px; background: rgba(8, 10, 14, .72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.ptz-grid { display: grid; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); gap: 2px; }
.ptz-zoom { display: grid; gap: 2px; }
.ptz-btn { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .14); touch-action: none; }
.ptz-btn.held { background: #fff; color: #000; }
.ptz-presets-wrap { position: relative; }
.ptz-presets { bottom: calc(100% + 6px); top: auto; right: 0; max-height: 50vh; overflow: auto; }

@media (max-width: 759px) {
  /* Phones: a bottom sheet with a grab handle; the camera's alerts fill what is left. */
  .solo-back { place-items: end stretch; padding-left: 0; padding-right: 0; padding-bottom: 0; }
  .solo-panel {
    flex-direction: column; width: 100%; height: calc(100dvh - max(40px, env(safe-area-inset-top, 0px) + 16px));
    border-radius: 18px 18px 0 0; animation: sheetup .26s var(--ease);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .solo-main { flex: none; }
  .solo-grip { display: block; flex: none; height: 22px; touch-action: none; cursor: grab; }
  .solo-grip::before { content: ""; display: block; width: 40px; height: 5px; margin: 8px auto 0; border-radius: 3px; background: rgba(255, 255, 255, .28); }
  .solo-top { min-height: 44px; }
  .solo-alerts { width: auto; flex: 1; contain: none; border-left: 0; border-top: 1px solid rgba(255, 255, 255, .08); }
  .solo-back.closing { opacity: 1; transition: background-color .2s; background-color: transparent; }
  .solo-back.closing .solo-panel { transform: translateY(100%) !important; transition: transform .2s var(--ease); }
  .solo-bar .btn .lbl { display: none; }
  .solo-bar .rw { flex-basis: 100%; } /* the strip gets its own row; the buttons go under it */
  .solo-cams { flex: none; scrollbar-width: none; }
  .solo-cams::-webkit-scrollbar { display: none; }
  .solo-cam { width: 96px; }
}
@media (max-width: 559px) {
  .solo-bar .spacer { display: none; }
  .solo-bar > .btn { flex: 1; }
}
@media (max-width: 759px) {
  .ptz { right: 6px; bottom: 6px; padding: 6px; gap: 6px; }
  .ptz-grid { grid-template-columns: repeat(3, 40px); grid-template-rows: repeat(3, 40px); }
  .ptz .btn.icon { width: 40px; min-width: 40px; min-height: 40px; }
}

/* Zoom for the time strips (tapezoom.js): zoom out, how much time the strip shows, zoom in.
   One bordered control, so the two buttons read as a pair and not as stray plus and minus. */
.tz {
  display: inline-flex; align-items: center; flex: none; height: 44px;
  border: 1px solid var(--line-2); border-radius: var(--r-m); background: var(--bg-3);
}
.tz .btn { min-height: 42px; min-width: 42px; width: 42px; border: 0; background: transparent; }
.tz .btn:active { background: var(--bg-4); }
.tz .btn:first-child { border-radius: calc(var(--r-m) - 1px) 0 0 calc(var(--r-m) - 1px); }
.tz .btn:last-child { border-radius: 0 calc(var(--r-m) - 1px) calc(var(--r-m) - 1px) 0; }
.tz-span {
  min-width: 50px; padding: 0 2px; text-align: center; font-size: 13px; font-weight: 650;
  color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap;
}
@media (hover: hover) and (pointer: fine) { .tz .btn:not(:disabled):hover { background: var(--bg-4); } }

/* ---------- timeline ---------- */

.tl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  height: 100%;
}
.tl-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tl-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px var(--gut); border-bottom: 1px solid var(--line);
}
.cam-chips {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; min-width: 0; flex: 1;
  scroll-snap-type: x proximity; overscroll-behavior-x: contain;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  padding-right: 24px;
}
.cam-chips::-webkit-scrollbar { display: none; }
.cam-chips .chip { scroll-snap-align: start; }
.day-pick { display: flex; align-items: center; gap: 2px; flex: none; }
.day-pick .day-btn { min-width: 132px; position: relative; }
.day-pick input[type="date"] { position: absolute; inset: 0; opacity: 0; pointer-events: none; }

.tl-stage {
  position: relative; flex: 1 1 auto; min-height: 180px; background: #000; overflow: hidden;
}
.tl-stage video, .tl-stage img.tl-poster {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000;
}
.tl-stage img.tl-poster { opacity: 0; transition: opacity .2s; }
.tl-stage.show-poster img.tl-poster { opacity: 1; }
.tl-overlay {
  position: absolute; right: 12px; top: 10px; justify-content: flex-end; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  pointer-events: none;
}
.tl-clock {
  padding: 5px 9px; border-radius: 7px; background: rgba(0, 0, 0, .62); color: #fff;
  font-weight: 700; font-size: 14px;
}
.zoom-wrap { position: absolute; inset: 0; }
.tl-stage, .viewer-stage { touch-action: pan-y; }
.tl-stage.zoomed, .viewer-stage.zoomed { touch-action: none; cursor: grab; }
.tl-note {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 6px;
  color: #d5dbe2; font-weight: 600; padding: 16px; pointer-events: none;
}
.tl-note:empty { display: none; }
.tl-note small { color: #9aa5b2; font-weight: 500; }

.tl-transport {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px var(--gut); border-top: 1px solid var(--line);
}
.tl-transport .play { width: 52px; }
.tl-transport .speed .seg button { min-width: 44px; padding: 0 8px; }

.tl-tape {
  position: relative; height: 116px; flex: none; touch-action: none; cursor: grab;
  border-top: 1px solid var(--line); background: var(--bg-2);
}
.tl-tape.dragging { cursor: grabbing; }
.tl-tape canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tl-range {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px var(--gut); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--range-edge) 7%, var(--bg));
}
.tl-range-text { font-size: 14px; color: var(--text-2); }
.tl-range-text b { color: var(--text); }
.tl-small { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 6px; font-weight: 600; font-size: 14px; cursor: pointer; }
.tl-small input { width: 18px; height: 18px; accent-color: var(--text); }
.tl-handle {
  position: absolute; top: 22px; bottom: 0; width: 44px; margin-left: -22px; z-index: 3; touch-action: none; cursor: ew-resize;
}
.tl-handle::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--range-edge); }
.tl-handle::after {
  content: ""; position: absolute; left: 50%; bottom: 8px; width: 14px; height: 26px; margin-left: -7px; border-radius: 5px;
  background: var(--range-edge); box-shadow: 0 0 0 2px var(--bg-2);
}
.tl-handle.held::after { transform: scale(1.15); }
.tl-handle-label {
  position: absolute; left: 50%; bottom: 38px; transform: translateX(-50%); white-space: nowrap; padding: 1px 5px; border-radius: 4px;
  background: var(--range-edge); color: #fff; font-size: 11px; font-weight: 700; pointer-events: none;
}
.tl-handle.start .tl-handle-label { left: auto; right: 50%; transform: translateX(-6px); border-radius: 4px 0 0 4px; }
.tl-handle.end .tl-handle-label { left: 50%; transform: translateX(6px); border-radius: 0 4px 4px 0; }
.tl-len { position: absolute; top: 60px; transform: translateX(-50%); padding: 1px 6px; border-radius: 4px; background: var(--bg-2); color: var(--range-edge); font-size: 11.5px; font-weight: 750; pointer-events: none; z-index: 2; }
@media (max-width: 759px) { .tl-range { padding: 6px 8px; } .tl-range-text { flex-basis: 100%; } }
.tl-legend {
  display: flex; gap: 14px; flex-wrap: wrap; padding: 8px var(--gut) 10px; color: var(--muted); font-size: 12.5px;
}
.tl-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tl-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.tl-side { border-left: 1px solid var(--line); overflow: auto; min-height: 0; background: var(--bg); }
.tl-side-head {
  position: sticky; top: 0; z-index: 2; background: var(--bg);
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 14px var(--gut) 10px; border-bottom: 1px solid var(--line);
}
.tl-side-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.tl-side-head { align-items: center; }
.tl-side-head small { color: var(--muted); font-size: 13px; white-space: nowrap; }
.tl-listseg button { min-height: 32px; padding: 0 12px; }
.tl-list .ev-end { display: grid; justify-items: center; gap: 10px; padding: 24px var(--gut); }
.tl-list { list-style: none; margin: 0; padding: 6px 0; }
.tl-item {
  display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center;
  width: 100%; padding: 8px var(--gut); border: 0; background: none; text-align: left; cursor: pointer;
}
.tl-item:active { background: var(--bg-3); }
.tl-item[aria-current="true"] { background: var(--bg-3); }
.tl-item[aria-current="true"] .thumb { box-shadow: 0 0 0 2px var(--text); }
.tl-item .thumb { width: 96px; aspect-ratio: 16 / 9; border-radius: var(--r-s); object-fit: cover; background: var(--bg-3); }
.tl-item .t { font-weight: 650; }
.tl-item .s { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.tl-item .s .ty { display: inline-flex; align-items: center; gap: 4px; font-weight: 650; }
.tl-item .s .ty .ico { width: 14px; height: 14px; }

@media (hover: hover) and (pointer: fine) {
  .tl-item:hover { background: var(--bg-2); }
}

@media (max-width: 1023px) {
  .tl { display: block; height: auto; }
  .tl-main { min-height: 0; }
  .tl-stage { flex: none; aspect-ratio: var(--ar, 16 / 9); max-height: 58dvh; min-height: 0; }
  .tl-side { border-left: 0; overflow: visible; }
  .tl-side-head { position: static; }
}
@media (max-width: 759px) {
  .ev-filter-row .ev-seen { width: 44px; padding: 0; justify-content: center; }
  .ev-filter-row .ev-seen span { display: none; }
  .tl-head { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .cam-chips { order: 2; flex-basis: 100%; }
  .day-pick { order: 1; width: 100%; justify-content: space-between; }
  .day-pick .day-btn { flex: 1; }
  .tl-transport { padding: 6px 8px; gap: 4px; }
  .tl-transport .hide-s { display: none; }
  .tl-transport .btn .lbl { display: none; }
}

/* ---------- events ---------- */

.ev-page { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100%; }
.ev-filters {
  display: grid; gap: 8px; padding: 10px var(--gut); border-bottom: 1px solid var(--line); background: var(--bg);
}
.ev-filter-row { display: flex; gap: 8px; }
.ev-filter-row .ev-search { flex: 1; min-width: 0; max-width: 420px; }
.ev-filter-row .ev-seen { margin-left: auto; flex: none; }
.ev-views { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; margin: 0 calc(var(--gut) * -1); padding: 0 var(--gut); }
.ev-views::-webkit-scrollbar { display: none; }
.ev-views.more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent); }
.ev-filters::-webkit-scrollbar { display: none; }
.ev-filters select.input { width: auto; min-width: 150px; flex: none; }
@media (max-width: 599px) {
  .ev-filters { padding: 8px 12px; gap: 6px; }
  .ev-filters select.input { min-width: 0; max-width: 150px; }
  .ev-filters .chip { padding: 0 12px; }
  .ev-filters .sep { display: none; }
}
.ev-filters .sep { width: 1px; height: 24px; background: var(--line-2); flex: none; margin: 0 4px; }
.ev-scroll { overflow: auto; overscroll-behavior: contain; min-height: 0; }
.ev-day {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: baseline; gap: 10px;
  padding: 12px var(--gut) 8px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.ev-day h2 { font-size: 15px; }
.ev-day small { color: var(--muted); font-size: 13px; }
.ev-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 16px 12px; padding: 4px var(--gut) 18px;
}
.ev {
  display: grid; gap: 7px; text-decoration: none; color: inherit; cursor: pointer;
  border: 0; background: none; padding: 0; text-align: left; min-width: 0;
}
.ev-thumb {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-m); overflow: hidden; background: var(--bg-3);
}
.ev-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ev-thumb .ev-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .15s var(--ease-out); }
.ev-thumb .ev-preview.on { opacity: 1; }
.ev-thumb :is(.type, .dur, .live-chip, .flags) { z-index: 1; }
.ev-thumb .dur {
  position: absolute; right: 6px; bottom: 6px; padding: 2px 6px; border-radius: 5px;
  background: rgba(0, 0, 0, .66); color: #fff; font-size: 12px; font-weight: 650;
}
.ev-thumb .live-chip {
  position: absolute; right: 6px; bottom: 6px; padding: 2px 7px; border-radius: 5px;
  background: #ff4f45; color: #fff; font-size: 11.5px; font-weight: 750;
}
.ev-thumb .type {
  position: absolute; left: 6px; top: 6px; display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 7px 3px 5px; border-radius: 6px; background: rgba(0, 0, 0, .62);
  font-size: 12px; font-weight: 700;
}
.ev-thumb .type .ico { width: 16px; height: 16px; stroke-width: 2.2; }
.ev-thumb .flags { position: absolute; right: 6px; top: 6px; display: flex; gap: 4px; }
.ev-thumb .flags span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: rgba(0, 0, 0, .62); color: #fff; }
.ev-thumb .flags .ico { width: 15px; height: 15px; }
.ev-meta { display: grid; gap: 1px; min-width: 0; }
.ev-meta .l1 { display: flex; align-items: center; gap: 7px; font-weight: 650; min-width: 0; }
.ev-meta .l1 .cam { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-meta .l2 { color: var(--muted); font-size: 13px; }
.ev-meta .swatch { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.ev .unseen { width: 8px; height: 8px; border-radius: 50%; background: var(--person); flex: none; margin-left: auto; }
.ev.is-new .ev-thumb { animation: evnew 1.6s var(--ease); }
@keyframes evnew { from { box-shadow: 0 0 0 3px var(--motion); } to { box-shadow: 0 0 0 3px transparent; } }

.t-person { color: var(--person); }
.t-vehicle { color: var(--vehicle); }
.t-manual { color: var(--manual); }
.t-alert { color: var(--alert); }
.t-motion { color: var(--motion); }
.ev-thumb .type.t-person { color: #8cc4ff; }
.ev-thumb .type.t-vehicle { color: #cdb3ff; }
.ev-thumb .type.t-manual { color: #74e2b1; }
.ev-thumb .type.t-alert { color: #ff9fb8; }
.ev-thumb .type.t-motion { color: #f8cd6a; }

.ev-sk .ev-thumb { animation: sk 1.6s ease-in-out infinite; background: linear-gradient(100deg, var(--bg-3) 30%, var(--bg-4) 50%, var(--bg-3) 70%); background-size: 300% 100%; }
.ev-sk .l1, .ev-sk .l2 { height: 14px; border-radius: 4px; }
.ev-sk .l1 { width: 60%; } .ev-sk .l2 { width: 40%; margin-top: 4px; }
.ev-end { padding: 18px var(--gut) 40px; text-align: center; color: var(--muted); font-size: 13px; }

@media (max-width: 599px) {
  .ev-grid { grid-template-columns: 1fr; gap: 0; padding: 0 0 12px; }
  .ev { grid-template-columns: 136px minmax(0, 1fr); gap: 12px; align-items: center; padding: 8px var(--gut); }
  .ev:active { background: var(--bg-3); }
  .ev-thumb { border-radius: var(--r-s); }
  .ev-thumb .type { padding: 2px 5px 2px 4px; font-size: 11px; }
  .ev-thumb .type .lbl { display: none; }
  .ev-meta .l2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ---------- event viewer: the review player (viewer.js) ----------
   The video on the left, the list it was opened from on the right (under the video on
   phones). Always dark, like the camera window. Color only marks event types. */

.viewer {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(3, 5, 8, .82);
}
.viewer-panel {
  width: min(1560px, calc(100vw - 40px)); height: min(940px, calc(100dvh - 40px));
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; overflow: hidden;
  border-radius: var(--r-l); background: #0b0e12; box-shadow: var(--shadow);
  border: 1px solid #1c232c;
}
.viewer-main { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto auto; min-width: 0; min-height: 0; }
.viewer-top { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 18px; min-height: 58px; }
.viewer-top .title { display: grid; min-width: 0; }
.viewer-top .title b { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-top .title span { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
/* With the list beside the video, Close goes to the panel's top-right corner, over the list's
   head, not the corner of the video column. */
@media (min-width: 760px) {
  .viewer-panel { position: relative; }
  .viewer-close { position: absolute; top: 7px; right: 8px; }
  .viewer-side .vlist-head { padding-right: 60px; }
}
/* A zoomed picture stays inside the stage, as on the Timeline and in the camera window. */
.viewer-stage { position: relative; background: #000; min-height: 0; overflow: hidden; }
.viewer-stage video, .viewer-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.viewer-stage img { transition: opacity .2s var(--ease-out); }
.viewer-stage.playing img { opacity: 0; }

/* The clip bar: the event's span, what played, a handle, and a time while dragged. */
.vbar { position: relative; height: 30px; margin: 0 18px; cursor: pointer; touch-action: none; }
.vbar-track { position: absolute; left: 0; right: 0; top: 13px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .12); }
.vbar-ev { position: absolute; top: 0; bottom: 0; background: rgba(255, 255, 255, .26); border-radius: 2px; }
.vbar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--text); border-radius: 2px; }
.vbar-head {
  position: absolute; top: 9px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%;
  background: var(--text); box-shadow: 0 0 0 3px rgba(0, 0, 0, .5); pointer-events: none;
}
.vbar-tip {
  position: absolute; bottom: calc(100% + 2px); transform: translateX(-50%); padding: 4px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, .86); color: #fff; font-size: 12.5px; font-weight: 650; white-space: nowrap;
  pointer-events: none; font-variant-numeric: tabular-nums;
}
/* Touch: the bar takes fingers on 44 px, its own 30 and 14 over the video's bottom edge.
   Nothing reaches down: the transport's buttons start right under the bar, and an area
   over their top edge would take their taps. */
@media (pointer: coarse) {
  .vbar::before { content: ""; position: absolute; inset: -14px 0 0; }
}

.viewer-transport { display: flex; align-items: center; gap: 4px; padding: 0 12px 4px; flex-wrap: wrap; }
.viewer-transport .vclock { margin-left: 8px; color: var(--text-2); font-size: 13.5px; font-weight: 600; white-space: pre; font-variant-numeric: tabular-nums; }
.viewer-transport .vspeed button { min-width: 40px; padding: 0 8px; font-variant-numeric: tabular-nums; }
.viewer-transport .vauto { gap: 6px; }
.viewer-transport .vauto[aria-pressed="false"] { color: var(--muted); }

.viewer-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px max(12px, env(safe-area-inset-bottom, 0px)); border-top: 1px solid #1a2129;
}
.viewer-actions .labels { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 13px; padding: 0 4px; }
.viewer-actions .lab { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 6px; background: rgba(255, 255, 255, .08); color: var(--text-2); font-weight: 650; }
.viewer-actions .lab .ico { width: 14px; height: 14px; }

/* The list beside the video. */
.viewer-side { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; border-left: 1px solid #1a2129; background: #0d1116; }
.vlist-head { display: flex; align-items: baseline; gap: 8px; padding: 18px 16px 10px; }
.vlist-head b { font-size: 15px; }
.vlist-head span { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.vlist-scroll { overflow-y: auto; overscroll-behavior: contain; padding: 0 8px 12px; }
.vlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.vday { padding: 12px 8px 6px; color: var(--muted); font-size: 12.5px; font-weight: 650; }
.vitem {
  display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 10px; align-items: center; width: 100%;
  padding: 6px; border: 0; border-radius: var(--r-m); background: transparent; color: var(--text); text-align: left; cursor: pointer;
  font: inherit; transition: background-color .12s;
}
.vitem.is-current { background: rgba(255, 255, 255, .1); }
.vitem:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.vthumb { position: relative; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: #050709; }
.vthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vthumb .dur {
  position: absolute; right: 4px; bottom: 4px; padding: 1px 5px; border-radius: 4px;
  background: rgba(0, 0, 0, .72); color: #fff; font-size: 11.5px; font-weight: 650; font-variant-numeric: tabular-nums;
}
.vitem.is-current .vthumb { box-shadow: 0 0 0 2px var(--text); }
.vmeta { display: grid; gap: 2px; min-width: 0; }
.vmeta .l1 { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.vmeta .unseen { width: 7px; height: 7px; border-radius: 50%; background: var(--person); margin-left: auto; flex: none; }
.vmeta .l2 { display: flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 650; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.vmeta .l2 .ico { width: 14px; height: 14px; flex: none; }
.vmeta .l3 { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.vmeta .swatch { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.vlist-end { padding: 10px 8px; color: var(--muted); font-size: 12.5px; text-align: center; }
.vlist-keys { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 10px 16px 14px; color: var(--muted); font-size: 12px; border-top: 1px solid #1a2129; }
.vlist-keys kbd { font: 600 11.5px/1 ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--text-2); }
@media (hover: hover) and (pointer: fine) {
  .vitem:hover { background: rgba(255, 255, 255, .06); }
  .vitem.is-current:hover { background: rgba(255, 255, 255, .12); }
  .vbar:hover .vbar-track { height: 6px; top: 12px; }
}

@media (max-width: 1099px) {
  .viewer-panel { grid-template-columns: minmax(0, 1fr) 290px; }
  .vitem { grid-template-columns: 92px minmax(0, 1fr); }
}

/* Phones: the video on top, its controls, and the list under them. */
@media (max-width: 759px) {
  .viewer { background: #000; place-items: stretch; }
  .viewer-panel {
    width: 100%; height: 100dvh; border-radius: 0; border: 0;
    grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr);
    padding-top: env(safe-area-inset-top, 0px);
  }
  .viewer-main { grid-template-rows: auto auto auto auto auto; }
  .viewer-top { min-height: 52px; padding-left: 14px; }
  .viewer-top .title b { font-size: 15.5px; }
  .viewer-stage { aspect-ratio: 16 / 9; max-height: 46dvh; }
  .vbar { margin: 0 14px; }
  /* Two rows: moving through the clip and the list, then the clock, speed and Play next. */
  .viewer-transport { padding: 0 8px 4px; gap: 2px 4px; }
  .viewer-transport .spacer { order: 9; flex-basis: 100%; height: 0; }
  .viewer-transport .vclock { order: 10; flex: 1 1 auto; margin: 0 4px; font-size: 12.5px; }
  .viewer-transport .vspeed { order: 11; }
  .viewer-transport .vauto { order: 12; }
  .viewer-transport .vauto span { display: none; }
  .viewer-transport .vspeed button { min-width: 36px; padding: 0 6px; }
  .viewer-actions { flex-wrap: nowrap; gap: 6px; padding: 6px 10px; }
  .viewer-actions .labels { flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; overflow: hidden; }
  .viewer-actions .labels .src { display: none; }
  .viewer-actions .spacer { display: none; }
  .viewer-actions .btn { flex: none; width: 44px; padding: 0; justify-content: center; }
  .viewer-actions .btn span { display: none; }
  .viewer-side { border-left: 0; border-top: 1px solid #1a2129; }
  .vlist-head { padding: 12px 14px 6px; }
  .vlist-keys { display: none; }
  .vitem { grid-template-columns: 104px minmax(0, 1fr); }
}

/* ---------- system ---------- */

.sys { padding: 18px var(--gut) 32px; display: grid; gap: 22px; max-width: 1280px; margin: 0 auto; }
.sys-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sys-head h1 { font-size: 20px; }
.sys-head span { color: var(--muted); font-size: 13.5px; }
.sys-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: var(--r-l); background: var(--bg-2); overflow: hidden; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 14px 16px 10px; }
.panel-head small { color: var(--muted); font-size: 13px; }
.panel-body { padding: 0 16px 16px; }

.meter-row { display: grid; gap: 7px; padding: 12px 0; border-top: 1px solid var(--line); }
.meter-row:first-child { border-top: 0; padding-top: 0; }
.meter-row .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.meter-row .top b { font-size: 15px; }
.meter-row .top span { color: var(--muted); font-size: 13px; }
.meter-row .top .big { color: var(--text); font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.meter { position: relative; height: 10px; border-radius: 5px; background: var(--bg-4); overflow: hidden; display: flex; }
.meter > i { display: block; height: 100%; }
.meter .cap { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); }
.meter i.indeterminate { width: 35% !important; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.meter-tall { height: 16px; border-radius: 6px; overflow: visible; }
.meter-tall > i:first-child { border-radius: 6px 0 0 6px; }
.storage-legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 16px; margin-top: 4px; }
.storage-legend div { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.storage-legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.storage-legend .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.storage-legend .v { margin-left: auto; color: var(--muted); }

.svc { list-style: none; margin: 0; padding: 0; }
.svc li { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.svc li:first-child { border-top: 0; padding-top: 0; }
.svc .d { grid-column: 2; color: var(--muted); font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.dot.bad { background: var(--err); }
.dot.idle { background: var(--muted); }
.dot.warn { background: var(--warn); }

.cam-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cam-table th { text-align: left; font-size: 12.5px; font-weight: 650; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.cam-table td { padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: top; }
.cam-table tr:last-child td { border-bottom: 0; }
.cam-table td.num, .cam-table th.num { text-align: right; }
.cam-table .cname { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.cam-table .err { color: var(--err); font-size: 12.5px; white-space: normal; max-width: 280px; }
.cam-table .muted { color: var(--muted); }
.table-wrap { overflow-x: auto; }
.cam-table .only-s { display: none; }

.log {
  margin: 0; padding: 10px 0; max-height: 420px; overflow: auto; overscroll-behavior: contain;
  font: 12.5px/1.55 var(--mono); background: var(--bg); border-top: 1px solid var(--line);
}
.log div { display: grid; grid-template-columns: 92px 76px 1fr; gap: 10px; padding: 1px 16px; }
.log .ts { color: var(--muted); }
.log .src { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.log .msg { white-space: pre-wrap; word-break: break-word; }
.log .l1 .msg { color: var(--warn); }
.log .l2 .msg { color: var(--err); }

@media (max-width: 1100px) { .sys-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .sys-cols > :first-child { grid-column: 1 / -1; } }
@media (max-width: 759px) { .sys-cols { grid-template-columns: 1fr; } }
@media (max-width: 759px) {
  .sys { padding: 14px 12px 28px; gap: 16px; }
  .cam-table thead { display: none; }
  .cam-table, .cam-table tbody, .cam-table tr, .cam-table td { display: block; }
  .cam-table tr { padding: 10px 16px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
  .cam-table tr:last-child { border-bottom: 0; }
  .cam-table td { padding: 0; border: 0; white-space: normal; }
  .cam-table td.hide-s { display: none; }
  .cam-table td.num { text-align: right; }
  .cam-table td.sub-s { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
  .cam-table td.only-s { display: block; }
  .log div { grid-template-columns: 74px 1fr; padding: 2px 12px; }
  .log .src { display: none; }
}

/* ---------- settings ---------- */

.set2 { min-height: 100%; }
.set-tabs {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 4px; padding: 8px var(--gut) 0;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.set-tab {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; position: relative;
  color: var(--muted); font-weight: 650; text-decoration: none;
}
.set-tab .ico { width: 19px; height: 19px; }
.set-tab[aria-current="true"] { color: var(--text); }
.set-tab[aria-current="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--text); border-radius: 2px 2px 0 0; }
.set-body { min-height: 0; }
.set-form { max-width: 1060px; margin: 0 auto; padding: 18px var(--gut) 40px; display: grid; gap: 20px; }
.set-form.narrow { max-width: 760px; }
.set-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.set-head h1 { font-size: 21px; margin-right: auto; }
.set-head .back-link + h1 { flex-basis: 100%; }
.back-link { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; color: var(--muted); font-weight: 650; text-decoration: none; margin-left: -6px; }
.back-link .ico { width: 18px; height: 18px; }
.cam-status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.set-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.set-col { display: grid; gap: 20px; }
.set-sec { display: grid; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--bg-2); }
.set-sec > h2 { padding: 14px 16px 6px; font-size: 15px; }
.sec-hint { padding: 0 16px 10px; color: var(--muted); font-size: 13.5px; }
.set-sec > .sec-hint:first-child { padding-top: 12px; }
.set-grid > *, .set-col, .set-sec, .set-sec > *, .set-form > *, .mask { min-width: 0; }
.row .seg { flex-wrap: wrap; }
.row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 10px 16px; min-height: 56px; border-top: 1px solid var(--line);
}
.set-sec > h2 + .row, .set-sec > .sec-hint + .row, .set-sec > :first-child.row { border-top: 0; }
.row .lbl { display: grid; gap: 2px; min-width: 0; flex: 1 1 180px; }
.row > .btn { flex: none; }
.row .lbl b { font-weight: 600; }
.row .lbl small { color: var(--muted); font-size: 13px; }
.row.stack { display: grid; justify-content: stretch; gap: 8px; }
.range-row { display: grid; grid-template-columns: 1fr 88px; gap: 12px; align-items: center; }
.range-row .input { text-align: right; padding: 0 10px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 48px; }
.pw-wrap .pw-eye { position: absolute; right: 0; top: 0; }
.set-adv { border: 1px solid var(--line); border-radius: var(--r-l); background: var(--bg-2); }
.set-sec .set-adv { border: 0; border-top: 1px solid var(--line); border-radius: 0; background: none; }
.set-adv > summary {
  display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 16px; cursor: pointer; list-style: none;
  font-weight: 650; color: var(--text-2);
}
.set-adv > summary::-webkit-details-marker { display: none; }
.set-adv > summary .chev { width: 18px; height: 18px; transition: transform .15s var(--ease); }
.set-adv[open] > summary .chev { transform: rotate(90deg); }
.set-adv-body > .row:first-child { border-top: 1px solid var(--line); }
.set-save {
  position: sticky; bottom: 0; z-index: 4; display: flex; align-items: center; gap: 10px; justify-content: flex-end;
  margin: 0 calc(var(--gut) * -1) -40px; padding: 10px var(--gut) max(10px, env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--bg) 94%, transparent); border-top: 1px solid var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.set-save.clean { position: static; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.set-save.clean .revert { display: none; }
.set-save .state { margin-right: auto; color: var(--muted); font-size: 13.5px; }
.set-save .state.dirty { color: var(--warn); font-weight: 600; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-m); background: var(--bg-3); border: 1px solid var(--line-2); font-size: 14px; }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.notice .ico { color: var(--warn); }
.err-text { color: var(--err); font-weight: 600; font-size: 14px; min-height: 1em; }
.warn-text { color: var(--warn); font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; }
.field small.hint { margin-top: -2px; }
.inline { display: flex; gap: 8px; }
.inline .input { flex: 1; min-width: 0; }
.tag { padding: 3px 8px; border-radius: 6px; background: var(--bg-4); color: var(--text-2); font-size: 12px; font-weight: 650; white-space: nowrap; }
.muted-line { color: var(--muted); font-size: 13.5px; }

.cam-list { display: grid; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--bg-2); overflow: hidden; }
.cam-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 8px; min-height: 64px; text-decoration: none; border-top: 1px solid var(--line); }
.cam-row:first-child { border-top: 0; }
.cam-row:active { background: var(--bg-3); }
.cam-thumb { width: 84px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: var(--bg-4); flex: none; }
.cam-row-text { display: grid; gap: 2px; min-width: 0; flex: 1; }
.cam-row-text small { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.chev { width: 18px; height: 18px; color: var(--muted); flex: none; }
.cam-thumb.off { display: grid; place-items: center; color: var(--muted); }
.add-body > div, .add-body > form { display: grid; gap: 16px; }
.group-card { display: grid; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }
.set-sec > .sec-hint + .group-card { border-top: 0; }
.group-top { display: flex; gap: 8px; }
.group-top .input { flex: 1; }
.group-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.group-chips .chip { min-height: 36px; }
@media (pointer: coarse) { .group-chips .chip { min-height: 44px; } }

.steps { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; counter-reset: s; flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; font-weight: 650; padding-right: 10px; }
.steps li span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line-2); font-size: 12px; }
.steps li.on { color: var(--text); }
.steps li.on span { background: var(--text); color: var(--bg); border-color: transparent; }
.steps li.done span { background: var(--bg-4); border-color: transparent; }
.step-actions { display: flex; justify-content: space-between; gap: 10px; }
.discover-wait { display: grid; justify-items: center; gap: 10px; padding: 10px 0; color: var(--text-2); text-align: center; width: 100%; }
.discover-wait .dev-row { width: 100%; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--bg-4); border-top-color: var(--text); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.dev-list { display: grid; gap: 8px; }
.dev-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 8px 12px; text-align: left;
  border: 1px solid var(--line-2); border-radius: var(--r-m); background: var(--bg-3); cursor: pointer;
}
.dev-row:disabled { opacity: .6; cursor: default; }
.dev-row:not(:disabled):active { background: var(--bg-4); }
.dev-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.dev-text small { color: var(--muted); font-size: 13px; }
.manual-ip { width: 100%; }
.probe-box, .probe-inline { width: 100%; }
.probe-ok { display: grid; grid-template-columns: minmax(0, 220px) 1fr; gap: 14px; align-items: start; }
.probe-snap { width: 100%; border-radius: 8px; background: #000; }
.probe-snap.wide { max-width: 420px; }
.probe-title { display: flex; align-items: center; gap: 6px; font-weight: 700; margin-bottom: 6px; }
.probe-title .ico { color: var(--ok); }
.probe-list { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 14px; display: grid; gap: 3px; }
.probe-err { display: flex; gap: 10px; align-items: flex-start; color: var(--text); }
.probe-err .ico { color: var(--err); flex: none; margin-top: 2px; }
.probe-tried { margin-top: 10px; color: var(--muted); font-size: 13px; }
.probe-tried summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.probe-tried code { font-family: var(--mono); font-size: 12px; word-break: break-all; }
@media (max-width: 599px) { .probe-ok { grid-template-columns: 1fr; } }

.people .row.person { gap: 12px; justify-content: flex-start; }
.person .lbl { flex: 1; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--bg-4); font-weight: 700; flex: none; }
.person-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pair-code { font: 650 20px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; max-width: 14ch; }
.pair-code::placeholder { letter-spacing: .18em; }
.tv-found { gap: 12px; justify-content: flex-start; }
.avatar .ico { width: 20px; height: 20px; }
.key-once { display: block; padding: 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line-2); font-family: var(--mono); font-size: 13px; word-break: break-all; user-select: all; }

@media (max-width: 1023px) { .set-grid { grid-template-columns: 1fr; } }
@media (max-width: 459px) { .set-tab .ico { display: none; } .set-tab { padding: 0 6px; } }
@media (max-width: 759px) {
  .set-tabs { padding: 4px 8px 0; overflow-x: auto; scrollbar-width: none; }
  .set-tab { flex: 1 0 auto; justify-content: center; padding: 0 10px; }
  .set-form { padding: 14px 12px 32px; gap: 16px; }
  .set-save { margin: 0 -12px -32px; padding-left: 12px; padding-right: 12px; }
  .person { flex-wrap: wrap; }
  .person-actions { flex-basis: 100%; justify-content: flex-start; padding-left: 48px; }
}
@media (max-width: 459px) {
  .person-actions { display: grid; grid-template-columns: 1fr 1fr 44px; padding-left: 0; }
  .person-actions .btn { padding: 0 8px; white-space: normal; line-height: 1.2; text-align: center; }
}

.update-notes { padding: 0 16px 14px; white-space: pre-wrap; color: var(--text-2); font-size: 14px; }
.reconnect { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: rgba(5, 7, 10, .92); padding: 24px; }
.reconnect-box { display: grid; justify-items: center; gap: 12px; text-align: center; max-width: 420px; }
.reconnect-box p { color: var(--text-2); }

.mask { display: grid; gap: 10px; padding: 4px 16px 16px; }
.mask-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mask-stage {
  position: relative; border-radius: var(--r-m); overflow: hidden; background: #000;
  touch-action: none; aspect-ratio: var(--ar, 16 / 9); cursor: crosshair;
}
.mask-stage img, .mask-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.mask-stage img { object-fit: fill; }
.mask-stage canvas.mask-live { pointer-events: none; }
.mask-note { color: var(--muted); font-size: 13px; }
.mm { position: relative; height: 12px; border-radius: 6px; background: var(--bg-4); }
.mm i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 6px; background: var(--text-2); transition: width .25s var(--ease); }
.mm i.over { background: var(--motion); }
.mm-line { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--err); border-radius: 1px; }
.mm-state { margin-left: 8px; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--bg-4); color: var(--muted); }
.mm-state:empty { display: none; }
.mm-state.on { background: color-mix(in srgb, var(--motion) 20%, transparent); color: var(--motion); }

/* ---------- setup ---------- */

.setup { min-height: 100%; display: grid; place-items: center; padding: 24px var(--gut) calc(24px + env(safe-area-inset-bottom, 0px)); }
.setup-card { width: min(560px, 100%); display: grid; gap: 18px; }
.setup-card form { display: grid; gap: 16px; }
.setup-card h1 { font-size: 24px; }
.setup-card p { color: var(--text-2); }
.setup-card .mark { display: flex; align-items: center; gap: 10px; font-size: 18px; margin-bottom: 14px; }
.drive-list { display: grid; gap: 8px; }
.drive {
  display: grid; grid-template-columns: 70px 1fr; grid-template-rows: auto auto; gap: 4px 12px; align-items: center;
  padding: 10px 14px; text-align: left; border: 1px solid var(--line-2); border-radius: var(--r-m); background: var(--bg-3); cursor: pointer;
}
.drive b { grid-row: span 2; font-size: 16px; }
.drive small { color: var(--muted); font-size: 13px; }
.drive[aria-checked="true"] { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.summary { margin: 0; padding-left: 18px; display: grid; gap: 4px; color: var(--text-2); }

/* ---------- login ---------- */

.login {
  min-height: 100%; display: grid; place-items: center; padding: 24px var(--gut) calc(24px + env(safe-area-inset-bottom, 0px));
}
.login form { width: min(380px, 100%); display: grid; gap: 16px; }
.login .mark { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login .mark .status-dot { width: 14px; height: 14px; background: var(--rec); }
.login h1 { font-size: 26px; font-weight: 500; letter-spacing: -.02em; }
.login h1 b { font-weight: 750; }
.login .err { color: var(--err); font-weight: 600; font-size: 14px; min-height: 20px; }
.login .btn { width: 100%; min-height: 48px; font-size: 16px; }
.login .hint { color: var(--muted); font-size: 13px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.st-links { display: flex; gap: 14px; padding-top: 2px; }
.st-links a { color: var(--muted); font-weight: 650; font-size: 12.5px; text-decoration: none; min-height: 28px; display: inline-flex; align-items: center; }
.log-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.log-tools .input { width: auto; flex: 1 1 200px; }
@media (max-width: 599px) { .log-tools .input { flex-basis: 100%; } .log-tools > .btn { flex: 1 1 0; } }
.log-levels { display: flex; gap: 6px; }
.log-count { color: var(--muted); font-size: 13px; }
.log.log-full { max-height: calc(100dvh - 300px); min-height: 320px; border-top: 0; }
.log.log-full div { grid-template-columns: 92px 52px 96px 1fr; }
.lvl { font-size: 11px; font-weight: 750; text-transform: lowercase; align-self: start; padding: 0 5px; border-radius: 4px; background: var(--bg-3); color: var(--muted); text-align: center; }
.lvl-l1 { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.lvl-l2 { color: var(--err); background: color-mix(in srgb, var(--err) 14%, transparent); }
.log-empty { padding: 20px 16px !important; color: var(--muted); display: block !important; font-family: var(--font); }
@media (max-width: 759px) {
  /* Phones: time, level and source on one line, the message full width under them. */
  .log.log-full div { grid-template-columns: auto auto minmax(0, 1fr); gap: 1px 8px; padding: 4px 12px; }
  .log.log-full .ts { white-space: nowrap; }
  .log.log-full .src { display: block; }
  .log.log-full .msg { grid-column: 1 / -1; }
}
@media (max-width: 759px) {
  body[data-page="setup"] .topbar, body[data-page="login"] .topbar { display: none; }
}

/* Phones: a swipe between main sections slides the new page in from that side. */
#view.swipe-in-left { animation: swipein-left .22s var(--ease); }
#view.swipe-in-right { animation: swipein-right .22s var(--ease); }
@keyframes swipein-left { from { transform: translateX(28%); opacity: .4; } }
@keyframes swipein-right { from { transform: translateX(-28%); opacity: .4; } }
@media (prefers-reduced-motion: reduce) { #view.swipe-in-left, #view.swipe-in-right { animation: none; } }

/* ---------- weather ---------- */

.wx { padding: 18px var(--gut) 32px; display: grid; gap: 18px; max-width: 1280px; margin: 0 auto; interpolate-size: allow-keywords; }
.wx-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.wx-head h1 { font-size: 20px; }
.wx-place { font-weight: 600; color: var(--text-2); }
.wx-updated { color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.wx .panel-head h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.wx .panel-head h2 .ico { width: 18px; height: 18px; color: var(--muted); }
.wx .panel-head small { font-variant-numeric: tabular-nums; }
.wx-grid {
  display: grid; gap: 18px; align-items: start;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas: "now now" "hours hours" "week radar" "past past";
}
.wx-now { grid-area: now; }
.wx-hours { grid-area: hours; }
.wx-week { grid-area: week; }
.wx-radar { grid-area: radar; }
.wx-past { grid-area: past; }
@media (max-width: 899px) {
  .wx-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "now" "hours" "week" "radar" "past"; }
}
.wx-none { margin: 0 16px 16px; color: var(--muted); }
.wx-sk { padding: 16px; display: grid; gap: 10px; }

/* What did not load or is old. Without it a missing piece looks like a quiet day. */
.wx-problems { display: grid; gap: 4px; }
.wx-problems p { display: flex; gap: 8px; align-items: flex-start; margin: 0; color: var(--text-2); font-size: 13.5px; }
.wx-problems .ico { width: 18px; height: 18px; color: var(--warn); margin-top: 1px; }

/* NWS warnings: the icon carries the severity, the text stays in text colors. */
.wx-alerts { display: grid; gap: 8px; }
.wx-alert { border: 1px solid var(--line); border-radius: var(--r-m); background: var(--bg-2); }
.wx-alert.sev-hi { border-color: color-mix(in srgb, var(--err) 50%, var(--line)); }
.wx-alert summary { display: flex; align-items: center; gap: 10px; padding: 12px 14px; min-height: 48px; cursor: pointer; list-style: none; }
.wx-alert summary::-webkit-details-marker { display: none; }
.wx-alert .sev-ico { color: var(--muted); }
.wx-alert.sev-hi .sev-ico { color: var(--err); }
.wx-alert.sev-mid .sev-ico { color: var(--warn); }
.wx-alert-t { flex: 1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; min-width: 0; }
.wx-alert-t small { color: var(--muted); font-size: 13px; }
.wx-alert .chev { width: 18px; height: 18px; color: var(--muted); transition: transform .2s var(--ease-out); }
.wx-alert[open] .chev { transform: rotate(180deg); }
.wx-alert-body { padding: 0 14px 14px 46px; color: var(--text-2); font-size: 14px; line-height: 1.5; }
.wx-alert-body p { margin: 0 0 8px; }
.wx-alert-body .pre { white-space: pre-line; }
.wx-alert-body .hl { color: var(--text); font-weight: 600; }

/* Now */
.wx-now { padding: 18px 18px 14px; display: grid; gap: 16px 28px; grid-template-columns: auto minmax(0, 1fr); align-items: center; }
.wx-now-main { display: grid; grid-template-columns: auto auto; column-gap: 14px; align-items: center; justify-content: start; }
.wx-big { width: 52px; height: 52px; stroke-width: 1.5; color: var(--text-2); }
.wx-temp { font-size: 56px; font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.wx-sky { grid-column: 1 / -1; display: grid; gap: 2px; margin-top: 10px; }
.wx-sky b { font-size: 16px; }
.wx-sky span { color: var(--muted); font-size: 14px; }
.wx-reads { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 14px 18px; }
.wx-r { display: flex; gap: 10px; align-items: flex-start; }
.wx-r .ico { width: 20px; height: 20px; color: var(--muted); margin-top: 1px; }
.wx-r > div { display: grid; min-width: 0; }
.wx-r .lbl { color: var(--muted); font-size: 12.5px; }
.wx-r b { font-size: 15px; font-variant-numeric: tabular-nums; }
.wx-r small { color: var(--text-2); font-size: 12.5px; }
.wx-src { grid-column: 1 / -1; display: flex; gap: 8px; align-items: flex-start; margin: 0; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.wx-src .ico { width: 16px; height: 16px; margin-top: 1px; }
@media (max-width: 759px) {
  .wx-now { grid-template-columns: minmax(0, 1fr); }
  .wx-reads { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Charts: monochrome; only the event bars carry the event colors. */
.wx-chart-wrap { margin: 0 16px 14px; }
.wx-chart-box { position: relative; }
.wx-chart { display: block; overflow: visible; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: default; }
.wx-past .wx-chart { cursor: pointer; }
.wx-night { fill: var(--bg-3); }
.wx-gridline, .wx-base { stroke: var(--line-2); stroke-width: 1; }
.wx-line { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.wx-wash { fill: var(--text); opacity: .07; }
.wx-dot { fill: var(--text); stroke: var(--bg-2); stroke-width: 2; }
.wx-bar { fill: var(--muted); }
.wx-bar-alert { fill: var(--alert); }
.wx-bar-motion { fill: var(--motion); }
.wx-hover { fill: var(--text); opacity: .07; }
.wx-use { fill: none; stroke: var(--text-2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.wx-chart text { font-family: var(--font); font-variant-numeric: tabular-nums; }
.wx-tick { fill: var(--muted); font-size: 11.5px; font-weight: 600; }
.wx-val { fill: var(--text); font-size: 12.5px; font-weight: 700; }
.wx-small { fill: var(--text-2); font-size: 11px; }
.wx-small.muted { fill: var(--muted); }
.wx-rowlbl { fill: var(--muted); font-size: 11.5px; font-weight: 600; }
.wx-midnight { fill: var(--text-2); font-size: 11.5px; font-weight: 700; }
.wx-tip {
  position: absolute; top: 0; left: 0; z-index: 3; display: grid; gap: 4px; min-width: 170px; max-width: 250px;
  padding: 10px 12px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-m);
  box-shadow: var(--shadow); color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums;
  pointer-events: none; opacity: 0; transform: translateY(4px);
  transition: opacity .12s var(--ease-out), transform .12s var(--ease-out);
}
.wx-tip.on { opacity: 1; transform: none; }
.wx-tip b { color: var(--text); }
.wx-tip span { display: flex; align-items: center; gap: 6px; }
.wx-tip .ico { width: 15px; height: 15px; color: var(--muted); }
.wx-tip small { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.wx-legend { display: flex; gap: 14px; color: var(--text-2); font-size: 12.5px; }
.wx-legend span { display: inline-flex; align-items: center; gap: 6px; }
.wx-legend .sw { width: 10px; height: 10px; border-radius: 3px; }
.wx-legend .sw.alert { background: var(--alert); }
.wx-legend .sw.motion { background: var(--motion); }
.wx-past-sum { margin: -2px 16px 12px; color: var(--text-2); font-size: 14px; }
.wx-past-sum small { color: var(--muted); font-size: 13px; }

/* 7 days: a row per day; the bar spans the low to the high on the scale of the week. */
.wx-week-list { padding: 0 6px 8px; }
details.wx-day + details.wx-day { border-top: 1px solid var(--line); }
details.wx-day summary {
  display: grid; grid-template-columns: 62px 24px minmax(0, 1fr) 48px 34px minmax(56px, 96px) 34px;
  align-items: center; gap: 10px; padding: 9px 10px; min-height: 48px; cursor: pointer; list-style: none; border-radius: var(--r-m);
}
details.wx-day summary::-webkit-details-marker { display: none; }
.wx-dname { font-size: 14.5px; }
.wx-dico { width: 22px; height: 22px; color: var(--text-2); }
.wx-dtext { color: var(--text-2); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wx-pop { display: inline-flex; align-items: center; gap: 3px; color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.wx-pop .ico { width: 14px; height: 14px; color: var(--muted); }
.wx-pop.none .ico { visibility: hidden; }
.wx-lo, .wx-hi { font-size: 14.5px; font-variant-numeric: tabular-nums; }
.wx-lo { color: var(--muted); text-align: right; }
.wx-hi { font-weight: 700; }
.wx-range { position: relative; height: 6px; border-radius: 3px; background: var(--bg-4); }
.wx-range i { position: absolute; top: 0; bottom: 0; min-width: 6px; border-radius: 3px; background: var(--text-2); }
.wx-day-body { padding: 0 10px 12px 106px; color: var(--text-2); font-size: 14px; line-height: 1.5; }
.wx-day-body p { margin: 0 0 6px; }
@media (max-width: 520px) {
  details.wx-day summary { grid-template-columns: 52px 22px 44px 30px minmax(40px, 1fr) 30px; gap: 8px; }
  .wx-dtext { display: none; }
  .wx-day-body { padding-left: 10px; }
}

/* Radar: the NWS loop as it comes, on a placeholder of its own size. */
.wx-radar-body { padding: 0 16px 16px; }
.wx-radar-link { display: block; aspect-ratio: 600 / 550; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--bg-3); }
.wx-radar-img { display: block; width: 100%; height: auto; opacity: 0; transition: opacity .25s var(--ease-out); }
.wx-radar-img.in { opacity: 1; }
:root[data-theme="dark"] .wx-radar-img { filter: brightness(.9); }

/* Opening a day or a warning grows it instead of popping it in. */
details.wx-day::details-content, .wx-alert::details-content {
  block-size: 0; overflow: hidden;
  transition: block-size .22s var(--ease-out), content-visibility .22s allow-discrete;
}
details.wx-day[open]::details-content, .wx-alert[open]::details-content { block-size: auto; }
@media (hover: hover) and (pointer: fine) {
  details.wx-day summary { transition: background-color .12s var(--ease-out); }
  details.wx-day summary:hover { background: var(--bg-3); }
}
@media (prefers-reduced-motion: reduce) {
  details.wx-day::details-content, .wx-alert::details-content, .wx-tip, .wx-radar-img, .wx-alert .chev { transition: none; }
}
