:root {
  --bg: #f4f5f7; --card: #fff; --ink: #0f172a; --muted: #64748b; --line: #e2e6ec;
  --open: #15803d; --open-bg: #dcfce7; --closed: #b91c1c; --closed-bg: #fee2e2;
  --soon: #b45309; --soon-bg: #fef3c7; --accent: #1d4ed8;
  --signal: #d32f2f; /* the red of a crossing light, and of the clearway sign */
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --card: #121a2b; --ink: #f1f5f9; --muted: #94a3b8; --line: #1e293b;
    --open: #4ade80; --open-bg: #052e16; --closed: #f87171; --closed-bg: #450a0a;
    --soon: #fbbf24; --soon-bg: #451a03; --accent: #60a5fa;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -12px rgba(0, 0, 0, .6);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); overflow: hidden; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.err { color: var(--closed); }
button { font: inherit; font-weight: 600; white-space: nowrap; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: inherit; cursor: pointer; }
button:hover { border-color: var(--muted); }
button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
button.wide { display: block; width: 100%; margin: 12px 0; }

/* ---------- the map ---------- */
.drive { position: fixed; inset: 0; z-index: 0; isolation: isolate; }
.drive .map { position: absolute; inset: 0; z-index: 0; background: var(--card); }
.map .leaflet-tooltip { font: 13px/1.3 system-ui, sans-serif; }
@media (prefers-color-scheme: dark) {
  .map .leaflet-tile { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); }
  .map .leaflet-control-attribution, .map .leaflet-bar a { background: var(--card); color: var(--ink); }
}

