:root {
  --paper: #f6f1e7;
  --card: #fffdf8;
  --ink: #1d1b18;
  --muted: #6f685d;
  --line: #e2d9c8;
  --accent: #b4461f;       /* fall rust */
  --accent-ink: #ffffff;
  --pin: #1d1b18;
  --shadow: 0 8px 28px rgba(40, 30, 10, .18);
  --sheet-peek: 132px;
  --top-h: 132px;
  --radius: 18px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --marker: "Permanent Marker", "Marker Felt", cursive;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* ---------- Map ---------- */
#map { position: fixed; inset: 0; background: #fff; }
.leaflet-container { font-family: var(--font); background: #fff; }
.leaflet-control-attribution { display: none; }

.pin {
  display: grid; place-items: center;
  width: 100%; height: 100%;
  border-radius: 50%;
  background: var(--pin);
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
  font: 700 11px/1 var(--font);
  transition: transform .15s, background .15s, opacity .15s;
}
.pin b { display: none; letter-spacing: -.02em; }
.z-detail .pin b { display: block; }
.pin.area { background: #fff; color: var(--ink); border-color: var(--ink); }
.pin.dim { opacity: .18; }
.pin.hit { background: var(--accent); }
.pin.selected { background: var(--accent); transform: scale(1.35); box-shadow: 0 0 0 5px rgba(180, 70, 31, .28), 0 2px 6px rgba(0,0,0,.4); }
.leaflet-marker-icon.on-top { z-index: 10000 !important; }

.section-label {
  font: 20px/1 var(--marker);
  color: var(--ink);
  white-space: nowrap;
  text-shadow: 0 0 3px #fff, 0 0 6px #fff, 0 0 10px #fff;
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.z-far .section-label { font-size: 14px; }
.amenity {
  font: 600 10px/1 var(--font);
  text-transform: uppercase; letter-spacing: .06em;
  background: #fff; border: 1px solid var(--ink); border-radius: 999px;
  padding: 3px 6px; white-space: nowrap;
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.z-far .amenity { display: none; }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 1000;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 8px;
  background: linear-gradient(var(--paper) 72%, rgba(246,241,231,0));
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brandline { display: flex; align-items: baseline; gap: 8px; padding: 0 4px 8px; }
.brand { font: 22px/1 var(--marker); letter-spacing: .02em; }
.sub { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.search { position: relative; display: flex; align-items: center; }
.search input {
  width: 100%; height: 46px;
  padding: 0 44px 0 42px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--ink);
  font: 16px var(--font); /* 16px stops iOS zoom-on-focus */
  box-shadow: var(--shadow);
  -webkit-appearance: none; appearance: none;
}
.search input::-webkit-search-cancel-button { display: none; }
.search input:focus { outline: 2px solid var(--ink); outline-offset: 0; }
.search-icon { position: absolute; left: 13px; width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.icon-btn { position: absolute; right: 6px; width: 36px; height: 36px; border: 0; background: none; display: grid; place-items: center; border-radius: 10px; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }

.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px 4px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 34px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); font-size: 13px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(40,30,10,.08);
}
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Zoom controls ---------- */
.zoom-ctl {
  position: fixed; right: 12px; z-index: 900;
  bottom: calc(var(--sheet-peek) + 16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 6px;
  transition: bottom .25s;
}
.zoom-ctl button {
  width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  font-size: 22px; font-weight: 500; line-height: 1; box-shadow: var(--shadow);
  display: grid; place-items: center;
}
.zoom-ctl svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 2; }

/* ---------- Bottom sheet ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100;
  height: 86dvh; max-height: calc(100dvh - 70px);
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -8px 30px rgba(40,30,10,.18);
  display: flex; flex-direction: column;
  transform: translateY(calc(100% - var(--sheet-peek) - env(safe-area-inset-bottom)));
  transition: transform .28s cubic-bezier(.2,.8,.2,1);
  touch-action: pan-y;
}
.sheet[data-state="half"] { transform: translateY(calc(100% - 42dvh)); }
.sheet[data-state="open"] { transform: translateY(0); }
.sheet.dragging { transition: none; }

.handle { flex: none; width: 100%; height: 26px; border: 0; background: none; display: grid; place-items: center; touch-action: none; }
.handle span { width: 42px; height: 5px; border-radius: 3px; background: var(--line); }

.view { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 2px 2px 10px; position: sticky; top: 0; background: var(--card); z-index: 1; }
.list-head h2 { font-size: 17px; margin: 0; }
.list-head .muted { font-size: 12px; }

.results { list-style: none; margin: 0; padding: 0; }
.results li + li { border-top: 1px solid var(--line); }
.row {
  display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 12px;
  width: 100%; padding: 10px 2px; border: 0; background: none; text-align: left;
}
.row:active { background: var(--paper); }
.thumb {
  width: 48px; height: 48px; border-radius: 12px; overflow: hidden;
  background: var(--paper); border: 1px solid var(--line);
  display: grid; place-items: center;
  font: 20px/1 var(--marker); color: var(--muted);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.row-name { font-weight: 600; line-height: 1.25; }
.row-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.booth-tag {
  font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 8px;
  background: var(--paper); border: 1px solid var(--line); white-space: nowrap;
}
.booth-tag.none { color: var(--muted); font-weight: 500; }
.empty { padding: 28px 8px; text-align: center; color: var(--muted); }

/* ---------- Detail ---------- */
.back { border: 0; background: none; display: inline-flex; align-items: center; gap: 4px; padding: 4px 0 10px; font-weight: 600; color: var(--muted); }
.back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.hero {
  width: 100%; aspect-ratio: 16 / 10; border-radius: 14px; overflow: hidden;
  background: var(--paper); border: 1px solid var(--line);
  display: grid; place-items: center; font: 56px/1 var(--marker); color: var(--muted);
}
.hero img { width: 100%; height: 100%; object-fit: cover; }
.thumb.big { width: 64px; height: 64px; font-size: 26px; border-radius: 16px; }
.detail h2 { font-size: 24px; line-height: 1.15; margin: 14px 0 6px; }
.where { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 4px 0 10px; }
.where .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); flex: none; }
.cats { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.cat { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); }
.cat.act { background: #fbe9df; border-color: #f0c6ae; color: var(--accent); }
.blurb { color: var(--muted); margin: 0 0 12px; }
.actions { display: flex; gap: 10px; margin: 14px 0 18px; }
.btn {
  flex: 1; height: 46px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; text-decoration: none; border: 1px solid var(--ink);
}
.btn.primary { background: var(--ink); color: #fff; }
.btn.ghost { background: var(--card); color: var(--ink); }
.also h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 8px 0 4px; }

/* ---------- Desktop: sheet becomes a sidebar ---------- */
@media (min-width: 900px) {
  :root { --side: 400px; }
  .topbar { right: auto; width: var(--side); background: none; padding: 16px; }
  .sheet {
    top: 170px; bottom: 16px; left: 16px; right: auto; width: calc(var(--side) - 32px);
    height: auto; max-height: none; border-radius: var(--radius);
    transform: none !important; box-shadow: var(--shadow);
  }
  .handle { display: none; }
  .view { padding-top: 14px; }
  .zoom-ctl { bottom: 24px !important; right: 24px; }
  #map { left: 0; }
}
