:root {
  --bg: #0d1117;
  --panel: #161b22;
  --line: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #2f81f7;
  --rec: #3fb950;
  --live: #f85149;
  --gap: #21262d;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); overscroll-behavior: none; }
[hidden] { display: none !important; }
h1 { font-size: 18px; margin: 0; font-weight: 600; }
button { font: inherit; color: var(--text); background: var(--accent); border: 0; border-radius: 10px;
  padding: 10px 14px; cursor: pointer; touch-action: manipulation; }
button.ghost { background: transparent; color: var(--muted); padding: 8px 4px; }
button.pill { background: var(--panel); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; }
input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%; }

.screen { max-width: 960px; margin: 0 auto; padding: 0 16px 24px; }
.bar { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.bar h1 { flex: 1; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.login-card { margin: 12vh auto 0; max-width: 360px; padding: 24px; display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.error { color: var(--live); min-height: 1.2em; margin: 0; font-size: 13px; }

.site h2 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tile { overflow: hidden; cursor: pointer; }
.tile .thumb { aspect-ratio: 16 / 9; background: #000; display: block; width: 100%; object-fit: cover; }
.tile .meta { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.tile .meta span:first-child { flex: 1; font-weight: 600; }
.tile .meta small { color: var(--muted); }

.rec { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.rec.on { background: var(--rec); box-shadow: 0 0 8px var(--rec); }

.stage { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 12px; overflow: hidden;
  margin: 0 -16px; border-radius: 0; }
@media (min-width: 700px) { .stage { margin: 0; border-radius: 12px; } }
.stage video, .stage video-stream, .stage img { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage video, .stage img { object-fit: contain; background: #000; }
.badge { position: absolute; top: 10px; left: 10px; font-size: 12px; font-weight: 700; padding: 3px 8px;
  border-radius: 6px; background: rgba(0,0,0,.6); }
.badge.live { color: var(--live); }
.badge.replay { color: var(--accent); }
.badge.scrub { color: #d29922; }
.clock { position: absolute; bottom: 10px; right: 10px; font: 600 14px ui-monospace, monospace;
  background: rgba(0,0,0,.6); padding: 3px 8px; border-radius: 6px; }

.controls { display: flex; align-items: center; gap: 8px; margin: 12px 0 8px; }
.spacer { flex: 1; }
.span-label { min-width: 44px; text-align: center; color: var(--muted); font-size: 13px; }
#go-live { color: var(--live); }
#thermal.on { background: #b3401a; border-color: #f0883e; }

.timeline-wrap { position: relative; height: 84px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#timeline { width: 100%; height: 100%; display: block; cursor: grab; }
#timeline:active { cursor: grabbing; }
.hint { color: var(--muted); font-size: 12px; text-align: center; margin: 6px 0 12px; }
.jump { display: flex; gap: 8px; }
:root { --ev-person: #f0883e; --ev-animal: #56d364; --ev-vehicle: #58a6ff; --ev-light: #e3b341; --ev-motion: #8b949e; }
.chip.light.on { border-color: var(--ev-light); color: var(--ev-light); }
.chip.motion.on { border-color: var(--ev-motion); color: var(--ev-motion); }
:root { --ev-heat: #ff5a36; }
.chip.heat.on { border-color: var(--ev-heat); color: var(--ev-heat); }
.events li.heat { border-left-color: var(--ev-heat); }
.events li.light { border-left-color: var(--ev-light); }
.events li.motion { border-left-color: var(--ev-motion); }
.section-title { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 20px 0 8px; }
.notif-btn { margin-bottom: 4px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.chip.person.on { border-color: var(--ev-person); color: var(--ev-person); }
.chip.animal.on { border-color: var(--ev-animal); color: var(--ev-animal); }
.chip.vehicle.on { border-color: var(--ev-vehicle); color: var(--ev-vehicle); }
.chip:not(.on) { opacity: .5; }
.events { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.events li { display: flex; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line);
  border-left: 4px solid var(--muted); border-radius: 10px; padding: 6px; cursor: pointer; }
.events li.person { border-left-color: var(--ev-person); }
.events li.animal { border-left-color: var(--ev-animal); }
.events li.vehicle { border-left-color: var(--ev-vehicle); }
.events img { width: 96px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: #000; flex: none; }
.events .ev-text { display: grid; gap: 2px; min-width: 0; }
.events .ev-text strong { font-size: 14px; }
.events .ev-text small { color: var(--muted); font-size: 12px; }
.events .empty { color: var(--muted); background: none; border: 0; cursor: default; }
.health { margin-top: 16px; color: var(--muted); }
.health ul { padding-left: 18px; font-size: 13px; }
