:root {
  --bg: #f3f5f4;
  --card: #ffffff;
  --text: #1c2622;
  --muted: #5d6b65;
  --line: #dfe5e2;
  --accent: #2f7d5b;
  --accent-soft: #e3f1ea;
  --yellow: #f5c518;
  --orange: #f08a24;
  --red: #d93a2b;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111715;
    --card: #1a2320;
    --text: #e7eeea;
    --muted: #9aaba3;
    --line: #2a3632;
    --accent: #5cc295;
    --accent-soft: #1f3a2e;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.topbar {
  /* Brand on the left, town search centred on the page. */
  display: grid;
  grid-template-columns: 1fr minmax(0, 440px) 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }

.brand { justify-self: start; }

.picker { display: flex; gap: 6px; margin: 0; }

@media (max-width: 640px) {
  .topbar { grid-template-columns: 1fr; justify-items: center; }
  .brand { justify-self: center; }
  .picker { width: 100%; }
}

.search { position: relative; flex: 1; }
.search input {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
}
.search input:focus { outline: none; border-color: var(--accent); }
.results {
  position: absolute;
  z-index: 10;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}
.results li { padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.results li .detail { color: var(--muted); font-size: 13px; margin-left: 6px; }
.results li.active, .results li:hover { background: var(--accent-soft); }
.results li.note { color: var(--muted); cursor: default; background: none; }

/* Pin for the place whose forecast is showing. */
.pin {
  width: 18px;
  height: 18px;
  border-radius: 50% 50% 50% 0;
  background: var(--red);
  border: 2px solid #fff;
  transform: rotate(-45deg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
}

select, button {
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

button:hover, select:hover { border-color: var(--accent); }

/* Warnings, under the map */
.warnings { display: grid; gap: 8px; }
.warnings[hidden] { display: none; }

.warning {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  border-left: 6px solid var(--yellow);
  background: var(--card);
}
.warning.orange { border-left-color: var(--orange); }
.warning.red { border-left-color: var(--red); }
.warning summary { cursor: pointer; font-weight: 600; }
.warning .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.warning p { margin: 6px 0 0; }
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 99px;
  margin-right: 6px;
  color: #1c2622;
  background: var(--yellow);
}
.badge.orange { background: var(--orange); }
.badge.red { background: var(--red); color: #fff; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  padding: 16px;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.map-wrap {
  position: relative;
  min-height: 70vh;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--card);
}

#map { position: absolute; inset: 0; }

.main-col { display: grid; gap: 16px; align-content: start; min-width: 0; }

/* Crosshair over the map, so it is clear where the readout is taken. */
.map-wrap .maplibregl-canvas-container.maplibregl-interactive { cursor: crosshair; }
.map-wrap .maplibregl-canvas-container.maplibregl-interactive:active { cursor: grabbing; }

/* Big readout of the value under the cursor, top centre of the map. */
.readout {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  pointer-events: none;
  text-align: center;
  background: rgba(255, 255, 255, .88);
  color: #1c2622;
  border-radius: 14px;
  padding: 6px 18px 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
  white-space: nowrap;
}
.readout[hidden] { display: none; }
.readout .value { font-size: 44px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.readout .value .unit { font-size: 22px; font-weight: 700; margin-left: 4px; }
.readout .value .arrow { display: inline-block; font-size: 30px; margin-right: 6px; }
.readout .label { font-size: 13px; color: #4a5853; }
@media (max-width: 600px) { .readout .value { font-size: 32px; } }

.map-controls {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  pointer-events: none;
}
.map-controls > * { pointer-events: auto; }

.layers, .radar-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--card);
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
.layers button { border: none; }
.layers button.on { background: var(--accent); color: #fff; }
.radar-bar { flex: 1; min-width: 240px; max-width: 460px; padding: 4px 10px 4px 4px; }
.radar-bar input { flex: 1; accent-color: var(--accent); }
.radar-bar span { font-variant-numeric: tabular-nums; font-size: 13px; min-width: 92px; text-align: right; }
.radar-bar[hidden] { display: none; }

.legend {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
.legend[hidden] { display: none; }
.legend .bar { width: 160px; height: 10px; border-radius: 5px; }

/* Map markers */
.marker {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  color: #fff;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
}
.marker .arrow { display: inline-block; }
.marker.selected { outline: 2px solid #fff; outline-offset: 1px; }

/* Written forecasts, under the map */
.texts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.text-fc h2 { margin-bottom: 4px; }
.text-fc .issued, .text-fc .muted { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.text-fc h3 { font-size: 14px; margin: 10px 0 2px; }
.text-fc p { margin: 0; }
.text-fc .note { color: var(--muted); font-size: 12px; margin-top: 10px; }

/* Side panel */
.panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; min-width: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card h2 { font-size: 14px; margin: 0 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.current .place { font-size: 20px; font-weight: 700; }
.current .updated { color: var(--muted); font-size: 13px; }
.current .big { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.current .temp { font-size: 52px; font-weight: 700; line-height: 1; }
.current .sym { font-size: 46px; }
.current .desc { color: var(--muted); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin: 0; }
.stats dt { color: var(--muted); font-size: 13px; }
.stats dd { margin: 0 0 4px; font-weight: 600; }

.hourly { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
.hour {
  flex: 0 0 56px;
  text-align: center;
  padding: 6px 2px;
  border-radius: 8px;
  background: var(--accent-soft);
  font-size: 13px;
}
.hour .s { font-size: 22px; }
.hour .t { font-weight: 700; }
.hour .r { color: #2a6fd6; font-size: 12px; }
.hour .w { color: var(--muted); font-size: 12px; }

.daily { display: grid; gap: 2px; }
.day {
  display: grid;
  grid-template-columns: 52px 32px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.day:last-child { border-bottom: none; }
.day .name { font-weight: 600; }
.day .s { font-size: 22px; }
.day .extra { color: var(--muted); font-size: 13px; }
.day .range { font-variant-numeric: tabular-nums; }
.day .range .lo { color: var(--muted); margin-left: 6px; }

.ad-slot { margin: 0 16px; min-height: 90px; }
.panel .ad-slot { margin: 0; min-height: 250px; }

.footer { padding: 8px 16px 24px; color: var(--muted); font-size: 13px; }

.error { color: var(--red); }
