/* 天氣警報站 — 以官方「燈號」語彙為核心：實線＝官方警報，虛線＝網站估算 */
:root {
  --bg: #e8ecef;
  --panel: #f7f9fa;
  --panel-2: #dfe5ea;
  --ink: #1c2b3a;
  --ink-2: #4a5b6b;
  --ink-3: #6f7f8e;
  --line: #c9d2da;
  --sea: #246a8a;
  --sea-ink: #ffffff;
  --calm: #8fa3b4;
  --l1: #8fa3b4;   /* 資訊 */
  --l2: #e5b000;   /* 注意（黃燈） */
  --l3: #dd6b1f;   /* 警戒（橙燈） */
  --l4: #c42b2b;   /* 緊急（紅燈） */
  --ok: #2f7d4f;
  --warn-bg: #fff4d6;
  --err-bg: #fbe3e1;
  --demo: #6b3fa0;
  --radius: 6px;
  --num: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --sans: system-ui, -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color-scheme: light;
  --lvl2-ink: #9a7500;
  --lvl3-ink: #b4520f;
  --lvl4-ink: #c42b2b;
  --tile-filter: saturate(.25) contrast(.92) brightness(1.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111a22;
    --panel: #18232d;
    --panel-2: #213040;
    --ink: #e4ebf1;
    --ink-2: #b2c0cc;
    --ink-3: #8696a4;
    --line: #2d3d4c;
    --sea: #5aa9cc;
    --sea-ink: #0b1720;
    --calm: #5d7184;
    --l1: #5d7184;
    --warn-bg: #3a3110;
    --err-bg: #3d1a18;
    --demo: #b38be0;
    color-scheme: dark;
    --lvl2-ink: #e5b000;
    --lvl3-ink: #f08a44;
    --lvl4-ink: #ef6a6a;
    --tile-filter: grayscale(.8) invert(.92) hue-rotate(180deg) brightness(.9) contrast(.9);
  }
}
:root[data-theme="dark"] {
  --bg: #111a22;
  --panel: #18232d;
  --panel-2: #213040;
  --ink: #e4ebf1;
  --ink-2: #b2c0cc;
  --ink-3: #8696a4;
  --line: #2d3d4c;
  --sea: #5aa9cc;
  --sea-ink: #0b1720;
  --calm: #5d7184;
  --l1: #5d7184;
  --warn-bg: #3a3110;
  --err-bg: #3d1a18;
  --demo: #b38be0;
  color-scheme: dark;
  --lvl2-ink: #e5b000;
  --lvl3-ink: #f08a44;
  --lvl4-ink: #ef6a6a;
  --tile-filter: grayscale(.8) invert(.92) hue-rotate(180deg) brightness(.9) contrast(.9);
}


* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
}
a { color: var(--sea); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sea); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }

/* ---------- 版面 ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.top-inner, main, .foot { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.top-inner { display: flex; align-items: center; gap: 8px; height: 56px; }
.brand { font-weight: 800; font-size: 1.05rem; text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: 8px; margin-right: auto; }
.brand svg { width: 22px; height: 22px; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: transparent; color: var(--ink); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--panel-2); }
.icon-btn svg { width: 22px; height: 22px; }
.badge {
  position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--l4); color: #fff; font: 600 11px/18px var(--sans); text-align: center;
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 10px; max-width: 760px; margin: 0 auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); text-decoration: none; font-size: .9rem; white-space: nowrap;
}
.chip[aria-current="page"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--calm); }
.chip .dot.l2 { background: var(--l2); } .chip .dot.l3 { background: var(--l3); } .chip .dot.l4 { background: var(--l4); }

main { padding-top: 20px; padding-bottom: 48px; }
section + section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }

/* ---------- 燈號條（核心元件） ---------- */
.signals { display: grid; gap: 10px; }
.signal {
  display: grid; grid-template-columns: 8px 1fr; gap: 0 14px;
  background: var(--panel); border-radius: 0 var(--radius) var(--radius) 0;
  padding: 12px 14px 12px 0; text-decoration: none; color: inherit;
  border: 1px solid var(--line); border-left: 0;
}
.signal::before { content: ""; grid-row: 1 / span 9; background: var(--l1); border-radius: 0; }
.signal.l2::before { background: var(--l2); }
.signal.l3::before { background: var(--l3); }
.signal.l4::before { background: var(--l4); }
.signal.estimated { border-style: dashed; }
.signal.estimated::before { background: repeating-linear-gradient(180deg, var(--sig, var(--l1)) 0 10px, transparent 10px 15px); }
.signal.estimated.l2 { --sig: var(--l2); } .signal.estimated.l3 { --sig: var(--l3); }
.signal.estimated.l2::before, .signal.estimated.l3::before { background: repeating-linear-gradient(180deg, var(--sig) 0 10px, transparent 10px 15px); }
a.signal:hover { background: var(--panel-2); }
.signal .where { font-size: .85rem; color: var(--ink-2); }
.signal .what { font-weight: 700; font-size: 1.05rem; }
.signal .meta { font-size: .85rem; color: var(--ink-3); margin-top: 2px; }
.signal .desc { margin-top: 4px; color: var(--ink-2); font-size: .95rem; }
.tag { display: inline-block; font-size: .75rem; padding: 0 6px; border-radius: 3px; vertical-align: 2px; margin-left: 6px; border: 1px solid currentColor; font-weight: 600; }
.tag.official { color: var(--ink); }
.tag.estimated { color: var(--ink-3); border-style: dashed; }
.lvl { font-weight: 700; }
.lvl.l2 { color: var(--lvl2-ink); } .lvl.l3 { color: var(--lvl3-ink); } .lvl.l4 { color: var(--lvl4-ink); }

