/* Home — design system
   Dark "night glass" by default (cameras read best on dark), with a light theme.
   One accent (iris), plus status colors: live, motion, record. */

:root {
  color-scheme: dark;
  --bg: #07090d;
  --bg-2: #0b0e14;
  --panel: rgba(18, 22, 31, 0.72);
  --panel-solid: #11151d;
  --card: rgba(255, 255, 255, 0.035);
  --card-hover: rgba(255, 255, 255, 0.06);
  --raise: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.075);
  --line-2: rgba(255, 255, 255, 0.13);
  --text: #eef1f6;
  --text-2: #a2abb9;
  --text-3: #6c7585;
  --accent: #9aa8ff;
  --accent-2: #5eead4;
  --accent-ink: #0b0e14;
  --accent-soft: rgba(154, 168, 255, 0.14);
  --live: #34d399;
  --motion: #fbbf24;
  --motion-soft: rgba(251, 191, 36, 0.14);
  --rec: #fb5a6e;
  --rec-soft: rgba(251, 90, 110, 0.16);
  --video-bg: #05070a;
  --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--line);
  --shadow-md: 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  --aurora-1: rgba(110, 125, 255, 0.16);
  --aurora-2: rgba(45, 212, 191, 0.10);

  --r-xl: 28px;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --r-xs: 9px;

  --font: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Inter Display", "SF Pro Display", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display", "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.4, .64, 1);

  --rail: 248px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f3f4f7;
    --bg-2: #eceef3;
    --panel: rgba(255, 255, 255, 0.78);
    --panel-solid: #ffffff;
    --card: #ffffff;
    --card-hover: #fafbfd;
    --raise: rgba(15, 20, 35, 0.06);
    --line: rgba(15, 20, 35, 0.08);
    --line-2: rgba(15, 20, 35, 0.14);
    --text: #10141c;
    --text-2: #4d5565;
    --text-3: #8a91a0;
    --accent: #4f5fe0;
    --accent-2: #0f9f8c;
    --accent-ink: #ffffff;
    --accent-soft: rgba(79, 95, 224, 0.10);
    --live: #10a36f;
    --motion: #c98404;
    --motion-soft: rgba(217, 140, 4, 0.12);
    --rec: #e0344b;
    --rec-soft: rgba(224, 52, 75, 0.10);
    --shadow-lg: 0 30px 70px -24px rgba(20, 28, 50, 0.28), 0 0 0 1px var(--line);
    --shadow-md: 0 10px 30px -14px rgba(20, 28, 50, 0.25);
    --aurora-1: rgba(99, 112, 255, 0.10);
    --aurora-2: rgba(20, 184, 166, 0.07);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f7; --bg-2: #eceef3; --panel: rgba(255,255,255,.78); --panel-solid: #fff;
  --card: #fff; --card-hover: #fafbfd; --raise: rgba(15,20,35,.06); --line: rgba(15,20,35,.08);
  --line-2: rgba(15,20,35,.14); --text: #10141c; --text-2: #4d5565; --text-3: #8a91a0;
  --accent: #4f5fe0; --accent-2: #0f9f8c; --accent-ink: #fff; --accent-soft: rgba(79,95,224,.10);
  --live: #10a36f; --motion: #c98404; --motion-soft: rgba(217,140,4,.12); --rec: #e0344b; --rec-soft: rgba(224,52,75,.10);
  --shadow-lg: 0 30px 70px -24px rgba(20,28,50,.28), 0 0 0 1px var(--line); --shadow-md: 0 10px 30px -14px rgba(20,28,50,.25);
  --aurora-1: rgba(99,112,255,.10); --aurora-2: rgba(20,184,166,.07);
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
body::before { /* ambient aurora */
  content: ""; position: fixed; inset: -20vmax; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40vmax 30vmax at 15% 0%, var(--aurora-1), transparent 70%),
    radial-gradient(35vmax 28vmax at 95% 10%, var(--aurora-2), transparent 70%);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
