/* PHONE GHOST — design system: deep graphite, glass panels, electric accent */
:root {
  --bg: #0b0d10;
  --bg-2: #101318;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-2: rgba(255, 255, 255, 0.08);
  --stroke: rgba(255, 255, 255, 0.09);
  --text: #e8edf2;
  --text-dim: #97a1ad;
  --text-faint: #5b636d;
  --accent: #6ee7ff;
  --accent-dim: rgba(110, 231, 255, 0.16);
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --rec: #ff4d4d;
  --radius: 18px;
  --radius-s: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(110, 231, 255, 0.07), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, rgba(110, 231, 255, 0.04), transparent 60%);
}
.app { position: relative; z-index: 1; min-height: 100dvh; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--stroke);
  border-radius: var(--radius-s); padding: 12px 14px; width: 100%; outline: none;
}
input:focus, select:focus { border-color: rgba(110, 231, 255, 0.5); }
a { color: var(--accent); text-decoration: none; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.icon.fill { fill: currentColor; stroke: none; }
h1 { font-size: 26px; letter-spacing: 0.5px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; font-family: "Cascadia Code", ui-monospace, monospace; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.wrap { padding: 18px; padding-top: calc(18px + var(--safe-top)); max-width: 640px; width: 100%; margin: 0 auto; flex: 1; display: flex; flex-direction: column; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 13px 20px; border-radius: 14px; font-weight: 600; font-size: 15px;
  background: var(--panel-2); border: 1px solid var(--stroke);
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: #06222b; border-color: transparent; box-shadow: 0 6px 26px rgba(110, 231, 255, 0.28); }
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(248, 113, 113, 0.14); color: var(--bad); border-color: rgba(248, 113, 113, 0.3); }
.btn.big { width: 100%; padding: 17px 20px; font-size: 16px; border-radius: 16px; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }
.btn-icon {
  width: 44px; height: 44px; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); border: 1px solid var(--stroke); transition: transform 0.12s, background 0.15s;
}
.btn-icon:active { transform: scale(0.92); }
.btn-icon.active { background: var(--accent); color: #06222b; border-color: transparent; }

/* cards / glass */
.card {
  background: var(--panel); border: 1px solid var(--stroke); border-radius: var(--radius);
  padding: 16px; backdrop-filter: blur(14px);
}
.glass { background: rgba(13, 16, 20, 0.72); backdrop-filter: blur(18px); border: 1px solid var(--stroke); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: var(--panel-2); color: var(--text-dim); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.badge.live { color: var(--good); background: rgba(74, 222, 128, 0.12); }
.badge.live .dot { background: var(--good); animation: breathe 2.4s ease-in-out infinite; }
.badge.off { color: var(--bad); background: rgba(248, 113, 113, 0.1); }
.badge.off .dot { background: var(--bad); }
.badge.rec { color: var(--rec); background: rgba(255, 77, 77, 0.12); }
.badge.rec .dot { background: var(--rec); animation: blink 1.1s steps(2) infinite; }
.badge.armed { color: var(--accent); background: var(--accent-dim); }
@keyframes breathe { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(0.8); } }
@keyframes blink { 50% { opacity: 0.25; } }

/* top bar */
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 16px; padding-top: calc(14px + var(--safe-top)); position: sticky; top: 0; z-index: 20; }
.topbar h2 { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* toasts */
.toasts { position: fixed; top: calc(14px + var(--safe-top)); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 200; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 92vw;
  background: rgba(18, 22, 27, 0.94); border: 1px solid var(--stroke); border-radius: 14px;
  padding: 11px 16px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow);
  animation: toast-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.toast.alert { border-color: rgba(110, 231, 255, 0.4); }
.toast.error { border-color: rgba(248, 113, 113, 0.45); }
.toast img { width: 44px; height: 33px; object-fit: cover; border-radius: 7px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(0.95); } }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(4, 6, 8, 0.72); backdrop-filter: blur(6px); z-index: 100; display: flex; align-items: flex-end; justify-content: center; animation: fade 0.2s; }
@media (min-width: 560px) { .modal-backdrop { align-items: center; } }
.modal {
  width: 100%; max-width: 460px; max-height: 88dvh; overflow: auto;
  background: #12161b; border: 1px solid var(--stroke); border-radius: 22px 22px 0 0; padding: 22px;
  animation: sheet-up 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@media (min-width: 560px) { .modal { border-radius: 22px; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ============ onboarding ============ */
.onb { flex: 1; display: flex; flex-direction: column; justify-content: space-between; padding: 26px; padding-top: calc(40px + var(--safe-top)); padding-bottom: calc(28px + var(--safe-bot)); text-align: center; min-height: 100dvh; }
.onb-art { flex: 1; display: flex; align-items: center; justify-content: center; }
.onb h1 { font-size: 30px; line-height: 1.16; letter-spacing: 0.4px; margin-bottom: 12px; }
.onb p { color: var(--text-dim); font-size: 16px; max-width: 300px; margin: 0 auto; }
.onb-dots { display: flex; gap: 7px; justify-content: center; margin: 26px 0; }
.onb-dots span { width: 7px; height: 7px; border-radius: 99px; background: var(--text-faint); transition: all 0.25s; }
.onb-dots span.on { width: 22px; background: var(--accent); }
.logo-mark { filter: drop-shadow(0 0 34px rgba(110, 231, 255, 0.25)); }
.role-btn {
  display: flex; align-items: center; gap: 16px; text-align: left; width: 100%;
  padding: 20px; border-radius: 20px; background: var(--panel); border: 1px solid var(--stroke);
  transition: transform 0.12s, border-color 0.15s;
}
.role-btn:active { transform: scale(0.98); }
.role-btn .icon { width: 30px; height: 30px; color: var(--accent); }
.role-btn b { display: block; font-size: 17px; }
.role-btn span { color: var(--text-dim); font-size: 13.5px; }

/* ============ camera mode ============ */
.cam-shell { min-height: 100dvh; display: flex; flex-direction: column; background: #07090b; }
.cam-preview { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 16/10; }
.cam-preview video { width: 100%; height: 100%; object-fit: cover; }
.cam-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--stroke); border-radius: var(--radius-s); padding: 12px 14px; }
.stat .small { margin-bottom: 2px; }
.stat b { font-size: 15px; }
.cam-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.cam-action { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 13px 4px; border-radius: 14px; background: var(--panel); border: 1px solid var(--stroke); font-size: 11.5px; color: var(--text-dim); transition: transform 0.12s; }
.cam-action:active { transform: scale(0.94); }
.cam-action .icon { width: 21px; height: 21px; color: var(--text); }
.cam-action.on { border-color: rgba(110, 231, 255, 0.55); color: var(--accent); }
.cam-action.on .icon { color: var(--accent); }
.qr-box { background: #fff; border-radius: 20px; padding: 18px; display: flex; align-items: center; justify-content: center; }
.qr-box svg, .qr-box img { width: min(62vw, 260px); height: min(62vw, 260px); image-rendering: pixelated; }
.pair-code { font-size: 34px; letter-spacing: 10px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.diag-row { display: flex; align-items: center; gap: 12px; padding: 13px 4px; border-bottom: 1px solid var(--stroke); }
.diag-row:last-child { border-bottom: 0; }
.diag-state { margin-left: auto; font-weight: 600; font-size: 13px; }
.diag-state.ok { color: var(--good); }
.diag-state.bad { color: var(--bad); }
.diag-state.wait { color: var(--text-faint); }

/* black-out overlays */
.blackout { position: fixed; inset: 0; background: #000; z-index: 300; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; color: #2c333b; }
.blackout.dim { background: rgba(0, 0, 0, 0.88); }
.blackout .clock { font-size: 44px; font-weight: 200; color: #3a424c; font-variant-numeric: tabular-nums; }
.screenlight { position: fixed; inset: 0; background: #fff; opacity: 0.65; z-index: 290; }
.lockring { width: 74px; height: 74px; border-radius: 50%; border: 2px solid #2c333b; display: flex; align-items: center; justify-content: center; position: relative; }
.lockring svg.progress { position: absolute; inset: -2px; transform: rotate(-90deg); }
.cam-msg-overlay { position: fixed; inset: 0; z-index: 280; background: rgba(0, 0, 0, 0.92); display: flex; align-items: center; justify-content: center; padding: 30px; text-align: center; }
.cam-msg-overlay h1 { font-size: clamp(30px, 8vw, 54px); color: var(--accent); }

/* ============ viewer / dashboard ============ */
.dash-greet { padding: 6px 2px 14px; }
.dash-greet h1 { font-size: 24px; }
.cam-grid { display: grid; gap: 14px; }
.cam-card {
  position: relative; border-radius: 20px; overflow: hidden; border: 1px solid var(--stroke);
  background: var(--bg-2); text-align: left; width: 100%; transition: transform 0.14s;
}
.cam-card:active { transform: scale(0.985); }
.cam-card .thumb { aspect-ratio: 16/9; width: 100%; object-fit: cover; display: block; background: #0d1013; }
.cam-card .thumb.empty { display: flex; align-items: center; justify-content: center; color: var(--text-faint); }
.cam-card .meta { position: absolute; inset: auto 0 0 0; padding: 30px 14px 12px; background: linear-gradient(transparent, rgba(5, 7, 9, 0.92)); display: flex; align-items: flex-end; gap: 10px; }
.cam-card .meta b { font-size: 16px; display: block; }
.cam-card .chips { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 6px; }
.summary-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.summary-strip .cell { background: var(--panel); border: 1px solid var(--stroke); border-radius: 14px; padding: 11px 6px; text-align: center; }
.summary-strip b { font-size: 19px; display: block; }
.summary-strip span { font-size: 11px; color: var(--text-dim); }
.fab { position: fixed; right: 18px; bottom: calc(20px + var(--safe-bot)); z-index: 30; width: 56px; height: 56px; border-radius: 19px; background: var(--accent); color: #06222b; display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 30px rgba(110, 231, 255, 0.35); transition: transform 0.12s; }
.fab:active { transform: scale(0.92); }

/* ============ live view ============ */
.live { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; flex-direction: column; }
.live video.main { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transition: transform 0.2s ease; transform-origin: center; }
.live .vignette { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(rgba(0, 0, 0, 0.55), transparent 18%, transparent 78%, rgba(0, 0, 0, 0.65)); }
.live-top { position: relative; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 14px 16px; padding-top: calc(12px + var(--safe-top)); }
.live-top .title b { display: block; font-size: 16px; }
.live-bottom { position: relative; z-index: 5; margin-top: auto; padding: 10px 14px calc(16px + var(--safe-bot)); display: flex; flex-direction: column; gap: 12px; }
.live-controls { display: flex; justify-content: space-around; align-items: center; gap: 6px; }
.live-ctl { display: flex; flex-direction: column; align-items: center; gap: 5px; color: var(--text-dim); font-size: 10.5px; font-weight: 600; letter-spacing: 0.3px; min-width: 52px; }
.live-ctl .pad { width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.09); border: 1px solid rgba(255, 255, 255, 0.12); backdrop-filter: blur(10px); transition: transform 0.12s, background 0.15s; color: var(--text); }
.live-ctl:active .pad { transform: scale(0.9); }
.live-ctl.on .pad { background: var(--accent); color: #06222b; }
.live-ctl.rec .pad { background: var(--rec); color: #fff; }
.live-ctl.talk .pad { width: 62px; height: 62px; }
.live-ctl.talk.on .pad { transform: scale(1.12); box-shadow: 0 0 0 10px rgba(110, 231, 255, 0.18); }
.live-status { position: relative; z-index: 5; display: flex; gap: 8px; padding: 0 16px; flex-wrap: wrap; }
.live-center-note { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; z-index: 4; text-align: center; padding: 28px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(110, 231, 255, 0.18); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.wave { display: flex; gap: 3px; align-items: center; height: 16px; }
.wave i { width: 3px; border-radius: 2px; background: var(--accent); height: 4px; animation: wavey 1s ease-in-out infinite; }
.wave i:nth-child(2) { animation-delay: 0.15s; } .wave i:nth-child(3) { animation-delay: 0.3s; }
.wave i:nth-child(4) { animation-delay: 0.45s; } .wave i:nth-child(5) { animation-delay: 0.6s; }
@keyframes wavey { 0%, 100% { height: 4px; } 50% { height: 15px; } }
.ts-overlay { position: absolute; right: 12px; top: calc(60px + var(--safe-top)); z-index: 4; font-size: 11px; color: rgba(255, 255, 255, 0.75); background: rgba(0, 0, 0, 0.4); padding: 3px 8px; border-radius: 7px; font-variant-numeric: tabular-nums; }

/* ============ timeline ============ */
.ev-row { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 16px; background: var(--panel); border: 1px solid var(--stroke); }
.ev-thumb { width: 84px; height: 56px; border-radius: 10px; object-fit: cover; background: #0d1013; flex: 0 0 auto; }
.ev-ico { width: 40px; height: 40px; border-radius: 12px; background: var(--panel-2); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.ev-ico.motion { color: var(--warn); } .ev-ico.sound { color: var(--accent); } .ev-ico.offline { color: var(--bad); } .ev-ico.online { color: var(--good); }
.filter-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.filter-chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; padding: 7px 15px; border-radius: 99px; background: var(--panel); border: 1px solid var(--stroke); font-size: 13px; font-weight: 600; color: var(--text-dim); }
.chip.on { background: var(--accent); color: #06222b; border-color: transparent; }

/* ============ settings ============ */
.set-row { display: flex; align-items: center; gap: 12px; padding: 15px 2px; border-bottom: 1px solid var(--stroke); }
.set-row:last-child { border-bottom: 0; }
.set-row .grow { flex: 1; }
.set-row .grow span { display: block; font-size: 12.5px; color: var(--text-dim); }
.switch { position: relative; width: 48px; height: 28px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--stroke); transition: background 0.2s; flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--text-dim); transition: all 0.2s; }
.switch.on { background: var(--accent); border-color: transparent; }
.switch.on::after { left: 23px; background: #06222b; }
.seg { display: flex; background: var(--panel); border: 1px solid var(--stroke); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; padding: 8px 6px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-dim); }
.seg button.on { background: var(--accent); color: #06222b; }
.zone-grid { position: relative; border-radius: 14px; overflow: hidden; aspect-ratio: 16/9; background: #0d1013; }
.zone-grid img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.55; }
.zone-cells { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(6, 1fr); }
.zone-cells i { border: 1px solid rgba(255, 255, 255, 0.07); background: rgba(248, 113, 113, 0.25); }
.zone-cells i.on { background: rgba(110, 231, 255, 0.22); border-color: rgba(110, 231, 255, 0.35); }
input[type="range"] { -webkit-appearance: none; appearance: none; height: 5px; border-radius: 4px; background: var(--panel-2); padding: 0; border: 0; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); }

/* misc */
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; padding: 40px 24px; color: var(--text-dim); }
.empty-state .icon { width: 46px; height: 46px; color: var(--text-faint); }
.otp-inputs { display: flex; gap: 8px; justify-content: center; }
.pulse-ring { animation: pulse-ring 2s ease-out infinite; }
@keyframes pulse-ring { 0% { opacity: 0.9; transform: scale(0.6); } 100% { opacity: 0; transform: scale(1.5); } }
.fade-in { animation: fade 0.3s ease; }
.slide-up { animation: sheet-up 0.3s cubic-bezier(0.2, 0.9, 0.3, 1); }
video::-webkit-media-controls { display: none !important; }
.hidden { display: none !important; }
