/* ============================================================
   HomeMap — dark neon design system
   ============================================================ */

:root {
  --bg: #0a0b10;
  --panel: rgba(14, 16, 24, 0.86);
  --panel-solid: #10121a;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #eef0f6;
  --text-dim: #9aa1b5;
  --text-faint: #7d8498; /* ≥4.5:1 on the panel — #5d6478 failed WCAG AA */
  --accent: #8b5cf6; /* overwritten per active layer via JS */
  --radius: 18px;
  --font: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* author display rules (e.g. .area-price { display:flex }) must never
   beat the hidden attribute */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--bg);
  font-family: var(--font);
  color: var(--text);
  overflow: hidden;
}

::selection { background: rgba(139, 92, 246, 0.4); }

/* ---------- map ---------- */

#map {
  position: fixed;
  inset: 0;
  background: var(--bg);
}

#map .maplibregl-canvas { outline: none; }

/* ---------- loading screen ---------- */

#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 600px at 30% 20%, rgba(139, 92, 246, 0.12), transparent 60%),
    radial-gradient(800px 500px at 75% 80%, rgba(45, 212, 191, 0.08), transparent 60%),
    var(--bg);
  transition: opacity 0.7s ease, visibility 0.7s;
}

#loader.done { opacity: 0; visibility: hidden; }

.loader-inner { text-align: center; }

.loader-logo {
  width: 92px;
  height: 92px;
  filter: drop-shadow(0 0 20px rgba(167, 139, 250, 0.5));
}

.loader-logo .logo-house {
  stroke-dasharray: 140;
  stroke-dashoffset: 140;
  animation: draw 1.6s var(--ease) forwards;
}

.loader-logo .logo-pin {
  stroke-dasharray: 55;
  stroke-dashoffset: 55;
  animation: draw 1.1s 0.8s var(--ease) forwards;
}

.loader-logo .logo-dot {
  opacity: 0;
  animation: rise 0.5s 1.6s var(--ease) forwards;
}

@keyframes draw { to { stroke-dashoffset: 0; } }

.wordmark {
  font-family: 'Poppins', var(--font);
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #f2f0fa;
}

.loader-word {
  margin-top: 16px;
  font-size: 30px;
  animation: rise 0.9s 0.4s var(--ease) backwards;
}

.loader-bar {
  width: 160px;
  height: 3px;
  margin: 22px auto 0;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.loader-bar i {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: 3px;
  background: linear-gradient(90deg, #a78bfa, #22d3ee);
  animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(420%); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ---------- side panel ---------- */

#panel {
  position: fixed;
  top: 16px;
  left: 16px;
  bottom: 16px;
  z-index: 10;
  width: 342px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
  overflow-x: hidden;
  animation: panel-in 0.8s 0.15s var(--ease) backwards;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

/* the bottom-sheet grip exists only on phones — inert on desktop */
#sheet-toggle { display: none; }

#panel::-webkit-scrollbar { width: 6px; }
#panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 3px; }

/* let the panel scroll rather than squash its sections */
#panel > * { flex-shrink: 0; }

@keyframes panel-in {
  from { opacity: 0; transform: translateX(-28px); }
  to { opacity: 1; transform: none; }
}

/* brand */

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  flex: none;
  filter: drop-shadow(0 0 10px rgba(167, 139, 250, 0.45));
}

.brand h1 {
  font-size: 23px;
  line-height: 1.1;
}

.brand p {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 400;
  margin-top: 2px;
}

.region-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px 1px 4px;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  color: var(--text);
  cursor: default;
}

.region-badge svg {
  width: 15px;
  height: 10px;
  border-radius: 2px;
}

/* search */

.search {
  position: relative;
  display: flex;
}

.search input {
  flex: 1;
  height: 42px;
  padding: 0 44px 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: 500 14px var(--font);
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}

.search input::placeholder { color: var(--text-faint); }

.search input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.search button {
  position: absolute;
  right: 5px;
  top: 5px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 9px;
  background: var(--accent);
  color: #0a0b10; /* dark glyph keeps ≥3:1 on light accents like the crime sky */
  cursor: pointer;
  transition: background 0.4s, transform 0.15s;
}

.search button:hover { transform: scale(1.06); }
.search button:active { transform: scale(0.94); }
.search button svg { width: 16px; height: 16px; }

.search.error input {
  border-color: #f43f5e;
  animation: shake 0.4s;
}

@keyframes shake {
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

/* section labels */

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 9px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.kbd-hint {
  font-size: 10px;
  letter-spacing: 0.4px;
  text-transform: none;
  color: var(--text-faint);
  opacity: 0.8;
}

/* layer group tabs */

.layer-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.tab {
  flex: 1;
  padding: 6px 0;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-faint);
  font: 600 10.5px var(--font);
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--line-strong);
}

.tab.has-layer::after {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: 4px;
  vertical-align: 2px;
}

/* IoD year toggle inside the Deprivation tab */

