*{box-sizing:border-box;margin:0;padding:0}
:root{
  --blue:#007AFF;
  --orange:#FF9500;
  --bg:#F2F2F7;
  --sep:#C6C6C8;
  --muted:#8E8E93;
  --red:#FF3B30;
  --safe-top:env(safe-area-inset-top,0px);
  --safe-bottom:env(safe-area-inset-bottom,0px);
  --header-h:0px;
  --tab-h:56px;
  --tab-total:calc(var(--tab-h) + var(--safe-bottom));
}
html,body{
  height:100%;
  height:100vh;
  height:100dvh;
  overflow:hidden;
}
body{
  font-family:-apple-system,"SF Pro Text","Noto Sans TC","PingFang TC","Helvetica Neue",sans-serif;
  background:var(--bg);
  color:#000;
  font-size:15px;
  -webkit-font-smoothing:antialiased;
  overscroll-behavior:none;
}
button{font-family:inherit;border:none;background:none;cursor:pointer;color:inherit}
a{color:var(--blue);text-decoration:none}
.app{
  height:100%;height:100vh;height:100dvh;
  min-height:0;display:flex;flex-direction:column;
  max-width:560px;margin:0 auto;position:relative;background:var(--bg);overflow:hidden;
}

/* Sticky shared header */
.app-header{
  position:sticky;top:0;z-index:80;flex-shrink:0;
  background:rgba(242,242,247,.92);
  backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);
  border-bottom:0.5px solid transparent;
  transition:box-shadow .2s ease, border-color .2s ease;
}
.app-header.scrolled{
  border-bottom-color:var(--sep);
  box-shadow:0 1px 0 rgba(0,0,0,.04);
}
.header-inner{
  padding:calc(6px + var(--safe-top)) 16px 10px;
}
.header-row{
  display:flex;align-items:center;gap:8px;min-height:36px;
}
.header-back{
  flex-shrink:0;width:36px;height:36px;border-radius:18px;
  color:var(--blue);font-size:28px;line-height:1;font-weight:400;
  display:inline-flex;align-items:center;justify-content:center;
  margin-left:-6px;
}
.header-back[hidden]{display:none!important;}
.header-title{
  flex:1;min-width:0;font-size:22px;font-weight:700;letter-spacing:.01em;
  line-height:1.15;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  transition:font-size .18s ease;
}
.app-header.scrolled .header-title{font-size:16px;font-weight:600}
.app-header.mode-detail .header-title{font-size:17px;font-weight:600}
.app-header.scrolled .header-inner{padding-top:calc(4px + var(--safe-top));padding-bottom:8px;}
.app-header.scrolled .county-btn{padding:5px 10px;font-size:12px;}
.county-btn{
  flex-shrink:0;padding:6px 12px;border-radius:16px;
  background:#E3E3E8;font-size:13px;font-weight:600;color:var(--blue);
  display:inline-flex;align-items:center;gap:4px;
}
.county-btn[hidden]{display:none!important;}
.header-action{
  flex-shrink:0;color:var(--blue);font-size:16px;padding:6px 4px;font-weight:500;
}
.header-action[hidden]{display:none!important;}
.search{
  margin-top:8px;background:#E3E3E8;border-radius:10px;padding:9px 12px;
  font-size:15px;color:var(--muted);display:flex;gap:8px;align-items:center;
  transition:margin .18s ease, padding .18s ease;
}
.app-header.scrolled .search{margin-top:6px;padding:8px 12px}
.search[hidden]{display:none!important;}
.search input{
  flex:1;border:none;background:transparent;outline:none;font-size:15px;color:#000;
  font-family:inherit;min-width:0;
}
.search input::placeholder{color:var(--muted)}
.app-header.mode-detail .search{display:none!important;}
.app-header.mode-map{
  position:absolute;left:0;right:0;top:0;max-width:560px;margin:0 auto;
  background:rgba(255,255,255,.88);
}

/* Views */
.view{display:none;flex:1;flex-direction:column;min-height:0;padding-bottom:var(--tab-total)}
.view.active{display:flex}
.view-map{padding-bottom:0}
.view-map.active{
  position:relative;flex:1;min-height:0;height:100%;
}
.view-detail{padding-bottom:calc(16px + var(--safe-bottom))}

