/* =========================================================
   LebThree Map · styles
   Editorial light theme. Mobile-first.
   ========================================================= */

:root {
  --red:        #E4252B;
  --red-deep:   #B31A1F;
  --red-ink:    #6A0F12;
  --ink:        #121212;
  --ink-soft:   #2A2622;
  --ink-faded:  #6B6158;
  --paper:      #F5EFE3;
  --paper-2:    #EDE4D2;
  --paper-3:    #E5DAC2;
  --cream:      #FBF6EC;
  --line:       #D9CDB2;
  --line-soft:  #E7DCC4;
  --accent:     #E4252B;
  --ok:         #18794E;
  --gold:       #B58A1F;
  --shadow-lg:  0 22px 60px rgba(40, 25, 10, 0.18), 0 4px 14px rgba(40, 25, 10, 0.08);
  --shadow-md:  0 10px 26px rgba(40, 25, 10, 0.10);
  --shadow-sm:  0 2px 6px rgba(40, 25, 10, 0.10);
  --radius:     14px;
  --radius-sm:  10px;
  --radius-lg:  20px;

  --sans: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --display: 'Archivo Black', 'Anton', 'Impact', sans-serif;
  --serif: 'Fraunces', 'Playfair Display', Georgia, serif;

  --sheet-peek: 92px;
  --sheet-half: 52vh;
  --sheet-full: 92vh;

  /* Topbar height — used by .detail to position itself below the topbar
     instead of having the topbar overlay it (which left only ~1px of
     visible gap before the .detail__kind label and squashed the layout). */
  --topbar-h: 47px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }

/* ——— App frame ——— */
#app {
  position: fixed; inset: 0;
  display: grid;
  grid-template-columns: 400px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "topbar topbar"
    "panel  map";
}

/* ——— Topbar ——— */
.topbar {
  grid-area: topbar;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  z-index: 40;
  position: relative;
}
.topbar__brand {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: inherit;
  padding: 2px 0;
}
.topbar__logo {
  height: 26px; display: block;
}
.topbar__tag {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-faded);
  padding-left: 12px;
  border-left: 1px solid var(--line);
  line-height: 1;
}
.topbar__spacer { flex: 1; }

/* Quiet text link — About */
.topbar__about {
  font-size: 13px;
  color: var(--ink-faded);
  text-decoration: none;
  padding: 6px 4px;
  border-radius: 6px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: color .15s;
}
.topbar__about:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

/* Primary CTA — Get on the map */
.topbar__cta {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--red);
  color: #fff;
  text-decoration: none;
  padding: 8px 14px 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.005em;
  margin-left: 6px;
  border: 1px solid var(--red-deep);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.18),
    0 1px 0 rgba(106,15,18,0.25),
    0 2px 6px rgba(179,26,31,0.18);
  transition: transform .12s ease, box-shadow .15s, background .15s;
}
.topbar__cta:hover {
  background: #ED3036;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.22),
    0 1px 0 rgba(106,15,18,0.3),
    0 3px 10px rgba(179,26,31,0.28);
  transform: translateY(-0.5px);
}
.topbar__cta:active {
  transform: translateY(0);
  box-shadow:
    inset 0 1px 2px rgba(106,15,18,0.35),
    0 0 0 rgba(0,0,0,0);
}
.topbar__cta:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.topbar__cta-icon { flex-shrink: 0; margin-top: -0.5px; }

/* Mobile sheet footer (about + credit) — hidden on desktop */
.sheet-footer { display: none; }

.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px;
  font-size: 10px; font-weight: 600;
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 4px; color: var(--ink-faded);
  margin-left: 6px;
}

/* Mobile-only filter toggle */
.topbar__filter-btn {
  display: none;
  background: var(--ink); color: var(--paper);
  border: 0; border-radius: 10px;
  padding: 9px 14px; font-weight: 600; font-size: 13px;
  gap: 6px;
}

/* ——— Panel (desktop left rail) ——— */
.panel {
  grid-area: panel;
  background: var(--cream);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden; position: relative; z-index: 20;
}