.calm-state {
  display: grid; grid-template-columns: 8px 1fr; gap: 14px;
  background: var(--panel); border: 1px solid var(--line); border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; padding: 14px 14px 14px 0;
}
.calm-state::before { content: ""; background: var(--ok); }

/* ---------- 狀態提示 ---------- */
.notice { padding: 10px 14px; border-radius: var(--radius); background: var(--warn-bg); border: 1px solid var(--l2); font-size: .92rem; }
.notice.err { background: var(--err-bg); border-color: var(--l4); }
.notice + .notice { margin-top: 8px; }
.demo-banner { background: var(--demo); color: #fff; text-align: center; padding: 6px 16px; font-weight: 600; font-size: .9rem; }

/* ---------- 地點列表 ---------- */
.places { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.place {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
  background: var(--panel); padding: 12px 14px; text-decoration: none; color: inherit;
}
.place:hover { background: var(--panel-2); }
.place .name { font-weight: 700; }
.place .sub { font-size: .85rem; color: var(--ink-3); }
.place .temp { font-family: var(--num); font-size: 2rem; line-height: 1; font-weight: 600; text-align: right; }
.place .line { grid-column: 1 / -1; font-size: .9rem; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.place .alert-line { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font-size: .8rem; padding: 1px 8px; border-radius: 999px; background: var(--panel-2); }
.pill.l2 { background: var(--l2); color: #2a2000; } .pill.l3 { background: var(--l3); color: #fff; } .pill.l4 { background: var(--l4); color: #fff; }
.pill.est { background: transparent; border: 1px dashed var(--ink-3); }

/* ---------- 地點詳細 ---------- */
.now-block { display: grid; grid-template-columns: auto 1fr; gap: 4px 20px; align-items: end; }
.now-temp { font-family: var(--num); font-size: 4.5rem; line-height: .9; font-weight: 600; letter-spacing: -1px; }
.now-temp sup { font-size: 1.6rem; vertical-align: top; position: relative; top: .4rem; }
.now-side { padding-bottom: 6px; }
.now-wx { font-size: 1.15rem; font-weight: 600; }
.readings { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-top: 14px; }
.reading { background: var(--panel); padding: 8px 12px; }
.reading dt { font-size: .8rem; color: var(--ink-3); }
.reading dd { margin: 0; font-family: var(--num); font-size: 1.35rem; font-weight: 600; }
.reading dd small { font-family: var(--sans); font-size: .75rem; font-weight: 400; color: var(--ink-3); margin-left: 2px; }
.source-line { font-size: .8rem; color: var(--ink-3); margin-top: 6px; }
.stale { color: var(--l3); font-weight: 600; }

.hours { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.hours svg { display: block; }
.hours text { font-family: var(--num); fill: var(--ink-2); }
.hours .hl { font-family: var(--sans); fill: var(--ink-3); font-size: 11px; }

.days { display: grid; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); gap: 1px; }
.day { display: grid; grid-template-columns: 4.5em 1fr auto auto; gap: 10px; align-items: center; background: var(--panel); padding: 9px 14px; }
.day .d { font-weight: 600; }
.day .w { color: var(--ink-2); font-size: .92rem; }
.day .p { font-size: .85rem; color: var(--sea); min-width: 3.2em; text-align: right; }
.day .t { font-family: var(--num); font-size: 1.1rem; min-width: 5em; text-align: right; }
.day .uv { grid-column: 2 / -1; font-size: .8rem; color: var(--ink-3); margin-top: -4px; }

.two { display: grid; gap: 14px; }
@media (min-width: 640px) { .two { grid-template-columns: 1fr 1fr; } }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.big-num { font-family: var(--num); font-size: 2.6rem; line-height: 1; font-weight: 600; }

/* ---------- 分頁、表單 ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--ink-2); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--ink); border-color: var(--ink); font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--sea);
  background: var(--sea); color: var(--sea-ink); cursor: pointer; text-decoration: none; font-weight: 600; min-height: 40px;
}
.btn.secondary { background: transparent; color: var(--sea); }
.btn.danger { background: transparent; color: var(--l4); border-color: var(--l4); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.field { display: grid; gap: 4px; margin-bottom: 14px; }
.field label, .field .label { font-weight: 600; font-size: .92rem; }
.field .hint { font-size: .82rem; color: var(--ink-3); }
input[type=text], input[type=time], input[type=search], select {
  width: 100%; padding: 8px 10px; min-height: 42px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.list { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > * { background: var(--panel); padding: 12px 14px; }
.list-item { display: flex; align-items: center; gap: 10px; }
.list-item .grow { flex: 1; min-width: 0; }

details.hz { border-top: 1px solid var(--line); }
details.hz:first-of-type { border-top: 0; }
details.hz summary { cursor: pointer; padding: 12px 0; display: flex; align-items: center; gap: 10px; list-style: none; }
details.hz summary::-webkit-details-marker { display: none; }
details.hz summary::after { content: "＋"; margin-left: auto; color: var(--ink-3); }
details.hz[open] summary::after { content: "－"; }
details.hz .body { padding: 0 0 14px; }
.switch { display: flex; align-items: center; gap: 8px; margin: 6px 0; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--sea); }
input[type=range] { width: 100%; accent-color: var(--sea); }

.channel { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; }
.state { font-size: .82rem; font-weight: 600; }
.state.ok { color: var(--ok); } .state.fail { color: var(--l4); } .state.skip { color: var(--ink-3); }

.map-box { height: 320px; border-radius: var(--radius); border: 1px solid var(--line); margin-top: 10px; }
.empty { text-align: left; padding: 28px 18px; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--radius); max-width: calc(100% - 32px); font-size: .92rem;
}
.loading { color: var(--ink-3); padding: 24px 0; }

pre.official { white-space: pre-wrap; font: inherit; margin: 0; }
.kv { display: grid; grid-template-columns: 6.5em 1fr; gap: 6px 12px; font-size: .92rem; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }

.foot { padding-top: 24px; padding-bottom: 32px; border-top: 1px solid var(--line); font-size: .82rem; color: var(--ink-3); }
.foot p { margin: 4px 0; }

@media (prefers-reduced-motion: no-preference) {
  .signal.fresh { animation: blink 1.2s ease-out 1; }
  @keyframes blink { 0% { box-shadow: inset 0 0 0 2px var(--l3); } 100% { box-shadow: inset 0 0 0 2px transparent; } }
}

main > h1 { margin-bottom: 18px; }
.btn { white-space: nowrap; }

/* ---------- 首頁地圖 ---------- */
body.map-mode main { max-width: none; padding: 0; }
body.map-mode .foot { display: none; }
.map-home { position: relative; height: calc(100dvh - var(--top-h, 100px)); min-height: 420px; overflow: hidden; }
.map-canvas { position: absolute; inset: 0; background: var(--panel-2); z-index: 0; }
/* 底圖去飽和，讓警報色塊成為畫面重點 */
.map-canvas .leaflet-tile-pane { filter: var(--tile-filter); }
.leaflet-container { font: 14px/1.5 var(--sans); }
.leaflet-popup-content { margin: 10px 12px; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--ink); }
.leaflet-container a { color: var(--sea); }

.map-tools { position: absolute; top: 12px; left: 12px; z-index: 500; display: flex; gap: 6px; }
.map-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px;
  padding: 6px 14px; font-weight: 600; font-size: .88rem; cursor: pointer; box-shadow: 0 1px 3px rgba(20,33,48,.18);
}
.map-btn:hover { background: var(--panel-2); }
.legend {
  position: absolute; z-index: 500; right: 12px; bottom: calc(var(--sheet-peek) + 12px);
  display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; max-width: 220px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; font-size: .78rem;
}
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; opacity: .8; }
.legend-note { flex-basis: 100%; color: var(--ink-3); }

/* 收藏地點標記：圓點顯示溫度，外圈顏色＝最高等級；只有網站估算時外圈為虛線 */
.place-mark { display: inline-flex; align-items: center; gap: 4px; transform: translate(0, 0); white-space: nowrap; }
.pm-temp {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--ink); color: var(--bg); font: 600 15px/1 var(--num);
  border: 4px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.place-mark.lv2 .pm-temp { border-color: var(--l2); }
.place-mark.lv3 .pm-temp { border-color: var(--l3); }
.place-mark.lv4 .pm-temp { border-color: var(--l4); }
.place-mark.est .pm-temp { border-style: dashed; }
.pm-name {
  background: var(--panel); color: var(--ink); border-radius: 4px; padding: 1px 6px; font: 600 12px/1.5 var(--sans);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.quake-mark {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  border: 3px solid var(--c); background: color-mix(in srgb, var(--c) 25%, transparent);
  font: 600 11px/1 var(--sans); color: var(--ink);
}
.pop-where { font-weight: 700; margin-bottom: 4px; }
.pop-title { font-weight: 700; }
.pop-meta { color: var(--ink-3); font-size: .82rem; }
.pop-item { padding: 4px 0; border-top: 1px solid var(--line); }
.pop-item:first-child { border-top: 0; }
.pop-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; flex: none; }

/* 清單面板：手機為底部抽屜，桌機為左側欄 */
.map-home { --sheet-peek: 74px; }
.sheet {
  position: absolute; z-index: 600; left: 0; right: 0; bottom: 0;
  background: var(--bg); border-top: 1px solid var(--line); border-radius: 14px 14px 0 0;
  box-shadow: 0 -4px 16px rgba(20,33,48,.18);
  height: var(--sheet-peek); display: flex; flex-direction: column;
  transition: height .25s ease;
}
.sheet[data-open="true"] { height: 72%; }
.sheet-handle {
  flex: none; display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  border: 0; background: transparent; padding: 8px 16px 10px; text-align: left; cursor: pointer; color: var(--ink);
}
.grip { align-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--line); }
.sheet-title { display: flex; flex-direction: column; border-left: 6px solid var(--ok); padding-left: 10px; }
.sheet[data-level="2"] .sheet-title { border-color: var(--l2); }
.sheet[data-level="3"] .sheet-title { border-color: var(--l3); }
.sheet[data-level="4"] .sheet-title { border-color: var(--l4); }
.sheet-body { flex: 1; overflow-y: auto; padding: 4px 16px 24px; -webkit-overflow-scrolling: touch; }
.sheet[data-open="false"] .sheet-body { visibility: hidden; }
.sheet-body section + section { margin-top: 22px; }
.sheet-foot { margin-top: 24px; }
@media (prefers-reduced-motion: reduce) { .sheet { transition: none; } }

