/* ------------------------------------------------------------------------------------------
 * LiqMaps (/maps). Uses site.css's tokens only: its own few (--ok-ink, --bad-ink, --warn, --nav) live
 * there with the rest, so the contrast check can see what they sit on. The map itself is drawn on a canvas (maps-paint.js
 * holds its colours, checked by tools/maps-test.mjs); everything here is the interface over it.
 *
 * ------------------------------------------------------------------------------------------ */
:root { --sheet-radius: 16px; --ctl: 40px; }

/* ---- page ------------------------------------------------------------------------------------ */
html.maps-html, body.maps { height: 100%; }
body.maps {
  margin: 0; overflow: hidden; overscroll-behavior: none;
  background-color: var(--bg); color: var(--fg);
  font: 400 14px/1.45 var(--font);
}
body.maps::before { content: none; }
.map {
  position: fixed; inset: 0; touch-action: none; overflow: hidden;
  background-color: var(--bg); color: var(--fg); cursor: grab; user-select: none; -webkit-user-select: none;
}
.map:focus { outline: none; }
.map:focus-visible { box-shadow: inset 0 0 0 3px var(--focus-ring); }
.map.grabbing, .map.grabbing .map-canvas { cursor: grabbing; }
.map.over-label { cursor: pointer; }
body.is-measuring .map { cursor: crosshair; }
.map-canvas { display: block; position: absolute; left: 0; top: 0; max-width: none; }
.map-markers { position: absolute; inset: 0; pointer-events: none; }
.map-marker { position: absolute; left: 0; top: 0; pointer-events: auto; will-change: transform; }
.map-marker[hidden] { display: none; }

.map-loading {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 40; pointer-events: none;
  background-color: transparent; color: inherit;
  background-image: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 40% 100%; background-repeat: no-repeat;
  animation: maps-load 1.1s linear infinite;
}
@keyframes maps-load { from { background-position: -40% 0; } to { background-position: 140% 0; } }
@media (prefers-reduced-motion: reduce) { .map-loading { animation: none; background-size: 100% 100%; opacity: 0.6; } }