.year-toggle {
  grid-column: 1 / -1;
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.year-btn {
  flex: 1;
  padding: 4px 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-faint);
  font: 700 10.5px var(--font);
  letter-spacing: 0.4px;
  cursor: pointer;
  transition: all 0.2s;
}

.year-btn:hover { color: var(--text); }

.year-btn.active {
  color: #fff;
  background: color-mix(in srgb, var(--accent) 25%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* layer chips */

.chips {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

/* the flagship "Overall" severity chip owns the full row — hierarchy
   the eye gets before reading a single word */
#chips[data-group="crime"] .chip:first-child { grid-column: 1 / -1; }

.chip {
  --hue: #8b5cf6;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-dim);
  font: 600 11.5px var(--font);
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: all 0.28s var(--ease);
  animation: chip-in 0.6s var(--ease) backwards;
}

@keyframes chip-in {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: none; }
}

.chip svg {
  flex: none;
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.28s var(--ease);
}

.chip:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-2px);
}

.chip:hover svg { transform: scale(1.12); }

.chip.active {
  color: #fff;
  border-color: color-mix(in srgb, var(--hue) 70%, transparent);
  background: color-mix(in srgb, var(--hue) 16%, rgba(255, 255, 255, 0.03));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--hue) 35%, transparent),
    0 6px 22px color-mix(in srgb, var(--hue) 28%, transparent);
}

.chip.active svg { stroke: var(--hue); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--hue) 70%, transparent)); }

.chip.loading svg { animation: spin 0.9s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* legend */

.legend {
  padding: 13px 14px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.legend-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.legend-desc {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-dim);
  margin: 3px 0 11px;
  min-height: 34px;
}

.legend-bar {
  height: 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: opacity 0.3s;
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
}

.legend-mid {
  margin-top: 4px;
  text-align: center;
  font-size: 10.5px;
  color: var(--text-faint);
}
.legend-mid:empty { display: none; }

.legend-caveat {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-faint);
}
.legend-caveat a { color: var(--text-dim); text-decoration: none; white-space: nowrap; }
.legend-caveat a:hover { color: var(--text); text-decoration: underline; }

.brand-tag { color: var(--text-faint); font-size: 11.5px; letter-spacing: 0.02em; }

.legend.swap .legend-bar,
.legend.swap .legend-title,
.legend.swap .legend-desc,
.legend.swap .legend-labels { animation: fadeswap 0.5s var(--ease); }

@keyframes fadeswap {
  0% { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: none; }
}

/* floating neighbourhood card */

.floatcard {
  position: fixed;
  z-index: 15;
  width: 296px;
  padding: 15px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line-strong));
  background: rgba(13, 15, 22, 0.92);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  visibility: hidden; /* keep hidden close/link buttons out of the tab order */
  transform: translateY(8px) scale(0.97);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease), visibility 0s 0.3s;
}

.floatcard.open {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  transform: none;
}

.areacard-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.area-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1.25;
}

.area-code {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}

.unpin {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}

.unpin:hover { color: #fff; border-color: #f43f5e; }
.unpin svg { width: 13px; height: 13px; }

.area-price {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 10px;
  padding: 8px 11px;
  border-radius: 10px;
  background: color-mix(in srgb, #e879f9 10%, transparent);
  border: 1px solid color-mix(in srgb, #e879f9 25%, transparent);
}

.price-label { font-size: 11.5px; color: var(--text-dim); }

.price-val {
  font-size: 16px;
  font-weight: 800;
  color: #f0abfc;
  letter-spacing: -0.2px;
}

.area-bars { margin-top: 11px; display: flex; flex-direction: column; gap: 3px; }

.bar-row {
  --hue: #8b5cf6;
  display: grid;
  grid-template-columns: 86px 1fr 30px;
  align-items: center;
  gap: 9px;
  padding: 3px 6px;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-dim);
  font: 500 11.5px var(--font);
  text-align: left;
  transition: background 0.2s, color 0.2s;
}

.bar-row:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }

.bar-row.current { color: var(--text); background: color-mix(in srgb, var(--hue) 10%, transparent); }

.bar-track {
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.bar-fill {
  display: block; /* spans are inline and would ignore width */
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--hue) 55%, #111), var(--hue));
  box-shadow: 0 0 8px color-mix(in srgb, var(--hue) 45%, transparent);
  transition: width 0.55s var(--ease);
}

.bar-num {
  font-weight: 700;
  font-size: 11px;
  text-align: right;
  color: var(--hue);
  font-variant-numeric: tabular-nums;
}

.areacard-tip {
  margin-top: 11px;
  font-size: 10.5px;
  color: var(--text-faint);
  text-align: center;
}

/* Floating POI bar */

#poibar {
  position: fixed;
  top: 16px;
  left: 374px;
  right: 200px;
  z-index: 9;
  padding: 3px 0;
  animation: rise 0.8s 0.5s var(--ease) backwards;
}