@media (min-width: 900px) {
  .map-home { --sheet-peek: 0px; }
  .sheet, .sheet[data-open="true"], .sheet[data-open="false"] {
    top: 0; right: auto; width: 420px; height: auto; border-radius: 0; border-top: 0; border-right: 1px solid var(--line);
    box-shadow: 2px 0 12px rgba(20,33,48,.12);
  }
  .sheet[data-open="false"] .sheet-body { visibility: visible; }
  .sheet-handle { cursor: default; padding-top: 14px; }
  .grip { display: none; }
  .map-canvas { left: 420px; }
  .map-tools { left: 432px; }
  .legend { bottom: 24px; }
}
body.map-mode .top-inner, body.map-mode .chips { max-width: none; }
.sheet-title .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-home { --sheet-peek: 80px; }
@media (min-width: 900px) { .sheet-title .small { white-space: normal; } }

/* ---------- 圖層切換與分布圖面板 ---------- */
.map-top { position: absolute; z-index: 500; top: 10px; left: 10px; right: 56px; display: grid; gap: 8px; justify-items: start; pointer-events: none; }
.map-top > * { pointer-events: auto; }
.map-top .map-tools { position: static; }
.layer-bar {
  display: flex; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px;
  box-shadow: 0 1px 4px rgba(20,33,48,.2);
}
.layer-bar::-webkit-scrollbar { display: none; }
.layer-chip {
  flex: none; border: 0; background: transparent; color: var(--ink-2); cursor: pointer;
  padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: .88rem; white-space: nowrap;
}
.layer-chip:hover { background: var(--panel-2); }
.layer-chip[aria-checked="true"] { background: var(--ink); color: var(--bg); }

