:root {
  --ink: #1c1915;
  --muted: #5e584f;
  --paper: #f4f0e8;
  --panel: #fffcf7;
  --line: #ddd4c4;
  --focus: #1d4e3a;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100%;
  color: var(--ink);
  background: var(--paper);
  font: 16px/1.45 "Segoe UI", "PingFang HK", "Noto Sans CJK HK", "Noto Sans CJK TC", "Noto Sans TC", "Noto Sans", sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button { font: inherit; color: inherit; }

a { color: var(--focus); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.wrap {
  max-width: 40rem;
  margin: 0 auto;
}

.utility {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 0;
}

.home-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 14px 8px 8px;
  border: 1px solid #c9bfae;
  border-radius: 999px;
  background: #fff;
  color: var(--focus);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.home-link:hover { border-color: var(--ink); color: var(--ink); }

.home-chevron {
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
  transform: translateY(-1px);
}

.lang-switch {
  display: inline-flex;
  border: 1px solid #c9bfae;
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
}

.lang-switch button {
  min-height: 44px;
  min-width: 44px;
  border: 0;
  background: transparent;
  padding: 8px 14px;
  font-weight: 650;
}

.lang-switch button + button { border-left: 1px solid #c9bfae; }

.lang-switch button[aria-pressed="true"] {
  background: var(--ink);
  color: #fbf8f2;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  padding: 12px 16px 8px;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-family: Palatino, "Palatino Linotype", "Iowan Old Style", "Times New Roman", serif;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}

.header-note {
  margin: 0;
  max-width: 18rem;
  color: var(--muted);
  text-align: right;
}

.disclaimer {
  margin: 0 16px 10px;
  padding: 8px 12px;
  border: 1px solid #e7c07a;
  background: #fff6df;
  color: #3f2e10;
  font-size: 13.5px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 16px 12px;
}

.status {
  flex: 1;
  margin: 0;
  padding: 10px 12px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-left-width: 6px;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
}

.status[data-state="loading"] { color: var(--muted); }
.status[data-state="stale"] { background: #fffaf0; }
.status[data-state="error"],
.status[data-state="partial"] { background: #f6f3ec; }

#refresh {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 14px;
  border: 1px solid #c9bfae;
  border-radius: 999px;
  background: #fff;
  font-weight: 650;
}

#refresh:disabled { opacity: 0.55; }

.legend {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 8px 16px 10px;
  background: var(--paper);
  color: var(--muted);
  font-size: 13px;
}

.legend span { display: block; }

.station {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(5.2rem, 0.8fr) minmax(5.6rem, 0.9fr);
  gap: 4px 12px;
  align-items: center;
}

.stations {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0 16px 18px;
}

.station {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.station h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.metric {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

.num {
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.cap {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.empty {
  margin: 0 16px 16px;
  color: var(--muted);
}

.credits {
  padding: 12px 16px 18px;
  border-top: 1px solid var(--line);
  background: #ebe4d6;
  font-size: 12.5px;
  color: #3f3a33;
}

.credits p { margin: 0 0 8px; }
.credits p:last-child { margin-bottom: 0; }

@media (max-width: 640px) {
  .top { flex-direction: column; align-items: flex-start; }
  .header-note { text-align: left; max-width: none; }
  .status-row { align-items: stretch; }
  #refresh { align-self: center; }
}

@media (max-width: 380px) {
  .num { font-size: 1.45rem; }
  .station { gap: 4px 8px; }
}
