/* Night-first, FIRE-hued — deep ember-dark surfaces so this app reads as the
   fire product in the Knotworks suite (Rampart owns navy). Zero pure-white
   floods. Ember orange is the action color; BLUE is reserved for water
   actions (FIND WATER, in-use); crimson stays reserved for genuinely critical
   states. Glove targets ≥48px, primary actions ≥56px (house UI rules). */

/* Themes: Michael picks live via the THEME button (persisted in localStorage).
   Semantic colors (critical red, stale amber, verified teal, NFPA classes,
   water blue) are the same in every theme — only the chrome changes. */
:root {
  /* MIDNIGHT (default): neutral charcoal, ember-orange accent */
  --bg: #0e0f12;
  --panel: #17181d;
  --panel-2: #101115;
  --line: #2b2e37;
  --text: #eceef2;
  --text-dim: #9aa1ad;
  --panel-glass: rgba(20, 21, 26, 0.93);
  --accent: #ff6a2b;   /* the app's action color */
  --accent-ink: #2a0f00; /* text on the accent surface (white in redline) */
  --blue: #2f7df6;     /* water actions */
  --amber: #ffb020;    /* stale/caution semantics (unchanged) */
  --teal: #2bd9c7;     /* verified/saved semantics (unchanged) */
  --red: #ff4d5e;      /* critical only */
  --cyan: #55c8ff;
  /* NFPA 291 bonnet colors */
  --class-aa: #6ec6ff;
  --class-a: #66bb6a;
  --class-b: #ffa726;
  --class-c: #ef5350;
  --class-unk: #7c89ab;
  --water: #3d7eff;
  /* Responder-bus source colors — suite-wide (Rampart's map legend), same in
     every theme: green = synthetic patrol, amber = live device. */
  --unit-syn: #3ddc97;
  --unit-live: #ffb23e;
}
[data-theme="engine"] {
  /* Charcoal with fire-engine red-orange accent */
  --bg: #111013; --panel: #1b191d; --panel-2: #131114; --line: #322e34;
  --text: #f1edee; --text-dim: #a49aa0; --panel-glass: rgba(24, 22, 25, 0.93);
  --accent: #ff5230;
}
[data-theme="redline"] {
  /* FIRE-TRUCK RED: red-tinted darks, apparatus-red accent, white ink */
  --bg: #150a09; --panel: #211010; --panel-2: #180b0a; --line: #4b211d;
  --text: #f6ecea; --text-dim: #c0a09b; --panel-glass: rgba(28, 14, 13, 0.93);
  --accent: #d81f1f; --accent-ink: #ffffff;
}
[data-theme="turnout"] {
  /* Near-black with turnout-gear yellow trim */
  --bg: #0b0b0d; --panel: #151517; --panel-2: #0e0e10; --line: #2c2c30;
  --text: #f0f0ec; --text-dim: #a0a09a; --panel-glass: rgba(18, 18, 20, 0.93);
  --accent: #ffd23f;
}
[data-theme="slate"] {
  /* Dark blue-gray with orange accent (closest to Rampart's family) */
  --bg: #10141a; --panel: #1a2029; --panel-2: #131820; --line: #2e3a4c;
  --text: #ebeff5; --text-dim: #97a4b5; --panel-glass: rgba(22, 28, 37, 0.93);
  --accent: #ff7a3d;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
/* The background runs edge to edge, under the status bar and home indicator (safe areas, below).
   overflow:hidden HERE as well as on body: when html leaves overflow visible, CSS hands body's
   overflow to the whole viewport and the body box clips nothing, so an over-tall phone page drew
   under the home indicator (iPhone 17 Pro and iPad Air simulators, 2026-10-07). With html clipping
   the viewport, body's own overflow:hidden clips at the body box, which is the safe area. */
html { background: var(--bg); overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Safe areas (Michael's rule for every Knotworks iPhone/iPad app, 2026-10-07): nothing we draw may
     sit under the status bar, the notch or Dynamic Island, the home indicator, or the side insets in
     landscape. The body BOX is inset by MARGINS, not padding: overflow:hidden clips at the padding
     edge, so with padding a page taller than the phone screen drew into the home-indicator area (seen
     on the iPhone 17 Pro simulator). With margins, the body box and everything it clips sit inside the
     safe area, including every element positioned inside #main; the html background fills the edges.
     Browsers report 0 insets, so nothing changes there. Needs viewport-fit=cover in the viewport meta.
     Pinned by tools/test-safe-areas.mjs. */
  margin: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  height: calc(100% - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

/* ---- prototype banner: always on, every surface ---- */
#proto-banner {
  background: #3a2a00;
  color: var(--amber);
  border-bottom: 1px solid #5d4400;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  padding: 6px 10px;
  flex: 0 0 auto;
}

/* ---- school-alert strip: every page, every tab, never blank ---- */
#alert-strip {
  flex: 0 0 auto;
  display: flex; flex-direction: column; gap: 0;
  padding: 4px 12px;
  border-bottom: 2px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
}
#alert-strip .as-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 6px 0; border-top: 1px solid rgba(255,255,255,0.14); }
#alert-strip .as-row:first-child, #alert-strip .as-stale + .as-row { border-top: 0; }
#alert-strip .as-row[data-state="acknowledged"] { border-left: 4px solid var(--teal); padding-left: 8px; }
#alert-strip .as-acked { color: var(--teal); font-weight: 700; }
#alert-strip .as-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 0; }
#alert-strip .as-stale { color: var(--red); font-weight: 700; padding: 4px 0; }
#alert-strip .as-narrative { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin-top: 4px; font-size: 15px; line-height: 1.35; white-space: pre-wrap; }
#alert-strip .as-narrative.expanded { display: block; -webkit-line-clamp: unset; overflow: visible; }
#alert-strip .as-narr-toggle { align-self: flex-start; min-height: 40px; padding: 0 10px; font-size: 12px; margin-top: 2px; }
#alert-strip .as-main { flex: 1 1 320px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#alert-strip .as-headline { font-weight: 800; letter-spacing: 0.06em; font-size: 16px; }
#alert-strip .as-detail { color: var(--text-dim); }
#alert-strip .as-more { font-weight: 700; color: var(--amber); }
#alert-strip .as-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
#alert-strip button { min-height: 56px; padding: 0 16px; font-weight: 800; letter-spacing: 0.04em; }
#alert-strip .as-ack { background: var(--blue); border-color: var(--blue); color: #fff; }
#alert-strip .as-arm { color: var(--amber); border-color: #6b4b00; background: #2a2000; }
#alert-strip[data-state="alert"] { background: #3d0c14; border-bottom-color: var(--red); color: #fff; }
#alert-strip[data-state="alert"] .as-row[data-state="unacknowledged"] .as-headline { color: var(--red); font-size: 20px; }
#alert-strip[data-state="alert"] .as-row[data-open="false"] .as-headline { color: var(--amber); font-size: 18px; }
#alert-strip[data-state="alert"] .as-detail { color: #ffd7dc; font-size: 15px; }
#alert-strip[data-state="alert-closed"] { background: #2a2000; border-bottom-color: var(--amber); }
#alert-strip[data-state="alert-closed"] .as-headline { color: var(--amber); font-size: 18px; }
#alert-strip[data-state="down"], #alert-strip[data-state="signedout"] { background: #2a0e14; border-bottom-color: var(--red); }
#alert-strip[data-state="down"] .as-headline, #alert-strip[data-state="signedout"] .as-headline { color: var(--red); }
#alert-strip[data-state="checking"] { background: #2a2000; border-bottom-color: var(--amber); }
#alert-strip[data-state="checking"] .as-headline { color: var(--amber); }
#alert-strip[data-state="ok"] { padding: 4px 12px; font-size: 13px; }
#alert-strip[data-state="ok"] .as-headline { font-size: 13px; color: var(--teal); }
#alert-strip[data-state="ok"] button { min-height: 44px; }
#alert-strip[data-state="ok"][data-armed="false"] { border-bottom-color: var(--amber); }
@media (max-width: 480px) {
  /* phone: every pending row still visible, each one tighter so the map keeps some screen */
  #alert-strip[data-state="alert"] .as-row[data-state="unacknowledged"] .as-headline { font-size: 17px; }
  #alert-strip .as-row { gap: 6px; padding: 4px 0; }
  #alert-strip .as-detail { font-size: 13px; }
  #alert-strip .as-narrative { -webkit-line-clamp: 2; font-size: 14px; }
  #alert-strip .as-main { flex-basis: 100%; }
  #alert-strip .as-actions { width: 100%; }
  #alert-strip .as-actions .as-ack { flex: 1 1 auto; }
  #alert-strip .as-foot .as-open { display: none; }
  #alert-strip .as-arm { font-size: 12px; min-height: 44px; }
}

/* ---- header ---- */
/* The page's own toolbar only (body > header): the Messages kit has <header> elements of its own. */
body > header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
#wordmark { font-weight: 800; font-size: 18px; letter-spacing: 0.04em; }
#wordmark small { font-weight: 500; color: var(--text-dim); font-size: 12px; margin-left: 8px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; font-weight: 700; letter-spacing: 0.05em;
  color: var(--text-dim); min-height: 32px;
}
.badge.online { color: var(--teal); border-color: #1c5f57; }
.badge.offline { color: var(--amber); border-color: #6b4b00; }
.badge.saving { color: var(--amber); border-color: #6b4b00; }
.badge.saved { color: var(--teal); border-color: #1c5f57; }
.badge.save-error { color: var(--red); border-color: #7a2530; }
body > header .spacer { flex: 1; }

/* ---- buttons: glove targets ---- */
/* Every button of the app's own; never one inside the Messages kit (.cui-root), which styles its
   own. :where() keeps the specificity of a bare `button`, so the cascade below is unchanged. */
button:where(:not(.cui-root *)) {
  font: inherit;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
}
button:where(:not(.cui-root *)):active { transform: translateY(1px); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); min-height: 56px; }
/* Dark text on the red surfaces: #fff on #ff4d5e is only ~3.2:1 (fails AA). */
button.primary.armed { background: var(--red); border-color: var(--red); color: #1c060a; }
button.danger { color: var(--red); border-color: #7a2530; }
button.small { min-height: 48px; font-size: 13px; }
.messages-link { display: inline-flex; align-items: center; min-height: 48px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); font: inherit; font-size: 13px; font-weight: 700;
  letter-spacing: 0.03em; text-decoration: none; }
.messages-link[hidden] { display: none; }
.messages-link:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
/* Water actions: blue with white text (Michael, 2026-07-26). #fff on #2f7df6 ≈ 4.6:1. */
button.water { background: var(--blue); border-color: var(--blue); color: #fff; min-height: 56px; }

#addr-search {
  min-height: 48px; width: 250px; max-width: 28vw;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 0 14px; font: inherit;
}
#addr-search::placeholder { color: var(--text-dim); }
#addr-search:focus { outline: 2px solid var(--blue); }

#btn-search-area {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 1000; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}
#btn-clear-pin {
  position: absolute; top: 12px; right: 412px; /* clear of the 400px sidebar */
  z-index: 1000; background: var(--panel);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}
@media (max-width: 900px) {
  #btn-clear-pin { right: 12px; }
}

/* ---- main layout ---- */
#main { flex: 1; display: flex; min-height: 0; position: relative; }
#map { flex: 1; background: #060912; }
#sidebar {
  flex: 0 0 400px;
  max-width: 46vw;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
  min-height: 0;
}
#tabs { display: flex; border-bottom: 1px solid var(--line); }
#tabs button {
  flex: 1; border: none; border-radius: 0; background: none;
  color: var(--text-dim); border-bottom: 3px solid transparent; min-height: 52px;
  padding: 0 6px; font-size: 12px; white-space: nowrap;
}
#tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
#panel { flex: 1; overflow-y: auto; padding: 12px; min-height: 0; }

/* ---- source cards ---- */
.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--panel-2);
  cursor: pointer;
  min-height: 56px;
}
.card:hover { border-color: #7a4526; }
.card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.card .row1 { display: flex; align-items: center; gap: 8px; }
.card .name { font-weight: 700; flex: 1; }
.card .dist { color: var(--text-dim); font-variant-numeric: tabular-nums; font-weight: 700; }
.card .meta { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.chip {
  display: inline-block; border-radius: 6px; padding: 2px 8px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.06em; margin-right: 6px; margin-top: 6px;
}
.chip.state-current { background: #0e3b35; color: var(--teal); }
.chip.state-stale { background: #4a3500; color: var(--amber); }
.chip.state-unverified { background: #4a1219; color: var(--red); }
.chip.state-status_unknown { background: #4a1219; color: var(--red); }
.chip.state-out_of_service { background: var(--red); color: #1c060a; }
.chip.seasonal { background: #0d3a52; color: var(--cyan); }
.chip.class-AA { background: #0d3752; color: var(--class-aa); }
.chip.class-A { background: #163f18; color: var(--class-a); }
.chip.class-B { background: #4a3000; color: var(--class-b); }
.chip.class-C { background: #4a1219; color: var(--class-c); }
.chip.class-unk { background: #232c44; color: var(--class-unk); }
.chip.private { background: #3d1030; color: #ff8ad2; }
.chip.iso { background: #16324a; color: #8fd0ff; }
.chip.inuse { background: #123c77; color: #7db4ff; }

.section-h {
  font-size: 12px; font-weight: 800; letter-spacing: 0.1em;
  color: var(--text-dim); margin: 16px 0 8px;
}
.section-h.loud-red { color: var(--red); }
.section-h.loud-amber { color: var(--amber); }

/* ---- detail panel ---- */
#detail .field { margin: 8px 0; font-size: 14px; }
#detail .field b { color: var(--text-dim); font-weight: 600; display: block; font-size: 12px; letter-spacing: 0.05em; }
#detail .provenance {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 10px 0;
  font-size: 13px;
}
#detail .provenance.none { border-color: #7a2530; color: var(--red); font-weight: 700; }
.detail-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.warnbox {
  border: 1px solid #7a2530; background: #2a0e14; color: var(--red);
  border-radius: 10px; padding: 10px; font-weight: 700; margin: 10px 0; font-size: 14px;
}
.warnbox.amber { border-color: #6b4b00; background: #2a2000; color: var(--amber); }
.warnbox.cyan { border-color: #1d5a7a; background: #0c2231; color: var(--cyan); }
.warnbox.blue { border-color: #1d4a8f; background: #0c1a31; color: #7db4ff; }

/* ---- verify form ---- */
#verify-form { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 10px; }
#verify-form label { display: block; font-size: 12px; color: var(--text-dim); margin: 10px 0 4px; letter-spacing: 0.05em; }
#verify-form select, #verify-form input:not([type="checkbox"]), #verify-form textarea, .water-status-fields input {
  width: 100%; min-height: 48px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; font: inherit;
}
/* The checkrow is a <label>: the ENTIRE ≥48px row toggles the box (glove rule). */
#verify-form .checkrow { display: flex; align-items: center; gap: 12px; margin-top: 12px; min-height: 56px; cursor: pointer; }
#verify-form input[type="checkbox"] { width: 32px; height: 32px; accent-color: var(--amber); flex: 0 0 auto; }

/* ---- find-water ---- */
.hint { font-size: 12px; color: var(--text-dim); font-style: italic; }
.hint.marginal { color: var(--amber); }
.hint.shuttle { color: var(--cyan); }
#find-banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 1000; background: var(--blue); color: #fff;
  font-weight: 800; padding: 10px 18px; border-radius: 10px; letter-spacing: 0.05em;
  display: none;
}

/* ---- legend ---- */
#legend {
  position: absolute; bottom: 24px; left: 12px; z-index: 1000;
  background: var(--panel-glass); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; font-size: 12px; max-width: 240px;
}
#legend h4 { margin: 4px 0 6px; font-size: 11px; letter-spacing: 0.08em; color: var(--text-dim); }
#legend .lrow { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
#legend .sw { width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto; }

/* ---- map markers (divIcons) ---- */
.src-marker { display: flex; align-items: center; justify-content: center; }
.src-marker .glyph {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #0b1020;
  border: 3px solid rgba(232, 236, 248, 0.85);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}
.src-marker.shape-square .glyph { border-radius: 8px; }
.src-marker.shape-diamond .glyph { border-radius: 8px; transform: rotate(45deg); }
.src-marker.shape-diamond .glyph span { transform: rotate(-45deg); }
.src-marker.state-stale .glyph { border-color: var(--amber); border-width: 4px; }
.src-marker.state-unverified .glyph,
.src-marker.state-status_unknown .glyph {
  border-color: var(--red); border-style: dashed; border-width: 3px;
  background: rgba(11, 16, 32, 0.75) !important; color: var(--red);
}
.src-marker.state-out_of_service .glyph {
  border-color: var(--red); border-width: 4px;
  background: #2a0e14 !important; color: var(--red);
}
.src-marker .flag {
  position: absolute; top: -7px; right: -7px;
  width: 20px; height: 20px; border-radius: 50%;
  font-size: 11px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}
.src-marker .flag.oos { background: var(--red); color: #1c060a; }
.src-marker .flag.warn { background: var(--amber); color: #221600; }
.src-marker .flag.seasonal { background: var(--cyan); color: #06121c; }
/* Second flag slot (seasonal alongside a severity flag) — never masks the first. */
.src-marker .flag.flag2 { top: auto; right: auto; bottom: -7px; left: -7px; }
/* Tactical slot: occupied by a unit (blue = water action semantics). */
.src-marker .flag.inuse { background: var(--blue); color: #fff; }
.src-marker .flag.flagtac { right: auto; left: -7px; }
.src-marker.selected .glyph { outline: 3px solid var(--amber); outline-offset: 2px; }
/* Candidate markers: imported, field-unverified — visually a question, not a source. */
.cand-marker { display: flex; align-items: center; justify-content: center; }
.cand-marker .dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px dashed #6f86c2;
  background: rgba(61, 126, 255, 0.18);
  color: #9db4e8; font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
#btn-candidates.on { border-color: #6f86c2; color: #9db4e8; }

.incident-marker .pin {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0;
  background: var(--red); transform: rotate(-45deg);
  border: 3px solid #ffd7db; box-shadow: 0 1px 8px rgba(0,0,0,0.7);
}

/* Leaflet dark chrome + dimmed tiles for night use */
.leaflet-container { background: var(--bg); font: inherit; }
.leaflet-tile { filter: brightness(0.62) contrast(1.08) saturate(0.55) sepia(0.1); }
/* Satellite view: barely dimmed — imagery detail is the point (pool spotting). */
.sat-mode .leaflet-tile { filter: brightness(0.85) contrast(1.02); }
.leaflet-control-zoom a, .leaflet-bar a {
  background: var(--panel); color: var(--text); border-color: var(--line);
  width: 48px !important; height: 48px !important; line-height: 48px !important; font-size: 20px;
}
.leaflet-control-attribution { background: var(--panel-glass); color: var(--text-dim); }
.leaflet-control-attribution a { color: var(--cyan); }

/* Hazard marks: warning-triangle silhouette so they never read as a water source */
.src-marker.shape-hazard .glyph { border-radius: 6px; font-size: 10px; }
.src-marker.shape-hazard .glyph::before { content: "\26A0"; font-size: 12px; margin-right: 2px; }
.import-picker button { width: 100%; }

/* CRN command-map staging cones */
.crn-stage { text-align: center; }
.crn-cone {
  width: 0; height: 0; margin: 0 auto;
  border-left: 13px solid transparent; border-right: 13px solid transparent;
  border-bottom: 26px solid #ffb020;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,0.7));
}
.crn-cone-label {
  display: inline-block; margin-top: 2px; padding: 1px 7px; border-radius: 6px;
  background: rgba(10, 10, 14, 0.85); color: #f0f0f0;
  font-size: 10px; font-weight: 800; letter-spacing: 0.05em; white-space: nowrap;
}

/* toast */
#toast {
  /* The one element pinned to the screen itself: offset from every edge by that edge's safe-area inset,
     centred between the side insets (left + right + fit-content width + auto margins). */
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: calc(16px + env(safe-area-inset-left));
  right: calc(16px + env(safe-area-inset-right));
  width: fit-content; margin: 0 auto;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 12px 18px; border-radius: 10px; z-index: 2000; display: none;
  font-weight: 700;
}
#toast.error { border-color: var(--red); color: var(--red); }

/* ---- UNITS tab: the responder-location bus (trucks + coarse status, never people) ----
   Marker language shared suite-wide: circle = EMS, square = FIRE, diamond = POLICE;
   color by source (--unit-syn / --unit-live). Everything here is static — no
   animation: a command surface must read correctly after ten minutes of neglect. */
.umk {
  width: 13px; height: 13px; flex: 0 0 auto;
  border: 3px solid var(--unit-syn); background: rgba(61, 220, 151, 0.22);
}
.umk.e { border-radius: 50%; }
.umk.f { border-radius: 3px; }
.umk.p { border-radius: 3px; transform: rotate(45deg); }
.umk.live { border-color: var(--unit-live); background: rgba(255, 178, 62, 0.22); }
.unit-marker { display: flex; align-items: center; gap: 6px; }
/* Callsign chip beside the marker — dark chip, border matches the source color
   (Rampart's .unitlbl, restated here so the suite reads as one language). */
.unitlbl {
  background: rgba(11, 16, 32, 0.9);
  border: 1px solid var(--unit-syn); color: var(--unit-syn);
  border-radius: 6px; padding: 1px 6px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.05em; white-space: nowrap;
}
.unit-marker.live .umk { border-color: var(--unit-live); background: rgba(255, 178, 62, 0.22); }
.unit-marker.live .unitlbl { border-color: var(--unit-live); color: var(--unit-live); }
/* Blind feed: stale positions dim, statically — the banner carries the why.
   Old positions + a loud banner beat an empty map that reads as calm. */
.units-blind .unit-marker { opacity: 0.45; }

/* FEED LOST — over the map, impossible to mistake for a quiet screen.
   Below the find-banner/search-area slot so neither ever masks the other. */
#units-feed-banner {
  position: absolute; top: 72px; left: 50%; transform: translateX(-50%);
  z-index: 1001; max-width: 84%; text-align: center;
  background: var(--red); color: #1c060a;
  font-weight: 800; padding: 10px 18px; border-radius: 10px; letter-spacing: 0.05em;
  display: none;
}

/* The freshness stamp: quiet only while young; amber as it ages; red = blind. */
.units-stamp {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
  margin-bottom: 8px;
}
.units-stamp.aging { color: var(--amber); border-color: #6b4b00; }
.units-stamp.blind { color: var(--red); border-color: #7a2530; background: #2a0e14; }

#units-chips { display: flex; gap: 8px; margin-bottom: 10px; }
.svc-chip { flex: 1; min-height: 48px; font-size: 13px; color: var(--text-dim); }
.svc-chip.on { color: var(--text); border-color: var(--accent); }

.unit-row {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  margin-bottom: 8px; background: var(--panel-2);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 48px;
}
.unit-row .uname { font-weight: 800; }
.unit-row .usvc { color: var(--text-dim); font-size: 11px; letter-spacing: 0.06em; }
.unit-row .usrc {
  font-size: 10px; font-weight: 800; letter-spacing: 0.06em;
  color: var(--unit-syn); border: 1px solid var(--unit-syn);
  border-radius: 6px; padding: 1px 5px;
}
.unit-row .usrc.live { color: var(--unit-live); border-color: var(--unit-live); }
.unit-row .ustat { flex: 1; text-align: right; font-size: 13px; }
.unit-row .usince { color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: 12px; }
/* A positionless unit is a listed fact, not a silent gap (THE ABSENCE LAW). */
.unit-row .unopos {
  flex: 0 0 100%; color: var(--amber);
  font-size: 11px; font-weight: 800; letter-spacing: 0.04em;
}

@media (max-width: 900px) {
  #main { flex-direction: column; }
  #sidebar { flex: 0 0 45%; max-width: none; border-left: none; border-top: 1px solid var(--line); }
}

.water-status-fields label { display:block; margin:12px 0 4px; font-size:12px; color:var(--text-dim); }
#verify-form textarea { padding:12px; resize:vertical; }
#verify-form > button { width:100%; margin-top:12px; }

/* ---- SCHOOL ALERTS tab: the incident-bridge inbox (app/js/alerts.js) ---- */
.alert-card:hover { border-color: var(--line); }
.alert-card .messages-link.expired { text-decoration: line-through; }
.alert-card details summary { list-style: none; font-size: 12px; font-weight: 800; letter-spacing: 0.1em; color: var(--text-dim); }
.alert-card details summary::-webkit-details-marker { display: none; }

/* ---- MESSAGES (#/messages): the shared Knotworks kit, app/js/messages.js ---- */
/* The toolbar and the alert strip paint above the map's overlays (the legend and the Leaflet
   controls, z-index 1000), still below the toast. On a phone the toolbar wraps tall and the legend,
   anchored to the bottom of a short map, grew up over it and hid MESSAGES (and READINESS, IMPORT)
   behind it, so a tap there hit the legend (seen in the headless proof, 2026-10-31). The legend's
   own phone layout is still the open item from 2026-10-07. */
body > header, #alert-strip { position: relative; z-index: 1001; }
/* The header entry's unread count: accent = unread, red = an unread URGENT message. */
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; margin-left: 8px; padding: 0 6px; border-radius: 11px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 12px; font-weight: 800; letter-spacing: 0; font-variant-numeric: tabular-nums;
}
.nav-badge.urgent { background: var(--red); color: #1c060a; }
.nav-badge[hidden] { display: none; }
#alert-strip .as-msg { background: var(--panel-2); border-color: var(--line); color: var(--text); }
.alert-card .msg-btn { width: 100%; margin-top: 8px; }

/* The screen takes the toolbar's and the map's place; the banner and the alert strip stay above
   it (every route). It sits in the body's flow, so it is inside every safe-area inset already. */
body[data-route="messages"] > header,
body[data-route="messages"] > #main { display: none; }
#messages-screen { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
#messages-screen[hidden] { display: none; }
#messages-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 6px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
#messages-title { font-weight: 800; letter-spacing: 0.06em; }
#messages-unit { color: var(--text-dim); font-size: 13px; font-weight: 700; }
#messages-state { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
#messages-state[hidden] { display: none; }
.messages-state-card { max-width: 420px; text-align: center; }
.messages-state-card h2 { margin: 0 0 8px; font-size: 20px; letter-spacing: 0.02em; }
.messages-state-card p { margin: 0 0 16px; color: var(--text-dim); line-height: 1.45; }
.messages-state-card button { min-width: 200px; }

/* The kit reads only --cui-* tokens: here they are the app's own palette, so the THEME button
   restyles Messages too (the kit is mounted with theme {} and sets none of its own). Safe areas:
   the body box is already inset on all four edges by margins (above), so the kit pads nothing
   more; 0px on every edge, keyboard or not. Pinned by tools/test-safe-areas.mjs. */
#messages-kit {
  flex: 1 1 auto; min-height: 0; position: relative; display: flex; flex-direction: column;
  color-scheme: dark;
  --cui-bg: var(--bg);
  --cui-fg: var(--text);
  --cui-muted: var(--text-dim);
  --cui-accent: var(--accent);
  --cui-on-accent: var(--accent-ink);
  --cui-urgent: var(--red);
  --cui-on-urgent: #1c060a;            /* dark text on the red, as button.primary.armed: #fff on it fails AA */
  --cui-urgent-bg: #2a0e14;
  --cui-surface: var(--panel);
  --cui-raised: var(--panel);
  --cui-line: var(--line);
  --cui-bubble: var(--line);
  --cui-bubble-fg: var(--text);
  --cui-selected: color-mix(in srgb, var(--accent) 16%, var(--bg));
  --cui-amber: var(--amber);
  --cui-amber-bg: #2a2000;
  --cui-amber-line: #6b4b00;
  --cui-red: var(--red);
  --cui-red-bg: #2a0e14;
  --cui-red-line: #7a2530;
  --cui-slate: var(--text-dim);
  --cui-slate-bg: var(--panel-2);
  --cui-slate-line: var(--line);
  --cui-avatar-fg: #ffffff;
  --cui-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  --cui-backdrop: rgba(3, 4, 6, 0.74);
  --cui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --cui-safe-top: 0px;
  --cui-safe-right: 0px;
  --cui-safe-bottom: 0px;
  --cui-safe-left: 0px;
}
#messages-kit[hidden] { display: none; }
#messages-kit > .cui-mount { flex: 1 1 auto; }
/* While the keyboard is up (data-kb="up" on <html>, set by messages.js only while a field on the
   Messages screen has focus) the composer sits on the keyboard: the body drops its bottom margin
   (the home indicator is under the keyboard), as the kit's own [data-kb=up] rule drops its token. */
html[data-kb="up"] body { margin-bottom: 0; height: calc(100% - env(safe-area-inset-top)); }