.field-panel {
  position: absolute; z-index: 500; left: 10px; right: 10px; bottom: calc(var(--sheet-peek) + 10px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 10px;
  box-shadow: 0 2px 8px rgba(20,33,48,.2); font-size: .85rem;
}
.field-panel:empty { display: none; }
.fp-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.fp-head strong { font-size: 1rem; }
.fp-time { margin-left: auto; font-family: var(--num); font-weight: 600; font-size: .95rem; }
.fp-note { color: var(--ink-3); font-size: .78rem; margin-top: 6px; line-height: 1.45; }
.err-text { color: var(--l4); }
.lg-bar { height: 10px; border-radius: 5px; margin-top: 8px; }
.lg-ticks { display: flex; justify-content: space-between; font: 500 .75rem/1.4 var(--num); color: var(--ink-2); margin-top: 2px; }
.lg-cats { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: .78rem; }
.lg-cats i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.lg-cats b { font-weight: 500; color: var(--ink-3); margin-left: 4px; font-family: var(--num); }
.fp-slider { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.fp-slider input { flex: 1; margin: 0; }
.fp-play {
  flex: none; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); cursor: pointer; font-size: .8rem;
}
.fp-range-label { font: 500 .78rem/1 var(--num); color: var(--ink-3); white-space: nowrap; }

/* 測站：數值標籤、點、風向箭頭 */
.st-val {
  display: inline-block; min-width: 28px; padding: 1px 5px; border-radius: 4px; text-align: center;
  background: var(--c); color: #111; font: 600 12px/16px var(--num);
  border: 1px solid rgba(0,0,0,.35); box-shadow: 0 1px 2px rgba(0,0,0,.25); white-space: nowrap;
}
.st-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); border: 1px solid rgba(0,0,0,.45); }
.wind-arrow {
  width: 18px; height: 18px; position: relative;
}
.wind-arrow::before {
  content: ""; position: absolute; left: 50%; top: 2px; bottom: 2px; width: 2.5px; margin-left: -1.25px; background: var(--c);
  box-shadow: 0 0 0 1px rgba(0,0,0,.35);
}
.wind-arrow::after {
  content: ""; position: absolute; left: 50%; top: 0; margin-left: -5px;
  border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 7px solid var(--c);
  filter: drop-shadow(0 0 1px rgba(0,0,0,.6));
}
.pop-est { font-size: .95rem; margin: 2px 0; }
.pop-sub { font-weight: 700; font-size: .82rem; margin-top: 8px; }
.pop-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; font-size: .82rem; }

