.wx-history-page {
    --wx-page-bg: #e7edf2;
    --wx-page-glow: rgba(20, 104, 116, 0.12);
    --wx-surface: #fbfcfd;
    --wx-surface-soft: #f1f5f7;
    --wx-surface-raised: #ffffff;
    --wx-header: #101820;
    --wx-header-text: #f8fafc;
    --wx-text: #142231;
    --wx-muted: #4c5d6d;
    --wx-line: #c7d2dc;
    --wx-line-strong: #718394;
    --wx-accent: #74491d;
    --wx-accent-soft: #e3c28f;
    --wx-link: #0d6370;
    --wx-link-hover: #084d57;
    --wx-focus: #08798a;
    --wx-warm: #8b3d28;
    --wx-warm-soft: #fff2eb;
    --wx-cool: #245f8b;
    --wx-cool-soft: #edf6fd;
    --wx-shadow: 0 18px 42px rgba(20, 34, 49, 0.11);
    color: var(--wx-text);
    max-width: 96rem;
    margin-inline: auto;
    padding: clamp(1rem, 2.7vw, 2.75rem);
    border: 1px solid color-mix(in srgb, var(--wx-line) 78%, transparent);
    border-radius: 1.5rem;
    background:
        radial-gradient(circle at 8% 0%, var(--wx-page-glow), transparent 28rem),
        linear-gradient(145deg, #edf2f5 0%, var(--wx-page-bg) 54%, #dde5eb 100%);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.55;
}

:root[data-theme="dark"] .wx-history-page {
    --wx-page-bg: #11171d;
    --wx-page-glow: rgba(102, 157, 147, 0.11);
    --wx-surface: #171e25;
    --wx-surface-soft: #1d252d;
    --wx-surface-raised: #202932;
    --wx-header: #090e13;
    --wx-header-text: #f7f9fb;
    --wx-text: #eef3f7;
    --wx-muted: #bac5cf;
    --wx-line: #45525e;
    --wx-line-strong: #677582;
    --wx-accent: #efc986;
    --wx-accent-soft: #8f6a36;
    --wx-link: #8cd6dc;
    --wx-link-hover: #b8eff2;
    --wx-focus: #f3c878;
    --wx-warm: #f0a18b;
    --wx-warm-soft: #35231f;
    --wx-cool: #9ccdf1;
    --wx-cool-soft: #1d2d3a;
    --wx-shadow: 0 20px 48px rgba(0, 0, 0, 0.3);
    background:
        radial-gradient(circle at 9% 0%, var(--wx-page-glow), transparent 30rem),
        radial-gradient(circle at 92% 15%, rgba(179, 132, 75, 0.07), transparent 26rem),
        linear-gradient(145deg, #151c22 0%, var(--wx-page-bg) 58%, #0d1217 100%);
}

.wx-history-page,
.wx-history-page * {
    box-sizing: border-box;
}

.wx-history-page .wx-page-intro {
    display: block;
    max-width: none;
    margin: 0 0 clamp(1.5rem, 3vw, 2.5rem);
    padding: 0;
    background: transparent;
    text-align: center;
}

.wx-page-kicker,
.wx-card-kicker,
.wx-day-eyebrow {
    margin: 0;
    color: var(--wx-accent);
    font-size: 0.75em;
    font-weight: 800;
    letter-spacing: 0.12em;
    line-height: 1.35;
    text-transform: uppercase;
}

.wx-page-intro h1 {
    margin: 0.25rem 0 0.45rem;
    color: var(--wx-text);
    font-size: clamp(2em, 4vw, 3.35em);
    letter-spacing: -0.035em;
    line-height: 1.05;
    text-wrap: balance;
}

.wx-page-intro p:last-child {
    max-width: 44rem;
    margin: 0 auto;
    color: var(--wx-muted);
    font-size: clamp(1em, 1.35vw, 1.12em);
}

#wx-reportContainer {
    color: var(--wx-text);
}

.wx-container {
    display: grid;
    gap: clamp(1.25rem, 2.4vw, 2rem);
}

.wx-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--wx-line);
    border-radius: 1.05rem;
    background: var(--wx-surface);
    box-shadow: var(--wx-shadow);
}

.wx-card-body {
    padding: clamp(1rem, 2.1vw, 1.65rem);
}

.wx-history-page .wx-report-hero {
    display: block;
    padding: clamp(1.25rem, 2.8vw, 2.2rem);
    border-bottom: 1px solid var(--wx-line);
    background:
        linear-gradient(112deg, color-mix(in srgb, var(--wx-surface-raised) 92%, transparent), color-mix(in srgb, var(--wx-surface-soft) 88%, transparent));
    text-align: center;
}

.wx-report-hero h2 {
    margin: 0.28rem 0 0.35rem;
    color: var(--wx-text);
    font-size: clamp(1.65em, 3vw, 2.45em);
    letter-spacing: -0.025em;
    line-height: 1.1;
    text-wrap: balance;
}

.wx-report-lead {
    max-width: 54rem;
    margin: 0;
    color: var(--wx-muted);
    font-size: 1em;
}

