:root {
  --ink: #12232e; --muted: #5b6b75; --bg: #ffffff; --panel: rgba(255,255,255,.96); --line: rgba(127,127,127,.18);
  --route: #e4572e; --accent: #0b4f6c; --gps: #1a73e8;
  --shadow: 0 2px 10px rgba(0,0,0,.18);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #e6edf2; --muted: #9fb0bb; --bg: #0f1a21; --panel: rgba(18,30,38,.96); }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#map { position: fixed; inset: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* floating buttons */
/* stacked bottom-right, just above the bottom bar (--bar-h is measured in JS) */
#controls { position: fixed; right: 10px; bottom: calc(var(--bar-h, 96px) + 12px); display: flex; flex-direction: column; gap: 10px; z-index: 5; }
.fab { width: 48px; height: 48px; border-radius: 24px; border: 0; background: var(--panel); box-shadow: var(--shadow); font-size: 19px;
  display: grid; place-items: center; padding: 0; }
#compass { display: block; transition: transform .3s; }
/* invisible strip on the right edge that catches a swipe-left to open the drawer */
#edge { position: fixed; right: 0; top: 0; bottom: var(--bar-h, 96px); width: 16px; z-index: 4; touch-action: none; }
.fab.off { opacity: .55; }

/* bottom bar */
#bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--panel); box-shadow: 0 -2px 12px rgba(0,0,0,.15);
  padding: 8px 12px calc(10px + var(--safe-b)); border-radius: 14px 14px 0 0; }
#readout { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0 2px 6px; }
#bar-row { display: flex; align-items: center; gap: 8px; }
#btn-snap { width: 40px; height: 40px; border-radius: 20px; border: 0; background: var(--gps); color: #fff; font-size: 20px; flex: none; }
#btn-snap.idle { background: #c9d6df; color: #234; }
#day-label { border: 1px solid #c9d6df; background: transparent; border-radius: 10px; padding: 0 8px; height: 36px; font-size: 15px; font-weight: 700;
  flex: none; }
#track-wrap { position: relative; flex: 1; height: 44px; }
#track-ticks { position: absolute; left: 14px; right: 14px; top: 0; height: 100%; pointer-events: none; }
#track-ticks span { position: absolute; top: 0; transform: translateX(-50%); font-size: 11px; line-height: 1; }
#track-ticks .gps { top: 19px; width: 12px; height: 12px; border-radius: 6px; background: var(--gps); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--gps); z-index: 1; }
#scrub { position: absolute; left: 0; right: 0; bottom: 2px; width: 100%; height: 28px; margin: 0; -webkit-appearance: none; appearance: none;
  background: transparent; touch-action: none; }
#scrub::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--route) var(--pct, 0%), #c9d6df var(--pct, 0%)); }
#scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -11px; border-radius: 14px; background: #fff;
  border: 3px solid var(--route); box-shadow: var(--shadow); }
#scrub::-moz-range-track { height: 6px; border-radius: 3px; background: #c9d6df; }
#scrub::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--route); }
#scrub::-moz-range-thumb { width: 24px; height: 24px; border-radius: 12px; background: #fff; border: 3px solid var(--route); }
#day-chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; }
#day-chips button { flex: none; border: 1px solid #c9d6df; background: transparent; border-radius: 16px; padding: 6px 10px; font-size: 13px; }
#day-chips button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
#day-chips button.today::after { content: " •"; color: var(--gps); }

/* landmarks drawer */
#drawer { position: fixed; top: 0; right: 0; height: 100%; height: 100dvh; width: min(86vw, 380px); z-index: 7; background: var(--panel);
  box-shadow: var(--shadow); transform: translateX(105%); transition: transform .25s ease; display: flex; flex-direction: column;
  padding-top: var(--safe-t); touch-action: pan-y; }
#drawer.open { transform: none; }
#drawer.dragging { transition: none; }
#drawer header { display: flex; align-items: center; gap: 6px; padding: 8px 6px 8px 10px; border-bottom: 1px solid var(--line); flex: none; }
#drawer footer { flex: none; padding: 8px 10px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); }
#btn-save { flex: 1; display: flex; align-items: center; gap: 10px; border: 0; background: transparent; text-align: left; padding: 4px; border-radius: 8px; }
#btn-save svg { flex: none; color: var(--accent); }
@media (prefers-color-scheme: dark) { #btn-save svg { color: #7fd1ff; } }
#btn-save b { display: block; font-size: 14px; }
#btn-save small { display: block; font-size: 12px; color: var(--muted); }
#btn-save.done svg { color: #1f8a4c; }
.seg { display: flex; flex: 1; background: rgba(127,127,127,.15); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 7px; border-radius: 8px; font-weight: 600; }
.seg button.on { background: var(--bg); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
#drawer-close { border: 0; background: transparent; font-size: 20px; width: 40px; height: 40px; }
#chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 8px; }
.chip { border: 1px solid #c9d6df; background: transparent; border-radius: 16px; padding: 5px 10px; font-size: 13px; opacity: .5; }
.chip.on { opacity: 1; border-color: var(--accent); }
#list { position: relative; overflow-y: auto; flex: 1; min-height: 0; overscroll-behavior: contain; }
.row { display: flex; gap: 10px; padding: 9px 12px 9px 9px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; align-items: flex-start; }
.row[data-i] { cursor: pointer; }
.row.inview { border-left-color: var(--route); }
.row .ic { width: 26px; text-align: center; font-size: 18px; flex: none; }
.row .nm { font-weight: 600; }
.row .meta { font-size: 12px; color: var(--muted); }
.row .note { font-size: 12.5px; margin-top: 2px; }
.dayhead { position: sticky; top: 0; z-index: 1; background: var(--accent); color: #fff; padding: 7px 12px; font-size: 13px; }
.dayhead b { font-size: 14px; }
.dayhead .note { opacity: .85; font-size: 12px; margin-top: 2px; }
.here { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 12px; }
.here::after { content: ""; flex: 1; height: 2px; background: currentColor; }
#here-gps { color: var(--gps); }
#here-map { color: var(--route); }

/* map markers + popups */
.marker { font-size: 20px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); cursor: pointer; }
.marker.lodging { background: #fff; border-radius: 8px; padding: 3px 4px; border: 2px solid var(--accent); font-size: 16px; }
.maplibregl-popup-content { color: #12232e; border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.maplibregl-popup-content h3 { margin: 0 4px 4px 0; font-size: 15px; }
.maplibregl-popup-content .meta { color: #5b6b75; font-size: 12px; }
.maplibregl-popup-content a.btn { display: inline-block; margin-top: 8px; background: var(--gps); color: #fff; padding: 6px 10px; border-radius: 8px;
  text-decoration: none; font-weight: 600; }
.maplibregl-ctrl-bottom-left { bottom: calc(var(--bar-h, 96px) + 4px); }

#toast { position: fixed; left: 50%; top: calc(14px + var(--safe-t)); transform: translateX(-50%); z-index: 9; background: #12232e; color: #fff;
  padding: 8px 14px; border-radius: 18px; font-size: 13px; box-shadow: var(--shadow); max-width: 80vw; }
