:root {
  --bg: #ffffff;
  --fg: #1c2421;
  --muted: #5d6b66;
  --line: #dfe5e2;
  --accent: #1f5f3f;
  --accent-fg: #ffffff;
  --route: #1a73e8;
  --shadow: 0 2px 10px rgba(0, 0, 0, .18);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b211f; --fg: #e8eeeb; --muted: #9fb0a9; --line: #33403b; --accent: #4caf7f; --accent-fg: #0d1512;
    --shadow: 0 2px 12px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --bg: #1b211f; --fg: #e8eeeb; --muted: #9fb0a9; --line: #33403b; --accent: #4caf7f; --accent-fg: #0d1512;
  --shadow: 0 2px 12px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#map { position: fixed; inset: 0; }

/* Search */
#searchbox { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 16px; right: 16px; max-width: 420px; z-index: 10; }
.search-field { display: flex; align-items: center; gap: 8px; background: var(--bg); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 0 12px; }
.search-field svg { width: 20px; height: 20px; fill: var(--muted); flex: none; }
#q { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--fg); font: inherit; font-size: 16px; padding: 12px 0; }
#results { list-style: none; margin: 6px 0 0; padding: 4px; background: var(--bg); border-radius: var(--radius);
  box-shadow: var(--shadow); max-height: 50vh; overflow: auto; }
#results li { padding: 9px 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
#results li .sub { color: var(--muted); font-size: 13px; }
#results li[aria-selected="true"], #results li:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
#results li.empty { color: var(--muted); cursor: default; background: none; }
.road-result { display: inline-flex; align-items: center; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; max-height: 132px; overflow: auto; }
.chip { border: 1px solid var(--line); background: transparent; color: var(--fg); border-radius: 999px; padding: 3px 10px;
  font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* Hover preview of a site, beside the road card */
#peek { position: fixed; z-index: 11; width: 260px; background: var(--bg); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px 4px; pointer-events: none; border-left: 4px solid #d93025; }
#peek .site-title { font-size: 22px; margin-right: 0; }
#peek .facts { margin-bottom: 10px; }

/* Bottom sheet (left panel on wide screens) */
#sheet { position: fixed; left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 10;
  background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 55vh; overflow: auto;
  padding: 16px; }
@media (min-width: 760px) {
  #sheet { right: auto; width: 400px; top: 76px; bottom: auto; max-height: calc(100vh - 100px); }
}
#sheet .close { position: absolute; top: 8px; right: 8px; border: 0; background: none; color: var(--muted);
  font-size: 26px; line-height: 1; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; }
