/*
 * The map application.
 *
 * One rule governs the layout: the map owns the whole viewport and every control
 * floats above it. Nothing scrolls the page — only the results list and the drawer
 * scroll, each inside its own surface.
 *
 * Phone and desktop share one component tree. The results sheet is a draggable
 * bottom sheet under 900px and a floating left column above it; that is the only
 * structural difference, and it is expressed entirely here.
 */

:root {
  color-scheme: light dark;

  --bg: #eef1f5;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-sunken: #f2f4f7;
  --border: rgba(16, 22, 32, 0.10);
  --text: #101620;
  --muted: #667085;
  --accent: #0a66ff;
  --accent-ink: #ffffff;

  /* Price bands. Kept distinguishable by lightness as well as hue, so the
     cheap/dear reading survives the common forms of colour blindness. */
  --cheap: #0f9d58;
  --mid: #d98d00;
  --dear: #d93a2b;

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 22px;

  --shadow-sm: 0 1px 2px rgba(16, 22, 32, 0.08), 0 2px 8px rgba(16, 22, 32, 0.06);
  --shadow: 0 4px 14px rgba(16, 22, 32, 0.10), 0 12px 32px rgba(16, 22, 32, 0.12);

  --gap: 0.625rem;
  --panel-w: 23.5rem;

  /* Measured from the floating top controls by app.js, so the desktop column can
     sit under them however the chips wrap. */
  --hud-h: 7rem;
}

[data-bs-theme="dark"] {
  --bg: #0f1115;
  --surface: rgba(24, 28, 35, 0.86);
  --surface-solid: #181c23;
  --surface-sunken: #12161c;
  --border: rgba(255, 255, 255, 0.11);
  --text: #e9edf3;
  --muted: #9aa4b2;
  --accent: #4d92ff;
  --accent-ink: #06101f;

  --cheap: #2fbf71;
  --mid: #e8a33d;
  --dear: #f0655a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.5), 0 16px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

/* Several surfaces below set an explicit display, and an author display rule beats
   the [hidden] attribute's UA style. Without this, hiding a panel does nothing. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 2000;
  background: var(--accent); color: var(--accent-ink); padding: 0.6rem 1rem;
}
.skip-link:focus { left: 0; }

/* ── The map itself ─────────────────────────────────────────────────────── */

.map-canvas {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 0;
}

/* OSM publishes raster tiles only, so dark mode is a filter rather than a second
   tile source. Markers live in their own pane and are not touched. */
[data-bs-theme="dark"] .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.92) saturate(0.75);
}

.leaflet-container {
  background: var(--bg);
  font: inherit;
}

.leaflet-control-attribution {
  background: var(--surface) !important;
  color: var(--muted);
  border-radius: var(--r-sm) 0 0 0;
  padding: 2px 8px;
  font-size: 10px;
  backdrop-filter: blur(10px);
}
.leaflet-control-attribution a { color: var(--muted); }

/* ── Floating chrome ────────────────────────────────────────────────────── */

.hud-top {
  position: fixed;
  z-index: 600;
  top: calc(env(safe-area-inset-top, 0px) + var(--gap));
  left: calc(env(safe-area-inset-left, 0px) + var(--gap));
  right: calc(env(safe-area-inset-right, 0px) + var(--gap));
  display: grid;
  /* minmax(0,...) clamps the track: without it the chip row's intrinsic width
     sizes the column and drags the search bar off the right edge of a phone. */
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
  pointer-events: none;
}
.hud-top > * { pointer-events: auto; min-width: 0; }

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3125rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(140%);
}

.icon-btn {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 2.5rem; height: 2.5rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.icon-btn[aria-pressed="true"], .icon-btn.is-on { background: var(--accent); color: var(--accent-ink); }

.finder {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
}
.finder-icon { flex: none; color: var(--muted); margin-inline: 0.125rem 0.375rem; }

.finder-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0.5rem 0;
  outline: none;
}
.finder-input::placeholder { color: var(--muted); }
.finder-input::-webkit-search-cancel-button { display: none; }

