:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --ink: #1c1917;
  --muted: #6b6460;
  --line: #e9e4de;
  --hover: #f4f0eb;
  --bar: #b42344;
  --cafe: #d97706;
  --restaurant: #0f766e;
  --maybe: #8b8f98;
  --open: #15803d;
  --closed: #9f1239;
  --you: #2563eb;
  --radius: 12px;
  --panel-w: 390px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); overflow: hidden; }
button { font: inherit; color: inherit; }
a { color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--panel-w) minmax(0, 1fr);
}

/* ---------- Panel ---------- */
.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
  border-right: 1px solid var(--line);
  z-index: 2;
}

.sheet-handle { display: none; }

.head { padding: 22px 22px 6px; }
.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--bar);
}
h1 { margin: 0; font-size: 28px; line-height: 1.1; letter-spacing: -.02em; font-weight: 750; }
.sub { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }

.controls { padding: 14px 22px 12px; border-bottom: 1px solid var(--line); }

.search {
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.search:focus-within { border-color: #c9c0b6; box-shadow: 0 0 0 3px rgba(180, 35, 68, .10); }
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 15px; color: var(--ink);
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px; font-weight: 550;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.chip:hover { background: var(--hover); }
.chip[aria-pressed="true"] { color: var(--ink); border-color: #cfc6bc; background: #fff; box-shadow: 0 1px 0 rgba(0,0,0,.03); }
.chip[aria-pressed="false"] .dot { opacity: .35; }
.chip .n { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.chip:focus-visible, .locate-btn:focus-visible, .item:focus-visible, .sheet-handle:focus-visible {
  outline: 2px solid var(--you); outline-offset: 2px;
}

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.bar { background: var(--bar); }
.dot.cafe { background: var(--cafe); }
.dot.restaurant { background: var(--restaurant); }
.dot.maybe { background: #fff; border: 2px solid var(--maybe); }
.dot.open { background: var(--open); }

.locate-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.locate-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 13px 0 11px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface);
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
}
.locate-btn:hover { background: var(--hover); }
.locate-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.locate-btn[aria-pressed="true"] { background: var(--you); border-color: var(--you); color: #fff; }
.locate-btn.busy svg { animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sort { font-size: 12.5px; color: var(--muted); text-align: right; }
.locate-msg { margin: 10px 0 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
.locate-msg.error { color: var(--closed); }

.body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

.list { list-style: none; margin: 0; padding: 6px 10px; }
.item {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 4px 12px;
  width: 100%;
  padding: 11px 12px;
  border: 0; border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.item:hover { background: var(--hover); }
.item.active { background: #fff; box-shadow: inset 0 0 0 1px var(--line), 0 1px 3px rgba(0,0,0,.05); }
.item .dot { grid-row: 1 / span 2; align-self: start; margin-top: 5px; }
.item .name { font-weight: 650; font-size: 15px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { grid-column: 2; font-size: 13px; color: var(--muted); }
.item .side { grid-column: 3; grid-row: 1 / span 2; text-align: right; font-size: 12.5px; line-height: 1.35; white-space: nowrap; }
.item .dist { display: block; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.status { font-weight: 600; }
.status.open { color: var(--open); }
.status.closed { color: var(--closed); }
.status.unknown { color: var(--muted); font-weight: 500; }

/* Cross-off checkboxes */
.list li.row { display: flex; align-items: center; }
.list li.row .item { flex: 1; min-width: 0; }
.check {
  position: relative; flex: none;
  display: grid; place-items: center;
  width: 36px; height: 46px; margin-right: -6px;
  cursor: pointer;
}
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.check .box {
  display: grid; place-items: center;
  width: 20px; height: 20px;
  border: 2px solid #cfc6bc; border-radius: 6px;
  background: #fff;
  transition: background .12s, border-color .12s;
}
.check:hover .box { border-color: #9d9388; }
.check input:checked + .box { background: var(--ink); border-color: var(--ink); }
.check input:checked + .box::after {
  content: ""; width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg);
}
.check input:focus-visible + .box { outline: 2px solid var(--you); outline-offset: 2px; }
.row.crossed .item { cursor: default; opacity: .5; }
.row.crossed .item:hover { background: transparent; }
.row.crossed .name { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.section-head {
  margin-top: 10px; padding: 14px 12px 6px;
  border-top: 1px solid var(--line);
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
}

.empty { margin: 24px 22px; color: var(--muted); font-size: 14px; }

.foot { padding: 16px 22px 28px; border-top: 1px solid var(--line); font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.foot p { margin: 0 0 8px; }
.foot strong { color: var(--ink); font-weight: 600; }
.foot a { color: var(--ink); }

/* ---------- Map ---------- */
.map { min-width: 0; min-height: 0; background: #eceae6; z-index: 1; }

.leaflet-container { font: inherit; }
.leaflet-tile-pane { filter: saturate(.5) brightness(1.04) contrast(.95); }
.leaflet-popup-content-wrapper { border-radius: var(--radius); box-shadow: 0 8px 28px rgba(0,0,0,.16); }
.leaflet-popup-content { margin: 14px 16px 12px; min-width: 220px; }
.pop h3 { margin: 0 34px 2px 0; font-size: 17px; line-height: 1.25; letter-spacing: -.01em; }
.pop .kind { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.pop .row { margin: 0 0 4px; font-size: 13.5px; line-height: 1.4; }
.pop .row.muted { color: var(--muted); }
.pop .hours { margin: 6px 0 8px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.pop .note { margin: 8px 0; padding: 7px 9px; border-radius: 8px; background: #f5f3f0; font-size: 12.5px; line-height: 1.4; color: var(--muted); }
.pop .links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pop .links a {
  display: inline-flex; align-items: center; height: 28px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 7px;
  font-size: 12.5px; font-weight: 600; text-decoration: none; color: var(--ink);
}
.pop .links a:hover { background: var(--hover); }
.pop .links a.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.pop .cross-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; height: 32px; margin-top: 8px;
  border: 1px dashed #cfc6bc; border-radius: 7px;
  background: #fff;
  font-size: 12.5px; font-weight: 600; color: var(--ink);
  cursor: pointer;
}
.pop .cross-btn:hover { background: var(--hover); border-style: solid; }
.pop .cross-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pop .osm { display: block; margin-top: 9px; font-size: 11.5px; color: var(--muted); }

.you-pulse { animation: pulse 2s ease-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes pulse { 0% { opacity: .55; } 70% { opacity: 0; } 100% { opacity: 0; } }

/* ---------- Mobile: map on top, list as a bottom sheet ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .map { grid-row: 1; }
  .panel {
    grid-row: 2;
    min-width: 0;
    max-height: 56dvh;
    border-right: 0;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    margin-top: -16px;
    box-shadow: 0 -6px 24px rgba(0,0,0,.08);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sheet-handle {
    display: flex; justify-content: center; align-items: center;
    width: 100%; height: 22px; padding: 0;
    border: 0; background: transparent; cursor: pointer;
  }
  .grip { width: 40px; height: 4px; border-radius: 4px; background: #d6cfc7; }
  .head { padding: 2px 16px 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
  .eyebrow { display: none; }
  h1 { font-size: 21px; }
  .sub { margin: 0; font-size: 13px; }
  .controls { padding: 10px 16px 10px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 10px -16px 0; padding: 0 16px 2px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .list { padding: 4px 6px; }
  .panel.collapsed .body { display: none; }
  .panel.collapsed .search { display: none; }
  .panel.collapsed .controls { border-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .you-pulse, .locate-btn.busy svg { animation: none; }
}