img, video { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.ic { flex: none; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: var(--accent-soft); }

/* ------------------------------------------------------------------ shell */
.shell { min-height: 100dvh; display: grid; grid-template-columns: var(--rail) 1fr; }
.rail {
  position: sticky; top: 0; height: 100dvh; padding: 22px 14px 18px;
  display: flex; flex-direction: column; gap: 6px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in oklab, var(--bg-2) 60%, transparent), transparent);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 22px; }
.logo-mark { width: 34px; height: 34px; border-radius: 11px; box-shadow: 0 6px 20px -6px rgba(124, 140, 255, .55); }
.brand b { font: 650 19px/1 var(--font-display); letter-spacing: -0.02em; }
.brand small { display: block; color: var(--text-3); font-size: 12px; margin-top: 3px; letter-spacing: 0; font-weight: 500; }
.nav-label { color: var(--text-3); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; padding: 16px 12px 6px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px;
  border-radius: var(--r-sm); color: var(--text-2); font-weight: 520; transition: background .2s, color .2s;
}
.nav-item:hover { background: var(--card-hover); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--raise); color: var(--text); }
.nav-item[aria-current="page"]::before {
  content: ""; position: absolute; left: -14px; top: 11px; bottom: 11px; width: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(var(--accent), var(--accent-2));
}
.nav-item.soon { opacity: .55; cursor: default; }
.nav-item.soon:hover { background: none; color: var(--text-2); }
.pill-soon { margin-left: auto; font-size: 10.5px; font-weight: 600; color: var(--text-3); border: 1px solid var(--line-2); padding: 1px 7px; border-radius: 99px; }
.badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px;
  background: var(--motion); color: #1a1204; font-size: 11.5px; font-weight: 700; display: grid; place-items: center;
}
.rail-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 10px 2px; border-top: 1px solid var(--line); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; font-size: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); text-transform: uppercase;
}
.rail-foot .who { min-width: 0; flex: 1; }
.rail-foot .who b { display: block; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.rail-foot .who small { color: var(--text-3); font-size: 12px; }

main { min-width: 0; padding: 30px clamp(18px, 3.2vw, 44px) 60px; max-width: 1680px; width: 100%; }
.page { animation: page-in .45s var(--ease) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.eyebrow { color: var(--text-3); font-size: 13px; font-weight: 550; margin: 0 0 4px; }
h1 { font: 680 clamp(26px, 3.2vw, 34px)/1.1 var(--font-display); letter-spacing: -0.028em; margin: 0; }
h2 { font: 640 17px/1.3 var(--font-display); letter-spacing: -0.015em; margin: 0; }
.section { margin-top: 38px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.link { color: var(--text-2); font-size: 13.5px; font-weight: 550; display: inline-flex; align-items: center; gap: 2px; transition: color .2s; }
.link:hover { color: var(--text); }

/* ------------------------------------------------------------------ mobile shell */
.topbar, .tabbar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  main { padding: 12px 16px calc(96px + var(--safe-b)); }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30;
    padding: calc(10px + var(--safe-t)) 16px 10px; margin: 0;
    background: color-mix(in oklab, var(--bg) 78%, transparent);
    backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
    border-bottom: 1px solid transparent; transition: border-color .2s;
  }
  .topbar.scrolled { border-bottom-color: var(--line); }
  .topbar .logo-mark { width: 30px; height: 30px; border-radius: 10px; }
  .topbar b { font: 650 17px/1 var(--font-display); letter-spacing: -0.02em; }
  .topbar .spacer { flex: 1; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; z-index: 40;
    left: 12px; right: 12px; bottom: calc(10px + var(--safe-b)); height: 64px; padding: 6px;
    border-radius: 22px; background: var(--panel); border: 1px solid var(--line-2);
    backdrop-filter: saturate(1.8) blur(24px); -webkit-backdrop-filter: saturate(1.8) blur(24px);
    box-shadow: var(--shadow-md);
  }
  .tab { position: relative; display: grid; place-items: center; align-content: center; gap: 3px; border-radius: 16px; color: var(--text-3); font-size: 10.5px; font-weight: 600; transition: color .2s, background .2s; }
  .tab[aria-current="page"] { color: var(--text); background: var(--raise); }
  .tab .badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 17px; height: 17px; font-size: 10px; margin: 0; }
  .page-head { margin-bottom: 18px; }
  .section { margin-top: 30px; }
}