.pois {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.poi-group { position: relative; }

.poi-group .poi-pill svg.chev {
  width: 11px;
  height: 11px;
  opacity: 0.7;
  transition: transform 0.25s var(--ease);
}

.poi-group.open .poi-pill svg.chev { transform: rotate(180deg); }

.poi-group .poi-pill svg:not(.chev) {
  width: 13px;
  height: 13px;
  opacity: 0.85;
}

.poi-pill .count {
  font-size: 10px;
  font-weight: 800;
  color: #0a0b10;
  background: var(--text-dim);
  border-radius: 9px;
  padding: 0 5px;
  line-height: 15px;
}

.poi-pill.active .count { background: #fff; }

.poi-pill .count:empty { display: none; }

.poi-pop {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  min-width: 172px;
  padding: 6px;
  border-radius: 13px;
  border: 1px solid var(--line-strong);
  background: rgba(12, 14, 20, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 20;
}

.poi-group.open .poi-pop {
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: rise 0.25s var(--ease);
}

.poi-row {
  --hue: #fff;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 9px;
  border: none;
  background: none;
  color: var(--text-dim);
  font: 600 11.5px var(--font);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.poi-row:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }

.poi-row svg {
  flex: none;
  opacity: 0.75;
  transition: color 0.2s, opacity 0.2s;
}

.poi-row .lbl {
  flex: 1;
  text-align: left;
}

.poi-row .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--hue);
  box-shadow: 0 0 7px color-mix(in srgb, var(--hue) 65%, transparent);
  opacity: 0.35;
  transition: opacity 0.25s;
  margin-left: auto;
}

.poi-row.active { color: #fff; }
.poi-row.active svg {
  color: var(--hue);
  opacity: 1;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--hue) 60%, transparent));
}
.poi-row.active .dot { opacity: 1; }
.poi-row.loading .dot { animation: dot-pulse 0.7s ease-in-out infinite; }

.poi-pill.standalone svg { width: 13px; height: 13px; opacity: 0.85; }
.poi-pill.standalone.active svg { color: var(--hue); }

/* context overlays selector (bottom-right) */

#overlaybox {
  position: fixed;
  right: 16px;
  bottom: 36px;
  z-index: 9;
}

#overlays-btn {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  border: 1px solid var(--line-strong);
  background: rgba(12, 14, 20, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.25s var(--ease);
}

#overlays-btn svg { width: 20px; height: 20px; }

#overlays-btn:hover { color: #fff; transform: translateY(-1px); }

#overlays-btn.active {
  color: #fff;
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent), 0 6px 20px rgba(0, 0, 0, 0.4);
}

#overlays-btn .count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 17px;
  height: 17px;
  border-radius: 9px;
  background: var(--accent);
  color: #0a0b10;
  font: 800 10px var(--font);
  line-height: 17px;
  padding: 0 4px;
}

#overlays-btn .count:empty { display: none; }

#overlaybox .poi-pop {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  top: auto;
  right: 0;
  left: auto;
}

#overlaybox.open .poi-pop {
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: rise 0.25s var(--ease);
}

/* People sub-category headers inside the chip grid */

.chip-sub {
  grid-column: 1 / -1;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 4px 2px -2px;
}

/* POI info popup */

.poi-card { width: 252px; }

.pp-cat { margin-top: 5px; }

.pp-cat .pill {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 10.5px;
  color: #0a0b10;
}

.pp-detail {
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-dim);
}

.pp-actions {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 12px;
}

.pp-range {
  font-size: 11px;
  color: var(--text-faint);
}

.pp-actions a {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 1px dotted var(--text-faint);
}

.pp-actions a:hover { color: #fff; }

.poi-pill {
  --hue: #fff;
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  background: rgba(12, 14, 20, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  color: var(--text-dim);
  font: 600 11.5px var(--font);
  cursor: pointer;
  transition: all 0.25s var(--ease);
}

.poi-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hue);
  box-shadow: 0 0 7px color-mix(in srgb, var(--hue) 65%, transparent);
  opacity: 0.45;
  transition: opacity 0.25s;
}

.poi-pill:hover {
  color: var(--text);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.poi-pill.active {
  color: #fff;
  border-color: color-mix(in srgb, var(--hue) 55%, transparent);
  background: color-mix(in srgb, var(--hue) 22%, rgba(12, 14, 20, 0.85));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--hue) 25%, transparent);
}

.poi-pill.active .dot { opacity: 1; }

.poi-pill.loading .dot { animation: dot-pulse 0.7s ease-in-out infinite; }

@keyframes dot-pulse { 50% { opacity: 0.15; } }

/* credits */

.credits {
  margin-top: auto;
  padding-top: 10px;
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--text-faint);
}

.credits a { color: var(--text-dim); text-decoration: none; border-bottom: 1px dotted var(--text-faint); }
.credits a:hover { color: var(--text); }

/* ---------- tooltip ---------- */

.tooltip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  padding: 8px 12px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: rgba(12, 14, 20, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
  max-width: 240px;
  transform: translate(14px, 14px);
  transition: opacity 0.15s;
}

.tooltip-name { font-size: 12.5px; font-weight: 700; line-height: 1.3; }

