/* Phase B: themed (light/dark via custom properties), modern type, pill
   tabs — still the compact cream-panel spirit of the original. */

* { box-sizing: border-box; }

:root {
  --bg: #99ccff;
  --panel: #ffffcc;
  --panel-line: #223;
  --head: #ffff99;
  --text: #101418;
  --muted: #4a5568;
  --link: #993300;
  --link-hover: #2b6cb0;
  --tab-bg: #fff6bf;
  --tab-line: #d8c980;
  --sea: #95c1ed;
  --land: #f2fda3;
  --mainland: #a9cfa4;
  --coast: #556;
  --map-label: #102;
  --map-halo: #fff;
  --chart-bg: #fffff2;
  --chart-grid: #ddd0a0;
  --chart-ax: #555;
  --c-yellow: #9a7d00;
  --c-orange: #e05c00;
  --c-red: #e60000;
  --c-magenta: #cc00cc;
  --c-blue: #0000ee;
  --c-cyan: #007799;
  --s1: #993300;   /* chart series */
  --s2: #0066cc;
  --s3: #008844;
}

/* one dark palette, applied when chosen explicitly… */
[data-theme="dark"] {
  --bg: #0f1726;
  --panel: #1b2436;
  --panel-line: #3a4763;
  --head: #253352;
  --text: #e6ebf4;
  --muted: #9aa7bd;
  --link: #f0a870;
  --link-hover: #7ab8ff;
  --tab-bg: #232f47;
  --tab-line: #3a4763;
  --sea: #16304e;
  --land: #39422b;
  --mainland: #2c3c33;
  --coast: #7d8ba6;
  --map-label: #eef3ff;
  --map-halo: #0c1420;
  --chart-bg: #16203344;
  --chart-grid: #33405c;
  --chart-ax: #9aa7bd;
  --c-yellow: #ffd34d;
  --c-orange: #ff9f45;
  --c-red: #ff6b5e;
  --c-magenta: #f07ce8;
  --c-blue: #7aa7ff;
  --c-cyan: #59c7e8;
  --s1: #ff9f6e;
  --s2: #6fb3ff;
  --s3: #58d0a0;
}
/* …and when the system prefers dark and no explicit choice overrides it */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1726;
    --panel: #1b2436;
    --panel-line: #3a4763;
    --head: #253352;
    --text: #e6ebf4;
    --muted: #9aa7bd;
    --link: #f0a870;
    --link-hover: #7ab8ff;
    --tab-bg: #232f47;
    --tab-line: #3a4763;
    --sea: #16304e;
    --land: #39422b;
    --mainland: #2c3c33;
    --coast: #7d8ba6;
    --map-label: #eef3ff;
    --map-halo: #0c1420;
    --chart-bg: #16203344;
    --chart-grid: #33405c;
    --chart-ax: #9aa7bd;
    --c-yellow: #ffd34d;
    --c-orange: #ff9f45;
    --c-red: #ff6b5e;
    --c-magenta: #f07ce8;
    --c-blue: #7aa7ff;
    --c-cyan: #59c7e8;
    --s1: #ff9f6e;
    --s2: #6fb3ff;
    --s3: #58d0a0;
  }
}

html { color-scheme: light dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "PingFang TC", "Microsoft JhengHei",
    "Noto Sans TC", sans-serif;
  padding: 0 8px 24px;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }

.site-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 6px 12px;
  padding: 10px 0 6px;
}
.site-head h1 { font-size: 20px; margin: 0; text-align: center; letter-spacing: 0.02em; }
@media (max-width: 420px) { .site-head h1 { font-size: 17px; } }
.lang-btn, .theme-btn {
  font-size: 13px;
  border: 1px solid var(--link);
  padding: 1px 8px;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  color: var(--link);
}

/* ---- layout ---- */
.layout {
  display: grid;
  grid-template-columns: minmax(300px, 384px) minmax(260px, 320px);
  gap: 10px;
  justify-content: center;
  align-items: start;
}
.col-side { display: grid; gap: 10px; }
@media (max-width: 740px) {
  .layout { grid-template-columns: minmax(0, 420px); }
}

/* ---- panels ---- */
.panel {
  border: 1px solid var(--panel-line);
  background: var(--panel);
  border-radius: 6px;
  overflow: hidden;
}
.wxhead {
  background: var(--head);
  border-bottom: 1px solid var(--panel-line);
  font-size: 15.5px;
  font-weight: 700;
  text-align: center;
  padding: 3px 4px;
}
.wxbody { padding: 6px 7px 9px; }

