:root{
  --surface:rgba(255,255,255,.96);
  --text:#20282d;
  --muted:#596778;
  --accent:#1677ef;
  --active:#e7f1ff;
  --line:rgba(89,103,120,.16);
  --shadow:0 8px 28px rgba(23,40,59,.16);
  color-scheme:light;
}
:root[data-theme="dark"]{
  --surface:rgba(32,40,47,.96);
  --text:#edf1f7;
  --muted:#b5c0cf;
  --accent:#78b7ff;
  --active:#243d5a;
  --line:rgba(255,255,255,.12);
  color-scheme:dark;
}

*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{
  overflow:hidden;
  background:#e5ebe6;
  color:var(--text);
  font:calc(16px + 2pt)/1.35 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}
button,input{font:inherit;color:inherit}
button{border:0;background:none;cursor:pointer;-webkit-tap-highlight-color:transparent}
button:focus-visible,input:focus-visible,.leaflet-marker-icon:focus-visible{outline:3px solid var(--accent);outline-offset:2px}
button:disabled{cursor:default;opacity:.42}
svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;pointer-events:none}

#map{position:fixed;inset:0}
.leaflet-control-zoom{display:none}
.leaflet-tile-pane{filter:saturate(.45) brightness(1.06) contrast(.93)}
:root[data-theme="dark"] .leaflet-tile-pane{filter:saturate(.34) brightness(.74) contrast(.93)}
.leaflet-control-attribution{font-size:11px}
.leaflet-popup-content{max-height:240px;overflow:auto;margin:10px 12px}
.leaflet-popup-content button{display:block;width:100%;min-height:42px;padding:7px 4px;text-align:left;border-bottom:1px solid #ddd}

/* Header */
.app-header{
  position:fixed;
  inset:0 0 auto;
  z-index:910;
  height:calc(36px + env(safe-area-inset-top));
  padding:env(safe-area-inset-top) 6px 0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  background:var(--surface);
}
.brand{min-width:0;display:flex;align-items:center;gap:6px;padding-right:68px}
.brand-mark{width:24px;height:24px;flex:0 0 24px;display:grid;place-items:center;border-radius:7px;background:var(--text);color:var(--surface)}
.brand-mark svg{width:15px;height:15px}
.brand-title{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:calc(17px + 2pt);font-weight:720;line-height:1;letter-spacing:-.2px}
.header-actions{position:absolute;top:env(safe-area-inset-top);right:4px;height:34px;display:flex;align-items:center}
.icon-button{width:32px;height:32px;display:grid;place-items:center;border-radius:9px}
.icon-button:hover{background:var(--active)}
.icon-button:active{transform:scale(.94)}
.icon-button.compact{width:36px;height:36px}

/* Toolbar */
.toolbar-shell{
  position:fixed;
  top:calc(36px + env(safe-area-inset-top));
  left:0;right:0;
  z-index:900;
  height:31px;
  padding:0 3px;
  background:var(--surface);
  border-bottom:1px solid var(--line);
  box-shadow:0 2px 10px rgba(23,40,59,.10);
  backdrop-filter:blur(12px);
}
.toolbar{height:30px;display:flex;align-items:center;overflow-x:auto;scrollbar-width:none}
.toolbar::-webkit-scrollbar{display:none}
.tool{position:relative;width:36px;height:30px;flex:0 0 36px;padding:0;display:grid;place-items:center;border-radius:7px}
.tool svg{display:block;width:18px;height:18px}
.tool[aria-pressed="true"]{background:var(--active)}
.tool.unavailable{opacity:.36}
.tool.unavailable[aria-pressed="true"]{opacity:.6}
.popover{
  position:fixed;
  top:calc(69px + env(safe-area-inset-top));
  right:10px;
  z-index:930;
  padding:12px;
  border-radius:16px;
  background:var(--surface);
  box-shadow:var(--shadow);
  backdrop-filter:blur(14px);
}
.search-panel{width:min(420px,calc(100vw - 20px))}
.more-panel{width:min(340px,calc(100vw - 20px));max-height:65dvh;overflow:auto}
.search-line{display:flex;align-items:center;gap:6px}
.search-line input{min-width:0;flex:1;padding:9px 4px;border:0;border-bottom:1px solid var(--line);background:transparent}
.search-results{max-height:min(48dvh,380px);overflow:auto;margin-top:6px}
.search-result{display:block;width:100%;min-height:46px;padding:8px;border-radius:9px;text-align:left}
.search-result:hover{background:var(--active)}
.search-result small{display:block;color:var(--muted)}
.more-panel h2{margin:0 0 8px;font-size:calc(15px + 2pt)}
.food-grid{display:flex;flex-wrap:wrap;gap:6px}
.food-grid button{min-height:40px;padding:7px 10px;border-radius:12px;background:rgba(89,103,120,.10)}
.food-grid button[aria-pressed="true"]{background:var(--active)}
.map-help{margin-top:10px;padding-top:9px;border-top:1px solid var(--line);color:var(--muted);font-size:calc(13px + 2pt)}
.map-help summary{cursor:pointer;color:var(--text);font-weight:650}
.map-help p{margin:8px 0}
.evidence-key{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-top:8px}
.evidence-key span{display:flex;align-items:center;gap:6px}
.evidence-key i{width:12px;height:12px;border-radius:50%;background:var(--e)}

/* Places sheet */
.places-sheet{
  position:fixed;
  left:0;right:0;bottom:0;
  z-index:720;
  height:34dvh;
  max-height:calc(100dvh - 74px - env(safe-area-inset-top));
  display:flex;
  flex-direction:column;
  overflow:hidden;
  background:var(--surface);
  border-top:1px solid var(--line);
  border-radius:16px 16px 0 0;
  box-shadow:0 -8px 28px rgba(23,40,59,.16);
  backdrop-filter:blur(14px);
  transition:height .16s ease,width .16s ease;
}
.places-sheet[data-mode="collapsed"]{height:13px}
.places-sheet[data-mode="expanded"]{height:68dvh}
.sheet-handle{flex:0 0 11px;min-height:11px;display:flex;align-items:center;justify-content:center;padding:0;touch-action:none;cursor:ns-resize}
.sheet-handle span{display:block;width:32px;height:3px;border-radius:999px;background:#aab4bc}
.sheet-head{flex:0 0 27px;display:flex;align-items:center;justify-content:space-between;gap:4px;padding:0 5px 1px;border-bottom:1px solid var(--line)}
.sheet-head strong{white-space:nowrap;font-size:calc(13px + 2pt)}
.sort-control{display:flex;gap:1px;padding:1px;border-radius:8px;background:rgba(89,103,120,.10)}
.sort-control button{height:22px;padding:0 7px;border-radius:7px;font-size:calc(12px + 2pt);font-weight:650;color:var(--muted)}
.sort-control button[aria-pressed="true"]{background:var(--text);color:var(--surface)}
.place-list{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:0 4px calc(4px + env(safe-area-inset-bottom));scrollbar-width:thin}
.place-item{border-bottom:1px solid var(--line)}
.place-row{height:34px;display:grid;grid-template-columns:22px minmax(0,1fr);gap:5px;align-items:center}
.place-row.selected{background:var(--active)}
.evidence-dot{width:20px;height:20px;justify-self:center;padding:0;display:grid;place-items:center;border:1.5px solid var(--e);border-radius:50%;background:var(--e);color:#fff}
.evidence-dot svg{display:block;width:13px;height:13px;stroke-width:2.1}
.evidence-dot.ring{background:transparent;color:var(--e);border-width:2px}
.evidence-dot.closed{background:transparent;color:#000;border-color:#000}
.place-main{width:100%;height:100%;min-width:0;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px;align-items:center;padding:0;text-align:left}
.place-main:hover{background:rgba(89,103,120,.06)}
.place-line{min-width:0;display:flex;align-items:baseline;gap:5px;white-space:nowrap;overflow:hidden}
.place-line strong{min-width:42px;overflow:hidden;text-overflow:ellipsis;font-size:calc(14px + 2pt)}
.place-meta{min-width:0;overflow:hidden;text-overflow:ellipsis;color:var(--muted);font-size:calc(12.6px + 2pt)}
.place-distance{padding-right:2px;color:var(--muted);white-space:nowrap;font-size:calc(12.5px + 2pt)}
.crown-inline{width:calc(18px + 2pt);height:calc(17px + 2pt);flex:0 0 calc(18px + 2pt);color:#dda31b;fill:currentColor;stroke:#000;stroke-width:1.2;paint-order:stroke fill}
.place-details{display:grid;gap:2px;padding:1px 2px 6px 27px;animation:details-in .14s ease-out}
.detail-row{min-height:25px;display:grid;grid-template-columns:22px minmax(0,1fr);gap:5px;align-items:center;color:var(--muted);font-size:calc(13px + 2pt)}
.detail-row .detail-icon{width:22px;height:22px;display:grid;place-items:center;border-radius:6px}
.detail-row .detail-icon:hover{background:var(--active)}
.detail-row svg{width:16px;height:16px}
.detail-copy{min-width:0;overflow-wrap:anywhere}
.detail-tags{display:flex;flex-wrap:wrap;gap:4px}
.tag{padding:2px 6px;border-radius:999px;background:rgba(89,103,120,.10);font-size:calc(11.5px + 2pt)}
.empty{margin:18px 8px;color:var(--muted);text-align:center}
@keyframes details-in{from{opacity:0;transform:translateY(-2px)}to{opacity:1;transform:none}}

.status{
  position:fixed;
  top:calc(76px + env(safe-area-inset-top));
  left:50%;
  z-index:940;
  transform:translateX(-50%);
  max-width:min(460px,calc(100% - 32px));
  padding:7px 12px;
  border-radius:12px;
  background:var(--surface);
  box-shadow:var(--shadow);
  text-align:center;
  pointer-events:none;
  font-size:calc(13px + 2pt);
}
.status:empty{display:none}

/* Map symbols */
.venue-hit,.cluster-hit{background:none;border:0}
.venue-dot{position:relative;width:22px;height:22px;display:grid;place-items:center;border:1.5px solid var(--e);border-radius:50%;background:var(--e);color:#fff;box-shadow:0 1px 3px #0003}
.venue-dot svg{width:68%;height:68%;stroke-width:2.1}
.venue-dot.ring{background:transparent;color:var(--e);border-width:2px;box-shadow:none}
.venue-dot.selected::after{content:"";position:absolute;inset:-6px;border:2px solid var(--accent);border-radius:50%;box-shadow:0 0 0 3px rgba(22,119,239,.10)}
.venue-dot.closed{background:transparent;border:2px solid #000;color:#000}
.map-crown{position:absolute;left:50%;bottom:calc(100% + 2px);transform:translateX(-50%);width:calc(23px + 2pt);height:calc(19px + 2pt);color:#dda31b;fill:currentColor;stroke:#000;stroke-width:1.2;paint-order:stroke fill}
.cluster{position:relative;display:block;width:var(--cluster-size);height:var(--cluster-size);border-radius:50%;box-shadow:0 2px 6px #0003}
.cluster b{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:var(--cluster-core);height:var(--cluster-core);display:grid;place-items:center;border-radius:50%;background:rgba(255,255,255,.88);border:1px solid rgba(23,40,59,.10);color:#20282d;font-size:var(--cluster-font);line-height:1}
.cluster-crown{position:absolute;left:50%;bottom:calc(100% + 2px);transform:translateX(-50%);width:calc(22px + 2pt);height:calc(18px + 2pt);color:#dda31b;fill:currentColor;stroke:#000;stroke-width:1.2;paint-order:stroke fill}

@media(min-width:900px) and (min-height:600px){
  .places-sheet{
    left:auto;right:18px;bottom:18px;
    width:410px;height:min(58vh,650px);max-height:86vh;
    border:1px solid var(--line);border-radius:20px;
  }
  .places-sheet[data-mode="collapsed"]{width:13px;height:min(58vh,650px)}
  .places-sheet[data-mode="expanded"]{width:min(46vw,520px);height:min(70vh,760px)}
  .sheet-handle{cursor:ew-resize}
}

@media(orientation:landscape) and (max-height:599px){
  .app-header{height:calc(34px + env(safe-area-inset-top))}
  .toolbar-shell{top:calc(34px + env(safe-area-inset-top))}
  .popover{top:calc(67px + env(safe-area-inset-top))}
  .places-sheet{
    top:calc(67px + env(safe-area-inset-top));right:0;bottom:0;left:auto;
    width:min(42vw,380px);height:auto;max-height:none;
    border-radius:16px 0 0 0;border-left:1px solid var(--line);
  }
  .places-sheet[data-mode="collapsed"]{width:13px;height:auto}
  .places-sheet[data-mode="expanded"]{width:min(48vw,440px);height:auto}
  .sheet-handle{position:absolute;left:0;top:0;bottom:0;width:11px;height:auto;cursor:ew-resize}
  .sheet-handle span{width:3px;height:32px}
  .sheet-head,.place-list{margin-left:10px}
}

@media(prefers-reduced-motion:reduce){
  *,*::before,*::after{scroll-behavior:auto;transition:none;animation:none}
}