.tooltip-value {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.tooltip-value .pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 11px;
  color: #0a0b10;
}

/* ---------- zoom hint ---------- */

.zoomhint {
  position: fixed;
  z-index: 9;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 30px;
  border: 1px solid var(--line-strong);
  background: rgba(12, 14, 20, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-dim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s, transform 0.5s var(--ease);
}

.zoomhint.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

.zoomhint svg { width: 15px; height: 15px; }

/* ---------- search marker ---------- */

.pulse-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid #fff;
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 80%, transparent);
  position: relative;
}

.pulse-marker::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: pulse-ring 1.8s ease-out infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(2.6); opacity: 0; }
}

/* ---------- maplibre controls, dark restyle ---------- */

.maplibregl-ctrl-top-right { top: 68px; right: 16px; }

/* ---------- account / beta access ---------- */

#userbox { position: fixed; top: 16px; right: 16px; z-index: 16; }

#userbtn {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  border: 1px solid var(--line-strong);
  background: rgba(12, 14, 20, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s, transform 0.15s;
}
#userbtn:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.28); transform: translateY(-1px); }
#userbtn svg { width: 19px; height: 19px; }

#userdot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(100deg, #8b5cf6, #0ea5e9);
  border: 2px solid var(--bg);
}

.user-card {
  position: fixed;
  top: 68px;
  right: 16px;
  width: 292px;
}

.user-title { font-size: 15px; font-weight: 700; }
.user-mail { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; word-break: break-all; }
.user-note { color: var(--text-dim); font-size: 12.5px; line-height: 1.5; margin-top: 6px; display: block; }

.user-row { display: flex; align-items: flex-start; gap: 9px; margin-top: 12px; }
.user-badge {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--text-faint);
  flex-shrink: 0;
}
.user-badge.live { color: #41d488; border-color: rgba(65, 212, 136, 0.4); background: rgba(65, 212, 136, 0.1); }
.user-row .user-note { margin-top: 1px; }

.user-form { display: flex; gap: 7px; margin-top: 13px; }
.user-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: 500 13px var(--font);
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.user-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.user-go {
  padding: 10px 15px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(100deg, #8b5cf6, #0ea5e9);
  color: #fff;
  font: 600 13px var(--font);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.3s;
}
.user-go:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(139, 92, 246, 0.4); }

.user-err { min-height: 16px; margin-top: 7px; font-size: 12px; color: #f43f5e; }

.user-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.user-links a { color: var(--text-dim); font-size: 12.5px; text-decoration: none; transition: color 0.25s; }
.user-links a:hover { color: var(--text); }
.user-forget {
  align-self: flex-start;
  border: none;
  background: none;
  color: var(--text-faint);
  font: 500 12px var(--font);
  cursor: pointer;
  padding: 0;
}
.user-forget:hover { color: #f43f5e; }

/* ---------- centered Pro modal ---------- */

#promodal, #authmodal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.25s var(--ease);
}
#promodal.show, #authmodal.show { opacity: 1; }

/* progressive steps inside the one modal */
.step[hidden] { display: none; }
.step-back {
  display: block;
  margin: 12px auto 0;
  border: none;
  background: none;
  color: var(--text-faint);
  font: 500 12.5px var(--font);
  cursor: pointer;
  padding: 4px;
}
.step-back:hover { color: var(--text); }

#co-code {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: 700 26px/1 var(--font);
  letter-spacing: 0.36em;
  text-align: center;
  text-indent: 0.36em; /* keeps the glyphs optically centred despite tracking */
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}
#co-code:focus { border-color: #8b5cf6; box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.22); }
#co-form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.pm-terms { margin-top: 11px; font-size: 11px; line-height: 1.55; color: var(--text-faint); }
.pm-terms a { color: var(--text-dim); }

.pay-spin {
  width: 28px; height: 28px;
  margin: 6px auto 16px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.12);
  border-top-color: #a78bfa;
  animation: pay-spin 0.8s linear infinite;
}
@keyframes pay-spin { to { transform: rotate(360deg); } }

.am-msg.bad { color: #f87171; }

/* email + code forms */
#em-form { display: flex; flex-direction: column; gap: 9px; margin-top: 16px; }
#em-form input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: 500 14px var(--font);
  text-align: center;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}