/* ---------- search ---------- */
.where { position: absolute; z-index: 700; top: calc(12px + env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; gap: 6px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px 6px 6px 12px; box-shadow: var(--shadow); }
.where input { flex: 1; min-width: 0; font: inherit; font-size: 17px; border: 0; background: none; color: inherit; padding: 8px 4px; outline: none; }
.where button { flex: none; background: var(--accent); border-color: var(--accent); color: #fff; }
.results { position: absolute; z-index: 700; top: calc(72px + env(safe-area-inset-top)); left: 12px; right: 12px; max-height: 50vh; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; }
.results .rhead { font: 700 11px/1 system-ui, sans-serif; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 10px 10px 6px; }
.results button { display: block; width: 100%; text-align: left; border: 0; border-radius: 10px; padding: 10px; white-space: normal; background: none; }
.results button:hover { background: var(--bg); }
.results small, .xname small, .xverdict small, .pills small { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.results p { margin: 8px 10px; }
.fab { position: absolute; z-index: 600; right: 12px; top: calc(80px + env(safe-area-inset-top)); width: 44px; height: 44px; padding: 0; display: grid; place-items: center; border-radius: 50%; box-shadow: var(--shadow); }
.fab svg { width: 22px; height: 22px; }
.fab.cams { top: calc(132px + env(safe-area-inset-top)); }

/* ---------- the sheet ---------- */
.sheet { position: absolute; z-index: 650; left: 0; right: 0; bottom: 0; max-height: 52vh; overflow: auto; background: var(--card); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px -12px rgba(15, 23, 42, .35); padding: 14px 16px calc(10px + env(safe-area-inset-bottom)); }
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: -4px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; font-size: 17px; }
.sheet .x { border: 0; font-size: 26px; line-height: 1; padding: 0 6px; color: var(--muted); background: none; }
.sheet p { margin: 8px 0; }
.summary { color: var(--muted); font-size: 14px; margin: 4px 0 6px; }
.summary b { color: var(--ink); }
.rows { margin: 4px 0; }
.xrow { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; cursor: pointer; }
.xrow:first-child { border-top: 0; }
.xat { flex: none; min-width: 3.2em; font-weight: 700; }
.pip { flex: none; width: 12px; height: 12px; border-radius: 50%; background: #94a3b8; box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--line); }
.pip.open { background: #16a34a; } .pip.soon { background: #f59e0b; } .pip.closed { background: #dc2626; }
.xname { flex: 1; min-width: 0; font-weight: 700; }
.xname small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xverdict { flex: none; max-width: 48%; text-align: right; font-size: 13.5px; line-height: 1.3; }
.xverdict.open b { color: var(--open); } .xverdict.soon b { color: var(--soon); } .xverdict.closed b { color: var(--closed); } .xverdict.unknown b { color: var(--muted); font-weight: 600; }
.pills { display: flex; gap: 8px; overflow-x: auto; margin: 6px 0 8px; }
.pills button { text-align: left; padding: 8px 12px; }
.pills button i { font-style: normal; color: var(--soon); }
.pills button[aria-pressed="true"] i, .pills button[aria-pressed="true"] small { color: #fff; opacity: .9; }
.bar { display: flex; gap: 10px; margin: 10px 0 4px; }
.sheet .bar { position: sticky; bottom: 0; z-index: 1; padding: 8px 0; background: var(--card); } /* Start/End always in reach, however long the list */
.bar .go, .bar .stop { flex: 1; font: 800 20px/1 "Barlow Condensed", system-ui, sans-serif; text-transform: uppercase; letter-spacing: .06em; padding: 14px; border-radius: 12px; color: #fff; }
.bar .go { background: var(--accent); border-color: var(--accent); }
.bar .stop { background: var(--signal); border-color: var(--signal); }
.credit { display: none; margin: 6px 0 0; text-align: center; }

/* ---------- when you get in the car ---------- */
.car-row { font-weight: 500; color: var(--muted); margin: 4px 0 0; }
.car-row b { color: var(--ink); }
.carlist { margin: 6px 0; }
.carlist button { display: block; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 12px 2px; white-space: normal; background: none; }
.carlist button:first-child { border-top: 0; }
.carlist small { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.steps { margin: 8px 0; padding-left: 22px; }
.steps li { margin: 6px 0; }
a.button { display: block; text-align: center; font-weight: 600; text-decoration: none; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); margin: 12px 0; }
a.go-link { background: var(--accent); border-color: var(--accent); color: #fff; }
.credit a { color: inherit; }

/* ---------- driving ---------- */
.next { border-radius: 14px; padding: 14px 16px; background: var(--bg); }
.next.open { background: var(--open-bg); } .next.soon { background: var(--soon-bg); } .next.closed { background: var(--closed-bg); }
.next .eyebrow { font: 700 12px/1.2 system-ui, sans-serif; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-variant-numeric: tabular-nums; }
.next .nname { font: 800 34px/1 "Barlow Condensed", system-ui, sans-serif; text-transform: uppercase; margin-top: 6px; }
.next .nroad { color: var(--muted); font-size: 14px; }
.next .nverdict { font: 800 24px/1.1 "Barlow Condensed", system-ui, sans-serif; text-transform: uppercase; margin-top: 10px; letter-spacing: .02em; }
.next.open .nverdict { color: var(--open); } .next.soon .nverdict { color: var(--soon); } .next.closed .nverdict { color: var(--closed); }
.next .nsub { font-size: 15px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.then { margin-top: 6px; }
.you { background: none; border: 0; }
.you svg { width: 28px; height: 28px; transition: transform .3s; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4)); }
.you-dot { display: block; width: 18px; height: 18px; margin: 5px; border-radius: 50%; background: #2563eb; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(37, 99, 235, .2); }

/* ---------- a crossing's popup ---------- */
.drive .leaflet-popup-content-wrapper, .drive .leaflet-popup-tip { background: var(--card); color: var(--ink); }
.pop b { font-size: 15px; }
.pop-state { margin: 6px 0 4px; font-weight: 700; }
.pop-state.open { color: var(--open); } .pop-state.soon { color: var(--soon); } .pop-state.closed { color: var(--closed); } .pop-state.unknown { color: var(--muted); }
.pop-next { display: flex; flex-wrap: wrap; gap: 4px 10px; font-weight: 600; }
.pop-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.pop-actions button { padding: 6px 12px; background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- speed cameras: a speed-limit roundel, the limit in it (a camera if OSM doesn't say) ---------- */
.cam { background: none; border: 0; }
.roundel { flex: none; display: inline-grid; place-items: center; box-sizing: border-box; width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 3px solid #d32f2f; color: #111; font: 800 11px/1 system-ui, sans-serif; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.roundel svg { width: 12px; height: 12px; }
.roundel.small { width: 22px; height: 22px; font-size: 10px; border-width: 2.5px; box-shadow: none; }
.avg { display: inline-flex; align-items: center; gap: 3px; padding: 2px 2px 2px 6px; border-radius: 999px; background: #f59e0b; color: #111; font: 800 10px/1 system-ui, sans-serif; letter-spacing: .04em; white-space: nowrap; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.avg.end { padding: 4px 7px; background: #64748b; color: #fff; }
.camstrip { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 8px 12px; border-radius: 12px; background: var(--bg); font-size: 15px; }
.camstrip b { flex: 1; }
.camstrip .roundel { width: 36px; height: 36px; border-width: 4px; font-size: 15px; }
.camstrip.check { background: color-mix(in srgb, #f59e0b 24%, var(--card)); }
.cam-row .xname { font-weight: 600; }

@media (max-width: 899px) { .drive .leaflet-control-attribution { display: none; } .credit { display: block; } }
@media (min-width: 900px) {
  .where { right: auto; width: 380px; left: 16px; top: 16px; }
  .results { right: auto; width: 380px; left: 16px; top: 76px; }
  .sheet { left: 16px; right: auto; width: 380px; top: 80px; bottom: auto; max-height: calc(100vh - 96px); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
  .sheet::before { display: none; }
  .fab { top: 16px; right: 16px; }
  .fab.cams { top: 68px; }
}
