/* Palette follows the logo: night navy, haven amber, community teal. */
:root {
  --navy: #0b1426;
  --navy-2: #16294d;
  --amber-brand: #f5b544;
  --teal: #4fd1c5;
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #121a2b;
  --muted: #5f6b80;
  --line: #e3e7ee;
  --ink: #0b1426;
  --danger: #c8321f;
  --success: #12805c;
  --soft: #eceff5;
  --ok-bg: #e3f6ee;
  --ok-text: #0e6b4b;
  --alert-bg: #fff0ee;
  --alert-line: #ffc9c2;
  --shadow: 0 1px 2px rgba(11, 20, 38, .06), 0 8px 24px rgba(11, 20, 38, .07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070d19;
    --card: #101a2e;
    --text: #e7ecf5;
    --muted: #98a4ba;
    --line: #22304a;
    --ink: #e7ecf5;
    --soft: #1a2640;
    --ok-bg: #0f2e24;
    --ok-text: #7fdcb5;
    --alert-bg: #35130f;
    --alert-line: #6e2a22;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { letter-spacing: -.01em; }

.top {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, var(--navy-2), var(--navy) 70%);
  color: #fff;
  padding: calc(18px + env(safe-area-inset-top)) 20px 20px;
}

/* faint signal rings behind the header, echoing the logo */
.top::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -60px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: 2px solid rgba(79, 209, 197, .18);
  box-shadow: 0 0 0 28px rgba(79, 209, 197, .06), 0 0 0 56px rgba(79, 209, 197, .03);
  pointer-events: none;
}

.top-inner { width: min(700px, 100%); margin: 0 auto; position: relative; z-index: 1; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: .14em;
}

.brand img { border-radius: 10px; box-shadow: 0 4px 14px rgba(0, 0, 0, .35); }

.top p { margin: 6px 0 0; color: rgba(255, 255, 255, .7); font-size: .88rem; }
.top p b { color: var(--amber-brand); font-weight: 600; }

.banner {
  background: #fef0c7;
  color: #7a2e0e;
  padding: 10px 16px;
  text-align: center;
  font-size: .9rem;
}

main {
  width: min(700px, 100% - 32px);
  margin: 18px auto 24px;
}

/* Fluid type: scales smoothly from small phones to tablets. */
h1 { font-size: clamp(1.2rem, 1.05rem + .8vw, 1.45rem); margin: 0 0 10px; overflow-wrap: break-word; }
h2 { font-size: clamp(1rem, .95rem + .3vw, 1.1rem); margin: 0 0 10px; }
p, li, dd, .status { overflow-wrap: break-word; }

.awake { margin: 8px 0 0; display: flex; align-items: center; gap: 6px; }
.awake::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: breathe 2s ease-in-out infinite; }

/* Tablets and desktops: wider canvas, two-column cards where they help. */
@media (min-width: 900px) {
  main { width: min(1040px, 100% - 48px); }
  #view-guardian, #view-city, #view-connect, #view-landing {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
    align-items: start;
  }
  #view-guardian[hidden], #view-city[hidden], #view-connect[hidden], #view-landing[hidden] { display: none; }
  .tabbar a { max-width: 180px; }
}

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  animation: rise .45s ease both;
}

