/* The locator page, in aegis's clothes. Every colour, radius and type setting below is aegis's own
   (apps/web/tailwind.config.ts, apps/web/src/app/globals.css, admin/layout.tsx, Sidebar.tsx + Brand.tsx), so a link
   from the control room looks like it came from the control room. Two things differ on purpose, for a cheap phone
   held in the sun: every control is at least 48 px tall, and type is a size up (aegis's text-sm 14 px is 16 px here,
   which also keeps iOS from zooming into the name field). Dark mode follows the phone, with aegis's dark surfaces.
   Two layouts share all of it: the mobile recovery view (.rv, a responder's link) and the desktop operator view (.op),
   both aegis's map full screen with everything else floating over it — the map's own chrome (map.js), the slim chip,
   and panels that fold with aegis's tab (components/map/PanelFold.tsx). */

:root {
  /* aegis's brand (tailwind.config.ts) */
  --ink: #0b0d10;
  --ink-soft: #15181c;
  --steel: #8b95a1;
  --gold-100: #f5ecd2;
  --gold-200: #e9d59b;
  --gold-300: #d9bb63;
  --gold-400: #cba23c;
  --gold-500: #bd8f2a;
  --gold-600: #9c7320;
  --gold-700: #7a591a;
  /* light: aegis's slate page and white cards (globals.css) */
  --page: #f8fafc;                 /* slate-50 */
  --text: #0f172a;                 /* slate-900 */
  --text-2: #334155;               /* slate-700 */
  --muted: #64748b;                /* slate-500 */
  --card: #ffffff;
  --card-line: #e2e8f0;            /* slate-200 */
  --field-line: #cbd5e1;           /* slate-300 */
  --header: #ffffff;
  --header-line: #e2e8f0;
  --primary-bg: var(--ink);
  --primary-hover: #000000;
  --primary-text: #ffffff;
  --secondary-bg: #ffffff;
  --secondary-hover: #f8fafc;
  --secondary-text: #334155;
  --secondary-line: #cbd5e1;
  --input-bg: #ffffff;
  --input-text: #0f172a;
  --placeholder: #94a3b8;          /* slate-400 */
  --warn-bg: #fffbeb; --warn-line: #fde68a; --warn-text: #92400e;       /* amber-50 / 200 / 800 */
  --final-bg: #fff1f2; --final-line: #fecdd3; --final-text: #be123c;    /* rose-50 / 200 / 700 */
  --live: #10b981;                 /* aegis's "Live" green (live-map-draw.ts) */
  --amber: #b45309;                /* amber-700: a word getting old */
  --red: #be123c;                  /* rose-700: a word too old */
  --sheet-shadow: 0 -4px 16px rgba(15, 23, 42, 0.12);
  --chip-enroute-bg: #dbeafe; --chip-enroute-text: #1d4ed8;        /* aegis's RESPONDER_LOOK, as tints */
  --chip-arrived-bg: #dcfce7; --chip-arrived-text: #15803d;
  --chip-stopped-bg: #f1f5f9; --chip-stopped-text: #475569;
  --chip-sharing-bg: #cffafe; --chip-sharing-text: #0e7490;
  --map-bg: #e2e8f0;
  /* aegis's map chrome (geography/stage.tsx CARD, PanelFold): white, slate-200, slate-600, slate-100 */
  --chrome-bg: #ffffff;
  --chrome-line: #e2e8f0;
  --chrome-text: #475569;
  --chrome-hover: #f1f5f9;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    /* aegis's dark skin (globals.css .dark overrides) */
    --page: #0b0d10;
    --text: #e7ebf0;
    --text-2: #c2c9d2;
    --muted: #8b95a1;
    --card: #15181c;
    --card-line: rgba(255, 255, 255, 0.1);
    --field-line: rgba(255, 255, 255, 0.15);
    --header: #15181c;
    --header-line: rgba(255, 255, 255, 0.08);
    --primary-bg: rgba(255, 255, 255, 0.1);
    --primary-hover: rgba(255, 255, 255, 0.2);
    --primary-text: #ffffff;
    --secondary-bg: rgba(255, 255, 255, 0.05);
    --secondary-hover: rgba(255, 255, 255, 0.1);
    --secondary-text: #e2e8f0;
    --secondary-line: rgba(255, 255, 255, 0.15);
    --input-bg: #15181c;
    --input-text: #f1f5f9;
    --placeholder: #64748b;
    --warn-bg: rgba(245, 158, 11, 0.12); --warn-line: rgba(245, 158, 11, 0.3); --warn-text: #fcd34d;
    --final-bg: rgba(244, 63, 94, 0.12); --final-line: rgba(244, 63, 94, 0.3); --final-text: #fda4af;
    --map-bg: #20242b;
    --chrome-bg: #15181c;
    --chrome-line: #334155;
    --chrome-text: #cbd5e1;
    --chrome-hover: rgba(255, 255, 255, 0.05);
    --amber: #fbbf24;
    --red: #fda4af;
    --sheet-shadow: 0 -4px 16px rgba(0, 0, 0, 0.5);
    --chip-enroute-bg: rgba(37, 99, 235, 0.2); --chip-enroute-text: #93c5fd;
    --chip-arrived-bg: rgba(22, 163, 74, 0.2); --chip-arrived-text: #86efac;
    --chip-stopped-bg: rgba(255, 255, 255, 0.08); --chip-stopped-text: #cbd5e1;
    --chip-sharing-bg: rgba(8, 145, 178, 0.2); --chip-sharing-text: #67e8f9;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
  /* aegis's console wears a 2 px gold line along its top edge (admin/layout.tsx) */
  border-top: 2px solid var(--gold-500);
}