.wx-controls-panel {
    padding: clamp(1rem, 2.2vw, 1.6rem);
}

.wx-view-controls {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.wx-view-controls > legend {
    margin: 0 0 0.75rem;
    padding: 0;
    color: var(--wx-text);
    font-size: 1em;
    font-weight: 800;
}

.wx-toolbar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
    gap: 0.85rem;
    align-items: end;
}

.wx-control-group {
    display: grid;
    min-width: 0;
    gap: 0.38rem;
}

.wx-control-group--toggle {
    align-content: end;
}

.wx-form-label,
.wx-inline-label {
    color: var(--wx-muted);
    font-size: 0.875em;
    font-weight: 750;
}

.wx-form-control {
    width: 100%;
    min-height: 44px;
    padding: 0.65rem 2.45rem 0.65rem 0.8rem;
    border: 1px solid var(--wx-line-strong);
    border-radius: 0.65rem;
    color: var(--wx-text);
    background: var(--wx-surface-raised);
    font: inherit;
    font-size: 1em;
}

:root[data-theme="dark"] .wx-form-control {
    color-scheme: dark;
}

:root:not([data-theme="dark"]) .wx-form-control {
    color-scheme: light;
}

.wx-form-control option {
    color: var(--wx-text);
    background: var(--wx-surface-raised);
}

.wx-checkbox-label {
    display: flex;
    min-height: 44px;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--wx-line-strong);
    border-radius: 0.65rem;
    color: var(--wx-text);
    background: var(--wx-surface-raised);
    cursor: pointer;
    font-weight: 700;
}

.wx-checkbox-label input {
    width: 1.25rem;
    height: 1.25rem;
    flex: 0 0 auto;
    margin: 0;
    accent-color: var(--wx-link);
}

.wx-control-help,
.wx-control-note {
    margin: 0.8rem 0 0;
    color: var(--wx-muted);
    font-size: 0.875em;
}

.wx-control-note {
    color: var(--wx-text);
    font-weight: 700;
}

.wx-history-page .wx-card-header,
.wx-history-page .wx-day-header {
    display: block;
    padding: 0.9rem clamp(1rem, 2vw, 1.45rem);
    color: var(--wx-header-text);
    background:
        linear-gradient(115deg, rgba(255, 255, 255, 0.035), transparent 45%),
        var(--wx-header);
}

.wx-card-header .wx-card-kicker,
.wx-day-header .wx-day-eyebrow {
    color: #e8bd77;
}

.wx-card-header h2,
.wx-day-header h3 {
    margin: 0.13rem 0 0;
    color: var(--wx-header-text);
    font-size: clamp(1.15em, 2vw, 1.45em);
    line-height: 1.25;
    text-wrap: balance;
}

.wx-metric-list,
.wx-rain-day-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.wx-metric-list--summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    gap: 0.7rem;
}

.wx-metric-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: baseline;
    min-width: 0;
    padding: 0.67rem 0.1rem;
    border-bottom: 1px solid color-mix(in srgb, var(--wx-line) 72%, transparent);
    font-size: 0.95em;
}

.wx-metric-row:last-child {
    border-bottom: 0;
}

.wx-metric-list--summary .wx-metric-row {
    grid-template-columns: minmax(7.5rem, 1fr) minmax(6.5rem, 11rem);
    min-height: 4.3rem;
    align-content: center;
    padding: 0.78rem 0.9rem;
    border: 1px solid var(--wx-line);
    border-radius: 0.7rem;
    background: var(--wx-surface-soft);
}

.wx-metric-key,
.wx-metric-full {
    min-width: 0;
    color: var(--wx-muted);
    overflow-wrap: anywhere;
}

.wx-metric-value {
    color: var(--wx-text);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    text-align: right;
    overflow-wrap: anywhere;
}

.wx-metric-full {
    grid-column: 1 / -1;
}

.wx-table-danger {
    border-inline-start: 0.22rem solid var(--wx-warm) !important;
    background: var(--wx-warm-soft) !important;
}

.wx-table-primary {
    border-inline-start: 0.22rem solid var(--wx-cool) !important;
    background: var(--wx-cool-soft) !important;
}

.wx-history-page .wx-section-heading {
    display: flex;
    gap: 1rem;
    align-items: end;
    justify-content: space-between;
    margin: 0 0 0.85rem;
    padding: 0;
    color: var(--wx-text);
    background: transparent;
}

.wx-section-heading h2 {
    margin: 0.15rem 0 0;
    color: var(--wx-text);
    font-size: clamp(1.4em, 2.4vw, 1.9em);
    letter-spacing: -0.02em;
    line-height: 1.15;
    text-wrap: balance;
}

.wx-section-count {
    flex: 0 0 auto;
    margin: 0;
    color: var(--wx-muted);
    font-size: 0.875em;
    font-variant-numeric: tabular-nums;
}

.wx-section-count strong {
    color: var(--wx-text);
    font-size: 1.05em;
}

#wx-dayCards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 31rem), 1fr));
    gap: clamp(0.9rem, 1.8vw, 1.35rem);
}

