:root {
  color-scheme: dark;
  --bg: #090c11;
  --surface: #10151d;
  --surface-2: #171d27;
  --border: rgba(255,255,255,.1);
  --text: #f5f7fb;
  --muted: #9099a8;
  --accent: #5ee7b3;
  --accent-strong: #38cf98;
  --danger: #ff6969;
  --shadow: 0 24px 70px rgba(0,0,0,.38);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 85% -20%, #18312d 0, transparent 35%), var(--bg); color: var(--text); }
button, input { font: inherit; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
.hidden { display: none !important; }

.app-header {
  height: 72px; padding: 0 max(24px, calc((100vw - 1180px) / 2));
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); background: rgba(9,12,17,.82);
  backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 720; letter-spacing: -.02em; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; background: var(--accent); color: #07120e; box-shadow: 0 0 28px rgba(94,231,179,.18); }
.brand-mark svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.user-actions { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 14px; }
.user-actions form { margin: 0; }
.text-button { border: 0; background: transparent; padding: 8px 0; cursor: pointer; color: var(--text); }
.text-button:hover, .back-link:hover { color: var(--accent); }

.dashboard-shell, .viewer-shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 64px 0 80px; }
.page-heading, .viewer-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 34px; }
.eyebrow { display: block; color: var(--accent); font-size: 12px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 10px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(34px, 5vw, 54px); line-height: 1; letter-spacing: -.045em; }
.page-heading p, .auth-copy p { color: var(--muted); margin-bottom: 0; font-size: 17px; }
.secure-pill { display: flex; align-items: center; gap: 9px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 999px; color: #c8ced7; font-size: 13px; background: rgba(255,255,255,.025); }
.secure-pill span, .privacy-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }

