:root {
  --bg: #f2efe6;            /* the map's land; also behind the iPhone status bar */
  --surface: #fffdf8;
  --surface-2: #f3f0e7;
  --thumb: #e2e7d2;
  --text: #1d221d;
  --muted: #5a6259;
  --line: #e6e1d4;
  --line-strong: #cfc8b8;
  --primary: #1f6b45;
  --on-primary: #ffffff;
  --accent: #d9481f;
  --warn: #a3410f;
  --easy: #1d7448;
  --moderate: #875400;
  --hard: #b0390c;
  --strenuous: #a11f50;
  --shadow: 0 8px 28px rgba(35, 40, 30, 0.16), 0 1px 3px rgba(35, 40, 30, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c201c;
    --surface: #1e231f;
    --surface-2: #2a302b;
    --thumb: #29322b;
    --text: #eeece4;
    --muted: #a8afa5;
    --line: #333a34;
    --line-strong: #4a524b;
    --primary: #62c793;
    --on-primary: #0b1c12;
    --accent: #ff7a4d;
    --warn: #ffb07a;
    --easy: #72d6a1;
    --moderate: #f2bd55;
    --hard: #ff9a6b;
    --strenuous: #ff86b0;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  position: fixed; inset: 0;
  background: var(--bg); color: var(--text);
  font: 16px/1.4 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
}
body:has(dialog[open]) { background: color-mix(in srgb, var(--bg) 55%, #0a0d0a); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 70%, transparent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic.tiny { width: 15px; height: 15px; margin-right: 4px; vertical-align: -2px; stroke-width: 2.2; }
.ic.big { width: 34px; height: 34px; stroke-width: 1.6; color: var(--muted); }
svg:not(.ic):not(.chart) { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- map ---- */
.map { position: absolute; inset: 0; }
.maplibregl-canvas:focus-visible { outline: none; }
.me { width: 22px; height: 22px; position: relative; pointer-events: none; }
.me-dot { position: absolute; inset: 0; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4); }
.me-heading { display: none; position: absolute; left: 50%; top: -15px; transform: translateX(-50%); border-left: 9px solid transparent; border-right: 9px solid transparent; border-bottom: 17px solid rgba(26, 115, 232, 0.55); }
.me.moving .me-heading { display: block; }
.me::before { content: ''; position: absolute; inset: -9px; border-radius: 50%; background: rgba(26, 115, 232, 0.22); animation: me-pulse 2.4s ease-out infinite; }
@keyframes me-pulse { from { transform: scale(0.5); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }

/* ---- search bar ---- */
.top { position: absolute; z-index: 5; top: 10px; left: 12px; right: 12px; display: flex; gap: 10px; }
.search { flex: 1; min-width: 0; display: flex; align-items: center; height: 50px; padding: 0 4px 0 16px; background: var(--surface); border-radius: 25px; box-shadow: var(--shadow); }
.search .search-icon { width: 20px; height: 20px; color: var(--muted); flex: none; }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; padding: 0 8px 0 10px; font-size: 16px; -webkit-appearance: none; appearance: none; }
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input::-webkit-search-cancel-button { display: none; }
.search:focus-within { box-shadow: var(--shadow), 0 0 0 2.5px color-mix(in srgb, var(--primary) 60%, transparent); }
.search-clear[hidden] { display: none; }
.search-clear { width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; display: grid; place-items: center; color: var(--muted); }
.round { flex: none; width: 50px; height: 50px; border: 0; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--text); }
.net { position: absolute; z-index: 5; top: 70px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px); margin: 0; display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 18px; background: var(--text); color: var(--surface); font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); }
.net[hidden] { display: none; }
.net svg { width: 18px; height: 18px; }
.toast { position: absolute; z-index: 8; top: 72px; left: 50%; transform: translate(-50%, -12px); width: max-content; max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 16px; background: var(--text); color: var(--surface); font-size: 14.5px; font-weight: 600; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- the sheet ---- */
.sheet { position: absolute; z-index: 4; left: 0; right: 0; bottom: 0; height: 42%; display: flex; flex-direction: column; background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: 0 -6px 26px rgba(30, 35, 25, 0.16); }
.sheet.animating { transition: height 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }
.grip { flex: none; height: 24px; display: grid; place-items: center; cursor: grab; touch-action: none; }
.grip span { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); }
.pane { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: none; padding: 0 16px 28px; outline: none; }
.sheet:not([data-snap="full"]) .pane { touch-action: none; }
.sheet[data-snap="full"] .pane { touch-action: pan-y; }
.sheet-tools { position: absolute; left: 12px; right: 12px; bottom: calc(100% + 12px); display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; pointer-events: none; transition: opacity 0.2s; }
.sheet-tools > * { pointer-events: auto; }
.sheet[data-snap="full"] .sheet-tools { opacity: 0; visibility: hidden; }
.attrib { margin: 0; padding: 3px 9px; border-radius: 10px; font-size: 11px; color: var(--text); background: color-mix(in srgb, var(--surface) 82%, transparent); }
.attrib a { color: inherit; text-decoration: none; }
.locate[data-state="on"] .locate-core, .locate[data-state="follow"] .locate-core { fill: var(--primary); stroke: var(--primary); }
.locate[data-state="follow"] { color: var(--primary); }
.locate[data-state="searching"] svg { animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

/* ---- lists ---- */
.list-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 2px 0 10px; background: var(--surface); }
.tabs { display: inline-flex; padding: 3px; border-radius: 15px; background: var(--surface-2); }
.tabs button { min-height: 44px; padding: 0 14px; border: 0; border-radius: 12px; background: none; font-weight: 650; font-size: 15px; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }
.count { margin-left: 3px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.results-head h2 { margin: 6px 0 0; font-size: 19px; line-height: 1.25; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.section-title { margin: 14px 0 4px; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.cards, .places { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.card { position: relative; width: 100%; display: flex; align-items: center; gap: 14px; padding: 9px 8px; margin: 0 -8px; width: calc(100% + 16px); border: 0; border-radius: 18px; background: none; text-align: left; }
@media (hover: hover) { .card:hover, .place:hover { background: var(--surface-2); } }
.card:active { background: var(--surface-2); }
.thumb { flex: none; position: relative; width: 92px; height: 92px; border-radius: 17px; overflow: hidden; background: var(--thumb); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line-strong) 50%, transparent); }
.thumb img { display: block; width: 100%; height: 100%; animation: fade 0.3s; }
@keyframes fade { from { opacity: 0; } }
.icon-thumb { display: grid; place-items: center; color: var(--primary); width: 64px; height: 64px; }
.icon-thumb .ic { width: 28px; height: 28px; }
.card-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.card-name { font-weight: 680; font-size: 17px; line-height: 1.25; letter-spacing: -0.01em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-size: 13.5px; color: var(--muted); }
.card-stats { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 14.5px; font-weight: 620; font-variant-numeric: tabular-nums; }
.card-stats .muted { font-weight: 500; color: var(--muted); }
.card-saved { position: absolute; top: 12px; left: 76px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); box-shadow: 0 0 0 2px var(--surface); }
.card-saved .ic { width: 14px; height: 14px; stroke-width: 3; }
.diff { font-size: 12.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.diff-easy, .chip.diff-easy { color: var(--easy); background: color-mix(in srgb, var(--easy) 13%, var(--surface)); }
.diff-moderate, .chip.diff-moderate { color: var(--moderate); background: color-mix(in srgb, var(--moderate) 13%, var(--surface)); }
.diff-hard, .chip.diff-hard { color: var(--hard); background: color-mix(in srgb, var(--hard) 13%, var(--surface)); }
.diff-strenuous, .chip.diff-strenuous { color: var(--strenuous); background: color-mix(in srgb, var(--strenuous) 13%, var(--surface)); }
.pending { display: inline-block; width: 110px; height: 14px; border-radius: 7px; margin-top: 2px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton .card { pointer-events: none; }
.skeleton .thumb { animation: pulse 1.3s ease-in-out infinite; }
.bar { display: block; height: 13px; border-radius: 7px; background: var(--surface-2); animation: pulse 1.3s ease-in-out infinite; }
.bar.w60 { width: 60%; height: 16px; } .bar.w40 { width: 40%; } .bar.w50 { width: 50%; }
@keyframes pulse { 50% { opacity: 0.55; } }
.place { width: 100%; display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 8px; margin: 0 -8px; width: calc(100% + 16px); border: 0; border-radius: 14px; background: none; text-align: left; }
.place .ic { color: var(--primary); }
.place span { display: grid; min-width: 0; }
.place b { font-weight: 650; }
.place small { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { display: grid; justify-items: center; gap: 10px; padding: 18px 12px 8px; text-align: center; color: var(--muted); }
.empty p { margin: 0; max-width: 300px; line-height: 1.45; }
.empty b { color: var(--text); }
.note { margin: 12px 0; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 14px; color: var(--muted); }
.loading-line { color: var(--muted); padding: 8px 0; }
.spinner { flex: none; display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--primary); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }
.btn { min-height: 48px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); color: var(--text); font-weight: 650; font-size: 15px; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: transparent; color: var(--on-primary); }
.btn.on { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 50%, transparent); background: color-mix(in srgb, var(--primary) 10%, var(--surface)); }
.icon-btn { flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text); }
.link-btn { min-height: 44px; padding: 0 2px; border: 0; background: none; color: var(--primary); font-weight: 650; font-size: 14px; display: inline-flex; align-items: center; }
.link-btn.danger { color: var(--warn); }

