/* ===========================================================================
   Dawn Route — design system (§6 of the design document).
   Palette: near-black blue-indigo background (the 5am sky), sodium-amber
   signature accent (a porch light left on for the carrier), muted green for
   delivered, brick-red for issues, slate for pending. The signature element
   is the mobile house-number plaque. Restraint keeps the map scannable.
   =========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* --- surfaces (the 5am sky, layered depth) --- */
  --bg:        #0a0f1c;   /* near-black, faint blue-indigo (the sky at 5am)     */
  --panel:     #111827;   /* raised surface — stop list, detail                 */
  --panel-2:  #18202f;   /* nested / hover surface                           */
  --panel-3:  #1e2839;   /* raised hover / active                             */
  --line:     #243044;   /* hairlines / borders                              */
  --line-soft: #1a2333;  /* very subtle separators                           */

  /* --- text --- */
  --ink:      #e8edf5;   /* primary text                                     */
  --muted:    #8493a8;   /* secondary text                                  */
  --faint:    #5a6678;   /* tertiary / placeholder                           */

  /* --- signature accent (sodium-amber: porch light, route line, selection) -- */
  --accent:    #f5b942;
  --accent-d:  #d99c2e;  /* hover / pressed                                  */
  --accent-bg: rgba(245,185,66,.12);

  /* --- status palette (§6): muted, unsaturated, scannable --- */
  --delivered: #4ade80;  /* muted porch-light green                           */
  --issue:     #c0564a;  /* muted brick-red (missed paper, not an emergency)  */
  --pending:   #64748b;  /* neutral slate grey                                */
  --not_home:  #f5b942;  /* amber — someone wasn't home                        */
  --refused:   #c0564a;  /* brick-red                                         */
  --wrong_addr:#8b5cf6;  /* purple — wrong address                             */
  --skipped:   #64748b;  /* slate — deliberately skipped                      */
  --priority:  #f5b942;  /* amber outline for priority stops                  */

  /* status alias map (used by JS-rendered class names) */
  --c-delivered:     #4ade80;
  --c-not_home:      #f5b942;
  --c-refused:       #c0564a;
  --c-wrong_address: #8b5cf6;
  --c-skipped:       #64748b;
  --c-pending:       #64748b;

  /* --- geometry --- */
  --radius:    .625rem;
  --radius-sm: .375rem;
  --radius-xs: .25rem;
  --shadow:    0 4px 20px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.45);
  --glow-amber: 0 0 0 3px rgba(245,185,66,.18);

  /* --- type --- */
  --font-sans: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, "SF Mono", Consolas, monospace;
  --font-display: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--font-sans);
  display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; }

/* mono for numbers — tabular alignment matters for distances / counts */
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.mono { font-family: var(--font-mono); }

/* =========================================================================
   TOP BAR — brand · route meta · day strip · icon controls
   ========================================================================= */
.topbar {
  display: flex; align-items: center; gap: .75rem;
  padding: 0 1rem;
  height: 3.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  z-index: 10;
}
.topbar .brand {
  font-weight: 700; letter-spacing: -.01em; font-size: 1rem;
  white-space: nowrap;
}
.topbar .brand .accent { color: var(--accent); }
.topbar .route-meta {
  color: var(--muted); font-size: .8rem; flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-left: .5rem;
}
.topbar .route-meta .sep { color: var(--line); margin: 0 .35rem; }
.topbar .route-select {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--radius-sm); padding: .3rem .5rem; font-size: .78rem;
  cursor: pointer; appearance: none;
  padding-right: 1.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%238493a8' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .4rem center;
  max-width: 12rem;
}
.topbar .route-select:focus { outline: 0; border-color: var(--accent); }
.topbar .pill {
  font-size: .72rem; padding: .2rem .55rem; border-radius: 999px;
  background: var(--panel-2); color: var(--ink);
  font-variant-numeric: tabular-nums; font-weight: 600;
  border: 1px solid var(--line);
}
.topbar .pill .ok { color: var(--delivered); }
.topbar .pill .total { color: var(--muted); }