main section > .card:nth-child(2) { animation-delay: .05s; }
main section > .card:nth-child(3) { animation-delay: .1s; }
main section > .card:nth-child(4) { animation-delay: .15s; }
main section > .card:nth-child(n+5) { animation-delay: .2s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.card.alert { border: 2px solid var(--danger); }

.profile { display: flex; gap: 16px; align-items: center; }
.profile h2 { margin: 0; font-size: 1.35rem; }

.avatar {
  width: 72px;
  height: 72px;
  flex: none;
  border-radius: 50%;
  background: #dce6f7;
  color: #1d3a6b;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 28px;
  font-weight: 700;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  background: var(--ok-bg);
  color: var(--ok-text);
  border-radius: 999px;
  font-size: .8rem;
  margin-top: 6px;
}

hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

.kv { display: flex; justify-content: space-between; gap: 12px; }
.kv span { color: var(--muted); }

button, .button {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 15px;
  margin-top: 10px;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}

button:not(:disabled):active, .button:active { transform: scale(.98); }
button:not(:disabled):hover, .button:hover { filter: brightness(1.06); }
button:disabled { opacity: .65; cursor: default; }

.primary { background: var(--navy); color: #fff; box-shadow: 0 4px 14px rgba(11, 20, 38, .25); }
.danger { background: linear-gradient(180deg, #e0442f, var(--danger)); color: #fff; box-shadow: 0 6px 18px rgba(200, 50, 31, .3); }
.secondary { background: var(--soft); color: var(--text); }
.success { background: linear-gradient(180deg, #17966c, var(--success)); color: #fff; box-shadow: 0 6px 18px rgba(18, 128, 92, .28); }
.accent { background: linear-gradient(135deg, var(--teal), #2bb3a6); color: var(--navy); box-shadow: 0 6px 18px rgba(43, 179, 166, .3); }

@media (prefers-color-scheme: dark) {
  .primary { background: #24395f; }
}

/* ---------- Bottom tab bar ---------- */

body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  background: rgba(11, 20, 38, .92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, .08);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar a {
  flex: 1;
  max-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 4px 10px;
  color: rgba(255, 255, 255, .55);
  text-decoration: none;
  font-size: .7rem;
  font-weight: 600;
}

.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--teal); }
.tabbar a.on svg { filter: drop-shadow(0 0 6px rgba(79, 209, 197, .6)); }

button.link {
  display: inline;
  width: auto;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  padding: 8px;
  margin: 0;
  font-weight: 400;
  font-size: .85rem;
}

.status {
  padding: 14px;
  border-radius: 12px;
  background: var(--soft);
  margin-top: 4px;
  font-weight: 600;
}

.status.active {
  background: var(--alert-bg);
  border: 1px solid var(--alert-line);
  color: var(--danger);
}

@media (prefers-color-scheme: dark) {
  .status.active { color: #ff9d94; }
}

.status.ok { background: var(--ok-bg); color: var(--ok-text); }

.step {
  margin-top: 14px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
}

.step p { margin: 4px 0 0; }

.plist, .log { list-style: none; margin: 10px 0 0; padding: 0; }

.plist li, .log li {
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.plist li:last-child, .log li:last-child { border-bottom: 0; }

.plist .row { display: flex; justify-content: space-between; gap: 12px; }

.log .time, .small { font-size: .85rem; color: var(--muted); }
.log .time { display: block; }
.log .closed { font-weight: 800; }

.checks div { padding: 6px 0; font-weight: 600; }
.checks .no { color: var(--danger); }

.foot { text-align: center; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
.foot a { color: var(--muted); }

/* =====================================================
   Motion graphics, map, Bluetooth, connect page
   ===================================================== */

:root {
  --blue: #2f6fec;
  --amber: #e8a317;
  --red: #d92d20;
  --map-bg: #0f1724;
  --map-line: rgba(140, 170, 220, .22);
}

a { color: var(--blue); }
code { font-size: .8rem; word-break: break-all; }

.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.center { text-align: center; }

.field { display: block; margin-top: 14px; }
.field span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.field textarea, .field input {
  width: 100%;
  font: inherit;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}

.note {
  background: var(--alert-bg);
  border-left: 4px solid var(--danger);
  padding: 10px 12px;
  border-radius: 8px;
  text-align: left;
}

.count {
  min-width: 32px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--soft);
  font-weight: 800;
  text-align: center;
}
.count.bump { animation: bump .5s ease; }

/* ---------- Landing hero: bracelet tap ---------- */

.hero {
  display: block;
  text-decoration: none;
  text-align: center;
  color: #fff;
  background:
    radial-gradient(circle at 50% 0%, rgba(79, 209, 197, .22), transparent 60%),
    linear-gradient(170deg, var(--navy-2), var(--navy));
  border-color: transparent;
  padding: 24px 20px 22px;
}
.hero h1 { font-size: 1.5rem; margin-top: 4px; }
.hero .small { color: rgba(255, 255, 255, .72); }
.hero .cta {
  display: inline-block;
  margin-top: 10px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--amber-brand);
  color: var(--navy);
  font-weight: 800;
  font-size: .9rem;
}
.tap-scene { width: 100%; max-width: 420px; height: auto; display: block; margin: 0 auto 6px; }
.band { fill: none; stroke: var(--amber-brand); stroke-width: 12; }
.band-inner { fill: none; stroke: #ffd98a; stroke-width: 2; opacity: .45; }
.chip { fill: var(--navy); stroke: var(--amber-brand); stroke-width: 2; }
.chip-text { fill: #fff; font-size: 9px; font-weight: 800; text-anchor: middle; letter-spacing: .08em; }
.wave { fill: none; stroke: var(--teal); stroke-width: 4; stroke-linecap: round; opacity: 0; }
.phone-body { fill: #060b16; stroke: rgba(79, 209, 197, .5); stroke-width: 1.5; }
.phone-screen { fill: #15233f; }

/* feature list on the landing page */
.features { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.features li { display: flex; gap: 12px; align-items: flex-start; }
.features .ic {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--soft);
}
.features .ic svg { width: 20px; height: 20px; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.features strong { display: block; font-size: .95rem; }
.features span { font-size: .85rem; color: var(--muted); }
.s-avatar { fill: #dce6f7; }
.s-initial { fill: #1d3a6b; font-size: 14px; font-weight: 800; text-anchor: middle; }
.s-line { fill: #e5e7eb; }
.s-line.dim { opacity: .5; }
.s-btn { fill: #b42318; }
.screen-on { opacity: 0; }

.bracelet { animation: tap 4s ease-in-out infinite; }
.w1 { animation: wave 4s ease-out .9s infinite; }
.w2 { animation: wave 4s ease-out 1.1s infinite; }
.w3 { animation: wave 4s ease-out 1.3s infinite; }
.screen-on { animation: screen 4s ease infinite; }

@keyframes tap {
  0%, 100% { transform: translateX(0); }
  20%, 45% { transform: translateX(34px); }
  65% { transform: translateX(0); }
}
@keyframes wave {
  0% { opacity: 0; }
  10% { opacity: 1; }
  30%, 100% { opacity: 0; }
}
@keyframes screen {
  0%, 35% { opacity: 0; }
  45%, 90% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- Status: live pulse, timer, broadcast ripple ---------- */

.status { position: relative; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pulse-dot { display: none; width: 10px; height: 10px; border-radius: 50%; background: var(--red); flex: none; }
.status.active .pulse-dot { display: inline-block; animation: pulse 1.2s ease-out infinite; }
.timer {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: .04em;
}
.status.active.ripple::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  border: 2px solid var(--red);
  animation: ripple 1.2s ease-out 3;
  pointer-events: none;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(217, 45, 32, .6); }
  100% { box-shadow: 0 0 0 12px rgba(217, 45, 32, 0); }
}
@keyframes ripple {
  0% { transform: scale(1); opacity: .9; }
  100% { transform: scale(1.06, 1.5); opacity: 0; }
}
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); background: var(--blue); color: #fff; }
  100% { transform: scale(1); }
}

/* ---------- Close summary with drawn check ---------- */

.summary { display: flex; gap: 14px; align-items: center; margin-top: 12px; }
.check { width: 52px; height: 52px; flex: none; }
.check.big { width: 84px; height: 84px; display: block; margin: 0 auto 10px; }
.check circle { fill: none; stroke: var(--success); stroke-width: 3; stroke-dasharray: 145; stroke-dashoffset: 145; animation: draw .6s ease forwards; }
.check path { fill: none; stroke: var(--success); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .4s .5s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- Search map ---------- */

.map {
  width: 100%;
  height: auto;
  display: block;
  margin-top: 8px;
  border-radius: 14px;
  background: var(--map-bg);
}
.map .ring { fill: none; stroke: var(--map-line); stroke-width: 1; }
.map .ring-label { fill: rgba(170, 190, 225, .6); font-size: 9px; }
.map .axis { stroke: var(--map-line); stroke-width: 1; }
.map .sweep { transform-box: view-box; transform-origin: 160px 160px; opacity: 0; }
.map.live .sweep { opacity: 1; animation: spin 4s linear infinite; }
.map .empty { fill: rgba(200, 215, 240, .75); font-size: 12px; text-anchor: middle; }
.map .pt { cursor: pointer; outline: none; }
.map .pt .hit { fill: transparent; }
.map .pt .dot { stroke: #0f1724; stroke-width: 2; }
.map .pt.guardian .dot { fill: #f5f7fb; }
.map .pt.phone .dot { fill: var(--blue); }
.map .pt.tile .dot { fill: var(--amber); }
.map .pt.sighting .dot { fill: var(--red); }
.map .pt .halo { fill: none; stroke-width: 2; transform-box: fill-box; transform-origin: center; }
.map .pt.tile .halo { stroke: var(--amber); animation: ping 1.8s ease-out infinite; }
.map .pt.sighting .halo { stroke: var(--red); animation: ping 1.4s ease-out infinite; }
.map .pt.sel .dot, .map .pt:focus-visible .dot { stroke: #fff; stroke-width: 3; }
.map .pt-label { fill: rgba(230, 236, 246, .9); font-size: 9px; pointer-events: none; }
.map .pop { transform-box: fill-box; transform-origin: center; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ping {
  0% { transform: scale(.6); opacity: 1; }
  100% { transform: scale(2.6); opacity: 0; }
}
@keyframes pop {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.lg.guardian { background: #f5f7fb; border: 2px solid #0f1724; }
.lg.phone { background: var(--blue); }
.lg.tile { background: var(--amber); }
.lg.sighting { background: var(--red); }

.map-detail {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--soft);
  min-height: 40px;
}

/* ---------- Participant radar ---------- */

.radar-mini { width: 120px; height: 120px; display: block; margin: 0 auto 8px; }
.r-ring { fill: none; stroke: var(--line); stroke-width: 2; }
.r-core { fill: var(--muted); }
.r-core.alert { fill: var(--red); }
.r-wave { fill: none; stroke: var(--red); stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: ping 2.4s ease-out infinite; }
.r-wave.d2 { animation-delay: .8s; }
.r-wave.d3 { animation-delay: 1.6s; }
.radar-mini.idle .r-ring { animation: breathe 3s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .4; } }

/* ---------- Event log entry animation ---------- */

.log li.enter { animation: enter .45s ease both; }
@keyframes enter {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Bluetooth / NFC result with signal meter ---------- */

.bt-result {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--soft);
  display: flex;
  gap: 14px;
  align-items: center;
}
.bt-result.good { background: var(--ok-bg); color: var(--ok-text); }
.bt-result.bad { background: var(--alert-bg); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 28px; flex: none; }
.bars i { width: 6px; border-radius: 2px; background: var(--line); }
.bars i:nth-child(1) { height: 25%; }
.bars i:nth-child(2) { height: 50%; }
.bars i:nth-child(3) { height: 75%; }
.bars i:nth-child(4) { height: 100%; }
.bars i.on { background: currentColor; }
.bars.scanning i { animation: scanbar 1s ease-in-out infinite; background: var(--blue); }
.bars.scanning i:nth-child(2) { animation-delay: .15s; }
.bars.scanning i:nth-child(3) { animation-delay: .3s; }
.bars.scanning i:nth-child(4) { animation-delay: .45s; }
@keyframes scanbar { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

/* ---------- Connect page diagram ---------- */

.diagram { width: 100%; height: auto; display: block; margin-top: 8px; }
.diagram .edge { fill: none; stroke: var(--muted); stroke-width: 2.5; opacity: .55; }
.diagram .edge.solid { stroke-dasharray: 6 6; animation: flow 1.2s linear infinite; }
.diagram .edge.ble { stroke: var(--amber); stroke-dasharray: 2 6; stroke-linecap: round; stroke-width: 3; animation: flow .8s linear infinite; }
.diagram .edge.dashed { stroke-dasharray: 3 7; }
.diagram .edge.hot { opacity: 1; stroke: var(--blue); stroke-width: 3.5; }
.diagram .edge.ble.hot { stroke: var(--amber); }
.diagram .edge-labels text { fill: var(--muted); font-size: 9.5px; }
.diagram .node { cursor: pointer; outline: none; }
.diagram .node circle { fill: var(--card); stroke: var(--ink); stroke-width: 2.5; transition: transform .2s; transform-box: fill-box; transform-origin: center; }
.diagram .node.core circle { fill: #111827; stroke: var(--blue); }
.diagram .node.core text { fill: #fff; }
.diagram .node.tile circle { stroke: var(--amber); animation: tileglow 2s ease-in-out infinite; }
.diagram .node.ext circle { stroke-dasharray: 4 4; }
.diagram .node text { fill: var(--text); font-size: 11px; font-weight: 700; text-anchor: middle; pointer-events: none; }
.diagram .node text.sub { font-size: 8.5px; font-weight: 400; fill: var(--muted); }
.diagram .node.core text.sub { fill: #c7d2e5; }
.diagram .node:hover circle, .diagram .node:focus-visible circle { transform: scale(1.08); }
.diagram .node.sel circle { stroke: var(--blue); stroke-width: 4; transform: scale(1.1); }
@keyframes flow { to { stroke-dashoffset: -24; } }
@keyframes tileglow { 50% { stroke-width: 5; } }

.ways { display: grid; gap: 12px; margin-top: 12px; }
.way { border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.way p { margin: 6px 0 0; }
.tag-pill { display: inline-block; font-size: .72rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; margin-bottom: 6px; }
.tag-pill.ok { background: var(--ok-bg); color: var(--ok-text); }
.tag-pill.next { background: var(--soft); color: var(--muted); }
.steps { padding-left: 20px; margin: 6px 0 0; }
.steps li { margin: 4px 0; }

/* ---------- City view ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; margin: 14px 0 12px; }
.tile-stat { background: var(--soft); border-radius: 12px; padding: 12px; }
.tile-stat b { display: block; font-size: 1.7rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-stat span { font-size: .8rem; color: var(--muted); }
.tile-stat.amber b { color: var(--amber); }
.tile-stat.red b { color: var(--red); }
.tile-stat b.bump { animation: bumptext .6s ease; }
@keyframes bumptext { 40% { transform: scale(1.25); } }

.map.city .cell { stroke: rgba(140, 170, 220, .18); stroke-width: 1; fill: rgba(140, 170, 220, .05); }
.map.city .blk { cursor: pointer; outline: none; }
.map.city .blk rect { stroke: #0f1724; stroke-width: 2; rx: 6; }
.map.city .blk.searchers rect { fill: var(--blue); }
.map.city .blk.tile rect { fill: var(--amber); }
.map.city .blk.sighting rect { fill: var(--red); }
.map.city .blk.sel rect, .map.city .blk:focus-visible rect { stroke: #fff; stroke-width: 3; }
.map.city .blk text { fill: #fff; font-size: 12px; font-weight: 800; text-anchor: middle; pointer-events: none; }
.map.city .blk .inner { transform-box: fill-box; transform-origin: center; }
.map.city .blk.changed .inner { animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
.map.city .blk.sighting .inner { animation: glow 1.6s ease-in-out infinite; }
.map.city .grid-label { fill: rgba(170, 190, 225, .6); font-size: 9px; text-anchor: middle; }
@keyframes glow { 50% { opacity: .65; } }

table.blocks { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.blocks th, table.blocks td { text-align: left; padding: 9px 4px; border-bottom: 1px solid var(--line); }
table.blocks th { font-size: .78rem; color: var(--muted); font-weight: 600; }
table.blocks td:not(:first-child), table.blocks th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- OpenStreetMap basemap (night-styled to match the radar) ---------- */

.map .basemap { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.85) saturate(.45); }
.map .shade { fill: rgba(11, 20, 38, .38); pointer-events: none; }
.attrib { margin: 6px 0 0; font-size: .72rem; color: var(--muted); text-align: right; }
.attrib a { color: inherit; }

/* ---------- Weather card ---------- */

.wx-head { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
.wx-icon svg { width: 64px; height: 64px; display: block; }
.wx-main { flex: 1; min-width: 0; }
.wx-temp { font-size: 2.2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.wx-cond { font-weight: 600; margin-top: 4px; }
.wx-meta { text-align: right; line-height: 1.6; }
.wx-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.chip.amber { background: #fff3d6; color: #8a5a00; }
.chip.navy { background: var(--soft); color: var(--text); }
.chip.blue { background: #e4edff; color: #1f4fbf; }
.chip.red { background: var(--alert-bg); color: var(--danger); }
.chip.green { background: var(--ok-bg); color: var(--ok-text); }
@media (prefers-color-scheme: dark) {
  .chip.amber { background: #3a2a06; color: #ffcf6b; }
  .chip.blue { background: #142650; color: #9dbbff; }
}
.wx-foot { margin-top: 10px; }
.wx-foot a { color: inherit; }

.wx-sunfill { fill: var(--amber-brand); }
.wx-rays { stroke: var(--amber-brand); stroke-width: 3.5; stroke-linecap: round; fill: none; }
.wx-sun { transform-box: view-box; transform-origin: 32px 32px; animation: spin 18s linear infinite; }
.wx-moon { fill: #c9d6f2; }
.wx-cloud { fill: #dfe6f3; stroke: #9fb0cc; stroke-width: 1.5; }
.wx-drift { animation: drift 4s ease-in-out infinite; }
.wx-drop { stroke: #4f8cff; stroke-width: 3; stroke-linecap: round; fill: none; stroke-dasharray: 8 14; animation: fall .9s linear infinite; }
.wx-flakes circle { fill: #b9d0ff; animation: flake 2.4s ease-in-out infinite; }
.wx-flakes circle:nth-child(2) { animation-delay: .6s; }
.wx-flakes circle:nth-child(3) { animation-delay: 1.2s; }
.wx-bolt { fill: var(--amber-brand); animation: flash 2.2s ease-in-out infinite; }
.wx-fog { stroke: #a9b6cc; stroke-width: 4; stroke-linecap: round; fill: none; animation: drift 3s ease-in-out infinite; }
@keyframes drift { 50% { transform: translateX(3px); } }
@keyframes fall { to { stroke-dashoffset: -22; } }
@keyframes flake { 0% { transform: translateY(-3px); opacity: .3; } 50% { opacity: 1; } 100% { transform: translateY(5px); opacity: .3; } }
@keyframes flash { 0%, 70%, 100% { opacity: 1; } 75%, 85% { opacity: .2; } }

/* ---------- Bracelet installer wizard ---------- */

.install { border: 2px solid var(--teal); }
.wizard { list-style: none; margin: 14px 0 0; padding: 0; counter-reset: none; }
.wstep { display: flex; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.wstep:first-child { border-top: 0; padding-top: 4px; }
.wnum {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: var(--soft);
  transition: background .3s, color .3s;
}
.wstep.done .wnum { background: var(--success); color: transparent; position: relative; }
.wstep.done .wnum::after { content: "✓"; position: absolute; color: #fff; animation: pop .4s cubic-bezier(.2, 1.6, .4, 1); }
.wbody { flex: 1; min-width: 0; }
.wbody > strong { display: block; margin: 4px 0 6px; }
.choices { display: grid; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--teal); background: rgba(79, 209, 197, .08); }
.choice input { margin-top: 3px; accent-color: #2bb3a6; }
.urlbox { display: flex; gap: 8px; align-items: center; margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--navy); color: #d6f7f3; }
.urlbox code { flex: 1; min-width: 0; font-size: .78rem; }
button.mini { width: auto; display: inline-block; margin: 0; padding: 6px 12px; font-size: .8rem; border-radius: 8px; background: var(--teal); color: var(--navy); }
.steps button.mini { margin-left: 6px; vertical-align: 1px; }
.check-line { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-weight: 600; }
.check-line input { width: 18px; height: 18px; accent-color: #12805c; }

.write-scene { width: 100%; max-width: 280px; display: block; margin: 4px auto 0; }
.write-scene .ph { fill: var(--navy); stroke: rgba(79, 209, 197, .5); stroke-width: 1.5; }
.write-scene .ph-coil { fill: none; stroke: rgba(79, 209, 197, .6); stroke-width: 2; stroke-dasharray: 3 3; }
.write-scene .wr-ring { fill: none; stroke: var(--teal); stroke-width: 2; opacity: 0; transform-box: fill-box; transform-origin: center; }
.write-scene .wr-band { animation: tap 3.2s ease-in-out infinite; }
.write-scene.writing .wr-band { animation: none; transform: translateX(84px); transition: transform .4s; }
.write-scene.writing .wr-ring { animation: ping 1.2s ease-out infinite; }
.write-scene.writing .wr-ring.r2 { animation-delay: .6s; }

/* ---------- 360° appearance viewer + missing-child alert ---------- */

.v-stage {
  position: relative;
  margin-top: 6px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 50% 38%, rgba(79, 209, 197, .22), transparent 62%),
    linear-gradient(180deg, var(--navy-2), var(--navy));
  touch-action: pan-y; /* horizontal drags rotate; vertical still scrolls the page */
  cursor: grab;
  user-select: none;
  overflow: hidden;
}
.v-stage:active { cursor: grabbing; }
.v-fig { display: block; width: 100%; max-width: 300px; height: auto; margin: 0 auto; }
.v-table { fill: rgba(79, 209, 197, .1); stroke: rgba(79, 209, 197, .45); stroke-width: 1.5; }
.v-tick { fill: rgba(79, 209, 197, .35); }
.v-tick.front { fill: var(--teal); }
.v-shadow { fill: rgba(0, 0, 0, .35); }
.v-shoe { stroke: #c9ced8; stroke-width: 1; }
.v-zip { stroke: rgba(0, 0, 0, .3); stroke-width: 2; }
.v-eye { fill: #1b1b1b; transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }
.v-cheek { fill: #e9897a; opacity: .35; }
.v-mouth { fill: none; stroke: #5a2a1a; stroke-width: 2; stroke-linecap: round; }
.v-tile rect { stroke: #d9dde5; stroke-width: 1; }
@keyframes blink { 0%, 95%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }

.v-badge, .v-illus {
  position: absolute;
  top: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .04em;
}
.v-badge { left: 10px; background: var(--teal); color: var(--navy); }
.v-illus { right: 10px; background: rgba(255, 255, 255, .12); color: rgba(255, 255, 255, .8); }

.v-controls { display: flex; gap: 6px; align-items: center; margin-top: 10px; }
button.mini.ghost { background: var(--soft); color: var(--text); }
.v-angle { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--muted); }
.v-hint { margin: 6px 0 0; }

.alert-banner {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 900;
  letter-spacing: .05em;
  text-align: center;
  font-size: .85rem;
}
.alert-banner.live { background: var(--danger); color: #fff; animation: alertpulse 1.6s ease-in-out infinite; }
.alert-banner.found { background: var(--ok-bg); color: var(--ok-text); }
@keyframes alertpulse { 50% { box-shadow: 0 0 0 6px rgba(200, 50, 31, .18); } }

.alert-who { margin-top: 12px; font-size: 1.15rem; }
.alert-who span { color: var(--muted); font-size: .95rem; }

.case-code {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--navy);
  color: #fff;
}
.case-code .small { color: rgba(255, 255, 255, .6); }
.case-code code { flex: 1; min-width: 0; font-size: .95rem; font-weight: 800; letter-spacing: .03em; white-space: nowrap; color: var(--amber-brand); }
@media (max-width: 380px) { .case-code .small { display: none; } }

.alert-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0 0; }
.alert-facts dt { color: var(--muted); font-size: .85rem; }
.alert-facts dd { margin: 0; font-weight: 600; }
.alert-facts .alert-elapsed { font-variant-numeric: tabular-nums; color: var(--danger); }
.alert-facts .last-seen { color: var(--danger); }

/* ---------- HAVEN wearable ---------- */

.wearable { border: 2px solid rgba(47, 111, 236, .35); }
.w-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 700;
  background: var(--soft);
}
.w-icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.w-status.off { color: var(--muted); }
.w-status.busy { color: var(--blue); }
.w-status.busy .w-icon { animation: scanbar 1s ease-in-out infinite; }
.w-status.on { background: var(--ok-bg); color: var(--ok-text); }
.w-status.on .w-icon { filter: drop-shadow(0 0 6px rgba(18, 128, 92, .5)); animation: breathe 2s ease-in-out infinite; }
.w-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.w-msgs { list-style: none; margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--navy); color: #d6f7f3; font-family: ui-monospace, Consolas, monospace; font-size: .8rem; }
.w-msgs li { display: flex; gap: 10px; padding: 3px 0; }
.w-msgs li.in { color: var(--teal); }
.w-msgs li.out { color: var(--amber-brand); }
.w-msgs li.sys { color: rgba(214, 247, 243, .7); }
.w-msgs .time { color: rgba(214, 247, 243, .5); }
.w-msgs li.enter { animation: enter .35s ease both; }

/* ---------- Touch: press-and-hold buttons ---------- */

button.hold {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
.hold-fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(255, 255, 255, .28);
  transform: scaleX(0);
  transform-origin: left center;
  transition-property: transform;
  transition-timing-function: linear;
  transition-duration: 0ms;
}
button.hold.holding .hold-fill { transform: scaleX(1); }
button.hold:not(.holding) .hold-fill { transition-duration: 180ms !important; }
button.hold.holding { transform: scale(.98); }
button.hold.held { animation: heldpop .5s ease; }
@keyframes heldpop { 30% { transform: scale(1.03); filter: brightness(1.2); } }

/* ---------- Touch: map gestures ---------- */

.map-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 30px; }
#gMap { touch-action: pan-y; }        /* page scroll still works at 1× */
#gMap.zoomed { touch-action: none; }  /* while zoomed, one finger pans the map */

/* ---------- HAVEN ID card with the AI-generated portrait ---------- */

.idcard {
  background:
    linear-gradient(135deg, rgba(79, 209, 197, .12), transparent 45%),
    linear-gradient(315deg, rgba(245, 181, 68, .12), transparent 45%),
    var(--card);
}
.idcard-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -4px 0 14px;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .14em;
  color: var(--muted);
}
.idcard-top img { border-radius: 6px; }
.idcard-flag { margin-left: auto; padding: 2px 8px; border-radius: 999px; background: var(--amber-brand); color: var(--navy); letter-spacing: .08em; }
.idcard .profile { align-items: flex-start; }
.photo-frame {
  position: relative;
  flex: none;
  width: 112px;
  height: 139px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--soft);
  box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--teal);
  display: grid;
  place-items: center;
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-frame .avatar { width: 72px; height: 72px; }
.ai-tag, .ai-note {
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.ai-tag {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  padding: 2px 0;
  border-radius: 6px;
  text-align: center;
  background: rgba(11, 20, 38, .72);
  color: #fff;
}
.ai-note { color: var(--muted); margin-top: 4px; }
.id-details { flex: 1; min-width: 0; }
.id-details h2 { margin: 0 0 6px; font-size: 1.3rem; }
.id-facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0 0 8px; font-size: .9rem; }
.id-facts dt { color: var(--muted); }
.id-facts dd { margin: 0; font-weight: 600; }
.id-facts dd { min-width: 0; overflow-wrap: anywhere; }
.id-facts dd strong { white-space: nowrap; font-size: .82rem; letter-spacing: .02em; }
@media (max-width: 380px) {
  .photo-frame { width: 92px; height: 115px; }
  .idcard .profile { gap: 12px; }
  .id-details h2 { font-size: 1.15rem; }
  .id-facts { font-size: .84rem; gap: 2px 8px; }
  .id-facts dd strong { font-size: .74rem; letter-spacing: 0; }
}
.id-note { margin: 14px 0 0; }

.alert-who { display: flex; gap: 12px; align-items: center; }
.alert-photo { width: 64px; height: 80px; object-fit: cover; border-radius: 10px; flex: none; box-shadow: 0 0 0 2px var(--danger); }

/* ---------- Phone layout: one card per screen ---------- */

.screens {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.screens::-webkit-scrollbar { display: none; }
.chip-tab {
  position: relative;
  flex: none;
  width: auto;
  margin: 0;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 700;
  background: var(--soft);
  color: var(--muted);
  white-space: nowrap;
}
.chip-tab.on { background: var(--navy); color: #fff; box-shadow: 0 2px 10px rgba(11, 20, 38, .25); }
@media (prefers-color-scheme: dark) { .chip-tab.on { background: var(--teal); color: var(--navy); } }
.chip-tab.dot::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--bg);
  animation: pop .4s cubic-bezier(.2, 1.6, .4, 1);
}

body.paged { overflow: hidden; height: 100dvh; padding-bottom: 0; overscroll-behavior: none; }
body.paged .top { padding-top: calc(10px + env(safe-area-inset-top)); padding-bottom: 10px; }
body.paged .top p { display: none; }
body.paged .brand { font-size: 1.15rem; }
body.paged .brand img { width: 30px; height: 30px; }
body.paged main { margin: 10px auto 0; }
body.paged .foot { display: none; }

.pager {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.pager::-webkit-scrollbar { display: none; }
.pager { align-items: flex-start; }
.pager > [data-screen] {
  flex: 0 0 100%;
  min-width: 0;
  max-height: 100%; /* short screens hug their content; long ones scroll inside */
  margin: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  -webkit-overflow-scrolling: touch;
}
.pager > [data-screen][hidden] { display: none; }
/* The joined-searcher screen is a wrapper around two cards. */
.pager > #pJoined { display: block; padding-bottom: 2px; }
.pager > #pJoined[hidden] { display: none; }
.pager > #pJoined > .card { animation: none; }

/* ---------- Reduced motion: keep the information, drop the motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition: none !important;
  }
  .screen-on, .wave { opacity: 1; }
  .map.live .sweep { opacity: 0; }
}