.camera-card { width: min(560px, 100%); display: block; overflow: hidden; border: 1px solid var(--border); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); transition: transform .24s ease, border-color .24s ease; }
.camera-card:hover { transform: translateY(-4px); border-color: rgba(94,231,179,.32); }
.camera-preview { aspect-ratio: 16/9; position: relative; display: grid; place-items: center; overflow: hidden; background: #0b1018; }
.camera-gradient { position: absolute; inset: 0; background: radial-gradient(circle at 65% 35%, rgba(94,231,179,.13), transparent 34%), linear-gradient(145deg, #151d28, #090c11); }
.camera-gradient::before { content: ""; position: absolute; inset: 0; opacity: .15; background-image: linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px); background-size: 36px 36px; mask-image: linear-gradient(to bottom, black, transparent); }
.camera-icon { width: 70px; height: 70px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.12); border-radius: 24px; background: rgba(255,255,255,.05); backdrop-filter: blur(12px); }
.camera-icon svg { width: 36px; fill: none; stroke: #dce4ee; stroke-width: 1.4; stroke-linejoin: round; }
.preview-label { position: absolute; left: 20px; bottom: 18px; padding: 8px 11px; border-radius: 9px; background: rgba(4,7,11,.65); border: 1px solid rgba(255,255,255,.1); font-size: 12px; font-weight: 680; backdrop-filter: blur(10px); }
.camera-meta { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 24px; }
.camera-meta h2 { font-size: 19px; margin-bottom: 7px; letter-spacing: -.02em; }
.camera-meta p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.open-camera { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.055); font-size: 20px; transition: background .2s, color .2s; }
.camera-card:hover .open-camera { background: var(--accent); color: #07120e; }

.auth-page { background: radial-gradient(circle at 20% 20%, rgba(94,231,179,.13), transparent 38%), var(--bg); }
.auth-page .app-header { position: relative; border: 0; background: transparent; }
.auth-shell { min-height: calc(100vh - 72px); width: min(1080px, calc(100% - 48px)); margin: auto; display: grid; grid-template-columns: 1.1fr .8fr; align-items: center; gap: 9vw; padding: 48px 0 100px; }
.auth-copy h1 { max-width: 580px; font-size: clamp(48px, 7vw, 82px); line-height: .96; }
.auth-card { padding: 34px; border: 1px solid var(--border); border-radius: 24px; background: rgba(16,21,29,.9); box-shadow: var(--shadow); }
.auth-card h2 { margin-bottom: 7px; font-size: 28px; letter-spacing: -.03em; }
.muted, .privacy-note { color: var(--muted); }
.form-stack { display: grid; gap: 10px; margin-top: 28px; }
.form-stack label { margin-top: 8px; font-size: 13px; font-weight: 650; color: #d5dae2; }
.form-stack input { width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--border); border-radius: 12px; outline: none; color: var(--text); background: #0b1017; transition: border-color .2s, box-shadow .2s; }
.form-stack input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(94,231,179,.11); }
.primary-button, .secondary-button { min-height: 46px; padding: 0 18px; border: 0; border-radius: 12px; font-weight: 720; cursor: pointer; }
.primary-button { margin-top: 18px; background: var(--accent); color: #07120e; }
.primary-button:hover { background: var(--accent-strong); }
.secondary-button { margin-top: 14px; border: 1px solid var(--border); background: rgba(255,255,255,.08); }
.privacy-note { margin: 22px 0 0; font-size: 12px; text-align: center; }
.alert { margin-top: 20px; padding: 12px 14px; border: 1px solid rgba(255,105,105,.3); border-radius: 11px; color: #ffc3c3; background: rgba(255,105,105,.08); font-size: 13px; }

.viewer-shell { padding-top: 42px; }
.viewer-heading { align-items: center; margin-bottom: 22px; }
.viewer-heading h1 { margin: 8px 0 0; font-size: clamp(27px, 4vw, 38px); }
.back-link { color: var(--muted); font-size: 13px; transition: color .2s; }
.live-status { display: flex; align-items: center; gap: 9px; padding: 9px 13px; border: 1px solid var(--border); border-radius: 999px; background: rgba(255,255,255,.025); color: var(--muted); font-size: 12px; }
.live-status span { width: 8px; height: 8px; border-radius: 50%; background: #788291; }
.live-status[data-state="live"] { color: #cffff0; border-color: rgba(94,231,179,.24); background: rgba(94,231,179,.07); }
.live-status[data-state="live"] span { background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.live-status[data-state="error"] span { background: var(--danger); }
.player-frame { position: relative; overflow: hidden; aspect-ratio: 16/9; border-radius: 22px; border: 1px solid var(--border); background: #030507; box-shadow: var(--shadow); }
.player-frame video { width: 100%; height: 100%; object-fit: contain; background: #030507; }
.player-shade { pointer-events: none; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,.4), transparent 22%, transparent 68%, rgba(0,0,0,.72)); opacity: 0; transition: opacity .25s; }
.player-frame[data-state="live"]:hover .player-shade, .player-frame[data-state="live"]:hover .player-controls, .player-frame[data-state="live"]:hover .player-topline { opacity: 1; }
.connection-state { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; padding: 24px; text-align: center; background: radial-gradient(circle, #101821 0, #05080c 70%); }
.connection-state h2 { margin: 20px 0 8px; font-size: clamp(20px, 3vw, 28px); }
.connection-state p { max-width: 460px; margin-bottom: 0; color: var(--muted); font-size: 14px; }
.spinner { width: 38px; height: 38px; border: 3px solid rgba(255,255,255,.12); border-top-color: var(--accent); border-radius: 50%; animation: spin .85s linear infinite; }
.player-frame[data-state="error"] .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.player-topline { position: absolute; top: 20px; left: 20px; right: 20px; display: flex; justify-content: space-between; align-items: center; opacity: 0; transition: opacity .25s; pointer-events: none; }
.live-badge { display: flex; align-items: center; gap: 7px; padding: 7px 9px; border-radius: 8px; background: rgba(4,7,11,.67); font-size: 10px; font-weight: 800; letter-spacing: .1em; backdrop-filter: blur(8px); }
.live-badge i { width: 7px; height: 7px; border-radius: 50%; background: #ff4e5e; box-shadow: 0 0 10px #ff4e5e; }
.player-topline time { font-size: 12px; font-variant-numeric: tabular-nums; text-shadow: 0 1px 5px #000; }
.player-controls { position: absolute; left: 18px; right: 18px; bottom: 16px; display: flex; align-items: center; gap: 9px; opacity: 0; transition: opacity .25s; }
.control-spacer { flex: 1; }
.control-button, .icon-button { height: 42px; border: 1px solid rgba(255,255,255,.14); border-radius: 11px; background: rgba(4,7,11,.62); backdrop-filter: blur(10px); cursor: pointer; }
.control-button { display: flex; align-items: center; gap: 9px; padding: 0 13px; font-size: 12px; font-weight: 650; }
.icon-button { width: 42px; display: grid; place-items: center; }
.control-button:hover, .icon-button:hover { background: rgba(255,255,255,.14); }
.control-button svg, .icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.viewer-footnote { padding: 14px 4px 0; display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.viewer-footnote span { display: flex; align-items: center; gap: 8px; }

@media (hover: none) {
  .player-frame[data-state="live"] .player-shade, .player-frame[data-state="live"] .player-controls, .player-frame[data-state="live"] .player-topline { opacity: 1; }
}
@media (max-width: 760px) {
  .app-header { height: 64px; padding: 0 18px; }
  .user-name { display: none; }
  .dashboard-shell, .viewer-shell { width: min(100% - 28px, 1180px); padding-top: 38px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .auth-shell { grid-template-columns: 1fr; gap: 44px; width: min(100% - 30px, 520px); align-content: center; }
  .auth-copy { display: none; }
  .auth-card { padding: 26px 22px; }
  .viewer-heading { align-items: flex-end; }
  .player-frame { border-radius: 14px; aspect-ratio: 9/14; }
  .player-frame video { object-fit: contain; }
  .control-button span { display: none; }
  .control-button { width: 42px; padding: 0; justify-content: center; }
  .viewer-footnote { padding-left: 2px; padding-right: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