/* --- day strip (§4 mockup: Mon-Sun) replaces the year scrubber --- */
.day-strip {
  display: flex; gap: .15rem; align-items: center;
  padding: 0 .5rem 0 0;
}
.day-strip .day {
  display: flex; flex-direction: column; align-items: center;
  padding: .3rem .45rem; border-radius: var(--radius-sm);
  cursor: pointer; transition: background .12s, color .12s;
  min-width: 2rem;
}
.day-strip .day .lbl { font-size: .62rem; color: var(--faint); text-transform: uppercase; letter-spacing: .03em; }
.day-strip .day .num { font-size: .82rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.day-strip .day:hover { background: var(--panel-2); }
.day-strip .day.today { background: var(--accent-bg); }
.day-strip .day.today .lbl,
.day-strip .day.today .num { color: var(--accent); }
.day-strip .day.has-route .num::after {
  content: ""; display: block; width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent); margin: 2px auto 0;
}
.day-strip .day.selected { background: var(--accent); }
.day-strip .day.selected .lbl,
.day-strip .day.selected .num { color: #1a1305; }

/* --- icon buttons --- */
.topbar .icon-btn {
  background: transparent; border: 0; color: var(--muted); cursor: pointer;
  width: 2rem; height: 2rem; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.topbar .icon-btn:hover { color: var(--ink); background: var(--panel-2); }
.topbar .icon-btn.active { color: var(--accent); }
.topbar .dot { font-size: .65rem; color: var(--muted); }
.topbar .dot.online { color: var(--delivered); }
.topbar .dot.offline { color: var(--pending); }
.topbar .dot.pending { color: var(--accent); }

/* =========================================================================
   SHELL — surface switching (one visible surface fills viewport under topbar)
   ========================================================================= */
main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.surface { flex: 1 1 auto; min-height: 0; display: none; }
.surface.active { display: flex; flex-direction: column; }

/* =========================================================================
   INGEST — empty state (§6 voice: instructions, not apologies)
   ========================================================================= */
#ingest-view { align-items: center; justify-content: center; padding: 2rem; }
.ingest-card {
  max-width: 28rem; width: 100%; text-align: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
}
.ingest-card .icon {
  width: 3rem; height: 3rem; margin: 0 auto 1.2rem;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--accent-bg);
}
.ingest-card .icon svg { width: 1.5rem; height: 1.5rem; }
.ingest-card h2 {
  margin: 0 0 .5rem; font-size: 1.2rem; font-weight: 700;
  letter-spacing: -.01em;
}
.ingest-card .hint { color: var(--muted); font-size: .85rem; margin: 0 0 1.6rem; line-height: 1.6; }
.ingest-card .file-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .8rem 1.5rem;
  background: var(--accent); color: #1a1305;
  border-radius: var(--radius); font-weight: 600; font-size: .9rem;
  cursor: pointer; transition: filter .12s, transform .12s;
  border: 0;
}
.ingest-card .file-btn:hover { filter: brightness(1.08); }
.ingest-card .file-btn:active { transform: scale(.98); }
.ingest-summary {
  background: var(--bg); border: 1px solid var(--line);
  padding: .8rem 1rem; border-radius: var(--radius-sm); white-space: pre-wrap;
  margin-top: 1.2rem; text-align: left; font-size: .82rem; color: var(--muted);
  font-family: var(--font-mono);
}

/* =========================================================================
   ROUTE PLANNER (desktop ≥768px) — three panes: list · map · detail
   ========================================================================= */
#planner-view { flex-direction: row; min-height: 0; }
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }

/* --- left: stop list --- */
.pane-list {
  width: 20rem; flex: 0 0 auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

/* search / sort / filter row (§4.1) */
.list-bar {
  padding: .6rem .65rem;
  border-bottom: 1px solid var(--line);
  display: flex; gap: .4rem; align-items: center;
}
.list-bar input[type="search"],
.list-bar select {
  background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--radius-sm); padding: .4rem .5rem; font-size: .82rem;
  transition: border-color .12s;
}
.list-bar input[type="search"] { flex: 1 1 6rem; min-width: 0; }
.list-bar input[type="search"]:focus,
.list-bar select:focus {
  outline: 0; border-color: var(--accent);
}
.list-bar select {
  cursor: pointer; appearance: none;
  padding-right: 1.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%238493a8' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .5rem center;
}
.list-bar .add-btn {
  width: 1.85rem; height: 1.85rem; border-radius: var(--radius-sm);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto; transition: background .12s, color .12s, border-color .12s;
  font-size: .9rem;
}
.list-bar .add-btn:hover {
  background: var(--accent-bg); color: var(--accent); border-color: var(--accent);
}

/* stop list (§4.1: drag handle · status dot · house number · street · distance · chip · badge) */
.stop-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.stop-row {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .65rem .5rem .35rem;
  border-bottom: 1px solid var(--line-soft);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background .1s;
  position: relative;
}
.stop-row:hover { background: var(--panel-2); }
.stop-row.cur {
  background: var(--accent-bg);
  border-left-color: var(--accent);
}
.stop-row.selected { background: rgba(245,185,66,.06); }

/* drag handle (§4.1: reordering re-sequences the route) */
.stop-row .grip {
  color: var(--faint); cursor: grab; flex: 0 0 auto;
  width: 1rem; display: flex; justify-content: center;
  font-size: .75rem; line-height: 1;
  padding-top .1rem;
}
.stop-row .grip:active { cursor: grabbing; }
.stop-row.dragging { opacity: .4; }
.stop-row.drag-over { border-top: 2px solid var(--accent); }

/* status dot */
.stop-row .sdot {
  width: .55rem; height: .55rem; border-radius: 50%; flex: 0 0 auto;
  transition: transform .12s;
}
.stop-row.cur .sdot { transform: scale(1.3); }
.stop-row .sdot-priority {
  box-shadow: 0 0 0 2px var(--accent);
}

/* main text */
.stop-row .main { flex: 1 1 auto; min-width: 0; }
.stop-row .addr {
  display: flex; align-items: baseline; gap: .3rem; min-width: 0;
}
.stop-row .num {
  font-weight: 700; font-variant-numeric: tabular-nums;
  font-size: .88rem; color: var(--ink);
}
.stop-row .street {
  color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: .85rem;
}
.stop-row .sub {
  color: var(--faint); font-size: .72rem; display: flex; gap: .35rem; align-items: center;
  margin-top: .1rem;
}
.stop-row .chips { display: flex; gap: .2rem; flex-wrap: wrap; }
.stop-row .chip {
  font-size: .62rem; padding: .08rem .32rem; border-radius: 3px;
  background: var(--panel-3); color: var(--muted); font-weight: 500;
  font-family: var(--font-mono); letter-spacing: .02em;
}

/* distance from previous stop */
.stop-row .dist {
  color: var(--faint); font-size: .72rem; font-variant-numeric: tabular-nums;
  flex: 0 0 auto; font-family: var(--font-mono);
}

/* remove button */
.stop-row .rm {
  color: var(--faint); opacity: 0; cursor: pointer; font-size: .8rem;
  flex: 0 0 auto; width: 1.2rem; text-align: center;
  transition: opacity .1s, color .1s;
}
.stop-row:hover .rm { opacity: .5; }
.stop-row .rm:hover { color: var(--issue); opacity: 1; }

/* bulk-select checkbox (§4.1: multi-select enables bulk actions) */
.stop-row .ck {
  flex: 0 0 auto; margin: 0; accent-color: var(--accent);
  cursor: pointer;
}
.stop-row .ck.hidden { display: none; }

/* status dot colors */
.sdot-delivered     { background: var(--c-delivered); }
.sdot-not_home      { background: var(--c-not_home); }
.sdot-refused       { background: var(--c-refused); }
.sdot-wrong_address { background: var(--c-wrong_address); }
.sdot-skipped       { background: var(--c-skipped); }
.sdot-pending       { background: var(--c-pending); }