/* ---- trail page ---- */
.trail-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; gap: 8px; margin: 0 -2px; padding: 0 0 8px; background: var(--surface); }
.trail-title { flex: 1; min-width: 0; padding: 4px 4px 0; }
.trail-title h2 { margin: 0; font-size: 23px; line-height: 1.2; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.trail-title p { margin: 3px 0 0; font-size: 14px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 13px; font-weight: 650; background: var(--surface-2); color: var(--muted); }
.chip.diff { font-size: 13px; padding: 5px 10px; }
.chip.ok { color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.blaze i { width: 9px; height: 14px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; border: 1px solid var(--line); border-radius: 18px; }
.stat { min-width: 0; padding: 11px 12px 12px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat dt { font-size: 12.5px; font-weight: 650; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat dd { margin: 3px 0 0; font-size: clamp(21px, 6.4vw, 28px); font-weight: 750; letter-spacing: -0.025em; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat dd small { margin-left: 2px; font-size: 0.55em; font-weight: 650; letter-spacing: 0; color: var(--muted); }
.outback { margin: 10px 2px 0; font-size: 13.5px; color: var(--muted); }
.outback b { color: var(--text); }
.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0 20px; }
.act { flex-direction: column; gap: 3px; min-height: 62px; padding: 6px 4px; font-size: 13.5px; }
.act .ic { width: 22px; height: 22px; }
.ring { width: 22px; height: 22px; border-radius: 50%; background: conic-gradient(var(--primary) calc(var(--p) * 1turn), var(--line) 0); -webkit-mask: radial-gradient(circle, transparent 7px, #000 7.5px); mask: radial-gradient(circle, transparent 7px, #000 7.5px); }
.profile-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.profile h3, .about h3 { margin: 0; font-size: 17px; }
.chart-host { position: relative; margin: 4px -6px 0; min-height: 172px; touch-action: pan-y; }
.chart-host.compact { min-height: 92px; margin: 10px 0 0; }
.chart-wait { height: 172px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 14px; border-radius: 14px; background: var(--surface-2); margin: 0 6px; }
.chart { display: block; overflow: visible; -webkit-user-select: none; user-select: none; }
.chart-fill-top { stop-color: var(--primary); stop-opacity: 0.34; }
.chart-fill-bottom { stop-color: var(--primary); stop-opacity: 0.02; }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart-done { fill: var(--primary); opacity: 0.32; }
.chart-grid { stroke: var(--line); stroke-dasharray: 2 4; }
.chart-axis, .chart-tick { stroke: var(--line-strong); }
.chart-label { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart-unit { font-weight: 650; }
.chart-end { fill: var(--text); font-weight: 750; }
.chart-peak { fill: var(--primary); stroke: var(--surface); stroke-width: 2; }
.chart-cursor { stroke: var(--text); stroke-width: 1; opacity: 0.45; }
.chart-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 3; }
.chart-you { fill: var(--accent); stroke: var(--surface); stroke-width: 2.5; }
.chart-tip { fill: var(--text); }
.chart-tip-text { fill: var(--surface); font-size: 12px; font-weight: 650; }
.chart-hit { fill: transparent; cursor: crosshair; }
.range { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.range b { color: var(--text); font-weight: 650; }
.about { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 15px; }
.about p { margin: 0 0 10px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 0 0 12px; }
.facts dt { font-size: 12.5px; color: var(--muted); font-weight: 650; }
.facts dd { margin: 1px 0 0; overflow-wrap: anywhere; }
.links a { font-weight: 650; }
.fine { font-size: 12.5px; color: var(--muted); line-height: 1.45; }

/* ---- on the trail ---- */
.follow-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.follow-head h2 { margin: 0; font-size: 20px; line-height: 1.2; overflow-wrap: anywhere; }
.eyebrow { margin: 0 0 2px; font-size: 12.5px; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; color: var(--primary); }
.btn.end { min-width: 76px; background: var(--text); color: var(--surface); border-color: transparent; }
.progress { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-bottom: 12px; }
.progress span { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--primary); transition: width 0.6s; }
.stats.compact .stat dd { font-size: clamp(18px, 5.4vw, 23px); }
.gps { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.gps .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); flex: none; }
.gps.ok .dot { background: var(--primary); }
.gps.warn { color: var(--warn); font-weight: 600; }
.gps.warn .dot { background: var(--accent); }

/* ---- settings ---- */
dialog { width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; color: var(--text); overflow: hidden; overscroll-behavior: none; }
dialog[open] { display: flex; align-items: flex-end; justify-content: center; }
dialog::backdrop { background: rgba(10, 13, 10, 0.45); }
.dialog-card { width: 100%; max-width: 520px; max-height: calc(100% - 48px); display: flex; flex-direction: column; background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: var(--shadow); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 6px 20px; }
.dialog-head h2 { margin: 0; font-size: 21px; }
.dialog-body { overflow-y: auto; overflow-x: hidden; overscroll-behavior: none; padding: 0 20px 28px; outline: none; }
.field-label { margin: 18px 0 8px; font-size: 13px; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.segmented { display: flex; padding: 3px; border-radius: 15px; background: var(--surface-2); }
.segmented label { flex: 1; position: relative; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented span { display: grid; place-items: center; min-height: 46px; padding: 4px 8px; border-radius: 12px; text-align: center; font-weight: 650; font-size: 15px; color: var(--muted); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }
.segmented input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--primary) 70%, transparent); }
.storage { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.storage p { margin: 0; }
.hint, .about-text { font-size: 14px; color: var(--muted); line-height: 1.5; }
.about-text { margin: 0 0 10px; }

/* ---- the shared install prompt, in this app's colours ---- */
install-prompt {
  --ip-bg: var(--surface); --ip-fg: var(--text); --ip-muted: var(--muted); --ip-line: var(--line); --ip-chip: var(--surface-2);
  --ip-accent: var(--primary); --ip-on-accent: var(--on-primary); --ip-font: var(--font); --ip-radius: 24px; --ip-radius-inner: 14px;
}

/* ---- phone: the trail page and "on the trail" use the whole map above the sheet ---- */
@media (max-width: 899px) {
  body[data-view="trail"] .top, body[data-view="follow"] .top { display: none; }
  body[data-view="trail"] .net, body[data-view="follow"] .net { top: 12px; }
  body[data-view="trail"] .toast, body[data-view="follow"] .toast { top: 14px; }
}

/* ---- wide screens: a floating side panel ---- */
@media (min-width: 900px) {
  .top { top: 16px; left: 16px; right: auto; width: 420px; }
  .sheet { top: 80px; left: 16px; bottom: 16px; right: auto; width: 420px; height: auto !important; border-radius: 22px; box-shadow: var(--shadow); }
  .grip { display: none; }
  .pane, .sheet:not([data-snap="full"]) .pane { touch-action: auto; padding-top: 14px; border-radius: 22px; }
  .sheet-tools { position: fixed; left: auto; right: 16px; bottom: 16px; flex-direction: column-reverse; align-items: flex-end; }
  .sheet[data-snap="full"] .sheet-tools { opacity: 1; visibility: visible; }
  .net, .toast { left: calc(50% + 218px); }
  dialog[open] { align-items: center; }
  .dialog-card { border-radius: 24px; }
}
