:root {
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #5f6f86; /* the small grey print: 5.1 to 1 on white and 4.7 to 1 on the grey panels (#94a3b8 before it was 2.6 to 1, unreadable outdoors) */
  --line: #e2e8f0;
  --bg: #ffffff;
  --bg-2: #f1f5f9;
  --panel: #0f172a; /* the dark panels with white writing: the menu, the brand pill, the status bar; dark in both themes */
  --brand: #ff5a36;
  --brand-ink: #ffffff;
  --green: #16a34a;
  --water: #0284c7;
  --quiet: #8b5cf6;
  --r1: #2563eb;
  --r2: #ea580c;
  --r3: #9333ea;
  --radius: 18px;
  --shadow: 0 10px 40px rgba(15, 23, 42, 0.18);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg-2);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#map { position: fixed; inset: 0; z-index: 0; background: #e5e7eb; }
/* Heading-up during a run: the map's own bearing turns it (street names stay upright). */
body.heading-up .maplibregl-ctrl-attrib { display: none; }
/* Markers: the HTML icons the app draws, centred on their point by the adapter. */
.rtt-marker { display: grid; place-items: center; }
.rtt-marker > * { pointer-events: auto; }
.maplibregl-popup { z-index: 5; font-family: inherit; }
.maplibregl-popup-content { padding: 12px 14px; border-radius: 12px; box-shadow: 0 6px 20px rgba(15, 23, 42, 0.25); font: 13px/1.4 Inter, system-ui, sans-serif; color: var(--ink, #0f172a); }
.maplibregl-popup-close-button { font-size: 18px; padding: 2px 8px; color: #64748b; }
.maplibregl-ctrl-attrib { font-size: 10px; }
.maplibregl-ctrl-group button { width: 36px; height: 36px; }

/* Top bar */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1050; /* above the bottom sheet so suggestions are never hidden */
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 0;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.brand {
  pointer-events: auto; align-self: flex-start; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--panel); color: #fff; padding: 6px 12px 6px 10px; border-radius: 999px; min-height: 44px;
}
.brand .logo { height: 28px; }
.mode-badge { font-size: 12px; font-weight: 700; color: #cbd5e1; }
.burger { display: inline-grid; gap: 3px; margin-left: 2px; }
.burger span { display: block; width: 14px; height: 2px; border-radius: 2px; background: #fff; }
.logo { display: block; width: auto; height: 34px; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.search {
  pointer-events: auto; display: flex; align-items: center; gap: 8px;
  background: var(--bg); border-radius: 14px; padding: 4px 4px 4px 14px; box-shadow: var(--shadow);
}
.search > svg { width: 18px; height: 18px; color: var(--ink-3); flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; font: inherit; font-size: 16px; padding: 10px 0; background: transparent;
}
.icon-btn {
  flex: none; width: 44px; height: 44px; border: 0; border-radius: 11px;
  background: var(--bg-2); display: grid; place-items: center;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.busy svg { animation: pulse 1s infinite; }
.search-results {
  pointer-events: auto; list-style: none; margin: 0; padding: 6px; background: var(--bg);
  border-radius: 14px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto;
}
.search-results li {
  display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 10px; cursor: pointer;
  font-size: 15px; line-height: 1.3;
}
.search-results li.active, .search-results li:hover { background: var(--bg-2); }
.search-results li.muted { color: var(--ink-3); cursor: default; background: none; }
.search-results .ico {
  flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--bg-2); color: var(--ink-2);
  display: grid; place-items: center;
}
.search-results li.active .ico, .search-results li:hover .ico { background: #fff; }
.search-results .ico svg { width: 16px; height: 16px; }
.search-results .ico.loc { color: #2563eb; }
.search-results .txt { min-width: 0; }
.search-results .main { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results .main b { font-weight: 700; }
.search-results small { display: block; color: var(--ink-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results .powered { font-size: 11.5px; color: var(--ink-3); text-align: right; padding: 4px 8px 2px; cursor: default; display: block; }
.clear-btn { flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--ink-3); display: grid; place-items: center; }
.clear-btn svg { width: 16px; height: 16px; }

/* Bottom sheet: three heights (peek / half / full), dragged by the handle or tapped through. */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  background: var(--bg); border-radius: var(--radius) var(--radius) 0 0; box-shadow: var(--shadow);
  padding: 0 16px calc(16px + var(--safe-b)); max-height: 62vh; overflow-y: auto;
  transition: max-height 0.25s ease;
}
.sheet[data-pos='peek'] { max-height: var(--peek, 150px); overflow: hidden; }
.sheet[data-pos='half'] { max-height: 50vh; }
.sheet[data-pos='full'] { max-height: 88vh; }
.sheet.dragging { transition: none; }
.grab { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 10px 0 6px; margin: 0 -16px 4px; cursor: grab; touch-action: none; }
.handle { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto; }
/* In peek, the routes are a strip of coloured chips so the map can be read. */
.route-strip { display: none; gap: 8px; overflow-x: auto; padding: 2px 0 8px; margin: 0; }
.route-strip button { flex: none; border: 1.5px solid var(--line); border-radius: 999px; min-height: 40px; padding: 6px 14px; font-size: 13px; font-weight: 600; background: var(--bg); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.route-strip button i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.route-strip button.on { border-color: var(--ink); background: var(--ink); color: #fff; }
.sheet[data-pos='peek'] .route-strip { display: flex; }
.topbar.start-set .search, .topbar.start-set .search-results { display: none; }
.map-back { position: fixed; z-index: 1051; left: 16px; top: calc(env(safe-area-inset-top, 0px) + 64px); border: 0; border-radius: 999px; background: var(--bg); box-shadow: var(--shadow); min-height: 44px; padding: 8px 16px 8px 12px; font-weight: 700; font-size: 13px; display: none; align-items: center; gap: 6px; }
.map-back svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.topbar.start-set ~ .map-back { display: inline-flex; }
body.navigating .map-back { display: none; }
.start-line { font-size: 13px; color: var(--ink-2); margin-bottom: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.start-line b { color: var(--ink); font-weight: 600; }
/* The place name is a link to the search: tap it to pick another start (or finish). */
.start-line { cursor: pointer; }
.start-line b { text-decoration: underline; text-decoration-color: var(--ink-3); text-decoration-thickness: 1px; text-underline-offset: 3px; }

.field { margin-bottom: 16px; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.field-head label { font-weight: 700; font-size: 14px; }
.field-head output { font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.hint { font-size: 12px; color: var(--ink-3); }

.distance-value {
  display: flex; align-items: baseline; justify-content: center; gap: 6px; cursor: text;
  background: var(--bg-2); border-radius: 14px; padding: 6px 14px; border: 2px solid transparent;
}
.distance-value:focus-within { border-color: var(--ink); background: var(--bg); }
.distance-value input {
  width: 1.4ch; min-width: 1.4ch; max-width: 6ch; border: 0; outline: 0; background: transparent; text-align: center; /* the width follows the number (fitDistanceInput) */
  font: 800 34px/1.2 Inter, system-ui, sans-serif; letter-spacing: -0.03em; color: var(--ink); padding: 0;
}
.distance-value input::placeholder { color: var(--ink-3); }
.distance-value span { font-weight: 600; font-size: 17px; color: var(--ink-2); }
.distance-value.invalid { border-color: #dc2626; background: #fef2f2; }
.distance-msg { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; min-height: 1em; }
.distance-msg.error { color: #b91c1c; }

input[type='range'] { width: 100%; accent-color: var(--brand); height: 28px; margin: 0 0 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  border: 1.5px solid var(--line); background: var(--bg); border-radius: 999px;
  padding: 8px 14px; min-height: 44px; font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 8px;
  transition: background 0.15s, border-color 0.15s;
}
.chips.quick button { padding: 5px 14px; min-height: 40px; font-size: 13px; }
/* The pace choices under the minutes: a name with the pace range beneath it. */
.pace-chips { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; }
.pace-chips button { display: block; padding: 7px 12px; text-align: center; line-height: 1.25; }
.pace-chips button:nth-child(5) { grid-column: 1 / -1; } /* the runner's own pace, once the journal has one, across the row */
.pace-chips button small { display: block; font-size: 12px; font-weight: 500; opacity: 0.9; }
.chips button.on, .chips button[aria-pressed='true'] { border-color: var(--ink); background: var(--ink); color: #fff; }
/* Sightseeing is a mode of its own, not a landscape option: Running mode hides it, the tour shows only it (locked on). */
body[data-mode='run'] #landscape [data-pref='sights'] { display: none; }
body[data-mode='tour'] #landscape [data-pref]:not([data-pref='sights']) { display: none; }
body[data-mode='tour'] #landscape [data-pref='sights'] { pointer-events: none; padding-right: 14px; }
body[data-mode='tour'] #landscape [data-pref='sights']::after {
  content: ''; display: inline-block; width: 7px; height: 11px; margin-left: 9px; margin-bottom: 2px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); /* a tick: the tour is on */
}
.tour-note { margin-top: 8px; font-size: 12.5px; line-height: 1.45; color: var(--ink-3); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.green { background: var(--green); }
.dot.water { background: var(--water); }
.dot.quiet { background: var(--quiet); }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg-2); border-radius: 12px; padding: 4px; }
.segmented button { border: 0; background: transparent; padding: 0; min-height: 44px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.segmented button.on { background: var(--bg); color: var(--ink); box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12); }

.primary {
  width: 100%; border: 0; border-radius: 14px; padding: 14px 12px; margin-top: 4px;
  background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: 19px; /* white on this orange is 3.1 to 1: enough for large bold writing (19px bold and up), not for smaller. Keep it at 19px or more. */
}
.primary:disabled { opacity: 0.45; cursor: not-allowed; }

/* Results */
.results-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.back { width: 44px; height: 44px; border: 0; border-radius: 12px; background: var(--bg-2); display: grid; place-items: center; flex: none; }
.back svg { width: 20px; height: 20px; }
.results-title { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.results-sub { font-size: 12px; color: var(--ink-2); }

.cards { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 2px 16px 6px; }
.card {
  flex: 0 0 84%; scroll-snap-align: center; text-align: start; border: 2px solid var(--line); border-radius: 16px;
  background: var(--bg); padding: 14px; display: flex; flex-direction: column; gap: 8px;
}
.card.on { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent); }
.card-top { display: flex; align-items: center; gap: 8px; }
.badge {
  margin-left: auto; flex: none; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: #0369a1; background: #e0f2fe; padding: 3px 7px; border-radius: 6px;
}
.swatch { width: 12px; height: 12px; border-radius: 4px; background: var(--c); flex: none; }
.card-name { font-weight: 700; font-size: 15px; line-height: 1.25; }
.card-dist { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.card-dist small { font-size: 14px; font-weight: 600; color: var(--ink-2); margin-inline-start: 2px; }
.bars { display: flex; height: 6px; border-radius: 6px; overflow: hidden; background: var(--bg-2); }
.bars i { display: block; height: 100%; }
.card ul { margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--ink-2); display: grid; gap: 3px; }
.profile { width: 100%; height: 44px; }
.profile path.area { fill: color-mix(in srgb, var(--c) 16%, transparent); stroke: none; }
.profile path.line { stroke: var(--c); stroke-width: 1.8; fill: none; }

/* Laps: ask for the distance */
.ask { position: fixed; inset: 0; z-index: 1150; background: rgba(15, 23, 42, 0.45); display: grid; place-items: center; padding: 16px; }
.ask-card { background: var(--bg); border-radius: 20px; padding: 20px; width: 100%; max-width: 360px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.ask-title { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.ask-sub { font-size: 14px; color: var(--ink-2); margin-top: -6px; }
.ask .distance-msg { margin-top: -4px; }
.ask-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 8px; align-items: center; }
.ask-actions .primary { margin: 0; }
.ask-actions .ghost { text-decoration: none; background: var(--bg-2); border-radius: 14px; padding: 13px; }

/* Status & toast */
.status {
  position: fixed; z-index: 1100; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: var(--panel); color: #fff; border-radius: 14px; padding: 14px 18px;
  display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow);
  max-width: calc(100vw - 32px);
}
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, 0.25); border-top-color: var(--brand); animation: spin 0.8s linear infinite; flex: none; }
.toast {
  position: fixed; z-index: 1200; left: 16px; right: 16px; top: calc(env(safe-area-inset-top, 0px) + 120px);
  margin: 0 auto; max-width: 420px; background: var(--panel); color: #fff; border: 1px solid transparent;
  border-radius: 12px; padding: 12px 14px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow);
}
/* Red is for a message that reports a problem (toast(msg, 'error')); good news and plain notes are dark. */
.toast.error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.3; } }

/* Map markers */
.start-pin { width: 22px; height: 22px; border-radius: 50%; background: var(--brand); border: 4px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); }
/* The finish of a one-way run: a chequered dot. */
.dest-pin { width: 22px; height: 22px; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); background: conic-gradient(#0f172a 0 25%, #fff 0 50%, #0f172a 0 75%, #fff 0); }

/* Desktop: side panel instead of bottom sheet */
@media (min-width: 900px) {
  .topbar { left: 16px; right: auto; width: 380px; }
  .sheet, .sheet[data-pos] { left: 16px; bottom: 16px; top: 150px; width: 380px; right: auto; border-radius: var(--radius); max-height: none; overflow-y: auto; padding-top: 14px; } /* no grab handle here: room above the first line instead */
  .grab, .route-strip, .sheet[data-pos='peek'] .route-strip { display: none; }
  .topbar.start-set .search { display: flex; }
  .map-back { display: none !important; }
  .cards { flex-direction: column; overflow: visible; margin: 0; padding: 0; }
  .card { flex: none; }
}

/* Sightseeing */
.dot.sights { background: #f59e0b; }
.sight-pin { display: flex; align-items: center; gap: 4px; white-space: nowrap; pointer-events: auto; }
.sight-pin i {
  flex: none; width: 22px; height: 22px; border-radius: 50%; background: #f59e0b; color: #fff; font-style: normal;
  font-size: 12px; display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.sight-pin span {
  font: 700 11px Inter, sans-serif; color: #78350f; background: rgba(255, 255, 255, 0.92); padding: 2px 6px;
  border-radius: 6px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* Running spots (tracks, parks) */
.badge.laps { color: #166534; background: #dcfce7; }
.place-pin { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35); color: #fff; }
.place-pin.track { background: #dc2626; }
.place-pin.park { background: #16a34a; }
.place-pin.stadium { background: #1e3a8a; }
.place.stadium i { background: #1e3a8a; }
.place-note { font-size: 12px; color: var(--ink-3); }
.place-pin svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.place-pin.track svg, .place-pin.stadium svg { fill: none; stroke: currentColor; stroke-width: 2.2; }
.place-pop { font: 13px/1.35 Inter, system-ui, sans-serif; }
.place-pop b { font-size: 14px; }
.place-pop small { display: block; color: var(--ink-2); margin: 2px 0 8px; }
.place-info { margin: 0 0 8px; font-size: 12.5px; }
.place-info.muted { color: var(--ink-3); }
.place-links { display: flex; flex-wrap: wrap; gap: 6px; }
.place-link { color: #1d4ed8; background: #eff6ff; border-radius: 999px; padding: 4px 9px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.place-link.site { color: #fff; background: #1d4ed8; }
.place-facts { margin-top: 6px; color: var(--ink-2); }
.place-run { border: 0; border-radius: 10px; background: var(--brand); color: #fff; font: 700 19px Inter, sans-serif; padding: 9px 12px; width: 100%; }
.places { display: grid; gap: 6px; margin-top: 10px; }
#spotsPrefs { margin: -4px 0 14px; }
.spots-hint { font-size: 12px; color: var(--ink-3); margin: -6px 0 10px; }
.places-title { font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }
.place { display: flex; align-items: center; gap: 10px; text-align: start; border: 1.5px solid var(--line); background: var(--bg); border-radius: 12px; padding: 8px 10px; }
.place i { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.place.track i { background: #dc2626; }
.place.park i { background: #16a34a; }
.place i svg { width: 17px; height: 17px; fill: currentColor; stroke: none; }
.place.track i svg, .place.stadium i svg { fill: none; stroke: currentColor; stroke-width: 2.2; }
.place span { min-width: 0; }
.place b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.place small { font-size: 12px; color: var(--ink-2); }

/* Start run */
.run-actions { display: grid; gap: 6px; margin-top: 12px; }
.run-actions .primary { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; }
.run-actions .primary svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.ghost { border: 0; background: transparent; color: var(--ink-2); font-size: 13.5px; font-weight: 600; padding: 8px; min-height: 44px; text-decoration: underline; text-underline-offset: 3px; }

/* Live navigation */
body.navigating .topbar, body.navigating .sheet { display: none; }
body.navigating #map .maplibregl-ctrl-top-right { display: none; }
.nav { position: fixed; inset: 0; z-index: 1060; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; }
.nav > * { pointer-events: auto; }
.nav-top { padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 0; display: grid; gap: 8px; pointer-events: none; }
.nav-top > * { pointer-events: auto; }
.nav-banner {
  display: flex; align-items: center; gap: 14px; background: #065f46; color: #fff; border-radius: 18px;
  padding: 14px 16px; box-shadow: var(--shadow); min-height: 92px;
}
.nav-banner.off { background: #b91c1c; }
.nav-arrow { flex: none; width: 56px; height: 56px; }
.nav-arrow svg { width: 56px; height: 56px; stroke-width: 2.6; }
.nav-main { min-width: 0; flex: 1; }
.nav-dist { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
.nav-text { font-size: 18px; font-weight: 700; line-height: 1.2; }
.nav-street { font-size: 14px; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; unicode-bidi: plaintext; }
.nav-demo { align-self: flex-start; flex: none; border: 0; border-radius: 8px; background: rgba(255, 255, 255, 0.18); color: #fff; font-size: 12px; font-weight: 800; padding: 4px 7px; letter-spacing: 0.04em; }
.nav-alert { background: #fef3c7; color: #92400e; border-radius: 12px; padding: 10px 12px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); }
.nav-caption:empty { display: none; }
.nav-caption {
  justify-self: start; max-width: 100%; background: rgba(15, 23, 42, 0.82); color: #fff; font-size: 13px;
  border-radius: 10px; padding: 6px 10px; line-height: 1.35; unicode-bidi: plaintext;
}
/* Re-center sits on the bottom panel, at the right, however tall the panel is (.nav is a column: banner, this, panel). */
.recenter {
  margin: auto 12px 10px auto; z-index: 1061; border: 0; border-radius: 999px; background: var(--bg); min-height: 44px;
  box-shadow: var(--shadow); padding: 10px 14px; font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px;
}
.recenter svg { width: 16px; height: 16px; fill: #2563eb; stroke: #2563eb; }
/* North up: shown once the map has been turned by hand while planning (never during a run). */
.map-north { position: fixed; right: 12px; top: calc(env(safe-area-inset-top, 0px) + 124px); z-index: 1051; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--bg); box-shadow: var(--shadow); display: grid; place-items: center; }
.map-north svg { width: 24px; height: 24px; }
.map-north .n { fill: var(--brand); } .map-north .s { fill: #94a3b8; }
body.navigating .map-north { display: none; }
.nav-bottom { background: var(--bg); border-radius: var(--radius) var(--radius) 0 0; box-shadow: var(--shadow); padding: 0 14px calc(12px + var(--safe-b)); overflow: hidden; }
.nav-progress { height: 5px; background: var(--bg-2); margin: 0 -14px 10px; }
.nav-progress i { display: block; height: 100%; width: 0; background: #10b981; transition: width 0.5s; }
.nav-stats { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; margin-bottom: 10px; }
.nav-stats b { display: block; font-size: 22px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.nav-stats span { font-size: 12.5px; color: var(--ink-2); }
.nav-buttons { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; }
.nav-buttons button {
  border: 0; border-radius: 12px; background: var(--bg-2); padding: 12px 6px; min-height: 50px; font-weight: 700; font-size: 15px; /* pressed on the move: taller than anything else in the app */
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.nav-buttons svg { width: 18px; height: 18px; }
.nav-buttons .off, #pauseBtn.paused .on, #muteBtn[aria-pressed='true'] .on { display: none; }
#pauseBtn.paused .off, #muteBtn[aria-pressed='true'] .off { display: inline; }
#pauseBtn.paused { background: #dcfce7; color: #166534; }
#pauseBtn .off { fill: currentColor; }
#muteBtn[aria-pressed='true'] { background: #fee2e2; color: #991b1b; }
.nav-buttons .danger { background: #fee2e2; color: #991b1b; }
.nav-buttons .danger.confirm { background: #dc2626; color: #fff; }
.nav-note { font-size: 12.5px; color: var(--ink-3); text-align: center; margin-top: 8px; }
.user-dot { width: 22px; height: 22px; border-radius: 50%; background: #2563eb; border: 4px solid #fff; box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.25), 0 2px 6px rgba(0, 0, 0, 0.35); }
.nav-finish { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); display: grid; place-items: center; padding: 16px; z-index: 1070; }
.finish-card { background: var(--bg); border-radius: 20px; padding: 22px; width: 100%; max-width: 360px; text-align: center; box-shadow: var(--shadow); }
.finish-title { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 14px; }
.finish-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 18px; }
.finish-stats b { display: block; font-size: 24px; font-weight: 800; }
.finish-stats span { font-size: 12px; color: var(--ink-2); }

@media (min-width: 900px) {
  .nav-top { width: 420px; padding-left: 16px; }
  .nav-bottom { width: 420px; margin: 0 0 16px 16px; border-radius: var(--radius); }
  [dir='rtl'] .nav-top { padding-left: 12px; padding-right: 16px; }
  [dir='rtl'] .nav-bottom { margin: 0 16px 16px 0; }
  .recenter { position: fixed; right: 12px; bottom: 24px; margin: 0; }
}


/* ---------- Views: home cover, app, pages ---------- */
body[data-view='home'] .topbar, body[data-view='home'] .sheet, body[data-view='home'] #map .maplibregl-ctrl-top-right { display: none; }
body[data-view='app'] .home { display: none; }

/* Side toolbar */
.rail {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 1400; width: 280px; max-width: 86vw;
  background: var(--panel); color: #fff; padding: calc(env(safe-area-inset-top, 0px) + 18px) 14px 18px;
  display: flex; flex-direction: column; gap: 6px;
  transform: translateX(-105%); transition: transform 0.22s ease; box-shadow: var(--shadow);
}
.rail.open { transform: none; }
.rail-logo { border: 0; background: transparent; padding: 6px 8px 14px; cursor: pointer; text-align: start; }
.rail-logo .logo { height: 64px; }
.rail-item {
  border: 0; background: transparent; color: #e2e8f0; text-align: start; cursor: pointer;
  display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: 12px; font-size: 15px; font-weight: 600;
}
.rail-item:hover, .rail-item.on { background: rgba(255, 255, 255, 0.1); color: #fff; }
.rail-item.on { box-shadow: inset 3px 0 0 var(--brand); }
.rail-item .ic { width: 24px; height: 24px; flex: none; color: var(--brand); stroke-width: 2; }
.rail-item .ic.mark { width: 36px; height: 36px; margin: -6px 0; object-fit: contain; flex: 0 0 36px; } /* all menu marks share one box; the artwork is left-aligned inside it */
.rail-foot { margin-top: auto; font-size: 12px; color: #94a3b8; padding: 0 10px; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 1390; background: rgba(15, 23, 42, 0.5); }
.menu-btn { border: 0; background: var(--panel); width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; gap: 4px; padding: 0; cursor: pointer; }
.menu-btn span { display: block; width: 18px; height: 2px; border-radius: 2px; background: #fff; }
.menu-btn span:first-child { margin-top: 1px; }

/* Cover page: a dark page, the runners on the promenade at golden hour, the headline over
   the picture, two glass cards. On wide screens a stylised night map with a glowing route
   fills the right third, split from the hero by a diagonal orange edge. */
.home { position: fixed; inset: 0; z-index: 1300; overflow: auto; background: #0f172a; color: #fff; -webkit-overflow-scrolling: touch; }
.home-bar { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top, 0px) + 12px) 18px 8px; background: linear-gradient(rgba(15, 23, 42, 0.55), transparent); }
.home-bar .logo { height: 48px; }
.home-bar .menu-btn { background: rgba(255, 255, 255, 0.12); }
.hero { --photo-top: min(34vh, 300px); position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: 0 0 calc(22px + var(--safe-b)); }
/* The picture fills the page from below the headline to the bottom: the headline sits in the
   dark above the runners, the two cards lie over the promenade in front of them. */
.hero-copy { order: 0; } .hero-photo { order: 1; } .modes { order: 2; } .perks { order: 3; } .home-foot { order: 4; } /* the picture is first in the markup (it is the backdrop on wide screens) */
.hero-photo { position: absolute; left: 0; right: 0; top: calc(-68px - env(safe-area-inset-top, 0px)); bottom: 0; overflow: hidden; z-index: 0; } /* the picture is the whole opening page: from behind the top bar to the bottom, the words and the card on it */
/* The picture starts at the very top of the page: its evening sky is behind the words, which are written in front of it. It is a fixed, generous height (and never shorter than the page), so the sun and the runner come out just under the words on a small phone and a large one alike. */
.hero-photo img { position: absolute; left: 0; right: 0; top: 0; bottom: auto; width: 100%; height: max(118%, 1100px); object-fit: cover; object-position: 50% 0; display: block; }
.hero-photo::before { content: ''; position: absolute; inset: 0; z-index: 1; background: linear-gradient(180deg, rgba(15, 23, 42, 0.8) 0%, rgba(15, 23, 42, 0.62) 16%, rgba(15, 23, 42, 0.3) 30%, rgba(15, 23, 42, 0) 42%, rgba(15, 23, 42, 0) 56%, rgba(15, 23, 42, 0.5) 85%, rgba(15, 23, 42, 0.9) 100%); } /* a light veil at the top for the words, darker at the foot for the perks */
.hero-copy { position: relative; z-index: 1; padding: 6px 20px 0; } /* the words at the top of the page, on the darkened top of the picture */
.hero h1 { font-size: clamp(38px, 10.5vw, 76px); line-height: 0.96; letter-spacing: -0.035em; font-weight: 900; text-transform: uppercase; margin: 0 0 14px; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.35); }
.hero h1 span { display: block; }
.hero h1 .h1-b { color: var(--brand); }
.lede { font-size: clamp(15px, 2.4vw, 19px); line-height: 1.5; color: #e2e8f0; max-width: 560px; margin: 0; text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5); }
.modes { position: relative; z-index: 1; display: grid; gap: 12px; padding: 0 16px; margin: auto 0 18px; padding-top: 30vh; }
.mode-card {
  text-align: start; color: #fff; border: 1px solid rgba(255, 255, 255, 0.16); background: rgba(15, 23, 42, 0.62); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-radius: 18px; padding: 18px 18px 16px; display: grid; gap: 8px; cursor: pointer; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35); transition: transform 0.15s, border-color 0.15s;
}
.mode-card:hover { transform: translateY(-2px); border-color: rgba(255, 122, 79, 0.6); }
.mode-title { font-size: 22px; font-weight: 900; letter-spacing: -0.02em; text-transform: uppercase; }
.mode-text { font-size: 14px; line-height: 1.45; color: #cbd5e1; }
.mode-cta { justify-self: stretch; text-align: center; margin-top: 10px; font-weight: 800; font-size: 19px; letter-spacing: 0.01em; color: #fff; background: var(--brand); border-radius: 14px; padding: 16px 18px; box-shadow: 0 8px 24px rgba(255, 122, 79, 0.45); }
.mode-cta::after { content: ' \2197'; }
.perks { position: relative; z-index: 1; list-style: none; margin: 0 0 14px; padding: 0 20px; display: flex; flex-wrap: wrap; gap: 10px 22px; font-size: 13.5px; color: #e2e8f0; }
.perks li { display: inline-flex; align-items: center; gap: 8px; }
.perks li svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--brand); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.perks li::before { display: none; }
.perks .link { color: #fff; }
.home-foot { position: relative; z-index: 1; font-size: 12.5px; color: #cbd5e1; padding: 0 20px; }
.home-foot .link { color: #cbd5e1; }
.home-foot .link { color: #94a3b8; } /* on the dark cover: the light grey it always had, whatever the small print's grey is elsewhere */
.home-map { display: none; }
.link { position: relative; border: 0; background: transparent; padding: 0; color: var(--ink-2); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
/* A text link stays as small as its words, but answers a finger in a taller strip around them (about 36 to 40 points). */
.link::after { content: ''; position: absolute; left: -4px; right: -4px; top: -10px; bottom: -10px; }

/* Text pages (terms) */
.page { position: fixed; inset: 0; z-index: 1450; background: var(--bg); overflow: auto; }
.page-bar { position: sticky; top: 0; background: var(--bg); display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 10px; border-bottom: 1px solid var(--line); }
.page-title { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.page-body { max-width: 680px; margin: 0 auto; padding: 16px 20px calc(40px + var(--safe-b)); font-size: 15px; line-height: 1.6; color: var(--ink-2); }
.page-body h2 { font-size: 16px; color: var(--ink); margin: 22px 0 6px; }
.page-body p { margin: 0 0 10px; }
.page-body ul { padding-left: 20px; margin: 0 0 10px; }
.page-body b { color: var(--ink); }
.page-note { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; border-radius: 12px; padding: 10px 12px; font-size: 13.5px; }

@media (min-width: 900px) {
  .map-north { top: 110px; }
  /* The toolbar is a permanent rail on wide screens; the app and the cover sit to its right. */
  .rail { transform: none; width: 220px; box-shadow: none; }
  .drawer-backdrop { display: none; }
  .menu-btn, .burger { display: none; }
  .home-bar { display: none; }
  .home, .page { left: 220px; }
  .home { display: grid; grid-template-columns: minmax(0, 1fr) clamp(240px, 28vw, 460px); }
  .hero { --photo-top: 0px; padding: 0 0 28px; min-height: 100%; }
  .hero-photo { position: absolute; left: 0; right: 0; top: var(--photo-top); bottom: 0; height: auto; margin: 0; }
  /* On a wide screen (Uri's design: the runners beneath the headline, the route beside
     them) the picture is his runners seen from the side, with the sky above them and the
     paving below them drawn on (Nov 23, 2026: he asked for the space above and below to
     continue the photograph, and the picture was extended for him), so it is square and
     fills the panel by itself. It is shown across the panel at its own proportions: never
     enlarged to fill (that costs sharpness), never cropped at the sides, never stretched,
     and with no blurred copy behind it.
     - The panel runs on under the map's slanted edge and is cut along the same diagonal,
       so the picture meets the orange line instead of stopping short of it (--slant is
       the width of that slant: 14% of the map column).
     - It is placed so that the runners' faces come just under the writing whatever the
       window: the heads are 32.2% of the way down the picture, and stay 272px down the
       panel. In an ordinary window that leaves sky to spare above and paving below.
     - Only a window much taller than it is wide, or a very narrow one, leaves the picture
       short of the top or the foot of the panel. There the sky goes on in the colours of
       the picture's own top edge and the paving in those of its bottom edge, and that edge
       of the picture fades into them so no rectangle shows (--fade-top and --fade-foot are
       the length of the fade: nothing at all when the picture reaches past the edge). */
  .home { --slant: calc(0.14 * clamp(240px, 28vw, 460px)); }
  .hero-photo { right: calc(-1 * var(--slant)); clip-path: polygon(0 0, 100% 0, calc(100% - var(--slant)) 100%, 0 100%); container-type: size; background:
    linear-gradient(90deg, #978674 0%, #968777 12%, #94877a 25%, #8f857b 38%, #8a847d 50%, #838280 62%, #7f8183 75%, #7c7e82 88%, #797b80 100%) top / 100% 50% no-repeat,
    linear-gradient(90deg, #704d3d 0%, #754f3b 12%, #78513d 25%, #734e3c 38%, #6c4939 50%, #6e4b3a 62%, #654637 75%, #5b4237 88%, #6e4f42 100%) bottom / 100% 50% no-repeat; }
  .hero-photo img { top: 0; height: auto; object-fit: fill; }
  @supports (top: 1cqw) {
    .hero-photo img { --top: calc(272px - 32.2cqw); --fade-top: clamp(0px, calc(var(--top) * 1000), 7cqw); --fade-foot: clamp(0px, calc((100cqh - var(--top) - 100cqw) * 1000), 12cqw); top: var(--top);
      -webkit-mask-image: linear-gradient(180deg, transparent 0, rgba(0, 0, 0, 0.55) calc(var(--fade-top) * 0.45), #000 var(--fade-top), #000 calc(100% - var(--fade-foot)), rgba(0, 0, 0, 0.5) calc(100% - var(--fade-foot) * 0.45), transparent 100%);
      mask-image: linear-gradient(180deg, transparent 0, rgba(0, 0, 0, 0.55) calc(var(--fade-top) * 0.45), #000 var(--fade-top), #000 calc(100% - var(--fade-foot)), rgba(0, 0, 0, 0.5) calc(100% - var(--fade-foot) * 0.45), transparent 100%); }
  }
  .hero-photo::before { background: linear-gradient(180deg, rgba(36, 26, 16, 0.86) 0, rgba(36, 26, 16, 0.74) 150px, rgba(36, 26, 16, 0.38) 232px, rgba(36, 26, 16, 0) 292px, rgba(15, 23, 42, 0) 62%, rgba(15, 23, 42, 0.5) 86%, rgba(15, 23, 42, 0.88) 100%); } /* dusk over the sky behind the writing; the foot of the panel darkened for the small print */
  .hero-copy { padding: 44px 48px 0; }
  .hero h1 { font-size: clamp(36px, 3.9vw, 58px); }
  .modes { grid-template-columns: minmax(0, 560px); gap: 16px; padding: 0 48px; margin: auto 0 16px; padding-top: 24vh; }
  .perks, .home-foot { padding-left: 48px; padding-right: 48px; }
  .home-map { display: block; position: relative; overflow: hidden; clip-path: polygon(14% 0, 100% 0, 100% 100%, 0 100%); background: #1a2436; }
  .home-map::before { content: ''; position: absolute; inset: 0; background: linear-gradient(104deg, var(--brand) 0, var(--brand) 100%); clip-path: polygon(14% 0, calc(14% + 14px) 0, 14px 100%, 0 100%); z-index: 1; }
  .home-map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
  .topbar { left: 236px; }
  .sheet, .sheet[data-pos] { left: 236px; } /* the panel rule above also matches .sheet[data-pos], so this must too */
  /* The run screen, its finish card, dialogs and messages also start right of the rail, never under it. */
  .nav, .nav-finish, .ask { left: 220px; }
  .toast { left: 236px; }
  .status { left: calc(50% + 110px); }
}

/* Menu icons drawn by the user: phone and document, brand orange on transparency */


/* Install page */
.steps { padding-left: 22px; margin: 0 0 12px; }
.steps li { margin: 0 0 6px; }
.inline-ic { width: 18px; height: 18px; vertical-align: -4px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.perks .link { font: inherit; color: var(--brand); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }
#installBtn { margin: 4px 0 8px; }

/* Running mode: streets, laps or one way (the third card spans the row) */
.run-styles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.run-styles button:nth-child(3) { grid-column: 1 / -1; }
.run-styles button { text-align: start; border: 1.5px solid var(--line); background: var(--bg); border-radius: 14px; padding: 10px 12px; display: grid; gap: 3px; cursor: pointer; color: var(--ink); }
.run-styles button b { font-size: 14px; }
.run-styles button small { font-size: 12px; color: var(--ink-2); line-height: 1.35; }
.run-styles button.on { border-color: var(--brand); background: #fff7f3; box-shadow: inset 0 0 0 1px var(--brand); }
body[data-mode="tour"] #runStyleField { display: none; }
#prefsView[data-style="laps"] .streets-only { display: none; }
#prefsView:not([data-style="oneway"]) .oneway-only { display: none; }
#prefsView[data-style="oneway"] #spotsHint, #prefsView[data-style="oneway"] #spotsPrefs, #prefsView[data-style="oneway"] #spotsEmpty { display: none; }
/* The finish search sits in the sheet: a bordered box instead of a floating bar, its list in the flow. */
.search.in-sheet { box-shadow: none; border: 1.5px solid var(--line); background: var(--bg-2); padding: 2px 4px 2px 12px; }
.search.in-sheet input { font-size: 15px; padding: 12px 0; }
.search-results.in-sheet { box-shadow: none; border: 1px solid var(--line); margin-top: 6px; max-height: 40vh; }
.dest-line { margin: 8px 0 0; }
#destField .field-head label { white-space: nowrap; }
.badge.oneway { color: #9a3412; background: #ffedd5; }
.spots-empty { font-size: 13.5px; color: var(--ink-2); background: var(--bg-2); border-radius: 12px; padding: 10px 12px; }
.results-note { font-size: 13px; color: var(--ink-2); text-align: center; margin: 6px 0 2px; }

/* Route pop-up */
.route-card-pop { gap: 8px; }
.route-pop-dist { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin-top: -4px; }
.route-pop-dist b { font-size: 34px; }
.route-pop-facts { list-style: none; padding: 0; margin: 0 0 6px; display: grid; gap: 4px; font-size: 14px; color: var(--ink-2); }
.route-pop-facts li::before { content: "•"; color: var(--brand); margin-right: 6px; }
.route-card-pop .primary { margin: 0; display: flex; align-items: center; justify-content: center; gap: 8px; }
.route-card-pop .primary svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.route-pop-foot { display: flex; justify-content: space-between; gap: 16px 8px; flex-wrap: wrap; margin-top: 6px; } /* rows far enough apart that the links' finger strips do not overlap */
.route-pop-foot .link { font-size: 13px; }
#prefsView[data-style="streets"] #spotsHint, #prefsView[data-style="streets"] #spotsPrefs, #prefsView[data-style="streets"] #spotsEmpty { display: none; }

/* Report a problem */
.report-reasons button { padding: 7px 12px; min-height: 40px; font-size: 13.5px; }
#reportNote {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; font: inherit; font-size: 14px;
  background: var(--bg-2); color: var(--ink); resize: vertical; min-height: 64px;
}
#reportNote:focus { outline: none; border-color: var(--ink); background: var(--bg); }
.ask-note { font-size: 12px; color: var(--ink-3); margin-top: -4px; }
.nav-foot { margin-top: 8px; }
/* Take me back and Report: buttons, not small print. A runner reaches for them on the move. */
.nav-foot .link { min-height: 44px; border-radius: 12px; background: var(--bg-2); color: var(--ink); font-size: 13.5px; font-weight: 600; line-height: 1.25; text-decoration: none; padding: 6px 10px; }
.nav-foot .link::after { display: none; }

/* Profile and the run journal */
.rail-user { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; color: #fff; border-radius: 14px; padding: 8px 10px; margin: 0 6px 8px; text-align: start; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.rail-user:hover, .rail-user:active { background: rgba(255, 255, 255, 0.1); }
.rail-user .who { min-width: 0; }
.rail-user b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-user small { display: block; font-size: 12px; color: #94a3b8; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px; overflow: hidden; flex: none; background-size: cover; background-position: center; }
.avatar.big { width: 84px; height: 84px; font-size: 30px; cursor: pointer; border: 3px solid var(--bg); box-shadow: var(--shadow); -webkit-tap-highlight-color: transparent; }
.avatar.big:active, .avatar.big:focus-within { outline: none; opacity: 1; }
.photo-row { display: flex; align-items: center; gap: 16px; margin: 6px 0 18px; }
.avatar.big { position: relative; }
button.avatar.big { padding: 0; -webkit-appearance: none; appearance: none; }
.photo-menu { gap: 6px; }
.photo-menu button { border: 0; border-radius: 12px; background: var(--bg-2); padding: 13px; font: inherit; font-weight: 700; font-size: 15px; color: var(--ink); }
.photo-menu .danger-link { color: #b91c1c; }
.photo-menu .ghost { background: transparent; text-decoration: none; color: var(--ink-2); }
#photoAsk { z-index: 1500; }
.photo-viewer { position: fixed; inset: 0; z-index: 1600; background: rgba(15, 23, 42, 0.96); display: grid; place-items: center; padding: 24px; }
.photo-viewer img { width: min(86vw, 86vh); height: min(86vw, 86vh); border-radius: 50%; object-fit: cover; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.photo-viewer-hint { position: absolute; bottom: calc(24px + var(--safe-b)); color: #94a3b8; font-size: 13px; }
.photo-row b { display: block; color: var(--ink); }
.photo-row small { color: var(--ink-3); font-size: 12.5px; }
.field-label { display: block; font-weight: 700; font-size: 14px; color: var(--ink); margin: 0 0 12px; }
.field-label input { display: block; width: 100%; margin-top: 6px; border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; font: inherit; font-size: 16px; background: var(--bg-2); color: var(--ink); }
.field-label input:focus { outline: none; border-color: var(--ink); background: var(--bg); }
.profile .primary { width: 100%; margin: 6px 0 8px; }
/* Signing in. The three ways in are one column of equal buttons: Apple's in its own black
   with its mark (white in the dark theme), Google's as Google asks (white, its coloured
   mark; on the website Google draws the button itself), e-mail in the app's own look.
   "Continue as a guest" is a full button too, not small print: nobody has to sign in. */
.welcome-lead { font-size: 16px; color: var(--ink); margin: 6px 0 18px; }
/* Sign up or Log in: two halves of one control, at the width of the buttons under it. */
.segmented.two { grid-template-columns: repeat(2, 1fr); }
.sign-mode { max-width: 400px; margin: 4px auto 16px; }
.sign-mode button { padding: 11px 0; font-size: 15px; }
/* Google draws its own button on the website and makes it 400px wide at most: the column of
   ways in and the guest button keep to that width, so the buttons line up on a wide screen. */
.sign-ways { display: grid; gap: 10px; max-width: 400px; margin: 0 auto; }
.sign-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 50px; border-radius: 25px; border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; }
.sign-btn svg { width: 19px; height: 19px; flex: none; }
.sign-apple { background: #000; border-color: #000; color: #fff; }
.sign-apple svg { fill: #fff; margin-top: -3px; }
.sign-google { background: #fff; border-color: #dadce0; color: #1f1f1f; }
.sign-google-web { display: flex; justify-content: center; min-height: 44px; color-scheme: light; }
html[data-theme='dark'] .sign-apple { background: #fff; border-color: #fff; color: #000; }
html[data-theme='dark'] .sign-apple svg { fill: #000; }
.sign-form { margin-top: 4px; }
.sign-form .route-pop-foot { margin-top: 4px; }
.code-input { letter-spacing: 0.4em; font-size: 24px !important; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.guest-btn { display: block; width: 100%; max-width: 400px; height: 50px; margin: 18px auto 10px; border-radius: 25px; border: 0; background: var(--bg-2); color: var(--ink); font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; }
.welcome-small { font-size: 13px; color: var(--ink-3); text-align: center; }
#welcome.busy .sign-ways, #welcome.busy .sign-form, #welcome.busy .guest-btn { opacity: 0.5; pointer-events: none; }
.welcome #signMsg { text-align: center; min-height: 1.4em; margin-top: 10px; }
#welcome.busy #signMsg { color: var(--ink-2); }
/* The account on the profile page. */
.account-box { margin-top: 22px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2); }
.account-box b { display: block; overflow-wrap: anywhere; }
.account-box p { font-size: 13.5px; margin: 4px 0 10px; }
.account-box .ghost { padding: 4px 0; color: var(--ink); font-size: 14.5px; }
.account-ways { display: flex; gap: 22px; }
.profile-totals { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.profile-totals b { display: block; font-size: 20px; font-weight: 800; color: var(--ink); }
.profile-totals span { font-size: 12.5px; color: var(--ink-3); }
.page-action { margin-left: auto; }
.runs-summary { font-size: 13px; color: var(--ink-2); margin: 0 0 12px; }
.runs-list { display: grid; gap: 12px; }
.run-card { display: grid; grid-template-columns: 112px 1fr; gap: 12px; border: 1.5px solid var(--line); border-radius: 16px; padding: 10px; background: var(--bg); text-align: start; cursor: pointer; }
.run-card .thumb { width: 112px; height: 70px; border-radius: 10px; background: var(--bg-2) center / cover no-repeat; }
.run-card b { display: block; font-size: 15px; color: var(--ink); }
.run-card small { display: block; color: var(--ink-2); font-size: 12.5px; line-height: 1.4; }
.run-card .when { color: var(--ink-3); }
.run-pic-btn { position: relative; display: block; width: 100%; padding: 0; border: 0; background: none; margin-bottom: 14px; cursor: pointer; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.run-pic { width: 100%; display: block; }
.run-pic-hint { position: absolute; right: 10px; bottom: 10px; background: rgba(15, 23, 42, 0.78); color: #fff; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; }
.run-map-page { display: flex; flex-direction: column; }
.run-map-page[hidden] { display: none; }
.run-map { flex: 1; min-height: 0; background: #e5e7eb; }
.run-map-foot { padding: 10px 16px calc(10px + var(--safe-b)); font-size: 13px; color: var(--ink-2); border-top: 1px solid var(--line); background: var(--bg); }
.run-actions { display: grid; grid-template-columns: 1.6fr 1fr; gap: 8px; margin: 4px 0 12px; }
.run-actions .primary { margin: 0; }
.run-actions .ghost { text-decoration: none; background: var(--bg-2); border-radius: 14px; padding: 13px; }
.finish-card .link { display: block; margin: 10px auto 0; }
.finish-card .link.danger { color: #b91c1c; margin-top: 14px; }
.finish-sub { font-size: 14px; color: var(--ink-2); margin: -6px 0 14px; }
.run-detail .finish-stats { margin-bottom: 14px; text-align: center; }
.run-detail .route-pop-facts { padding: 0; }
.run-detail .run-actions { grid-template-columns: 1fr 1fr; }
.run-detail .run-actions .primary { grid-column: 1 / -1; }
.danger-link { color: #b91c1c; }

/* Photo crop (above the profile page) */
#cropAsk { z-index: 1500; }
.crop-stage { position: relative; width: 280px; height: 280px; margin: 0 auto; border-radius: 16px; overflow: hidden; background: #0f172a; touch-action: none; cursor: grab; }
.crop-stage canvas { display: block; width: 280px; height: 280px; }
.crop-ring { position: absolute; inset: 0; border-radius: 16px; pointer-events: none; box-shadow: inset 0 0 0 20px rgba(15, 23, 42, 0.55); }
.crop-ring::after { content: ''; position: absolute; left: 20px; top: 20px; width: 240px; height: 240px; border-radius: 50%; box-shadow: 0 0 0 400px rgba(15, 23, 42, 0.55); border: 2px solid rgba(255, 255, 255, 0.9); }

/* Inside the native app: no "install" page, no update checker, no home-screen hints. */
body.native [data-nav='install'], body.native #railInstall, body.native #setUpdate, body.native .web-only { display: none !important; }
.native-only { display: none !important; }
body.native .native-only { display: list-item !important; }
body.native .set-row.native-only { display: flex !important; }
body.native .perks .native-only { display: inline-flex !important; }

/* Settings */
.settings h2 { margin-top: 26px; }
.settings h2:first-child { margin-top: 4px; }
.set-sub { margin: -2px 0 10px; font-size: 14px; }
.set-hint { font-size: 13px; color: var(--ink-3); margin: 8px 0 0; }
.settings .segmented { margin: 4px 0 2px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.set-row.with-control { border-bottom: 0; padding-bottom: 6px; } /* a title whose control is the row of choices right under it: no line between them */
.set-row > span { display: block; min-width: 0; }
.set-row b { display: block; font-size: 15px; }
.set-row small { display: block; font-size: 12.5px; color: var(--ink-3); line-height: 1.4; }
.set-row .ghost { flex: none; white-space: nowrap; }
.switch { appearance: none; -webkit-appearance: none; width: 48px; height: 28px; border-radius: 999px; background: #94a3b8; position: relative; flex: none; margin: 0; cursor: pointer; transition: background 0.15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: left 0.15s; }
.switch:checked { background: var(--brand); }
.switch:checked::after { left: 23px; }
.switch:disabled { opacity: 0.4; }
/* Voice picker */
.voice-list { display: grid; gap: 6px; }
.voice-row { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--line); border-radius: 12px; padding: 8px 10px; background: var(--bg); text-align: start; cursor: pointer; }
.voice-row.on { border-color: var(--ink); background: var(--bg-2); }
.voice-row .who { flex: 1; min-width: 0; }
.voice-row b { display: block; font-size: 15px; color: var(--ink); }
.voice-row small { color: var(--ink-2); font-size: 12.5px; }
.voice-row .play { border: 0; border-radius: 999px; background: var(--brand); color: #fff; width: 44px; height: 44px; display: grid; place-items: center; flex: none; }
.voice-row .play svg { width: 14px; height: 14px; fill: currentColor; margin-left: 2px; }
.voice-row .tick { width: 20px; flex: none; color: var(--brand); font-weight: 800; }
.voice-row.missing { opacity: 0.6; }
.voice-diag { font-size: 11.5px; line-height: 1.5; color: var(--ink-3); background: var(--bg-2); border-radius: 10px; padding: 8px 10px; margin: 6px 0 0; white-space: pre-wrap; word-break: break-all; max-height: 240px; overflow: auto; }
.set-hint .link + .link { margin-left: 12px; }

/* Plan by distance or by time: a small switch in the field's head. */
.plan-by { grid-template-columns: repeat(2, 1fr); width: 180px; padding: 3px; }
/* The Distance | Time switch sits in the middle of its row, the limits at the right. */
.plan-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.plan-head .hint { justify-self: end; }
.plan-by button { min-height: 36px; font-size: 13px; }
/* The run screen's small links: take me back, report a problem. */
.nav-foot { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }

/* ---------- Hebrew (right to left) ---------- */
/* The page's direction does most of the work: rows, text and grids mirror by themselves.
   What follows are the pieces that need a hand. */
/* Back arrows point the other way. */
[dir='rtl'] .back svg, [dir='rtl'] .map-back svg, [dir='rtl'] #backBtn svg { transform: scaleX(-1); }
/* Numbers people type and read as numbers stay left to right. */
[dir='rtl'] #distanceInput, [dir='rtl'] #lapsKm, [dir='rtl'] .nav-stats b, [dir='rtl'] .finish-stats b { direction: ltr; unicode-bidi: isolate; }
/* A number with its unit (6.01 km on a card, 300 m in the turn banner) follows the page: in Hebrew the number is read first, at the right, in line with the rest. */
[dir='rtl'] .nav-street { text-align: right; } /* a street name in Latin letters still sits under the Hebrew instruction */
[dir='rtl'] .places-title { letter-spacing: 0; }
/* The map keeps its own left-to-right frame (controls, attribution). */
[dir='rtl'] #map, [dir='rtl'] .run-map { direction: ltr; }
/* Hebrew has no capitals: the cover's upper-case headlines keep their weight without the tracking. */
[dir='rtl'] .hero-copy h1, [dir='rtl'] .mode-title { letter-spacing: 0; }
[dir='rtl'] .route-pop-facts li::before { margin-right: 0; margin-left: 6px; }
/* The cover keeps its frame (picture, then the night map with its slanted edge); only the words read right to left. */
[dir='rtl'] .home { direction: ltr; }
[dir='rtl'] .home .hero, [dir='rtl'] .home .home-top { direction: rtl; }

/* Offline pack: a quiet link under the search button, and the line that says an area is saved. */
.offline-row { display: grid; gap: 4px; justify-items: center; margin: 10px 0 2px; font-size: 13px; }
.offline-row .link { color: var(--ink-2); }
.offline-note { color: var(--ink-3); text-align: center; }

/* ---------- Routes downloaded to run later ---------- */
/* On the route sheet: the second choice under Start run, and the line that replaces it once
   the route is on the phone. */
.route-card-pop .secondary { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin: 8px 0 0; padding: 12px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--ink); font: 700 15px Inter, system-ui, sans-serif; cursor: pointer; }
.route-card-pop .secondary svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.route-pop-note { margin: 8px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); color: var(--ink-2); font-size: 13px; text-align: center; }
/* In the planner: the list, a tap opens a route. */
.saved-routes { margin: 0 0 14px; }
.saved-list { display: grid; gap: 6px; max-height: 172px; overflow-y: auto; }
.saved-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: start; border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); padding: 9px 12px; cursor: pointer; font: inherit; }
.saved-row .ico { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--bg-2); display: grid; place-items: center; }
.saved-row .ico svg { width: 16px; height: 16px; fill: none; stroke: var(--brand); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.saved-row .txt { min-width: 0; display: grid; gap: 1px; }
.saved-row b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-row small { font-size: 12px; color: var(--ink-3); }
body.navigating .saved-routes { display: none; }
/* In Settings: each with its Delete. */
.settings .set-row .delete { flex: none; border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); color: #b91c1c; font: 600 13px Inter, system-ui, sans-serif; padding: 7px 12px; min-height: 40px; cursor: pointer; }
html[data-theme='dark'] .settings .set-row .delete { color: #f87171; }

/* ---------- Dark theme (Settings, Appearance: Dark) ----------
   The app's surfaces and text come from the variables at the top of this file, so the dark
   look is mostly those eight values. Below them: the places that state a light colour of
   their own (tinted badges, notes, the switch), and the dark pills that use the text colour
   as their background, which must stay dark. The cover page and the run screen's dark
   panels are dark in both themes. */
html[data-theme='dark'] {
  color-scheme: dark;
  --ink: #f1f5f9;
  --ink-2: #cbd5e1;
  --ink-3: #8b9bb4;
  --line: #334155;
  --bg: #1e293b;
  --bg-2: #0f172a;
  --panel: #0b1220;
  --r1: #60a5fa;
  --r2: #fb923c;
  --r3: #c084fc;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
}
html[data-theme='dark'] #map, html[data-theme='dark'] .run-map { background: #0f172a; }
/* The dark panels sit on a dark page now: a hairline keeps their edge. */
html[data-theme='dark'] .brand, html[data-theme='dark'] .menu-btn, html[data-theme='dark'] .status { box-shadow: 0 0 0 1px #334155; }
html[data-theme='dark'] .rail { box-shadow: 1px 0 0 #1e293b, var(--shadow); }
/* A chosen chip is the reverse of the page: light with dark letters. */
html[data-theme='dark'] .route-strip button.on, html[data-theme='dark'] .chips button.on, html[data-theme='dark'] .chips button[aria-pressed='true'] { color: #0f172a; }
html[data-theme='dark'] .search-results li.active .ico, html[data-theme='dark'] .search-results li:hover .ico { background: var(--bg); }
html[data-theme='dark'] .search-results .ico.loc { color: #60a5fa; }
html[data-theme='dark'] .segmented button.on { background: #475569; box-shadow: none; }
html[data-theme='dark'] .switch { background: #64748b; }
html[data-theme='dark'] .switch:checked { background: var(--brand); }
html[data-theme='dark'] .run-styles button.on { background: rgba(255, 90, 54, 0.14); }
/* Tinted badges, notes and warnings: the same hues, as a glow on the dark surface. */
html[data-theme='dark'] .badge { color: #7dd3fc; background: rgba(56, 189, 248, 0.16); }
html[data-theme='dark'] .badge.laps { color: #86efac; background: rgba(34, 197, 94, 0.16); }
html[data-theme='dark'] .badge.oneway { color: #fdba74; background: rgba(251, 146, 60, 0.16); }
html[data-theme='dark'] .place-link { color: #93c5fd; background: rgba(59, 130, 246, 0.16); }
html[data-theme='dark'] .page-note { color: #fdba74; background: rgba(251, 146, 60, 0.12); border-color: rgba(251, 146, 60, 0.35); }
html[data-theme='dark'] .toast { border-color: #334155; }
html[data-theme='dark'] .toast.error { color: #fecaca; background: #450a0a; border-color: #7f1d1d; }
html[data-theme='dark'] .distance-value.invalid { background: rgba(220, 38, 38, 0.16); }
html[data-theme='dark'] .distance-msg.error, html[data-theme='dark'] .danger-link, html[data-theme='dark'] .photo-menu .danger-link, html[data-theme='dark'] .finish-card .link.danger { color: #f87171; }
html[data-theme='dark'] .nav-caption { box-shadow: 0 0 0 1px #334155; } /* a dark pill on the dark map: a hairline keeps its edge */
html[data-theme='dark'] #pauseBtn.paused { color: #86efac; background: rgba(34, 197, 94, 0.2); }
html[data-theme='dark'] #muteBtn[aria-pressed='true'], html[data-theme='dark'] .nav-buttons .danger { color: #fca5a5; background: rgba(220, 38, 38, 0.2); }
/* The map's own pieces: pop-ups, the zoom buttons on a computer, the credits line. */
html[data-theme='dark'] .maplibregl-popup-content { background: var(--bg); color: var(--ink); }
html[data-theme='dark'] .maplibregl-popup-anchor-bottom .maplibregl-popup-tip, html[data-theme='dark'] .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip, html[data-theme='dark'] .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: var(--bg); }
html[data-theme='dark'] .maplibregl-popup-anchor-top .maplibregl-popup-tip, html[data-theme='dark'] .maplibregl-popup-anchor-top-left .maplibregl-popup-tip, html[data-theme='dark'] .maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: var(--bg); }
html[data-theme='dark'] .maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--bg); }
html[data-theme='dark'] .maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--bg); }
html[data-theme='dark'] .maplibregl-popup-close-button { color: var(--ink-3); }
html[data-theme='dark'] .maplibregl-ctrl-group { background: var(--bg); }
html[data-theme='dark'] .maplibregl-ctrl-group button + button { border-top-color: var(--line); }
html[data-theme='dark'] .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }
html[data-theme='dark'] .maplibregl-ctrl-attrib { background: rgba(15, 23, 42, 0.7); color: #94a3b8; }
html[data-theme='dark'] .maplibregl-ctrl-attrib a { color: #cbd5e1; }

/* ---------- For everyone: keyboards, screen readers, reduced motion ---------- */
/* Read by a screen reader, not drawn: the line that speaks the app's messages. */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
/* The ring that shows where a keyboard is. A finger or a mouse never brings it up
   (:focus-visible); text boxes keep their own darker border instead. */
:focus-visible:not(input):not(textarea) { outline: 3px solid var(--ink); outline-offset: 2px; }
.switch:focus-visible, input[type='range']:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.rail :focus-visible, .home :focus-visible, .nav-banner :focus-visible, .photo-viewer :focus-visible { outline-color: #fff; }
.search:focus-within { box-shadow: 0 0 0 3px var(--ink), var(--shadow); }
.search.in-sheet:focus-within { box-shadow: none; border-color: var(--ink); background: var(--bg); }
/* A page's title or a pop-up takes the focus when it opens, so a screen reader starts there; it is not a control and shows no ring. */
[tabindex='-1']:focus { outline: none; }
/* The phone's "Reduce Motion" setting: things appear in place instead of sliding. (The map obeys the same setting by itself.) */
@media (prefers-reduced-motion: reduce) {
  .rail, .sheet, .mode-card, .chips button, .switch, .switch::after, .nav-progress i { transition: none; }
  .mode-card:hover { transform: none; }
  .icon-btn.busy svg { animation: none; opacity: 0.5; }
}