#em-form input:focus { border-color: #8b5cf6; box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.22); }
.am-cta { width: 100%; padding: 12px; font-size: 14px; }
.am-cta:disabled { opacity: 0.7; cursor: default; transform: none; }
.am-lead { margin-top: 6px; color: var(--text-dim); font-size: 13.5px; line-height: 1.5; }
.am-msg { min-height: 17px; margin-top: 9px; font-size: 12.5px; color: #41d488; }

.modal-back {
  position: absolute;
  inset: 0;
  background: rgba(6, 7, 11, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  width: min(430px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 30px 28px 24px;
  border-radius: 20px;
  border: 1px solid rgba(139, 92, 246, 0.45);
  background: rgba(13, 15, 22, 0.97);
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.2), 0 30px 90px rgba(0, 0, 0, 0.7);
  text-align: center;
  transform: translateY(10px) scale(0.98);
  transition: transform 0.25s var(--ease);
}
#promodal.show .modal-card, #authmodal.show .modal-card { transform: none; }
.modal-card .unpin { position: absolute; top: 12px; right: 12px; }

.pm-logo { width: 44px; height: 44px; margin-bottom: 6px; }
.modal-card h3 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.grad-text {
  background: linear-gradient(100deg, #a78bfa, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.pm-price { margin: 6px 0 16px; color: var(--text-dim); font-size: 14px; }
.pm-price b { color: var(--text); font-size: 26px; font-weight: 800; }
.pm-beta {
  display: inline-block;
  margin-left: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #41d488;
  border: 1px solid rgba(65, 212, 136, 0.4);
  background: rgba(65, 212, 136, 0.1);
}

.pm-list { list-style: none; text-align: left; margin: 0 auto 18px; max-width: 300px; }
.pm-list li { padding: 5px 0 5px 26px; position: relative; color: var(--text-dim); font-size: 13.5px; }
.pm-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 9px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(65, 212, 136, 0.14) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%2341d488" stroke-width="3.4" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg>') center/9px no-repeat;
}

#pm-form { display: flex; gap: 8px; }
#pm-form input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: 500 14px var(--font);
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}
#pm-form input:focus { border-color: #8b5cf6; box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.22); }
.pm-note { margin-top: 12px; color: var(--text-faint); font-size: 11.5px; }

.pm-alt {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pm-alt span { color: var(--text-faint); font-size: 12px; }
.pm-cta { width: 100%; padding: 12px; font-size: 14px; }

.pm-lead { margin-top: 4px; color: var(--text); font-size: 13.5px; font-weight: 500; }
.pm-signin-note { display: none; }
#promodal.needs-signin .pm-signin-note { display: block; }

#pm-signin {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 11px;
  padding: 10px 14px;
  font: 600 13px var(--font);
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s, transform 0.15s;
}
#pm-signin:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.28); transform: translateY(-1px); }
#pm-subscribe:disabled { opacity: 0.6; cursor: default; transform: none; }

/* ---------- guided tour ---------- */

#tour {
  position: fixed;
  inset: 0;
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}
#tour.show { opacity: 1; pointer-events: auto; }

.tour-mask { position: absolute; inset: 0; }
/* the "hole" is a transparent box with a huge shadow — one element,
   no SVG masks, and it animates smoothly between targets */
.tour-hole {
  position: absolute;
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(6, 7, 11, 0.78);
  border: 1px solid rgba(167, 139, 250, 0.5);
  opacity: 0;
  transition: all 0.42s var(--ease);
}
.tour-mask:has(.tour-hole[style*="opacity: 0"]) { background: rgba(6, 7, 11, 0.78); }

.tour-card {
  position: absolute;
  width: min(330px, calc(100vw - 24px));
  padding: 22px 22px 18px;
  border-radius: 18px;
  border: 1px solid rgba(139, 92, 246, 0.4);
  background: rgba(14, 16, 24, 0.98);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
  transition: left 0.42s var(--ease), top 0.42s var(--ease);
}
.tour-card.centred { left: 50% !important; top: 50% !important; transform: translate(-50%, -50%); }

.tour-icon { font-size: 26px; line-height: 1; margin-bottom: 10px; }
.tour-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 7px; }
.tour-body { color: var(--text-dim); font-size: 13.5px; line-height: 1.6; }

.tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.tour-dots { display: flex; gap: 5px; }
.tour-dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  transition: background 0.3s, width 0.3s;
}
.tour-dots i.on { width: 18px; border-radius: 3px; background: linear-gradient(100deg, #a78bfa, #22d3ee); }
.tour-btns { display: flex; align-items: center; gap: 8px; }
.tour-skip {
  border: none; background: none; color: var(--text-faint);
  font: 500 12.5px var(--font); cursor: pointer; padding: 6px 4px;
}
.tour-skip:hover { color: var(--text); }
.tour-next { padding: 9px 15px; font-size: 13px; }

@media (max-width: 720px) {
  .tour-card { left: 12px !important; right: 12px; top: auto !important; bottom: 16px; width: auto; }
  .tour-card.centred { transform: none; }
}

/* ---------- account card ---------- */

.acc-card {
  margin-top: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}
.acc-id { display: flex; align-items: center; gap: 10px; }
.acc-avatar {
  width: 30px; height: 30px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(100deg, #8b5cf6, #0ea5e9);
  color: #fff; font-size: 13px; font-weight: 700;
}
.acc-mail { font-size: 13px; font-weight: 600; word-break: break-all; line-height: 1.35; }
.acc-mail.dim { color: var(--text-dim); font-weight: 500; }

.acc-plan { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 12px 0 13px; }
.acc-plan .user-note { margin: 0; flex-basis: 100%; }

.acc-cta { width: 100%; padding: 10px; font-size: 13px; }
.acc-second {
  width: 100%;
  margin-top: 7px;
  padding: 9px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  font: 500 12.5px var(--font);
  cursor: pointer;
  transition: color 0.25s, background 0.25s, border-color 0.25s;
}
.acc-second:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.24); }

.set-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 2px;
}
.set-link {
  align-self: flex-start;
  border: none;
  background: none;
  padding: 2px 0;
  color: var(--text-dim);
  font: 500 12.5px var(--font);
  cursor: pointer;
  transition: color 0.2s;
}
.set-link:hover { color: var(--text); }
.set-link.danger { color: var(--text-faint); }
.set-link.danger:hover { color: #f87171; }
.set-link:disabled { opacity: 0.6; cursor: default; }

.acc-region {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #41d488;
}

/* profile menu extras */

.user-plan {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 13px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}
.plan-name { font-size: 13.5px; font-weight: 700; margin-right: 7px; }
.user-plan > div { min-width: 0; } /* let long emails wrap instead of pushing the button out */
/* signed-in block stacks: name/badge, email, actions */
.user-plan.col { display: flex; flex-direction: column; align-items: stretch; gap: 9px; }
.user-plan.col .plan-top { display: flex; align-items: center; gap: 7px; }
.user-plan.col .user-mail { margin: 0; }
.user-plan.col .user-forget { align-self: flex-start; }
.user-plan .user-note { margin-top: 2px; }
.user-plan .user-go { flex-shrink: 0; }
.user-plan .user-mail { margin-top: 2px; }
.user-plan .user-go { padding: 8px 12px; font-size: 12px; }

.user-set {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.set-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); cursor: pointer; }
.set-row input { accent-color: var(--accent); width: 15px; height: 15px; }

/* PRO tag on locked chips + POI pills */
.chip { position: relative; }
.chip.pro { opacity: 0.82; }
.poi-pill.pro::after, .poi-row.pro::after {
  content: 'PRO';
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 5px;
  border-radius: 6px;
  color: #fff;
  background: linear-gradient(100deg, #8b5cf6, #0ea5e9);
  margin-left: 6px;
  flex-shrink: 0;
}
.chip .pro-tag {
  position: absolute;
  top: 5px;
  right: 6px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 5px;
  border-radius: 6px;
  color: #fff;
  background: linear-gradient(100deg, #8b5cf6, #0ea5e9);
  opacity: 0.92;
}

.maplibregl-ctrl-group {
  background: var(--panel) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 12px !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4) !important;
  overflow: hidden;
}

.maplibregl-ctrl-group button {
  background: transparent !important;
  width: 34px !important;
  height: 34px !important;
}

.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line) !important; }

.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(0.9); }

.maplibregl-ctrl-group button:hover { background: rgba(255, 255, 255, 0.08) !important; }

.maplibregl-ctrl-attrib {
  background: rgba(12, 14, 20, 0.75) !important;
  color: var(--text-faint);
  font: 400 10px var(--font);
  border-radius: 8px;
}

.maplibregl-ctrl-attrib a { color: var(--text-dim); }

.maplibregl-ctrl-attrib-button { filter: invert(0.85); }

/* ---------- mobile ---------- */