/* ------------------------------------------------------------------ buttons & controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: var(--r-sm); font-weight: 600; font-size: 14px; letter-spacing: -0.005em; white-space: nowrap;
  background: var(--raise); color: var(--text); border: 1px solid var(--line);
  transition: transform .15s var(--ease), background .2s, border-color .2s, opacity .2s;
}
.btn:hover { background: var(--card-hover); border-color: var(--line-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--text); color: var(--bg); border-color: transparent; }
.btn.primary:hover { opacity: .92; }
.btn.danger { color: var(--rec); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--r-sm);
  color: var(--text-2); transition: background .2s, color .2s, transform .15s var(--ease);
}
.icon-btn:hover { background: var(--raise); color: var(--text); }
.icon-btn:active { transform: scale(.92); }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 13px; background: var(--raise); border: 1px solid var(--line); }
.seg button { height: 32px; padding: 0 13px; border-radius: 10px; color: var(--text-2); font-size: 13.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; transition: background .2s, color .2s; }
.seg button[aria-pressed="true"] { background: var(--panel-solid); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.25), 0 0 0 1px var(--line); }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { height: 34px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--text-2); font-size: 13.5px; font-weight: 560; white-space: nowrap; transition: all .2s; }
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: transparent; }

/* ------------------------------------------------------------------ status bits */
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.live { background: var(--live); box-shadow: 0 0 0 0 var(--live); animation: pulse 2.4s infinite; }
.dot.rec { background: var(--rec); animation: blink 1.2s steps(2, jump-none) infinite; }
.dot.motion { background: var(--motion); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--live) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }
@keyframes blink { 50% { opacity: .25; } }

/* ------------------------------------------------------------------ stat cards */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat {
  position: relative; padding: 18px 18px 16px; border-radius: var(--r-lg);
  background: var(--card); border: 1px solid var(--line); overflow: hidden;
}
.stat .label { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; font-weight: 560; }
.stat .value { font: 680 30px/1 var(--font-display); letter-spacing: -0.03em; margin-top: 14px; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 16px; color: var(--text-3); font-weight: 600; letter-spacing: -0.01em; margin-left: 2px; }
.stat .hint { color: var(--text-3); font-size: 12.5px; margin-top: 6px; }
.stat .glyph { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: var(--raise); color: var(--text); }
.stat.ok .glyph { color: var(--live); background: color-mix(in oklab, var(--live) 14%, transparent); }
.stat.warn .glyph { color: var(--motion); background: var(--motion-soft); }
.stat.rec .glyph { color: var(--rec); background: var(--rec-soft); }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .stats { gap: 10px; } .stat { padding: 14px; border-radius: 18px; } .stat .value { font-size: 26px; margin-top: 10px; } }

/* ------------------------------------------------------------------ camera tiles */
.cam-grid { display: grid; gap: 14px; grid-template-columns: repeat(var(--cols, auto-fill), minmax(min(100%, 340px), 1fr)); }
.cam-grid[data-cols="2"] { --cols: 2; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cam-grid[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { .cam-grid, .cam-grid[data-cols] { grid-template-columns: 1fr; gap: 12px; } }

.tile {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-lg); overflow: hidden;
  background: var(--video-bg); isolation: isolate; cursor: pointer;
  box-shadow: 0 0 0 1px var(--line), var(--shadow-md);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease);
  container-type: inline-size;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px var(--line-2), 0 24px 50px -20px rgba(0,0,0,.75); }
