:root {
  --bg: #f6efe3;
  --panel: #fffaf2;
  --ink: #2a2118;
  --muted: #7a6a58;
  --line: #e8dccb;
  --crust: #b5651d;
  --crust-ink: #fff;
  --sesame: #e9c46a;
  --t1: #b5651d;   /* ranks 1-10 */
  --t2: #d08c3e;   /* 11-20 */
  --t3: #9c8b76;   /* 21-30 */
  --t4: #b9ada0;   /* 31-39 */
  --mine: #2f7d5b;
  --shadow: 0 6px 24px rgba(60, 40, 20, .14);
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --serif: "Fraunces", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1712; --panel: #241d17; --ink: #f3e9dc; --muted: #b3a28e; --line: #3a2f25;
    --crust: #e08a3c; --crust-ink: #1c1712; --t1: #e08a3c; --t2: #c9894a; --t3: #8f7f6c; --t4: #6c6052;
    --mine: #5fc495; --shadow: 0 6px 24px rgba(0, 0, 0, .45); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1712; --panel: #241d17; --ink: #f3e9dc; --muted: #b3a28e; --line: #3a2f25;
  --crust: #e08a3c; --crust-ink: #1c1712; --t1: #e08a3c; --t2: #c9894a; --t3: #8f7f6c; --t4: #6c6052;
  --mine: #5fc495; --shadow: 0 6px 24px rgba(0, 0, 0, .45); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); }
a { color: var(--crust); }
button, select, input { font: inherit; color: inherit; }

.app { display: flex; height: 100dvh; }
.panel {
  width: 420px; max-width: 100%; display: flex; flex-direction: column; background: var(--panel);
  border-right: 1px solid var(--line); overflow-y: auto; z-index: 500;
}
.map-wrap { flex: 1; position: relative; }
#map { position: absolute; inset: 0; background: var(--bg); }

.head { padding: 18px 18px 6px; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h1 { font-family: var(--serif); font-weight: 800; font-size: 26px; margin: 0; display: flex; align-items: center; gap: 10px; letter-spacing: -.01em; }
.logo { width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 50% 50%, var(--panel) 0 22%, transparent 23%), radial-gradient(circle at 40% 35%, #e3a35c, var(--crust) 70%);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); }
.sub { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; }

.controls { padding: 8px 18px 4px; display: grid; gap: 8px; }
.search input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 10px; font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.chip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.btn { border: 1px solid var(--crust); background: var(--crust); color: var(--crust-ink); padding: 7px 12px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 13.5px; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn.small { padding: 4px 9px; font-size: 12.5px; border-radius: 8px; }
.btn.on { background: var(--mine); border-color: var(--mine); color: #fff; }
select.btn { appearance: none; padding-right: 12px; }
.icon-btn { border: 1px solid var(--line); background: transparent; border-radius: 50%; width: 34px; height: 34px; cursor: pointer; font-size: 16px; }
.origin { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.origin button { border: 0; background: none; color: var(--crust); cursor: pointer; padding: 0; }

.tabs { display: flex; gap: 2px; padding: 8px 18px 0; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.tab { border: 0; background: none; padding: 8px 10px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tab.active { color: var(--ink); border-color: var(--crust); }
.tab span { font-weight: 500; color: var(--muted); font-size: 12px; }

.list { list-style: none; margin: 0; padding: 6px 10px 10px; }
.item { border-radius: 12px; }
.item + .item { border-top: 1px solid var(--line); }
.item.active { background: var(--bg); border-color: transparent; }
.item.active + .item { border-color: transparent; }
.item-main { width: 100%; display: flex; gap: 12px; align-items: center; text-align: left; background: none; border: 0; padding: 10px 8px; cursor: pointer; }
.rank { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-family: var(--serif); font-weight: 700; color: #fff; font-size: 15px; }
.body { flex: 1; min-width: 0; }
.name { display: block; font-weight: 600; }
.meta { display: block; color: var(--muted); font-size: 13px; }
.meta .trend { font-weight: 600; }
.meta .up { color: var(--mine); } .meta .down { color: #c0563b; }
.dist { color: var(--muted); font-size: 13px; white-space: nowrap; }
.been-mark { color: var(--mine); font-weight: 700; margin-left: 4px; }
.details { padding: 0 10px 12px 54px; }
.note { margin: 0 0 8px; }
.tags { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 8px; }
.tag { font-size: 11.5px; border-radius: 6px; padding: 1px 7px; background: var(--line); color: var(--ink); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.stars { display: inline-flex; gap: 1px; margin-left: 2px; }
.stars button { border: 0; background: none; padding: 0 1px; cursor: pointer; font-size: 17px; color: var(--line); line-height: 1; }
.stars button.on { color: var(--sesame); }
.reviews { margin-top: 10px; font-size: 13px; display: grid; gap: 3px; }
.reviews a { text-decoration: none; }
.reviews a:hover { text-decoration: underline; }
.reviews .date { color: var(--muted); }
.spark { margin-top: 8px; }
.spark svg { display: block; width: 100%; height: 54px; }
.spark .cap { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }

.crawl, .mine { padding: 6px 18px 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 10px; }
.crawl-list { margin: 0 0 10px; padding-left: 22px; display: grid; gap: 6px; }
.crawl-list li { padding-left: 4px; }
.crawl-list .stop { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.meta-inline { color: var(--muted); font-size: 13px; }
.crawl-list .leg { color: var(--muted); font-size: 12.5px; display: block; }
.crawl-list button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 4px; }
.crawl-presets { margin-top: 14px; }
.progress .bar { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress .bar span { display: block; height: 100%; background: var(--mine); width: 0; transition: width .4s; }
.progress p { margin: 6px 0 0; font-weight: 600; }

.foot { margin-top: auto; padding: 14px 18px 18px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }

.fab { position: absolute; right: 12px; bottom: 24px; z-index: 450; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); cursor: pointer; font-size: 18px; }
.pick-banner { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 460; background: var(--ink); color: var(--panel); padding: 8px 10px 8px 14px; border-radius: 12px; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: center; font-size: 14px; }
.pick-banner { flex-wrap: wrap; justify-content: center; max-width: calc(100% - 90px); }
.pick-banner .btn.ghost { color: var(--panel); border-color: rgba(255,255,255,.3); }
.addr { display: flex; gap: 4px; }
.addr input { width: 190px; max-width: 46vw; padding: 4px 8px; border-radius: 8px; border: 0; background: var(--panel); color: var(--ink); }
.addr-err { color: #ffb4a0; font-size: 12.5px; width: 100%; text-align: center; }
.map-wrap.picking #map { cursor: crosshair; }

/* map pins */
.pin { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 700 13px/1 var(--serif); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); transition: transform .15s; }
.pin.approx { border-style: dashed; }
.pin.been::after { content: "✓"; position: absolute; right: -5px; top: -5px; width: 14px; height: 14px; border-radius: 50%; background: var(--mine); color: #fff; font: 700 9px/14px var(--font); text-align: center; border: 1.5px solid #fff; }
.pin.crawl { outline: 3px solid var(--sesame); outline-offset: 1px; }
.pin.active { transform: scale(1.3); z-index: 1000; }
.pin.dim { opacity: .25; }
.origin-pin { width: 18px; height: 18px; border-radius: 50%; background: #2a7de1; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(42,125,225,.25); }
.leaflet-container { font: inherit; }
.leaflet-popup-content-wrapper { border-radius: 12px; background: var(--panel); color: var(--ink); }
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 10px 14px; }
.pop b { font-family: var(--serif); font-size: 16px; }
.pop .meta { margin: 2px 0 6px; }
.pop .row { margin-top: 6px; }
.pop .btn { color: var(--crust-ink); }
.pop .btn.ghost { color: var(--ink); }
.osm-tiles { filter: grayscale(.55) sepia(.18) brightness(1.04) contrast(.92); }
:root[data-theme="dark"] .osm-tiles { filter: invert(1) hue-rotate(180deg) grayscale(.6) sepia(.25) brightness(.85) contrast(.9); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .osm-tiles { filter: invert(1) hue-rotate(180deg) grayscale(.6) sepia(.25) brightness(.85) contrast(.9); }
}
.leaflet-control-attribution { font-size: 10px; }

/* phone: map on top, panel as a bottom sheet */
@media (max-width: 760px) {
  .app { flex-direction: column-reverse; }
  .map-wrap { flex: none; height: 46dvh; }
  .panel { width: 100%; flex: 1; border-right: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; margin-top: -14px; box-shadow: 0 -6px 18px rgba(0,0,0,.12); }
  .app.expanded .map-wrap { height: 18dvh; }
  .grab { display: block; width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 8px auto 0; cursor: pointer; flex: none; }
  .head { padding: 8px 16px 4px; }
  h1 { font-size: 22px; }
  .controls, .tabs, .crawl, .mine, .foot { padding-left: 16px; padding-right: 16px; }
  .list { padding: 4px 6px 10px; }
  .details { padding-left: 52px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .controls .row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .controls .row > * { flex: none; }
  .sub { font-size: 13px; }
  .pin { width: 24px; height: 24px; font-size: 11px; }
  .fab { bottom: 26px; }
}
@media (min-width: 761px) { .grab { display: none; } }