/* ---- warnings strip ---- */
#warnings { text-align: center; margin: 2px auto 8px; max-width: 720px; }
.warn-none { font-size: 13px; color: var(--muted); }
.warn-chip {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 2px 9px;
  margin: 2px 3px;
  border: 1px solid rgba(0, 0, 0, 0.55);
  border-radius: 999px;
  background: #eee;
  color: #000;
}
.w-tc { background: #ffb84d; }
.w-amber, .w-firey, .w-thunder { background: #ffcc00; }
.w-red, .w-firer { background: #ff2a00; color: #fff; }
.w-black { background: #000; color: #fff; }
.w-monsoon { background: #99e0ff; }
.w-hot { background: #ff7733; color: #fff; }
.w-cold, .w-frost { background: #4d88ff; color: #fff; }
.w-flood { background: #33aa33; color: #fff; }
.w-landslip { background: #996633; color: #fff; }
.w-tsunami { background: #6600cc; color: #fff; }

/* ---- pill tabs ---- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 5px;
  margin: 3px 0 7px;
}
.tabs a {
  font-size: 12.5px;
  line-height: 1;
  padding: 5px 9px;
  border: 1px solid var(--tab-line);
  border-radius: 999px;
  background: var(--tab-bg);
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.tabs a.active {
  background: var(--link);
  border-color: var(--link);
  color: var(--panel);
  font-weight: 700;
}

/* ---- map ---- */
.map-box {
  position: relative;
  aspect-ratio: 350 / 273;
  max-width: 370px;
  border: 1px solid var(--coast);
  border-radius: 4px;
  user-select: none;
  overflow: hidden;
  background: var(--sea);
}
.map-base { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#map-labels { position: absolute; inset: 0; }
.map-stn {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--map-label);
  text-shadow: 0 0 2px var(--map-halo), 0 0 2px var(--map-halo), 0 0 3px var(--map-halo);
}
.map-stn:hover { color: var(--link); }
.map-stn.c-plain { color: var(--map-label); }
.wind-arrow { display: inline-block; margin-right: 1px; }

/* ---- element table ---- */
.tbl-head { font-size: 13px; font-weight: 700; margin: 2px 0 4px; }
.rows { columns: 2; column-gap: 16px; }
.rows.wide { columns: 1; max-width: 330px; }
@media (max-width: 360px) { .rows { columns: 1; } }
.r {
  display: flex;
  justify-content: space-between;
  break-inside: avoid;
  font-size: 13px;
  padding: 1px 0;
}
.r .stn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r .data { font-variant-numeric: tabular-nums; text-align: right; }

/* ---- severity colors ---- */
.c-yellow { color: var(--c-yellow); font-weight: 700; }
.c-orange { color: var(--c-orange); font-weight: 700; }
.c-red { color: var(--c-red); font-weight: 700; }
.c-magenta { color: var(--c-magenta); font-weight: 700; }
.c-blue { color: var(--c-blue); font-weight: 700; }
.c-cyan { color: var(--c-cyan); font-weight: 700; }

/* ---- side panels ---- */
.radar-body { text-align: center; }
#radar-img {
  width: 100%;
  max-width: 288px;
  display: inline-block;
  border: 1px solid var(--coast);
  border-radius: 4px;
}

#flw p { margin: 0 0 6px; font-size: 13px; }
#flw p.b { font-weight: 700; }
.tiny { font-size: 11px; color: var(--muted); margin-top: 3px; }

.fnd-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 1px 0;
}
.fnd-date { flex: 0 0 74px; }
.fnd-icon { width: 22px; height: 22px; }
.fnd-temp { flex: 1; font-variant-numeric: tabular-nums; }
.fnd-psr { color: var(--muted); }

/* ---- AQHI ---- */
.aq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px 12px; }
@media (max-width: 360px) { .aq-grid { grid-template-columns: 1fr; } }
.aq-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 1px 0; }
.aq-row .stn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aq-badge {
  min-width: 26px;
  text-align: center;
  font-weight: 700;
  border-radius: 4px;
  padding: 0 5px;
  color: #000;
}
.aq-1 { background: #3aa757; color: #fff; }   /* low 1-3 */
.aq-2 { background: #f9ab1a; }                /* moderate 4-6 */
.aq-3 { background: #ed1b24; color: #fff; }   /* high 7 */
.aq-4 { background: #93353f; color: #fff; }   /* very high 8-10 */
.aq-5 { background: #000; color: #fff; }      /* serious 10+ */

.pchart {
  width: 100%;
  height: auto;
  display: block;
  background: var(--chart-bg);
  border: 1px solid var(--chart-grid);
  border-radius: 4px;
}
.pchart .grid { stroke: var(--chart-grid); stroke-width: 0.6; }
.pchart .ax { font-size: 8px; fill: var(--chart-ax); }
.pchart .s1 { stroke: var(--s1); }
.pchart .s2 { stroke: var(--s2); }
.pchart .s3 { stroke: var(--s3); }
.leg-s1 { color: var(--s1); }
.leg-s2 { color: var(--s2); }
.leg-s3 { color: var(--s3); }

.site-foot {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-top: 14px;
}
