:root {
  --night: #0c1316; --asphalt: #141e22; --kerb: #1c292e; --line: #2a3a41;
  --paper: #eef1ea; --ink: #11181b; --muted: #8b9ca3; --sign: #f4c430; --sign-ink: #1d1700;
  --dry: #3fb37f; --showers: #7fa7c9; --light: #e9b949; --moderate: #f08a3c; --heavy: #e5484d;
  --display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  --body: 'Atkinson Hyperlegible', Verdana, sans-serif;
  --mono: 'Martian Mono', ui-monospace, monospace;
  --r: 14px;
  color-scheme: dark;
}
/* Light follows the phone unless theme.js set data-theme from the header switch */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --night: #e9ece6; --asphalt: #f6f7f3; --kerb: #ffffff; --line: #cfd6d2; --paper: #11181b; --ink: #f6f7f3; --muted: #56656b; color-scheme: light; }
}
:root[data-theme="light"] { --night: #e9ece6; --asphalt: #f6f7f3; --kerb: #ffffff; --line: #cfd6d2; --paper: #11181b; --ink: #f6f7f3; --muted: #56656b; color-scheme: light; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
button, label, .nav-how { -webkit-user-select: none; user-select: none; }
/* Installed app: no page bounce or pull-to-refresh */
@media (display-mode: standalone) { html, body { overscroll-behavior-y: none; } }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--night); color: var(--paper); font: 16px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
a { color: var(--sign); }
:focus-visible { outline: 3px solid var(--sign); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header with monsoon streaks ---------- */
/* Safe-area insets are 0 in a browser tab; the installed iPhone app draws under the status bar */
.masthead { position: relative; overflow: hidden; padding: max(18px, calc(env(safe-area-inset-top) + 8px)) 16px 22px; border-bottom: 1px solid var(--line);
  background: radial-gradient(120% 140% at 85% -20%, color-mix(in srgb, var(--sign) 14%, transparent), transparent 55%), var(--asphalt); }
.masthead::before { content: ""; position: absolute; inset: -50% -10%; pointer-events: none; opacity: .18;
  background: repeating-linear-gradient(105deg, transparent 0 22px, var(--paper) 22px 23px, transparent 23px 61px);
  mask: linear-gradient(to bottom, #000, transparent 85%); animation: rain 1.1s linear infinite; }
@keyframes rain { to { transform: translate(-12px, 58px); } }
.bar { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1280px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--paper); }
.brand svg { width: 26px; height: 32px; flex: none; }
.brand b { font: 900 1.7rem/1 var(--display); letter-spacing: .04em; text-transform: uppercase; }
.nav-how { font: 600 .95rem var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--paper); text-decoration: none;
  border: 1px solid var(--line); padding: 8px 12px; border-radius: 999px; background: color-mix(in srgb, var(--night) 60%, transparent); }
.nav-how:hover { border-color: var(--sign); color: var(--sign); }
.tagline { position: relative; max-width: 1280px; margin: 14px auto 0; font: 800 clamp(2rem, 7vw, 3.6rem)/.95 var(--display); text-transform: uppercase; letter-spacing: .01em; }
.tagline em { font-style: normal; color: var(--sign); }
.here { position: relative; max-width: 1280px; margin: 16px auto 0; display: grid; gap: 10px; }
.here-pick { display: flex; align-items: center; gap: 8px; max-width: 420px; }
.here-pick .field-label { flex: none; }
.here-pick input { padding: 8px 12px; }
.here-pick .icon-btn { width: 38px; height: 38px; }
.here-days { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; max-width: 640px; }
@media (max-width: 520px) { .here-days { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.here-days[hidden] { display: none; }
.here-days li { background: color-mix(in srgb, var(--night) 60%, transparent); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; gap: 2px; }
.here-days li { position: relative; }
.here-days .ico { position: absolute; top: 8px; right: 10px; font-size: 1.9rem; line-height: 1; }
.here-days .d { font: 600 .78rem var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.here-days .t { font: 800 1.5rem/1 var(--display); }
.here-days .t small { font-size: .9rem; color: var(--muted); }
.here-days .w { font-size: .8rem; }
.here-days .r { font: .72rem var(--mono); color: var(--muted); }
.here-days .r.wet { color: var(--showers); }
.here-note { margin: 0; font-size: .8rem; color: var(--muted); }
.here-note:empty { display: none; }

/* ---------- App layout ---------- */
.app { max-width: 1280px; margin: 0 auto; display: grid; gap: 16px; padding: 16px; }
@media (min-width: 960px) {
  .app { grid-template-columns: minmax(360px, 440px) 1fr; align-items: start; }
  /* The Find card sits above the map; the pair stays in view while the cards on the left scroll */
  .side { position: sticky; top: 16px; height: calc(100vh - 32px); }
  .side .map-wrap { flex: 1; min-height: 0; }
  #map { height: 100% !important; }
}
.side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; }

/* ---------- Trip ticket (form) ---------- */
.ticket { background: var(--kerb); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 14px; }
.legs { position: relative; display: grid; gap: 10px; padding-left: 26px; }
.legs::before { content: ""; position: absolute; left: 8px; top: 22px; bottom: 22px; width: 2px;
  background: repeating-linear-gradient(var(--muted) 0 6px, transparent 6px 12px); }
.leg { position: relative; display: flex; gap: 6px; align-items: center; }
.leg::before { content: ""; position: absolute; left: -24px; width: 12px; height: 12px; border-radius: 50%; background: var(--kerb); border: 2px solid var(--muted); }
.leg.start::before { background: var(--paper); border-color: var(--paper); }
.leg.end::before { background: var(--sign); border-color: var(--sign); border-radius: 3px; }
.leg input { flex: 1; }
.place-list { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px; list-style: none; background: var(--kerb); color: var(--paper); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgb(0 0 0 / .35); }
.place-list[hidden] { display: none; }
.place-list li { padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.place-list li:hover, .place-list li.active { background: var(--asphalt); color: var(--sign); }
.field-label { font: 600 .78rem var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
input, select { font: inherit; color: var(--paper); background: var(--asphalt); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; min-width: 0; width: 100%; }
input::placeholder { color: var(--muted); }
/* Spinner while place suggestions load */
input.place.loading { padding-right: 36px; background: var(--asphalt) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3a9 9 0 0 1 9 9' fill='none' stroke='%23e9b949' stroke-width='3' stroke-linecap='round'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='.8s' repeatCount='indefinite'/%3E%3C/path%3E%3C/svg%3E") no-repeat right 12px center / 18px; }
#status .link { color: inherit; font-size: inherit; font-weight: 700; }
input:focus { border-color: var(--sign); outline: none; }
.icon-btn { flex: none; width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--asphalt); color: var(--paper); cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { border-color: var(--sign); color: var(--sign); }
.icon-btn svg { width: 18px; height: 18px; }
.add-stop { justify-self: start; margin-left: 26px; background: none; border: 1px dashed var(--line); color: var(--muted); border-radius: 999px; padding: 6px 12px; font: 600 .85rem var(--display); letter-spacing: .1em; text-transform: uppercase; cursor: pointer; }
.add-stop:hover { color: var(--sign); border-color: var(--sign); }
.add-stop[hidden] { display: none; }
.when { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } /* minmax: iPhone's date/time boxes have a wide built-in minimum that pushed past the form */
.when label { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; min-width: 0; } /* Safari sized an auto column from the date box's native width */
/* iPhone ignores the width of its native date/time boxes; without native styling they fit, and min-height stops an empty one collapsing */
.when input { -webkit-appearance: none; appearance: none; display: block; max-width: 100%; min-height: calc(1.5em + 24px); }
/* Travel mode: a row of icon pills, like a maps app; Custom opens a speed box under the row */
.vehicles { position: relative; display: flex; flex-wrap: wrap; gap: 4px; border: 0; }
.vehicles input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.vehicles input + label { flex: 1; display: grid; justify-items: center; gap: 2px; padding: 8px 2px 6px; border-radius: 999px; cursor: pointer; color: var(--muted); transition: background .15s, color .15s; }
.vehicles svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.vehicles label small { font: 400 .62rem var(--mono); }
.vehicles input:hover + label { color: var(--paper); }
.vehicles input:checked + label { background: color-mix(in srgb, var(--showers) 32%, transparent); color: var(--paper); }
.vehicles input:checked + label svg { animation: pop .25s; }
@keyframes pop { 50% { transform: scale(1.15); } }
.vehicles input:focus-visible + label { outline: 3px solid var(--sign); outline-offset: -3px; }
.custom-speed { display: none; flex-basis: 100%; align-items: center; justify-content: center; gap: 8px; margin-top: 4px; font-size: .9rem; color: var(--muted); }
.vehicles:has(#v-custom:checked) .custom-speed { display: flex; }
.custom-speed input { width: 5em; padding: 6px 8px; text-align: center; }
.go { font: 900 1.35rem/1 var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--sign-ink); background: var(--sign);
  border: 0; border-radius: 10px; padding: 16px; cursor: pointer; box-shadow: 0 4px 0 color-mix(in srgb, var(--sign) 55%, #000); transition: transform .08s, box-shadow .08s; }
.go:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--sign) 55%, #000); }
.go[disabled] { opacity: .6; cursor: progress; }

#status { font: .85rem var(--mono); color: var(--muted); min-height: 1.3em; margin: -4px 2px; }
#status.error { color: var(--heavy); }
#status:not(:empty):not(.error)::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--sign); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .2; } }

/* ---------- Verdict milestone ---------- */
.milestone { display: none; border-radius: 120px 120px var(--r) var(--r); overflow: hidden; background: var(--paper); color: var(--ink); box-shadow: 0 18px 40px -18px #000; }
.milestone.show { display: block; animation: rise .5s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.cap { background: var(--sign); color: var(--sign-ink); text-align: center; padding: 26px 20px 12px; }
.cap .kicker { font: 600 .72rem var(--mono); letter-spacing: .08em; text-transform: uppercase; opacity: .7; }
.cap h2 { margin: 2px 0 0; font: 900 clamp(2.1rem, 9vw, 2.9rem)/.95 var(--display); text-transform: uppercase; letter-spacing: .02em; }
.milestone.typical .cap { background: repeating-linear-gradient(135deg, var(--sign) 0 14px, color-mix(in srgb, var(--sign) 80%, #fff) 14px 28px); }
.stone { padding: 14px 18px 18px; }
.stone .sentence { margin: 0 0 12px; font-size: 1.05rem; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: color-mix(in srgb, var(--ink) 15%, transparent); border-radius: 8px; overflow: hidden; }
.stats div { background: var(--paper); padding: 8px 6px; text-align: center; }
.stats b { display: block; font: 600 .95rem var(--mono); }
.stats span { font: 600 .66rem var(--display); letter-spacing: .12em; text-transform: uppercase; opacity: .65; }
.stone .note { margin: 12px 0 0; font-size: .82rem; opacity: .75; }
.share-btn { display: block; width: 100%; margin-top: 14px; padding: 12px; border-radius: 10px; cursor: pointer; border: 0;
  font: 800 1.05rem var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--paper); background: var(--ink); }
.share-btn:hover { color: var(--sign); }

/* ---------- Journey ribbon (milestones along the trip) ---------- */
.ribbon-wrap { display: none; }
.ribbon-wrap.show { display: block; }
.ribbon-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 2px 8px; }
.ribbon-head h3 { margin: 0; font: 800 1.1rem var(--display); letter-spacing: .1em; text-transform: uppercase; }
.ribbon-head span { font: .72rem var(--mono); color: var(--muted); }
.ribbon { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.post { flex: none; width: 66px; scroll-snap-align: start; border: 0; padding: 0; cursor: pointer; background: none; color: var(--paper); text-align: center; font: inherit;
  animation: rise .4s both; animation-delay: calc(var(--i) * 35ms); }
.post .time { font: 600 .68rem var(--mono); color: var(--muted); }
.post .rock { margin-top: 4px; height: 64px; border-radius: 33px 33px 6px 6px; background: var(--kerb); border: 1px solid var(--line); position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; }
.post .rock::before { content: ""; position: absolute; inset: 0 0 auto; height: 22px; background: var(--lvl); }
.post .fill { background: color-mix(in srgb, var(--lvl) 35%, transparent); height: var(--h); }
.post .temp { position: absolute; left: 0; right: 0; top: 28px; font: 700 .9rem var(--display); }
.post .lvl { font: 600 .62rem var(--display); letter-spacing: .1em; text-transform: uppercase; margin-top: 4px; display: block; }
.post .km { font: .62rem var(--mono); color: var(--muted); }
.post:hover .rock, .post[aria-pressed="true"] .rock { border-color: var(--sign); }

/* ---------- Hazards and packing (inside the milestone) ---------- */
.warns { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.warns:empty, .pack:empty { display: none; }
.warn { padding: 8px 10px 8px 34px; border-radius: 8px; font-size: .88rem; position: relative; background: color-mix(in srgb, var(--c) 18%, transparent); border-left: 4px solid var(--c); }
.warn::before { position: absolute; left: 10px; top: 7px; font: 900 1rem var(--display); }
.warn.fog { --c: #7c8b93; } .warn.fog::before { content: "≋"; }
.warn.wind { --c: #3e8ed0; } .warn.wind::before { content: "≫"; }
.warn.heat { --c: var(--moderate); } .warn.heat::before { content: "☀"; }
.warn.thunder { --c: #8e6bd8; } .warn.thunder::before { content: "ϟ"; }
.warn.dark { --c: #5a6f96; } .warn.dark::before { content: "☾"; }
.pack { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 12px; }
.pack-label { font: 700 .72rem var(--display); letter-spacing: .14em; text-transform: uppercase; opacity: .65; margin-right: 2px; }
.chip { font-size: .8rem; padding: 3px 10px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--ink) 25%, transparent); }

/* ---------- Side cards: other road, stops, feedback ---------- */
.card { display: none; background: var(--kerb); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.card.show { display: block; animation: rise .45s cubic-bezier(.2,.8,.2,1); }
.card h3 { margin: 0 0 6px; font: 800 1.15rem var(--display); letter-spacing: .08em; text-transform: uppercase; }
.card p { margin: 0 0 10px; font-size: .92rem; }
.card .small { margin: 8px 0 0; font-size: .78rem; color: var(--muted); }
#alt.drier, #best { border-color: var(--dry); }
#alt.drier h3, #best h3 { color: var(--dry); }
#wetroad { border-color: var(--showers); } #wetroad h3 { color: var(--showers); }
/* Logged-in cards: signed-out visitors see the heading and a blurred body under an unlock button */
.unlock { display: none; }
.card.locked { position: relative; }
.card.locked > :not(h3, .unlock) { filter: blur(5px); user-select: none; }
.card.locked .unlock { display: block; position: absolute; left: 50%; top: calc(50% + 14px); transform: translate(-50%, -50%); white-space: nowrap; cursor: pointer;
  font: 800 .85rem var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--sign-ink); background: var(--sign); border: 0; border-radius: 999px; padding: 9px 16px; box-shadow: 0 3px 12px #0006; }
/* Road tabs float along the top of the map, between the zoom and radar buttons */
.roads { position: absolute; z-index: 1000; top: 10px; left: 54px; right: 104px; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
@media (max-width: 600px) { .roads { top: 56px; right: 10px; } } /* below the radar button, so two roads fit side by side */
.road-tab { flex: none; display: grid; gap: 1px; text-align: left; color: var(--paper); background: color-mix(in srgb, var(--night) 85%, transparent); backdrop-filter: blur(6px); border: 2px solid var(--line); border-radius: 10px; padding: 5px 10px; cursor: pointer; font-size: .72rem; }
.road-tab b { font: 800 .85rem var(--display); letter-spacing: .06em; text-transform: uppercase; }
.road-tab:hover { border-color: var(--sign); }
.road-tab .src { margin-left: 6px; font: 600 .62rem var(--body); letter-spacing: 0; text-transform: none; color: var(--muted); }
.road-tab.more { align-content: center; border-style: dashed; font: 800 .85rem var(--display); letter-spacing: .06em; text-transform: uppercase; }
.road-tab.more:disabled { cursor: default; opacity: .75; border-color: var(--line); }
.road-tab[aria-pressed="true"] { border-color: var(--sign); background: color-mix(in srgb, var(--sign) 30%, var(--night)); }
.ghost { font: 700 .9rem var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--paper); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer; }
.ghost:hover { border-color: var(--sign); color: var(--sign); }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; font-size: .85rem; }
.fb-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.feedback { border-color: var(--sign); }
.recent-list { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; }
.recent-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); }
.recent-list li:first-child { border-top: 0; }
.recent-list a { flex: 1; min-width: 0; color: var(--paper); text-decoration: none; padding: 9px 0; }
.recent-list .trip-mode { flex: none; width: 1.6em; font-size: 1.15rem; text-align: center; }
.recent-list a small { display: block; color: var(--muted); font-size: .75rem; }
.recent-list a:hover { color: var(--sign); }
.recent-list .link { font-size: 1.2rem; text-decoration: none; padding: 4px 8px; }
.recent-list:empty::after { content: 'Your searches will show up here.'; color: var(--muted); font-size: .85rem; }
.nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
button.nav-how { cursor: pointer; }
.nav-how.install { background: var(--sign); color: var(--sign-ink); border-color: var(--sign); }
/* Install popup: slides up above the tab bar; the step's icon bobs to catch the eye */
.install-pop { position: fixed; z-index: 1250; left: 12px; right: 12px; bottom: calc(var(--tabbar, 0px) + 12px); max-width: 440px; margin: 0 auto;
  display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; padding: 14px; border-radius: var(--r); background: var(--kerb); border: 1px solid var(--sign);
  box-shadow: 0 18px 40px -12px #000; animation: slide-up .45s cubic-bezier(.2,.8,.2,1); }
.install-pop[hidden] { display: none; }
@keyframes slide-up { from { opacity: 0; transform: translateY(110%); } }
.install-pop img { border-radius: 10px; }
.install-pop h3 { margin: 0 0 2px; font: 800 1.1rem var(--display); letter-spacing: .08em; text-transform: uppercase; }
.install-pop p { margin: 0; font-size: .88rem; }
.pop-ico { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; margin: 0 4px; vertical-align: middle; border-radius: 6px; font-weight: 700;
  background: color-mix(in srgb, var(--sign) 25%, transparent); color: var(--paper); animation: bob 1.2s ease-in-out infinite; }
.pop-ico svg { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.install-pop-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.install-pop .go { padding: 10px 18px; font-size: 1rem; }
.install-pop .go[hidden] { display: none; }
.nav .who { max-width: 24ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .brand { margin-right: auto; }
.side-toggle, .theme-btn { display: inline-flex; padding: 7px 9px; }
.theme-btn svg { width: 20px; height: 20px; }
.side-toggle[hidden] { display: none; }
.side-toggle svg { width: 20px; height: 20px; }
/* My Recent Searches: a left side panel; pushes the page over on wide screens, slides over it on phones */
.drawer { position: fixed; inset: 0 auto 0 0; z-index: 1100; width: min(280px, 85vw); display: flex; flex-direction: column; padding: 16px; background: var(--kerb); border-right: 1px solid var(--line); transform: translateX(-100%); transition: transform .2s; }
.drawer[hidden] { display: none; }
.side-open .drawer { transform: none; box-shadow: 0 0 40px -10px #000; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.drawer h3 { margin: 0; font: 800 1.15rem var(--display); letter-spacing: .08em; text-transform: uppercase; }
#side-close { font-size: 1.4rem; text-decoration: none; }
@media (min-width: 1100px) { body.side-open { padding-left: 280px; } .side-open .drawer { box-shadow: none; } }
.login .go { width: 100%; }
.login .or { margin: 14px 0 8px; font-size: .85rem; opacity: .75; }
.login .ghost, .login .link { color: var(--ink); border-color: color-mix(in srgb, var(--ink) 40%, transparent); }
.signin-email { display: flex; gap: 8px; margin-bottom: 10px; }
.signin-email input { padding: 7px 12px; }
.signin-email button { white-space: nowrap; }
#recent .small:empty, #login-note:empty { display: none; }
.stop-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.stop-list button { width: 100%; display: flex; gap: 10px; align-items: baseline; text-align: left; background: var(--asphalt); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--paper); cursor: pointer; font: inherit; }
.stop-list button:hover { border-color: var(--sign); }
.stop-list .kind { flex: none; min-width: 84px; font: 700 .72rem var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--sign); }
.premium { font: 800 .62rem var(--display); letter-spacing: .14em; padding: 2px 7px; border-radius: 999px; background: var(--sign); color: var(--sign-ink); vertical-align: middle; margin-left: 6px; }
.find-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.find-chips button { font: 700 .78rem var(--display); letter-spacing: .08em; text-transform: uppercase; padding: 7px 11px; border-radius: 999px; cursor: pointer;
  background: var(--asphalt); color: var(--paper); border: 1px solid var(--line); }
.find-chips button:hover:not(:disabled) { border-color: var(--sign); }
.find-chips button[aria-pressed="true"] { background: #2e9e5b; border-color: #2e9e5b; color: #fff; }
.find-chips button:disabled { opacity: .45; cursor: not-allowed; }
/* ::before, so reduced motion (below) leaves a still ring instead of a spinning one */
.find-chips button[aria-busy="true"]::before { content: ''; display: inline-block; width: .8em; height: .8em; margin-right: 6px; vertical-align: -1px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.stop-pin { display: grid !important; place-items: center; background: var(--sign); color: var(--sign-ink); border: 2px solid #11181b; border-radius: 6px; font: 900 .8rem var(--display); }

/* ---------- Map ---------- */
.radar-ctl { position: absolute; z-index: 500; top: 10px; right: 10px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.radar-ctl button { font: 800 .85rem var(--display); letter-spacing: .12em; text-transform: uppercase; padding: 8px 12px; border-radius: 8px; cursor: pointer;
  color: var(--paper); background: color-mix(in srgb, var(--night) 85%, transparent); border: 1px solid var(--line); backdrop-filter: blur(6px); }
.radar-ctl button[aria-pressed="true"] { background: #3e8ed0; border-color: #3e8ed0; color: #fff; }
.find-pin { display: grid !important; place-items: center; background: #2e9e5b; color: #fff; border: 2px solid #11181b; border-radius: 6px; font: 900 .62rem var(--display); white-space: nowrap; }
#radar-time:not(:empty) { font: .7rem var(--mono); padding: 3px 8px; border-radius: 6px; background: color-mix(in srgb, var(--night) 85%, transparent); }
.map-wrap { position: relative; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); min-height: 58vh; background: var(--asphalt); }
#map { height: 58vh; background: var(--asphalt); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.6); } }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.6); }
.legend { position: absolute; z-index: 500; left: 10px; bottom: 26px; display: flex; gap: 10px; flex-wrap: wrap; padding: 6px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--night) 82%, transparent); backdrop-filter: blur(6px); font: 600 .72rem var(--display); letter-spacing: .1em; text-transform: uppercase; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; background: var(--c); vertical-align: 0; }
.leaflet-popup-content-wrapper { border-radius: 12px; background: var(--paper); color: var(--ink); }
.leaflet-popup-tip { background: var(--paper); }
.leaflet-popup-content { font: .85rem/1.45 var(--body); margin: 12px 14px; }
.leaflet-popup-content b { font: 800 1.05rem var(--display); letter-spacing: .04em; }
.leaflet-container a.leaflet-popup-close-button { color: var(--ink); }
.pop-lvl { display: inline-block; margin: 4px 0; padding: 1px 8px; border-radius: 999px; font: 700 .72rem var(--display); letter-spacing: .1em; text-transform: uppercase; color: #111; }

/* ---------- How it works ---------- */
.how { border-top: 1px solid var(--line); background: var(--asphalt); padding: 48px 16px 24px; }
.how-inner { max-width: 1080px; margin: 0 auto; }
.how h2 { margin: 0; font: 900 clamp(2.2rem, 7vw, 3.4rem)/.95 var(--display); text-transform: uppercase; }
.how h2 em { font-style: normal; color: var(--sign); }
.how .lede { max-width: 60ch; color: var(--muted); margin: 10px 0 32px; }
.road { list-style: none; margin: 0; padding: 0 0 0 56px; position: relative; display: grid; gap: 26px; counter-reset: stop; }
.road::before { content: ""; position: absolute; left: 18px; top: 0; bottom: 0; width: 6px; border-radius: 3px; background: var(--kerb); }
.road::after { content: ""; position: absolute; left: 20px; top: 8px; bottom: 8px; width: 2px; background: repeating-linear-gradient(var(--sign) 0 14px, transparent 14px 26px); }
.road li { position: relative; counter-increment: stop; }
.road li::before { content: counter(stop); position: absolute; left: -56px; top: -2px; width: 44px; height: 52px; border-radius: 22px 22px 6px 6px;
  background: linear-gradient(var(--sign) 0 44%, var(--paper) 44%); color: var(--sign-ink); display: grid; place-items: start center; padding-top: 2px;
  font: 900 1.2rem var(--display); box-shadow: 0 6px 16px -8px #000; z-index: 1; }
.road h3 { margin: 0 0 4px; font: 800 1.35rem var(--display); letter-spacing: .05em; text-transform: uppercase; }
.road p { margin: 0; max-width: 62ch; }
.road code { font: .82rem var(--mono); background: var(--kerb); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.road .eg { margin-top: 8px; font: .78rem var(--mono); color: var(--muted); }
.keys { display: grid; gap: 16px; margin-top: 40px; }
@media (min-width: 760px) { .keys { grid-template-columns: 1.2fr 1fr; } }
.key { background: var(--kerb); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.key h3 { margin: 0 0 10px; font: 800 1.15rem var(--display); letter-spacing: .1em; text-transform: uppercase; }
.key table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.key td, .key th { text-align: left; padding: 7px 4px; border-top: 1px solid var(--line); }
.key th { font: 600 .72rem var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); border-top: 0; }
.key td:nth-child(2) { font-family: var(--mono); font-size: .8rem; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; background: var(--c); }
.key p { margin: 10px 0 0; font-size: .85rem; color: var(--muted); }
.key dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; font-size: .92rem; }
.key dt { font: 800 1rem var(--display); letter-spacing: .08em; text-transform: uppercase; }
.key dd { margin: 0; }

/* ---------- Caution dialog (shown on every load) ---------- */
.caution { width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 0; border: 0; border-radius: var(--r); background: var(--paper); color: var(--ink); box-shadow: 0 30px 80px -20px #000; overflow: hidden; }
.caution::backdrop { background: color-mix(in srgb, var(--night) 75%, transparent); backdrop-filter: blur(3px); }
.caution[open] { animation: rise .35s cubic-bezier(.2,.8,.2,1); }
.caution .stripe { height: 14px; background: repeating-linear-gradient(135deg, var(--sign) 0 14px, var(--ink) 14px 28px); }
.caution .body { padding: 18px 20px 20px; }
.caution h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font: 900 1.9rem/1 var(--display); text-transform: uppercase; letter-spacing: .02em; }
.caution h2 svg { width: 34px; height: 30px; flex: none; }
.caution p { margin: 0 0 10px; }
.caution ul { margin: 0 0 16px; padding-left: 20px; }
.caution li { margin-bottom: 4px; }
.caution .go { width: 100%; }

/* ---------- What people say ---------- */
.says { width: 100%; min-width: 0; max-width: 1280px; margin: 8px auto 0; padding: 0 16px; } /* width: on phones body is a flex column, where auto margins would size it to the scrolling strip */
.says h3 { margin: 0 0 10px; font: 800 1.1rem var(--display); letter-spacing: .1em; text-transform: uppercase; }
.says-list { list-style: none; margin: 0; padding: 0 0 8px; display: grid; grid-auto-flow: column; grid-auto-columns: min(340px, 86%); align-items: start; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: thin; }
@media (min-width: 960px) { .says-list { grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); } }
/* Each quote is drawn as an X post, in X's own colours for the current theme */
.says-list { --x-bg: #000; --x-text: #e7e9ea; --x-muted: #71767b; --x-line: #2f3336; }
@supports (color: light-dark(#000, #fff)) { .says-list { --x-bg: light-dark(#fff, #000); --x-text: light-dark(#0f1419, #e7e9ea); --x-muted: light-dark(#536471, #71767b); --x-line: light-dark(#cfd9de, #2f3336); } }
.says-list li { scroll-snap-align: start; position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); align-content: start; column-gap: 12px; padding: 12px 40px 14px 16px;
  background: var(--x-bg); color: var(--x-text); border: 1px solid var(--x-line); border-radius: 16px; font: 15px/20px -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; }
.says-list li::after { content: ""; position: absolute; top: 14px; right: 14px; width: 18px; height: 18px; background: var(--x-text);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z'/%3E%3C/svg%3E") center / contain no-repeat; }
.says .av { grid-row: span 2; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--a); color: #fff; font-weight: 700; font-size: 17px; }
/* Like X, a long header gives up the handle first and keeps the date */
.says .x-head { margin: 0; display: flex; gap: 4px; min-width: 0; white-space: nowrap; color: var(--x-muted); }
.says .x-head b { flex: none; color: var(--x-text); }
.says .handle { min-width: 0; overflow: hidden; filter: blur(4px); user-select: none; }
.says .ago { flex: none; }
.says blockquote { margin: 2px 0 0; overflow-wrap: anywhere; }

footer { max-width: 1080px; margin: 0 auto; padding: 24px 16px max(40px, env(safe-area-inset-bottom)); font-size: .82rem; color: var(--muted); display: grid; gap: 6px; }
footer strong { color: var(--paper); }
footer a.coffee { background: #FFDD00; color: #000; padding: 2px 10px; border-radius: 999px; text-decoration: none; font-weight: 600; white-space: nowrap; }
.reveal { animation: rise .6s both; }
.reveal:nth-child(2) { animation-delay: .08s; } .reveal:nth-child(3) { animation-delay: .16s; }
/* Full-screen map: the map box covers the page (and the tab bar); borders keep its controls off the notch and home bar */
.map-full-btn { position: absolute; z-index: 1000; top: 84px; left: 10px; width: 34px; height: 34px; display: grid; place-items: center; padding: 0; cursor: pointer;
  color: #333; background: #fff padding-box; border: 2px solid rgba(0, 0, 0, .2); border-radius: 4px; }
.map-full-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.map-full-btn[aria-pressed="true"] .open, .map-full-btn[aria-pressed="false"] .close { display: none; }
body.map-full { overflow: hidden; }
body.map-full .map-wrap { position: fixed; inset: 0; z-index: 1300; min-height: 0; border-radius: 0; animation: none;
  border: 0 solid var(--asphalt); border-width: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
body.map-full #map { height: 100% !important; }
body.map-full .side { z-index: 1300; } /* on wide screens .side is sticky, so the map's z-index only counts inside it */

/* ---------- Phones: one tab at a time over a bottom tab bar (app.js sets body[data-tab]) ---------- */
.tabbar, .tab-empty { display: none; }
@media (max-width: 759px) {
  :root { --tabbar: calc(62px + env(safe-area-inset-bottom)); }
  body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; padding-bottom: var(--tabbar); } /* vh first: browsers before Chrome 108 drop dvh */
  .masthead { order: -1; padding-bottom: 12px; }
  main.app { width: 100%; min-width: 0; } /* its auto margins would otherwise size it to the milestone strip's full length */
  .reveal { animation: none; } /* it would replay on every tab switch */
  .tabbar { position: fixed; z-index: 1200; inset: auto 0 0 0; height: var(--tabbar); padding-bottom: env(safe-area-inset-bottom);
    display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--asphalt) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
  .tabbar button { position: relative; display: grid; place-items: center; align-content: center; gap: 3px; min-height: 44px; background: none; border: 0; cursor: pointer;
    color: var(--muted); font: 700 .72rem var(--display); letter-spacing: .12em; text-transform: uppercase; }
  .tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .1s; }
  .tabbar button:active svg { transform: scale(.88); }
  .tabbar [aria-current] { color: var(--sign); }
  .tabbar .dot::after { content: ""; position: absolute; top: 8px; left: calc(50% + 9px); width: 8px; height: 8px; border-radius: 50%; background: var(--heavy); }

  /* Header: one line; its buttons live on the Me tab */
  .brand b { font-size: 1.4rem; white-space: nowrap; }
  .brand svg { width: 22px; height: 27px; }
  .side-toggle, #side-close { display: none !important; }
  body:not([data-tab="me"]) :is(.nav, footer), body:not([data-tab="plan"]) :is(.tagline, .here, .says), .drawer { display: none; }

  /* Plan: town weather and the form */
  [data-tab="plan"] .panel > :is(#verdict, #ribbon-wrap, #best, #wetroad, #alt, #stops), [data-tab="plan"] .side { display: none; }

  /* Result: the verdict and its cards */
  [data-tab="result"] :is(#feedback, #trip), [data-tab="result"] .side { display: none; }
  [data-tab="result"]:not(.has-result) .tab-empty { display: block; margin: 24px 4px; color: var(--muted); text-align: center; }

  /* Map: only the map (with Find on the road above it), filling the screen between header and tabs */
  body[data-tab="map"] { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
  [data-tab="map"] main.app { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 0; padding: 0; }
  [data-tab="map"] .panel { display: none; }
  [data-tab="map"] .side { flex: 1; min-height: 0; gap: 0; }
  [data-tab="map"] .map-wrap { flex: 1; min-height: 0; border: 0; border-radius: 0; }
  [data-tab="map"] #map { height: 100% !important; }
  [data-tab="map"] #find { border-width: 0 0 1px; border-radius: 0; padding: 8px 12px; }
  [data-tab="map"] #find h3 { font-size: .9rem; margin-bottom: 6px; }
  [data-tab="map"] .find-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  [data-tab="map"] .find-chips button { flex: none; }
  .radar-ctl { display: none; }
  .roads { top: 10px; } /* Radar's spot is free on phones */

  /* Me: account buttons, My Recent Searches and the small print */
  [data-tab="me"] main.app { display: none; }
  [data-tab="me"] .bar { flex-wrap: wrap; }
  [data-tab="me"] .nav { flex-basis: 100%; flex-direction: column; align-items: stretch; margin-top: 16px; }
  [data-tab="me"] .nav-how { text-align: center; padding: 13px; font-size: 1.05rem; }
  [data-tab="me"] .nav .who { max-width: none; }
  [data-tab="me"] .drawer:not([hidden]) { display: flex; position: static; transform: none; width: auto; margin: 16px; border: 1px solid var(--line); border-radius: var(--r); box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } html { scroll-behavior: auto; } }