.wx-day-stat {
    container-name: wx-day;
    container-type: inline-size;
    align-self: start;
}

.wx-day-stat .wx-card-body {
    padding-top: 0.75rem;
}

.wx-history-page .wx-day-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.9rem;
}

.wx-day-header h3 {
    flex: 0 0 auto;
    font-size: 1.18em;
}

.wx-day-header .wx-day-eyebrow {
    flex: 1 1 auto;
}

.wx-container .wx-extended-row {
    display: none;
}

.wx-container.wx-show-extended .wx-extended-row {
    display: grid;
}

.wx-card-footer {
    margin: 0.85rem -0.1rem -0.1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--wx-line);
}

.wx-graph-toggle {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.58rem 0.85rem;
    border: 1px solid var(--wx-line-strong);
    border-radius: 0.65rem;
    color: var(--wx-link);
    background: var(--wx-surface-raised);
    cursor: pointer;
    font: inherit;
    font-size: 0.93em;
    font-weight: 800;
}

.wx-graph-toggle:hover {
    border-color: var(--wx-link);
    color: var(--wx-link-hover);
    background: var(--wx-surface-soft);
}

.wx-graph-toggle i {
    font-size: 0.9em;
}

.wx-graph-container {
    margin-top: 0.8rem;
    padding: 0.5rem;
    border: 1px solid var(--wx-line);
    border-radius: 0.7rem;
    background: var(--wx-surface-soft);
}

.wx-graph-container img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    margin-inline: auto;
}

.wx-history-page .wx-rain-summary {
    display: flex;
    gap: 0.9rem;
    align-items: center;
    justify-content: space-between;
}

.wx-history-page .wx-rain-summary h2 {
    margin: 0.15rem 0 0;
    color: var(--wx-header-text);
    font-size: clamp(1.3em, 2.2vw, 1.7em);
    line-height: 1.2;
}

.wx-rain-total {
    flex: 0 0 auto;
    margin: 0;
    padding: 0.42rem 0.68rem;
    border: 1px solid var(--wx-line-strong);
    border-radius: 999px;
    color: var(--wx-text);
    background: var(--wx-surface-soft);
    font-size: 0.875em;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.wx-rain-day-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
    gap: 0.55rem;
    margin-top: 1rem;
}

.wx-rain-day-list li {
    padding: 0.62rem 0.75rem;
    border: 1px solid var(--wx-line);
    border-radius: 0.62rem;
    color: var(--wx-text);
    background: var(--wx-surface-soft);
    font-size: 0.92em;
    font-variant-numeric: tabular-nums;
}

#wxMeta {
    display: none;
}

#wx-scrollToTopBtn {
    position: fixed;
    right: max(1rem, env(safe-area-inset-right));
    bottom: max(1rem, env(safe-area-inset-bottom));
    z-index: 30;
    display: inline-flex;
    min-width: 2.9rem;
    min-height: 2.9rem;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--wx-line-strong);
    border-radius: 999px;
    color: var(--wx-header-text);
    background: var(--wx-header);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
    cursor: pointer;
    font: inherit;
    font-size: 0.875em;
    font-weight: 800;
}

.wx-history-page :is(button, select, input):focus-visible {
    outline: 0.2rem solid var(--wx-focus);
    outline-offset: 0.16rem;
}

@container wx-day (max-width: 23rem) {
    .wx-day-stat .wx-metric-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.18rem;
    }

    .wx-day-stat .wx-metric-value {
        text-align: left;
    }
}

@media (max-width: 40rem) {
    .wx-history-page {
        padding: 1rem;
        border-radius: 1rem;
    }

    .wx-history-page .wx-section-heading,
    .wx-history-page .wx-rain-summary {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.45rem;
    }

    .wx-day-header {
        padding-block: 0.82rem;
    }

    .wx-metric-row {
        font-size: 0.94em;
    }
}

@media (max-width: 32rem) {
    .wx-toolbar {
        grid-template-columns: minmax(0, 1fr);
    }

    .wx-metric-list--summary {
        grid-template-columns: minmax(0, 1fr);
    }

    .wx-metric-list--summary .wx-metric-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.18rem;
        min-height: 0;
    }

    .wx-metric-list--summary .wx-metric-value {
        text-align: left;
    }
}

@media (pointer: coarse) {
    .wx-form-control,
    .wx-checkbox-label,
    .wx-graph-toggle,
    #wx-scrollToTopBtn {
        min-height: 48px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wx-history-page *,
    .wx-history-page *::before,
    .wx-history-page *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media (forced-colors: active) {
    .wx-history-page,
    .wx-card,
    .wx-form-control,
    .wx-checkbox-label,
    .wx-metric-list--summary .wx-metric-row,
    .wx-graph-toggle,
    .wx-graph-container,
    .wx-rain-day-list li,
    #wx-scrollToTopBtn {
        border: 1px solid CanvasText;
    }

    .wx-history-page .wx-card-header,
    .wx-history-page .wx-day-header,
    #wx-scrollToTopBtn {
        color: ButtonText;
        background: ButtonFace;
    }
}