#sheet .close:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); }
.site-title { font-size: 26px; font-weight: 700; margin: 0 40px 2px 0; letter-spacing: -.01em; }
.site-meta { color: var(--muted); margin-bottom: 12px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 14px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.road-link { border: 0; background: none; padding: 0; font: inherit; color: #c4126f; text-decoration: underline;
  text-underline-offset: 2px; cursor: pointer; }
.road-link:hover { color: #ff1f8e; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-fg); font: inherit; font-weight: 600; padding: 11px 16px; cursor: pointer; width: 100%; }
.btn.secondary { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn-row { display: flex; gap: 8px; }

.route-summary { font-size: 22px; font-weight: 700; margin: 0 40px 2px 0; }
.route-sub { color: var(--muted); margin-bottom: 10px; font-size: 14px; }
.steps { list-style: none; margin: 0 0 12px; padding: 0; }
.steps li { display: flex; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--line); cursor: pointer; }
.steps li:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.steps .icon { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: color-mix(in srgb, var(--route) 14%, transparent); color: var(--route); font-size: 16px; }
.steps .icon svg { width: 18px; height: 18px; fill: currentColor; }
.steps .txt { flex: 1; }
.steps .dist { color: var(--muted); font-size: 13px; }
.steps .near { color: var(--muted); font-size: 12px; }

#status { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 20; background: var(--bg);
  padding: 16px 20px; border-radius: var(--radius); box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center; }

/* Map controls: below the search box on phones */
@media (max-width: 519px) {
  .maplibregl-ctrl-top-right { top: calc(max(12px, env(safe-area-inset-top)) + 52px); }
}
.maplibregl-ctrl-group button.park-view, .maplibregl-ctrl-group button.sat-toggle { font-size: 0; }
.maplibregl-ctrl-group button svg { width: 20px; height: 20px; display: block; margin: auto; }
.maplibregl-ctrl-group button.on { background: color-mix(in srgb, var(--route) 20%, #fff); }
.marker { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: grid; place-items: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .4); border: 2px solid #fff; }
.marker span { transform: rotate(45deg); color: #fff; font: 700 13px system-ui, sans-serif; }
.marker.entrance { background: #1f5f3f; }

/* GPS */
.gps-btn svg path { fill: none; stroke: #555; }
.gps-btn.gps-follow svg path { fill: #1a73e8; stroke: #1a73e8; }
.gps-btn.gps-free svg path { fill: none; stroke: #1a73e8; }
.gps-dot { width: 20px; height: 20px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .12), 0 1px 5px rgba(0, 0, 0, .45); transition: background-color .3s; }
.gps-dot.weak { background: #9aa0a6; }
#gpsNote { margin-top: 6px; background: var(--bg); color: var(--fg); border-radius: 10px; box-shadow: var(--shadow);
  padding: 8px 12px; font-size: 13px; }
.btn-stack { display: grid; gap: 8px; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; border: 0; background: none; padding: 4px 0;
  color: var(--accent); font: inherit; font-size: 14px; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.exit-btn { position: fixed; left: 16px; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 8px); z-index: 9;
  display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; padding: 11px 18px;
  background: var(--accent); color: var(--accent-fg); font: inherit; font-weight: 600; box-shadow: var(--shadow); cursor: pointer; }
.exit-btn[hidden] { display: none; }
.marker.entrance { cursor: pointer; }
#searchbox[hidden] { display: none; }

/* Heading-up button */
.maplibregl-ctrl-group button.headup-btn[hidden] { display: none; }
.maplibregl-ctrl-group button.headup-btn.on { background: color-mix(in srgb, #1a73e8 22%, #fff); }

/* Live navigation: next-turn banner */
#navBanner { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 16px; right: 16px; max-width: 460px; z-index: 12;
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 14px; border-radius: var(--radius);
  background: #1f5f3f; color: #fff; box-shadow: var(--shadow); }
#navBanner[hidden] { display: none; }
@media (max-width: 519px) { #navBanner { right: 64px; } }
.nav-icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; }
.nav-icon svg { width: 40px; height: 40px; fill: #fff; }
.nav-text { flex: 1; min-width: 0; }
.nav-dist { font-size: 24px; font-weight: 700; line-height: 1.1; }
.nav-instr { font-size: 15px; line-height: 1.25; opacity: .95; }
.nav-round { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; background: #fff;
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.nav-round svg { width: 24px; height: 24px; stroke: #1f5f3f; fill: none; }
.nav-round .spk { fill: #1f5f3f; stroke: none; }
.nav-round .waves { stroke: #1f5f3f; }
.nav-round .slash { display: none; stroke: #d93025; }
.nav-round.muted .slash { display: inline; }
.nav-round.muted .waves { display: none; }
.nav-round.muted .spk { fill: #6b7570; }

/* Labelled voice toggle in the navigation panel */
.voice-toggle { display: flex; align-items: center; gap: 10px; width: 100%; margin: 0 0 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--fg); font: inherit; cursor: pointer; }
.voice-toggle svg { width: 22px; height: 22px; flex: none; }
.voice-toggle .spk { fill: currentColor; }
.voice-toggle .waves { stroke: currentColor; fill: none; }
.voice-toggle .slash { display: none; stroke: #d93025; }
.voice-toggle.muted .slash { display: inline; }
.voice-toggle.muted .waves { display: none; }
.voice-toggle .state { margin-left: auto; font-weight: 600; color: var(--accent); }
.voice-toggle.muted .state { color: #d93025; }
.nav-steps summary { cursor: pointer; color: var(--accent); font-weight: 600; margin: 4px 0 8px; }
.steps li.current { background: color-mix(in srgb, var(--route) 12%, transparent); border-radius: 8px; }
.sheet-note { color: var(--muted); margin: 4px 0 14px; }
.marker.dest { background: #d93025; }