@media (max-width: 720px), (max-height: 560px) {

  :root {
    --dock: 148px;          /* JS keeps this equal to the real dock height */
    --kb: 0px;              /* visualViewport keyboard inset */
    --sa-t: env(safe-area-inset-top, 0px);
    --sa-b: env(safe-area-inset-bottom, 0px);
    --sa-l: env(safe-area-inset-left, 0px);
    --sa-r: env(safe-area-inset-right, 0px);
  }

  /* ---------- top: single-row scrolling POI rail ---------- */

  #poibar {
    top: calc(8px + var(--sa-t));
    left: calc(8px + var(--sa-l));
    right: calc(60px + var(--sa-r));   /* clears #userbox */
    z-index: 12;
    padding: 0;
    animation-name: bw-fade;  /* NOT `rise`: a transform here would make
                                 #poibar the containing block for the
                                 fixed .poi-pop below */
  }
  @keyframes bw-fade { from { opacity: 0 } to { opacity: 1 } }

  /* NEVER add mask-image/filter/transform to .pois — it clips the fixed
     .poi-pop, making the POI dropdown invisible AND untappable.
     The partly-cut last pill is the scroll affordance. */
  .pois {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    padding: 2px;
    margin: -2px;
  }
  .pois::-webkit-scrollbar { display: none; }

  .poi-pill {
    min-height: 44px;
    padding: 0 14px;
    border-radius: 22px;
    font-size: 12.5px;
    /* the rail scrolls, so a pill may be as wide as its label needs —
       never let a two-word category break onto a second line */
    white-space: nowrap;
    flex-shrink: 0;
    /* base is `transition: all`, which animates geometry on every
       breakpoint cross and outranks !important mid-flight */
    transition: color .25s, background .25s, border-color .25s, box-shadow .25s;
  }

  /* must be fixed: .pois is a scroll container and clips absolute children */
  #poibar .poi-pop {
    position: fixed;
    top: calc(60px + var(--sa-t));
    left: calc(8px + var(--sa-l));
    right: calc(8px + var(--sa-r));
    width: auto;
    min-width: 0;
    max-height: 52dvh;
    overflow-y: auto;
  }

  /* ---------- top-right: account only ---------- */

  #userbox { top: calc(8px + var(--sa-t)); right: calc(8px + var(--sa-r)); }
  #userbtn { width: 44px; height: 44px; }

  /* ---------- bottom-right thumb rail ---------- */

  #map .maplibregl-ctrl-top-right {
    top: auto;
    right: calc(8px + var(--sa-r));
    bottom: calc(var(--dock) + 66px + var(--sa-b) + var(--kb));
    z-index: 12;
  }
  /* hide the GROUP, not the button — an emptied group still costs ~12px */
  .maplibregl-ctrl-top-right .maplibregl-ctrl-group:has(.maplibregl-ctrl-zoom-in),
  .maplibregl-ctrl-top-right .maplibregl-ctrl-group:has(.maplibregl-ctrl-fullscreen) {
    display: none;
  }
  /* line the map controls up with our own buttons: MapLibre adds a 10px
     margin, and the group's 1px border made it 2px wider than the
     overlays button beside it. Same 44px box, same 8px edge, same
     13px corner — they read as one column now. */
  #map .maplibregl-ctrl-top-right .maplibregl-ctrl { margin: 0; }
  #map .maplibregl-ctrl-top-right .maplibregl-ctrl-group {
    box-sizing: border-box;
    width: 44px;
    border-radius: 13px !important;
  }
  .maplibregl-ctrl-group button { width: 42px !important; height: 42px !important; }

  #overlaybox {
    right: calc(8px + var(--sa-r));
    bottom: calc(var(--dock) + 12px + var(--sa-b) + var(--kb));
    z-index: 12;
  }
  #overlays-btn {
    width: 44px; height: 44px;
    transition: color .25s, border-color .25s, box-shadow .25s;  /* was `all` */
  }
  #overlaybox .poi-pop { max-height: 50dvh; overflow-y: auto; }

  /* attribution: was painted under #panel and invisible */
  #map .maplibregl-ctrl-bottom-right {
    right: auto;
    left: calc(6px + var(--sa-l));
    bottom: calc(var(--dock) + 6px + var(--sa-b) + var(--kb));
    z-index: 8;
  }

  .zoomhint { bottom: auto; top: calc(64px + var(--sa-t)); z-index: 8; }

  /* ---------- bottom sheet ---------- */

  #panel {
    top: auto;
    left: 0; right: 0;
    bottom: var(--kb);
    width: auto;
    z-index: 30;                 /* must cover #userbox(16) and #areacard(15) */
    max-height: none;
    gap: 10px;
    padding: 0 12px calc(10px + var(--sa-b));
    border-radius: 20px 20px 0 0;
    border-width: 1px 0 0;
    overflow: hidden;
    animation-name: sheet-in;
  }
  @keyframes sheet-in {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: none; }
  }

  #sheet-toggle {
    display: block;
    order: -2;                   /* must outrank .legend's order:-1 */
    width: 100%; height: 22px;
    border: 0; background: none; padding: 0;
    cursor: pointer;
  }
  #sheet-toggle::before {
    content: '';
    display: block;
    width: 40px; height: 4px; margin: 8px auto 0;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.26);
  }

  /* collapsed = dock */
  #panel:not(.open) > .brand,
  #panel:not(.open) > .search,
  #panel:not(.open) > .credits,
  #panel:not(.open) .section-label,
  #panel:not(.open) #layer-tabs,
  #panel:not(.open) .legend-desc,
  #panel:not(.open) .legend-mid,
  #panel:not(.open) .legend-caveat,
  #panel:not(.open) .chip-sub { display: none; }

  #panel:not(.open) > .legend { order: -1; }
  #panel:not(.open) .legend { padding: 0; border: 0; background: none; }
  #panel:not(.open) .legend-title  { font-size: 14px; }
  #panel:not(.open) .legend-bar    { margin-top: 6px; height: 8px; }
  #panel:not(.open) .legend-labels { margin-top: 5px; font-size: 10.5px; }

  /* the mask IS safe here: #chips has no fixed descendants and sits on
     the opaque panel. Do not copy it to .pois. */
  #panel:not(.open) .chips {
    display: flex;
    grid-template-columns: none;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 2px 22px 2px 2px;
    margin: -2px;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
            mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
  }
  #panel:not(.open) .chips::-webkit-scrollbar { display: none; }
  #panel:not(.open) .chip { flex: 0 0 auto; min-height: 44px; padding: 0 12px; font-size: 12px; }
  /* `#panel:not(.open) .chip` is (1,2,0) and would beat a bare `.chip.pro`
     (0,2,0) padding-right — restate at equal weight */
  #panel:not(.open) .chip.pro { padding-right: 36px; }

  #panel.open { max-height: 82dvh; overflow-y: auto; }

  /* ---------- touch targets ---------- */

  .kbd-hint { display: none; }                        /* "keys 1–9" is desktop-only */
  .chips { grid-template-columns: repeat(2, 1fr); }   /* was 3 — PRO tag collided */
  .chip {
    min-height: 44px; padding: 8px 10px; font-size: 11.5px;
    transition: color .28s, background .28s, border-color .28s, box-shadow .28s;
  }
  .chip.pro { padding-right: 36px; }
  .tab      { min-height: 44px; font-size: 11.5px; }
  .poi-row  { min-height: 44px; padding: 9px 12px; }
  .unpin    { width: 44px; height: 44px; }
  .bar-row  { min-height: 38px; }        /* 8 rows x 44 would be 352px */
  .set-row input { width: 20px; height: 20px; }
  .user-links a { min-height: 40px; display: flex; align-items: center; }

  /* 16px stops iOS auto-zooming the viewport on focus */
  .search input { height: 46px; font-size: 16px; }
  .user-form input, #em-form input, #co-code { font-size: 16px; }
  .search button { width: 38px; height: 38px; top: 4px; right: 4px; }

  .brand-logo { width: 32px; height: 32px; }
  .brand h1 { font-size: 18px; }
  .brand p  { font-size: 11px; }
  .legend-desc { min-height: 0; }

  /* ---------- area card / POI popup: dock-anchored sheet ---------- */

  .floatcard {
    top: auto !important;
    bottom: calc(var(--dock) + 10px + var(--sa-b) + var(--kb)) !important;
    left: calc(8px + var(--sa-l)) !important;
    right: calc(8px + var(--sa-r));
    width: auto;
    max-height: 42dvh;
    overflow-y: auto;
  }
  /* the account menu opts back out of the bottom anchor */
  .floatcard.user-card {
    top: calc(60px + var(--sa-t)) !important;
    bottom: auto !important;
    right: calc(8px + var(--sa-r));
    left: auto !important;
    width: min(300px, calc(100vw - 16px));
    max-height: calc(100dvh - 76px);
    overflow-y: auto;
  }
  body.sheet-open .floatcard.open:not(.user-card) {
    opacity: 0; pointer-events: none; visibility: hidden;
  }

  /* ---------- things that must clear the dock ---------- */

  #toast { bottom: calc(var(--dock) + 66px + var(--sa-b) + var(--kb)); }
  body .ck-banner { bottom: calc(var(--dock) + 12px + var(--sa-b) + var(--kb)); }
  /* the centred step keeps `left: 50% !important` from the desktop rule
     but loses its compensating transform on mobile, which parked the
     card half off-screen — pin it to the full width instead */
  .tour-card,
  .tour-card.centred {
    left: 12px !important;
    right: 12px;
    top: auto !important;
    bottom: calc(var(--dock) + 12px + var(--sa-b)) !important;
    width: auto;
    max-height: 52dvh;
    overflow-y: auto;
    transform: none;
  }
}