.finder-clear {
  flex: none;
  display: grid; place-items: center;
  width: 1.75rem; height: 1.75rem;
  border: 0; border-radius: 50%;
  background: color-mix(in srgb, var(--text) 10%, transparent);
  color: var(--text);
  cursor: pointer;
}
.finder-clear svg { width: 0.875rem; height: 0.875rem; stroke-width: 2.4; }

.suggestions {
  position: absolute;
  top: calc(100% + 0.375rem);
  left: 0; right: 0;
  z-index: 10;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.suggestions li { margin: 0; }
.suggestions button {
  display: flex;
  width: 100%;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.suggestions button:hover,
.suggestions button:focus-visible { background: var(--surface-sunken); }
.suggestions .s-name { font-weight: 600; }
.suggestions .s-meta { color: var(--muted); font-size: 0.8125rem; margin-left: auto; white-space: nowrap; }

/* Filter chips. They scroll sideways on a phone rather than wrapping into a wall. */
.chiprow {
  display: flex;
  gap: 0.375rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 0.125rem;
  -webkit-overflow-scrolling: touch;
}
.chiprow::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 13rem;
  padding: 0.4375rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(16px) saturate(140%);
  cursor: pointer;
}
.chip > span { overflow: hidden; text-overflow: ellipsis; }
.chip-caret { width: 0.875rem; height: 0.875rem; stroke-width: 2.6; opacity: 0.55; }
.chip:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.chip[aria-expanded="true"],
.chip[aria-pressed="true"],
.chip.is-set {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.chip[aria-expanded="true"] .chip-caret,
.chip.is-set .chip-caret { opacity: 0.8; }
.chip-primary { font-weight: 700; }
/* Long fuel names ("Gases licuados del petróleo…") truncate early so the sort chip stays on screen. */
.chip-primary > span { max-width: 6rem; }
.chip-icon { padding: 0.4375rem; }
.chip-icon svg { width: 1rem; height: 1rem; }
.chip-icon[aria-pressed="true"] svg { fill: currentColor; }

.hud-side {
  position: fixed;
  z-index: 600;
  right: calc(env(safe-area-inset-right, 0px) + var(--gap));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 8.5rem);
  display: grid;
  gap: 1px;
  padding: 1px;
  background: var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hud-side .icon-btn {
  border-radius: 0;
  background: var(--surface-solid);
  width: 2.625rem; height: 2.625rem;
}

/* ── Results sheet ──────────────────────────────────────────────────────── */

.sheet {
  position: fixed;
  z-index: 500;
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - var(--hud-h) - env(safe-area-inset-top, 0px) - 1.5rem);
  background: var(--surface-solid);
  border-top: 1px solid var(--border);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow);
  transition: height 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  touch-action: none;
}
.sheet[data-state="peek"] { height: calc(5.25rem + env(safe-area-inset-bottom, 0px)); }
.sheet[data-state="half"] { height: calc(52dvh + env(safe-area-inset-bottom, 0px)); }
.sheet[data-state="full"] { height: calc(100dvh - var(--hud-h) - env(safe-area-inset-top, 0px) - 1.5rem); }
.sheet.is-dragging { transition: none; }

.sheet-grip {
  flex: none;
  display: block;
  width: 100%;
  padding: 0.6875rem 0;
  border: 0;
  background: transparent;
  cursor: grab;
}
.sheet-grip::before {
  content: "";
  display: block;
  width: 2.25rem; height: 0.25rem;
  margin: 0 auto;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 22%, transparent);
}

.sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem 0.625rem;
}
.sheet-title { margin: 0; font-size: 1rem; font-weight: 700; }
.sheet-note { margin: 0.125rem 0 0; color: var(--muted); font-size: 0.8125rem; }

