:root {
  color-scheme: dark;
  --bg: #0f172a;
  --card: #1e293b;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --ok: #22c55e;
  --bad: #ef4444;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
main { padding: 0 max(16px, env(safe-area-inset-left)) 32px; max-width: 1600px; margin: 0 auto; }
h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 24px 0 12px; }
.muted { color: var(--muted); }

button, .button {
  font: inherit; color: var(--text); background: var(--accent); color: #04121d;
  border: 0; border-radius: 8px; padding: 10px 16px; cursor: pointer; font-weight: 600;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button:disabled { opacity: .6; cursor: default; }
button.ghost, .button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--bad); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- login ---------- */
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card {
  background: var(--card); border-radius: var(--radius); padding: 32px; width: min(360px, 100%);
  text-align: center; display: grid; gap: 12px; justify-items: center;
}
.login-card form { display: grid; gap: 12px; width: 100%; }
.login-card label { color: var(--muted); }
.login-card input {
  font-size: 2rem; text-align: center; letter-spacing: .5em; padding: 10px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.error { color: var(--bad); min-height: 1.2em; margin: 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px; background: rgb(15 23 42 / .9);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}

/* ---------- live ---------- */
.live-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.live-card { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.video-wrap { position: relative; aspect-ratio: 16 / 9; background: #000; }
.video-wrap video { width: 100%; height: 100%; object-fit: contain; display: block; }
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted);
  background: rgb(0 0 0 / .6); text-align: center; padding: 16px; font-size: .9rem;
}
.overlay[hidden] { display: none; }
.badge {
  position: absolute; top: 8px; padding: 2px 8px; border-radius: 6px; font-size: .75rem; font-weight: 700;
}
.badge.rec { left: 8px; background: var(--bad); color: #fff; animation: blink 1s steps(2) infinite; }
.badge.person { right: 8px; background: #f59e0b; color: #000; }
@keyframes blink { 50% { opacity: .4; } }
@media (prefers-reduced-motion: reduce) { .badge.rec { animation: none; } }
.live-meta { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.live-meta .name { flex: 1; }
.live-meta .fs { padding: 4px 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); flex: none; }
.dot.on { background: var(--ok); }

/* ---------- recordings ---------- */
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button { padding: 6px 12px; font-size: .85rem; }
.filters button[aria-pressed="false"] { background: transparent; color: var(--text); border: 1px solid var(--line); }
.day { color: var(--muted); font-size: .9rem; margin: 20px 0 8px; font-weight: 600; }
.rec-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.rec-card {
  background: var(--card); border-radius: var(--radius); overflow: hidden; padding: 0; text-align: left;
  color: var(--text); font-weight: 400; display: block; border: 1px solid transparent;
}
.rec-card:hover { border-color: var(--accent); }
.rec-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: #000; }
.rec-card .info { padding: 8px 10px; display: grid; gap: 2px; font-size: .85rem; }
.rec-card .info .muted { font-size: .75rem; }
.rec-card.new { border-color: #f59e0b; }

/* ---------- player dialog ---------- */
dialog {
  width: min(960px, 96vw); padding: 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / .75); }
.player-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; }
.player-head h3 { margin: 0; font-size: 1rem; }
.player-head button { padding: 4px 10px; }
dialog video { width: 100%; display: block; background: #000; max-height: 70vh; }
.player-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px; }
