/* 長照機構選擇器 — 樣式
   色彩：中性暖灰底 + 單一藍色序列（選擇題用）；機構類型用色盲驗證過的三色 + 形狀。
   深淺主題用 CSS 變數；地圖分級色用 class，換主題不需重畫。 */

:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #fcfcfb;
  --surface2: #f7f6f2;
  --ink: #0b0b0b;
  --ink2: #52514e;
  --ink3: #6b6a65;
  --line: #e1e0d9;
  --line2: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-soft: #e6f0fc;
  --focus: #1c5cab;
  --brand: #1c5cab;
  --s0: #cde2fb; --s1: #86b6ef; --s2: #3987e5; --s3: #1c5cab; --s4: #0d366b;
  --flag: #eb6834;            /* 「無住宿機構」標示用（橘） */
  --flag-ink: #a63d11;
  --neutral: #ebeae4;         /* 無資料／未納入 */
  --hatch: #8f8e87;
  --c-elder: #2a78d6; --c-nh: #eb6834; --c-ltcres: #1baf7a;
  --c-home: #e87ba4; --c-comm: #4a3aa7; --c-comp: #eda100; --c-hn: #008300; --c-pp: #898781;
  --good: #006300; --bad: #b32424; --warnc: #8a5a00;
  --shadow: 0 1px 2px rgba(11,11,11,.06), 0 8px 24px rgba(11,11,11,.06);
  --r: 12px;
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d; --surface: #1a1a19; --surface2: #222221;
    --ink: #ffffff; --ink2: #c3c2b7; --ink3: #a3a29b;
    --line: #2c2c2a; --line2: #383835;
    --accent: #3987e5; --accent-ink: #6da7ec; --accent-soft: #14233a; --focus: #8fbdf2; --brand: #6da7ec;
    --s0: #0d366b; --s1: #184f95; --s2: #2a78d6; --s3: #6da7ec; --s4: #b7d3f6;
    --flag: #d95926; --flag-ink: #f0a07e; --neutral: #262625; --hatch: #77766f;
    --c-elder: #3987e5; --c-nh: #d95926; --c-ltcres: #199e70;
    --c-home: #d55181; --c-comm: #9085e9; --c-comp: #c98500; --c-hn: #1f9f1f; --c-pp: #898781;
    --good: #5fd35f; --bad: #ff8f8f; --warnc: #f0b84a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d; --surface: #1a1a19; --surface2: #222221;
  --ink: #ffffff; --ink2: #c3c2b7; --ink3: #a3a29b;
  --line: #2c2c2a; --line2: #383835;
  --accent: #3987e5; --accent-ink: #6da7ec; --accent-soft: #14233a; --focus: #8fbdf2; --brand: #6da7ec;
  --s0: #0d366b; --s1: #184f95; --s2: #2a78d6; --s3: #6da7ec; --s4: #b7d3f6;
  --flag: #d95926; --flag-ink: #f0a07e; --neutral: #262625; --hatch: #77766f;
  --c-elder: #3987e5; --c-nh: #d95926; --c-ltcres: #199e70;
  --c-home: #d55181; --c-comm: #9085e9; --c-comp: #c98500; --c-hn: #1f9f1f; --c-pp: #898781;
  --good: #5fd35f; --bad: #ff8f8f; --warnc: #f0b84a;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}

