:root {
  --bg: #12161c;
  --card: #1c2128;
  --text: #e8eaed;
  --sub: #9aa0a6;
  --accent: #4c8dff;
  --warn: #ff6b5e;
  --line: #2d333b;
  --rtline: #3a4250;
}
html[data-theme="light"] {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1d21;
  --sub: #5f6368;
  --accent: #1a6fe8;
  --warn: #d33f30;
  --line: #e2e5e9;
  --rtline: #d0d4da;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "PingFang HK", "Microsoft JhengHei", sans-serif;
  min-height: 100vh;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 8px; max-width: 480px; margin: 0 auto;
}
.topbar h1 { font-size: 20px; font-weight: 600; }
.tools { display: flex; align-items: center; gap: 6px; }
.toolbtn {
  background: var(--card); border: none; color: var(--sub);
  font-size: 13px; font-weight: 600; padding: 8px 10px; border-radius: 999px;
  min-width: 40px; height: 40px;
}
.toolbtn:active { filter: brightness(1.2); }
.refresh {
  background: none; border: none; color: var(--sub); font-size: 22px;
  width: 40px; height: 40px; border-radius: 50%;
}
.refresh:active { background: var(--card); }
main { max-width: 480px; margin: 0 auto; padding: 4px 12px 32px; }
.card {
  background: var(--card); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 10px;
}
.card h2 {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; font-weight: 500; color: var(--sub);
  letter-spacing: .05em; margin-bottom: 10px;
}
.card h2 .upd { font-size: 11px; font-weight: 400; letter-spacing: 0; }
.hidden { display: none; }
.now-row { display: flex; justify-content: space-between; align-items: flex-start; }
.big-temp { font-size: 54px; font-weight: 300; line-height: 1.05; }
.sub { font-size: 14px; color: var(--sub); margin-top: 6px; }
.sub.dim { font-size: 12px; }
.temp-row { display: flex; align-items: center; gap: 14px; }
.range .rlabel { font-size: 10px; color: var(--sub); }
.range .rhi { font-size: 16px; font-weight: 500; line-height: 1.2; }
.range .rlo { font-size: 16px; color: var(--sub); line-height: 1.2; }
.hum { font-size: 17px; font-weight: 500; margin-top: 6px; }
.now-right { text-align: center; min-width: 96px; }
.wx-icon-large { width: 84px; height: 84px; }
.cond { font-size: 14px; margin-top: 4px; }
.home-inline:not(.hidden) {
  display: flex; align-items: baseline; gap: 10px;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line);
}
.hi-label { font-size: 13px; color: var(--sub); letter-spacing: .05em; }
.hi-temp { font-size: 17px; font-weight: 500; }
.hi-rh { font-size: 14px; color: var(--sub); }
.fc-period { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.fc-desc { font-size: 15px; line-height: 1.55; }
.fc-outlook { font-size: 15px; line-height: 1.55; margin-top: 8px; color: var(--sub); }
/* warnings */
.warn-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.warn-item img { width: 30px; height: 30px; flex: none; }
.warn-item .wname { font-size: 15px; }
.swt-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0 2px; border-top: 1px solid var(--line); margin-top: 8px; }
.swt-item img { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.swt-item .swtitle { font-size: 13px; color: var(--sub); }
.swt-item .swtext { font-size: 14px; line-height: 1.5; margin-top: 2px; }
/* rainfall nowcast */
/* 9 day columns */
.nd-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; }
.nd-col { text-align: center; padding: 4px 0 2px; }
.nd-d { font-size: 11px; font-weight: 600; }
.nd-w { font-size: 10px; color: var(--sub); }
.nd-col img { width: 26px; height: 26px; margin: 3px 0 1px; }
.nd-t { font-size: 11px; }
.nd-t .lo { color: var(--sub); }
.nd-r { font-size: 9px; color: var(--sub); margin-top: 1px; }
.nd-p { font-size: 10px; color: var(--sub); margin-top: 1px; }
.nd-today .nd-d { color: var(--accent); }
.error { font-size: 14px; color: var(--warn); }
footer { text-align: center; font-size: 11px; color: var(--sub); padding: 14px 0 6px; }
/* rainfall timeline (HKO-style) */
.rain-place { text-align: center; font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.rain-timeline { position: relative; height: 86px; margin-top: 4px; }
.rt-line { position: absolute; left: 4%; right: 4%; top: 42px; height: 2px; background: var(--rtline); }
.rt-node { position: absolute; top: 42px; transform: translateX(-50%); text-align: center; }
.rt-dot { border-radius: 50%; background: #4c8dff; margin: 0 auto; transform: translateY(-50%); }
.rt-node.rt-now .rt-dot { background: var(--text); }
.rt-person { position: absolute; left: 50%; transform: translate(-50%, 0); top: -20px; }
.rt-time { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--sub); white-space: nowrap; }
.rt-mm { position: absolute; top: 26px; left: 50%; transform: translateX(-50%); font-size: 9px; color: var(--accent); white-space: nowrap; }
