:root {
  --text: #1a1a18;
  --text-2: #5f5e5a;
  --text-3: #8a8983;
  --border: #e8e6e0;
  --border-2: #d3d1c7;
  --surface: #ffffff;
  --surface-1: #f7f6f3;
  --accent: #0f6e56;
  --accent-bg: #e1f5ee;
  --brand: #1d9e75;
  --utg: #378add;
  --utg-bg: #e6f1fb;
  --utg-text: #0c447c;
  --cm: #ef9f27;
  --cm-bg: #faeeda;
  --cm-text: #633806;
  --dodo: #d5487f;
  --dodo-bg: #fbe6ef;
  --dodo-text: #7a1f47;
  --tps: #6b57c8;
  --tps-bg: #ece8fa;
  --tps-text: #362a6e;
  --vivi: #0f8ea8;
  --vivi-bg: #e0f4f8;
  --vivi-text: #07505f;
  --pks: #b9553b;
  --pks-bg: #f8e8e2;
  --pks-text: #6e2a17;
  --warn-bg: #faeeda;
  --warn-text: #854f0b;
  --nav-h: 76px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background: var(--surface);
  display: flex;
  flex-direction: column;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.app-header { flex-shrink: 0; border-bottom: 0.5px solid var(--border); background: var(--surface); }
.header-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 8px; }
.header-brand { display: flex; align-items: center; gap: 8px; }
.header-brand .logo { width: 26px; height: 26px; border-radius: 7px; }
.header-brand .logo, .picker-greeting svg, .empty svg, .share-hero svg { stroke: none; }
.header-row h1 { font-size: 17px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 6px; }
.data-date { font-size: 12px; color: var(--text-3); }
.icon-btn { width: 36px; height: 36px; margin-right: -6px; display: flex; align-items: center; justify-content: center; color: var(--text-2); }
.icon-btn svg { font-size: 20px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000; display: flex; align-items: flex-end; }
.modal-sheet { background: var(--surface); border-radius: 16px 16px 0 0; width: 100%; max-height: 80%; overflow-y: auto; padding: 0 16px calc(20px + env(safe-area-inset-bottom)); transition: transform .18s ease; }
.modal-sheet h2 { font-size: 15px; font-weight: 600; padding: 4px 0 8px; }
.settings-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px 2px; border-bottom: 0.5px solid var(--border); }
.settings-row:disabled { opacity: .55; }
.settings-row .s-icon { width: 40px; height: 40px; border-radius: 11px; background: var(--accent-bg); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.settings-row .s-icon svg { font-size: 21px; }
.settings-row .s-text { flex: 1; min-width: 0; }
.settings-row .s-text b { font-size: 15px; font-weight: 500; display: block; }
.settings-row .s-text small { font-size: 12px; color: var(--text-2); }
.settings-row .s-chev { color: var(--text-3); flex-shrink: 0; }
.settings-row .s-chev svg { font-size: 18px; }
.install-hint { font-size: 13px; color: var(--text-2); line-height: 1.7; padding: 12px 14px; background: var(--accent-bg); border-radius: 10px; margin-top: 10px; }
.install-hint svg { font-size: 15px; color: var(--accent); vertical-align: -2px; margin: 0 1px; }
.settings-links { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 2px 4px; }
.settings-links a { font-size: 12.5px; color: var(--accent); background: var(--accent-bg); padding: 5px 11px; border-radius: 999px; text-decoration: none; }
.settings-links a:first-child { flex-basis: 100%; text-align: center; }
.settings-meta { font-size: 12px; color: var(--text-3); text-align: center; padding: 16px 0 2px; }

/* 分享 */
.share-hero { display: flex; justify-content: center; padding: 8px 0 4px; }
.share-hero svg { width: 92px; height: auto; }
.share-title { font-size: 17px; font-weight: 600; text-align: center; padding: 2px 0 0; }
.share-sub { font-size: 13px; color: var(--text-2); text-align: center; line-height: 1.6; margin-top: 4px; }
.share-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.share-native, .share-copy { height: 48px; border-radius: 24px; font-size: 15px; font-weight: 500; }
.share-native { background: var(--accent); color: #fff; }
.share-copy { border: 0.5px solid var(--border-2); color: var(--text); }
.share-qr-wrap { text-align: center; margin-top: 18px; padding-top: 16px; border-top: 0.5px solid var(--border); }
.share-qr { display: flex; justify-content: center; }
.share-qr svg { width: 150px; height: 150px; }
.share-qr-cap { font-size: 12px; color: var(--text-3); margin-top: 8px; }
#share-done { text-align: center; padding-bottom: 4px; }
#share-done .share-copy { margin-top: 16px; }

/* 商業化好康彈窗（點 pill 後的圖文說明，主 CTA 才外連） */
.offer-sheet { position: relative; }
.offer-close { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; color: var(--text-3); background: rgba(255,255,255,.7); border-radius: 50%; z-index: 1; }
.offer-close svg { font-size: 17px; }
.offer-hero { display: flex; justify-content: center; padding-top: 4px; }
.offer-hero img { height: 200px; width: auto; max-width: 100%; display: block; border-radius: 12px; }
.offer-title { font-size: 18px; font-weight: 700; text-align: center; padding: 14px 0 0; }
.offer-sub { font-size: 13px; color: var(--text-2); text-align: center; line-height: 1.6; margin-top: 6px; }
.offer-tiers { margin-top: 14px; border: 0.5px solid var(--border); border-radius: 12px; overflow: hidden; }
.offer-tier { display: flex; align-items: baseline; gap: 8px; padding: 11px 14px; border-bottom: 0.5px solid var(--border); }
.offer-tier:last-child { border-bottom: 0; }
.offer-tier .t-name { font-size: 14px; color: var(--text); flex: 1; }
.offer-tier .t-price { font-size: 15px; font-weight: 700; color: var(--accent); }
.offer-tier .t-save { font-size: 12px; color: var(--text-3); }
.offer-cta { text-decoration: none; display: flex; align-items: center; justify-content: center; }
.offer-note { font-size: 11px; color: var(--text-3); text-align: center; line-height: 1.6; margin-top: 10px; }

/* 桌機軟性提示 */
.desktop-hint {
  flex-shrink: 0; display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; background: var(--accent-bg); color: var(--accent);
  font-size: 13px; border-bottom: 0.5px solid var(--border);
}
.desktop-hint .dh-text { flex: 1; }
.desktop-hint .dh-qr { color: var(--accent); font-weight: 600; font-size: 13px; padding: 4px 8px; }
.desktop-hint .dh-close { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; color: var(--accent); }
.desktop-hint .dh-close svg { font-size: 16px; }

.chips { display: flex; gap: 8px; padding: 8px 16px 10px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  font-size: 13px; padding: 8px 14px; min-height: 36px;
  border: 0.5px solid var(--border-2); border-radius: 8px; color: var(--text-2);
}
.chip svg { font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--accent); font-weight: 500; }
/* 商業化好康：靠右、實心綠 pill，與左側篩選工具做出區隔 */
.offer-chip {
  display: inline-flex; align-items: center; flex-shrink: 0;
  margin-left: auto; position: relative; padding-left: 14px;
  font-size: 13px; font-weight: 600; padding: 8px 14px; min-height: 36px;
  background: var(--accent-bg); color: var(--accent); border-radius: 999px; white-space: nowrap;
  animation: offer-hint 6s ease-in-out 2s infinite;
}
.offer-chip::before { content: ""; position: absolute; left: -8px; top: 6px; bottom: 6px; width: 0.5px; background: var(--border-2); }
.offer-chip .offer-ic { width: 16px; height: 16px; margin-right: 5px; flex-shrink: 0; }
/* 偶爾閃一下提示：安靜約 4 秒後連閃兩下（放大＋綠色光暈＋較深底），較明顯但不長時間干擾 */
@keyframes offer-hint {
  0%, 62%, 100% { transform: scale(1); background: var(--accent-bg); box-shadow: 0 0 0 0 rgba(29,158,117,0); }
  70% { transform: scale(1.07); background: #a9e0cd; box-shadow: 0 0 0 6px rgba(29,158,117,.38); }
  78% { transform: scale(1); background: var(--accent-bg); box-shadow: 0 0 0 0 rgba(29,158,117,0); }
  86% { transform: scale(1.07); background: #a9e0cd; box-shadow: 0 0 0 6px rgba(29,158,117,.38); }
  94% { transform: scale(1); background: var(--accent-bg); box-shadow: 0 0 0 0 rgba(29,158,117,0); }
}
@media (prefers-reduced-motion: reduce) { .offer-chip { animation: none; } }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-utg { background: var(--utg); }
.dot-cm { background: var(--cm); }
.dot-dodo { background: var(--dodo); }
.dot-tps { background: var(--tps); }
.dot-vivi { background: var(--vivi); }
.dot-pks { background: var(--pks); }

.status-row {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 16px; font-size: 12px; color: var(--text-2); background: var(--surface-1);
}
#loc-retry { margin-left: auto; flex-shrink: 0; color: var(--accent); font-weight: 500; font-size: 12px; padding: 4px 0 4px 10px; }
.status-row:empty { display: none; }
.status-row svg { font-size: 14px; color: var(--accent); flex-shrink: 0; }

#main { flex: 1; overflow: hidden; position: relative; }
.view { height: 100%; overflow-y: auto; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
#view-map { overflow: hidden; padding-bottom: 0; position: relative; }
#map { position: absolute; inset: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 0; }

.card { border-bottom: 0.5px solid var(--border); padding: 12px 14px; position: relative; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.badges { display: flex; gap: 5px; flex-wrap: wrap; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 4px; }
.badge-utg { background: var(--utg-bg); color: var(--utg-text); }
.badge-cm { background: var(--cm-bg); color: var(--cm-text); }
.badge-dodo { background: var(--dodo-bg); color: var(--dodo-text); }
.badge-tps { background: var(--tps-bg); color: var(--tps-text); }
.badge-vivi { background: var(--vivi-bg); color: var(--vivi-text); }
.badge-pks { background: var(--pks-bg); color: var(--pks-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }

.card-main { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-info { min-width: 0; flex: 1; }
.card-name { font-size: 15px; font-weight: 500; }
.card-addr { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.card-addr-missing { display: flex; align-items: center; gap: 4px; color: var(--warn-text); }
.card-addr-missing svg { font-size: 14px; flex-shrink: 0; }
.card-label { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.card-warn-text { font-size: 12px; color: var(--warn-text); margin-top: 4px; }
.nav-go { text-align: center; flex-shrink: 0; }
.nav-go button {
  width: 48px; height: 48px; border-radius: 50%; background: var(--accent-bg); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.nav-go button svg { font-size: 22px; }
.nav-go .dist { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-top: 2px; }
.nav-go .dist.near { color: var(--accent); }

.card-detail { margin-top: 10px; padding-top: 10px; border-top: 0.5px solid var(--border); }
.detail-note { display: flex; gap: 6px; font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.detail-note svg { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.detail-actions { display: flex; gap: 8px; }
.detail-actions button, .detail-actions a {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
  font-size: 13px; height: 40px; border: 0.5px solid var(--border-2); border-radius: 20px;
  color: var(--text); text-decoration: none;
}
.detail-actions svg { font-size: 15px; }
.detail-actions button.on { background: var(--cm-bg); border-color: #fac775; color: var(--cm-text); }
.detail-actions button.on svg { fill: #fac775; stroke: #ba7517; }
@keyframes star-pop { 0% { transform: scale(1); } 50% { transform: scale(1.18); } 100% { transform: scale(1); } }
.detail-actions button.pop { animation: star-pop .25s ease; }
.detail-meta { font-size: 12px; color: var(--text-3); margin-top: 8px; }
.report-context {
  font-size: 12.5px; color: var(--text-3); text-align: center; margin-top: 12px;
}

.group-head {
  padding: 10px 16px 6px; font-size: 13px; font-weight: 600; color: var(--text-2);
  background: var(--surface-1); position: sticky; top: 0; z-index: 1;
}
.empty { padding: 40px 32px; text-align: center; color: var(--text-3); font-size: 13px; line-height: 1.7; }
.empty svg { width: 96px; height: auto; }
.empty .empty-title { font-size: 14px; color: var(--text-2); margin: 10px 0 2px; }
.load-more { display: block; width: calc(100% - 32px); margin: 12px 16px; height: 44px; border: 0.5px solid var(--border-2); border-radius: 22px; font-size: 14px; color: var(--text-2); }

.locate-btn {
  position: absolute; right: 12px; bottom: calc(var(--nav-h) + 96px + env(safe-area-inset-bottom));
  width: 48px; height: 48px; border-radius: 14px; background: var(--surface);
  border: 0.5px solid var(--border); box-shadow: 0 2px 8px rgba(0,0,0,.12);
  display: flex; align-items: center; justify-content: center; color: var(--accent); z-index: 500;
}
.locate-btn svg { font-size: 22px; }
.locate-btn.is-pending { color: var(--text-3); }
.locate-btn.is-pending svg { animation: loc-spin .9s linear infinite; }
.locate-btn.is-error { color: var(--warn, #d9624b); }
.locate-btn.is-error::after {
  content: "!"; position: absolute; top: -3px; right: -3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--warn, #d9624b); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 16px; text-align: center;
}
@keyframes loc-spin { to { transform: rotate(360deg); } }

.loc-steps { margin: 4px 0 14px; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.loc-steps li { font-size: 13px; color: var(--text); line-height: 1.55; }
.loc-help-dismiss { display: block; width: 100%; margin-top: 10px; padding: 8px; font-size: 13px; color: var(--text-3); }

.sheet {
  position: absolute; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  background: var(--surface); border-radius: 16px 16px 0 0;
  border: 0.5px solid var(--border); border-bottom: none;
  box-shadow: 0 -4px 16px rgba(0,0,0,.10); z-index: 600;
  max-height: 60%; overflow-y: auto;
  transition: transform .18s ease;
}
.sheet-handle { padding: 6px 0 2px; display: flex; justify-content: center; }
.sheet-handle span { width: 32px; height: 4px; border-radius: 2px; background: var(--border-2); }
.sheet .card { border-bottom: none; }
.sheet-close {
  position: absolute; top: 2px; right: 2px; width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center; color: var(--text-2); z-index: 1;
}
.sheet-close svg { font-size: 18px; }

.snackbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
  background: #2c2c2a; color: #f1efe8; border-radius: 8px; padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  font-size: 13px; z-index: 900; box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.snackbar button { color: #9fe1cb; font-weight: 600; font-size: 13px; padding: 4px 8px; margin: -4px -8px; }

.picker-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000; display: flex; align-items: flex-end; }
.picker-sheet {
  background: var(--surface); border-radius: 16px 16px 0 0; width: 100%;
  max-height: 70%; overflow-y: auto; padding: 0 16px calc(20px + env(safe-area-inset-bottom));
  transition: transform .18s ease;
}
.picker-sheet h2 { font-size: 15px; font-weight: 600; padding: 10px 0 12px; }
.picker-hint { font-size: 12px; color: var(--text-3); margin: -8px 0 12px; }
.picker-greeting { display: flex; align-items: flex-start; gap: 10px; padding: 16px 0 14px; }
.picker-greeting svg { width: 54px; height: auto; flex-shrink: 0; }
.picker-greeting .bubble { background: var(--accent-bg); border-radius: 12px 12px 12px 2px; padding: 9px 13px; }
.picker-greeting .bubble-title { font-size: 14px; font-weight: 600; color: #085041; }
.picker-greeting .bubble p:not(.bubble-title) { font-size: 12.5px; color: var(--accent); margin-top: 2px; line-height: 1.5; }
.picker-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.picker-grid button {
  height: 44px; border: 0.5px solid var(--border-2); border-radius: 10px; font-size: 14px; color: var(--text);
}
.picker-grid button.sel { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--accent); font-weight: 500; }

.brand-list { display: flex; flex-direction: column; gap: 8px; }
.brand-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  padding: 13px 14px; border: 0.5px solid var(--border-2); border-radius: 10px;
  font-size: 14px; color: var(--text); background: var(--surface);
}
.brand-opt.sel { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--accent); font-weight: 500; }
.brand-opt-label { display: flex; align-items: center; gap: 9px; }
.brand-opt .dot { width: 10px; height: 10px; }
.brand-opt .chk { width: 19px; height: 19px; flex-shrink: 0; opacity: 0; color: var(--accent); }
.brand-opt.sel .chk { opacity: 1; }
.brand-opt.brand-all { font-weight: 600; }

.navbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 800;
  display: flex; background: var(--surface); border-top: 0.5px solid var(--border);
  padding: 8px 0 calc(10px + env(safe-area-inset-bottom)); height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.nav-pill {
  width: 64px; height: 32px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center; color: var(--text-2);
}
.nav-pill svg { font-size: 20px; }
.nav-label { font-size: 12px; color: var(--text-2); }
.nav-item[aria-pressed="true"] .nav-pill { background: var(--accent-bg); color: var(--accent); }
.nav-item[aria-pressed="true"] .nav-label { color: var(--text); font-weight: 500; }

.user-loc { position: relative; width: 22px; height: 22px; }
.user-loc-dot {
  position: absolute; inset: 4px; border-radius: 50%;
  background: #378add; border: 2.5px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.user-loc-pulse {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(55,138,221,.45);
  animation: loc-pulse 2.2s ease-out infinite;
}
@keyframes loc-pulse {
  0% { transform: scale(.6); opacity: .9; }
  70% { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(2.2); opacity: 0; }
}

.pin-utg { --pin: var(--utg); }
.pin-cm { --pin: var(--cm); }
.pin-dodo { --pin: var(--dodo); }
.pin-tps { --pin: var(--tps); }
.pin-vivi { --pin: var(--vivi); }
.pin-pks { --pin: var(--pks); }
.lot-pin { background: var(--pin, #378add); width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); color: #fff; font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.lot-pin.sel { transform: scale(1.35); z-index: 10; }
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: rgba(29,158,117,.3) !important; }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div { background: #1d9e75 !important; color: #fff !important; }