@media (min-width: 900px) {
  .map-top { left: 432px; }
  .field-panel { left: auto; right: 12px; bottom: 24px; width: 360px; }
}
.fp-more { border: 0; background: transparent; color: var(--sea); font-size: .8rem; cursor: pointer; padding: 0 2px; text-decoration: underline; }
@media (max-width: 899px) {
  .field-panel { padding: 6px 10px 8px; }
  .field-panel .fp-note { display: none; }
  .field-panel.notes-open .fp-note, .field-panel .fp-note.err-text, .field-panel .fp-note.always { display: block; }
  .fp-slider { margin-top: 4px; }
  .fp-play { width: 28px; height: 28px; }
  .layer-chip { padding: 5px 10px; font-size: .84rem; }
}
@media (min-width: 900px) { .fp-more { display: none; } }

.map-btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.map-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.map-btn.primary { background: var(--sea); color: var(--sea-ink); border-color: var(--sea); }
.pop-add {
  display: block; width: 100%; margin-top: 10px; padding: 8px 12px; border-radius: var(--radius);
  border: 1px solid var(--sea); background: var(--sea); color: var(--sea-ink); font-weight: 600; cursor: pointer;
}

/* ---------- 地震 ---------- */
.quake-banner {
  display: flex; align-items: stretch; max-width: min(560px, 100%);
  background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--c, var(--l3));
  border-radius: 10px; box-shadow: 0 2px 8px rgba(20,33,48,.25); overflow: hidden;
}
.quake-banner[hidden] { display: none; }
.qb-main {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; border: 0; background: transparent;
  color: var(--ink); text-align: left; padding: 8px 10px; cursor: pointer; font: inherit; font-size: .88rem;
}
.qb-main:hover { background: var(--panel-2); }
.qb-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qb-int { flex: none; border-radius: 6px; padding: 3px 7px; font: 700 .9rem/1.2 var(--num); }
.qb-x { flex: none; border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--ink-3); width: 40px; font-size: 1.2rem; cursor: pointer; }
.qb-x:hover { background: var(--panel-2); color: var(--ink); }

.eq-select {
  display: block; width: 100%; margin-top: 6px; padding: 6px 8px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); font: inherit; font-size: .85rem;
}
.eq-one { margin-top: 4px; font-weight: 600; }
.eq-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 6px; font-size: .82rem; }
.eq-chip { border-radius: 6px; padding: 2px 8px; font-weight: 700; }
.eq-counties { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; font-size: .8rem; }
.eq-counties b { display: inline-block; border-radius: 4px; padding: 0 5px; margin-left: 2px; font: 700 .78rem/1.5 var(--num); }
.quake-lg { gap: 4px 8px; }
.eq-st {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--c); font: 700 12px/1 var(--num); border: 1.5px solid rgba(0,0,0,.45);
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.eq-epi {
  width: 34px; height: 34px; display: grid; place-items: center; font-size: 30px; line-height: 1;
  color: #e3262b; text-shadow: 0 0 2px #fff, 0 0 4px #fff, 0 1px 3px rgba(0,0,0,.6);
}
@media (max-width: 899px) {
  .field-panel .eq-counties span:nth-child(n+5) { display: none; }
  .field-panel .quake-lg { display: none; }
  .field-panel.notes-open .quake-lg { display: flex; }
  .field-panel.notes-open .eq-counties span { display: inline; }
}

