:root {
  --blue: #1a73e8;
  --green: #188038;
  --green-bg: #e6f4ea;
  --amber: #b06000;
  --amber-bg: #fef0cd;
  --red: #c5221f;
  --red-bg: #fce8e6;
  --gray: #5f6368;
  --gray-bg: #f1f3f4;
  --line: #e0e3e7;
  --text: #202124;
  --sub: #5f6368;
  --bg: #ffffff;
  --shadow: 0 1px 3px rgba(60, 64, 67, .3), 0 4px 8px 3px rgba(60, 64, 67, .15);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --sheet-h: 42vh;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #e8eaed; color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#map { position: fixed; inset: 0; }

/* 上方搜尋列 */
.top { position: fixed; top: calc(10px + var(--safe-t)); left: 10px; right: 10px; z-index: 1000; max-width: 520px; }
.search { display: flex; align-items: center; height: 48px; padding: 0 6px 0 14px; background: var(--bg); border-radius: 24px; box-shadow: var(--shadow); }
.search .ico { width: 20px; height: 20px; color: var(--sub); flex: none; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; font-size: 16px; padding: 0 10px; background: transparent; color: var(--text); }
.search input::-webkit-search-cancel-button { display: none; }
.clear { border: 0; background: none; width: 40px; height: 40px; border-radius: 20px; color: var(--sub); display: grid; place-items: center; }
.clear svg { width: 20px; height: 20px; }
.clear[hidden] { display: none; }
.suggest { position: absolute; left: 0; right: 0; top: 54px; z-index: 2; list-style: none; margin: 0; padding: 6px 0; background: var(--bg); border-radius: 16px; box-shadow: var(--shadow); max-height: 50vh; overflow: auto; }
.suggest li { padding: 10px 16px; cursor: pointer; }
.suggest li:active, .suggest li.hl { background: var(--gray-bg); }
.suggest .s-main { font-size: 15px; }
.suggest .s-sub { font-size: 12px; color: var(--sub); margin-top: 2px; }
.suggest .s-hint { color: var(--sub); font-size: 13px; cursor: default; }
.chips { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 34px; padding: 0 14px; border-radius: 17px; border: 1px solid var(--line); background: var(--bg); font-size: 14px; box-shadow: 0 1px 2px rgba(60, 64, 67, .2); }
.chip.on { background: #e8f0fe; border-color: #d2e3fc; color: #1967d2; font-weight: 600; }

/* 右側按鈕 */
.fabs { position: fixed; right: 12px; bottom: calc(var(--sheet-h) + 14px); z-index: 900; display: flex; flex-direction: column; gap: 10px; transition: bottom .25s; }
.fab { width: 46px; height: 46px; border-radius: 23px; border: 0; background: var(--bg); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--blue); }
.fab svg { width: 24px; height: 24px; }
.dragging .fabs, .dragging .sheet { transition: none; }

/* 下方抽屜 */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; height: var(--sheet-h); z-index: 950; background: var(--bg); border-radius: 18px 18px 0 0; box-shadow: 0 -2px 10px rgba(60, 64, 67, .2); display: flex; flex-direction: column; transition: height .25s; max-width: 560px; }
.handle { height: 26px; display: grid; place-items: center; touch-action: none; cursor: grab; flex: none; }
.handle span { width: 40px; height: 5px; border-radius: 3px; background: #dadce0; }
.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 16px calc(16px + var(--safe-b)); }
.sh-title { font-size: 18px; font-weight: 700; margin: 0; }
.sh-sub { font-size: 13px; color: var(--sub); margin-top: 3px; }
.tabs { display: flex; gap: 6px; margin: 12px 0 4px; }
.tabs button { flex: 1; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 14px; }
.tabs button.on { background: var(--text); border-color: var(--text); color: #fff; font-weight: 600; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list li:last-child { border-bottom: 0; }
.li-main { flex: 1; min-width: 0; }
.li-name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-sub { font-size: 13px; color: var(--sub); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num { flex: none; min-width: 64px; text-align: right; font-size: 22px; font-weight: 700; line-height: 1.1; }
.num small { display: block; font-size: 11px; font-weight: 400; color: var(--sub); }
.num.g { color: var(--green); } .num.a { color: var(--amber); } .num.r { color: var(--red); } .num.n { color: var(--gray); font-size: 16px; }
.empty { color: var(--sub); font-size: 14px; line-height: 1.7; padding: 16px 0; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: var(--gray-bg); color: var(--gray); vertical-align: 2px; margin-left: 4px; }
.tag.pub { background: #e8f0fe; color: #1967d2; }

/* 詳情 */
.back { border: 0; background: none; padding: 4px 0; color: var(--blue); font-size: 15px; display: inline-flex; align-items: center; gap: 2px; }
.back svg { width: 18px; height: 18px; }
.d-name { font-size: 21px; font-weight: 700; margin: 6px 0 6px; line-height: 1.3; }
.d-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.d-tags .tag { margin: 0; font-size: 12px; padding: 2px 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 14px 0; }
.stat { background: var(--gray-bg); border-radius: 12px; padding: 10px 12px; }
.stat label { display: block; font-size: 12px; color: var(--sub); }
.stat b { font-size: 26px; line-height: 1.25; }
.stat small { font-size: 13px; color: var(--sub); margin-left: 4px; }
.stat.g b { color: var(--green); } .stat.a b { color: var(--amber); } .stat.r b { color: var(--red); } .stat.n b { color: var(--gray); font-size: 18px; }
.facts { margin: 0; font-size: 14px; line-height: 1.6; }
.facts div { display: grid; grid-template-columns: 64px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--sub); }
.facts dd { margin: 0; word-break: break-word; }
.facts a { color: var(--blue); text-decoration: none; }
.d-upd { font-size: 12px; color: var(--sub); margin: 10px 0 0; }
.actions { display: flex; gap: 10px; margin-top: 14px; }
.btn-nav { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; height: 48px; border-radius: 24px; background: var(--blue); color: #fff; font-size: 16px; font-weight: 600; text-decoration: none; }
.btn-nav svg { width: 20px; height: 20px; }
.note { font-size: 12px; color: var(--sub); line-height: 1.6; margin-top: 10px; }

/* 地圖標記：.mk 是定位點（寬高 0），裡面的 .pin 往上長 */
.mk { position: absolute; width: 0; height: 0; }
.pin { position: absolute; left: 0; bottom: 6px; transform: translateX(-50%); display: inline-flex; align-items: center; height: 28px; border-radius: 14px; padding: 0 9px 0 3px; gap: 5px; white-space: nowrap; font-size: 14px; font-weight: 700; color: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); cursor: pointer; transition: transform .12s; }
.pin::after { content: ""; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: inherit; }
.pin b { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 11px; background: rgba(255, 255, 255, .95); font-size: 12px; }
.pin.g { background: var(--green); border-color: var(--green); } .pin.g b { color: var(--green); }
.pin.a { background: #e37400; border-color: #e37400; } .pin.a b { color: #e37400; }
.pin.r { background: var(--red); border-color: var(--red); } .pin.r b { color: var(--red); }
.pin.n { background: #80868b; border-color: #80868b; padding-right: 3px; } .pin.n b { color: #80868b; }
.pin.priv { background: #fff; color: var(--gray); border: 1.5px solid #9aa0a6; } .pin.priv b { background: var(--gray-bg); }
.pin.priv::after { border-top-color: #9aa0a6; }
.pin.seg { height: 24px; border-radius: 6px; font-size: 13px; padding-right: 7px; }
.pin.seg b { width: 18px; height: 18px; border-radius: 4px; font-size: 11px; }
.pin.sel { transform: translateX(-50%) scale(1.25); z-index: 10; box-shadow: 0 0 0 3px rgba(26, 115, 232, .55), 0 2px 6px rgba(0, 0, 0, .4); }
.legend .pin { position: relative; left: auto; bottom: auto; transform: none; margin-right: 10px; vertical-align: middle; }
.ldot { position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 7px; border: 2px solid #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .4); cursor: pointer; }
.ldot.g { background: var(--green); } .ldot.a { background: #e37400; } .ldot.r { background: var(--red); } .ldot.n { background: #80868b; } .ldot.priv { background: #fff; border-color: #9aa0a6; }
.dot { position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 5px; border: 1.5px solid #fff; box-shadow: 0 0 1px rgba(0, 0, 0, .6); }
.legend .dot { position: relative; left: auto; top: auto; display: inline-block; margin-right: 4px; vertical-align: middle; }
.dot.free { background: #34a853; } .dot.occ { background: #ea4335; } .dot.unk { background: #9aa0a6; } .dot.off { background: #3c4043; }
.me { position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 9px; background: var(--blue); border: 3px solid #fff; box-shadow: 0 0 0 7px rgba(26, 115, 232, .2), 0 1px 3px rgba(0, 0, 0, .4); }
.spin { position: absolute; left: -13px; bottom: 0; width: 26px; height: 36px; }

/* 說明視窗、提示 */
.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(0, 0, 0, .45); display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--bg); border-radius: 16px; padding: 20px; max-width: 440px; width: 100%; max-height: 86vh; overflow: auto; }
.modal-card h2 { margin: 0 0 12px; font-size: 19px; }
.modal-card h3 { margin: 16px 0 6px; font-size: 15px; }
.modal-card ul { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.7; color: var(--sub); }
.legend div { display: flex; align-items: center; font-size: 14px; min-height: 36px; }
.btn { margin-top: 16px; width: 100%; height: 44px; border-radius: 22px; border: 0; background: var(--blue); color: #fff; font-size: 15px; font-weight: 600; }
.toast { position: fixed; left: 50%; top: calc(112px + var(--safe-t)); transform: translateX(-50%); z-index: 3000; background: #323232; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; max-width: calc(100vw - 32px); box-shadow: var(--shadow); }

/* Leaflet 暫代地圖 */
.leaflet-container { background: #e8eaed; font-family: inherit; }
.leaflet-div-icon.mk, .leaflet-marker-icon.mk { background: none; border: 0; }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-bottom { bottom: var(--sheet-h); transition: bottom .25s; }

@media (min-width: 700px) {
  .sheet { left: 10px; bottom: 10px; top: auto; border-radius: 18px; max-height: calc(100vh - 140px); }
}