/* ---- shared bits ------------------------------------------------------------------------------- */
.muted { color: var(--muted-fg); background-color: transparent; }
.small { font-size: 0.86em; }
.tiny { font-size: 0.76em; }
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn.small svg { width: 15px; height: 15px; }
.mbtn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  font: 600 0.92rem/1 var(--font); padding: 10px 14px; border-radius: 999px;
  background-color: var(--surface); color: var(--surface-fg); border: 1px solid var(--border-strong);
}
.mbtn:hover { background-color: var(--surface-2); color: var(--surface-2-fg); }
.mbtn:disabled { opacity: 0.55; cursor: default; }
.mbtn-sm { padding: 8px 12px; font-size: 0.86rem; }
.mbtn-primary { background-color: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.mbtn-primary:hover { background-color: var(--fg); color: var(--bg); border-color: var(--fg); }
.mbtn.is-saved { background-color: var(--surface-2); color: var(--surface-2-fg); border-color: var(--accent-ink); }
.mbtn svg { flex: none; }
.linkish { font: inherit; padding: 0; border: 0; cursor: pointer; background-color: transparent; color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
.linkish:hover { background-color: transparent; color: var(--fg); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 0; }
.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.field { display: grid; gap: 4px; margin: 0 0 12px; }
.field > span { font-weight: 600; font-size: 0.9rem; }
select, input[type="datetime-local"] {
  font: inherit; padding: 7px 9px; border-radius: 9px;
  background-color: var(--surface); color: var(--surface-fg); border: 1px solid var(--border-strong);
}
.kv { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.kv svg { align-self: center; color: var(--muted-fg); flex: none; }
.kv-k { color: var(--muted-fg); background-color: transparent; min-width: 92px; font-size: 0.9em; }
.kv-v { color: inherit; background-color: transparent; overflow-wrap: anywhere; }
.kv a { overflow-wrap: anywhere; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer; white-space: nowrap;
  font: 600 0.84rem/1 var(--font); padding: 8px 12px; border-radius: 999px;
  background-color: var(--surface); color: var(--surface-fg); border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}
.chip:hover { background-color: var(--surface-2); color: var(--surface-2-fg); border-color: var(--border-strong); }
.chip-dot { width: 9px; height: 9px; border-radius: 50%; background-color: var(--g, var(--accent)); color: inherit; flex: none; }
/* POI group colours, as in the map (decoration: the words carry the meaning) */
.g-food { --g: #be540d; } .g-shop { --g: #2f62cc; } .g-health { --g: #c92a3e; } .g-lodging { --g: #a43a73; }
.g-transport { --g: #3b5ea8; } .g-car { --g: #4f5d70; } .g-learn { --g: #7d5f2b; } .g-outdoors { --g: #2b7a3e; }
.g-culture { --g: #0f7d7d; } .g-civic { --g: #5d6072; }

/* ---- top bar: search and chips -------------------------------------------------------------------- */
.m-top { position: fixed; top: 12px; left: 12px; z-index: 30; width: min(408px, calc(100vw - 24px)); }
.m-searchrow { position: relative; }
.m-search {
  display: flex; align-items: center; gap: 6px; height: 50px; padding: 0 6px 0 46px; margin: 0;
  background-color: var(--surface); color: var(--surface-fg); border-radius: 14px; border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.m-search:focus-within { border-color: var(--accent-ink); }
.m-brand { position: absolute; left: 9px; top: 10px; z-index: 2; display: block; width: 30px; height: 30px; border-radius: 8px; background-color: transparent; color: inherit; }
.m-brand img { width: 30px; height: 30px; }
.m-search-ic { display: none; }
.m-search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: none; font: 400 1rem var(--font);
  background-color: transparent; color: var(--surface-fg);
}
.m-search input::placeholder { color: var(--muted-fg); opacity: 1; }
.m-search input::-webkit-search-cancel-button { display: none; }
.m-search [hidden], .m-top [hidden] { display: none; }
.m-dir-btn {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; cursor: pointer; flex: none;
  background-color: var(--accent); color: var(--accent-fg); border: 0;
}
.m-dir-btn:hover { background-color: var(--fg); color: var(--bg); }
.m-chips {
  display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px;
  width: min(760px, calc(100vw - 90px));
}
.m-chips::-webkit-scrollbar { display: none; }
body.has-panel .m-chips { display: none; }

.suggest {
  list-style: none; margin: 6px 0 0; padding: 6px; position: absolute; left: 0; right: 0; top: 100%; z-index: 50;
  background-color: var(--surface); color: var(--surface-fg); border: 1px solid var(--border-strong); border-radius: 12px;
  box-shadow: var(--shadow); max-height: min(60vh, 440px); overflow-y: auto;
}
.sg { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 9px; cursor: pointer; background-color: transparent; color: inherit; }
.sg:hover, .sg.is-active { background-color: var(--surface-2); color: var(--surface-2-fg); }
.sg-ic { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; flex: none; background-color: var(--surface-2); color: var(--muted-fg); }
.sg-ic[class*="g-"] { box-shadow: inset 0 0 0 2px var(--g); }
.sg.is-active .sg-ic, .sg:hover .sg-ic { background-color: var(--surface); color: var(--surface-fg); }
.sg-text { display: grid; min-width: 0; flex: 1; }
.sg-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-sub { font-size: 0.85em; color: var(--muted-fg); background-color: transparent; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-dist { font-size: 0.82em; color: var(--muted-fg); background-color: transparent; flex: none; }

/* ---- panel: a column on wide screens, a bottom sheet on phones ------------------------------------ */
.m-panel {
  position: fixed; left: 12px; top: 72px; bottom: 42px; width: min(408px, calc(100vw - 24px)); z-index: 25;
  display: flex; flex-direction: column;
  background-color: var(--surface); color: var(--surface-fg); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
}
.m-panel[hidden] { display: none; }
.p-handle { display: none; }
.p-head { display: flex; align-items: center; gap: 6px; padding: 8px 8px 4px 14px; flex: none; }
.p-head .icon-btn { width: 34px; height: 34px; }
.p-back[hidden] { display: none; }
.p-title { flex: 1; font: 700 1.05rem/1.25 var(--font); letter-spacing: -0.01em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-body { flex: 1; overflow-y: auto; padding: 4px 14px 16px; overscroll-behavior: contain; }
.p-body h4 { margin: 16px 0 8px; font: 700 0.95rem var(--font); }
.empty { color: var(--muted-fg); background-color: transparent; padding: 20px 0; }

/* results */
.results { list-style: none; margin: 0; padding: 0; }
.res {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 6px; text-align: left; cursor: pointer;
  font: inherit; border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
  background-color: transparent; color: inherit;
}
.res:hover, .res:focus-visible { background-color: var(--surface-2); color: var(--surface-2-fg); }
.res-n {
  display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%;
  font: 700 0.78rem var(--font); background-color: var(--surface-2); color: var(--surface-2-fg); box-shadow: inset 0 0 0 2px var(--g, var(--border-strong));
}
.res-text { display: grid; min-width: 0; flex: 1; }
.res-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-sub { font-size: 0.85em; color: var(--muted-fg); background-color: transparent; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-dist { font-size: 0.82em; color: var(--muted-fg); background-color: transparent; flex: none; }
.res-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }

/* place card */
.place-head { padding: 4px 0 10px; }
.place-head[class*="g-"] .place-kind::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background-color: var(--g); color: inherit; }
.place-kind { font-size: 0.82rem; font-weight: 600; color: var(--muted-fg); background-color: transparent; text-transform: none; }
.place-name { font: 700 1.4rem/1.15 var(--font-display); letter-spacing: -0.02em; margin: 2px 0 4px; overflow-wrap: anywhere; }
.place-addr { color: var(--muted-fg); background-color: transparent; }
.place-open { font-weight: 600; margin-top: 4px; }
.place-open.is-open { color: var(--ok-ink); background-color: transparent; }
.place-open.is-closed { color: var(--bad-ink); background-color: transparent; }
.place-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 12px; border-bottom: 1px solid var(--border); }
.place-desc { margin: 8px 0; }
.place-meta { margin-top: 12px; }
.place-coords { font-size: 0.86rem; overflow-wrap: anywhere; }
.place-elev { margin-top: 4px; }
.more-coords summary { cursor: pointer; color: var(--muted-fg); background-color: transparent; font-size: 0.85rem; margin-top: 4px; }
.hours { margin: 6px 0; }
.hours summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.hours table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.hours th { text-align: left; font-weight: 400; color: var(--muted-fg); background-color: transparent; padding: 3px 8px 3px 0; width: 40%; }
.hours td { padding: 3px 0; }
.hours tr.is-today th, .hours tr.is-today td { font-weight: 700; color: var(--surface-fg); background-color: transparent; }
.wiki-card { margin: 12px 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background-color: var(--surface); color: var(--surface-fg); }
.wiki-card img { width: 100%; max-height: 200px; object-fit: cover; }
.wiki-card figcaption { padding: 10px 12px; font-size: 0.92rem; display: grid; gap: 6px; }

/* weather */
.wx-now { display: flex; align-items: center; gap: 12px; }
.wx-ic { display: grid; place-items: center; color: var(--accent-ink); background-color: transparent; }
.wx-temp { font: 700 2rem/1 var(--font-display); }
.wx-desc { display: grid; font-size: 0.9rem; }
.wx-hours { list-style: none; margin: 10px 0 4px; padding: 0 0 4px; display: flex; gap: 4px; overflow-x: auto; }
.wx-hours li { display: grid; justify-items: center; gap: 2px; min-width: 46px; padding: 6px 2px; border-radius: 10px; background-color: var(--surface-2); color: var(--surface-2-fg); font-size: 0.8rem; }
.wx-hours svg { color: var(--accent-ink); }
.wx-h-pop { color: var(--muted-fg); background-color: transparent; min-height: 1.1em; }
.wx-h-pop.is-wet { color: var(--accent-ink); font-weight: 700; }
.wx-week summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.wx-days { list-style: none; margin: 0; padding: 0; }
.wx-days li { display: grid; grid-template-columns: 54px 22px 1fr 40px 70px; align-items: center; gap: 6px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.wx-days svg { color: var(--accent-ink); }
.wx-d-pop { color: var(--accent-ink); background-color: transparent; font-size: 0.85em; text-align: right; }
.wx-d-range { text-align: right; }
.alerts { display: grid; gap: 8px; margin-top: 10px; }
.alert-card {
  border-radius: 10px; padding: 8px 10px; border-left: 5px solid var(--sev, var(--warn-ink));
  background-color: var(--warn); color: var(--warn-fg);
}
.alert-card summary { cursor: pointer; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.alert-card .muted { color: var(--warn-fg); background-color: transparent; opacity: 0.85; }
.alert-card p { margin: 6px 0 0; white-space: pre-line; }
.alert-do { font-weight: 600; }
.alert-unknown { padding: 8px 10px; border-radius: 10px; background-color: var(--warn); color: var(--warn-fg); font-size: 0.9rem; }

/* saved */
.saved-special { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 8px; }
.saved-sp { display: flex; align-items: center; gap: 10px; padding: 10px; text-align: left; cursor: pointer; font: inherit; border-radius: 12px; border: 1px solid var(--border); background-color: var(--surface-2); color: var(--surface-2-fg); }
.saved-sp:hover { border-color: var(--border-strong); background-color: var(--surface); color: var(--surface-fg); }
.saved-sp span { display: grid; min-width: 0; }
.saved-list ul { list-style: none; margin: 0; padding: 0; }
.saved-item, .file-row { display: flex; align-items: center; gap: 4px; }
.saved-item .res svg, .file-row .res svg { color: var(--accent-ink); flex: none; }

/* measure */
.measure-total { font: 700 1.25rem var(--font-display); margin: 6px 0; }

/* ---- directions ------------------------------------------------------------------------------- */
.dir-modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 10px; }
.dir-mode {
  display: grid; justify-items: center; gap: 2px; padding: 8px 4px; cursor: pointer; font: 600 0.84rem var(--font);
  border-radius: 12px; border: 1px solid var(--border); background-color: var(--surface); color: var(--surface-fg);
}
.dir-mode:hover { background-color: var(--surface-2); color: var(--surface-2-fg); }
.dir-mode[aria-selected="true"] { background-color: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.dir-mode-time { font-size: 0.78rem; font-weight: 400; min-height: 1.1em; }
.dir-stops { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dir-stop { display: flex; align-items: center; gap: 6px; position: relative; background-color: var(--surface); color: var(--surface-fg); border-radius: 10px; }
.dir-stop.is-dragging { z-index: 3; box-shadow: var(--shadow); }
.dir-dot {
  display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%;
  font: 700 0.75rem var(--font); background-color: var(--surface-2); color: var(--surface-2-fg); border: 2px solid var(--border-strong);
}
.dir-dot.is-start { border-color: #0f9d58; }
.dir-dot.is-end { border-color: #d62839; }
.dir-field { position: relative; flex: 1; min-width: 0; }
.dir-input {
  width: 100%; font: inherit; padding: 9px 10px; border-radius: 10px;
  background-color: var(--surface-2); color: var(--surface-2-fg); border: 1px solid var(--border);
}
.dir-input::placeholder { color: var(--muted-fg); opacity: 1; }
.dir-input:focus { outline: 2px solid var(--focus-ring); outline-offset: 0; }
.dir-input::-webkit-search-cancel-button { display: none; }
.dir-grip { cursor: grab; touch-action: none; }
.dir-stop-tools { display: flex; justify-content: space-between; gap: 6px; margin: 8px 0 4px 30px; }
.dir-stop-tools [hidden] { display: none; }
.dir-opts { margin: 6px 0 10px; }
.dir-opts summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.dir-avoid { display: flex; flex-wrap: wrap; gap: 2px 14px; }
.dir:not(.is-car) .opt-highways, .dir:not(.is-car) .opt-tolls { display: none; }
.dir.is-car .opt-hills { display: none; }
.dir.is-transit .dir-avoid { display: none; }
.dir-leave { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.dir-when { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.dir-when [hidden] { display: none; }
.dir-hint { padding: 10px 0; }
.dir-busy { padding: 12px 0; }
.dir-error { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; border-radius: 10px; background-color: var(--warn); color: var(--warn-fg); }
.dir-error p { flex: 1; min-width: 180px; }
.dir-warn { padding: 8px 10px; border-radius: 10px; background-color: var(--warn); color: var(--warn-fg); margin: 6px 0; }
.dir-cards { display: grid; gap: 6px; margin: 6px 0; }
.dir-card {
  display: grid; gap: 2px; text-align: left; padding: 10px 12px; cursor: pointer; font: inherit;
  border-radius: 12px; border: 1px solid var(--border); background-color: var(--surface); color: var(--surface-fg);
}
.dir-card:hover { background-color: var(--surface-2); color: var(--surface-2-fg); }
.dir-card.is-sel { border: 2px solid var(--accent-ink); padding: 9px 11px; }
.dir-card-time { font: 700 1.25rem var(--font-display); }
.dir-card-flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.flag { font-size: 0.78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background-color: var(--surface-2); color: var(--surface-2-fg); }
.wx-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background-color: var(--surface-2); color: var(--surface-2-fg); }
.wx-badge.is-ok { color: var(--ok-ink); background-color: var(--surface-2); }
.wx-badge.is-bad { color: var(--bad-ink); background-color: var(--surface-2); }
.dir-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.dir-sec { border-top: 1px solid var(--border); padding: 4px 0; }
.dir-sec > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 8px 0; }
.dir-sec > summary svg { color: var(--accent-ink); }
.dir-wx-line { margin: 0 0 8px; }
.dir-wx-line.is-bad { color: var(--bad-ink); background-color: transparent; font-weight: 600; }
.wx-strip { list-style: none; margin: 0 0 8px; padding: 0 0 4px; display: flex; gap: 4px; overflow-x: auto; }
.wx-strip li { display: grid; justify-items: center; gap: 1px; min-width: 52px; padding: 6px 2px; border-radius: 10px; font-size: 0.78rem; background-color: var(--surface-2); color: var(--surface-2-fg); border: 2px solid transparent; }
.wx-strip li svg { color: var(--accent-ink); }
.wx-strip li.risk-2 { border-color: #d99a0f; }
.wx-strip li.risk-3 { border-color: #d62839; }
.wx-s-temp { font-weight: 700; }
.dir-wx-better { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background-color: var(--surface-2); color: var(--surface-2-fg); }
.dir-wx-better span { flex: 1; min-width: 160px; font-weight: 600; }
.dir-steps { list-style: none; margin: 0; padding: 0; }
.dir-leave-label { font-weight: 600; }
.dir-card-lines { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; }
.line-badge { display: inline-block; min-width: 26px; padding: 2px 7px; border-radius: 6px; font: 700 0.8rem/1.3 var(--font); text-align: center; }
.dir-card-arrive.live { color: var(--ok-ink); background-color: transparent; font-weight: 600; }
.dir-legs { list-style: none; margin: 0; padding: 0; }
.dir-leg { display: grid; grid-template-columns: 64px 44px 1fr; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.dir-leg:not(.is-walk):not(.is-end) .dir-leg-text { border-left: 4px solid var(--line, var(--border-strong)); padding-left: 8px; }
.dir-leg.is-walk, .dir-leg.is-end { cursor: default; }
.dir-leg-time { font-weight: 700; font-size: 0.88rem; }
.dir-leg-ic { display: grid; justify-items: center; align-content: start; color: var(--muted-fg); background-color: transparent; }
.dir-leg-text { display: grid; gap: 2px; min-width: 0; }
.dir-step-btn { display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left; cursor: pointer; font: inherit; padding: 8px 4px; border: 0; border-bottom: 1px solid var(--border); background-color: transparent; color: inherit; }
.dir-step-btn:hover { background-color: var(--surface-2); color: var(--surface-2-fg); }
.dir-step-ic { flex: none; color: var(--accent-ink); background-color: transparent; padding-top: 1px; }
.dir-step-text { display: grid; gap: 2px; }
.dir-step-stop { display: flex; align-items: center; gap: 8px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.m-chart { display: block; margin: 4px 0; touch-action: pan-y; }

/* ---- controls on the right -------------------------------------------------------------------- */
.m-controls { position: fixed; right: 12px; top: 12px; z-index: 30; display: grid; gap: 10px; }
.m-ctl-group { display: grid; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border); background-color: var(--surface); color: var(--surface-fg); }
.m-ctl {
  display: grid; place-items: center; width: var(--ctl); height: var(--ctl); cursor: pointer; border: 0; border-radius: 0;
  background-color: var(--surface); color: var(--surface-fg);
}
.m-ctl + .m-ctl { border-top: 1px solid var(--border); }
.m-ctl:hover { background-color: var(--surface-2); color: var(--surface-2-fg); }
.m-ctl.is-on, #layers-btn.is-on { color: var(--accent-ink); background-color: var(--surface); }
.m-ctl.is-busy svg { animation: maps-spin 1s linear infinite; }
.m-ctl.is-follow { background-color: var(--accent); color: var(--accent-fg); }
@keyframes maps-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .m-ctl.is-busy svg { animation: none; } }
.m-compass .n { fill: #d62839; }
.m-compass .s { fill: var(--muted-fg); }
.m-compass svg { transition: transform .15s; }

.m-pop {
  position: fixed; right: 64px; top: 12px; z-index: 35; width: min(320px, calc(100vw - 24px)); padding: 12px;
  background-color: var(--surface); color: var(--surface-fg); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow);
  max-height: calc(100dvh - 80px); overflow-y: auto;
}
.m-pop[hidden], .m-pop [hidden] { display: none; }
.m-pop-title { font: 700 0.95rem var(--font); margin: 4px 0 8px; letter-spacing: 0; }
.m-pop-title + .m-overlays { margin-top: 0; }
.m-bases { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.m-base { display: grid; gap: 4px; justify-items: center; padding: 4px; cursor: pointer; font: 600 0.82rem var(--font); border: 2px solid transparent; border-radius: 12px; background-color: transparent; color: inherit; }
.m-base:hover { background-color: var(--surface-2); color: var(--surface-2-fg); }
.m-base[aria-pressed="true"] { border-color: var(--accent-ink); }
.m-base-swatch { display: block; width: 100%; aspect-ratio: 4 / 3; border-radius: 9px; border: 1px solid var(--border); background-color: #e9e6df; color: inherit; }
.sw-map { background-image: linear-gradient(120deg, transparent 46%, #f6b04e 47%, #f6b04e 53%, transparent 54%), linear-gradient(20deg, #a6d1f0 0 28%, #f3f1ec 29% 70%, #cbe7b9 71%); }
.sw-sat { background-image: radial-gradient(circle at 30% 30%, #6d7f4e, #34452a 60%, #1f2a33); }
.sw-terrain { background-image: repeating-radial-gradient(circle at 60% 60%, #e8e1cf 0 6px, #cdbd96 7px 8px), linear-gradient(#e8e1cf, #e8e1cf); }
.sw-topo { background-image: repeating-linear-gradient(160deg, #e9e3cf 0 7px, #b89a6a 8px 9px), linear-gradient(#e9e3cf, #e9e3cf); }
.sw-cycle { background-image: linear-gradient(60deg, transparent 45%, #7d3cc8 46% 52%, transparent 53%), linear-gradient(150deg, transparent 40%, #2a9d5c 41% 46%, transparent 47%), linear-gradient(#f2f0ea, #f2f0ea); }
.m-overlays { display: grid; gap: 4px; margin-top: 4px; }
.m-ov { display: flex; align-items: center; gap: 10px; padding: 8px; text-align: left; cursor: pointer; font: inherit; border-radius: 10px; border: 1px solid transparent; background-color: transparent; color: inherit; }
.m-ov:hover { background-color: var(--surface-2); color: var(--surface-2-fg); }
.m-ov[aria-pressed="true"] { border-color: var(--accent-ink); background-color: var(--surface-2); color: var(--surface-2-fg); }
.m-ov > span:last-child { display: grid; }
.ov-ic { width: 30px; height: 30px; border-radius: 8px; flex: none; background-color: var(--surface-2); color: inherit; }
.ov-radar { background-image: radial-gradient(circle at 40% 50%, #e0243a 0 12%, #f2c94c 13% 26%, #3bb273 27% 45%, transparent 46%); }
.ov-alerts { background-image: linear-gradient(135deg, #d9480f 0 50%, #b0174d 50%); }
.ov-quakes { background-image: radial-gradient(circle at 35% 40%, #e0243a 0 18%, transparent 19%), radial-gradient(circle at 70% 65%, #f29900 0 12%, transparent 13%); }
.ov-wiki { background-image: radial-gradient(circle at 50% 50%, #5d6072 0 22%, transparent 23%); }

.radar-bar {
  position: fixed; right: 64px; bottom: 44px; z-index: 30; display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  background-color: var(--surface); color: var(--surface-fg); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.radar-bar[hidden] { display: none; }
.radar-info { display: grid; margin-left: 4px; line-height: 1.2; }
.radar-legend { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--muted-fg); background-color: transparent; margin-left: 8px; }
.radar-ramp { width: 70px; height: 8px; border-radius: 4px; background-color: #3bb273; color: inherit; background-image: linear-gradient(90deg, #3bb273, #f2c94c, #f29900, #e0243a, #b0174d); }

/* ---- status bar --------------------------------------------------------------------------------- */
.m-status {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 28; height: 30px; display: flex; align-items: center; gap: 12px; padding: 0 10px;
  font-size: 0.78rem; background-color: var(--surface); color: var(--surface-fg); border-top: 1px solid var(--border);
}
.st-notice { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.st-line { display: flex; align-items: center; gap: 8px; min-width: 0; margin: 0; transition: opacity .6s; }
.st-line.is-faded { opacity: 0.55; }
.st-line.is-empty { display: none; }
.st-msg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-line.is-error .st-msg { color: var(--bad-ink); background-color: transparent; font-weight: 600; white-space: normal; line-height: 1.2; }
.st-line.is-busy .st-msg::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background-color: var(--accent); color: inherit; animation: maps-pulse 1s ease-in-out infinite; }
@keyframes maps-pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .st-line.is-busy .st-msg::before { animation: none; } }
.st-undo, .st-x, .st-hist {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer; font: 600 0.78rem var(--font); padding: 3px 8px; border-radius: 999px;
  background-color: var(--surface-2); color: var(--surface-2-fg); border: 1px solid var(--border-strong); flex: none;
}
.st-undo:hover, .st-x:hover, .st-hist:hover { background-color: var(--accent); color: var(--accent-fg); }
.st-x { padding: 3px 5px; }
.st-hist[hidden], .st-undo[hidden], .st-x[hidden] { display: none; }
.st-offline { font-weight: 700; padding: 2px 8px; border-radius: 999px; background-color: var(--warn); color: var(--warn-fg); }
.st-offline[hidden] { display: none; }
.st-scale { display: inline-flex; align-items: center; gap: 6px; color: var(--surface-fg); background-color: transparent; }
.scale-bar { display: inline-block; height: 6px; border: 2px solid var(--surface-fg); border-top: 0; background-color: transparent; color: inherit; min-width: 10px; }
.st-pos { font-family: var(--font-mono); font-size: 0.74rem; color: var(--muted-fg); background-color: transparent; min-width: 15ch; }
.st-zoom { color: var(--muted-fg); background-color: transparent; }
.st-health { width: 22px; height: 22px; display: grid; place-items: center; cursor: pointer; border: 0; border-radius: 50%; background-color: transparent; color: inherit; }
.st-health span { width: 10px; height: 10px; border-radius: 50%; background-color: #1f9d55; color: inherit; }
.st-health.is-bad span { background-color: #d62839; }
.st-theme { display: grid; place-items: center; width: 24px; height: 24px; cursor: pointer; border: 0; border-radius: 6px; background-color: transparent; color: var(--surface-fg); }
.st-theme:hover { background-color: var(--surface-2); color: var(--surface-2-fg); }
.st-theme .ic-light, .st-theme .ic-dark { display: none; }
.st-theme[data-mode="light"] .ic-auto, .st-theme[data-mode="dark"] .ic-auto { display: none; }
.st-theme[data-mode="light"] .ic-light, .st-theme[data-mode="dark"] .ic-dark { display: inline; }
.st-attr { color: var(--muted-fg); background-color: transparent; white-space: nowrap; }
.st-attr a { color: var(--muted-fg); background-color: transparent; }

/* ---- menus and dialogs ---------------------------------------------------------------------------- */
.m-menu {
  position: fixed; z-index: 60; min-width: 230px; max-width: min(340px, calc(100vw - 16px)); padding: 6px;
  background-color: var(--surface); color: var(--surface-fg); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow);
}
.m-menu-title { padding: 4px 8px 6px; font-size: 0.78rem; font-weight: 600; color: var(--muted-fg); background-color: transparent; }
.m-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; text-align: left; cursor: pointer; font: inherit; border: 0; border-radius: 8px; background-color: transparent; color: inherit; }
.m-menu-item:hover, .m-menu-item:focus-visible { background-color: var(--surface-2); color: var(--surface-2-fg); outline: none; }
.m-menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--focus-ring); }
.m-menu-item:disabled { opacity: 0.5; cursor: default; }
.m-menu-item svg { color: var(--muted-fg); flex: none; }
.m-menu-noicon { width: 16px; flex: none; }
.m-menu-label { flex: 1; }
.m-menu-hint { font-size: 0.78rem; color: var(--muted-fg); background-color: transparent; }
.m-menu-sep { height: 1px; margin: 4px 6px; background-color: var(--border); color: inherit; }
.m-dialog {
  width: min(460px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); padding: 18px 20px; border-radius: 16px;
  background-color: var(--surface); color: var(--surface-fg); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
}
.m-dialog-wide { width: min(680px, calc(100vw - 24px)); }
.m-dialog::backdrop { background-color: rgb(0 0 0 / 0.45); }
.m-dialog h2 { font: 700 1.25rem var(--font-display); margin: 0 0 14px; }
.dlg-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.dlg-foot { display: flex; justify-content: flex-end; margin-top: 12px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 0.92rem; }
.keys dt { color: var(--muted-fg); background-color: transparent; }
.keys dd { margin: 0; }
kbd { display: inline-block; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border-strong); background-color: var(--surface-2); color: var(--surface-2-fg); font-size: 0.85em; }
.sources { width: 100%; border-collapse: collapse; font-size: 0.88rem; margin: 8px 0; }
.sources th, .sources td { text-align: left; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.src-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background-color: var(--border-strong); color: inherit; }
.src-ok .src-dot { background-color: #1f9d55; }
.src-down .src-dot, .src-busy .src-dot { background-color: #d62839; }
.src-down td:last-child, .src-busy td:last-child { color: var(--bad-ink); background-color: transparent; }

/* ---- markers -------------------------------------------------------------------------------------- */
.mk-pin { width: 0; height: 0; cursor: pointer; }
.mk-pin-inner { position: absolute; left: -17px; top: -40px; width: 34px; height: 40px; display: grid; place-items: start center; color: #ffffff; background-color: transparent; filter: drop-shadow(0 2px 3px rgb(0 0 0 / 0.4)); }
.mk-pin-inner svg { width: 34px; height: 34px; fill: #d62839; stroke: #ffffff; stroke-width: 1.6; }
.mk-me { width: 0; height: 0; }
.mk-me-dot { position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%; background-color: #0a84ff; color: #ffffff; border: 3px solid #ffffff; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.25), 0 0 0 0 rgb(10 132 255 / 0.5); animation: maps-me 2s ease-out infinite; }
.mk-me.is-pinned .mk-me-dot { background-color: #6b7286; animation: none; }
.mk-me.is-sim .mk-me-dot { background-color: #8a5bff; }
.mk-me-cone { display: none; position: absolute; left: -22px; top: -44px; width: 44px; height: 44px; transform-origin: 22px 44px; background-color: transparent; color: inherit; background-image: radial-gradient(circle at 50% 100%, rgb(10 132 255 / 0.45), transparent 70%); clip-path: polygon(50% 100%, 18% 0, 82% 0); }
.mk-me.has-heading .mk-me-cone { display: block; }
@keyframes maps-me { 70% { box-shadow: 0 0 0 1px rgb(0 0 0 / 0.25), 0 0 0 14px rgb(10 132 255 / 0); } 100% { box-shadow: 0 0 0 1px rgb(0 0 0 / 0.25), 0 0 0 0 rgb(10 132 255 / 0); } }
@media (prefers-reduced-motion: reduce) { .mk-me-dot { animation: none; } }
.mk-stop { width: 0; height: 0; cursor: grab; }
.mk-stop span { position: absolute; left: -13px; top: -13px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; font: 700 0.78rem var(--font); background-color: #5d6072; color: #ffffff; border: 2.5px solid #ffffff; box-shadow: 0 1px 4px rgb(0 0 0 / 0.4); }
.mk-stop.is-start span { background-color: #0b7d46; }
.mk-stop.is-end span { background-color: #c21f33; }
.mk-stop.dragging { cursor: grabbing; }
.mk-vertex { width: 0; height: 0; cursor: grab; }
.mk-vertex::after { content: ""; position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%; background-color: #ffffff; color: inherit; border: 3px solid #8a5bff; box-sizing: border-box; }

/* ---- navigation ---------------------------------------------------------------------------------- */
.nav-banner {
  position: fixed; z-index: 45; top: 12px; left: 50%; transform: translateX(-50%); width: min(520px, calc(100vw - 24px));
  display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 16px; box-shadow: var(--shadow);
  background-color: var(--nav); color: var(--nav-fg);
}
.nav-banner[hidden], .nav-bar[hidden] { display: none; }
.nav-ic { flex: none; display: grid; place-items: center; }
.nav-main { display: grid; flex: 1; min-width: 0; }
.nav-dist { font: 700 1.6rem/1.1 var(--font-display); }
.nav-text { font-size: 1.02rem; font-weight: 600; }
.nav-then { display: grid; justify-items: center; gap: 2px; }
.nav-then .muted { color: var(--nav-fg); background-color: transparent; opacity: 0.85; }
.nav-bar {
  position: fixed; z-index: 45; bottom: 40px; left: 50%; transform: translateX(-50%); width: min(520px, calc(100vw - 24px));
  display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 16px; border-radius: 14px; box-shadow: var(--shadow);
  background-color: var(--surface); color: var(--surface-fg); border: 1px solid var(--border);
}
.nav-times { flex: 1; min-width: 0; }
.nav-eta { font-weight: 700; font-size: 1.05rem; }
body.is-navigating .m-top, body.is-navigating .radar-bar { display: none; }
/* over the part of the map the panel leaves free (set from maps.js) */
@media (min-width: 761px) {
  .nav-banner, .nav-bar { left: calc(50% + var(--panel-right, 0px) / 2); }
}

/* ---- dropping files -------------------------------------------------------------------------------- */
.drop-hint { display: none; }
body.is-dropping .drop-hint {
  display: grid; place-items: center; position: fixed; inset: 12px; z-index: 70; pointer-events: none; border-radius: 18px;
  background-color: rgb(10 132 255 / 0.12); color: var(--fg); border: 3px dashed var(--accent-ink);
}
body.is-dropping .drop-hint p { padding: 14px 18px; border-radius: 12px; font-weight: 600; background-color: var(--surface); color: var(--surface-fg); }

.maps-nojs { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; background-color: var(--bg); color: var(--fg); }
.print-sheet { display: none; }

/* ---- the web desktop's window: no brand, no theme switch (the desktop owns those) ------------------- */
body.is-embed .m-brand { display: none; }
body.is-embed .m-search { padding-left: 14px; }
body.is-embed .st-theme { display: none; }

/* ---- phones: a bottom sheet ----------------------------------------------------------------------- */
@media (max-width: 760px) {
  .m-top { left: 8px; right: 8px; top: 8px; width: auto; }
  .m-chips { width: auto; }
  .m-controls { top: 112px; right: 8px; gap: 8px; }
  body.has-panel .m-controls { top: 70px; }
  .m-pop { right: 8px; top: 70px; }
  .m-panel {
    left: 0; right: 0; top: auto; bottom: 0; width: auto; border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
    height: 46dvh; transition: height .22s ease; padding-bottom: env(safe-area-inset-bottom);
  }
  .m-panel.dragging { transition: none; }
  .m-panel[data-snap="peek"] { height: 132px; }
  .m-panel[data-snap="full"] { height: calc(100dvh - 66px); }
  .p-handle { display: grid; place-items: center; height: 18px; flex: none; cursor: ns-resize; touch-action: none; }
  .p-handle span { width: 40px; height: 5px; border-radius: 3px; background-color: var(--border-strong); color: inherit; }
  .p-head { padding-top: 0; }
  .m-status { height: 26px; gap: 8px; }
  body.has-panel .m-status { display: none; }
  .st-pos, .st-zoom, .st-scale { display: none; }
  .radar-bar { right: 8px; left: 8px; bottom: 34px; flex-wrap: wrap; }
  body.has-panel .radar-bar { display: none; }
  .nav-banner { top: 8px; }
  .nav-bar { bottom: 8px; }
  .place-name { font-size: 1.25rem; }
}
@media (max-width: 420px) {
  .st-attr { font-size: 0.7rem; }
  .radar-legend { display: none; }
}

/* ---- print: the map as a picture, then the panel ----------------------------------------------- */
@media print {
  body.maps { overflow: visible; height: auto; background-color: #ffffff; color: #000000; }
  .map, .m-top, .m-panel, .m-controls, .m-pop, .m-status, .radar-bar, .nav-banner, .nav-bar, .map-loading, dialog, .m-menu { display: none !important; }
  .print-sheet { display: block; padding: 0; background-color: #ffffff; color: #000000; }
  .print-sheet img { width: 100%; height: auto; border: 1px solid #999999; margin: 8px 0 16px; }
  .print-sheet h1 { font: 700 20pt var(--font-display); }
  .print-sheet button { border: 0; background-color: transparent; color: #000000; padding: 2px 0; }
  .print-sheet .dir-actions, .print-sheet .res-tools, .print-sheet .place-actions, .print-sheet .place-nearby, .print-sheet .place-reach { display: none; }
  .print-sheet details > *:not(summary) { display: block; }
}