/* ---------- 危害總覽（首頁最上方：一眼看懂現在面對什麼） ---------- */
.map-home { display: flex; flex-direction: column; }
.map-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.hz-board {
  flex: none; background: var(--bg); border-bottom: 1px solid var(--line); padding: 10px 14px 10px;
  display: grid; gap: 8px; position: relative; z-index: 700;
}
.hz-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.hz-head strong { font-size: 1.05rem; }
.hz-place {
  font: inherit; font-weight: 700; font-size: 1rem; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px;
}
.hz-verdict { font-weight: 700; font-size: .95rem; }
.hz-today { font-size: .92rem; line-height: 1.6; margin: 2px 0 8px; color: var(--ink); }
.hz-verdict.ok { color: var(--ok); }
.hz-verdict.warn.l1 { color: var(--ink-2); }
.hz-verdict.warn.l2 { color: color-mix(in srgb, var(--l2) 70%, var(--ink)); }
.hz-verdict.warn.l3 { color: var(--l3); }
.hz-verdict.warn.l4 { color: var(--l4); }
@media (min-width: 700px) { .hz-verdict { margin-left: auto; } }

.hz-cards { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.hz-cards::-webkit-scrollbar { display: none; }
.hz-card {
  --c: var(--l1);
  flex: none; display: flex; align-items: center; gap: 10px; min-width: 150px; max-width: 260px;
  border: 2px solid var(--c); border-radius: 12px; padding: 8px 12px 8px 10px; cursor: pointer; text-align: left;
  background: color-mix(in srgb, var(--c) 16%, var(--panel)); color: var(--ink); font: inherit; position: relative;
}
.hz-card.l2 { --c: var(--l2); } .hz-card.l3 { --c: var(--l3); } .hz-card.l4 { --c: var(--l4); }
.hz-card.est { border-style: dashed; }
.hz-card[aria-pressed="true"] { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 45%, transparent); }
.hz-icon { font-size: 2rem; line-height: 1; }
.hz-body { display: grid; line-height: 1.25; }
.hz-name { font-weight: 800; font-size: 1.1rem; }
.hz-level { font-size: .8rem; font-weight: 700; color: var(--ink-2); }
.hz-card.l3 .hz-level, .hz-card.l4 .hz-level { color: var(--c); }
.hz-value { font: 700 .95rem/1.3 var(--num); }
.hz-src {
  position: absolute; top: 5px; right: 6px; font-size: .66rem; font-weight: 700; color: var(--ink-3);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; background: var(--panel);
}
.hz-card.official .hz-src { color: var(--c); border-color: var(--c); }
.hz-oks { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.hz-ok {
  display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink-2); border-radius: 999px; padding: 2px 10px 2px 7px; font: inherit; font-size: .8rem; cursor: pointer;
}
.hz-ok b { font: 600 .78rem/1 var(--num); color: var(--ink-3); margin-left: 2px; }
.hz-ok:hover, .hz-card:hover { filter: brightness(.97); }
.hz-ok[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); }
.hz-detail { font-size: .85rem; display: grid; gap: 4px; }
.hz-alert {
  display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 6px; text-decoration: none; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
}
.hz-alert .muted { display: block; font-size: .8rem; }
.hz-more { color: var(--sea); font-size: .8rem; white-space: nowrap; }
.hz-detail-src { font-size: .78rem; }
.hz-empty { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: .9rem; color: var(--ink-2); }
.hz-nation { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; font-size: .82rem; }
.hz-ntag { border-radius: 999px; padding: 1px 8px; border: 1px solid var(--l1); }
.hz-ntag.l2 { border-color: var(--l2); } .hz-ntag.l3 { border-color: var(--l3); } .hz-ntag.l4 { border-color: var(--l4); }

