:root {
  --route: #0b5d3b;      /* UK primary-route sign green */
  --route-ink: #ffffff;
  --sign: #ffc72c;       /* primary-route yellow */
  --asphalt: #22272b;
  --kerb: #e7e9e4;
  --paper: #ffffff;
  --ink: #22272b;
  --muted: #5d666c;
  --amber: #a35f00;
  --danger: #b3261e;
  --line: #d5d9d3;
  --shadow: 0 -2px 18px rgb(20 30 25 / 18%);
  --font: 'Overpass', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #1b1f22; --ink: #eef1ec; --muted: #a3ada6; --kerb: #2a3034; --line: #394046;
    --route: #12804f; --amber: #f0a742; --danger: #ff8a80; --shadow: 0 -2px 18px rgb(0 0 0 / 50%);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --paper: #1b1f22; --ink: #eef1ec; --muted: #a3ada6; --kerb: #2a3034; --line: #394046;
  --route: #12804f; --amber: #f0a742; --danger: #ff8a80; --shadow: 0 -2px 18px rgb(0 0 0 / 50%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 400 16px/1.45 var(--font); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-underline-offset: 2px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--sign); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* The price, set like a forecourt totem: whole pence big, the tenth raised and small. */
.ppl { font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1; white-space: nowrap; }
.ppl sup { font-size: 0.55em; vertical-align: 0.62em; margin-left: 0.04em; }

/* ---------- app shell ---------- */
.app { height: 100dvh; overflow: hidden; }
#map { position: fixed; inset: 0; background: var(--kerb); }
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 3; padding: max(12px, env(safe-area-inset-top)) 12px 0; pointer-events: none; }
.top > * { pointer-events: auto; }
.search { position: relative; display: flex; background: var(--route); color: var(--route-ink); border: 2px solid var(--route-ink); outline: 2px solid var(--route); border-radius: 10px; max-width: 560px; }
.search input { flex: 1; min-width: 0; border: 0; background: none; padding: 12px 14px; font-weight: 600; font-size: 17px; color: var(--route-ink); }
.search input::placeholder { color: rgb(255 255 255 / 75%); }
.search input:focus { outline: none; }
.locate { border: 0; background: none; padding: 0 14px; color: var(--sign); }
.locate svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; }
.locate[aria-busy='true'] svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.suggest { position: absolute; left: -2px; right: -2px; top: calc(100% + 6px); margin: 0; padding: 4px 0; list-style: none; background: var(--paper); color: var(--ink); border-radius: 10px; box-shadow: var(--shadow); }
.suggest li { padding: 10px 14px; cursor: pointer; }
.suggest li[aria-selected='true'], .suggest li:hover { background: var(--kerb); }
.suggest small { color: var(--muted); margin-left: 6px; }

.fuels { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; max-width: 560px; }
.fuels button, .sorts button { border: 0; border-radius: 999px; padding: 7px 13px; font-weight: 600; font-size: 14px; white-space: nowrap; background: var(--paper); color: var(--ink); box-shadow: 0 1px 4px rgb(0 0 0 / 18%); }
.fuels button[aria-checked='true'] { background: var(--sign); color: #1a1a1a; }

/* ---------- bottom sheet ---------- */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 2; height: 46dvh; display: flex; flex-direction: column; background: var(--paper); border-radius: 16px 16px 0 0; box-shadow: var(--shadow); transition: height 0.25s ease; padding-bottom: env(safe-area-inset-bottom); }
.sheet.open { height: calc(100dvh - 130px); }
.sheet.low { height: 112px; }
.grip { align-self: center; width: 64px; height: 22px; border: 0; background: none; flex: none; }
.grip::before { content: ''; display: block; margin: 0 auto; width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
.sheet-head { padding: 0 16px 8px; border-bottom: 1px solid var(--line); }
.summary { margin: 0 0 8px; font-size: 15px; color: var(--muted); }
.summary strong { color: var(--ink); }
.sorts { display: flex; gap: 6px; align-items: center; }
.sorts button { box-shadow: none; background: var(--kerb); }
.sorts button[aria-checked='true'] { background: var(--ink); color: var(--paper); }
.gear { margin-left: auto; padding: 6px !important; display: grid; place-items: center; }
.gear svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }

.scroll { overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.list { list-style: none; margin: 0; padding: 0; }
.st { display: grid; grid-template-columns: 88px 1fr auto; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.st:hover, .st.hl { background: var(--kerb); }
.tile { background: var(--route); color: var(--route-ink); border-radius: 8px; text-align: center; padding: 9px 4px 7px; font-size: 26px; }
.st.best .tile { background: var(--sign); color: #1a1a1a; }
.st.stale .tile, .st.suspect .tile, .st.closed .tile, .st.none .tile { background: var(--kerb); color: var(--muted); }
.st h3 { margin: 0; font-size: 16px; font-weight: 800; line-height: 1.2; }
.st p { margin: 2px 0 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.st .flag { font-weight: 600; }
.stale .flag, .ok .flag { color: var(--amber); }
.suspect .flag, .closed .flag { color: var(--danger); }
.meta { text-align: right; font-size: 13px; color: var(--muted); white-space: nowrap; }
.meta b { display: block; color: var(--ink); font-size: 15px; }
.empty { padding: 24px 16px; color: var(--muted); }
.sheet-foot { padding: 12px 16px 16px; font-size: 12px; color: var(--muted); }
.sheet-foot p { margin: 0 0 4px; }

/* map pins: little totems */
.pin { font: 900 13px/1 var(--font); font-variant-numeric: tabular-nums; background: var(--route); color: #fff; padding: 4px 5px 3px; border-radius: 5px; border: 1.5px solid #fff; box-shadow: 0 1px 4px rgb(0 0 0 / 35%); cursor: pointer; position: relative; }
.pin::after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -4px; border: 4px solid transparent; border-top-color: #fff; }
.pin.best { background: var(--sign); color: #1a1a1a; z-index: 2; }
.pin.dim { background: #8b948f; }
.pin.hl { outline: 3px solid var(--sign); z-index: 3; }
.me { width: 16px; height: 16px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgb(26 115 232 / 25%); }

/* ---------- dialogs ---------- */
.panel { border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.panel::backdrop { background: rgb(15 20 18 / 45%); }
.detail { padding: 20px; }
.detail header { display: flex; gap: 12px; align-items: start; }
.detail h2 { margin: 0; font-size: 22px; line-height: 1.15; font-weight: 900; }
.detail .addr { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.close { margin-left: auto; border: 0; background: var(--kerb); border-radius: 50%; width: 34px; height: 34px; font-size: 20px; line-height: 1; flex: none; }
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 16px 0; }
.board div { background: var(--route); color: #fff; border-radius: 8px; padding: 10px; }
.board div.stale { background: var(--kerb); color: var(--muted); }
.board span { display: block; font-size: 12px; font-weight: 600; opacity: 0.85; margin-bottom: 6px; }
.board .ppl { font-size: 30px; }
.board small { display: block; font-size: 11px; margin-top: 6px; opacity: 0.85; }
.spark { width: 100%; height: 70px; display: block; }
.spark-cap { font-size: 12px; color: var(--muted); margin: 2px 0 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.primary, .secondary { display: inline-block; border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 800; text-decoration: none; }
.primary { background: var(--route); color: #fff; }
.secondary { background: var(--kerb); color: var(--ink); }
.small { font-size: 13px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; list-style: none; margin: 12px 0; }
.tags li { background: var(--kerb); border-radius: 6px; padding: 3px 8px; font-size: 13px; }
.settings { padding: 20px; display: grid; gap: 14px; }
.settings h2 { margin: 0; }
.settings p { margin: 0; color: var(--muted); font-size: 14px; }
.settings label { display: grid; gap: 4px; font-weight: 600; font-size: 14px; }
.settings label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.settings input[type='number'] { border: 2px solid var(--line); border-radius: 8px; padding: 9px 10px; background: var(--paper); }
.settings menu { margin: 0; padding: 0; display: flex; justify-content: end; }

/* desktop: list on the left, map fills the rest */
@media (min-width: 900px) {
  .top { width: 420px; }
  .sheet, .sheet.open, .sheet.low { top: 0; bottom: 0; right: auto; width: 420px; height: auto; border-radius: 0; padding-top: 128px; }
  .grip { display: none; }
  #map { left: 420px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- server-rendered pages ---------- */
.page { background: var(--paper); }
.bar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: var(--route); color: #fff; }
.logo { font-size: 22px; font-weight: 600; text-decoration: none; letter-spacing: -0.01em; }
.logo b { font-weight: 900; color: var(--sign); }
.bar-link { margin-left: auto; font-weight: 600; }
.doc { max-width: 720px; margin: 0 auto; padding: 28px 16px 40px; }
.doc h1 { font-size: clamp(28px, 6vw, 44px); line-height: 1.05; font-weight: 900; letter-spacing: -0.02em; margin: 0 0 12px; }
.lede { font-size: 18px; max-width: 62ch; }
.cta { display: inline-block; background: var(--sign); color: #1a1a1a; font-weight: 800; padding: 10px 16px; border-radius: 10px; text-decoration: none; margin-right: 12px; }
.doc .list { overflow: visible; margin: 24px 0; border-top: 1px solid var(--line); }
.row a { display: grid; grid-template-columns: 84px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.row .price { background: var(--route); color: #fff; font-weight: 900; font-size: 20px; text-align: center; border-radius: 8px; padding: 7px 0 5px; font-variant-numeric: tabular-nums; }
.row:first-child .price { background: var(--sign); color: #1a1a1a; }
.row .where small { display: block; color: var(--muted); }
.row .age, .note { color: var(--muted); font-size: 13px; }
.prices { border-collapse: collapse; width: 100%; margin: 20px 0; }
.prices th, .prices td { text-align: left; padding: 10px 0; border-bottom: 1px solid var(--line); }
.prices .price { font-weight: 900; font-size: 22px; font-variant-numeric: tabular-nums; }
.prices .stale { color: var(--muted); }
.towns { columns: 3 160px; padding: 0; list-style: none; }
.towns li { padding: 3px 0; }
.foot { max-width: 720px; margin: 0 auto; padding: 20px 16px 40px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.linkish { border: 0; background: none; padding: 0; text-decoration: underline; color: inherit; }