/* bulk action bar */
.bulk-bar {
  display: none; align-items: center; gap: .5rem;
  padding: .5rem .65rem; background: var(--panel-2);
  border-top: 1px solid var(--line);
  font-size: .8rem; color: var(--muted);
}
.bulk-bar.show { display: flex; }
.bulk-bar .bulk-count { font-weight: 600; color: var(--ink); }
.bulk-bar .bulk-actions { display: flex; gap: .35rem; margin-left: auto; }
.bulk-bar .bulk-btn {
  padding: .3rem .55rem; border-radius: var(--radius-xs);
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  font-size: .75rem; cursor: pointer; transition: background .12s;
}
.bulk-bar .bulk-btn:hover { background: var(--panel-3); }
.bulk-bar .bulk-btn.danger:hover { border-color: var(--issue); color: var(--issue); }

/* =========================================================================
   MAP (center pane)
   ========================================================================= */
.pane-map { flex: 1 1 auto; background: var(--bg); position: relative; }
.pane-map .maplibregl-map { position: absolute; inset: 0; }
#planner-map, #replay-map, #nav-map { width: 100%; height: 100%; }

/* floating locate/search button (§4.2) */
.map-fab {
  position: absolute; bottom: 1rem; right: 1rem; z-index: 5;
  width: 2.6rem; height: 2.6rem; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); transition: background .12s, color .12s;
}
.map-fab:hover { background: var(--panel-2); color: var(--accent); }

/* =========================================================================
   DETAIL PANEL (right) — stop detail + stats + donut + layers
   ========================================================================= */
.pane-detail {
  width: 20rem; flex: 0 0 auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
}

/* empty state */
.detail-empty {
  color: var(--faint); padding: 3rem 1.5rem; font-size: .85rem;
  text-align: center; line-height: 1.6;
}

/* detail header */
.detail-head { padding: 1rem .9rem .6rem; }
.detail-head .dh-num {
  font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.detail-head .dh-street { color: var(--muted); font-size: .9rem; margin-top: .1rem; }
.detail-head .dh-meta {
  color: var(--faint); font-size: .75rem; margin-top: .35rem;
  display: flex; gap: .5rem; align-items: center;
}
.detail-head .dh-meta .sep { color: var(--line); }

/* product chips in detail */
.detail-chips { display: flex; gap: .3rem; flex-wrap: wrap; padding: 0 .9rem .6rem; }
.detail-chips .chip {
  font-size: .68rem; padding: .15rem .45rem; border-radius: 4px;
  background: var(--panel-2); color: var(--accent); font-weight: 600;
  font-family: var(--font-mono); letter-spacing: .03em;
  border: 1px solid var(--line);
}

/* editable fields (§4.3: all directly editable inline) */
.detail-body { padding: 0 .9rem; }
.detail-body .field { margin-bottom: .85rem; }
.detail-body .field label {
  display: block; color: var(--muted); font-size: .72rem;
  margin-bottom: .25rem; text-transform: uppercase; letter-spacing: .04em;
  font-weight: 600;
}
.detail-body .field input,
.detail-body .field textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--radius-sm); padding: .45rem .55rem; font-size: .85rem;
  transition: border-color .12s;
}
.detail-body .field input:focus,
.detail-body .field textarea:focus { outline: 0; border-color: var(--accent); }
.detail-body .field textarea { resize: vertical; min-height: 3rem; line-height: 1.5; }

/* autosave flash (§4.3: brief "saved" flash, no save button) */
.detail-body .saved-flash {
  color: var(--delivered); font-size: .72rem; opacity: 0;
  transition: opacity .2s; margin-top: .2rem;
  display: inline-flex; align-items: center; gap: .25rem;
}
.detail-body .saved-flash.show { opacity: 1; }

/* subscription day toggle chips (§4.3: Mon-Sun toggle chips) */
.day-toggles { display: flex; gap: .2rem; }
.day-toggles .dt {
  flex: 1; text-align: center; padding: .3rem 0;
  border-radius: var(--radius-xs); font-size: .72rem; font-weight: 600;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
  cursor: pointer; transition: all .12s;
}
.day-toggles .dt:hover { border-color: var(--accent); color: var(--ink); }
.day-toggles .dt.on {
  background: var(--accent); color: #1a1305; border-color: var(--accent);
}