.tile:active { transform: scale(.99); }
.tile .poster, .tile home-video, .tile home-video video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile .poster { opacity: .85; filter: saturate(.9); transition: opacity .6s; }
.tile home-video { opacity: 0; transition: opacity .6s var(--ease); }
.tile[data-state="live"] home-video { opacity: 1; }
.tile[data-state="live"] .poster { opacity: 0; }
.tile .shade {
  position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: linear-gradient(180deg, rgba(0,0,0,.42), transparent 26%, transparent 58%, rgba(0,0,0,.6));
}
.tile .top, .tile .bottom { position: absolute; left: 14px; right: 14px; z-index: 2; display: flex; align-items: center; gap: 8px; color: #fff; }
.tile .top { top: 12px; }
.tile .bottom { bottom: 12px; justify-content: space-between; }
.tile .name { font: 620 15px/1.2 var(--font-display); letter-spacing: -0.01em; text-shadow: 0 1px 10px rgba(0,0,0,.5); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .meta { color: rgba(255,255,255,.72); font-size: 12.5px; font-weight: 520; text-shadow: 0 1px 8px rgba(0,0,0,.6); }
.glass-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 99px;
  background: rgba(10, 12, 16, .5); backdrop-filter: blur(12px) saturate(1.4); -webkit-backdrop-filter: blur(12px) saturate(1.4);
  color: #fff; font-size: 11.5px; font-weight: 650; letter-spacing: .02em; border: 1px solid rgba(255,255,255,.1);
}
.glass-pill.rec { color: #ffd1d7; }
.glass-pill.motion { color: #ffe7a8; }
.tile .spacer { flex: 1; }
.tile .status-center {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; align-content: center; gap: 10px;
  color: rgba(255,255,255,.75); font-size: 13px; font-weight: 550; text-align: center; padding: 20px;
}
.tile[data-state="live"] .status-center { display: none; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.18); border-top-color: #fff; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tile .flash { position: absolute; inset: 0; z-index: 3; background: #fff; opacity: 0; pointer-events: none; }
.tile.motion-hit { box-shadow: 0 0 0 2px var(--motion), 0 20px 50px -18px color-mix(in oklab, var(--motion) 60%, transparent); }
.shimmer { background: linear-gradient(100deg, rgba(255,255,255,.02) 30%, rgba(255,255,255,.06) 50%, rgba(255,255,255,.02) 70%) var(--video-bg); background-size: 300% 100%; animation: shimmer 1.6s infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* horizontal rail of live cards on overview */
.scroller { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(300px, 1fr); gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 12px; margin: -4px -2px -12px; scrollbar-width: none; }
.scroller::-webkit-scrollbar { display: none; }
.scroller > * { scroll-snap-align: start; }
@media (max-width: 860px) { .scroller { grid-auto-columns: 84%; gap: 10px; margin: -4px -16px -12px; padding: 4px 16px 12px; scroll-padding: 0 16px; } }

/* ------------------------------------------------------------------ events */
.feed { display: flex; flex-direction: column; gap: 4px; }
.day { color: var(--text-3); font-size: 12.5px; font-weight: 640; letter-spacing: .03em; margin: 22px 4px 8px; text-transform: uppercase; }
.day:first-child { margin-top: 0; }
.ev {
  display: grid; grid-template-columns: 116px 1fr auto; align-items: center; gap: 16px; padding: 8px; border-radius: var(--r-md);
  transition: background .2s; cursor: pointer; text-align: left; width: 100%;
}
.ev:hover { background: var(--card-hover); }
.ev .thumb { width: 116px; aspect-ratio: 16/9; border-radius: 11px; overflow: hidden; background: var(--video-bg); position: relative; box-shadow: 0 0 0 1px var(--line); }
.ev .thumb img { width: 100%; height: 100%; object-fit: cover; }
.ev .thumb .ic { position: absolute; inset: 0; margin: auto; color: var(--text-3); }
.ev .title { font-weight: 600; font-size: 14.5px; letter-spacing: -0.005em; display: flex; align-items: center; gap: 8px; }
.ev .sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }
.ev .when { color: var(--text-2); font-size: 13px; font-weight: 550; font-variant-numeric: tabular-nums; }
.kind { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 7px; font-size: 11.5px; font-weight: 650; }
.kind.motion { color: var(--motion); background: var(--motion-soft); }
.kind.recording { color: var(--rec); background: var(--rec-soft); }
@media (max-width: 860px) { .ev { grid-template-columns: 96px 1fr; gap: 12px; padding: 6px; } .ev .thumb { width: 96px; } .ev .when { display: none; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card.pad { padding: 8px; }

/* overview two-column */
.split { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr); gap: 22px; align-items: start; }
@media (max-width: 1180px) { .split { grid-template-columns: 1fr; } }

/* module tiles ("Your home") */
.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.mod {
  position: relative; display: flex; flex-direction: column; gap: 14px; padding: 16px; border-radius: var(--r-lg);
  background: var(--card); border: 1px solid var(--line); min-height: 132px; transition: background .2s, transform .3s var(--ease), border-color .2s;
}
a.mod:hover { background: var(--card-hover); border-color: var(--line-2); transform: translateY(-2px); }
.mod .glyph { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--raise); color: var(--text-2); }
.mod.active .glyph { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); box-shadow: 0 8px 24px -8px color-mix(in oklab, var(--accent) 70%, transparent); }
.mod b { display: block; font-weight: 630; font-size: 15px; letter-spacing: -0.01em; }
.mod small { color: var(--text-3); font-size: 12.5px; }
.mod .pill-soon { position: absolute; top: 16px; right: 16px; }
.mod.soon { border-style: dashed; background: transparent; }
@media (max-width: 860px) { .modules { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .mod { min-height: 120px; padding: 14px; } }

/* ------------------------------------------------------------------ library */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.media { position: relative; border-radius: var(--r-md); overflow: hidden; background: var(--video-bg); aspect-ratio: 16/9; box-shadow: 0 0 0 1px var(--line); cursor: pointer; transition: transform .3s var(--ease); }
.media:hover { transform: translateY(-2px); }
.media img { width: 100%; height: 100%; object-fit: cover; }
.media .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 12px 10px; background: linear-gradient(transparent, rgba(0,0,0,.72)); color: #fff; font-size: 12.5px; font-weight: 560; display: flex; justify-content: space-between; gap: 8px; }
.media .cap span:last-child { color: rgba(255,255,255,.7); }
.media .film { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 8px; color: rgba(255,255,255,.6); background: radial-gradient(circle at 50% 40%, #1a2030, var(--video-bg)); }
.media .film .play { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.12); color: #fff; backdrop-filter: blur(8px); }
@media (max-width: 860px) { .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .media { border-radius: 12px; } }

.empty { display: grid; place-items: center; text-align: center; gap: 10px; padding: 70px 20px; color: var(--text-3); }
.empty .glyph { width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center; background: var(--raise); color: var(--text-2); margin-bottom: 4px; }
.empty b { color: var(--text); font-weight: 620; font-size: 16px; }
.empty p { margin: 0; max-width: 340px; font-size: 14px; }

/* ------------------------------------------------------------------ viewer */
.viewer {
  position: fixed; inset: 0; z-index: 60; display: grid; grid-template-columns: 1fr 360px;
  background: #030406; color: #fff; animation: fade-in .3s var(--ease) both;
  --text: #eef1f6; --text-2: #a2abb9; --text-3: #6c7585; --line: rgba(255,255,255,.08); --line-2: rgba(255,255,255,.14); --raise: rgba(255,255,255,.08); --card-hover: rgba(255,255,255,.06); --panel-solid: #151a23;
  color-scheme: dark;
}
@keyframes fade-in { from { opacity: 0; } }
.viewer .stage { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; overflow: hidden; }
.viewer .screen { position: absolute; inset: 0; display: grid; place-items: center; }
.viewer .stage home-video, .viewer .stage .poster { position: absolute; inset: 0; width: 100%; height: 100%; }
.viewer .stage home-video video, .viewer .stage .poster { object-fit: contain; width: 100%; height: 100%; }
.viewer .stage .poster { filter: blur(0); transition: opacity .5s; }
.viewer[data-state="live"] .stage .poster { opacity: 0; }
.viewer .stage .status-center { position: absolute; z-index: 2; display: grid; place-items: center; gap: 12px; color: rgba(255,255,255,.75); font-weight: 550; }
.viewer[data-state="live"] .status-center { display: none; }
.viewer .hud-top, .viewer .hud-bottom { position: absolute; left: 0; right: 0; z-index: 3; display: flex; align-items: center; gap: 10px; padding: 16px 18px; transition: opacity .35s var(--ease), transform .35s var(--ease); }
.viewer .hud-top { top: 0; padding-top: calc(16px + var(--safe-t)); background: linear-gradient(rgba(0,0,0,.55), transparent); }
.viewer .hud-bottom { bottom: 0; justify-content: center; background: linear-gradient(transparent, rgba(0,0,0,.6)); padding-bottom: calc(20px + var(--safe-b)); }
.viewer.idle .hud-top, .viewer.idle .hud-bottom { opacity: 0; pointer-events: none; }
.viewer.idle .hud-top { transform: translateY(-8px); }
.viewer.idle .hud-bottom { transform: translateY(8px); }
.viewer.idle { cursor: none; }
.viewer .title { min-width: 0; }
.viewer .title b { display: block; font: 640 18px/1.2 var(--font-display); letter-spacing: -0.015em; }
.viewer .title small { display: flex; align-items: center; gap: 7px; color: rgba(255,255,255,.7); font-size: 12.5px; font-weight: 520; }
.viewer .spacer { flex: 1; }
.hud-btn {
  height: 44px; min-width: 44px; padding: 0 14px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: rgba(255,255,255,.1); color: #fff; font-weight: 600; font-size: 13.5px; border: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(16px) saturate(1.5); -webkit-backdrop-filter: blur(16px) saturate(1.5);
  transition: background .2s, transform .15s var(--ease);
}
.hud-btn:hover { background: rgba(255,255,255,.18); }
.hud-btn:active { transform: scale(.95); }
.hud-btn.icon { padding: 0; width: 44px; }
.hud-btn.on { background: #fff; color: #0b0e14; }
.hud-btn.rec-on { background: var(--rec); color: #fff; border-color: transparent; }
.hud-bar { display: flex; gap: 8px; padding: 6px; border-radius: 20px; background: rgba(12,14,18,.5); border: 1px solid rgba(255,255,255,.08); backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5); }
.hud-bar .hud-btn { background: transparent; border-color: transparent; backdrop-filter: none; }
.hud-bar .hud-btn:hover { background: rgba(255,255,255,.1); }
.hud-bar .hud-btn.on { background: #fff; }
.hud-bar .hud-btn.rec-on { background: var(--rec); }
.hud-bar .sep { width: 1px; margin: 8px 2px; background: rgba(255,255,255,.12); }
.nav-arrow { position: absolute; top: 50%; z-index: 3; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.08); color: #fff; backdrop-filter: blur(12px); transition: opacity .3s, background .2s; }
.nav-arrow:hover { background: rgba(255,255,255,.18); }
.nav-arrow.prev { left: 16px; } .nav-arrow.next { right: 16px; }
.viewer.idle .nav-arrow { opacity: 0; pointer-events: none; }
.rec-timer { font-variant-numeric: tabular-nums; }
.flash-overlay { position: absolute; inset: 0; z-index: 4; background: #fff; pointer-events: none; animation: flash .45s ease-out forwards; }
@keyframes flash { from { opacity: .7; } to { opacity: 0; } }

.side { background: #0b0e13; border-left: 1px solid rgba(255,255,255,.07); display: flex; flex-direction: column; min-height: 0; overflow: auto; }
.side-sec { padding: 22px 22px 6px; }
.side-sec + .side-sec { border-top: 1px solid rgba(255,255,255,.06); padding-top: 20px; margin-top: 14px; }
.side h3 { margin: 0 0 14px; font-size: 12px; font-weight: 640; color: var(--text-3); letter-spacing: .07em; text-transform: uppercase; display: flex; justify-content: space-between; align-items: center; }
.side .ev { grid-template-columns: 88px 1fr; gap: 12px; padding: 6px; }
.side .ev .thumb { width: 88px; }
.side .ev .when { display: none; }

/* PTZ joystick */
.ptz { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; }
.joy {
  --size: 156px; position: relative; width: var(--size); height: var(--size); border-radius: 50%; touch-action: none; user-select: none;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,.06), rgba(255,255,255,.02) 62%), #10141b;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), inset 0 10px 30px rgba(0,0,0,.45), 0 1px 0 rgba(255,255,255,.04);
}
.joy .tick { position: absolute; color: rgba(255,255,255,.35); transition: color .2s; }
.joy .tick.u { top: 10px; left: 50%; transform: translateX(-50%); }
.joy .tick.d { bottom: 10px; left: 50%; transform: translateX(-50%); }
.joy .tick.l { left: 10px; top: 50%; transform: translateY(-50%); }
.joy .tick.r { right: 10px; top: 50%; transform: translateY(-50%); }
.joy[data-dir*="u"] .tick.u, .joy[data-dir*="d"] .tick.d, .joy[data-dir*="l"] .tick.l, .joy[data-dir*="r"] .tick.r { color: var(--accent-2); }
.joy .knob {
  position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%;
  background: linear-gradient(180deg, #2a3140, #1a1f29); box-shadow: 0 10px 22px -6px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.12), 0 0 0 1px rgba(255,255,255,.08);
  transition: transform .35s var(--spring); cursor: grab; display: grid; place-items: center; color: rgba(255,255,255,.5);
}
.joy.active .knob { transition: none; cursor: grabbing; background: linear-gradient(180deg, #353e52, #222937); }
.ptz-side { display: flex; flex-direction: column; gap: 8px; }
.ptz-side .btn { width: 100%; justify-content: flex-start; height: 42px; background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.06); color: #fff; }
.ptz-side .btn:hover { background: rgba(255,255,255,.1); }
.ptz-note { color: var(--text-3); font-size: 12.5px; margin-top: 14px; line-height: 1.45; }
.kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px; font-size: 11px; font-weight: 650; color: var(--text-2); background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); border-bottom-width: 2px; }
.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 9px 12px; font-size: 13px; color: var(--text-2); align-items: center; }

@media (max-width: 960px) {
  .viewer { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow: auto; }
  .viewer .stage { display: block; overflow: visible; width: 100%; margin-top: calc(68px + var(--safe-t)); }
  .viewer .screen { position: relative; inset: auto; aspect-ratio: 16 / 9; width: 100%; background: #000; overflow: hidden; }
  .viewer .hud-bar .hud-btn { padding: 0 10px; font-size: 13px; }
  .viewer .hud-top { position: fixed; background: #030406; }
  .viewer.idle .hud-top, .viewer.idle .hud-bottom { opacity: 1; pointer-events: auto; transform: none; }
  .viewer.idle { cursor: auto; }
  .viewer .hud-bottom { position: static; background: none; padding: 14px 16px 0; }
  .viewer .hud-bar { width: 100%; justify-content: space-between; }
  .viewer .nav-arrow { display: none; }
  .side { border: 0; background: transparent; overflow: visible; padding-bottom: calc(24px + var(--safe-b)); }
  .side-sec { padding: 18px 16px 4px; }
  .shortcuts-sec { display: none; }
}

/* ------------------------------------------------------------------ lightbox, dialog, toast */
.overlay { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px; background: rgba(3,4,7,.82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); animation: fade-in .25s var(--ease) both; }
.lightbox { position: relative; width: min(1200px, 100%); display: flex; flex-direction: column; gap: 14px; animation: pop .35s var(--ease) both; }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } }
.lightbox .media-frame { border-radius: var(--r-lg); overflow: hidden; background: #000; box-shadow: var(--shadow-lg); }
.lightbox .media-frame img, .lightbox .media-frame video { width: 100%; max-height: calc(100dvh - 170px); object-fit: contain; background: #000; }
.lightbox .bar { display: flex; align-items: center; gap: 10px; color: #fff; }
.lightbox .bar .title b { display: block; font-weight: 630; font-size: 15px; }
.lightbox .bar .title small { color: rgba(255,255,255,.6); font-size: 13px; }
.lightbox .spacer { flex: 1; }
.lightbox .hud-btn { height: 40px; }

.dialog { width: min(400px, 100%); padding: 24px; border-radius: var(--r-xl); background: var(--panel-solid); box-shadow: var(--shadow-lg); animation: pop .3s var(--ease) both; }
.dialog h2 { font-size: 18px; margin-bottom: 6px; }
.dialog p { color: var(--text-2); margin: 0 0 22px; font-size: 14.5px; }
.dialog .actions { display: flex; gap: 10px; justify-content: flex-end; }
.dialog .btn.danger-fill { background: var(--rec); color: #fff; border-color: transparent; }

.toasts { position: fixed; z-index: 90; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; min-width: 260px; max-width: 380px; padding: 10px 14px 10px 10px;
  border-radius: 18px; background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg);
  backdrop-filter: blur(24px) saturate(1.6); -webkit-backdrop-filter: blur(24px) saturate(1.6);
  animation: toast-in .45s var(--spring) both; cursor: default;
}
.toast.out { animation: toast-out .3s var(--ease) forwards; }
.toast .t-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--raise); flex: none; }
.toast.motion .t-icon { background: var(--motion-soft); color: var(--motion); }
.toast.ok .t-icon { color: var(--live); background: color-mix(in oklab, var(--live) 14%, transparent); }
.toast.err .t-icon { color: var(--rec); background: var(--rec-soft); }
.toast img { width: 64px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; flex: none; }
.toast b { display: block; font-size: 14px; font-weight: 620; }
.toast small { color: var(--text-2); font-size: 12.5px; }
.toast[data-href] { cursor: pointer; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }
@media (max-width: 860px) { .toasts { left: 12px; right: 12px; top: calc(10px + var(--safe-t)); bottom: auto; align-items: stretch; } .toast { max-width: none; } @keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(.96); } } }

/* ------------------------------------------------------------------ login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.login::before {
  content: ""; position: absolute; width: 900px; height: 900px; left: 50%; top: 42%; transform: translate(-50%, -50%);
  background: conic-gradient(from 200deg, rgba(124,140,255,.0), rgba(124,140,255,.22), rgba(45,212,191,.16), rgba(124,140,255,.0) 70%);
  filter: blur(90px); border-radius: 50%; animation: drift 18s ease-in-out infinite alternate; z-index: -1;
}
@keyframes drift { to { transform: translate(-46%, -54%) rotate(40deg); } }
.login-card {
  width: min(400px, 100%); padding: 34px 30px 28px; border-radius: var(--r-xl);
  background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg);
  backdrop-filter: blur(30px) saturate(1.6); -webkit-backdrop-filter: blur(30px) saturate(1.6);
  animation: pop .6s var(--ease) both;
}
.login-card .logo-mark { width: 52px; height: 52px; border-radius: 16px; margin-bottom: 22px; box-shadow: 0 14px 40px -10px rgba(124,140,255,.6); }
.login-card h1 { font-size: 26px; }
.login-card p.sub { color: var(--text-2); margin: 6px 0 26px; font-size: 14.5px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.field input {
  width: 100%; height: 48px; padding: 0 15px; border-radius: 14px; border: 1px solid var(--line-2);
  background: color-mix(in oklab, var(--bg) 55%, transparent); font-size: 15.5px; outline: none; transition: border-color .2s, box-shadow .2s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.login-card .btn.primary { width: 100%; height: 50px; border-radius: 14px; font-size: 15px; margin-top: 8px; }
.login-err { min-height: 22px; margin-top: 12px; color: var(--rec); font-size: 13.5px; font-weight: 550; text-align: center; }
.login-foot { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 18px; color: var(--text-3); font-size: 12.5px; }
.shake { animation: shake .45s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

/* boot */
.boot { min-height: 100dvh; display: grid; place-items: center; }
.boot .logo-mark { width: 56px; height: 56px; border-radius: 18px; animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(.94); opacity: .7; } }

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