:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6b7c;
  --line: #dde3ea;
  --accent: #51247a;          /* UQ purple */
  --accent-soft: #efe8f6;
  --ok: #2e7d32;
  --warn: #b26a00;
  --off: #8a94a0;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1b2129;
    --text: #e6eaf0;
    --muted: #9aa6b4;
    --line: #2c3540;
    --accent: #b893e0;
    --accent-soft: #2a2238;
    --ok: #66bb6a;
    --warn: #ffb74d;
    --off: #6b7682;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

h1 { margin: 0; font-size: 22px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px 0 12px; }

/* Logo is dark grey on transparent, so the header stays white in both themes
   and uses fixed colours rather than the theme variables */
.brand { background: #fff; border-bottom: 3px solid #51247a; color: #3c3c3c; }
.brand-inner { display: flex; align-items: center; gap: 14px 28px; flex-wrap: wrap; padding-top: 14px; padding-bottom: 14px; }
.logo { display: block; height: auto; width: 100%; max-width: 520px; flex: 0 1 520px; }
.title { border-left: 2px solid #c8c8c8; padding-left: 24px; flex: 1 1 260px; }
.title h1 { color: #51247a; font-size: 24px; line-height: 1.2; }
.sub { margin: 2px 0 0; font-size: 13px; color: #5d5d5d; }
.updated { margin: 2px 0 0; font-size: 12px; color: #767676; }
@media (max-width: 900px) {
  .title { border-left: 0; padding-left: 0; }
}
@media (max-width: 600px) {
  .brand-inner { padding-top: 10px; padding-bottom: 10px; }
  .title h1 { font-size: 20px; }
}

/* ── Current conditions ─────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; border-top: 4px solid var(--c, var(--accent));
}
.card h3 { margin: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.card .temp { font-size: 30px; font-weight: 600; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 6px 0 8px; font-size: 13px; }
.card dt { color: var(--muted); }
.card dd { margin: 0; font-variant-numeric: tabular-nums; }
.card .age { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.warn { background: var(--warn); }
.dot.off { background: var(--off); }
.card.offline .temp { color: var(--off); }

/* Cards link to each station's page */
a.card { display: block; color: inherit; text-decoration: none; transition: box-shadow .15s, transform .15s; }
a.card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.12); transform: translateY(-1px); }
a.card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.card .more { display: block; margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--accent); opacity: 0; transition: opacity .15s; }
a.card:hover .more, a.card:focus-visible .more { opacity: 1; }
@media (hover: none) { .card .more { opacity: 1; } }
.hint { margin: -6px 0 12px; font-size: 13px; color: var(--muted); }

/* ── Station page ───────────────────────────────────── */
.back { display: inline-block; margin-top: 22px; color: var(--accent); font-weight: 600; text-decoration: none; font-size: 14px; }
.back:hover { text-decoration: underline; }
.station-head {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  border-left: 6px solid var(--c, var(--accent)); padding: 16px 18px; margin-top: 12px;
}
.station-name { margin: 0 0 4px; font-size: 24px; text-transform: none; letter-spacing: 0; color: var(--text); }
.station-meta { margin: 2px 0; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 14px; }
.stat { background: var(--bg); border-radius: 8px; padding: 8px 12px; }
.stat-label { display: block; font-size: 12px; color: var(--muted); }
.stat-value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 12px; font-weight: 400; color: var(--muted); }

.summary-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 4px 16px 0; }
.summary-head h2 { margin: 12px 0 0; }
.summary-head .btn { border: 0; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; }
.table-wrap { max-height: 560px; overflow: auto; margin: 10px 0 0; border-top: 1px solid var(--line); }
table.daily { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.daily th, .daily td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.daily thead th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-weight: 600; font-size: 12px; vertical-align: bottom; z-index: 1; }
.daily thead th small { font-weight: 400; }
.daily th:first-child { text-align: left; }
.daily tbody th { font-weight: 600; }
.daily tbody tr:hover { background: var(--accent-soft); }
.daily tr.partial td, .daily tr.partial th { color: var(--muted); font-style: italic; }