/* status control (§4.3) */
.status-row { display: flex; gap: .3rem; flex-wrap: wrap; }
.status-btn {
  flex: 1; padding: .4rem .3rem; border-radius: var(--radius-sm);
  font-size: .72rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted);
  transition: all .12s; text-align: center; white-space: nowrap;
}
.status-btn:hover { border-color: var(--ink); color: var(--ink); }
.status-btn.active {
  border-color: var(--accent); background: var(--accent-bg); color: var(--accent);
}
.status-btn.active.delivered { border-color: var(--delivered); background: rgba(74,222,128,.1); color: var(--delivered); }
.status-btn.active.issue { border-color: var(--issue); background: rgba(192,86,74,.1); color: var(--issue); }

/* danger zone */
.detail-body .danger-zone { margin-top: 1.2rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.detail-body .btn-danger {
  width: 100%; padding: .5rem; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid var(--line); color: var(--issue);
  font-size: .8rem; font-weight: 600; cursor: pointer; transition: all .12s;
}
.detail-body .btn-danger:hover { background: rgba(192,86,74,.1); border-color: var(--issue); }

/* --- stat cards (§4.3: icon-stat cards) + donut (§4.3: weekly split) --- */
.detail-stats {
  padding: .8rem .9rem; border-top: 1px solid var(--line); margin-top: .4rem;
}
.detail-stats .stats-head {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--faint); font-weight: 600; margin-bottom: .6rem;
}
.stat-cards { display: flex; gap: .5rem; margin-bottom: .8rem; }
.stat-card {
  flex: 1; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: .6rem .55rem;
}
.stat-card .sc-label { font-size: .62rem; color: var(--faint); text-transform: uppercase; letter-spacing: .03em; }
.stat-card .sc-val {
  font-size: 1.1rem; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums; margin-top: .15rem;
}
.stat-card .sc-sub { font-size: .65rem; color: var(--muted); margin-top: .1rem; }

/* donut chart (SVG, §4.3: delivered / skipped / missed split) */
.donut-row { display: flex; gap: .8rem; align-items: center; }
.donut-row .donut { width: 3.5rem; height: 3.5rem; flex: 0 0 auto; }
.donut-row .donut-legend {
  flex: 1; display: flex; flex-direction: column; gap: .2rem;
}
.donut-row .dl-row {
  display: flex; align-items: center; gap: .4rem; font-size: .72rem; color: var(--muted);
}
.donut-row .dl-row .dl-dot { width: .5rem; height: .5rem; border-radius: 50%; flex: 0 0 auto; }
.donut-row .dl-row .dl-val { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }

/* --- layers panel (§4.4: toggle rows with colored dot + switch) --- */
.layers {
  padding: .8rem .9rem; border-top: 1px solid var(--line);
}
.layers h4 {
  margin: 0 0 .5rem; font-size: .68rem; color: var(--faint);
  text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
}
.layer-row {
  display: flex; align-items: center; gap: .5rem;
  padding: .3rem 0; font-size: .8rem;
}
.layer-row .ldot { width: .55rem; height: .55rem; border-radius: 50%; flex: 0 0 auto; }
.layer-row .ldot.outline { background: transparent; border: 2px solid var(--accent); }
.layer-row .lname { flex: 1; color: var(--ink); }

/* toggle switch */
.switch { position: relative; width: 2.1rem; height: 1.15rem; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--line); border-radius: 999px;
  transition: background .15s; cursor: pointer;
}
.switch .slider::before {
  content: ""; position: absolute; width: .85rem; height: .85rem;
  left: .15rem; top: .15rem; background: var(--muted); border-radius: 50%;
  transition: transform .15s, background .15s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(.95rem); background: #1a1305; }

/* =========================================================================
   DELIVERY MODE (mobile, <768px) — full-bleed map, one-stop-at-a-time
   ========================================================================= */
#nav-view { position: relative; background: var(--bg); }
#nav-map { position: absolute; inset: 0; }

/* progress strip (§5.2: "Stop 14 of 42" — small, top) */
.nav-progress {
  position: absolute; top: .6rem; left: 50%; transform: translateX(-50%);
  background: rgba(10,15,28,.88); border: 1px solid var(--line);
  padding: .3rem .8rem; border-radius: 999px; font-size: .72rem;
  z-index: 5; backdrop-filter: blur(8px);
  font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink);
  display: flex; gap: .3rem; align-items: center;
}
.nav-progress .np-cur { color: var(--accent); }
.nav-progress .np-sep { color: var(--line); }