/* ---------- landscape phones (these used to fall through to desktop) ---------- */

@media (max-height: 560px) {
  #poibar { top: calc(6px + var(--sa-t)); }
  .poi-pill { min-height: 40px; }

  /* landscape is short and wide, so the dock goes side-by-side instead
     of stacking: legend on the left, layer rail on the right. Hiding
     the chips here (the earlier approach) cost a tap for the single
     most common action on the map. */
  #panel { gap: 4px 14px; padding-bottom: calc(6px + var(--sa-b)); }
  #panel:not(.open) { flex-flow: row wrap; align-items: center; }
  #panel:not(.open) > #sheet-toggle { flex: 0 0 100%; height: 14px; }
  #panel:not(.open) > #sheet-toggle::before { margin-top: 5px; }
  #panel:not(.open) > .legend { flex: 0 0 33%; order: 0; min-width: 0; }
  #panel:not(.open) > .layers { flex: 1; order: 1; min-width: 0; }
  #panel:not(.open) .legend-title { font-size: 12.5px; }
  #panel:not(.open) .legend-bar { margin-top: 4px; height: 6px; }
  #panel:not(.open) .legend-labels { margin-top: 3px; font-size: 9.5px; }
  #panel:not(.open) .chip { min-height: 38px; }

  #panel.open { max-height: 92dvh; }
  #panel.open .chips { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- touch: kill hover states that stick after a tap ---------- */

@media (hover: none) {
  .tooltip { display: none !important; }   /* mousemove-driven; no reliable teardown */
  .chip:hover { transform: none; }
  .chip:hover svg { transform: none; }
  .poi-pill:hover { transform: none; }
  .poi-row:hover { background: none; }
  .bar-row:hover { background: none; }
  #overlays-btn:hover, #userbtn:hover, .user-go:hover,
  #pm-signin:hover, .search button:hover, .unpin:hover { transform: none; }
}

/* toast: transient error notice, bottom-centre */

#toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 16px);
  max-width: min(92vw, 420px);
  padding: 11px 16px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(20, 14, 18, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.45;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  z-index: 40;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- reduced motion ---------- */

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