@media (max-width: 699px) {
  .hz-board { padding: 8px 10px; gap: 6px; }
  .hz-card { min-width: 132px; padding: 6px 10px 6px 8px; gap: 8px; }
  .hz-icon { font-size: 1.6rem; }
  .hz-name { font-size: 1rem; }
  .hz-oks { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .hz-oks::-webkit-scrollbar { display: none; }
  .hz-ok { flex: none; }
}
@media (min-width: 900px) {
  /* 桌機：左側清單從總覽下方開始 */
  .sheet, .sheet[data-open="true"], .sheet[data-open="false"] { top: 0; }
}
.hz-place { width: auto; max-width: 60vw; display: inline-block; }
@media (max-width: 699px) {
  .hz-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .hz-card { min-width: 0; max-width: none; }
}
.hz-calm { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: .78rem; color: var(--ink-3); }
.hz-calm span { white-space: nowrap; }
@media (max-width: 699px) { .hz-calm { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; } }
.hz-calm em { font-style: normal; font-weight: 700; color: var(--ok); white-space: nowrap; flex: none; }
/* 手機：總覽在上、地圖在下，頁面可往下捲；地圖保持足夠高度 */
@media (max-width: 899px) {
  .map-home { height: auto; min-height: 0; overflow: visible; }
  .map-stage { flex: none; height: max(460px, calc(100dvh - var(--top-h, 100px) - 24px)); }
}
.seg { display: inline-flex; margin-top: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--panel-2); }
.seg button { border: 0; background: transparent; color: var(--ink-2); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--ink); color: var(--bg); }