/* next-stop card (§5.2: top-left, largest text on the screen) */
.nav-card {
  position: absolute; top: 2.6rem; left: .8rem; right: 3.8rem;
  background: rgba(17,24,39,.94); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .75rem .9rem; z-index: 5;
  backdrop-filter: blur(8px); box-shadow: var(--shadow);
}
.nav-card .nc-top {
  display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem;
}
.nav-card .turn {
  font-size: 1.4rem; line-height: 1; flex: 0 0 auto; color: var(--accent);
  width: 1.6rem; text-align: center;
}
.nav-card .nc-info { flex: 1 1 auto; min-width: 0; }
.nav-card .dist {
  color: var(--accent); font-weight: 700; font-size: .95rem;
  font-variant-numeric: tabular-nums;
}
.nav-card .instr { color: var(--ink); font-size: .85rem; margin-top: .1rem; }

/* the plaque (§6: styled after a physical house-number plaque) */
.nav-card .nc-plaque-row { display: flex; align-items: flex-end; gap: .5rem; }
.nav-card .plaque {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 16vw, 3.5rem); font-weight: 800;
  letter-spacing: .04em; color: var(--accent); line-height: .9;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 12px rgba(245,185,66,.3);
  /* plaque-like treatment: slight inner shadow + border feel */
  padding: .15rem .35rem; border-radius: 4px;
  background: linear-gradient(180deg, rgba(245,185,66,.06) 0%, transparent 100%);
}
.nav-card .street { color: var(--muted); font-size: .82rem; margin-bottom: .2rem; }
.nav-card.arrived { border-color: var(--delivered); }
.nav-card.arrived .plaque {
  color: var(--delivered); text-shadow: 0 2px 14px rgba(74,222,128,.4);
  animation: plaque-pulse 1.2s ease-in-out infinite;
  background: linear-gradient(180deg, rgba(74,222,128,.06) 0%, transparent 100%);
}
.nav-card.arrived .turn { color: var(--delivered); }
.nav-card.offroute { border-color: var(--accent); }
@keyframes plaque-pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* side icon stack (§5.2: recenter, zoom in/out, report issue, settings) */
.nav-icons {
  position: absolute; right: .8rem; top: 2.6rem;
  display: flex; flex-direction: column; gap: .4rem; z-index: 5;
}
.nav-icons button {
  width: 2.6rem; height: 2.6rem; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(17,24,39,.92);
  color: var(--ink); cursor: pointer; backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.nav-icons button:hover { background: var(--panel-2); color: var(--accent); }
.nav-icons button svg { width: 1.1rem; height: 1.1rem; }

/* bottom bar (§5.2: distance · stops remaining · ETA · Mark Delivered) */
.nav-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  background: rgba(10,15,28,.94); border-top: 1px solid var(--line);
  padding: .6rem .8rem calc(.6rem + env(safe-area-inset-bottom));
  backdrop-filter: blur(8px);
}
.nav-status {
  display: flex; gap: 1.2rem; color: var(--muted); font-size: .75rem;
  margin-bottom: .5rem; font-variant-numeric: tabular-nums;
}
.nav-status .ns-item { display: flex; align-items: baseline; gap: .2rem; }
.nav-status .v { color: var(--ink); font-weight: 600; }
.nav-delivered {
  width: 100%; padding: 1rem; border: 0; border-radius: var(--radius);
  background: var(--delivered); color: #052e12;
  font-size: 1rem; font-weight: 800; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  transition: filter .12s, transform .12s;
}
.nav-delivered:active { filter: brightness(.92); transform: scale(.99); }
.nav-mini { display: flex; gap: .4rem; margin-top: .5rem; }
.nav-mini button {
  flex: 1; padding: .5rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--ink); font-size: .75rem; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.nav-mini button:hover { background: var(--panel-2); border-color: var(--accent); }