/* 每個地圖指標各用一組單色相序列色階（床位密度沿用上方藍色）；UI 強調色跟著指標換 */
:root[data-metric="occ"] { --s0: #fee1d1; --s1: #f5af84; --s2: #df7a32; --s3: #ab5202; --s4: #713401; --accent: #df7a32; --accent-ink: #ab5202; --accent-soft: #fdf0e8; }
:root[data-metric="old"] { --s0: #ebe3ff; --s1: #cbb2f8; --s2: #a780e6; --s3: #7c58b3; --s4: #523779; --accent: #a780e6; --accent-ink: #7c58b3; --accent-soft: #f4effe; }
:root[data-metric="hc"] { --s0: #cef0ec; --s1: #82d2ca; --s2: #02afa6; --s3: #0a8079; --s4: #04534e; --accent: #02afa6; --accent-ink: #0a8079; --accent-soft: #e8f7f5; }
:root[data-metric="none"] { --s0: #ffdfde; --s1: #fba7a6; --s2: #e66d71; --s3: #b1464c; --s4: #78292e; --accent: #e66d71; --accent-ink: #b1464c; --accent-soft: #fdeeee; --flag: #e66d71; --flag-ink: #a3343a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-metric="occ"] { --s0: #713401; --s1: #ab5202; --s2: #df7a32; --s3: #f5af84; --s4: #fee1d1; --accent: #df7a32; --accent-ink: #f5af84; --accent-soft: #2e1d10; }
  :root:not([data-theme="light"])[data-metric="old"] { --s0: #523779; --s1: #7c58b3; --s2: #a780e6; --s3: #cbb2f8; --s4: #ebe3ff; --accent: #a780e6; --accent-ink: #cbb2f8; --accent-soft: #221a33; }
  :root:not([data-theme="light"])[data-metric="hc"] { --s0: #04534e; --s1: #0a8079; --s2: #02afa6; --s3: #82d2ca; --s4: #cef0ec; --accent: #02afa6; --accent-ink: #82d2ca; --accent-soft: #0e2826; }
  :root:not([data-theme="light"])[data-metric="none"] { --s0: #78292e; --s1: #b1464c; --s2: #e66d71; --s3: #fba7a6; --s4: #ffdfde; --accent: #e66d71; --accent-ink: #fba7a6; --accent-soft: #301617; --flag: #e66d71; --flag-ink: #fba7a6; }
}
:root[data-theme="dark"][data-metric="occ"] { --s0: #713401; --s1: #ab5202; --s2: #df7a32; --s3: #f5af84; --s4: #fee1d1; --accent: #df7a32; --accent-ink: #f5af84; --accent-soft: #2e1d10; }
:root[data-theme="dark"][data-metric="old"] { --s0: #523779; --s1: #7c58b3; --s2: #a780e6; --s3: #cbb2f8; --s4: #ebe3ff; --accent: #a780e6; --accent-ink: #cbb2f8; --accent-soft: #221a33; }
:root[data-theme="dark"][data-metric="hc"] { --s0: #04534e; --s1: #0a8079; --s2: #02afa6; --s3: #82d2ca; --s4: #cef0ec; --accent: #02afa6; --accent-ink: #82d2ca; --accent-soft: #0e2826; }
:root[data-theme="dark"][data-metric="none"] { --s0: #78292e; --s1: #b1464c; --s2: #e66d71; --s3: #fba7a6; --s4: #ffdfde; --accent: #e66d71; --accent-ink: #fba7a6; --accent-soft: #301617; --flag: #e66d71; --flag-ink: #fba7a6; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.6 var(--font); -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 50; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; }
.skip:focus { top: 8px; }

/* ---------- 頂欄 ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 20px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { width: 34px; height: 34px; flex: none; }
.logo rect { fill: var(--brand); } .logo path, .logo circle { fill: var(--surface); }
.logo circle { fill: var(--brand); }
.brand h1 { white-space: nowrap; font-size: 18px; font-weight: 700; letter-spacing: .04em; line-height: 1.2; }
.tagline { font-size: 12px; color: var(--ink3); letter-spacing: .02em; }
.topnav { display: flex; align-items: center; gap: 4px; flex: none; }
.topnav a { color: var(--ink2); text-decoration: none; padding: 7px 12px; border-radius: 8px; font-weight: 500; }
.topnav a:hover { background: var(--surface); color: var(--ink); }
.iconbtn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line2); background: var(--surface); border-radius: 999px; padding: 5px 12px 5px 10px; cursor: pointer; color: var(--ink2); }
.iconbtn:hover { color: var(--ink); border-color: var(--ink3); }
.iconbtn svg { width: 16px; height: 16px; fill: currentColor; }

/* ---------- 主版面 ---------- */
.app {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 440px); gap: 16px;
  padding: 16px 20px 24px; max-width: 1680px; margin: 0 auto;
  height: calc(100vh - 62px); min-height: 640px; outline: none;
}
.mapPanel, .side {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); min-height: 0;
}
.mapPanel { display: flex; flex-direction: column; overflow: hidden; }
.mapBar { padding: 14px 16px 6px; }
.metrics { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: thin; }
.metrics label { flex: none; position: relative; }
.metrics input { position: absolute; opacity: 0; pointer-events: none; }
.metrics span {
  display: block; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line2); cursor: pointer;
  color: var(--ink2); font-weight: 500; white-space: nowrap; background: var(--surface); user-select: none;
}
.metrics label:hover span { border-color: var(--ink3); color: var(--ink); }
.metrics input:checked + span { background: var(--accent-ink); border-color: var(--accent-ink); color: var(--surface); }
:root[data-theme="dark"] .metrics input:checked + span { color: #06101c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .metrics input:checked + span { color: #06101c; } }
.metrics input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.metricDesc { font-size: 12.5px; color: var(--ink3); max-width: 70ch; }
.crumbs { display: flex; align-items: center; gap: 4px; padding: 4px 16px 6px; min-height: 36px; flex-wrap: wrap; }
.crumbs button, .crumbs span.cur {
  border: 0; background: none; padding: 4px 8px; border-radius: 6px; font-weight: 600; cursor: pointer; color: var(--accent-ink);
}
.crumbs button:hover { background: var(--accent-soft); }
.crumbs span.cur { color: var(--ink); cursor: default; }
.crumbs .sep { color: var(--ink3); }
.mapWrap { position: relative; flex: 1; min-height: 360px; margin: 0 8px; border-radius: 10px; background: var(--surface2); border: 1px solid var(--line); overflow: hidden; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: manipulation; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink3); background: var(--surface2); }
.zoomBtns { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 4px; }
.zoomBtns button {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line2); background: var(--surface);
  color: var(--ink2); font-size: 18px; line-height: 1; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.zoomBtns button:hover { color: var(--ink); border-color: var(--ink3); }

/* 地圖元素 */
.rg { vector-effect: non-scaling-stroke; stroke: var(--surface); stroke-width: 1; stroke-linejoin: round; cursor: pointer; transition: fill .15s; }
.rg.ctx { fill: var(--neutral); pointer-events: none; stroke: var(--surface); }
.rg:hover { stroke: var(--ink); stroke-width: 1.8; }
.rg.sel { stroke: var(--ink); stroke-width: 2.4; }
.rg:focus-visible { outline: none; stroke: var(--focus); stroke-width: 3; }
.rg.nodata { fill: var(--neutral); }
.rg.small { fill: url(#hatch); }
.rg.flag { fill: var(--flag); }
.rg.b0 { fill: var(--s0); } .rg.b1 { fill: var(--s1); } .rg.b2 { fill: var(--s2); } .rg.b3 { fill: var(--s3); } .rg.b4 { fill: var(--s4); }
.pts-on .rg:not(.ctx) { fill-opacity: .7; }
.pts-on .rg.flag { fill-opacity: .7; }
.winframe { fill: var(--surface); stroke: var(--line2); }
.wintitle { font-size: 11.5px; font-weight: 600; fill: var(--ink2); }
.winnote { font-size: 10.5px; fill: var(--ink3); }
.lbl { font-size: 11px; fill: var(--ink); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; pointer-events: none; font-weight: 500; }
.lbl.mini { font-size: 10.5px; fill: var(--ink2); }
.farland { fill: var(--neutral); stroke: var(--line2); stroke-width: .6; }
.farpt { fill: var(--surface); stroke: var(--ink2); stroke-width: 1.6; }
.hatchline { stroke: var(--hatch); stroke-width: 1.2; }
.hatchbg { fill: var(--neutral); }
.pt { stroke: var(--surface); stroke-width: 1.2; cursor: pointer; }
.pt:hover { stroke: var(--ink); stroke-width: 1.8; }
.pt.dim { opacity: .28; }
.ptsel { fill: none; stroke: var(--ink); stroke-width: 2.4; pointer-events: none; }
.ptsel2 { fill: none; stroke: var(--surface); stroke-width: 5; pointer-events: none; }
.t-elder { fill: var(--c-elder); } .t-nh { fill: var(--c-nh); } .t-ltcres { fill: var(--c-ltcres); }
.t-home { fill: var(--c-home); } .t-comm { fill: var(--c-comm); } .t-comp { fill: var(--c-comp); }
.t-hn { fill: var(--c-hn); } .t-pp { fill: var(--c-pp); }

/* 圖例 */
.legend { padding: 10px 16px 14px; display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: flex-start; font-size: 12.5px; color: var(--ink2); }
.legend .ramp { display: flex; flex-direction: column; gap: 4px; }
.legend .ramp .bar { display: flex; gap: 2px; }
.legend .ramp .bar i { display: block; width: 66px; height: 10px; border-radius: 2px; }
.legend .ramp .ticks { display: flex; gap: 2px; font-size: 11.5px; color: var(--ink3); }
.legend .ramp .ticks span { width: 66px; text-align: center; line-height: 1.25; overflow-wrap: anywhere; }
.legend .ramp .name { font-weight: 600; color: var(--ink); }
.legend .keys { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .key i { width: 14px; height: 10px; border-radius: 2px; display: inline-block; border: 1px solid var(--line2); }
.legend .key i.hatch { background: repeating-linear-gradient(135deg, var(--hatch) 0 1.4px, var(--neutral) 1.4px 5px); }
.legend .key i.flag { background: var(--flag); border-color: var(--flag); }
.legend .key i.nd { background: var(--neutral); }
.tchips { display: flex; flex-wrap: wrap; gap: 6px; }
.tchip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 999px; border: 1px solid var(--line2); background: var(--surface); cursor: pointer; color: var(--ink2); font-size: 12.5px; }
.tchip[aria-pressed="true"] { border-color: var(--ink2); color: var(--ink); background: var(--surface2); font-weight: 600; }
.tchip[aria-pressed="false"] { opacity: .65; }
.tchip svg { width: 13px; height: 13px; overflow: visible; }
.tchip svg path { stroke: var(--surface); stroke-width: .8; }
.sizekey { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink3); }
.sizekey svg { display: block; }

/* ---------- 側欄 ---------- */
.side { display: flex; flex-direction: column; overflow: hidden; }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 6px 8px 0; gap: 4px; }
.tabs button {
  flex: 1; border: 0; background: none; padding: 10px 8px 12px; font-weight: 600; color: var(--ink3); cursor: pointer;
  border-radius: 8px 8px 0 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brand); }
.panel { overflow-y: auto; padding: 16px; flex: 1; outline: none; overscroll-behavior: contain; }
.panel h2 { font-size: 20px; line-height: 1.3; font-weight: 700; letter-spacing: .01em; }
.panel h3 { font-size: 13px; font-weight: 700; color: var(--ink2); margin: 20px 0 8px; letter-spacing: .06em; }
.panel .sub { color: var(--ink3); font-size: 12.5px; margin-top: 2px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.stat { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface2); min-width: 0; }
.stat.wide { grid-column: 1 / -1; }
.stat .k { font-size: 12px; color: var(--ink3); }
.stat .v { font-size: 22px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .v small { font-size: 12.5px; font-weight: 500; color: var(--ink3); margin-left: 3px; letter-spacing: 0; }
.stat .n { font-size: 12px; color: var(--ink3); margin-top: 2px; }
.stat.active { border-color: var(--accent-ink); background: var(--accent-soft); }
.note { font-size: 12.5px; color: var(--ink2); background: var(--surface2); border: 1px solid var(--line); padding: 10px 12px; border-radius: 8px; margin-top: 10px; }
.note.warn { border-color: var(--flag); }
.tag { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 6px; padding: 2px 8px; border: 1px solid var(--line2); color: var(--ink2); background: var(--surface); vertical-align: 1px; }
.tag.flag { border-color: var(--flag); color: var(--flag-ink); }

/* 排名圖 */
.rank { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; border-top: 1px solid var(--line); }
.rank li { border-bottom: 1px solid var(--line); }
.rank button {
  display: grid; grid-template-columns: 5.4em minmax(0, 1fr) 4.6em; align-items: center; gap: 8px; width: 100%;
  text-align: left; border: 0; background: none; padding: 5px 4px; cursor: pointer; border-radius: 6px;
}
.rank button:hover { background: var(--surface2); }
.rank .nm { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank .tr { height: 12px; position: relative; }
.rank .bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 2px; }
.rank .bar.small { background: repeating-linear-gradient(135deg, var(--hatch) 0 1.4px, var(--neutral) 1.4px 5px); }
.rank .val { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.rank li.sel button { background: var(--accent-soft); }
.rank li.sel .nm { font-weight: 700; }
.rank li.sel .bar { background: var(--accent-ink); }
.rank li.sep-note { padding: 6px 4px; font-size: 12px; color: var(--ink3); border-bottom: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; color: var(--ink3); font-size: 12px; padding: 4px 6px 4px 0; }
.tbl td { padding: 5px 6px 5px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; vertical-align: top; }
.tbl td.r, .tbl th.r { text-align: right; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent-ink); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
details.pl { margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
details.pl summary { cursor: pointer; font-weight: 600; }

/* 查詢 */
.sform { display: grid; gap: 10px; }
.sform label.lb { font-size: 12px; color: var(--ink3); display: block; margin-bottom: 3px; font-weight: 600; letter-spacing: .04em; }
.sform input[type=search], .sform select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line2); border-radius: 8px; background: var(--surface); min-height: 40px;
}
.sform input[type=search]:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sform .tchips .tchip { padding: 5px 10px 5px 8px; }
.results { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--line); }
.results li { border-bottom: 1px solid var(--line); }
.results button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 6px; cursor: pointer; border-radius: 6px; }
.results button:hover { background: var(--surface2); }
.results .t1 { display: flex; gap: 8px; align-items: flex-start; font-weight: 600; line-height: 1.4; }
.results .t1 svg { flex: none; width: 13px; height: 13px; margin-top: 4px; overflow: visible; }
.results .t2 { color: var(--ink3); font-size: 12.5px; margin-left: 21px; }
.count { font-size: 12.5px; color: var(--ink3); margin-top: 12px; }
.more { margin-top: 10px; width: 100%; padding: 9px; border: 1px solid var(--line2); border-radius: 8px; background: var(--surface); cursor: pointer; font-weight: 600; }
.more:hover { border-color: var(--ink3); }
.empty { padding: 20px 4px; color: var(--ink3); }

/* 機構卡片 */
.back { border: 0; background: none; color: var(--accent-ink); cursor: pointer; padding: 4px 6px 4px 0; font-weight: 600; margin-bottom: 8px; }
.card h2 { margin-bottom: 6px; }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }
.card dl { margin: 12px 0 0; display: grid; grid-template-columns: 4.2em minmax(0, 1fr); gap: 8px 10px; }
.card dt { color: var(--ink3); font-size: 12.5px; padding-top: 1px; }
.card dd { margin: 0; overflow-wrap: anywhere; }
.blk { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 14px; background: var(--surface2); }
.blk h3 { margin: 0 0 6px; }
.blk .big { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 700; padding: 1px 9px; border-radius: 6px; border: 1px solid currentColor; }
.badge.ok { color: var(--good); } .badge.no { color: var(--bad); } .badge.mid { color: var(--warnc); } .badge.na { color: var(--ink3); }
.blk p { font-size: 13px; color: var(--ink2); margin-top: 6px; }
.blk ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink2); }
.src { font-size: 12px; color: var(--ink3); margin-top: 16px; border-top: 1px solid var(--line); padding-top: 10px; }

/* ---------- 資料說明 ---------- */
.about { padding: 32px 20px 24px; }
.aboutInner { max-width: 1100px; margin: 0 auto; }
.about h2 { font-size: 24px; margin-bottom: 10px; letter-spacing: .02em; }
.about .lead { max-width: 70ch; color: var(--ink2); font-size: 15px; margin-bottom: 18px; }
.about h3 { font-size: 16px; margin: 28px 0 10px; }
.dsgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 12px; }
.ds { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.ds h4 { font-size: 14.5px; line-height: 1.45; margin-bottom: 6px; }
.ds dl { margin: 0; display: grid; grid-template-columns: 4.6em minmax(0, 1fr); gap: 3px 8px; font-size: 13px; }
.ds dt { color: var(--ink3); } .ds dd { margin: 0; overflow-wrap: anywhere; }
.ds ul { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink2); }
.ds ul li { margin-top: 3px; }
.caveats { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 18px 14px; }
.caveats li { margin-top: 8px; }
.foot { text-align: center; color: var(--ink3); font-size: 12.5px; padding: 8px 20px calc(28px + env(safe-area-inset-bottom, 0px)); }
.noscript { padding: 20px; text-align: center; }

/* 浮動提示 */
.tip {
  position: fixed; z-index: 40; pointer-events: none; max-width: 280px; font-size: 12.5px; line-height: 1.5;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line2); border-radius: 10px; padding: 8px 11px;
  box-shadow: var(--shadow);
}
.tip b { font-size: 13.5px; }
.tip .tv { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tip .tm { color: var(--ink3); }

/* ---------- 響應式 ---------- */
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; height: auto; min-height: 0; padding: 12px 12px 20px; }
  .mapWrap { height: min(78vh, 640px); min-height: 420px; flex: none; }
  .side { overflow: visible; }
  .panel { overflow: visible; }
  .rank { max-height: 320px; }
  .top { padding-left: 14px; padding-right: 14px; }
  .about { padding-left: 14px; padding-right: 14px; }
}
@media (max-width: 520px) {
  .tagline { display: none; }
  .brand h1 { font-size: 16px; letter-spacing: .02em; }
  .topnav a:first-of-type { display: none; }
  .logo { width: 30px; height: 30px; }
  .topnav a { padding: 7px 8px; }
  .iconbtn span { display: none; }
  .iconbtn { padding: 6px 8px; }
  .mapBar { padding: 12px 10px 4px; }
  .crumbs, .legend { padding-left: 10px; padding-right: 10px; }
  .mapWrap { margin: 0 6px; min-height: 480px; }
  .legend .ramp .bar i, .legend .ramp .ticks span { width: 54px; }
  .legend .ramp .ticks { font-size: 10.5px; }
  .row2 { grid-template-columns: 1fr; }
}
@media (forced-colors: active) {
  .rg { stroke: CanvasText; }
  .rg.small { fill: Canvas; }
}

/* 資料來源列與來源表 */
.datastrip { margin: 0; padding: 8px max(16px, env(safe-area-inset-left, 0px)); font-size: 12.5px; line-height: 1.6; color: var(--ink2); background: var(--surface2); border-bottom: 1px solid var(--line); }
.datastrip a { color: var(--brand); font-weight: 600; white-space: nowrap; }
.dsnote { font-size: 14px; color: var(--ink2); margin: 0 0 10px; }
.tblwrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.srcTbl { width: 100%; min-width: 760px; margin: 0; }
.srcTbl th, .srcTbl td { padding: 8px 12px; vertical-align: top; text-align: left; font-size: 13px; }
.srcTbl .nw { white-space: nowrap; }
#sources, #about { scroll-margin-top: 84px; }