/* ---------- 颱風 ---------- */
.ty-strip {
  --c: var(--l2);
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer; font: inherit; color: var(--ink);
  border: 2px solid var(--c); border-radius: 12px; padding: 8px 12px; background: color-mix(in srgb, var(--c) 14%, var(--panel));
}
.ty-strip.l3 { --c: var(--l3); } .ty-strip.l4 { --c: var(--l4); }
.ty-icon { font-size: 2rem; line-height: 1; animation: ty-spin 4s linear infinite; }
.ty-text { display: grid; gap: 1px; min-width: 0; flex: 1; }
.ty-text strong { font-size: 1.05rem; }
.ty-rel { font-size: .92rem; }
.ty-facts { font-size: .78rem; }
.ty-go { color: var(--sea); font-size: .85rem; font-weight: 600; white-space: nowrap; }
.ty-mark { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.ty-spin { font-size: 36px; line-height: 40px; display: inline-block; animation: ty-spin 4s linear infinite; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.ty-name { background: #c92a2a; color: #fff; font: 700 13px/1.3 var(--sans); padding: 2px 7px; border-radius: 6px; display: grid; }
.ty-name small { font-weight: 500; font-size: 11px; opacity: .9; }
.ty-time { font: 600 11px/1 var(--num); color: #c92a2a; background: rgba(255,255,255,.85); padding: 1px 4px; border-radius: 3px; white-space: nowrap; }
@keyframes ty-spin { to { transform: rotate(-360deg); } }
@media (prefers-reduced-motion: reduce) { .ty-icon, .ty-spin { animation: none; } }

/* 桌機：總覽放在左欄上方，地圖保持全高；左側清單接在總覽下面 */
@media (min-width: 900px) {
  .map-home { display: block; position: relative; }
  .map-stage { position: absolute; inset: 0; }
  .hz-board {
    position: absolute; top: 0; left: 0; width: 420px; max-height: calc(100% - 140px); overflow-y: auto;
    border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  }
  .hz-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .hz-card { min-width: 0; max-width: none; }
  .hz-verdict { margin-left: 0; flex-basis: 100%; }
  .sheet, .sheet[data-open="true"], .sheet[data-open="false"] { top: var(--board-h, 0px); }
}
.ty-mini {
  display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; cursor: pointer;
  border: 0; background: transparent; color: var(--ink-3); font: inherit; font-size: .8rem; padding: 0;
}
.ty-mini .ty-go { margin-left: auto; font-size: .78rem; }

/* 這週降雨機率 */
.wk { display: grid; gap: 4px; }
.wk-title { font-size: .78rem; font-weight: 700; color: var(--ink-2); }
.wk-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.wk-day { display: grid; justify-items: center; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 2px; }
.wk-day.wet { border-color: #3d8bf0; }
.wk-label { font-size: .74rem; color: var(--ink-2); white-space: nowrap; }
.wk-bar { width: 10px; height: 26px; border-radius: 3px; background: var(--panel-2); display: flex; align-items: flex-end; overflow: hidden; }
.wk-bar i { display: block; width: 100%; border-radius: 3px; }
.wk-pop { font: 700 .8rem/1 var(--num); }
.wk-day.wet .wk-pop { color: #1c64d6; }
:root[data-theme="dark"] .wk-day.wet .wk-pop { color: #8fbdf7; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wk-day.wet .wk-pop { color: #8fbdf7; } }
.hz-cause { font-size: .78rem; font-weight: 700; color: var(--ink-2); }
.hz-cause-note { font-size: .78rem; color: var(--ink-2); margin-top: 2px; }

/* 頂端：贊助與作者的其他作品 */
.top-link {
  flex: none; display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); text-decoration: none;
  font-size: .85rem; font-weight: 600; white-space: nowrap;
}
.top-link:hover { background: var(--panel-2); }
.top-link.sponsor { background: #f5b301; border-color: #e0a200; color: #1d1d1d; }
.top-link.sponsor:hover { background: #ffc21a; }
.brand { white-space: nowrap; }
@media (max-width: 420px) {
  .top-link { padding: 0 9px; font-size: .8rem; }
  .top-inner { gap: 4px; padding: 0 10px; }
  .top-inner .icon-btn { width: 34px; }
  .wide-only { display: none; }
}

/* ---------- 第一次使用引導 ---------- */
.onb {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto;
  border: 1px solid var(--line); border-radius: 10px; padding: 20px 20px 16px;
  background: var(--panel); color: var(--ink); box-shadow: 0 12px 40px rgb(0 0 0 / .25);
}
.onb::backdrop { background: rgb(10 20 30 / .45); }
.onb h2 { margin: 6px 0 8px; font-size: 1.25rem; }
.onb p { margin: 0 0 12px; }
.onb-steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 6px; counter-reset: s; }
.onb-steps li { counter-increment: s; flex: 1; font-size: .78rem; color: var(--ink-3); border-top: 3px solid var(--line); padding-top: 4px; }
.onb-steps li::before { content: counter(s) " "; font-weight: 700; }
.onb-steps li.done { border-color: var(--ok); color: var(--ink-2); }
.onb-steps li[aria-current="step"] { border-color: var(--sea); color: var(--ink); font-weight: 600; }
.onb-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.onb-actions .btn { flex: 1 1 200px; }
.onb-foot { text-align: center; margin-top: 4px; }
.linkish { background: none; border: 0; color: var(--sea); text-decoration: underline; cursor: pointer; font: inherit; padding: 6px; }
.onb-presets { display: grid; gap: 8px; margin-bottom: 8px; }
.onb-preset {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); color: var(--ink); cursor: pointer; font: inherit;
}
.onb-preset:hover, .onb-preset:focus-visible { border-color: var(--sea); outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--sea) 30%, transparent); }
.onb-preset strong { display: block; }
.onb-preset .small { display: block; margin-top: 2px; }
.onb-icon { font-size: 1.6rem; line-height: 1; }
.onb-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; background: var(--bg); }
.onb-box.ok { border-color: var(--ok); color: var(--ok); font-weight: 600; }
.onb-box p { margin: 6px 0 10px; }
.onb-howto { margin: 8px 0 6px; padding-left: 1.4em; display: grid; gap: 4px; }
.onb-daily { margin: 4px 0 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.onb-daily select { width: auto; min-height: 32px; padding: 2px 6px; }

/* ---------- 情境按鈕、每日摘要 ---------- */
.preset-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 10px; }
.chip-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px;
  padding: 5px 12px; font: inherit; font-size: .9rem; cursor: pointer; min-height: 34px;
}
.chip-btn:hover { border-color: var(--sea); }
.chip-btn[aria-pressed="true"] { background: var(--sea); color: var(--sea-ink); border-color: var(--sea); font-weight: 600; }
.daily-box {
  white-space: pre-wrap; font: inherit; font-size: .9rem; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px; margin-top: 10px;
}

/* ---------- 頂端「作品」選單 ---------- */
.works { position: relative; flex: none; }
.works > summary { list-style: none; cursor: pointer; }
.works > summary::-webkit-details-marker { display: none; }
.works > summary::after { content: "▾"; margin-left: 4px; font-size: .75em; }
.works[open] > summary { background: var(--panel-2); }
.works-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 1200; width: min(300px, calc(100vw - 24px));
  display: grid; gap: 2px; padding: 6px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); box-shadow: 0 10px 30px rgb(0 0 0 / .2);
}
.works-menu a { display: grid; gap: 2px; padding: 8px 10px; border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.works-menu a:hover, .works-menu a:focus-visible { background: var(--panel-2); outline: none; }
.works-menu span { font-size: .8rem; color: var(--ink-3); }
/* 選單打開時，整個頂端列要蓋在首頁總覽與地圖上面 */
.top:has(.works[open]) { z-index: 1300; }
/* 手機：選單改成整排寬度，貼齊畫面左右，不會被切到 */
@media (max-width: 600px) {
  .top-inner { position: relative; }
  .works { position: static; }
  .works-menu { left: 10px; right: 10px; width: auto; top: calc(100% - 2px); }
}

/* 空氣「普通」（環境部黃燈）：留意卡片，只顯示不推播 */
.hz-card.soft { --c: var(--l2); border-style: dotted; background: color-mix(in srgb, var(--c) 8%, var(--panel)); }
.hz-card.soft .hz-level { color: var(--lvl2-ink); }
.hz-verdict.warn.soft { color: var(--lvl2-ink); font-weight: 600; }
.hz-soft { font-weight: 600; color: var(--lvl2-ink); }