/* search icon (§5.2: bottom-left, jump out of route order) */
.nav-search {
  position: absolute; left: .8rem; bottom: 5.5rem; z-index: 5;
  width: 2.6rem; height: 2.6rem; border-radius: 50%;
  background: rgba(17,24,39,.92); border: 1px solid var(--line);
  color: var(--ink); cursor: pointer; backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
}
.nav-search:hover { color: var(--accent); }
.nav-search svg { width: 1.1rem; height: 1.1rem; }

/* =========================================================================
   MOBILE DRAWER (collapsible stop list)
   ========================================================================= */
.drawer-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; display: none; }
.drawer-scrim.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(22rem, 88vw);
  background: var(--panel); z-index: 41; transform: translateX(100%);
  transition: transform .22s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; padding: .65rem .75rem;
  border-bottom: 1px solid var(--line); gap: .5rem;
}
.drawer-head h3 { margin: 0; font-size: 1rem; flex: 1; }
.drawer-head .close {
  background: transparent; border: 0; color: var(--muted);
  font-size: 1.3rem; cursor: pointer; width: 2rem; height: 2rem;
  border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
}
.drawer-head .close:hover { background: var(--panel-2); color: var(--ink); }
.drawer .stop-list { flex: 1 1 auto; }

/* =========================================================================
   HISTORY
   ========================================================================= */
#history-view { overflow-y: auto; padding: 1.5rem 1rem; align-items: center; flex-direction: column; }
#history-view h2 { margin: 0 0 1.5rem; font-size: 1.2rem; font-weight: 700; align-self: flex-start; }
.hist-list { list-style: none; margin: 0; padding: 0; width: 100%; max-width: 36rem;
  display: flex; flex-direction: column; gap: .5rem; }
.hist-row {
  display: flex; gap: 1rem; padding: .9rem 1rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--panel); cursor: pointer;
  align-items: center; transition: background .12s, border-color .12s;
}
.hist-row:hover { background: var(--panel-2); border-color: var(--accent); }
.hist-date { flex: 0 0 6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hist-stat { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: .85rem; }

/* =========================================================================
   SETTINGS
   ========================================================================= */
#settings-view { overflow-y: auto; padding: 1.5rem; align-items: center; }
.settings-card {
  max-width: 28rem; width: 100%; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem;
}
.settings-card h2 { margin: 0 0 .5rem; font-size: 1.1rem; font-weight: 700; }
.settings-card .hint { margin: 0 0 1.2rem; font-size: .82rem; }
#settings-form { display: flex; flex-direction: column; gap: .85rem; }
#settings-form label {
  display: flex; flex-direction: column; gap: .25rem; color: var(--muted); font-size: .78rem;
}
#settings-form input {
  padding: .5rem .6rem; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--ink); font-size: .85rem;
}
#settings-form input:focus { outline: 0; border-color: var(--accent); }
#settings-form .btn-row { display: flex; gap: .5rem; margin-top: .4rem; }

/* =========================================================================
   BUTTONS (shared)
   ========================================================================= */
.btn {
  padding: .5rem .9rem; border: 0; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--accent); color: #1a1305; font-weight: 600; font-size: .85rem;
  transition: filter .12s, transform .12s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.98); }
.btn.secondary { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { background: var(--panel-3); }

#replay-view { flex-direction: column; }

/* =========================================================================
   RESPONSIVE — below 768px the planner is not offered
   ========================================================================= */
@media (max-width: 767px) {
  #planner-view.pane-mode { display: none; }
  .day-strip { display: none; }  /* day strip is a planner feature */
}

/* MapLibre attribution restyle for dark bg */
.maplibregl-ctrl-attrib { background: rgba(10,15,28,.7) !important; }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }