:root {
    --bg: #09111d;
    --panel: rgba(255, 255, 255, 0.06);
    --panel-strong: rgba(255, 255, 255, 0.1);
    --text: #eef4fb;
    --muted: #a9b8ca;
    --line: rgba(255, 255, 255, 0.12);
    --online: #48c78e;
    --warning: #f2b134;
    --error: #f16b6b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(76, 141, 255, 0.25), transparent 30%),
        radial-gradient(circle at top right, rgba(72, 199, 142, 0.16), transparent 28%),
        linear-gradient(180deg, #0b1321 0%, #07101b 100%);
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.hero {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

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

.refresh-toggle {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border-radius: 999px;
    padding: 10px 14px;
    margin-top: 4px;
    font: inherit;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.refresh-toggle__icon {
    width: 1.1em;
    text-align: center;
}

.refresh-toggle:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.09);
}

.refresh-toggle[aria-pressed="true"] {
    border-color: rgba(242, 177, 52, 0.45);
    background: rgba(242, 177, 52, 0.12);
    color: #ffd37c;
}

h1, h2, h3 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 700;
}

h1 {
    font-size: clamp(2.4rem, 4vw, 4.6rem);
    line-height: 0.98;
    max-width: 12ch;
}

.lead {
    max-width: 62ch;
    color: var(--muted);
    font-size: 1.04rem;
    line-height: 1.6;
    margin-top: 14px;
}

.hero-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: min(100%, 540px);
}

.stat, .card, .notes {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 22px;
    backdrop-filter: blur(18px);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

.stat {
    padding: 18px;
}

.stat span, .card__kicker, .card__meta, .notes li {
    color: var(--muted);
}

.stat strong {
    display: block;
    margin-top: 8px;
    font-size: 1.9rem;
}

[data-summary="refresh-state"] {
    text-transform: lowercase;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 18px;
}

.card {
    padding: 20px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 680px;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 5px;
    background: var(--accent);
}

.card--alert-storm::before { background: linear-gradient(90deg, #ff6b6b, #b21f1f); }
.card--alert-wind::before { background: linear-gradient(90deg, #ffd37c, #ff8f6b); }
.card--alert-rain::before { background: linear-gradient(90deg, #6bd3ff, #4f7fb8); }
.card--alert-mist::before { background: linear-gradient(90deg, #c7d2e0, #8ea0b5); }
.card--alert-stable::before { background: linear-gradient(90deg, #48c78e, #2f7d6d); }

.card__header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: start;
    margin-bottom: 14px;
}

.card__title-wrap {
    display: grid;
    gap: 6px;
}

.card__emoji {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.08);
    font-size: 1.15rem;
}

.card__kicker {
    margin-bottom: 4px;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.badge {
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--line);
    font-size: 0.88rem;
    white-space: nowrap;
}

.card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    font-size: 0.88rem;
    margin-bottom: 18px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-content: start;
}

.card__spacer {
    flex: 1 1 auto;
    min-height: 16px;
}

.chart-card {
    padding: 14px;
    border-radius: 18px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
}

.chart-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    min-height: 42px;
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    gap: 12px;
}

.chart-card__header span,
.chart-card__header strong {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chart-card__header strong {
    max-width: 58%;
    text-align: right;
}

.chart-card__body {
    height: 200px;
}

.weather-forecast {
    margin-top: 14px;
    padding: 14px;
    border-radius: 18px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
}

.weather-forecast__header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.weather-forecast__list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.weather-hour {
    padding: 12px;
    border-radius: 14px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    display: grid;
    gap: 8px;
}

.weather-hour__time {
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.weather-hour__icon {
    font-size: 1.25rem;
}

.weather-hour__temp {
    font-size: 1.05rem;
}

.weather-hour__rain-wrap {
    display: grid;
    gap: 6px;
}

.weather-hour__rain-label {
    color: var(--muted);
    font-size: 0.8rem;
}

.weather-hour__rain-bar {
    display: block;
    height: 7px;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
    overflow: hidden;
}

.weather-hour__rain-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(142,180,255,0.8), rgba(124,224,195,0.9));
}

.metric {
    appearance: none;
    width: 100%;
    padding: 14px;
    border-radius: 16px;
    background: var(--panel-strong);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    margin-bottom: 6px;
}

.metric strong {
    font-size: 1.18rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.metric:hover,
.metric:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(255,255,255,0.22);
    background: rgba(255,255,255,0.12);
    outline: none;
}

.metric.is-active {
    border-color: rgba(255,255,255,0.32);
    background: rgba(255,255,255,0.16);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.08) inset;
}

.metric:disabled,
.metric--static {
    cursor: default;
    opacity: 0.95;
}

.metric:disabled:hover,
.metric--static:hover {
    transform: none;
    border-color: rgba(255,255,255,0.08);
    background: var(--panel-strong);
}

.metric--state {
    border-color: rgba(59, 109, 177, 0.45);
    background: rgba(59, 109, 177, 0.14);
}

.metric--state strong {
    color: #8eb4ff;
}

.card--online .badge { color: var(--online); }
.card--warning .badge { color: var(--warning); }
.card--stale .badge { color: #f4a261; }
.card--error .badge { color: var(--error); }
.card--weather .badge { color: #8eb4ff; }

.notes {
    margin-top: 18px;
    padding: 18px 20px;
}

.notes ul {
    margin: 10px 0 0;
    padding-left: 20px;
}

.notes li {
    margin: 6px 0;
}

@media (max-width: 980px) {
    .hero { align-items: stretch; }
    .card { min-height: 0; }
    .hero-stats { grid-template-columns: 1fr; }
    .grid { grid-template-columns: 1fr; }
    .weather-forecast__list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .shell { width: min(100% - 20px, 1180px); padding-top: 20px; }
    .metrics { grid-template-columns: 1fr; }
    .card__header { flex-direction: column; }
    .chart-card__header { flex-direction: column; align-items: flex-start; min-height: 0; gap: 6px; letter-spacing: 0.1em; }
    .chart-card__header strong { max-width: 100%; text-align: left; white-space: normal; }
    .chart-card__body { height: 160px; }
    .weather-forecast__list { grid-template-columns: 1fr; }
    .refresh-toggle {
        width: 48px;
        height: 48px;
        justify-content: center;
        padding: 0;
    }

    .refresh-toggle__text {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
}
