/* Shared design tokens + components - white, mobile-first. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fbfbfc;
  --ink: #14181f;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2b5f8a;
  --accent-ink: #ffffff;
  --accent-soft: #e7eef4;
  --danger: #c0362c;
  --danger-bg: #fbeceb;
  --good: #2c7a4c;
  --good-bg: #e9f4ee;
  --nav-h: 64px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); }

/* ---- Top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; padding-top: calc(14px + env(safe-area-inset-top));
  background: rgba(255,255,255,0.92); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 0.95rem; letter-spacing: 0.02em; }
.topbar .brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }
.topbar .account-link { color: var(--muted); display: flex; align-items: center; }

/* ---- Page shell ---- */
main { padding: 18px; padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }

.page-title { font-size: 1.3rem; font-weight: 700; margin: 4px 0 4px; }
.page-sub { color: var(--muted); font-size: 0.9rem; margin: 0 0 20px; }

/* ---- Cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; box-shadow: 0 1px 2px rgba(20,24,31,0.03);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 18px; border-radius: 10px; border: none; font-weight: 600; font-size: 0.9rem;
  font-family: inherit; cursor: pointer; text-decoration: none; min-height: 44px; transition: opacity 0.15s, background 0.15s;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { opacity: 0.92; }
.btn-outline { background: var(--surface); color: var(--ink); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-block { width: 100%; }

/* ---- Bottom tab nav ---- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: rgba(255,255,255,0.96); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.01em;
  min-height: 44px;
}
.tabbar a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.tabbar a.active { color: var(--accent); }
.tabbar a.active svg { stroke: var(--accent); }

/* ---- Live view ---- */
.live-frame {
  position: relative; width: 100%; aspect-ratio: 16/9; background: #0e1013;
  border-radius: 16px; overflow: hidden; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; margin-bottom: 18px;
}
.live-frame img { width: 100%; height: 100%; object-fit: contain; }
.live-badge {
  position: absolute; top: 14px; left: 14px; background: rgba(192,54,44,0.16); color: #ff8a80;
  border: 1px solid rgba(255,138,128,0.5); padding: 4px 10px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }
.live-fs-btn {
  position: absolute; bottom: 14px; right: 14px; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,0.15); cursor: pointer;
}
.live-fs-btn svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2; }

/* ---- Filter form ---- */
.filter-form { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.filter-field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 150px; }
.filter-field label { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.filter-field input {
  padding: 11px 12px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-2); font-family: inherit; font-size: 0.9rem; color: var(--ink);
}
.filter-field input:focus { outline: none; border-color: var(--accent); background: #fff; }
.filter-actions { display: flex; gap: 10px; align-items: flex-end; }

/* ---- Recordings grid ---- */
.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 480px) { .grid { grid-template-columns: repeat(2, 1fr); } }
.rec-card {
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.rec-card .rec-time { font-size: 0.85rem; font-weight: 600; color: var(--ink); }
.rec-card .rec-play {
  align-self: flex-start; font-size: 0.8rem; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); padding: 7px 14px; border-radius: 20px; text-decoration: none;
  border: none; cursor: pointer; font-family: inherit; min-height: 36px;
}
.empty-state {
  grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 32px 20px;
  background: var(--surface); border: 1px dashed var(--border); border-radius: 12px; font-size: 0.9rem;
}

/* ---- Auth cards (login/verify) ---- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; padding-top: calc(24px + env(safe-area-inset-top)); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px 28px; box-shadow: 0 1px 2px rgba(20,24,31,0.04), 0 8px 24px rgba(20,24,31,0.06); }
.auth-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.auth-brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.auth-brand span { font-weight: 700; font-size: 0.95rem; letter-spacing: 0.02em; }
.auth-card h1 { font-size: 1.3rem; font-weight: 700; margin: 0 0 6px; }
.auth-card p.sub { color: var(--muted); font-size: 0.9rem; margin: 0 0 24px; line-height: 1.5; }
.auth-card p.sub b { color: var(--ink); }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.field input[type=email], .field input[type=password], .field input[type=text] {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 1rem; font-family: inherit; background: var(--surface-2);
}
.field input:focus { outline: none; border-color: var(--accent); background: #fff; }
input[name=code] { width: 100%; padding: 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 1.5rem; letter-spacing: 0.4em; text-align: center; font-family: inherit; background: var(--surface-2); }
input[name=code]:focus { outline: none; border-color: var(--accent); background: #fff; }
.alert-error { background: var(--danger-bg); color: var(--danger); padding: 11px 14px; border-radius: 10px; font-size: 0.85rem; margin-bottom: 18px; }
.alert-notice { background: var(--good-bg); color: var(--good); padding: 11px 14px; border-radius: 10px; font-size: 0.85rem; margin-bottom: 18px; }
.link-btn { background: transparent; color: var(--accent); font-weight: 500; }

/* ---- Video player modal ---- */
.player-modal {
  position: fixed; inset: 0; z-index: 100; background: #0a0c0e;
  display: flex; flex-direction: column;
}
.player-modal[hidden] { display: none; }

/* Any element using [hidden] to toggle visibility wins over a class-based
   display rule (e.g. .btn's inline-flex) - without this, [hidden] silently
   does nothing on elements styled with display elsewhere. */
[hidden] { display: none !important; }
.player-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top));
  color: #fff; flex: none;
}
.player-title { font-size: 0.85rem; font-weight: 600; color: rgba(255,255,255,0.85); }
.player-close {
  width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.1); border: none;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.player-close svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2; }

.player-video-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.player-video-wrap video { width: 100%; height: 100%; object-fit: contain; }

.player-controls {
  flex: none; padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.03); border-top: 1px solid rgba(255,255,255,0.08);
}
.player-scrub-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.player-time { font-size: 0.72rem; color: rgba(255,255,255,0.65); font-variant-numeric: tabular-nums; min-width: 34px; }
.player-scrub {
  flex: 1; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.2);
  -webkit-appearance: none; appearance: none;
}
.player-scrub::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent);
  border: 2px solid #fff; cursor: pointer;
}
.player-scrub::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; cursor: pointer; }

.player-buttons-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 12px; }
.player-btn {
  background: rgba(255,255,255,0.08); color: #fff; border: none; border-radius: 20px;
  padding: 10px 14px; font-size: 0.78rem; font-weight: 600; font-family: inherit; cursor: pointer; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
}
.player-btn svg { width: 20px; height: 20px; fill: currentColor; }
.player-btn-primary { background: var(--accent); width: 52px; height: 52px; border-radius: 50%; padding: 0; }

.player-speed-row { display: flex; align-items: center; gap: 8px; }
.speed-btn {
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.75); border: none; border-radius: 16px;
  padding: 7px 12px; font-size: 0.75rem; font-weight: 700; font-family: inherit; cursor: pointer; min-height: 36px;
}
.speed-btn.active { background: var(--accent); color: #fff; }