.panel__head {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--cream);
  position: relative;
}
.panel__title {
  display: flex; align-items: baseline; gap: 10px;
  margin: 0 0 10px;
}
.panel__title h1 {
  font-family: var(--display);
  font-size: 22px; font-weight: 900;
  letter-spacing: -0.01em;
  margin: 0; line-height: 1;
  text-transform: uppercase;
}
.panel__title span {
  font-size: 13px; color: var(--ink-faded);
  font-family: var(--serif); font-style: italic;
}
.panel__count {
  font-size: 12px; color: var(--ink-faded);
  text-transform: uppercase; letter-spacing: 0.12em;
  margin-left: auto;
}

/* Search */
.search {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(18,18,18,0.08);
}
.search svg { flex-shrink: 0; color: var(--ink-faded); }
.search input {
  border: 0; outline: 0; flex: 1;
  font-size: 14px; color: var(--ink);
  background: transparent;
}
.search input::placeholder { color: var(--ink-faded); }

/* Filters */
.filters {
  padding: 12px 16px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--cream);
  flex: 1;
  overflow-y: auto;
}
.filters__row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.filters__label {
  font-size: 11px; font-weight: 700;
  color: var(--ink-faded);
  text-transform: uppercase; letter-spacing: 0.1em;
}
.filters__group { margin-bottom: 12px; }
.filters__group:last-child { margin-bottom: 0; }

/* Chips */
.chips {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px; font-weight: 500;
  color: var(--ink-soft);
  transition: all .15s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.is-on {
  background: var(--ink); color: var(--paper);
  border-color: var(--ink);
}
.chip--coin { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-weight: 600; letter-spacing: 0.02em; }
.chip--ghost { background: var(--paper-2); border-color: var(--line-soft); }

/* Toggle switches */
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 8px 0; }
.toggles--single { grid-template-columns: 1fr; }
.toggle {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; padding: 6px 8px; margin: 0 -8px;
  border-radius: 8px; user-select: none;
}
.toggle:hover { background: var(--paper-2); }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle__box {
  width: 34px; height: 20px;
  background: var(--paper-3);
  border-radius: 999px; position: relative;
  transition: background .15s;
  flex-shrink: 0;
}
.toggle__box::after {
  content: ''; position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: transform .18s;
}
.toggle input:checked + .toggle__box { background: var(--ink); }
.toggle input:checked + .toggle__box::after { transform: translateX(14px); }
.toggle__label { font-size: 13px; color: var(--ink); }

