:root{
  --bg: #0A0A0B;
  --surface: #151517;
  --surface-2: #1C1C1F;
  --border: #262629;
  --red: #E4362F;
  --red-dim: rgba(228,54,47,0.15);
  --red-glow: rgba(228,54,47,0.35);
  --green: #22C55E;
  --amber: #F5A524;
  --text: #F5F5F6;
  --text-dim: #9A9AA1;
  --text-faint: #6B6B71;
  --radius: 18px;
  --radius-sm: 12px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

*{ box-sizing:border-box; margin:0; padding:0; }
/* Components below set display:flex, which outranks the UA rule for [hidden].
   Without this, el.hidden = true does nothing. */
[hidden]{ display:none !important; }

html,body{
  background: #050506;
  color: var(--text);
  height:100%;
}

button{ font-family:inherit; cursor:pointer; }

.app-shell{
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  overflow:hidden;
  box-shadow: 0 0 0 1px #000, 0 40px 80px rgba(0,0,0,0.6);
}

@media (min-width: 431px){
  body{ padding: 32px 0; background: radial-gradient(circle at 50% 0%, #141416, #050506 60%); }
  .app-shell{ border-radius: 40px; min-height: 860px; height:860px; }
}

/* ---------- screens ---------- */
.screen{
  display:none;
  flex-direction: column;
  height: 100%;
  min-height: 100vh;
  position:absolute;
  inset:0;
  background: var(--bg);
}
@media (min-width:431px){ .screen{ min-height: 860px; border-radius:40px; } }
.screen.active{ display:flex; }

.scroll-body{
  flex:1;
  overflow-y:auto;
  padding: 18px 20px 110px;
}
.scroll-body::-webkit-scrollbar{ display:none; }

/* ---------- topbar ---------- */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 20px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.topbar h1{
  font-size: 15px;
  font-weight:700;
  letter-spacing: 0.06em;
}
.topbar-alert h1.alert-title{ color: var(--red); }
.icon-btn{
  width:38px; height:38px;
  display:flex; align-items:center; justify-content:center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
}
.icon-btn i{ width:18px; height:18px; }
.icon-btn:empty{ background:transparent; border:none; }

/* ---------- welcome ---------- */
#screen-welcome{ justify-content:flex-start; }
.welcome-wrap{
  padding: 56px 28px 40px;
  display:flex;
  flex-direction:column;
  align-items:center;
  text-align:center;
}
.brand-mark{
  width:72px; height:72px;
  border-radius: 20px;
  background: linear-gradient(160deg, var(--red), #7a120e);
  display:flex; align-items:center; justify-content:center;
  box-shadow: 0 10px 30px var(--red-glow);
  margin-bottom:18px;
}
.brand-mark i{ width:36px; height:36px; color:#fff; }
.brand-name{ font-family:'Manrope', sans-serif; font-size:30px; font-weight:800; letter-spacing:0.04em; }
.brand-tag{ color: var(--red); font-weight:600; margin-top:6px; font-size:14px; }
.brand-sub{ color: var(--text-dim); font-size:13px; margin-top:14px; }

.feature-list{
  list-style:none;
  width:100%;
  margin: 30px 0 34px;
  display:flex; flex-direction:column; gap:14px;
  text-align:left;
}
.feature-list li{
  display:flex; align-items:center; gap:12px;
  font-size:14px; font-weight:500; color: var(--text);
}
.feature-list i{ width:18px; height:18px; color: var(--red); flex-shrink:0; }

.btn-primary{
  background: linear-gradient(180deg, var(--red), #b8241d);
  color:#fff;
  border:none;
  border-radius: 16px;
  padding: 16px 24px;
  font-weight:700;
  font-size:15px;
  line-height:1.4;
  box-shadow: 0 12px 24px var(--red-glow);
}
.btn-primary span{ font-weight:600; font-size:13px; opacity:0.9; }
.btn-block{ width:100%; }

/* ---------- home ---------- */
.status-pill{
  width:100%;
  display:flex; align-items:center; gap:12px;
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color:var(--text);
  margin-bottom:26px;
  text-align:left;
}
.status-pill i:first-child{ color: var(--green); width:20px; height:20px; }
.status-pill span{ display:flex; flex-direction:column; flex:1; }
.status-pill strong{ font-size:14px; }
.status-pill em{ font-style:normal; font-size:12px; color: var(--green); }
.chev{ width:16px; height:16px; color: var(--text-faint); }

.sos-wrap{ display:flex; flex-direction:column; align-items:center; margin: 10px 0 32px; }
.sos-btn{
  position:relative;
  width:210px; height:210px; border-radius:50%;
  background: radial-gradient(circle at 50% 38%, #F04A42, var(--red) 45%, #A81E18);
  border:none; color:#fff;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px;
  box-shadow: 0 0 0 10px rgba(228,54,47,0.08), 0 0 60px var(--red-glow);
  touch-action:none; -webkit-tap-highlight-color:transparent;
  transition: transform .12s ease, box-shadow .2s ease;
}
.sos-btn:active, .sos-btn.holding{
  transform: scale(0.97);
  box-shadow: 0 0 0 18px rgba(228,54,47,0.14), 0 0 90px var(--red-glow);
}
.sos-btn:focus-visible{ outline:3px solid #fff; outline-offset:6px; }

/* The ring is the hold indicator: it closes as the alarm arms. */
.sos-ring{ position:absolute; inset:-14px; width:calc(100% + 28px); height:calc(100% + 28px); transform: rotate(-90deg); }
.sos-ring circle{ fill:none; stroke-width:3; }
.sos-ring-track{ stroke: rgba(255,255,255,0.14); }
.sos-ring-fill{
  stroke:#fff; stroke-linecap:round;
  stroke-dasharray:352; stroke-dashoffset:352;
}
.sos-label{ font-family:'Manrope',sans-serif; font-size:46px; font-weight:800; letter-spacing:0.02em; }
.sos-sub{ font-size:11px; font-weight:700; letter-spacing:0.14em; opacity:0.92; }

.sos-hint{ color: var(--text-dim); font-size:12px; margin-top:16px; }

.quick-grid{
  display:grid; grid-template-columns: repeat(4,1fr); gap:8px; margin-bottom:26px;
}
/* Status readout: a label, a value, and one LED that says whether it is fine. */
.readout{
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 6px 11px;
  min-height:74px;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:5px;
  position:relative;
}
.readout-led{ width:6px; height:6px; border-radius:50%; background: var(--text-faint); }
.readout-label{ font-size:10px; font-weight:600; color: var(--text-faint); letter-spacing:0.04em; }
.readout-value{
  font-family:'JetBrains Mono', ui-monospace, monospace;
  font-size:13px; font-weight:700; font-variant-numeric: tabular-nums;
  white-space:nowrap;
}
.readout.is-ok .readout-led{ background: var(--green); box-shadow:0 0 8px rgba(34,197,94,0.6); }
.readout.is-ok .readout-value{ color: var(--text); }
.readout.is-warn{ border-color: rgba(245,165,36,0.35); }
.readout.is-warn .readout-led{ background: var(--amber); box-shadow:0 0 8px rgba(245,165,36,0.6); }
.readout.is-warn .readout-value{ color: var(--amber); }
.readout.is-idle .readout-value{ color: var(--text-faint); }

.section-row{ display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.section-row h3{ font-size:14px; font-weight:700; }
.link-btn{ background:none; border:none; color: var(--red); font-size:13px; font-weight:600; }

.actions-grid{ display:grid; grid-template-columns: repeat(4,1fr); gap:10px; margin-bottom:10px; }
.action-tile{
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 6px 12px;
  display:flex; flex-direction:column; align-items:center; gap:8px;
  color: var(--text);
}
.action-tile i{ width:20px; height:20px; color: var(--red); }
.action-tile span{ font-size:10.5px; font-weight:600; }

/* ---------- tabbar ---------- */
.tabbar{
  position:absolute; left:0; right:0; bottom:0;
  height:76px;
  background: rgba(10,10,11,0.92);
  backdrop-filter: blur(14px);
  border-top:1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:space-around;
  padding-bottom: 10px;
}
.tab-item{
  display:flex; flex-direction:column; align-items:center; gap:4px;
  background:none; border:none; color: var(--text-faint);
  font-size:10px; font-weight:600;
}
.tab-item i{ width:20px; height:20px; }
.tab-item.active{ color: var(--red); }

/* ---------- SOS activated ---------- */
.center-body{ align-items:center; text-align:center; }
.help-title{ font-size:20px; font-weight:800; margin-top:6px; }
.help-sub{ color: var(--text-dim); font-size:13px; margin-top:8px; line-height:1.5; }
.help-sub.small{ font-size:12px; margin-top:22px; margin-bottom:14px; }
.help-sub.pad-top{ margin-top: 20px; }

.timer-ring{
  width:150px; height:150px;
  border-radius:50%;
  border: 3px solid var(--red);
  box-shadow: 0 0 40px var(--red-glow);
  display:flex; align-items:center; justify-content:center;
  margin: 28px auto 0;
  font-size:30px; font-weight:800;
}

.stack-list{ width:100%; display:flex; flex-direction:column; gap:12px; margin: 4px 0 26px; }
.row-card{
  width:100%;
  display:flex; align-items:center; gap:12px;
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 14px;
  color: var(--text);
  text-align:left;
}
.row-card i:first-child{ width:18px; height:18px; color: var(--red); flex-shrink:0; }
.row-card span{ display:flex; flex-direction:column; flex:1; }
.row-card strong{ font-size:13.5px; }
.row-card em{ font-style:normal; font-size:11.5px; color: var(--text-faint); margin-top:2px; }

.btn-danger{
  background: var(--red);
  color:#fff;
  border:none;
  border-radius: 14px;
  padding:15px;
  font-weight:700;
  font-size:13.5px;
  letter-spacing:0.03em;
}

.avatar-row{ display:flex; margin: 4px 0 28px; }
.avatar{
  width:38px; height:38px; border-radius:50%;
  background: var(--surface-2);
  border: 2px solid var(--bg);
  display:flex; align-items:center; justify-content:center;
  font-size:13px; font-weight:700; color: var(--text-dim);
  margin-left:-10px;
}
.avatar:first-child{ margin-left:0; }
.avatar.more{ background: var(--red-dim); color: var(--red); }
.avatar.big{ width:56px; height:56px; font-size:20px; margin-left:0; }
.avatar.police{ background: var(--red-dim); color: var(--red); }
.avatar.police i{ width:16px; height:16px; }
.muted{ color: var(--text-faint); font-size:12px; }

/* ---------- responders ---------- */
.list-caption{ font-size:12.5px; color: var(--text-dim); margin-bottom:14px; }
.responder-list{ display:flex; flex-direction:column; gap:12px; margin-bottom:22px; }
.responder-row{
  display:flex; align-items:center; gap:12px;
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius-sm);
  padding:12px 14px;
}
.responder-row .avatar{ margin-left:0; }
.responder-row .info{ flex:1; display:flex; flex-direction:column; }
.responder-row .info strong{ font-size:13.5px; }
.responder-row .info em{ font-style:normal; font-size:11px; color: var(--text-faint); display:flex; align-items:center; gap:4px; margin-top:2px; }
.responder-row .info em i{ width:11px; height:11px; color: var(--green); }
.responder-row .meta{ text-align:right; }
.responder-row .meta strong{ display:block; font-size:12.5px; }
.responder-row .meta span{ font-size:11px; color: var(--text-faint); }

/* ---------- pill tabs ---------- */
.pill-tabs{ display:flex; gap:8px; margin-bottom:20px; overflow-x:auto; }
.pill{
  background: var(--surface);
  border:1px solid var(--border);
  color: var(--text-dim);
  padding: 9px 16px;
  border-radius: 20px;
  font-size:12.5px; font-weight:600;
  white-space:nowrap;
}
.pill.active{ background: var(--red); color:#fff; border-color: var(--red); }

/* ---------- toggle list ---------- */
.toggle-list{ display:flex; flex-direction:column; gap:12px; }
.toggle-row{
  display:flex; align-items:center; gap:12px;
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.toggle-row i{ width:18px; height:18px; color: var(--red); flex-shrink:0; }
.toggle-row span{ display:flex; flex-direction:column; flex:1; }
.toggle-row strong{ font-size:13px; }
.toggle-row em{ font-style:normal; font-size:11px; color: var(--text-faint); margin-top:2px; }

.switch{ position:relative; width:42px; height:24px; flex-shrink:0; }
.switch input{ opacity:0; width:0; height:0; }
.switch i{
  position:absolute; inset:0; background: var(--surface-2); border:1px solid var(--border);
  border-radius:20px; transition:.2s;
}
.switch i::before{
  content:""; position:absolute; width:18px; height:18px; left:2px; top:2px;
  background:#fff; border-radius:50%; transition:.2s;
}
.switch input:checked + i{ background: var(--red); border-color: var(--red); }
.switch input:checked + i::before{ transform: translateX(18px); }

/* ---------- records ---------- */
.group-label{ font-size:12px; font-weight:700; color: var(--text-faint); text-transform:uppercase; letter-spacing:0.05em; margin: 18px 0 12px; }
.group-label:first-of-type{ margin-top:0; }
.record-item{
  display:flex; align-items:center; gap:12px;
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom:10px;
}
.thumb{
  width:42px; height:42px; border-radius:10px;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
}
.thumb i{ width:18px; height:18px; color:#fff; }
.video-thumb{ background: linear-gradient(160deg,#3a3a3f,#1c1c1f); }
.audio-thumb{ background: linear-gradient(160deg, var(--red), #7a120e); }
.log-thumb{ background: linear-gradient(160deg,#2c2c30,#141416); }
.record-item span{ flex:1; display:flex; flex-direction:column; }
.record-item strong{ font-size:13px; }
.record-item em{ font-style:normal; font-size:11px; color: var(--text-faint); margin-top:2px; }
.record-item > i{ width:15px; height:15px; color: var(--text-faint); }

/* ---------- tools grid ---------- */
.tools-grid{ display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:24px; }
.tool-card{
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius);
  padding:16px;
  display:flex; flex-direction:column; align-items:flex-start; gap:8px;
  color: var(--text);
  text-align:left;
}
.tool-card i{ width:20px; height:20px; color: var(--red); }
.tool-card strong{ font-size:13px; }
.tool-card em{ font-style:normal; font-size:11px; color: var(--text-faint); line-height:1.3; }

/* ---------- profile ---------- */
.profile-card{
  display:flex; align-items:center; gap:14px;
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius);
  padding:16px;
  margin-bottom:22px;
}
.profile-card div{ flex:1; display:flex; flex-direction:column; gap:2px; }
.profile-card strong{ font-size:15px; }
.profile-card em{ font-style:normal; font-size:11.5px; color: var(--text-faint); }

.plain-list{ display:flex; flex-direction:column; }
.plain-row{
  display:flex; align-items:center; gap:12px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--border);
  /* rows are <button> so they are tappable and keyboard-reachable */
  width:100%; text-align:left; background:none; border-left:0; border-right:0;
  border-top:0; color:inherit; font:inherit; cursor:pointer;
}
@media (hover: hover){ .plain-row:hover{ background: var(--surface); } }
.plain-row:is(a){ text-decoration:none; }
.plain-row i:first-child{ width:18px; height:18px; color: var(--text-dim); }
.plain-row span{ flex:1; font-size:13.5px; font-weight:500; }
.plain-row em{ font-style:normal; font-size:12px; color: var(--text-faint); text-align:right; }
.plain-row em.perm-ok{ color: var(--green); }
.plain-row em.perm-warn{ color: var(--amber); }
.plain-row em.perm-bad{ color: var(--red); }
.contact-row em.reach-ok{ color: var(--green); font-size:11px; }
.contact-row em.reach-warn{ color: var(--amber); font-size:11px; }

/* ---------- contacts ---------- */
.contact-row{
  display:flex; align-items:center; gap:12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border);
}
.contact-row span:nth-child(2){ flex:1; display:flex; flex-direction:column; }
.contact-row strong{ font-size:13.5px; }
.contact-row em{ font-style:normal; font-size:11.5px; color: var(--text-faint); margin-top:2px; }
.call-ic{ width:18px; height:18px; color: var(--green); }

/* ---------- safe zones ---------- */
.zone-row{
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 2px;
  border-bottom: 1px solid var(--border);
}
.zone-row span{ display:flex; flex-direction:column; gap:2px; }
.zone-row strong{ font-size:13.5px; }
.zone-row em{ font-style:normal; font-size:11.5px; color: var(--text-faint); }

/* ---------- scrollbar hide ---------- */
::-webkit-scrollbar{ width:0; height:0; }

/* ---------- auth ---------- */
.auth-form{ display:flex; flex-direction:column; gap:12px; width:100%; margin: 24px 0 16px; }
.field{
  width:100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 15px 16px;
}
.field::placeholder{ color: var(--text-faint); }
.field:focus{ outline:none; border-color: var(--red); }
.form-error{ color: var(--red); font-size:13px; text-align:center; }
.btn-primary[disabled]{ opacity:0.6; }
.contact-row .del-ic{ color: var(--text-faint); width:18px; height:18px; margin-left:10px; }
.empty-note{ color: var(--text-faint); font-size:13px; text-align:center; padding: 24px 0; }

/* ---------- live data states ---------- */
.quick-chip div{ display:flex; flex-direction:column; align-items:center; gap:2px; }
.quick-chip .warn{ color: var(--text-faint); font-size:10px; }
.status-pill.alarmed{ border-color: var(--red); background: var(--red-dim); }
.status-pill.alarmed i:first-child{ color: var(--red); }
.avatar.primary{ background: var(--red); color:#fff; }
.live-dot.idle{ background: var(--surface-2); color: var(--text-dim); }
.contact-row .icon-btn.del, .zone-row .icon-btn.del{ background:none; border:none; color: var(--text-faint); padding:6px; }
.contact-row .icon-btn.del i, .zone-row .icon-btn.del i{ width:18px; height:18px; }
.contact-row a{ color: inherit; display:inline-flex; }
.record-item a{ color: var(--text-dim); display:inline-flex; }
.btn-danger[disabled]{ opacity:0.5; }

/* ---------- toast ---------- */
.toast-host{
  position:fixed; left:50%; bottom:92px; transform:translateX(-50%);
  z-index:200; display:flex; flex-direction:column; gap:8px;
  width:min(390px, calc(100vw - 32px)); pointer-events:none;
}
.toast{
  background: var(--surface-2);
  border:1px solid var(--border);
  border-radius: var(--radius-sm);
  padding:13px 16px; font-size:13.5px; font-weight:500; line-height:1.4;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  opacity:0; transform: translateY(12px);
  transition: opacity .22s ease, transform .22s ease;
}
.toast.in{ opacity:1; transform: translateY(0); }
.toast-ok{ border-color: var(--green); color: var(--green); }
.toast-error{ border-color: var(--red); color:#ff8a85; }

/* ---------- bottom sheet ---------- */
.sheet-backdrop{
  position:fixed; inset:0; z-index:210;
  background: rgba(0,0,0,0.6);
  display:flex; align-items:flex-end; justify-content:center;
  opacity:0; transition: opacity .22s ease;
}
.sheet-backdrop.in{ opacity:1; }
.sheet{
  width:min(430px,100%);
  background: var(--surface);
  border:1px solid var(--border); border-bottom:none;
  border-radius: 24px 24px 0 0;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom));
  display:flex; flex-direction:column; gap:14px;
  transform: translateY(100%); transition: transform .26s cubic-bezier(.22,1,.36,1);
  max-height: 88vh; overflow-y:auto;
}
.sheet-backdrop.in .sheet{ transform: translateY(0); }
.sheet-grab{ width:38px; height:4px; border-radius:2px; background: var(--border); align-self:center; margin-bottom:4px; }
.sheet h3{ font-size:18px; font-weight:800; font-family:'Manrope',sans-serif; }
.sheet-desc{ font-size:13px; color: var(--text-dim); line-height:1.5; margin-top:-6px; }
.sheet-field{ display:flex; flex-direction:column; gap:7px; }
.sheet-field > span{ font-size:12.5px; font-weight:600; color: var(--text-dim); }
.sheet-field em{ color: var(--text-faint); font-style:normal; font-weight:500; }
.sheet-toggle{
  display:flex; align-items:center; justify-content:space-between;
  background: var(--surface-2); border:1px solid var(--border);
  border-radius: var(--radius-sm); padding: 13px 16px; font-size:14px; font-weight:500;
}
.sheet-actions{ display:flex; gap:10px; margin-top:4px; }
.sheet-actions button{ flex:1; }
.btn-ghost{
  background: var(--surface-2); color: var(--text);
  border:1px solid var(--border); border-radius:16px;
  padding:16px 24px; font-weight:600; font-size:15px;
}

/* ---------- tool overlays ---------- */
.overlay{
  position:fixed; inset:0; z-index:220; background: var(--bg);
  display:flex; align-items:center; justify-content:center;
  opacity:0; transition: opacity .2s ease;
}
.overlay.in{ opacity:1; }
.overlay-torch{ background:#fff; }
.torch-hint{ color:#333; font-size:13px; }

.call-screen{ display:flex; flex-direction:column; align-items:center; gap:10px; padding:56px 24px calc(48px + env(safe-area-inset-bottom)); width:100%; height:100%; }
.call-status{ color: var(--text-dim); font-size:13px; letter-spacing:0.08em; text-transform:uppercase; }
.call-avatar{ width:96px; height:96px; font-size:34px; margin:22px 0 6px; }
.call-name{ font-size:28px; font-weight:800; font-family:'Manrope',sans-serif; }
.call-sub{ color: var(--text-dim); font-size:14px; }
.call-actions{ display:flex; gap:56px; margin-top:auto; padding-top:60px; }
.call-btn{ width:66px; height:66px; border-radius:50%; border:none; display:grid; place-items:center; }
.call-btn i{ width:26px; height:26px; color:#fff; }
.call-btn.accept{ background: var(--green); }
.call-btn.decline{ background: var(--red); }

/* ---------- guardian SOS takeover ---------- */
/* Fired by alerts.js on a live SOS from someone who lists this account as a
   guardian. Deliberately styled to be jarring — full red, animated ring,
   nothing else reachable — since the whole point is that it can't be missed
   the way a quiet notification badge can be. */
.overlay-sos{ background: var(--red); }
.sos-takeover{
  display:flex; flex-direction:column; align-items:center; text-align:center;
  gap:10px; padding:64px 28px calc(48px + env(safe-area-inset-bottom)); width:100%; height:100%;
  color:#fff;
}
.sos-takeover-badge{
  width:88px; height:88px; border-radius:50%; display:grid; place-items:center;
  background: rgba(255,255,255,0.16); margin-bottom:8px;
  animation: sosPulse 1.2s ease-in-out infinite;
}
.sos-takeover-badge i{ width:40px; height:40px; color:#fff; }
@keyframes sosPulse{
  0%, 100%{ box-shadow: 0 0 0 0 rgba(255,255,255,0.35); }
  50%{ box-shadow: 0 0 0 18px rgba(255,255,255,0); }
}
.sos-takeover-eyebrow{ font-size:13px; font-weight:700; letter-spacing:0.14em; opacity:0.85; }
.sos-takeover-name{ font-size:30px; font-weight:800; font-family:'Manrope',sans-serif; }
.sos-takeover-sub{ font-size:15px; opacity:0.9; max-width:300px; }
.sos-takeover-actions{ display:flex; flex-direction:column; gap:10px; width:100%; margin-top:auto; }
.sos-takeover-actions .btn-primary{ background:#fff; color: var(--red); }
.sos-takeover-actions .btn-ghost{ background: rgba(255,255,255,0.12); color:#fff; border-color: rgba(255,255,255,0.3); }

.rec-screen{ display:flex; flex-direction:column; align-items:center; gap:14px; padding:32px 24px; width:min(390px,100%); }
.rec-screen h2{ font-size:44px; font-weight:800; font-family:'Manrope',sans-serif; font-variant-numeric: tabular-nums; }
.rec-screen .btn-danger{ margin-top:28px; }
.rec-dot{ width:14px; height:14px; border-radius:50%; background: var(--red); animation: pulse-dot 1.2s infinite; }
@keyframes pulse-dot{ 0%,100%{ opacity:1; } 50%{ opacity:0.25; } }
.panic-ic{ width:44px; height:44px; color: var(--red); }

.cam-screen{ position:absolute; inset:0; display:flex; flex-direction:column; }
.cam-screen video{ flex:1; width:100%; object-fit:cover; background:#000; }
.cam-actions{ display:flex; align-items:center; justify-content:space-between; padding:20px 24px calc(28px + env(safe-area-inset-bottom)); }
.shutter{ width:68px; height:68px; border-radius:50%; background:#fff; border:5px solid var(--border); }

.discreet-screen{ text-align:center; }
.discreet-screen h1{ font-size:64px; font-weight:300; font-variant-numeric: tabular-nums; }
.discreet-screen p{ color: var(--text-faint); font-size:15px; margin-top:8px; }
.record-item .sealed{ width:16px; height:16px; color: var(--text-faint); flex-shrink:0; }

/* ---------- real maps ---------- */
.map-live{
  position:relative;
  height:280px;
  border-radius: var(--radius);
  overflow:hidden;
  border:1px solid var(--border);
  background: var(--surface);
  margin-bottom:22px;
}
.map-live.small{ height:180px; }
.map-canvas{ position:absolute; inset:0; display:none; background: var(--surface); }
/* OSM ships light tiles; invert them so the map belongs to a dark app. The
   filter is on the tile pane alone — over the whole map it would also invert
   the track, the zone circles and the markers, which are drawn in our colours
   on purpose. */
.map-canvas .leaflet-tile-pane{
  filter: invert(0.93) hue-rotate(180deg) brightness(1.04) contrast(0.88) saturate(0.65);
}
/* Attribution the tiles require, in our own type. Leaflet stacks its own
   panes and controls up to z-index 800, so anything meant to sit on top of
   the map has to say so. */
.map-live.has-map::after{
  content: "© OpenStreetMap";
  position:absolute; right:8px; top:8px; z-index:900;
  font-size:9.5px; letter-spacing:0.02em;
  color: var(--text-dim);
  background: rgba(10,10,11,0.72);
  padding:3px 7px; border-radius:6px;
  pointer-events:none;
}
.map-live.has-map .map-canvas{ display:block; }
.map-live.has-map .map-empty{ display:none; }
.map-empty{
  position:absolute; inset:0; display:grid; place-items:center;
  color: var(--text-faint); font-size:13px;
}
.map-card{
  position:absolute; left:12px; right:12px; bottom:12px; z-index:900;
  background: rgba(21,21,23,0.92);
  backdrop-filter: blur(12px);
  border:1px solid var(--border); border-radius: var(--radius-sm);
  padding:13px 15px; display:flex; flex-direction:column; gap:3px;
}
.map-card strong{ font-size:14px; font-weight:700; }
.map-card em{ font-style:normal; font-size:12.5px; color: var(--text-dim); }
.map-coords{
  font-family:'JetBrains Mono', ui-monospace, monospace;
  font-size:11px; color: var(--text-faint); font-variant-numeric: tabular-nums;
  margin-top:2px;
}
.live-dot{
  align-self:flex-start;
  background: var(--red); color:#fff;
  font-size:10px; font-weight:700; letter-spacing:0.08em; text-transform:uppercase;
  padding:3px 8px; border-radius:6px; margin-bottom:4px;
}

/* Readouts under stress: tabular numerals everywhere a number matters. */
#timerText, .rec-screen h2, .record-item em{
  font-variant-numeric: tabular-nums;
}
#timerText, .rec-screen h2{ font-family:'JetBrains Mono', ui-monospace, monospace; }

/* ---------- scream detection ---------- */
.scream-panel{
  background: var(--surface); border:1px solid var(--border);
  border-radius: var(--radius); padding:16px; margin-top:12px;
}
.meter{
  height:8px; background: var(--surface-2); border-radius:99px;
  overflow:hidden; border:1px solid var(--border);
}
.meter > i{
  display:block; height:100%; width:0%; background: var(--green);
  border-radius:99px; transition: width .05s linear, background .1s ease;
}
.meter > i.hot{ background: var(--red); }
.meter-label{
  font-size:11px; color: var(--text-faint); margin-top:8px;
  font-variant-numeric: tabular-nums;
}
.slider-row{
  display:flex; align-items:center; gap:14px; margin-top:16px;
  font-size:13px; font-weight:600;
}
.slider-row input[type=range]{ flex:1; accent-color: var(--red); }
.hint{ font-size:11px; color: var(--text-faint); line-height:1.5; margin-top:10px; }
.notice{
  display:flex; gap:10px; align-items:flex-start;
  background: var(--surface); border:1px solid var(--border);
  border-radius: var(--radius-sm); padding:14px; margin-top:12px;
}
.notice i{ width:16px; height:16px; color: var(--green); flex-shrink:0; margin-top:1px; }
.notice p{ font-size:11px; color: var(--text-dim); line-height:1.5; }

.overlay-scream{ background: var(--bg); }
.scream-alert{
  display:flex; flex-direction:column; align-items:center; text-align:center;
  gap:14px; padding:32px 28px; width:100%; max-width:340px;
}
.scream-alert i{ width:42px; height:42px; color: var(--red); }
.scream-alert h2{ font-size:22px; font-family:'Manrope',sans-serif; }
.scream-alert p{ color: var(--text-dim); font-size:14px; }
.scream-alert p strong{ color: var(--text); font-variant-numeric: tabular-nums; }
.scream-alert .btn-primary,
.scream-alert .btn-ghost{ width:100%; }

/* ---------- side drawer (menu + alert activity) ---------- */
.overlay-drawer{
  background: rgba(0,0,0,0.6);
  align-items: stretch; justify-content: flex-start;
}
.drawer{
  width: min(86%, 340px); height:100%;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display:flex; flex-direction:column;
  transform: translateX(-100%); transition: transform .22s ease;
  padding-top: env(safe-area-inset-top);
}
.overlay-drawer.in .drawer{ transform: none; }

/* The activity panel comes in from the other side, so the two never read as
   the same surface even though they share the shell. */
.overlay-drawer:has(.drawer-right){ justify-content: flex-end; }
.drawer-right{ border-right:0; border-left:1px solid var(--border); transform: translateX(100%); }

.drawer-head{
  display:flex; align-items:center; gap:12px;
  padding:20px 18px; border-bottom:1px solid var(--border);
}
.drawer-head > div{ flex:1; min-width:0; }
.drawer-head strong{ display:block; font-size:15px; font-weight:700; }
.drawer-head em{
  display:block; font-style:normal; font-size:12px; color: var(--text-dim);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}

.drawer-nav{ flex:1; overflow-y:auto; padding: 6px 18px; }
.drawer-item{
  display:flex; align-items:center; gap:14px; width:100%;
  padding:13px 2px; background:none; border:0; border-bottom:1px solid var(--border);
  color:inherit; font:inherit; text-align:left; cursor:pointer;
}
@media (hover: hover){ .drawer-item:hover{ background: var(--surface-2); } }
.drawer-item i:first-child{ width:19px; height:19px; color: var(--red); flex-shrink:0; }
.drawer-item span{ flex:1; min-width:0; }
.drawer-item strong{ display:block; font-size:14px; font-weight:600; }
.drawer-item em{ display:block; font-style:normal; font-size:11.5px; color: var(--text-faint); margin-top:2px; }

/* Activity rows reuse .plain-row, whose em is right-aligned — the nested one
   inside the label is a subtitle, not a value. */
.drawer-nav .plain-row span em{ text-align:left; display:block; margin-top:2px; }
.drawer-nav .plain-row i:first-child{ color: var(--text-dim); }

.drawer-foot{ padding:18px; border-top:1px solid var(--border); padding-bottom: calc(18px + env(safe-area-inset-bottom)); }

/* ---------- leaflet ---------- */
/* Markers are CSS, not the default icon set — no image requests to 404. */
.map-dot{
  display:block; width:16px; height:16px; border-radius:50%;
  border:2px solid #fff; box-shadow:0 1px 5px rgba(0,0,0,0.6);
}
.map-dot-you{ background: var(--red); box-shadow:0 0 0 6px var(--red-dim), 0 1px 5px rgba(0,0,0,0.6); }
.map-dot-start{ background: var(--text-faint); width:12px; height:12px; }
.map-dot-responder{ background: var(--green); }

.map-canvas .leaflet-control-zoom a{
  background: rgba(21,21,23,0.92); color: var(--text);
  border-color: var(--border); width:30px; height:30px; line-height:29px;
}
.map-canvas .leaflet-control-zoom a:hover{ background: var(--surface-2); color: var(--text); }
.map-canvas .leaflet-bar{ border:1px solid var(--border); box-shadow:none; }
.map-canvas .leaflet-tooltip{
  background: rgba(21,21,23,0.94); color: var(--text);
  border:1px solid var(--border); border-radius:8px;
  font-family:'Inter',sans-serif; font-size:11.5px; font-weight:600;
  box-shadow:0 4px 14px rgba(0,0,0,0.5);
}
.map-canvas .leaflet-tooltip::before{ display:none; }   /* the arrow inherits a white border */

/* ---------- offline ---------- */
/* Above every overlay: the app opening from cache while the network is gone
   is exactly when someone would otherwise press SOS and believe it worked. */
.offline-bar{
  position:fixed; left:0; right:0; bottom:0; z-index:400;
  background: var(--amber); color:#1A1206;
  font-size:12.5px; font-weight:600; text-align:center;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.offline-bar a{ color:#1A1206; }
