:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #16a34a;
  --accent-text: #ffffff;
  --red: #dc2626;
  --yellow: #eab308;
  --green: #22c55e;
  --warn-bg: #fef9c3;
  --warn-text: #713f12;
  --error-bg: #fee2e2;
  --error-text: #7f1d1d;
  --topbar: #0f172a;
  --topbar-text: #e2e8f0;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 4px 16px rgb(15 23 42 / 6%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --surface: #111a2e; --surface-2: #17223a; --text: #e2e8f0; --muted: #94a3b8;
    --border: #233150; --warn-bg: #3a2f0b; --warn-text: #fde68a; --error-bg: #3b1212; --error-text: #fecaca;
    --topbar: #060b16; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #111a2e; --surface-2: #17223a; --text: #e2e8f0; --muted: #94a3b8;
  --border: #233150; --warn-bg: #3a2f0b; --warn-text: #fde68a; --error-bg: #3b1212; --error-text: #fecaca;
  --topbar: #060b16; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--topbar); color: var(--topbar-text);
  padding-top: max(10px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 17px; font-weight: 400; white-space: nowrap; }
.data-status { font-size: 12.5px; text-align: right; color: #cbd5e1; display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: flex-end; }
.data-status b { color: #fff; font-weight: 600; }
.data-status .pill { background: #a16207; color: #fff; padding: 1px 7px; border-radius: 99px; font-weight: 600; }
.data-status .pill.bad { background: var(--red); }

.layout { flex: 1; display: grid; grid-template-columns: 390px 1fr; min-height: 0; }
.panel { overflow-y: auto; padding: 16px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.map { min-height: 300px; }

.field { display: flex; flex-direction: column; gap: 5px; border: 0; padding: 0; margin: 0; position: relative; }
.field-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 0; }
input[type="text"], select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; min-height: 42px;
}
input[type="text"]:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.input-row { display: flex; gap: 6px; }
.input-row input { flex: 1; min-width: 0; }

.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 8px; padding: 9px 12px; min-height: 42px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }

/* Line icons (icons.js), drawn in the text colour */
.ico { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.22em; }
.with-icon, .chip-label { display: inline-flex; align-items: center; gap: .35em; }
.ico.warn { color: #d97706; margin: 0 .1em; }
.stops .num .ico, .pin .ico { width: 13px; height: 13px; vertical-align: 0; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.whatsapp { background: #25d366; color: #052e16; border-color: #25d366; }
.btn.block { width: 100%; }
.plan-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.btn.small { min-height: 34px; padding: 5px 10px; font-size: 13.5px; }

.results { list-style: none; margin: 0; padding: 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); max-height: 220px; overflow-y: auto; }
.results li button { all: unset; display: block; width: 100%; box-sizing: border-box; padding: 8px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.results li button:hover, .results li button:focus { background: var(--surface-2); }
.place-title { display: block; font-weight: 600; }
.place-area { display: block; font-size: 12.5px; color: var(--muted); }
.input-row { position: relative; }
.input-row > .results { position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 1500; }
.chosen { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.chosen::before { content: "✓"; color: var(--accent); font-weight: 700; }

.help { font-size: 13.5px; color: var(--muted); }
.help summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.help ol { padding-left: 20px; margin: 8px 0; }
.help p { margin: 6px 0 0; }
.hint { margin: -4px 0 0; font-size: 13px; color: var(--muted); }

.card { display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
/* Tabs: Trip, Map, Rate, Help. One job on screen at a time. */
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; margin: 0;
  background: var(--surface-2); border-radius: 12px; position: sticky; top: 0; z-index: 6; }
.tabs button { font: inherit; font-size: 12.5px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 52px; padding: 6px 2px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.tabs button span { font-size: 20px; display: inline-flex; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs button[aria-selected="true"] span { color: var(--accent); }
.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pane { display: flex; flex-direction: column; gap: 12px; }
.panel > *, .pane > * { flex-shrink: 0; } /* scroll the panel; never squash what's in it */

/* Trip: A, stops, B as one stack of rows */
.route-stack { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.route-badge { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
  border-radius: 50%; color: #fff; font: 700 11px/1 system-ui, sans-serif; font-style: normal; }
.route-badge.a { background: #2563eb; }
.route-badge.b { background: #0f172a; box-shadow: inset 0 0 0 1.5px #fff; }
.stop-field .input-row { align-items: center; }
.stop-field .route-badge { width: 26px; height: 26px; font-size: 13px; margin: 0; flex: none; }
.stop-field .chosen { padding-left: 32px; }
.btn.icon { min-width: 42px; padding: 9px; }
.btn.icon .ico { width: 1.25em; height: 1.25em; }
.stack-foot { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding-left: 32px; }
.stack-foot .help { text-align: right; }
.stack-foot .help[open] { flex-basis: 100%; text-align: left; }
.link-btn { font: inherit; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; padding: 4px 0;
  border: 0; background: none; color: var(--accent); cursor: pointer; }
.route-badge.via { background: #7c3aed; }
.route-badge.via .ico { width: 13px; height: 13px; }
.via-field .via-name { margin: 6px 0 0 32px; width: calc(100% - 32px); }

/* Options, folded to one line that says what's set */
.options { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.options > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; cursor: pointer; font-weight: 600; }
.options > summary::-webkit-details-marker { display: none; }
.options > summary::after { content: ""; width: 8px; height: 8px; border: solid var(--muted); border-width: 0 2px 2px 0;
  transform: rotate(45deg); margin: -4px 4px 0 0; transition: transform .15s; flex: none; }
.options[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
.options > summary .ico { color: var(--accent); }
.options-summary { flex: 1; text-align: right; font-size: 13px; font-weight: 500; color: var(--muted); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.options-body { display: flex; flex-direction: column; gap: 14px; padding: 0 14px 14px; }
.options .field-label { color: var(--text); }

/* Map: what shows, as rows with switches */
.search-row input { border-radius: 999px; padding-left: 16px; }
.layer-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.layer-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.layer-row + .layer-row { border-top: 1px solid var(--border); }
.layer-icon { font-size: 20px; display: inline-flex; color: var(--accent); flex: none; }
.layer-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; font-size: 14px; }
.people-line { display: inline-flex; align-items: center; gap: 6px; }
.switch { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--border);
  position: relative; cursor: pointer; flex: none; margin: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 30%); transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Rate: the two rules, as short facts */
.facts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.facts li { display: inline-flex; align-items: center; gap: 6px; }

/* Help */
.how { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.how li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--muted); }
.how b { display: block; color: var(--text); }
.how-icon { font-size: 20px; display: inline-flex; padding: 8px; border-radius: 10px; flex: none;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.avoid .hint, .when .hint { margin-top: 6px; }

.night-toggle { display: flex; align-items: flex-start; gap: 8px; margin-top: 8px; font-size: 14px; cursor: pointer; }
.night-toggle input { margin-top: 3px; accent-color: var(--accent); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.segmented.three { grid-template-columns: repeat(3, 1fr); }
.segmented label { display: flex; }
.segmented label > span { flex: 1; text-align: center; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 9px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-weight: 500; min-height: 42px; }
.segmented input:checked + span { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.r, .sq.r { background: #ef4444; } .dot.y, .sq.y { background: #facc15; } .sq.g { background: #4ade80; }
.sq.m { background: #a3e635; }
/* FADE's colours from app.js, one quarter per level; red deepens to the worst */
.fade-key { flex-basis: 100%; display: grid; grid-template-columns: repeat(4, 1fr); row-gap: 3px;
  font-size: 11.5px; color: var(--muted); }
.fade-bar { grid-column: 1 / -1; height: 12px; border-radius: 3px;
  background: linear-gradient(90deg, #86efac, #bef264 25%, #fde047 50%, #fb923c 75%, #ef4444 83%, #b91c1c 92%, #7f1d1d); }
.fade-key span { border-left: 1px solid var(--muted); padding-left: 3px; white-space: nowrap; }
.sq.out { background: #0f172a; opacity: 0.45; }
/* Home values (home-values.js): pale yellow to dark blue, log scale R250k to R8m */
.value-bar { grid-column: 1 / -1; height: 12px; border-radius: 3px;
  background: linear-gradient(90deg, #ffffcc, #c7e9b4, #7fcdbb, #41b6c4, #1d91c0, #225ea8, #0c2c84); }
.stations-toggle { display: flex; align-items: center; gap: 6px; flex-basis: 100%; cursor: pointer; }
.station-dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid #0f172a; background: #fff; display: inline-block; }
.coverage { flex-basis: 100%; font-size: 12.5px; }
.coverage summary { cursor: pointer; color: var(--text); }
.coverage p { margin: 6px 0 0; color: var(--muted); }
.about { padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; }
.about h2 { margin: 0 0 4px; font-size: 13px; }
.about p { margin: 0 0 6px; color: var(--muted); }
.about details { margin-top: 4px; }
.about summary { cursor: pointer; }
.about summary h3 { display: inline; margin: 0; font-size: 12.5px; font-weight: 600; }
.about details p { margin: 4px 0 6px; }
.contact { padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.contact h3 { margin: 0 0 2px; font-size: 13px; }
.contact p { margin: 0 0 2px; color: var(--muted); }
.contact a { color: var(--accent); font-weight: 600; overflow-wrap: anywhere; }
.station-popup { min-width: 220px; font-size: 13px; }
.station-popup p { margin: 6px 0; }
.station-popup table { border-collapse: collapse; width: 100%; }
.station-popup td { padding: 2px 0; border-top: 1px solid #e2e8f0; }
.station-popup td:last-child { text-align: right; font-weight: 600; padding-left: 10px; }

.banner { padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.banner.warn { background: var(--warn-bg); color: var(--warn-text); }
.banner.error { background: var(--error-bg); color: var(--error-text); }

.result { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.result h2 { font-size: 17px; margin: 0; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.result p { margin: 0; }
.warnings { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.warnings li { background: var(--warn-bg); color: var(--warn-text); padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.parts { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.part { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--surface); }
.part.unclear { border-color: var(--yellow); }
.part-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.part-num { font-weight: 700; }
.part-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.part-route { font-size: 14px; margin: 2px 0 8px; overflow-wrap: anywhere; }
.part-links { display: flex; gap: 6px; }
.part-links .btn { flex: 1; }
.stops-box h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 6px; }
.stops { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.stops li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.stops .num { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.stops .name { flex: 1; min-width: 0; }
.btn.remove { min-height: 30px; padding: 3px 10px; font-size: 13px; color: var(--error-text); background: var(--error-bg); border-color: transparent; }
.red-passages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.red-passages button { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  padding: 6px 8px 6px 10px; border: 1px solid var(--border); border-left: 4px solid var(--red); border-radius: 8px;
  background: var(--surface); font-size: 13px; }
.red-passages button:hover { background: var(--surface-2); }
.red-passages .where { display: block; font-weight: 600; font-size: 12.5px; color: var(--muted); }
.share { display: flex; flex-direction: column; gap: 6px; }
.share-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.legend { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.legend p { margin: 0; display: flex; align-items: center; }
.sq { width: 12px; height: 12px; display: inline-block; border-radius: 3px; margin-right: 5px; vertical-align: -1px; opacity: .8; }

.pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: flex; align-items: center; justify-content: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgb(0 0 0 / 35%); }
.pin span { transform: rotate(45deg); color: #fff; font: 700 12px/1 system-ui, sans-serif; }
.pin.start { background: #2563eb; } .pin.end { background: #0f172a; } .pin.stop { background: var(--accent); }
.pin.via { background: #7c3aed; }
.stops .num.via { background: #7c3aed; }
.vias { display: flex; flex-direction: column; gap: 12px; }
.vias:empty { display: none; }
.add-via { align-self: flex-start; margin-top: -4px; }
.via-field .field-label { color: #7c3aed; }
/* Zones blend into the map ("multiply") so labels stay readable, and fade in. */
.zones-heat, .zones-crisp { mix-blend-mode: multiply; transition: opacity 0.4s ease; }
.zones-heat { filter: blur(2px); }
.zones-crisp { image-rendering: auto; }
.style-toggle { display: inline-flex; flex: none; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.style-toggle button { font: inherit; font-size: 12.5px; padding: 4px 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.style-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.map-popup { display: flex; flex-direction: column; gap: 6px; }
.route-popup { gap: 3px; font-size: 13px; }
.route-popup .where { font-weight: 700; font-size: 14px; }
.route-popup .zone { display: flex; align-items: center; gap: 6px; }
.route-popup .zone i { width: 12px; height: 12px; border-radius: 3px; flex: none; border: 1px solid rgb(0 0 0 / 15%); }
.route-popup .why { margin-top: 4px; padding: 4px 0 4px 8px; border-left: 4px solid #dc2626; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 2000; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

.sheet-handle { display: none; }
.place-note { display: block; font-size: 12px; color: var(--warn-text); margin-top: 2px; }
.results .searching { padding: 8px; font-size: 13px; color: var(--muted); }
.chosen { flex-wrap: wrap; }
.chosen .chosen-note { flex-basis: 100%; color: var(--warn-text); font-size: 12px; }
.leaflet-bar:is(.track-control, .draw-control, .contribute-control, .when-control) a,
.leaflet-touch .leaflet-bar:is(.track-control, .draw-control, .contribute-control, .when-control) a { width: auto; white-space: nowrap; padding: 0 9px; gap: 6px; font-size: 13px; font-weight: 600; line-height: 30px; text-decoration: none; }
.track-control a .ico { font-size: 16px; }
.track-control a.active { background: #dbeafe; color: #1d4ed8; }
.track-control a.busy { opacity: .6; }
.leaflet-marker-draggable .pin { cursor: grab; }
/* Long tooltips wrap instead of running off a phone screen. A tooltip opens on
   the side of its pin facing the map's middle, so half the width always fits. */
.leaflet-tooltip { white-space: normal; width: max-content; max-width: min(260px, calc(50vw - 32px)); }

/* Phones: the map fills the screen and the planner is a sheet over it,
   dragged up and down by its handle (peek, half, full). */
@media (max-width: 820px) {
  html, body { overflow: hidden; overscroll-behavior: none; }
  .topbar { padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top)); gap: 8px; }
  .brand { font-size: 15px; }
  .brand img { width: 22px; height: 22px; }
  .data-status { font-size: 11px; gap: 0 8px; }
  .data-status .st-next { display: none; }
  .layout { display: block; position: relative; }
  .map { position: absolute; inset: 0; z-index: 0; min-height: 0; }
  .panel {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; height: 50%; max-height: 100%;
    border-right: 0; border-radius: 16px 16px 0 0; box-shadow: 0 -4px 24px rgb(15 23 42 / 22%);
    padding: 0 16px calc(16px + env(safe-area-inset-bottom)); overscroll-behavior: contain;
    transition: height .25s ease;
  }
  .panel.dragging { transition: none; }
  .panel[data-sheet="peek"] { overflow: hidden; }
  .sheet-handle {
    display: flex; flex-direction: column; align-items: center; gap: 6px; flex: none;
    position: sticky; top: 0; z-index: 5; margin: 0 -16px; padding: 8px 16px 10px;
    background: var(--surface); border-radius: 16px 16px 0 0; cursor: grab; touch-action: none; user-select: none;
  }
  .sheet-handle i { width: 40px; height: 5px; border-radius: 3px; background: var(--border); }
  .sheet-handle span { font-weight: 600; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .panel[data-sheet="full"] .sheet-handle { border-bottom: 0; }
  .tabs { top: var(--handle-h, 56px); outline: 8px solid var(--surface); } /* covers what scrolls under it */
  /* 16px stops iOS zooming in on the box you tap */
  input[type="text"], select, .areas-list input, .via-name { font-size: 16px; }
  .field, .result, .banner, .route-stack, .options { scroll-margin-top: 130px; }
  .results { max-height: 40vh; }
  .results li button { padding: 10px 8px; }
  /* Plan stays in reach at the bottom of the sheet */
  .plan-row { position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); z-index: 4; background: var(--surface);
    margin: 0 -16px; padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
  .panel[data-sheet="peek"] .plan-row, .panel.has-trip .plan-row { position: static; margin: 0; padding: 0; border: 0; }
  .toast { bottom: calc(var(--sheet-h, 0px) + 12px); }
  .leaflet-touch .leaflet-bar a { width: 36px; height: 36px; line-height: 36px; }
  .leaflet-popup-content { margin: 12px 14px; }
  /* a popup is nearly as wide as the screen: the map buttons step aside */
  .map.popup-open .leaflet-top.leaflet-left { opacity: 0; pointer-events: none; transition: opacity .2s; }
}

/* areas to avoid (drawn on the map) */
.areas-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.areas-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.areas-list li { display: flex; align-items: center; gap: 6px; }
.areas-list input { flex: 1; min-width: 0; padding: 6px 8px; font-size: 14px; }
.area-swatch { width: 14px; height: 14px; flex: none; border: 2px dashed #7c3aed; background: rgb(124 58 237 / 0.15); border-radius: 3px; }
.areas-status { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.areas-status.error { color: #f87171; }
.map.drawing, .map.drawing .leaflet-interactive { cursor: crosshair !important; touch-action: none !important; }
.draw-control a { font-size: 16px; line-height: 30px; text-align: center; text-decoration: none; }
.when-control[hidden] { display: none; }
/* while drawing or picking, the banner needs the room: the map buttons drop their words */
.map:is(.contributing, .picking, .drawing) .leaflet-left .leaflet-bar a span { display: none; }
.draw-control a, .track-control a, .contribute-control a, .when-control a { display: flex; align-items: center; justify-content: center; color: #0f172a; }
.draw-control a.active { background: #ede9fe; }
.draw-banner { display: flex; align-items: center; gap: 8px; background: #fff; color: #0f172a; padding: 6px 8px 6px 12px;
  border-radius: 8px; box-shadow: 0 2px 8px rgb(0 0 0 / 0.25); font-size: 13px; font-weight: 600; }
.via-name { width: 100%; margin-top: 6px; padding: 6px 8px; font-size: 14px; }
.btn.rename { padding: 4px 8px; }
.stops-box h3 .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }

/* A police area's figures (and people's ratings), in the map and station popups */
.area-box { margin-top: 8px; padding-top: 8px; border-top: 1px solid #e2e8f0; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.area-box p { margin: 0; }
.area-head { font-size: 13px; }
.area-police { margin-top: 4px !important; }
.area-error { color: #b91c1c; }

/* People's ratings: tracing roads, painting areas, reports, safe stops */
.contribute { display: flex; flex-direction: column; gap: 12px; }
.contrib-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.contrib-head h2 { margin: 0; font-size: 17px; }
.contrib-tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.contrib-tools button { font: inherit; font-size: 12px; font-weight: 600; display: flex; flex-direction: column; align-items: center;
  gap: 2px; min-height: 64px; padding: 8px 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  color: var(--text); cursor: pointer; text-align: center; line-height: 1.2; }
.contrib-tools button span { font-size: 20px; display: inline-flex; }
.contrib-tools button[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent); }
.contrib-body { display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.contrib-body p { margin: 0; }
.contrib-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.contrib-actions .btn { flex: 1 1 auto; }
.chip-row { display: flex; flex-direction: column; gap: 4px; }
.chip-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.chip { font: inherit; font-size: 12px; font-weight: 600; min-height: 44px; padding: 4px 2px; line-height: 1.15; border-radius: 8px;
  border: 1px solid var(--border); border-bottom: 4px solid var(--lvl); background: var(--surface); color: var(--text); cursor: pointer; }
.chip { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.chip-ico { width: 15px; height: 15px; opacity: .85; }
.chip[aria-pressed="true"] { background: var(--lvl); border-color: var(--lvl); color: #fff; }
.lvl-1 { --lvl: #16a34a; } .lvl-2 { --lvl: #65a30d; } .lvl-3 { --lvl: #ca8a04; } .lvl-4 { --lvl: #ea580c; } .lvl-5 { --lvl: #991b1b; }
.kind-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.kind { font: inherit; font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); cursor: pointer; text-align: left; }
.kind-icon { font-size: 20px; display: inline-flex; color: var(--muted); }
.kind[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent); }
.kind[aria-pressed="true"] .kind-icon { color: var(--accent); }
.place-pin { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
  background: #fff; border: 2px solid #2563eb; color: #2563eb; box-shadow: 0 1px 4px rgb(0 0 0 / .35); font-size: 14px; }
.place-pin.risky { border-color: #b91c1c; color: #b91c1c; }
.chips.n4 { grid-template-columns: repeat(4, 1fr); }
.place-ways { display: flex; flex-direction: column; gap: 6px; }
.place-way { text-align: left; }
.place-way-text { display: flex; flex-direction: column; gap: 2px; font-weight: 400; }
.place-way-text b { font-weight: 600; }
.picked-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.picked-piece { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 6px 10px;
  border: 1px solid var(--border); border-radius: 8px; }
.picked-piece > span { min-width: 0; overflow-wrap: anywhere; }
.fuel-pin { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; border: 2px solid var(--c); color: var(--c); box-shadow: 0 1px 4px rgb(0 0 0 / .35); font-size: 13px; }
.robot-pin { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 2px solid var(--c); color: var(--c); box-shadow: 0 1px 4px rgb(0 0 0 / .35); font-size: 12px; }
.rank-pin { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 6px;
  background: #fef3c7; border: 2px solid #b45309; color: #b45309; box-shadow: 0 1px 4px rgb(0 0 0 / .35); font-size: 12px; }
.fuel-box summary { cursor: pointer; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 4px 0; }
.fuel-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.fuel-item { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.fuel-head { display: flex; align-items: center; gap: 8px; }
.fuel-dot { display: inline-flex; color: var(--c); font-size: 18px; }
.fuel-rate { display: flex; flex-direction: column; gap: 8px; }
.fuel-popup { display: flex; flex-direction: column; gap: 6px; min-width: 240px; }
.mine-head { margin: 4px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.mine-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mine-item { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.mine-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.contribute-control a { font-size: 16px; line-height: 30px; text-align: center; text-decoration: none; }
.contrib-banner { flex-wrap: wrap; max-width: min(360px, calc(100vw - 80px)); user-select: none; -webkit-user-select: none; }
.contrib-banner > span { flex: 1 1 100%; }
.banner-buttons { display: flex; flex-wrap: wrap; gap: 4px; }
.banner-buttons .btn { min-height: 40px; min-width: 40px; background: #f1f5f9; color: #0f172a; border-color: #cbd5e1; }
.banner-buttons .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.contrib-done { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 8px 0; }
.contrib-done .done-tick { display: inline-flex; font-size: 28px; color: #fff; background: #16a34a; border-radius: 50%; padding: 10px; }
.contrib-done .contrib-actions { width: 100%; }
.banner-buttons .btn[aria-pressed="true"] { background: #7c3aed; border-color: #7c3aed; color: #fff; }
.map.contributing, .map.contributing .leaflet-interactive { cursor: crosshair !important; touch-action: none !important; }
.map.picking { cursor: crosshair; }
.crowd-pin { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .4); font-size: 15px; color: #b91c1c; }
.crowd-pin.stop { width: 26px; height: 26px; font-size: 13px; border: 2px solid #16a34a; color: #15803d; }
.crowd-pin.faint { opacity: .55; }
.area-people { font-weight: 600; }
.people-key { display: inline-flex; width: 50px; height: 10px; border-radius: 3px; overflow: hidden; flex: none; }
.people-key b { flex: 1; }
.people-key .l1 { background: #16a34a; } .people-key .l2 { background: #84cc16; } .people-key .l3 { background: #eab308; }
.people-key .l4 { background: #f97316; } .people-key .l5 { background: #991b1b; }
@media (max-width: 420px) {
  .contrib-tools { grid-template-columns: repeat(2, 1fr); }
  .chip { font-size: 11px; }
}

/* Privacy and terms pages */
.text-page { overflow: auto; }
.text-page .brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.text-main { max-width: 760px; margin: 0 auto; padding: 16px; }
.text-card { gap: 6px; line-height: 1.55; }
.text-card h1 { margin: 0 0 4px; font-size: 24px; }
.text-card h2 { margin: 14px 0 0; font-size: 17px; }
.text-card p, .text-card ul { margin: 0; }
.text-card a { color: var(--accent); }

/* The tour (tour.js) */
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tour { position: fixed; z-index: 3000; left: 50%; bottom: 24px; transform: translateX(-50%); width: min(420px, calc(100vw - 24px));
  display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 14px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: 0 10px 40px rgb(0 0 0 / .35); }
.tour p { margin: 0; font-size: 14.5px; line-height: 1.45; }
.tour-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 16px; }
.tour-head .ico { color: var(--accent); }
.tour-actions { display: flex; gap: 6px; justify-content: flex-end; }
.tour-ring { outline: 3px solid var(--accent) !important; outline-offset: 3px; border-radius: 12px;
  box-shadow: 0 0 0 9999px rgb(15 23 42 / .35); position: relative; z-index: 2; transition: box-shadow .2s; }
#map.tour-ring { outline-offset: -3px; box-shadow: none; }
@media (min-width: 821px) { .tour { left: auto; right: 24px; transform: none; } }
@media (max-width: 820px) { .tour { top: 64px; bottom: auto; } .tour-ring { scroll-margin-top: 230px; } }

/* Must-accept disclaimer before planning a route */
.disclaimer { width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 18px;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text);
  box-shadow: 0 10px 40px rgb(0 0 0 / .35); }
.disclaimer::backdrop { background: rgb(15 23 42 / .55); }
.disclaimer h2 { margin: 0 0 10px; font-size: 18px; }
.disclaimer h2 .ico { color: var(--accent); }
.disclaimer p, .disclaimer li { font-size: 14.5px; line-height: 1.45; }
.disclaimer p { margin: 0 0 8px; }
.disclaimer ul { margin: 0 0 10px; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.disclaimer a { color: var(--accent); }
.disclaimer-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 12px; }
@media (max-width: 420px) { .disclaimer-actions .btn { flex: 1 1 100%; } .disclaimer-actions .primary { order: -1; } }

/* pins seen from far out: a small dot, so a few of them don't hide a city */
.crowd-pin.far, .place-pin.far { width: 10px; height: 10px; border: 2px solid #fff; background: #b91c1c; box-shadow: 0 0 2px rgb(0 0 0 / .5); }
.crowd-pin.stop.far { background: #16a34a; }
.place-pin.far:not(.risky) { background: #2563eb; }
/* after rating: how many of the people it needs have rated it */
.people-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 5px; font-size: 13px; }
.people-bar i { width: 22px; height: 8px; border-radius: 4px; background: #cbd5e1; }
.people-bar i.on { background: #16a34a; }
.people-bar span { flex-basis: 100%; }
.area-note { margin-top: 6px !important; }

/* "How this colour is worked out" in an area popup */
.how { margin-top: 8px; border-top: 1px solid rgb(127 127 127 / .25); padding-top: 6px; font-size: 12px; }
.how summary { cursor: pointer; font-weight: 600; color: var(--accent, #2563eb); }
.how-step { margin-top: 8px; }
.how-step p { margin: 3px 0 0 !important; }
.how-table { width: 100%; border-collapse: collapse; margin-top: 4px; font-variant-numeric: tabular-nums; }
.how-table th, .how-table td { padding: 2px 4px; text-align: right; border-bottom: 1px solid rgb(127 127 127 / .15); }
.how-table th:first-child, .how-table td:first-child { text-align: left; }
.how-table tfoot th { border-bottom: 0; }
.how-list { margin: 6px 0 0; padding-left: 18px; }
.how-list li { margin-bottom: 4px; }
.how-step > b { display: block; color: #0f172a; font-size: 12.5px; }

/* "How was your trip?" */
.ask-feedback { margin-bottom: 10px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--accent, #22c55e) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #22c55e) 35%, transparent); display: flex; flex-direction: column; gap: 6px; }
.ask-feedback p { margin: 0; }
.ask-row { display: flex; flex-wrap: wrap; gap: 6px; }
.btn.link { background: none; border: 0; padding: 0; text-decoration: underline; align-self: flex-start; }
.btn.warn { border-color: #dc2626; color: #dc2626; }
.confidence b { padding: 0 6px; border-radius: 6px; color: #fff; }
.confidence.high b { background: #15803d; }
.confidence.medium b { background: #b45309; }
.confidence.low b { background: #b91c1c; }
.acc-line { display: block; margin-top: 4px; }

/* ---------- Home values section (/home-values/) ---------- */
.site-nav { display: flex; gap: 4px; margin-right: auto; margin-left: 8px; }
.site-nav a { color: #cbd5e1; text-decoration: none; font-size: 14px; padding: 5px 10px; border-radius: 99px; white-space: nowrap; }
.site-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.site-nav a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, 0.14); font-weight: 600; }
.hv-page .topbar { justify-content: flex-start; }
.hv-main { max-width: 1040px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 22px; width: 100%; box-sizing: border-box; }
.hv-main h1 { margin: 0 0 6px; font-size: 26px; line-height: 1.2; }
.hv-main h2 { margin: 0 0 10px; font-size: 18px; }
.hv-main p { margin: 0; line-height: 1.55; }
.hv-main a { color: var(--accent); }
.hv-intro p { max-width: 70ch; }
.crumbs { color: var(--muted); margin-bottom: -14px; }
.city-list { list-style: none; padding: 0; margin: 0 0 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.hv-main .city-card { display: flex; flex-direction: column; gap: 6px; padding: 16px; text-decoration: none; color: var(--text); }
.city-card:hover { border-color: var(--accent); }
.city-name { font-size: 19px; font-weight: 650; }
.city-go { color: var(--accent); font-weight: 600; font-size: 14px; }
.city-figures { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 6px 0; }
.city-figures > span { display: flex; flex-direction: column; }
.city-figures b { font-size: 17px; }
.city-figures small { color: var(--muted); font-size: 12px; }
.city-figures.wide { margin-top: 14px; }
.hv-map-wrap { padding: 0; overflow: hidden; gap: 0; }
.hv-map { height: min(62vh, 560px); min-height: 320px; }
.hv-key { padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.hv-key .fade-key { max-width: 460px; }
.hv-tip { font-size: 13px; line-height: 1.4; }
.hv-tip .muted { color: #64748b; }
.hv-filter { display: flex; flex-direction: column; gap: 4px; max-width: 320px; margin-bottom: 10px; }
.hv-filter input { font: inherit; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.hv-table-wrap { max-height: 520px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.hv-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.hv-table th, .hv-table td { padding: 8px 12px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.hv-table th:first-child { text-align: left; font-weight: 500; white-space: normal; }
.hv-table thead th { position: sticky; top: 0; background: var(--surface-2); font-size: 12.5px; color: var(--muted); font-weight: 600; }
.hv-table tbody tr[data-lat] { cursor: pointer; }
.hv-table tbody tr:hover, .hv-table tbody tr:focus-visible { background: var(--surface-2); outline: none; }
.hv-sources { margin: 0 0 8px; padding-left: 18px; line-height: 1.8; }
.hv-faq details { border-top: 1px solid var(--border); padding: 10px 0; }
.hv-faq summary { cursor: pointer; }
.hv-faq summary h3 { display: inline; font-size: 15px; margin: 0; }
.hv-faq details p { margin-top: 8px; max-width: 70ch; }
.hv-footer { border-top: 1px solid var(--border); padding-top: 14px; }
@media (max-width: 600px) {
  .hv-main h1 { font-size: 22px; }
  .hv-table th, .hv-table td { padding: 7px 8px; }
  .site-nav { margin-left: 0; }
  .site-nav a { padding: 5px 8px; font-size: 13px; }
}
