:root {
    font-family: "Helvetica Neue", Arial, sans-serif;
    color: #203142;
    --accent: #176caa;
    --muted: #627385;
    --shadow: 0 3px 18px #20314220;
}
* { box-sizing: border-box; }
body { margin: 0; }
#mapid { width: 100%; height: 100vh; height: 100dvh; z-index: 0; }
button { font: inherit; cursor: pointer; color: inherit; border: 0; background: transparent; min-height: 44px; padding: 10px 14px; border-radius: 9px; touch-action: manipulation; }
button:disabled { opacity: .6; cursor: wait; }
button:hover { background: #edf3f7; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.panel { background: #fff; border: 1px solid #dce4ea; border-radius: 14px; box-shadow: var(--shadow); }
.brand { position: absolute; z-index: 500; top: max(18px, env(safe-area-inset-top)); left: 20px; background: #ffffffed; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); }
.brand strong { display: block; font-size: 21px; letter-spacing: -.7px; }
.brand span { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.map-tools { position: absolute; z-index: 500; top: max(18px, env(safe-area-inset-top)); right: 20px; display: flex; align-items: center; gap: 12px; padding: 5px; }
.control-icon { display: block; width: 24px; height: 24px; }
.map-tools > button, .weather-types button { display: grid; place-items: center; min-width: 44px; padding: 10px; }
.units { display: flex; border-left: 1px solid #dce4ea; padding-left: 6px; }
[data-selected="1"], [data-type-selected="1"] { color: var(--accent); background: #e7f2fb; font-weight: 700; }
.weather-types { position: absolute; z-index: 500; top: 85px; right: 20px; display: flex; padding: 5px; gap: 4px; }
.status { position: absolute; z-index: 600; left: 50%; top: 145px; transform: translateX(-50%); padding: 12px 18px; font-size: 13px; width: max-content; max-width: calc(100% - 32px); }
.location-status { top: 200px; }
.legend { position: absolute; z-index: 400; left: 20px; bottom: 32px; width: 300px; padding: 14px 16px; }
.legend strong { font-size: 13px; display: block; }
.legend strong span { color: var(--muted); font-weight: 400; margin-left: 6px; }
.legend-scale { display: flex; overflow: hidden; border-radius: 4px; margin-top: 12px; height: 8px; }
.legend-scale span { flex: 1; }
.legend-labels { display: flex; justify-content: space-between; margin: 5px 12% 0; font-size: 11px; color: var(--muted); }
.legend small { display: block; margin-top: 10px; font-size: 10px; color: var(--muted); line-height: 1.5; }
.weather-marker { border: 2px solid white; border-radius: 50%; font-size: 14px; font-weight: 700; text-align: center; line-height: 32px; box-shadow: 0 2px 5px #20314250; font-variant-numeric: tabular-nums; }
.weather-marker.selected { outline: 3px solid #203142; outline-offset: 3px; }
.weather-marker > div {
    position: relative;
}

.cluster-badge {
    position: absolute;
    top: 0;
    right: 0;
    transform: translate(40%, -40%);
    display: block;
    width: 18px;
    height: 18px;
}
.temp_0 { background: #7462b4; color: white; }
.temp_1 { background: #91c5ed; color: #173b58; }
.temp_2 { background: #a6d9b0; color: #23472c; }
.temp_3 { background: #f5d081; color: #573d15; }
.temp_4 { background: #ed9b65; color: #572b15; }
.temp_5 { background: #b64a4a; color: white; }
.wind_0 { background: #d5eaf6; color: #24465b; }
.wind_1 { background: #9bcfc4; color: #224d43; }
.wind_2 { background: #efd186; color: #573d15; }
.wind_3 { background: #e89b77; color: #572b15; }
.wind_4 { background: #ca6262; color: white; }
.wind_5 { background: #813d56; color: white; }
.rain_0 { background: #edf1ed; color: #435447; }
.rain_1 { background: #bfe3ed; color: #22485a; }
.rain_2 { background: #89c8e5; color: #173b58; }
.rain_3 { background: #439bc8; color: #102b3d; }
.rain_4 { background: #2968a4; color: white; }
.rain_5 { background: #334775; color: white; }
.humidity_0 { background: #eee5f2; color: #50395d; }
.humidity_1 { background: #d7c8e8; color: #50395d; }
.humidity_2 { background: #b9a5d4; color: #332348; }
.humidity_3 { background: #927bb8; color: #211a31; }
.humidity_4 { background: #735794; color: white; }
.humidity_5 { background: #503963; color: white; }
.station-panel { position: absolute; z-index: 600; right: 80px; bottom: 32px; width: 360px; padding: 22px; max-height: calc(100dvh - 170px); overflow-y: auto; }
[hidden] { display: none !important; }
.close { position: absolute; top: 5px; right: 5px; width: 44px; font-size: 26px; color: var(--muted); }
h1 { font-size: 19px; margin: 0 25px 5px 0; overflow-wrap: anywhere; }
.date { color: var(--muted); font-size: 12px; margin: 0; }
.station-current { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 18px 0; }
.station-temperature { display: flex; align-items: center; gap: 6px; font-size: 48px; letter-spacing: -2px; white-space: nowrap; }
.station-temperature strong { font-weight: 650; }
.station-temperature small { font-size: 19px; color: var(--muted); font-weight: 400; letter-spacing: 0; margin-left: 3px; }
.sky-icon { display: block; width: 36px; height: 36px; object-fit: contain; }
#station-sky:empty { display: none; }
#station-sky .sky-icon { width: 58px; height: 58px; }
.metric-icon { width: 22px; height: 22px; flex-shrink: 0; }
.station-wind { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 70px; }
.station-wind > .metric-icon { color: var(--muted); width: 27px; height: 27px; }
.station-wind > strong { font-size: 21px; font-weight: 600; white-space: nowrap; }
.station-wind small { font-size: 10px; font-weight: 400; color: var(--muted); }
.station-gust { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); }
.station-gust .metric-icon { width: 14px; height: 14px; }
.wind-direction { font-size: 10px; color: var(--muted); letter-spacing: 1px; }
.station-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.station-grid > div { position: relative; display: flex; justify-content: center; align-items: center; gap: 4px; min-width: 0; }
.station-grid .metric-icon { width: 19px; height: 19px; color: var(--muted); }
.station-grid strong { font-size: 17px; font-weight: 600; white-space: nowrap; }
.station-grid small { font-size: 10px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.rain-period { position: absolute; top: 23px; font-size: 9px; color: var(--muted); }
.station-forecast, .forecast-status { border-top: 1px solid #e4eaf0; margin-top: 26px; padding-top: 16px; }
.forecast-status { font-size: 12px; color: var(--muted); }
.forecast-days { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; }
.forecast-day { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.forecast-weekday { font-size: 12px; font-weight: 500; }
.forecast-temperatures { display: flex; gap: 5px; font-size: 13px; white-space: nowrap; }
.forecast-temperatures strong { font-weight: 600; }
.forecast-temperatures > span { color: var(--muted); }
.forecast-rain { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--accent); font-size: 11px; }
.forecast-rain .metric-icon { width: 13px; height: 13px; }
.forecast-no-icon { height: 36px; line-height: 36px; color: var(--muted); }
.forecast-credit { margin: 14px 0 0; text-align: center; color: var(--muted); font-size: 10px; }
.forecast-credit a { color: inherit; text-underline-offset: 2px; }
.leaflet-bar { border: 1px solid #dce4ea !important; border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.leaflet-bar a { width: 44px !important; height: 44px !important; line-height: 44px !important; color: #203142; }
.leaflet-bottom.leaflet-right { margin: 0 10px 16px 0; }
.leaflet-control-attribution { font-size: 9px; }
@media (max-width: 600px) {
    .brand { top: max(12px, env(safe-area-inset-top)); left: 12px; padding: 9px 12px; }
    .brand strong { font-size: 18px; }
    .brand span { display: none; }
    .map-tools { top: max(12px, env(safe-area-inset-top)); right: 12px; gap: 2px; padding: 3px; }
    .units button { padding: 8px 10px; }
    .weather-types { top: auto; bottom: calc(22px + env(safe-area-inset-bottom)); left: 50%; right: auto; transform: translateX(-50%); gap: 4px; padding: 4px; }
    .legend { left: 12px; bottom: calc(88px + env(safe-area-inset-bottom)); width: min(270px, calc(100% - 82px)); padding: 10px 12px; }
    .legend small { display: none; }
    .legend-scale { margin-top: 8px; }
    .legend strong { font-size: 12px; }
    .station-panel { left: 12px; right: 12px; bottom: calc(88px + env(safe-area-inset-bottom)); width: auto; padding: 18px; max-height: calc(100dvh - 170px - env(safe-area-inset-bottom)); }
    .status { top: 80px; }
    .location-status { top: 130px; }
    .leaflet-bottom.leaflet-right { margin-bottom: calc(88px + env(safe-area-inset-bottom)); margin-right: 4px; }
    .leaflet-control-attribution { position: fixed; bottom: 0; right: 0; max-width: 100%; }
}
@media (max-width: 360px) {
    .station-temperature { font-size: 40px; gap: 3px; }
    .station-temperature small { font-size: 16px; }
    #station-sky .sky-icon { width: 44px; height: 44px; }
    .station-grid strong { font-size: 15px; }
    .station-grid .metric-icon { width: 16px; height: 16px; }
    .station-grid > div { gap: 3px; }
    .station-grid small { font-size: 9px; }
    .forecast-temperatures { font-size: 12px; gap: 3px; }
}

/* Station history */
.history-button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 20px; background: #e7f2fb; color: var(--accent); font-weight: 600; }
.history-button:hover { background: #d9eaf8; }
#history-dialog { width: min(960px, calc(100% - 40px)); max-height: calc(100dvh - 48px); padding: 0; border: 1px solid #dce4ea; border-radius: 18px; color: #203142; box-shadow: 0 20px 80px #152a4440; }
#history-dialog::backdrop { background: #14283c70; }
.history-header { position: sticky; top: 0; z-index: 1; background: white; padding: 24px 24px 18px; border-bottom: 1px solid #e4eaf0; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
#history-title { margin: 0 30px 16px 0; font-size: 25px; overflow-wrap: anywhere; }
.history-periods { display: flex; gap: 4px; width: fit-content; border: 1px solid #e4eaf0; border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.history-periods button { min-width: 68px; }
.history-periods [aria-pressed="true"] { color: var(--accent); background: #e7f2fb; font-weight: 700; }
#history-description { line-height: 1.6; }
.history-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 20px 24px; background: #f5f8fa; }
.history-charts:empty { min-height: 160px; }
.history-chart { min-width: 0; background: white; border: 1px solid #e0e8ee; border-radius: 12px; padding: 16px 12px 10px; }
.chart-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 4px 12px; }
.chart-heading h3 { font-size: 14px; margin: 0; font-weight: 600; }
.chart-heading span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.history-chart svg { display: block; width: 100%; color: var(--chart-color); }
.history-chart svg:focus-visible { outline: 2px solid var(--accent); border-radius: 5px; }
.chart-grid { stroke: #e9eef2; stroke-width: 1; }
.chart-axis { fill: #627385; font: 16px Arial, sans-serif; }
.chart-readout { font-size: 11px; color: var(--muted); margin: 9px 4px 0; min-height: 16px; }
.chart-empty { color: var(--muted); text-align: center; padding: 50px 0; font-size: 13px; }
.history-note { margin: 0; padding: 16px 24px; color: var(--muted); font-size: 11px; line-height: 1.6; border-top: 1px solid #e4eaf0; }
@media (max-width: 900px) {
    #history-dialog { width: 100%; max-width: none; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
    .history-header { padding: max(16px, env(safe-area-inset-top)) 16px 12px; }
    .history-periods { width: 100%; }
    .history-periods button { flex: 1; min-width: 0; }
    .history-charts { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
    .chart-axis { font-size: 12px; }
    .chart-heading h3 { font-size: 16px; }
    .chart-heading span { font-size: 12px; }
    .chart-readout { font-size: 13px; min-height: 20px; }
    .history-note { padding: 12px 16px max(12px, env(safe-area-inset-bottom)); }
}

/* About lives in the copyright link, leaving the map uncluttered. */
.station-panel h2 { font-size: 19px; margin: 0 25px 5px 0; overflow-wrap: anywhere; }
#about-dialog { width: min(540px, calc(100% - 24px)); max-width: calc(100% - 24px); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid #dce4ea; border-radius: 16px; color: #203142; box-shadow: 0 20px 80px #152a4440; line-height: 1.65; }
#about-dialog::backdrop { background: #14283c70; }
.about-header { position: sticky; top: 0; z-index: 1; padding: 20px 28px 8px; background: white; border-bottom: 1px solid #e4eaf0; }
.about-content { padding: 0 28px 24px; }
#about-title { font-size: 28px; margin: 0; letter-spacing: -.7px; }
.about-intro { margin-top: 0; color: var(--muted); }
#about-dialog h2 { font-size: 16px; margin: 24px 0 6px; }
#about-dialog p { font-size: 14px; }
#about-dialog a { color: var(--accent); }
#about-dialog footer { border-top: 1px solid #e4eaf0; padding-top: 16px; margin-top: 24px; color: var(--muted); font-size: 12px; }
.noscript-message { position: fixed; inset: 0; z-index: 1000; padding: 32px; background: white; overflow: auto; line-height: 1.6; }
.noscript-message h2 { font-size: 24px; }