/* the DEV strip — aegis's, exactly (apps/web/src/app/layout.tsx); only dev's page carries it */
.dev-strip {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 2147483647;
  pointer-events: none;
  background: #b91c1c; color: #fff;
  font: 700 11px/16px system-ui, sans-serif; letter-spacing: 0.04em;
  padding: 1px 10px; border-radius: 0 0 6px 6px; white-space: nowrap;
}

/* ── the header: emblem, "World Risk", and what this page is ── */
.top {
  display: flex; align-items: center; gap: 12px;
  min-height: 64px;
  padding: max(8px, env(safe-area-inset-top)) 16px 8px;
  background: var(--header);
  border-bottom: 1px solid var(--header-line);
}
.emblem { display: block; height: 40px; width: auto; flex: none; }
.brand { display: flex; flex-direction: column; min-width: 0; }
.wordmark { font-weight: 700; text-transform: uppercase; letter-spacing: 0.18em; font-size: 18px; line-height: 1.5rem; color: var(--ink); }
.wordmark .gold { color: var(--gold-400); }
.subtitle { margin-top: 2px; font-size: 10px; line-height: 14px; text-transform: uppercase; letter-spacing: 0.25em; color: var(--steel); }
@media (prefers-color-scheme: dark) { .wordmark { color: #ffffff; } }

.boot-body { max-width: 720px; margin: 0 auto; padding-bottom: max(24px, env(safe-area-inset-bottom)); }

/* ── aegis's components (globals.css @layer components), touch-sized ── */
.card {
  margin: 12px 16px;
  border-radius: 12px;                        /* rounded-xl */
  border: 1px solid var(--card-line);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.label {                                       /* text-xs font-medium uppercase tracking-wide text-slate-500 */
  margin: 0;
  font-size: 12px; line-height: 16px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.025em;
  color: var(--muted);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px;
  padding: 8px 14px;                           /* py-2 px-3.5 */
  border: 1px solid transparent;
  border-radius: 8px;                          /* rounded-lg */
  font: 500 16px/1.25 var(--font);
  text-align: center; text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--gold-300); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary { background: var(--primary-bg); color: var(--primary-text); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-gold { background: var(--gold-500); color: var(--ink); }
.btn-gold:hover:not(:disabled) { background: var(--gold-600); }
.btn-secondary { background: var(--secondary-bg); color: var(--secondary-text); border-color: var(--secondary-line); }
.btn-secondary:hover:not(:disabled) { background: var(--secondary-hover); }
.btn-big { min-height: 56px; font-size: 17px; font-weight: 600; }
.input {
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;                           /* px-3 py-2 */
  border: 1px solid var(--field-line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--input-text);
  font: 16px/1.25 var(--font);
  outline: none;
}
.input::placeholder { color: var(--placeholder); }
.input:focus { border-color: var(--gold-400); box-shadow: 0 0 0 2px var(--gold-100); }
@media (prefers-color-scheme: dark) { .input:focus { box-shadow: 0 0 0 2px rgba(189, 143, 42, 0.3); } }

.status {
  margin: 12px 16px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--card-line);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  font-size: 17px; font-weight: 600;
}
.status[data-kind="warn"] { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-line); }
.status[data-kind="final"] { background: var(--final-bg); color: var(--final-text); border-color: var(--final-line); font-size: 19px; }

/* ── THE MAP (public/map.js), in aegis's chrome. MapLibre fills the view's map box; the zoom and fit buttons, the base
   switch and the credits stand at its bottom right, as on the Map page (geography/stage.tsx) and BLE Assets, and keep
   clear of the view's panels: --map-right and --map-bottom are what the panels take (each view sets them as its panel
   opens and folds). On a touch screen the same controls are finger-sized. ── */
.map-box { position: absolute; inset: 0; }
.lmap { overflow: hidden; background: var(--map-bg); }
/* maplibre's own class says position: relative, which would fold this box to 0 px */
.lmap-gl, .lmap-gl.maplibregl-map { position: absolute; inset: 0; }
.lmap-gl .maplibregl-canvas:focus-visible { outline: 2px solid var(--gold-300); outline-offset: -2px; }
.lmap-chrome {
  position: absolute; z-index: 10;
  right: calc(var(--map-right, 10px) + env(safe-area-inset-right));
  bottom: var(--map-bottom, 8px);
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
  pointer-events: none;
  transition: right 0.2s, bottom 0.2s;
}
.lmap-chrome > * { pointer-events: auto; }
/* aegis's map card (geography/stage.tsx CARD): rounded-lg, a slate-200 line, white, shadow-lg; dark #15181c, slate-700 */
.map-card {
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--chrome-line);
  background: var(--chrome-bg);
  box-shadow: var(--shadow-lg);
}
.lmap-zoom { display: flex; flex-direction: column; }
.lmap-btn {
  display: grid; place-items: center;
  width: 28px; height: 28px;                   /* h-7 w-7 */
  margin: 0; padding: 0;
  border: 0; background: transparent;
  color: var(--chrome-text);
  font: 15px/1 var(--font);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lmap-btn + .lmap-btn { border-top: 1px solid var(--chrome-line); }
.lmap-btn:hover { background: var(--chrome-hover); }
.lmap-btn:focus-visible, .lmap-base:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--gold-300); }
.lmap-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* moved away from what the view frames: the fit button says so in gold */
.lmap-fit[data-away] { color: var(--gold-600); }
@media (prefers-color-scheme: dark) { .lmap-fit[data-away] { color: var(--gold-400); } }
.lmap-bases { display: flex; }
.lmap-base {
  margin: 0; padding: 4px 10px;                /* px-2.5 py-1 */
  border: 0; background: transparent;
  color: #64748b;                              /* text-slate-500 */
  font: 400 11px/16px var(--font);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lmap-base:hover { background: var(--chrome-hover); }
.lmap-base[aria-pressed="true"] { background: var(--gold-500); color: var(--ink); font-weight: 600; }
/* the base switch's row: the credits' ⓘ (and, shown, the credits) to its left — never wider than the map beside the panel */
.lmap-foot {
  display: flex; align-items: flex-end; justify-content: flex-end; gap: 6px;
  max-width: calc(100vw - var(--map-right, 10px) - env(safe-area-inset-right) - 16px);
}
/* the credits: ours, as text, behind an ⓘ, as aegis's maps show maplibre's compact ones */
/* the base switch keeps its size; shown credits wrap in what is left beside it */
.lmap-foot > .lmap-bases { flex: none; }
.lmap-attrib { display: flex; align-items: flex-end; gap: 4px; min-width: 0; flex: 0 1 auto; }
.lmap-attrib-text {
  min-width: 0; max-width: 600px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.85);
  color: #1e293b;
  font: 10px/14px var(--font);
  text-align: right;
}
.lmap-attrib-text a { color: inherit; }
.lmap-attrib-btn {
  position: relative; flex: none;
  display: grid; place-items: center;
  width: 24px; height: 24px; margin: 0; padding: 0;
  border: 1px solid var(--chrome-line); border-radius: 999px;
  background: var(--chrome-bg); color: var(--chrome-text);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lmap-attrib-btn::before { content: ''; position: absolute; inset: -8px; }
.lmap-attrib-btn:hover { background: var(--chrome-hover); }
.lmap-attrib-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--gold-300); }
.lmap-attrib-btn .lmap-icon { width: 14px; height: 14px; }
@media (prefers-color-scheme: dark) { .lmap-attrib-text { background: rgba(21, 24, 28, 0.85); color: #cbd5e1; } }
.lmap-failed .lmap-gl { display: flex; align-items: center; justify-content: center; padding: 24px; }
.lmap-msg { max-width: 320px; margin: 0; color: var(--muted); font-size: 15px; text-align: center; }
/* the ring that grows out of a live vehicle's gold one while its position is fresh (TripMap's pulse) */
.lmap-pulse { width: 24px; height: 24px; pointer-events: none; }
.lmap-pulse-ring {
  display: block; width: 100%; height: 100%;
  border-radius: 50%;
  border: 2px solid var(--live);
  animation: lmap-pulse 1.6s ease-out infinite;
}
@keyframes lmap-pulse { 0% { transform: scale(1); opacity: 0.8; } 100% { transform: scale(2.1); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .lmap-pulse-ring { animation: none; opacity: 0; } }
@media (pointer: coarse) {
  .lmap-btn { width: 44px; height: 44px; font-size: 21px; }
  .lmap-icon { width: 20px; height: 20px; }
  .lmap-base { min-height: 40px; padding: 0 13px; font-size: 13px; }
  /* a finger pinches to zoom, and a phone's map needs the room: + and − stand down, the fit stays */
  .lmap-zoom .lmap-btn:not(.lmap-fit) { display: none; }
  .lmap-zoom .lmap-fit { border-top: 0; }
  .lmap-attrib-btn { width: 32px; height: 32px; }
  .lmap-attrib-btn .lmap-icon { width: 18px; height: 18px; }
}

/* ── THE FOLD TAB (components/map/PanelFold.tsx): 20 × 48, mid-height on the panel's inner edge; folded, on the map's
   edge with its arrow turned round. A slate-200 line, white, shadow-md; dark #15181c, slate-700, slate-300. Its target
   reaches 10 px past it all round, for a finger. ── */
.fold-tab {
  position: absolute; z-index: 21;
  display: grid; place-items: center;
  margin: 0; padding: 0;
  border: 1px solid var(--chrome-line);
  background: var(--chrome-bg);
  color: #64748b;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.fold-tab::before { content: ''; position: absolute; inset: -10px; }
.fold-tab:hover { background: #f8fafc; color: var(--ink); }
.fold-tab:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--gold-300); }
@media (prefers-color-scheme: dark) {
  .fold-tab { color: #cbd5e1; }
  .fold-tab:hover { background: rgba(255, 255, 255, 0.05); color: #ffffff; }
}
.fold-icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* on a panel's left edge (the panel floats on the right) */
.fold-tab-right {
  top: 50%; right: 0;
  width: 20px; height: 48px;
  transform: translateY(-50%);
  border-right: 0; border-radius: 8px 0 0 8px;
  transition: right 0.2s;
}
/* on a bottom panel's top edge, centred: the same tab turned on its side */
.fold-tab-bottom {
  top: -20px; left: 50%;
  width: 48px; height: 20px;
  transform: translateX(-50%);
  border-bottom: 0; border-radius: 8px 8px 0 0;
  box-shadow: 0 -3px 6px -2px rgba(0, 0, 0, 0.12);
}

/* ── what floats over a full-screen map: the slim chip (top left) and the banner ── */
.map-chip {
  position: absolute; z-index: 22;
  top: max(12px, calc(env(safe-area-inset-top) + 8px));
  left: max(12px, calc(env(safe-area-inset-left) + 8px));
  display: flex; align-items: center; gap: 10px;
  max-width: calc(100% - 24px);
  min-height: 40px;
  padding: 4px 12px 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--chrome-line);
  background: var(--chrome-bg);
  box-shadow: var(--shadow-lg);
}
.chip-emblem { display: block; height: 26px; width: auto; flex: none; }
.chip-title { font-weight: 700; text-transform: uppercase; letter-spacing: 0.16em; font-size: 12px; line-height: 16px; color: var(--text); white-space: nowrap; }
.chip-left { font-size: 13px; color: var(--muted); white-space: nowrap; }
.map-chip .live-badge { font-size: 12px; padding: 1px 8px; }
.map-banner {
  position: absolute; z-index: 22;
  top: calc(max(12px, calc(env(safe-area-inset-top) + 8px)) + 52px);
  left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 32px);
  margin: 0; padding: 6px 14px; border-radius: 999px;
  background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-line);
  box-shadow: var(--shadow-md);
  font-size: 14px; font-weight: 600; text-align: center;
}
@media (prefers-color-scheme: dark) { .map-banner { background: #2a2210; } }
/* the recovery view's banners stand in one column: trouble first, then "the vehicle has moved…" (a link: tapped, it opens
   the same app at the new point) and, navigating, "route updated" — under the chip, or under the navigation banner */
.map-banners {
  position: absolute; z-index: 22;
  top: calc(max(12px, calc(env(safe-area-inset-top) + 8px)) + 52px);
  left: 50%; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 32px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.map-banners > * { pointer-events: auto; }
.map-banners .map-banner { position: static; transform: none; max-width: 100%; }
.map-banner-link, .map-banner-note {
  display: block; text-decoration: none;
  background: var(--card); color: var(--text); border-color: var(--gold-400);
}
.map-banner-link { cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--gold-400); }
@media (prefers-color-scheme: dark) { .map-banner-link, .map-banner-note { background: var(--card); } }
.dev-strip ~ .fullmap .map-banners { top: calc(max(26px, calc(env(safe-area-inset-top) + 22px)) + 52px); }
.rv[data-nav] .map-banners { top: calc(var(--nav-top, 120px) + 8px); }

/* ── the vehicle's words ── */
.note { margin: 0 0 10px; font-size: 16px; color: var(--text-2); overflow-wrap: anywhere; white-space: pre-line; }
.coords {
  display: block; width: 100%;
  min-height: 48px;
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px dashed var(--field-line);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: 600 18px/1.2 var(--mono);
  text-align: left;
  cursor: pointer;
}
.coords:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--gold-300); }
.meta { margin: 4px 0; font-size: 15px; color: var(--muted); }

.actions { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── shared by the views ── */
.card-title { margin: 0; font-size: 18px; line-height: 1.3; font-weight: 600; color: var(--text); }
.field { display: flex; flex-direction: column; gap: 6px; }
.optional { text-transform: none; letter-spacing: 0; font-weight: 400; }
.hint { margin: 0; font-size: 14px; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.btn-small { min-height: 36px; padding: 4px 12px; font-size: 14px; }
.live-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px;
  background: rgba(16, 185, 129, 0.12); color: #047857;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.live-badge[data-stale] { background: var(--warn-bg); color: var(--warn-text); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); flex: none; }
.live-badge[data-stale] .live-dot { background: #f59e0b; }
@media (prefers-color-scheme: dark) { .live-badge { color: #6ee7b7; } }
.chip {
  display: inline-flex; align-items: center;
  padding: 1px 8px; border-radius: 999px;
  font-size: 12px; line-height: 18px; font-weight: 600; white-space: nowrap;
  background: var(--chip-sharing-bg); color: var(--chip-sharing-text);
}
.chip[data-status="enroute"] { background: var(--chip-enroute-bg); color: var(--chip-enroute-text); }
.chip[data-status="arrived"] { background: var(--chip-arrived-bg); color: var(--chip-arrived-text); }
.chip[data-status="stopped"] { background: var(--chip-stopped-bg); color: var(--chip-stopped-text); }
.chip[data-status="paused"] { background: var(--warn-bg); color: var(--warn-text); }
.chip-kind[data-live="1"] { background: rgba(16, 185, 129, 0.14); color: #047857; }
.chip-kind[data-live="0"] { background: var(--chip-stopped-bg); color: var(--chip-stopped-text); }
@media (prefers-color-scheme: dark) { .chip-kind[data-live="1"] { color: #6ee7b7; } }
[data-old] { color: var(--amber) !important; font-weight: 600; }
/* dev's red strip sits over the top edge: the header, the chips and the banner make room for it */
.dev-strip ~ .boot .top { padding-top: max(20px, env(safe-area-inset-top)); }
.dev-strip ~ .fullmap .map-chip { top: max(26px, calc(env(safe-area-inset-top) + 22px)); }
.dev-strip ~ .fullmap .map-banner { top: calc(max(26px, calc(env(safe-area-inset-top) + 22px)) + 52px); }
.dev-strip ~ .op .op-panel { top: 26px; }

/* ── BOTH VIEWS ARE THE MAP, FULL SCREEN, under aegis's 2 px gold line; everything else floats over it ── */
body.rv-on, body.op-on { min-height: 0; overflow: hidden; }
.fullmap {
  position: fixed; left: 0; right: 0; top: 2px;
  height: calc(100vh - 2px);
  height: calc(100dvh - 2px);
  overflow: hidden;
  background: var(--map-bg);
}

/* ── THE MOBILE RECOVERY VIEW: the details panel along the bottom, folding down to its bar ── */
.rv-panel {
  position: absolute; z-index: 20;
  left: 0; right: 0; bottom: 0;
  max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column;
  /* the map always keeps a strip for the vehicle, you and the controls above the panel: 260 px, or 30 % of a tall
     screen. A panel with more to say scrolls its body (More, a long note). */
  max-height: min(calc(100% - 260px), 70%);
  padding: 12px max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--card);
  border: 1px solid var(--chrome-line); border-bottom: 0;
  border-radius: 12px 12px 0 0;
  box-shadow: var(--sheet-shadow);
  transition: transform 0.2s;
}
.rv-bar { flex: none; }
.rv-panel[data-folded] .rv-bar { cursor: pointer; }
.rv-body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  margin: 0 -4px; padding: 0 4px;              /* room for the focus rings at its edges */
  transition: visibility 0.2s;
}
/* folded away: out of sight, out of the tab order and out of a screen reader's way — but still there */
.rv-panel[data-folded] .rv-body { visibility: hidden; }
.rv-label { margin: 0; font-size: 18px; line-height: 1.25; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.rv-note { margin: 4px 0 0; font-size: 15px; }
.rv-route { margin: 4px 0 0; font-size: 21px; line-height: 1.25; font-weight: 700; color: var(--text); }
.rv-pos { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.rv-actions { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 12px; }
/* Start navigation: the panel's first action, in its bar, so it is there with the panel folded too — and beside it the
   phone, so the control room is one tap away folded or not (the drive check found the Call button below the fold) */
.rv-start { width: 100%; margin-top: 10px; }
.rv-bar-acts { display: flex; gap: 8px; margin-top: 10px; }
.rv-bar-acts .rv-start { order: 1; flex: 1 1 auto; width: auto; margin-top: 0; }
.rv-bar-call { order: 2; flex: none; width: 56px; padding: 0; }
.brief-line { display: block; }
.btn-icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* the briefing: what to look for, the controller's instructions, the vehicle's way at its last report */
.brief { margin: 10px 0 0; }
.brief .label { margin-bottom: 2px; }
.brief-plate { margin: 0; font: 700 18px/1.3 var(--mono); letter-spacing: 0.02em; color: var(--text); overflow-wrap: anywhere; }
.brief-desc { margin: 2px 0 0; font-size: 16px; color: var(--text-2); overflow-wrap: anywhere; }
.brief .note { margin: 0; }
.rv-motion { margin-top: 8px; color: var(--text-2); font-weight: 600; }
/* "Call the control room": big, and the number with it — ink in the light, light in the dark (aegis's dark primary is a
   faint wash, too faint for the button a unit needs most) */
.rv-call { flex-wrap: wrap; column-gap: 8px; row-gap: 0; }
.rv-call-number { font-weight: 500; font-size: 15px; opacity: 0.85; font-variant-numeric: tabular-nums; }
@media (prefers-color-scheme: dark) { .rv-call { background: #e7ebf0; color: var(--ink); } .rv-call:hover { background: #ffffff; } }
.rv-me { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.rv-nav-hint { margin: -4px 0 0; font-size: 13px; }
.rv-coords .coords { margin: 0 0 2px; }
.rv-more-btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 44px; margin: 8px 0 0; padding: 0;
  border: 0; border-top: 1px solid var(--card-line);
  background: transparent; color: var(--text-2);
  font: 600 15px/1.2 var(--font);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.rv-more-btn:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--gold-300); border-radius: 8px; }
.rv-more { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; padding-bottom: 2px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--secondary-line); border-radius: 8px; overflow: hidden; }
.seg-btn {
  min-height: 48px; border: 0; margin: 0;
  background: var(--secondary-bg); color: var(--secondary-text);
  font: 600 16px/1.2 var(--font); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--secondary-line); }
.seg-btn[aria-pressed="true"] { background: var(--primary-bg); color: var(--primary-text); }
/* aegis's dark primary is a faint white wash — too faint to say which one you are: the chosen one goes light */
@media (prefers-color-scheme: dark) { .seg-btn[aria-pressed="true"] { background: #e7ebf0; color: var(--ink); } }
.seg-btn:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--gold-300); }
.rv .actions { margin: 0; }
.rv .meta { margin: 0; font-size: 14px; }

/* ── NAVIGATION MODE (public/recovery.js, public/navigation.js): the next manoeuvre in a banner on top — aegis's ink with
   its gold line, the arrow in gold — what is left in a strip at the bottom, and between them the map following you.
   The chip and the panel are put away; the cover still goes over everything. ── */
.rv[data-nav] .rv-chip, .rv[data-nav] .rv-panel { display: none; }
.nav { position: absolute; inset: 0; z-index: 21; pointer-events: none; }
.nav > * { pointer-events: auto; }
.nav-top {
  position: absolute; left: 0; right: 0; top: 0;
  max-width: 560px; margin: 0 auto;
  padding: max(10px, calc(env(safe-area-inset-top) + 6px)) max(14px, env(safe-area-inset-right)) 12px max(14px, env(safe-area-inset-left));
  background: var(--ink); color: #ffffff;
  border-bottom: 3px solid var(--gold-500);
  border-radius: 0 0 12px 12px;
  box-shadow: var(--shadow-lg);
}
.dev-strip ~ .fullmap .nav-top { padding-top: max(24px, calc(env(safe-area-inset-top) + 20px)); }
/* off the road: amber, as aegis says a warning; at the vehicle: Live's green */
.nav-top[data-mode="off"] { background: #92400e; border-bottom-color: #fbbf24; }
.nav-top[data-mode="arrived"] { background: #065f46; border-bottom-color: var(--live); }
.nav-main { display: flex; align-items: center; gap: 14px; min-height: 64px; }
.nav-arrow { flex: none; display: grid; place-items: center; width: 64px; height: 64px; color: var(--gold-300); }
.nav-top[data-mode="off"] .nav-arrow, .nav-top[data-mode="arrived"] .nav-arrow { color: #ffffff; }
.nav-arrow-icon { width: 60px; height: 60px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.nav-words { min-width: 0; flex: 1 1 auto; }
.nav-dist { margin: 0; font-size: 36px; line-height: 1.05; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.nav-text { margin: 3px 0 0; font-size: 22px; line-height: 1.25; font-weight: 600; overflow-wrap: anywhere; }
.nav-then {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 0 0; padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 15px; line-height: 1.3; color: #c2c9d2;
}
.nav-then-word { flex: none; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #ffffff; }
.nav-then[data-note] .nav-then-word { display: none; }
.nav-then-arrow { flex: none; display: grid; place-items: center; width: 24px; height: 24px; color: var(--gold-300); }
.nav-then-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.nav-then-text { min-width: 0; overflow-wrap: anywhere; }
/* "Look for ABC 123 GP · White Scania" on the last stretch, at the road's end and at the vehicle */
.nav-look {
  margin: 10px 0 0; padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 16px; line-height: 1.3; font-weight: 600; color: #ffffff; overflow-wrap: anywhere;
}
.nav-onscene { width: 100%; margin-top: 10px; }
/* driving against the road: amber, as off the route */
.nav-top[data-mode="wrong"] { background: #92400e; border-bottom-color: #fbbf24; }
.nav-top[data-mode="wrong"] .nav-arrow { color: #ffffff; }
/* navigating, the map keeps the re-centre button and drops the base switch (it stood in the middle of a 360 × 640 map) */
.rv[data-nav] .lmap-bases { display: none; }
.nav-bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 560px; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px;
  padding: 12px max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--card); color: var(--text);
  border: 1px solid var(--chrome-line); border-bottom: 0;
  border-radius: 12px 12px 0 0;
  box-shadow: var(--sheet-shadow);
}
.nav-sum { flex: 1 1 180px; min-width: 0; }
.nav-left { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; }
.nav-remain { font-size: 22px; line-height: 1.2; font-weight: 700; font-variant-numeric: tabular-nums; }
.nav-eta { font-size: 16px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.nav-report { margin: 2px 0 0; font-size: 13px; line-height: 1.3; color: var(--muted); }
.nav-btns { flex: 1 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.nav-btn {
  display: grid; place-items: center;
  width: 48px; height: 48px; margin: 0; padding: 0;
  border: 1px solid var(--secondary-line); border-radius: 999px;
  background: var(--secondary-bg); color: var(--secondary-text);
  text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn[aria-pressed="true"] { background: var(--gold-500); border-color: var(--gold-500); color: var(--ink); }
.nav-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--gold-300); }
.nav-btn-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-exit, .nav-brief-btn { padding: 8px 14px; }
/* the briefing over the map, above the strip, without leaving navigation */
.nav-brief {
  position: absolute; left: 0; right: 0; bottom: calc(var(--nav-bottom, 120px) + 8px);
  width: calc(100% - 24px); max-width: 536px; margin: 0 auto;
  max-height: calc(100% - var(--nav-top, 120px) - var(--nav-bottom, 120px) - 24px); overflow-y: auto; overscroll-behavior: contain;
  padding: 12px 14px 14px;
  border-radius: 12px; border: 1px solid var(--chrome-line);
  background: var(--card); color: var(--text); box-shadow: var(--shadow-lg);
}
.nav-brief-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.nav-brief-title { margin: 0; font-size: 17px; font-weight: 700; }
.nav-brief .brief:first-of-type { margin-top: 6px; }
@media (prefers-color-scheme: dark) {
  .nav-top { background: #15181c; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55); }
  .nav-top[data-mode="off"], .nav-top[data-mode="wrong"] { background: #78350f; }
  .nav-top[data-mode="arrived"] { background: #064e3b; }
}

/* the cover: nothing of the vehicle shows until the phone shares its position — over everything, the whole screen */
.gate {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px max(24px, env(safe-area-inset-bottom));
  background: var(--page);
  overflow-y: auto;
}
.gate-card {
  width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 14px;
  padding: 22px 18px;
  border-radius: 12px; border: 1px solid var(--card-line);
  background: var(--card); box-shadow: var(--shadow-sm);
}
.gate-emblem { display: block; height: 44px; width: auto; align-self: flex-start; }
.gate-title { margin: 0; font-size: 22px; line-height: 1.25; font-weight: 700; color: var(--text); }
.gate-text { margin: 0; font-size: 16px; color: var(--text-2); }

/* ── THE DESKTOP OPERATOR VIEW: the panel of the vehicle and the units floats on the right (BleView's panel: rounded-xl,
   a slate-200 line, white, shadow-lg), sliding off the map's edge when it folds ── */
.op-panel {
  position: absolute; z-index: 20;
  top: 12px; bottom: 12px; right: 12px;
  width: 360px; max-width: calc(100% - 24px);
  display: flex; flex-direction: column;
  overflow-y: auto; overscroll-behavior: contain;
  border-radius: 12px;
  border: 1px solid var(--card-line);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  transition: right 0.2s, visibility 0.2s;
}
.op-panel[data-folded] { visibility: hidden; }
.op-sec { padding: 14px 16px; border-bottom: 1px solid var(--card-line); }
.op-sec:last-child { border-bottom: 0; }
.op-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.op-label { margin: 0 0 4px; font-size: 20px; line-height: 1.25; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.op-pos { margin: 4px 0; font-size: 14px; color: var(--muted); }
.op-sec .coords { font-size: 15px; min-height: 40px; padding: 8px 10px; }
.op-sec .meta { font-size: 13px; }
.op-sec .brief { margin: 8px 0 0; }
/* what the units are told: folded under its own line until the operator opens it */
.op-brief { margin: 6px 0 4px; }
.op-brief-sum {
  display: flex; align-items: center; gap: 6px; min-height: 36px;
  font-size: 14px; font-weight: 600; color: var(--text-2); cursor: pointer; list-style: none;
}
.op-brief-sum::-webkit-details-marker { display: none; }
.op-brief-sum::before { content: '▸'; color: var(--gold-600); font-size: 12px; transition: transform 0.15s; }
.op-brief[open] > .op-brief-sum::before { transform: rotate(90deg); }
.op-brief-sum:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--gold-300); border-radius: 6px; }
.op-sec .brief-plate { font-size: 16px; }
.op-sec .brief-desc { font-size: 15px; }
.op-motion { color: var(--text-2); font-weight: 600; }
.op-call { color: var(--gold-700); font-weight: 600; font-variant-numeric: tabular-nums; }
@media (prefers-color-scheme: dark) { .op-call { color: var(--gold-300); } }
.op-empty { margin: 4px 0; font-size: 15px; color: var(--muted); }
.op-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.op-row {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 10px; align-items: start;
  padding: 10px 0; border-top: 1px solid var(--card-line);
}
.op-row:first-child { border-top: 0; }
.op-row[data-status="stopped"] { opacity: 0.7; }
.op-swatch { width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--card-line); }
.op-row-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.op-row-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.op-unit { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.op-unit-name { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.op-road { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); }
.op-line { margin: 0; font-size: 13px; color: var(--muted); }
.op-age[data-age="amber"] { color: var(--amber); font-weight: 600; }
.op-age[data-age="red"] { color: var(--red); font-weight: 700; }
.op-show { align-self: center; }
/* the chip keeps clear of the panel while it is out: it wraps before it would run under it */
.op-chip { max-width: calc(100% - var(--map-right, 10px) - 24px); flex-wrap: wrap; row-gap: 2px; }

/* the copy fallback's textarea: in the document, never seen */
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }

@media (min-width: 720px) {
  .top { padding-left: 24px; padding-right: 24px; }      /* px-6, as aegis's header */
}