.scroll{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;min-height:0}
#list-scroll,#fav-scroll,#detail-scroll{padding-bottom:12px}
#view-list .group,#view-favorites .group{margin-bottom:12px}

.group{margin:0 16px 20px;background:#fff;border-radius:12px;overflow:hidden}
.row{
  display:flex;align-items:center;padding:12px 16px;
  border-bottom:0.5px solid var(--sep);gap:12px;width:100%;text-align:left;
}
.row:last-child{border-bottom:none}
.row:active{background:#F2F2F7}
.icon{
  width:40px;height:40px;border-radius:8px;background:#E5F1FF;color:var(--blue);
  display:flex;align-items:center;justify-content:center;font-size:11px;font-weight:700;flex-shrink:0;
}
.icon.food{background:#FFF3E8;color:var(--orange)}
.info{flex:1;min-width:0}
.info .name{font-size:16px;font-weight:400;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.info .sub{font-size:13px;color:var(--muted);margin-top:1px}
.tags{display:flex;flex-wrap:wrap;gap:4px;margin-top:3px}
.tag-famous{
  display:inline-block;font-size:10px;font-weight:600;color:#6C6C70;
  background:#EFEFF4;border-radius:4px;padding:1px 6px;letter-spacing:.02em;
}
.trail{text-align:right;flex-shrink:0;display:flex;align-items:center;gap:2px}
.trail .sc{font-size:16px;font-weight:600;color:var(--blue)}
.trail .chev{color:#C7C7CC;font-size:18px;line-height:1}
.empty{padding:48px 24px;text-align:center;color:var(--muted);font-size:15px;line-height:1.5}
.count-bar{padding:8px 20px 6px;font-size:13px;color:var(--muted);flex-shrink:0}

/* Bottom nav */
.bot{
  position:fixed;bottom:0;left:50%;transform:translateX(-50%);width:100%;max-width:560px;
  height:var(--tab-total);padding-bottom:var(--safe-bottom);
  background:rgba(255,255,255,.96);border-top:0.5px solid var(--sep);
  display:flex;justify-content:space-around;align-items:center;
  backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);
  z-index:600; /* above map sheet */
  pointer-events:auto;
}
.bot button,.bot a{
  flex:1;font-size:10px;color:var(--muted);text-decoration:none;text-align:center;
  font-weight:500;padding:6px 0 4px;background:none;border:none;cursor:pointer;
}
.bot .on{color:var(--blue)}
.bot .ico{display:block;font-size:20px;margin-bottom:1px;line-height:1}

/* Map — top inset via --header-h so sticky/absolute header doesn't cover pins */
#map{
  position:absolute;left:0;right:0;bottom:var(--tab-total);
  top:var(--header-h);background:#E5EDF2;z-index:0;
}
.map-note{
  position:absolute;top:calc(var(--header-h) + 10px);left:50%;transform:translateX(-50%);z-index:450;
  font-size:12px;color:#3C3C43;background:rgba(255,255,255,.95);border-radius:16px;
  padding:6px 14px;white-space:nowrap;font-weight:500;box-shadow:0 1px 4px rgba(0,0,0,.08);
  pointer-events:none;
}
.sheet{
  position:absolute;bottom:var(--tab-total);left:0;right:0;
  z-index:500; /* below .bot (600) so tab bar stays tappable */
  background:#fff;border-radius:16px 16px 0 0;padding:8px 20px 16px;
  box-shadow:0 -2px 16px rgba(0,0,0,.08);transform:translateY(110%);
  transition:transform .25s ease;pointer-events:none;
  max-height:min(42%, 280px);
  overflow:auto;
}
.sheet.open{transform:translateY(0);pointer-events:auto}
.sheet .handle{width:36px;height:5px;background:var(--sep);border-radius:3px;margin:0 auto 14px}
.sheet .sheet-row{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:4px}
.sheet h3{font-size:18px;font-weight:600;line-height:1.25}
.sheet .meta{font-size:13px;color:var(--muted);margin-top:2px}
.sheet .sc{font-size:20px;font-weight:600;color:var(--blue);flex-shrink:0}
.actions{display:flex;gap:10px;margin-top:14px}
.btn{
  flex:1;padding:12px 8px;text-align:center;border-radius:12px;font-size:15px;
  font-weight:600;text-decoration:none;display:inline-flex;align-items:center;
  justify-content:center;gap:4px;line-height:1.2;border:none;cursor:pointer;font-family:inherit;
}
.btn.primary{background:var(--blue);color:#fff}
.btn.secondary{background:#F2F2F7;color:var(--blue)}
.btn.secondary.on-fav{background:#FFE8EC;color:var(--red)}
.pin-icon{width:28px;height:28px}
.leaflet-container{font:inherit}
.sheet .actions{flex-wrap:nowrap}
.sheet .actions .btn{font-size:14px;padding:11px 6px}
#map-sheet .nav-note{margin:10px 0 0;padding:0}

/* Filter */
.group-label{
  padding:0 20px 6px;font-size:13px;color:var(--muted);
  letter-spacing:.02em;font-weight:500;
}
.cell{
  display:flex;justify-content:space-between;align-items:center;
  padding:12px 16px;border-bottom:0.5px solid var(--sep);font-size:16px;
  width:100%;text-align:left;
}
.cell:last-child{border-bottom:none}
.cell .check{color:var(--blue);font-weight:600;font-size:18px;visibility:hidden}
.cell.on .check{visibility:visible}
.chips-wrap{padding:12px 16px;display:flex;flex-wrap:wrap;gap:8px}
.chip{
  padding:8px 14px;font-size:14px;background:var(--bg);border-radius:16px;font-weight:500;
}
.chip.on{background:var(--blue);color:#fff}
.slider-cell{padding:16px}
.labs{display:flex;justify-content:space-between;font-size:13px;color:var(--muted);margin-bottom:10px}
.range-wrap{position:relative;height:28px;display:flex;align-items:center}
.range-wrap .track-bg{
  position:absolute;left:0;right:0;height:4px;background:#E5E5EA;border-radius:2px;
}
.range-wrap .track-fill{
  position:absolute;height:4px;background:var(--blue);border-radius:2px;pointer-events:none;
}
.range-wrap input[type=range]{
  position:absolute;left:0;width:100%;margin:0;appearance:none;-webkit-appearance:none;
  background:transparent;pointer-events:none;height:28px;
}
.range-wrap input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none;appearance:none;pointer-events:auto;
  width:28px;height:28px;border-radius:50%;background:#fff;
  box-shadow:0 1px 4px rgba(0,0,0,.2);border:0.5px solid #ddd;cursor:pointer;
}
.range-wrap input[type=range]::-moz-range-thumb{
  pointer-events:auto;width:28px;height:28px;border-radius:50%;background:#fff;
  box-shadow:0 1px 4px rgba(0,0,0,.2);border:0.5px solid #ddd;cursor:pointer;
}
.val{text-align:center;margin-top:12px;font-size:15px;font-weight:600;color:var(--blue)}
.apply{
  position:fixed;left:50%;transform:translateX(-50%);
  bottom:calc(var(--tab-total) + 8px);
  width:min(358px, calc(100% - 32px));max-width:528px;
  height:50px;background:var(--blue);color:#fff;border:none;border-radius:12px;
  font-size:16px;font-weight:600;display:flex;align-items:center;justify-content:center;
  z-index:90;box-shadow:0 2px 8px rgba(0,122,255,.3);
}
#view-filter .scroll{padding-bottom:calc(var(--tab-total) + 72px);padding-top:8px;}
#view-filter:not(.active) .apply{display:none;}

/* Detail */
.hero{padding:8px 20px 16px;background:var(--bg)}
.hero .type{font-size:13px;color:var(--muted);font-weight:500}
.hero h1{font-size:28px;font-weight:700;margin-top:2px;line-height:1.2}
.hero .loc{font-size:15px;color:var(--muted);margin-top:4px}
.hero .famous-line{margin-top:8px}
.score-pill{
  display:inline-flex;align-items:baseline;gap:4px;margin-top:10px;
  background:#fff;border-radius:20px;padding:6px 14px;font-size:13px;
}
.score-pill strong{font-size:20px;color:var(--blue);font-weight:600}
.detail-actions{display:flex;gap:10px;padding:0 16px 16px}
.detail-group{margin:0 16px 16px;background:#fff;border-radius:12px;overflow:hidden}
.detail-group h2{
  font-size:13px;color:var(--muted);padding:12px 16px 0;font-weight:500;letter-spacing:.02em;
}
.detail-group p{font-size:15px;line-height:1.55;padding:8px 16px 14px;color:#000}
.detail-group ul{list-style:none;padding:0 0 4px}
.detail-group li{padding:12px 16px;border-top:0.5px solid var(--sep);font-size:15px}
.detail-group li:first-of-type{border-top:none}
.detail-group .note{font-size:11px;color:var(--muted);padding:0 16px 12px}
.meta-row{font-size:14px;color:#3C3C43;padding:4px 16px;line-height:1.45}
.meta-row:last-of-type{padding-bottom:14px}
.meta-row strong{color:var(--muted);font-weight:500;margin-right:6px}
.caution-list{list-style:none;padding:0 0 4px}
.caution-list li{padding:12px 16px;border-top:0.5px solid var(--sep);font-size:15px;line-height:1.55}
.caution-list li:first-child{border-top:none;padding-top:8px}
.caution-list a{font-size:13px;font-weight:500;margin-left:4px;white-space:nowrap}
.detail-group > p{font-size:15px;line-height:1.55;padding:8px 16px 14px;color:#000}
.nav-note{
  margin:8px 16px 0;font-size:12px;color:var(--muted);line-height:1.4;padding:0 4px;
}
.recheck-note{
  display:inline-block;margin-top:8px;font-size:11px;color:var(--muted);
  background:#EFEFF4;border-radius:6px;padding:3px 8px;line-height:1.35;font-weight:500;
}

/* County picker */
.overlay{
  position:fixed;inset:0;background:rgba(0,0,0,.35);z-index:700;
  display:none;align-items:flex-end;justify-content:center;
}
.overlay.open{display:flex}
.picker{
  background:#fff;border-radius:16px 16px 0 0;width:100%;max-width:560px;
  padding:8px 0 calc(20px + var(--safe-bottom));
}
.picker .handle{width:36px;height:5px;background:var(--sep);border-radius:3px;margin:0 auto 12px}
.picker h2{font-size:16px;font-weight:600;text-align:center;padding:0 16px 12px}
.picker button{
  display:flex;justify-content:space-between;align-items:center;
  width:100%;padding:14px 20px;font-size:17px;border-top:0.5px solid var(--sep);
}
.picker button .check{color:var(--blue);font-weight:600}

.filter-badge{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:16px;height:16px;padding:0 4px;margin-left:3px;
  border-radius:8px;background:var(--blue);color:#fff;
  font-size:10px;font-weight:700;line-height:1;vertical-align:middle;
}
.filter-badge[hidden]{display:none!important;}

.fav-notice{
  margin:8px 16px 12px;padding:10px 12px;border-radius:10px;
  background:#FFF6E5;color:#8A6116;font-size:12px;line-height:1.45;flex-shrink:0;
}
.toast-overlay{
  position:fixed;inset:0;z-index:800;display:flex;align-items:flex-end;justify-content:center;
  background:rgba(0,0,0,.28);padding:0 16px calc(var(--tab-total) + 16px);
}
.toast-overlay[hidden]{display:none!important;}
.toast-sheet{
  width:100%;max-width:528px;background:#fff;border-radius:14px;padding:16px 16px 14px;
  box-shadow:0 8px 28px rgba(0,0,0,.18);
}
.toast-sheet p{font-size:14px;line-height:1.5;color:#1C1C1E;margin:0 0 14px}
.toast-sheet .toast-ok{
  width:100%;height:44px;border-radius:10px;background:var(--blue);color:#fff;
  font-size:16px;font-weight:600;
}

/* Type segment under header (list/map) */
.type-seg{
  display:flex;margin-top:8px;background:#E3E3E8;border-radius:9px;padding:2px;
}
.type-seg[hidden]{display:none!important;}
.type-seg button{
  flex:1;text-align:center;padding:7px 0;font-size:13px;font-weight:500;
  color:#000;border-radius:7px;
}
.type-seg button.on{background:#fff;box-shadow:0 0.5px 1px rgba(0,0,0,.12);font-weight:600}
.app-header.scrolled .type-seg{margin-top:6px}
.app-header.scrolled .type-seg button{padding:6px 0}
.app-header.mode-filter .type-seg,
.app-header.mode-favorites .type-seg,
.app-header.mode-detail .type-seg{display:none!important;}

/* Map legend — above tab bar, left; below sheet when open (z under sheet) */
.map-legend{
  position:absolute;left:10px;bottom:calc(var(--tab-total) + 10px);
  z-index:480; /* below sheet(500) and bot(600) */
  display:flex;gap:10px;align-items:center;
  background:rgba(255,255,255,.95);border-radius:14px;padding:6px 12px;
  font-size:12px;font-weight:600;color:#3C3C43;
  box-shadow:0 1px 4px rgba(0,0,0,.12);pointer-events:none;
}
.map-legend .leg{display:inline-flex;align-items:center;gap:5px}
.leg-pin{
  display:inline-block;width:10px;height:10px;border-radius:50%;
  box-shadow:0 0 0 2px #fff;
}
.leg-pin.blue{background:#007AFF}
.leg-pin.orange{background:#FF9500}
/* When sheet open, lift legend above sheet? No — keep left and let sheet cover if needed,
   or move legend up. Prefer above sheet when open via JS class. */
.view-map.sheet-open .map-legend{
  bottom:calc(var(--tab-total) + min(42%, 280px) + 10px);
}

/* Applied filter chips (list/map under type seg) */
.applied-chips{
  margin-top:8px;min-height:0;
}
.applied-chips[hidden]{display:none!important;}
.applied-chips-scroll{
  display:flex;flex-wrap:nowrap;gap:8px;overflow-x:auto;-webkit-overflow-scrolling:touch;
  padding-bottom:2px;scrollbar-width:none;
}
.applied-chips-scroll::-webkit-scrollbar{display:none;}
.a-chip{
  flex:0 0 auto;display:inline-flex;align-items:center;gap:4px;
  padding:6px 8px 6px 10px;border-radius:14px;background:#E5F1FF;color:var(--blue);
  font-size:12px;font-weight:600;white-space:nowrap;max-width:70vw;
}
.a-chip .a-chip-x{
  width:18px;height:18px;border-radius:9px;display:inline-flex;align-items:center;justify-content:center;
  font-size:14px;line-height:1;color:var(--blue);background:rgba(0,122,255,.12);
}
.a-chip.clear-all{
  background:#F2F2F7;color:#3C3C43;
}
.a-chip.clear-all .a-chip-x{display:none;}
.app-header.scrolled .applied-chips{margin-top:6px;}
.app-header.mode-filter .applied-chips,
.app-header.mode-favorites .applied-chips,
.app-header.mode-detail .applied-chips{display:none!important;}

.empty-clear{
  margin-top:16px;padding:10px 18px;border-radius:10px;
  background:var(--blue);color:#fff;font-size:15px;font-weight:600;
}
.map-filter-empty{
  position:absolute;left:50%;transform:translateX(-50%);
  top:calc(var(--header-h) + 44px);z-index:470;
  display:flex;align-items:center;gap:10px;
  background:rgba(255,255,255,.96);border-radius:14px;padding:8px 12px;
  font-size:13px;font-weight:500;color:#3C3C43;
  box-shadow:0 1px 6px rgba(0,0,0,.12);white-space:nowrap;
}
.map-filter-empty[hidden]{display:none!important;}
.map-filter-empty button{
  padding:6px 10px;border-radius:8px;background:var(--blue);color:#fff;
  font-size:12px;font-weight:600;
}