.spinner {
  flex: none;
  width: 1.125rem; height: 1.125rem;
  margin-left: auto;
  border: 2px solid color-mix(in srgb, var(--text) 18%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.results {
  flex: 1 1 auto;
  /* Without this a flex child refuses to shrink below its content, and the list
     spills past the panel instead of scrolling inside it. */
  min-height: 0;
  margin: 0;
  padding: 0 0.5rem calc(env(safe-area-inset-bottom, 0px) + 0.5rem);
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.sheet[data-state="peek"] .results { overflow: hidden; }

.result {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.25rem 0.75rem;
  width: 100%;
  padding: 0.625rem 0.625rem;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.result + .result { box-shadow: 0 -1px 0 var(--border); }
.result:hover, .result:focus-visible { background: var(--surface-sunken); }
.result.is-active { background: color-mix(in srgb, var(--accent) 12%, transparent); }

.result-name {
  grid-column: 1;
  font-weight: 650;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.result-meta {
  grid-column: 1;
  color: var(--muted);
  font-size: 0.8125rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.result-price {
  grid-column: 2; grid-row: 1;
  font-size: 1.0625rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.result-sub {
  grid-column: 2; grid-row: 2;
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  margin-right: 0.375rem;
  padding: 0.0625rem 0.375rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
  vertical-align: 1px;
}
.badge-cheap { background: color-mix(in srgb, var(--cheap) 18%, transparent); color: var(--cheap); }
.badge-star { background: color-mix(in srgb, var(--mid) 20%, transparent); color: var(--mid); }

.price-cheap { color: var(--cheap); }
.price-dear { color: var(--dear); }

.sheet-state {
  padding: 1rem 1.25rem calc(env(safe-area-inset-bottom, 0px) + 1.5rem);
  text-align: center;
}
.state-title { margin: 0 0 0.25rem; font-weight: 650; }
.state-hint { margin: 0 0 1rem; color: var(--muted); font-size: 0.875rem; }

/* ── Station detail ─────────────────────────────────────────────────────── */

.detail {
  position: fixed;
  z-index: 700;
  left: 0; right: 0; bottom: 0;
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface-solid);
  border-top: 1px solid var(--border);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow);
  animation: rise 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes rise { from { transform: translateY(12%); opacity: 0; } }

.detail-head {
  flex: none;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.detail-title { margin: 0; font-size: 1.0625rem; font-weight: 700; }
.detail-address { margin: 0.125rem 0 0; color: var(--muted); font-size: 0.875rem; }
.detail-map-link {
  margin: 0.375rem 0 0; padding: 0; border: 0; background: none;
  color: var(--accent); font: inherit; font-size: 0.875rem; font-weight: 600; cursor: pointer;
}
.detail-map-link:hover { text-decoration: underline; }
.detail-head { flex-direction: column; align-items: stretch; gap: 0.375rem; }
.detail-back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  margin: -0.25rem 0 0 -0.5rem;
  padding: 0.25rem 0.625rem 0.25rem 0.25rem;
  border: 0;
  border-radius: var(--r);
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.detail-back:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.detail-back svg {
  width: 1.5rem; height: 1.5rem;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* While a station is open it replaces the list rather than stacking on it;
   visibility (not display) keeps the list's scroll position for "Back". */
.sheet.is-covered { visibility: hidden; pointer-events: none; }

.detail-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.875rem 1rem calc(env(safe-area-inset-bottom, 0px) + 1rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.detail-section + .detail-section { margin-top: 1.125rem; }
.detail-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.fuel-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.125rem 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.fuel-row:last-child { border-bottom: 0; }
.fuel-row.is-current {
  margin-bottom: 0.25rem;
  padding: 0.75rem;
  border: 1px solid var(--accent);
  border-radius: 0.625rem;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.fuel-row.is-current .fuel-name { font-size: 1.0625rem; font-weight: 700; }
.fuel-row.is-current .fuel-price { font-size: 1.25rem; font-weight: 800; color: var(--accent); }
.fuel-row.is-current .fuel-note { font-weight: 600; }
.fuel-name { grid-column: 1; }
.fuel-price { grid-column: 2; font-variant-numeric: tabular-nums; font-weight: 700; }
.fuel-note { grid-column: 1 / -1; color: var(--muted); font-size: 0.75rem; }

.nav-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-sunken);
  color: inherit;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn svg { width: 1rem; height: 1rem; }
.btn[aria-pressed="true"] svg { fill: currentColor; }

/* ── Drawer ─────────────────────────────────────────────────────────────── */

.drawer {
  position: fixed;
  z-index: 900;
  top: 0; bottom: 0; left: 0;
  width: min(22rem, 88vw);
  display: flex;
  flex-direction: column;
  background: var(--surface-solid);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: slide-in 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes slide-in { from { transform: translateX(-100%); } }

.drawer-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: calc(env(safe-area-inset-top, 0px) + 0.75rem) 0.75rem 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.drawer-head [data-action="close-drawer"] { margin-left: auto; }
.brand { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 700; }
.brand-mark { font-size: 1.25rem; }
.drawer-heading { margin: 0; font-size: 1rem; font-weight: 700; }

.drawer-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 1rem calc(env(safe-area-inset-bottom, 0px) + 1.5rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.drawer-body { display: flex; flex-direction: column; }
.drawer-page { flex: none; }

/* Root page fills the drawer so the "about" section sits at the bottom. */
.drawer-page[data-drawer-page="root"]:not([hidden]) { display: flex; flex: 1 0 auto; flex-direction: column; }
.drawer-page[data-drawer-page="root"] > .drawer-section { margin-top: auto; }

.drawer-page > :first-child { padding-top: 0.25rem; }
.drawer-nav { display: flex; flex-direction: column; padding: 0.75rem 0; }

.nav-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 0.5rem;
  margin: 0 -0.5rem;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.nav-row:hover { background: var(--surface-sunken); }
.nav-icon { flex: none; width: 1.25rem; height: 1.25rem; color: var(--muted); }
.nav-text { display: flex; flex-direction: column; gap: 0.125rem; min-width: 0; }
.nav-label { font-size: 0.9375rem; font-weight: 600; }
.nav-hint { color: var(--muted); font-size: 0.75rem; }
.nav-caret { flex: none; width: 1rem; height: 1rem; margin-left: auto; color: var(--muted); }

.drawer-section { padding: 1.125rem 0; border-top: 1px solid var(--border); }
.drawer-page > .drawer-section:first-child { border-top: 0; }
.drawer-section h3 {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field {
  display: flex;
  justify-content: space-between;
  margin: 0.875rem 0 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
}
.drawer-section > .field:first-of-type { margin-top: 0; }
.field output { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }

.control {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
}

.range { width: 100%; accent-color: var(--accent); }

.hint { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.8125rem; }
.link { color: var(--accent); }

.lang-switch { display: flex; gap: 0.25rem; list-style: none; margin: 0; padding: 0; }
.lang-switch a {
  display: block;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: none;
}
.lang-switch a[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.data-table th, .data-table td { padding: 0.375rem 0.25rem; border-bottom: 1px solid var(--border); text-align: left; }
.data-table thead th { color: var(--muted); font-size: 0.6875rem; font-weight: 700; white-space: nowrap; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr:last-child th, .data-table tbody tr:last-child td { border-bottom: 0; }

/* ── Shared overlays ────────────────────────────────────────────────────── */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(8, 11, 16, 0.42);
  animation: fade 0.2s ease;
}
.scrim.is-light { z-index: 650; background: rgba(8, 11, 16, 0.18); }
@keyframes fade { from { opacity: 0; } }

/* The chip menus: a popover pinned under its chip on a pointer device, a bottom
   sheet on a phone, where a 13rem-wide popover would be unusable. */
.menu {
  position: fixed;
  z-index: 850;
  left: 0; right: 0; bottom: 0;
  max-height: 70dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.5rem 0.5rem calc(env(safe-area-inset-bottom, 0px) + 0.75rem);
  background: var(--surface-solid);
  border-top: 1px solid var(--border);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow);
  animation: rise 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}

.menu-title {
  position: sticky;
  top: 0;
  margin: 0;
  padding: 0.625rem 0.75rem 0.5rem;
  background: var(--surface-solid);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-sunken); }
.menu-item .m-meta { margin-left: auto; color: var(--muted); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.menu-item .m-tick { flex: none; width: 1.125rem; height: 1.125rem; opacity: 0; color: var(--accent); }
.menu-item[aria-pressed="true"] { font-weight: 650; }
.menu-item[aria-pressed="true"] .m-tick { opacity: 1; }
.menu-foot { display: flex; gap: 0.5rem; padding: 0.5rem 0.75rem 0.25rem; }
.menu-foot .btn { flex: 1 1 auto; justify-content: center; }

.toast {
  position: fixed;
  z-index: 1000;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1.25rem);
  transform: translateX(-50%);
  margin: 0;
  max-width: min(26rem, calc(100vw - 2rem));
  padding: 0.625rem 1rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 90%, transparent);
  color: var(--bg);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow);
  animation: rise 0.2s ease;
}

/* ── Map markers ────────────────────────────────────────────────────────── */

.pin {
  display: grid;
  place-items: center;
  min-width: 3.25rem;
  padding: 0.1875rem 0.375rem;
  border: 1.5px solid var(--surface-solid);
  border-radius: 999px;
  background: var(--mid);
  color: #fff;
  font: 700 0.75rem/1.2 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease;
}
.pin-cheap { background: var(--cheap); }
.pin-dear { background: var(--dear); }
.pin-fav { border-color: var(--mid); }
.pin.is-active {
  transform: scale(1.18);
  z-index: 1000;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent), var(--shadow);
}

.cluster {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0;
  width: 2.75rem; height: 2.75rem;
  border: 2px solid var(--surface-solid);
  border-radius: 50%;
  background: var(--mid);
  color: #fff;
  font: 700 0.6875rem/1.1 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-sm);
}
.cluster-cheap { background: var(--cheap); }
.cluster-dear { background: var(--dear); }
.cluster small { font-size: 0.5625rem; font-weight: 600; line-height: 1; opacity: 0.85; }

.me-dot {
  width: 1rem; height: 1rem;
  border: 2.5px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 28%, transparent), var(--shadow-sm);
}

/* ── Desktop: the sheet becomes a floating left column ──────────────────── */

@media (min-width: 900px) {
  .hud-top {
    left: calc(env(safe-area-inset-left, 0px) + 0.875rem);
    right: auto;
    width: var(--panel-w);
  }

  /* The search bar keeps the column width; the chips spill past it over the map
     rather than hiding themselves behind a horizontal scroll nobody looks for. */
  .chiprow {
    width: max-content;
    max-width: calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 1.75rem);
    overflow: visible;
  }

  .hud-side {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 2.25rem);
  }

  .sheet {
    top: calc(env(safe-area-inset-top, 0px) + var(--hud-h) + 1.375rem);
    left: calc(env(safe-area-inset-left, 0px) + 0.875rem);
    right: auto;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 0.875rem);
    width: var(--panel-w);
    height: auto !important;
    max-height: none;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    touch-action: auto;
  }
  .sheet-grip { display: none; }
  .sheet-head { padding-top: 0.9375rem; }
  .sheet[data-state="peek"] .results { overflow-y: auto; }

  .detail {
    top: calc(env(safe-area-inset-top, 0px) + var(--hud-h) + 1.375rem);
    left: calc(env(safe-area-inset-left, 0px) + 0.875rem);
    right: auto;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 0.875rem);
    width: var(--panel-w);
    max-height: none;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
  }
  @keyframes rise { from { transform: translateY(8px); opacity: 0; } }

  /* Anchored under its chip instead of rising from the bottom edge. */
  .menu {
    left: var(--menu-x, 1rem);
    top: var(--menu-y, 7rem);
    right: auto; bottom: auto;
    width: min(20rem, calc(100vw - 2rem));
    max-height: min(26rem, 70dvh);
    padding-bottom: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--r);
  }

  .toast { left: calc(env(safe-area-inset-left, 0px) + 0.875rem + var(--panel-w) / 2); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Leaflet writes stroke and fill as presentation attributes; a CSS rule beats
   those, which is how the radius ring follows the theme's accent. */
.radius-ring { stroke: var(--accent); fill: var(--accent); }

/* Account card (drawer) */
.account-card { display: flex; align-items: center; gap: 0.75rem; }
.account-avatar { flex: none; width: 2.75rem; height: 2.75rem; border-radius: 50%; object-fit: cover; }
.account-initial {
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 1.125rem;
}
.account-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.account-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-hint { color: var(--muted); font-size: 0.8125rem; }