/* ── Explore panel ──────────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-top: 28px; }
.controls { display: grid; gap: 14px; padding: 16px; border-bottom: 1px solid var(--line); }
.control { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); width: 70px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--text);
  border-radius: 999px; padding: 4px 10px 4px 8px; font: inherit; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--c); }
.chip.on { background: var(--accent-soft); border-color: var(--c); }
.chip.on::before { background: var(--c); }
.chip-actions { display: flex; gap: 10px; }
.link { background: none; border: 0; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; padding: 0; text-decoration: underline; }

.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; border: 0; border-right: 1px solid var(--line); color: var(--text); font: inherit; font-size: 13px; padding: 6px 11px; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; }
.dates { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 13px; color: var(--muted); }
.dates input { font: inherit; font-size: 13px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); }
.btn { display: inline-block; background: var(--accent); color: #fff; text-decoration: none; padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 600; }
.btn:hover { filter: brightness(1.1); }

.tabs { display: flex; overflow-x: auto; border-bottom: 1px solid var(--line); padding: 0 8px; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 12px 14px; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }

.view { padding: 8px 12px 16px; }
.note { font-size: 12px; color: var(--muted); margin: 4px 4px 0; min-height: 18px; }
.chart { width: 100%; height: 460px; }
.map { width: 100%; height: 520px; border-radius: 8px; margin-top: 8px; }
.empty { display: grid; place-items: center; height: 100%; color: var(--muted); }
.leaflet-popup-content { font-size: 13px; line-height: 1.5; }

.about { font-size: 14px; color: var(--muted); max-width: 820px; }
.foot { color: var(--muted); font-size: 12px; padding-top: 24px; padding-bottom: 32px; }

@media (max-width: 600px) {
  .label { width: 100%; }
  .chart { height: 360px; }
  .map { height: 400px; }
  .card .temp { font-size: 26px; }
}

/* ── Location history (station page + map) ──────────── */
.loc-history { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.loc-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.loc-history h3 { margin: 0; font-size: 15px; }
.link-strong { color: var(--accent); font-weight: 600; font-size: 13px; text-decoration: none; }
.link-strong:hover { text-decoration: underline; }
.table-wrap.short { max-height: 260px; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; }
table.locs td, table.locs th { text-align: left; }
table.locs td.wrap { white-space: normal; min-width: 160px; }
table.locs tr.current th, table.locs tr.current td { font-weight: 600; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; margin-left: 4px; }
.pop-period { font-size: 12px; }
.map-legend { background: rgba(255,255,255,.92); color: #333; padding: 6px 10px; border-radius: 6px; font-size: 12px; line-height: 1.7; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -2px; background: #51247a; }
.lg.cur { border: 2px solid #fff; box-shadow: 0 0 0 1px #51247a; }
.lg.past { background: rgba(81,36,122,.35); border: 2px dashed #51247a; }
.lg.faded { background: rgba(81,36,122,.12); border: 2px solid rgba(81,36,122,.35); }

/* ── Record page ────────────────────────────────────── */
.record-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; align-items: start; }
@media (max-width: 860px) { .record-grid { grid-template-columns: 1fr; } }
.record .step { margin-top: 18px; padding: 16px; }
.record .map-step { padding: 0; overflow: hidden; }
.record h2 { margin: 0 0 12px; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 17px; display: flex; align-items: center; gap: 10px; }
.num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 14px; }
.field { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 0; }
.field input, .field select, .field textarea {
  display: block; width: 100%; margin-top: 5px; padding: 10px 11px; font: inherit; font-size: 16px; font-weight: 400;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.row { display: flex; gap: 8px; align-items: stretch; }
.row input { flex: 1; }
.row .btn { margin-top: 5px; }
.row.two > * { flex: 1; }
.help { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.help.warn { color: var(--warn); }
.btn { border: 0; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.big { display: block; width: 100%; padding: 13px; font-size: 16px; border-radius: 8px; margin-top: 4px; }
.btn.save { margin-top: 18px; background: var(--ok); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; margin-top: 10px; color: var(--muted); }
.results { list-style: none; margin: 8px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; max-height: 220px; overflow: auto; }
.results li { border-bottom: 1px solid var(--line); }
.results li:last-child { border-bottom: 0; }
.results li.help { padding: 8px 10px; margin: 0; }
.results button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); font: inherit; font-size: 13px; padding: 8px 10px; cursor: pointer; }
.results button:hover { background: var(--accent-soft); }
.hist { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; }
.hist li { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid var(--line); }
.hist li small { color: var(--muted); }
.link.danger { color: #c62828; flex: none; }
.pick-map { height: 520px; }
@media (max-width: 860px) { .pick-map { height: 380px; } }
.msg { margin-top: 14px; padding: 12px 14px; border-radius: 8px; font-size: 14px; }
.msg.ok { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }
.msg.err { background: #ffebee; color: #b71c1c; border: 1px solid #ef9a9a; }

/* ── Top navigation (inside the white header) ───────── */
.topnav { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.topnav a {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 8px;
  font-size: 14px; font-weight: 600; text-decoration: none; color: #51247a; border: 1.5px solid #d9cce6; white-space: nowrap;
}
.topnav a:hover { background: #f3edf8; }
.topnav a[aria-current="page"] { background: #51247a; border-color: #51247a; color: #fff; }
.topnav a:focus-visible { outline: 3px solid #51247a; outline-offset: 2px; }
@media (max-width: 1100px) { .topnav { margin-left: 0; width: 100%; } }
@media (max-width: 600px) { .topnav a { flex: 1; justify-content: center; padding: 9px 8px; font-size: 13px; } }
