:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --border: #e3e2dd;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #2a78d6;
  --bar: #2a78d6;
  --bar-fav: #eb6834;
  --grid: #ecebe7;
  --warn-bg: #fff4d6;
  --warn-text: #6b4a00;
  --row-hover: #f0efec;
  --critical: #d03b3b;
  --critical-text: #a32626;
  --alert-bg: #fdecec;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --border: #2e2e2b;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e86;
    --accent: #3987e5;
    --bar: #3987e5;
    --bar-fav: #d95926;
    --grid: #2a2a27;
    --warn-bg: #3a2e10;
    --warn-text: #f5d58a;
    --row-hover: #242422;
    --critical: #d03b3b;
    --critical-text: #f08a8a;
    --alert-bg: #3a1c1c;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }

.top {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 20px 24px 12px; max-width: 1400px; margin: 0 auto;
}
h1 { margin: 0; font-size: 1.5rem; }
h2 { margin: 0; font-size: 1rem; }
.sub { margin: 2px 0 0; color: var(--text-2); }
.updated { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: .875rem; }
button {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
/* Site menu shared by both pages: two big tabs */
.site-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  max-width: 1400px; margin: 0 auto; padding: 12px 24px 0;
}
.site-brand { font-weight: 800; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.site-tabs { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; }
.site-tabs a {
  text-decoration: none; color: var(--text-2); font-weight: 600; font-size: .9375rem;
  padding: 7px 14px; border-radius: 7px; white-space: nowrap;
}
.site-tabs a:hover { color: var(--text); background: var(--row-hover); }
.site-tabs a[aria-current="page"] { color: #fff; background: linear-gradient(90deg, #0ca30c, #2a78d6); }
@media (max-width: 600px) {
  .site-nav { padding: 10px 16px 0; }
  .site-tabs a { padding: 6px 10px; font-size: .875rem; }
}
.hero-link {
  display: inline-flex; align-items: baseline; gap: 6px; text-decoration: none; color: #fff; font-weight: 700;
  padding: 6px 12px; border-radius: 8px; background: linear-gradient(90deg, #0ca30c, #2a78d6);
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.hero-link span { font-weight: 500; font-size: .75rem; opacity: .9; }
.hero-link:hover { filter: brightness(1.08); }

.banner {
  max-width: 1352px; margin: 0 auto 12px; padding: 10px 14px; border-radius: 8px;
  background: var(--warn-bg); color: var(--warn-text);
}

.alerts { display: grid; gap: 8px; }
.alerts[hidden] { display: none; }
.alert {
  padding: 10px 14px; border-radius: 8px; border-left: 4px solid var(--critical);
  background: var(--alert-bg); color: var(--text);
}
.alert strong { color: var(--critical-text); }
.alert .tt-muted { color: var(--text-2); font-size: .8125rem; }

.small-link { font-size: .8125rem; }
.days { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(120px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.day {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px; text-align: center;
  display: grid; gap: 4px; justify-items: center; align-content: start;
}
.day .dname { font-weight: 600; font-size: .875rem; }
.day img { width: 56px; height: 56px; border-radius: 8px; }
.day .short { font-size: .75rem; color: var(--text-2); min-height: 2.4em; line-height: 1.2; }
.day .temps { font-variant-numeric: tabular-nums; }
.day .hi { font-weight: 600; }
.day .lo { color: var(--text-2); }
.day .rain { width: 100%; font-size: .75rem; color: var(--text-2); }
.day .rain-track { height: 4px; border-radius: 2px; background: var(--grid); margin-top: 3px; overflow: hidden; }
.day .rain-fill { height: 100%; background: var(--bar); border-radius: 2px; }
.forecast-detail { margin-top: 12px; display: grid; gap: 6px; font-size: .875rem; color: var(--text-2); }
.forecast-detail strong { color: var(--text); }

main { max-width: 1400px; margin: 0 auto; padding: 0 24px 32px; display: grid; gap: 16px; }

/* Ad row: four fixed-height ad spaces */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.tiles[hidden] { display: none; }
@media (max-width: 720px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }

/* Photo fills the full height of the box, edge to edge on the left. Fixed height so
   the ads never change size and the radar/chart stay on the first screen. */
.tile.sponsor {
  display: flex; align-items: stretch; gap: 12px; padding: 0; overflow: hidden; height: 104px;
  container-type: size; /* lets text scale with the box width */
  text-decoration: none; color: inherit; position: relative; transition: border-color .15s;
}
.sponsor[hidden] { display: none; }
.sponsor:hover { border-color: var(--accent); }
.sponsor .s-img { flex: 0 0 auto; height: 100%; aspect-ratio: 1 / 1; position: relative; background: #fff; max-width: 50%; }
.sponsor .s-img { overflow: hidden; }
.sponsor .s-house {
  display: grid; place-items: center; background: var(--grid); color: var(--muted);
  font-weight: 800; font-size: 1.25rem; letter-spacing: .08em;
}
.sponsor:not([href]) { cursor: default; border-style: dashed; }
.sponsor:not([href]):hover { border-color: var(--border); }
/* product shots have a wide white border; zoom in so the pedal itself fills the square */
.sponsor img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transform: scale(var(--zoom, 1.35)); }
.sponsor .s-body { align-self: center; padding: 4px 12px 4px 0; min-width: 0; }
/* text grows with the box width (cqw = % of box width), within sensible limits */
.sponsor .s-tag { font-size: clamp(.6875rem, 4.2cqw, .8125rem); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sponsor .s-title { font-weight: 700; font-size: clamp(.875rem, 6.8cqw, 1.375rem); line-height: 1.15; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sponsor .s-line { font-size: clamp(.75rem, 4.8cqw, .9375rem); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sponsor .s-cta { font-size: clamp(.8125rem, 5.6cqw, 1.0625rem); color: var(--accent); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@container (max-width: 260px) { .sponsor .s-shop { display: none; } }
.sponsor .s-body { min-width: 0; transition: opacity .25s; }
.sponsor.fading .s-body, .sponsor.fading img { opacity: 0; }
.sponsor img { transition: opacity .25s; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tile .label { color: var(--text-2); font-size: .8125rem; }
.tile .value { font-size: 1.75rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .value small { font-size: .9rem; font-weight: 500; color: var(--text-2); }
.tile .detail { color: var(--muted); font-size: .8125rem; margin-top: 2px; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 960px) { .grid { grid-template-columns: 1fr; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.note { color: var(--muted); font-size: .8125rem; margin: 10px 0 0; }

#radar-img { display: block; width: 100%; height: auto; border-radius: 8px; background: #000; aspect-ratio: 600 / 550; object-fit: contain; }
.map-frame { position: relative; }
/* soften the colorful street map so the rainfall colors stand out */
.rain-basemap { filter: grayscale(.85) brightness(1.05) contrast(.9); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .rain-basemap { filter: grayscale(1) invert(1) brightness(.85) contrast(.9); }
}
#rain-map { width: 100%; aspect-ratio: 600 / 550; border-radius: 8px; overflow: hidden; background: var(--grid); }
#rain-map[hidden], .view-radar[hidden], .view-rain[hidden] { display: none; }
.small-note { font-size: .8125rem; color: var(--text-2); }
/* Color scale: fixed size, short and wide, sits in the card header next to the view buttons */
.rain-scale { flex: 0 0 auto; width: 180px; }
.rain-scale[hidden] { display: none; }
.rain-scale .rs-bar { height: 10px; border-radius: 3px; }
.rain-scale .rs-ticks {
  display: grid; grid-template-columns: 1fr auto 1fr; margin-top: 2px;
  font-size: .75rem; line-height: 1.2; color: var(--text-2); font-variant-numeric: tabular-nums;
}
.rain-scale .rs-ticks span { white-space: nowrap; }
.rain-scale .rs-title { color: var(--text); font-weight: 600; text-align: center; }
.rain-scale .rs-hi { text-align: right; }

/* Hover readout: fixed-size one-line strip, centered at the top of the map */
.rain-readout {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 800;
  width: min(300px, calc(100% - 110px)); height: 26px; box-sizing: border-box; /* room for the zoom buttons */
  padding: 4px 10px; border-radius: 13px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); box-shadow: 0 1px 4px rgba(0,0,0,.15);
  font: 12px/16px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.rain-readout strong { color: var(--text); font-variant-numeric: tabular-nums; }
.rain-dots {
  display: flex; align-items: center; gap: 4px; cursor: pointer;
  background: var(--surface); color: var(--text-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 3px 7px; font: 12px/16px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.rain-dots input { margin: 0; }
select, input[type="search"] {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
}

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 5px 10px; font-size: .8125rem; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-selected="true"] { background: var(--accent); color: #fff; }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .axis-label { fill: var(--text-2); font-size: 12px; }
.chart .value-label { fill: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .hit { fill: transparent; cursor: default; }
.chart .divider { stroke: var(--border); stroke-dasharray: 3 3; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: .8125rem; color: var(--text-2); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; background: var(--c); }
.chart .row:hover .bar { opacity: .85; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

.tooltip {
  position: fixed; pointer-events: none; z-index: 10;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: .8125rem; box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
.tooltip strong { display: block; }
.tooltip .tt-muted { color: var(--text-2); }

.filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--text-2); font-size: .875rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { text-align: left; color: var(--text-2); font-weight: 500; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--surface); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
th[aria-sort="descending"]::after { content: " ↓"; }
th[aria-sort="ascending"]::after { content: " ↑"; }
tbody tr:hover { background: var(--row-hover); }
td.zero { color: var(--muted); }
td .groups { color: var(--muted); font-size: .75rem; }
.star { border: 0; background: none; padding: 0 4px; font-size: 1rem; color: var(--muted); }
.star[aria-pressed="true"] { color: var(--bar-fav); }
.badge { display: inline-block; font-size: .6875rem; padding: 1px 6px; border-radius: 999px; background: var(--warn-bg); color: var(--warn-text); margin-left: 6px; }
tr.fav td { font-weight: 600; }

@media (max-width: 600px) {
  .top { padding: 16px 16px 8px; }
  main { padding: 0 16px 24px; }
}