/* Rating slider */
.rating-row {
  display: flex; align-items: center; gap: 12px;
  margin-top: 4px;
}
.rating-row input[type="range"] {
  flex: 1; accent-color: var(--ink);
}
.rating-row output {
  font-size: 12px; font-weight: 600; color: var(--ink);
  min-width: 42px; text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Sort select */
.select {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12px;
}
.select select {
  border: 0; outline: 0; background: transparent;
  font-size: 12px; font-weight: 600; color: var(--ink);
  font-family: inherit;
}

/* Reset */
.reset-btn {
  background: transparent; border: 0;
  color: var(--red); font-size: 12px; font-weight: 600;
  padding: 4px 8px; border-radius: 6px;
}
.reset-btn:hover { background: rgba(228,37,43,0.08); }

/* ——— Listings ——— */
.listings {
  padding: 0 16px 16px;
  background: var(--cream);
}
.listings__empty {
  padding: 18px 16px; text-align: left;
  color: var(--ink-faded);
  background: #fff;
  border: 1px dashed var(--line-soft);
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
}
.listings__empty strong {
  display: block; font-family: var(--display);
  font-size: 16px; color: var(--ink); margin-bottom: 4px;
  text-transform: uppercase;
}

/* Card */
.card {
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  position: relative;
}
.card:hover, .card.is-hovered {
  border-color: var(--ink);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.card.is-selected {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(228,37,43,0.18), var(--shadow-sm);
}
.card__head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; margin-bottom: 8px;
}
.card__title h3 {
  font-family: var(--sans);
  font-size: 15px; font-weight: 700;
  margin: 0 0 2px; letter-spacing: -0.01em;
}
.card__loc {
  font-size: 12px; color: var(--ink-faded);
  margin: 0;
}
.card__rate {
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.card__rate-num {
  display: block;
  font-family: var(--display);
  font-size: 16px;
  color: var(--ink);
  line-height: 1;
}
.card__rate-unit {
  display: block;
  font-size: 10px;
  color: var(--ink-faded);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 3px;
}
.card__meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink-faded);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.stars { color: var(--gold); font-weight: 700; }
.stars--lg { font-size: 15px; }
.dot { color: var(--line); }
.card__coins {
  display: flex; gap: 4px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.coin {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px;
  background: var(--paper-2);
  border-radius: 4px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}
.coin--lg {
  font-size: 13px; padding: 5px 10px;
  background: var(--ink); color: var(--paper);
  border-radius: 6px;
}
.card__badges { display: flex; gap: 4px; flex-wrap: wrap; }
.tag {
  font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 3px 7px; border-radius: 4px;
}
.tag--red       { background: var(--red); color: #fff; }
.tag--verified  { background: #E8F5EC; color: var(--ok); border: 1px solid #C7E6D0; }
.tag--muted     { background: var(--paper-2); color: var(--ink-faded); }

/* ——— Map ——— */
#map {
  grid-area: map;
  position: relative;
  background: var(--paper);
  /* Establish a stacking context so Leaflet's internal pane z-indexes
     (200–700) are contained within #map and can't escape to overlay our
     chrome (topbar, mobile-bar, sheets, etc.). */
  z-index: 0;
  isolation: isolate;
}
/* Leaflet overrides */
#map.leaflet-container { background: #EFE7D2; font: inherit; outline: none; }
.leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--shadow-sm) !important;
  border-radius: 10px !important;
  overflow: hidden;
}
.leaflet-control-zoom a {
  background: #fff !important; color: var(--ink) !important;
  border: 1px solid var(--line) !important;
  width: 32px !important; height: 32px !important;
  line-height: 30px !important;
  font-size: 18px !important; font-weight: 500 !important;
}
.leaflet-control-zoom a:first-child { border-bottom: none !important; border-radius: 10px 10px 0 0 !important; }
.leaflet-control-zoom a:last-child  { border-radius: 0 0 10px 10px !important; }
.leaflet-control-zoom a:hover { background: var(--paper) !important; }
.leaflet-control-attribution {
  font-size: 10px !important;
  background: rgba(245,239,227,0.85) !important;
  color: var(--ink-faded) !important;
  padding: 2px 6px !important;
  border-radius: 6px 0 0 0;
}
.leaflet-control-attribution a { color: var(--ink-soft) !important; }
/* divIcon wrapper shouldn't hijack events outside the pin */
.pin-wrap { background: none; border: none; }
.leaflet-marker-icon.pin-wrap { pointer-events: none; }
.leaflet-marker-icon.pin-wrap .pin { pointer-events: auto; cursor: pointer; }

/* Map floating buttons (top-right) */
.map-actions {
  position: absolute;
  top: 14px; right: 14px;
  display: flex; gap: 8px;
  z-index: 10;
}
.map-btn {
  background: #fff; color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px; font-weight: 600;
  box-shadow: var(--shadow-sm);
  display: inline-flex; align-items: center; gap: 6px;
}
.map-btn:hover { background: var(--paper); }

/* ——— Pins ——— */
.pin {
  --sz: 30px;
  position: relative;
  width: var(--sz); height: calc(var(--sz) * 1.3);
  background: none; border: 0; padding: 0;
  cursor: pointer;
  transform-origin: bottom center;
  transition: transform .2s cubic-bezier(.2,.8,.2,1.2), opacity .2s;
  will-change: transform;
}
.pin__body {
  position: absolute; inset: 0 0 4px 0;
  background: var(--red);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  transform-origin: 50% 50%;
  box-shadow:
    inset 0 -3px 0 rgba(0,0,0,0.18),
    inset 0 2px 0 rgba(255,255,255,0.25),
    0 4px 8px rgba(40,25,10,0.28);
  border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center;
}
.pin__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #fff;
  transform: rotate(45deg);
}
.pin__shadow {
  position: absolute;
  bottom: -2px; left: 50%;
  width: 60%; height: 6px;
  background: rgba(0,0,0,0.2);
  border-radius: 50%;
  transform: translateX(-50%);
  filter: blur(2px);
}
.pin__label {
  position: absolute;
  bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  padding: 4px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .15s;
  box-shadow: var(--shadow-sm);
}
.pin__label::after {
  content: ''; position: absolute;
  bottom: -4px; left: 50%; transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--ink);
}
.pin:hover, .pin.is-hovered {
  transform: scale(1.15) translateY(-3px);
  z-index: 10;
}
.pin:hover .pin__label, .pin.is-hovered .pin__label { opacity: 1; }
.pin.is-selected {
  transform: scale(1.3) translateY(-4px);
  z-index: 20;
}
.pin.is-selected .pin__body { background: var(--red-deep); }
.pin.is-selected .pin__label { opacity: 1; }
.pin.is-dim { opacity: 0.5; }
.pin--featured .pin__body {
  background: linear-gradient(180deg, #FF4A4F 0%, var(--red) 45%, var(--red-deep) 100%);
  box-shadow:
    inset 0 -3px 0 rgba(0,0,0,0.22),
    inset 0 2px 0 rgba(255,255,255,0.35),
    0 0 0 3px rgba(228,37,43,0.14),
    0 6px 14px rgba(228,37,43,0.3);
}
.pin--verified .pin__dot { background: #fff; }
.pin--ex:not(.pin--verified) .pin__body {
  background: #9A8C6F;
  border-color: var(--paper);
}

/* ——— Merchant pins (olive/gold) ——— */
.pin--me .pin__body {
  background: linear-gradient(180deg, #C9A64A 0%, #9E7E2E 55%, #6F5416 100%);
  border-color: #FBF6EC;
  box-shadow:
    inset 0 -3px 0 rgba(0,0,0,0.22),
    inset 0 2px 0 rgba(255,255,255,0.28),
    0 4px 8px rgba(60,40,10,0.28);
}
.pin--me .pin__glyph {
  transform: rotate(45deg);
  font-size: 13px; line-height: 1;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,0.25));
}
.pin--me.pin--featured .pin__body {
  background: linear-gradient(180deg, #E8C568 0%, #B58A1F 50%, #7A5A10 100%);
  box-shadow:
    inset 0 -3px 0 rgba(0,0,0,0.25),
    inset 0 2px 0 rgba(255,255,255,0.35),
    0 0 0 3px rgba(181,138,31,0.18),
    0 6px 14px rgba(120,85,15,0.35);
}
.pin--me:not(.pin--verified) .pin__body { opacity: 0.85; }
.pin--me.is-selected .pin__body {
  background: linear-gradient(180deg, #B58A1F 0%, #7A5A10 100%);
}

/* ——— Mode pill (top of panel) ——— */
.mode-pill {
  display: flex; gap: 0;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 14px;
}
.mode-pill__opt {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent;
  color: var(--ink-faded);
  border: 0;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.mode-pill__opt:hover { color: var(--ink); }
.mode-pill__opt.is-on {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.mode-pill__dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
}
.mode-pill__dot--red   { background: var(--red); }
.mode-pill__dot--olive { background: linear-gradient(180deg, #C9A64A, #7A5A10); }

/* ——— Scoped filter groups ——— */
.filters__label--scoped {
  display: inline-flex; align-items: center; gap: 6px;
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--ink);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.filters__sublabel {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-faded);
  margin: 10px 0 6px;
  text-transform: uppercase;
}
.filters__group--ex { display: block; }
.filters__group--me { display: block; }
body[data-mode="merchants"]  .filters__group--ex { display: none; }
body[data-mode="exchangers"] .filters__group--me { display: none; }

/* ——— Merchant card kind row ——— */
.card__kind {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-faded);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.card--me { border-left: 3px solid transparent; }
.card--me:hover, .card--me.is-hovered, .card--me.is-selected {
  border-left-color: #B58A1F;
}
.card--ex { border-left: 3px solid transparent; }
.card--ex:hover, .card--ex.is-hovered, .card--ex.is-selected {
  border-left-color: var(--red);
}
.card__verified-ago {
  font-size: 11px;
  color: var(--ink-faded);
  margin-top: 4px;
}

.listgroup {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faded);
  padding: 14px 16px 6px;
  border-top: 1px solid var(--line-soft);
}
.listgroup:first-child { border-top: none; padding-top: 8px; }

/* ——— Tag variants ——— */
.tag--olive {
  background: linear-gradient(180deg, #C9A64A, #7A5A10);
  color: #FBF6EC;
  border-color: #7A5A10;
}

/* ——— Olive WhatsApp button for merchants ——— */
.btn--olive {
  background: linear-gradient(180deg, #B58A1F, #7A5A10);
  border-color: #7A5A10;
  color: #FBF6EC;
}
.btn--olive:hover { filter: brightness(1.06); }

/* ——— Merchant verify strip ——— */
.detail__verify {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  margin: 14px 18px 0;
  background: #F3EBD2;
  border: 1px solid #D9CDB2;
  border-radius: var(--radius-sm);
}
.detail__verify-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(180deg, #B58A1F, #7A5A10);
  color: #FBF6EC;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.detail__verify-title {
  font-size: 13px; font-weight: 700; color: var(--ink);
}
.detail__verify-sub {
  font-size: 11px; color: var(--ink-faded);
}
.detail__kind {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-faded);
  text-transform: uppercase;
  margin-top: 2px;
  margin-bottom: 10px;
}

/* ——— Detail drawer (desktop: overlays panel; mobile: full) ——— */
.detail {
  position: absolute;
  /* Start *below* the topbar so the topbar doesn't visually overlay the
     panel's header (which previously left only ~1px gap above the
     "EXCHANGER" / "MERCHANT" kind label). */
  top: var(--topbar-h);
  left: 0;
  width: 400px;
  height: calc(100% - var(--topbar-h));
  background: var(--cream);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  z-index: 30;
  overflow-y: auto;
  animation: slide-in .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes slide-in {
  from { transform: translateX(-12px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.detail__head {
  /* Top padding is now just for visual breathing room (no longer
     compensating for an overlaid topbar). The close button sits at
     top: 12px and is fully visible. */
  padding: 24px 18px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: #fff;
  position: relative;
}
.detail__close {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px;
  background: var(--paper-2); color: var(--ink);
  border: 0; border-radius: 50%;
  font-size: 14px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.detail__close:hover { background: var(--paper-3); }
.detail__titleline {
  display: flex; gap: 6px; margin-bottom: 10px;
}
.detail__name {
  font-family: var(--display);
  font-size: 26px; font-weight: 900;
  margin: 0 0 4px;
  line-height: 1.05; letter-spacing: -0.01em;
  text-transform: uppercase;
}
.detail__loc {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--ink-faded);
  margin: 0 0 10px;
  font-weight: 500;
  letter-spacing: 0;
}
.detail__loc svg { width: 13px; height: 13px; opacity: 0.7; flex-shrink: 0; }
.detail__metarow {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--ink-faded);
}
.detail__rate {
  display: grid; grid-template-columns: 1fr 1px 1fr;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--paper-2);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  margin: 14px 0;
}
.detail__stat { text-align: center; }
.detail__rate-sep { width: 1px; height: 40px; background: var(--line-soft); }
.detail__rate-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-faded); margin-bottom: 6px;
}
.detail__rate-num {
  font-family: var(--display);
  font-size: 22px; color: var(--ink);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.detail__rate-num--sm { font-size: 16px; }
.detail__rate-unit {
  font-size: 10px; color: var(--ink-faded);
  margin-top: 4px;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.detail__section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.detail__section h4 {
  margin: 0 0 10px;
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-faded);
}
.coins-row, .chips-row { display: flex; flex-wrap: wrap; gap: 6px; }
.detail__actions {
  padding: 14px 18px;
  display: flex; flex-direction: column; gap: 8px;
}
.btn {
  display: flex; align-items: center; justify-content: center;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px; font-weight: 600;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.btn--primary { background: var(--red); color: #fff; }
.btn--primary:hover { background: var(--red-deep); }
.btn--ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { background: var(--paper-2); }

.detail__foot {
  padding: 12px 18px 20px;
  display: flex;
  gap: 8px;
  justify-content: center;
  border-top: 1px solid var(--line-soft);
  margin-top: 4px;
}
.detail__foot-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  font-family: inherit;
}
.detail__foot-btn:hover {
  background: var(--paper-2);
  border-color: var(--ink-faded);
  color: var(--ink);
}
.detail__foot-btn svg { opacity: 0.7; }
.detail__foot-btn:hover svg { opacity: 1; }

/* Toast for share/report feedback */
.toast {
  position: fixed;
  left: 50%; bottom: 32px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 28px rgba(0,0,0,0.25);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.is-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ——— Loading ——— */
.loading {
  position: absolute; inset: 0;
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  transition: opacity .3s;
}
.loading.is-hidden { opacity: 0; pointer-events: none; }
.loading__inner { text-align: center; }
.loading__logo {
  height: 28px;
  margin-bottom: 14px;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.65; transform: scale(0.96); }
}
.loading__text {
  font-size: 12px; color: var(--ink-faded);
  text-transform: uppercase; letter-spacing: 0.2em;
}

/* =========================================================
   MOBILE
   ========================================================= */
@media (max-width: 900px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "topbar"
      "map";
  }

  /* ——— Top bar ——— */
  .topbar {
    padding: 12px 16px;
    gap: 12px;
    min-height: 60px;
    /* Add a slight drop shadow so it lifts off the map below */
    box-shadow: 0 1px 0 var(--line-soft), 0 2px 12px rgba(40,25,10,0.04);
  }
  .topbar__logo {
    height: 30px;
  }
  .topbar__filter-btn {
    display: inline-flex; align-items: center; gap: 8px;
    margin-left: auto; order: 4;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    min-height: 44px;
    border-radius: 999px;
  }
  .topbar__tag { display: none; }
  .topbar__about { display: none; }

  /* CTA becomes a red circle — icon only */
  .topbar__cta {
    order: 3;
    padding: 0;
    width: 40px; height: 40px;
    margin-left: 4px;
    border-radius: 999px;
    justify-content: center;
    gap: 0;
  }
  .topbar__cta-label { display: none; }
  .topbar__cta-icon { width: 18px; height: 18px; margin: 0; }
  /* Mobile search icon — becomes a button that expands the search */
  .topbar__search-btn {
    display: inline-flex; order: 2;
    width: 40px; height: 40px;
    align-items: center; justify-content: center;
    background: var(--paper-2, var(--paper));
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--ink);
    margin-left: auto;
  }
  .topbar__search-btn svg { width: 19px; height: 19px; }

  /* ——— Mode pill: float over the map, just below the top bar ——— */
  .panel__head .mode-pill {
    position: fixed;
    top: 76px; left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    box-shadow: 0 4px 16px rgba(40,25,10,0.12);
    background: #fff;
    /* Give the three tabs enough room so labels don't wrap */
    width: min(92vw, 360px);
    padding: 4px;
  }
  .panel__head .mode-pill__opt {
    padding: 8px 12px;
    font-size: 13px;
    white-space: nowrap;
  }

  /* ——— The desktop panel is completely retired on mobile ———
     Map owns the full viewport below the topbar. Filters & detail
     are independent bottom sheets layered over the map. */
  .panel {
    grid-area: map;
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: auto;
    background: transparent;
    border: 0;
    box-shadow: none;
    pointer-events: none;   /* only the floating pieces inside are interactive */
    z-index: 10;
    transform: none;
    transition: none;
  }
  /* Hide all the desktop chrome inside the panel on mobile. */
  .panel__head .panel__title,
  .panel__head .search,
  .panel .filters__row:not(:first-child),  /* handled below */
  .panel .empty,
  .panel .list-section,
  .panel .list,
  .sheet-handle {
    /* no-op default; specifics below */
  }
  .panel__title { display: none; }
  .panel__head .search { display: none; }
  .sheet-handle { display: none; }

  /* Mode pill container inside panel still renders it (fixed-pos above). */
  .panel__head {
    padding: 0; background: transparent; border: 0;
    pointer-events: none;
  }
  .panel__head > .mode-pill { pointer-events: auto; }

  /* ——— Floating bottom action bar: result count + filters ——— */
  .mobile-bar {
    position: fixed;
    left: 50%; bottom: 18px;
    transform: translateX(-50%);
    z-index: 28;
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px 8px 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: 0 8px 28px rgba(40,25,10,0.18);
    pointer-events: auto;
    max-width: calc(100vw - 32px);
    transition: opacity .2s ease, transform .2s ease;
  }
  .mobile-bar__count {
    font-family: var(--serif);
    font-size: 14px;
    white-space: nowrap;
    color: var(--ink);
  }
  .mobile-bar__count b {
    font-weight: 500;
    color: var(--ink);
    font-size: 15px;
  }
  .mobile-bar__btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px;
    background: var(--ink); color: var(--paper);
    border: 0; border-radius: 999px;
    font-size: 13px; font-weight: 500;
    letter-spacing: 0.02em;
  }

  /* ——— Filters drawer: full viewport modal ——— */
  .filters {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    z-index: 60;
    padding: 0;
    background: var(--cream);
    border: 0;
    max-height: none;
    transform: translateY(100%);
    transition: transform .32s cubic-bezier(.2,.8,.2,1), visibility 0s linear .32s;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    pointer-events: none;    /* ← off until opened */
    visibility: hidden;      /* ← off until opened, prevents touch capture */
  }
  body.filters-open .filters {
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
    transition: transform .32s cubic-bezier(.2,.8,.2,1), visibility 0s linear 0s;
  }

  /* Filters: sticky header with title + close */
  .filters__header {
    display: flex; align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--cream);
    position: sticky; top: 0; z-index: 2;
  }
  .filters__header h2 {
    margin: 0;
    font-family: var(--serif);
    font-weight: 500;
    font-size: 22px;
    flex: 1;
  }
  .filters__close {
    display: flex !important;
    align-items: center; justify-content: center;
    width: 36px; height: 36px;
    background: var(--paper-2, var(--paper));
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 50%;
    font-size: 16px;
  }
  .filters__body {
    flex: 1;
    padding: 18px 16px 24px;
    overflow-y: auto;
  }
  .filters__footer {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line);
    background: var(--cream);
    position: sticky; bottom: 0;
    display: flex; gap: 10px;
  }
  .filters__apply {
    flex: 1;
    background: var(--ink); color: var(--paper);
    border: 0; border-radius: 12px;
    padding: 14px;
    font-size: 15px; font-weight: 500;
  }
  .filters__reset {
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 20px;
    color: var(--ink);
  }

  /* Sheet footer — About + credit, shown only at the very bottom of the
     filters sheet on mobile. Scrolls with filter content. */
  .sheet-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 22px 16px 6px;
    margin-top: 12px;
    border-top: 1px solid var(--line-soft);
    font-size: 12px;
    color: var(--ink-faded);
  }
  .sheet-footer__link {
    color: var(--ink-soft);
    text-decoration: none;
    font-weight: 600;
    padding: 4px 0;
  }
  .sheet-footer__link:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
  }
  .sheet-footer__sep { opacity: 0.5; }
  .sheet-footer__credit { font-variant: small-caps; letter-spacing: 0.04em; }

  /* ——— Detail sheet: two snap points (peek ~52%, full ~92%) ———
     Google-Maps-style: peek starts tall enough that title + rating +
     action buttons are fully visible without any expand gesture. */
  .detail {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    top: auto; width: auto;
    height: 92vh;
    max-height: 92vh;
    border-right: 0;
    border-top: 0;
    border-radius: 18px 18px 0 0;
    background: #fff;
    z-index: 60;
    box-shadow: 0 -14px 40px rgba(40,25,10,0.22),
                0 -1px 0 rgba(40,25,10,0.06);
    transform: translateY(48vh);   /* peek — 52vh visible */
    transition: transform .32s cubic-bezier(.2,.8,.2,1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    display: block;
    padding-top: 14px; /* room for drag handle */
  }
  .detail[data-sheet="full"] { transform: translateY(0); visibility: visible; pointer-events: auto; }
  .detail[data-sheet="peek"] { transform: translateY(48vh); visibility: visible; pointer-events: auto; }
  .detail[data-sheet="hidden"] { transform: translateY(100%); visibility: visible; pointer-events: none; }
  /* Default before JS runs — keep offscreen and non-interactive */
  .detail:not([data-sheet]) {
    transform: translateY(100%);
    visibility: hidden;
    pointer-events: none;
  }
  /* Do NOT use display:none — it kills the initial transition state and
     causes a pop-in flash. Instead [hidden] maps to a no-interaction,
     fully-offscreen sheet that can still transition. */
  .detail[hidden] {
    display: flex !important;
    transform: translateY(100%);
    visibility: hidden;
    pointer-events: none;
  }
  /* Tighten mobile head padding a touch so title+rating fit in the peek band */
  .detail .detail__head { padding: 14px 18px 12px; }
  .detail .detail__close {
    top: 14px; right: 14px;
    background: rgba(245,239,225,0.9);
  }

  /* drag handle */
  .detail::before {
    content: '';
    position: absolute; top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 40px; height: 4px;
    background: var(--line);
    border-radius: 4px;
    z-index: 2;
  }
  /* When detail is open, dim the mobile bar so it's clearly secondary */
  body.detail-open .mobile-bar { opacity: 0; pointer-events: none; transform: translate(-50%, 20px); }
  /* When filters drawer is open, hide the mobile bar entirely — it would
     otherwise collide with the drawer's own sticky footer. */
  body.filters-open .mobile-bar { opacity: 0; pointer-events: none; transform: translate(-50%, 20px); }
  /* When the empty state is showing, also hide the mobile bar — it would
     otherwise sit directly over the "Nothing matches" card. */
  body.empty-state .mobile-bar { opacity: 0; pointer-events: none; transform: translate(-50%, 20px); }
  .filters__header, .filters__footer { display: flex !important; }

  /* Mobile search expanded row — slides down below topbar */
  .m-search {
    display: flex !important;
    align-items: center; gap: 10px;
    padding: 10px 14px;
    background: var(--cream);
    border-bottom: 1px solid var(--line);
    position: absolute;
    top: 76px; left: 0; right: 0;
    z-index: 35;
    color: var(--ink-faded);
    box-shadow: 0 6px 18px rgba(40,25,10,0.08);
  }
  .m-search[hidden] { display: none !important; }
  .m-search input {
    flex: 1 1 0; min-width: 0;
    border: 0; background: transparent;
    font: inherit; color: var(--ink); outline: none;
    font-size: 15px;
    padding-right: 4px;
  }
  /* Hide the native iOS clear button on search inputs — we use our own ✕ */
  .m-search input::-webkit-search-cancel-button,
  .m-search input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
  .m-search input::placeholder { color: var(--ink-faded); }
  .m-search button {
    flex: 0 0 auto;
    background: transparent; border: 0;
    width: 28px; height: 28px;
    color: var(--ink-faded);
    font-size: 14px;
  }
}

@media (min-width: 901px) {
  .sheet-handle { display: none; }
  .filters__close { display: none; }
  .topbar__search-btn { display: none; }
  .mobile-bar { display: none; }
  .m-search { display: none !important; }
  .filters__header, .filters__footer { display: none; }
}

/* ——— Tweaks panel (only when host activates) ——— */
.tweaks {
  position: fixed;
  right: 14px; bottom: 14px;
  width: 260px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  font-size: 13px;
  display: none;
}
.tweaks.is-on { display: block; }
.tweaks h5 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: 13px; text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tweaks label {
  display: flex; justify-content: space-between;
  align-items: center; margin: 8px 0;
}
.tweaks select, .tweaks input[type="color"] {
  font-size: 12px; padding: 4px 6px;
  border: 1px solid var(--line); border-radius: 6px;
}


/* ——— Pin hover tooltip (Leaflet) ——— */
.leaflet-tooltip.pin-tip {
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 6px 24px rgba(20,15,10,0.14), 0 1px 2px rgba(20,15,10,0.08);
  font-family: var(--sans, system-ui);
  color: var(--ink);
  white-space: normal;
  min-width: 220px;
  max-width: 280px;
}
.leaflet-tooltip.pin-tip::before { display: none; }
.pin-tip__kind {
  display: inline-block;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
}
.pin-tip__kind--red   { background: rgba(228,37,43,0.10); color: var(--red); }
.pin-tip__kind--olive { background: rgba(122,90,16,0.14); color: #7A5A10; }
.pin-tip__name {
  font-family: var(--display);
  font-size: 16px; font-weight: 700; line-height: 1.2;
  color: var(--ink);
  margin-bottom: 4px;
}
.pin-tip__meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink-faded);
  flex-wrap: wrap;
}
.pin-tip__stars { color: #B8860B; font-weight: 600; }
.pin-tip__reviews { color: var(--ink-faded); }
.pin-tip__dot { color: var(--ink-faded); opacity: .5; }
.pin-tip__badges { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.pin-tip__badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 6px; border-radius: 4px;
  white-space: nowrap;
}
.pin-tip__badge--red      { background: rgba(228,37,43,0.10); color: var(--red); }
.pin-tip__badge--verified { background: rgba(30,122,76,0.10); color: #1E7A4C; }
.pin-tip__cta {
  margin-top: 8px; padding-top: 6px;
  border-top: 1px dashed var(--line-soft);
  font-size: 11px; color: var(--ink-faded);
  font-style: italic;
}
