:root {
    color-scheme: light dark;
    --forecast-background: #f5f7f9;
    --forecast-surface: #ffffff;
    --forecast-surface-alt: #eef2f6;
    --forecast-text: #15191e;
    --forecast-muted: #5e6975;
    --forecast-border: #d9dee5;
    --forecast-ec: #155e9a;
    --forecast-wn: #9a4d00;
    --forecast-selected: #e4f2fc;
    --forecast-error: #9b1c1c;
}

@media (prefers-color-scheme: dark) {
    :root {
        --forecast-background: #111419;
        --forecast-surface: #1b2027;
        --forecast-surface-alt: #242b34;
        --forecast-text: #f4f6f8;
        --forecast-muted: #aeb8c4;
        --forecast-border: #3b4551;
        --forecast-ec: #76b9eb;
        --forecast-wn: #ffb45f;
        --forecast-selected: #16364d;
        --forecast-error: #ff9b9b;
    }
}

* {
    box-sizing: border-box;
}

html,
body,
form {
    margin: 0;
    min-height: 100%;
}

body {
    background: var(--forecast-background);
    color: var(--forecast-text);
    font-family: Helvetica, Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
}

button,
a {
    font: inherit;
}

.forecast-page {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    background: var(--forecast-background);
}

.forecast-nav {
    display: flex;
    gap: 4px;
    padding: 8px;
    overflow-x: auto;
    background: var(--forecast-surface);
    border-bottom: 1px solid var(--forecast-border);
}

.forecast-nav a {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 8px;
    color: var(--forecast-text);
    text-decoration: none;
    white-space: nowrap;
}

.forecast-nav a.is-current {
    background: var(--forecast-surface-alt);
    font-weight: 600;
}

.forecast-current {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 12px 8px;
    background: var(--forecast-surface);
}

.forecast-place {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.1;
}

.forecast-current-summary {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 3px;
    color: var(--forecast-muted);
    font-size: 13px;
}

.forecast-current-icon {
    width: 34px;
    height: 29px;
    object-fit: contain;
}

.forecast-current-temperature {
    font-size: 36px;
    line-height: 1;
    white-space: nowrap;
}

.forecast-updated {
    padding: 4px 12px 10px;
    background: var(--forecast-surface);
    border-bottom: 1px solid var(--forecast-border);
    color: var(--forecast-muted);
    font-size: 12px;
    line-height: 1.5;
}

.forecast-updated > div {
    display: flex;
    gap: 7px;
}

.forecast-source-name {
    min-width: 118px;
    font-weight: 600;
}

.forecast-source-name--ec,
.forecast-detail-source--ec {
    color: var(--forecast-ec);
}

.forecast-source-name--wn,
.forecast-detail-source--wn {
    color: var(--forecast-wn);
}

.forecast-scroll-heading {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px 6px 12px;
    color: var(--forecast-muted);
    font-size: 12px;
}

.forecast-scroll-heading > span:first-child {
    color: var(--forecast-text);
    font-weight: 600;
}

.forecast-pair-key {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.forecast-key-dot {
    width: 7px;
    height: 7px;
    display: inline-block;
    border-radius: 50%;
}

.forecast-key-dot--ec {
    background: var(--forecast-ec);
}

.forecast-key-dot--wn {
    margin-left: 5px;
    background: var(--forecast-wn);
}

.forecast-table-wrap {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
    background: var(--forecast-surface);
    border-top: 1px solid var(--forecast-border);
    border-bottom: 1px solid var(--forecast-border);
}

.forecast-table {
    width: max-content;
    min-width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
}

.forecast-table th,
.forecast-table td {
    width: 72px;
    min-width: 72px;
    height: 32px;
    padding: 4px 5px;
    background: var(--forecast-surface);
    border-right: 1px solid var(--forecast-border);
    border-bottom: 1px solid var(--forecast-border);
    text-align: center;
    vertical-align: middle;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.forecast-table th:first-child,
.forecast-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    width: 82px;
    min-width: 82px;
    background: var(--forecast-surface-alt);
    box-shadow: 1px 0 0 var(--forecast-border);
    text-align: left;
}

.forecast-table thead th {
    height: 76px;
    padding: 0;
    vertical-align: top;
}

.forecast-table thead th:first-child {
    z-index: 4;
    padding: 8px;
    vertical-align: middle;
    color: var(--forecast-muted);
    font-weight: 600;
}

.forecast-day-button {
    width: 100%;
    min-height: 75px;
    padding: 5px 2px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--forecast-text);
    cursor: pointer;
}

.forecast-day-button strong,
.forecast-day-button span {
    display: block;
}

.forecast-day-button strong {
    font-weight: 600;
}

.forecast-date {
    color: var(--forecast-muted);
    font-size: 11px;
}

.forecast-icons {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    min-height: 25px;
    margin-top: 2px;
}

.forecast-day-icon {
    width: 24px;
    height: 21px;
    object-fit: contain;
    justify-self: center;
}

.forecast-wn-icon,
.forecast-missing-icon {
    font-size: 16px;
    line-height: 1;
}

.forecast-source-group th,
.forecast-source-group td {
    height: 28px;
    background: var(--forecast-surface-alt);
    color: var(--forecast-muted);
    font-size: 11px;
    font-weight: 600;
}

.forecast-source-group th {
    z-index: 3;
}

.forecast-source-group--ec th {
    color: var(--forecast-ec);
}

.forecast-source-group--wn th {
    color: var(--forecast-wn);
}

.forecast-table tbody th {
    font-weight: 400;
}

.forecast-table tbody tr:last-child th,
.forecast-table tbody tr:last-child td {
    border-bottom: 0;
}

.forecast-table [data-day-index].is-selected {
    background: var(--forecast-selected);
}

.forecast-table--source-rows th,
.forecast-table--source-rows td {
    font-size: 20px;
    line-height: 22px;
}

.forecast-table--source-rows th:first-child {
    font-size: 16px;
}

.forecast-table--source-rows .forecast-day-button {
    position: relative;
}

.forecast-table--source-rows .forecast-day-button strong {
    font-size: 20px;
}

.forecast-table--source-rows .forecast-date {
    font-size: 14px;
    line-height: 16px;
}

.forecast-table--source-rows .forecast-source-group th,
.forecast-table--source-rows .forecast-source-group td {
    font-size: 13px;
    line-height: 18px;
}

.forecast-table--source-rows .forecast-source-group td {
    padding-top: 2px;
    padding-bottom: 2px;
}

.forecast-table--source-rows .forecast-source-group .forecast-day-icon {
    display: block;
    margin: 0 auto;
}

.forecast-table--source-rows .forecast-source-group .forecast-wn-icon {
    display: block;
    font-size: 22px;
    line-height: 22px;
}

.forecast-table--paired td {
    height: 46px;
    padding: 4px 3px;
}

.forecast-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    min-height: 34px;
}

.forecast-pair span {
    display: block;
}

.forecast-pair-ec {
    color: var(--forecast-ec);
    border-right: 1px solid var(--forecast-border);
}

.forecast-pair-wn {
    color: var(--forecast-wn);
}

.forecast-vertical-heading {
    border-bottom: 1px solid var(--forecast-border);
}

.forecast-vertical-list {
    background: var(--forecast-surface);
}

.forecast-vertical-day {
    background: var(--forecast-surface);
    border-bottom: 1px solid var(--forecast-border);
}

.forecast-vertical-day.is-selected {
    background: var(--forecast-selected);
}

.forecast-vertical-button {
    width: 100%;
    min-height: 70px;
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    background: transparent;
    text-align: left;
}

.forecast-vertical-date {
    display: flex !important;
    flex-direction: column;
    align-self: center;
}

.forecast-vertical-date strong {
    font-size: 22px;
    line-height: 26px;
}

.forecast-vertical-date span {
    color: var(--forecast-muted);
    font-size: 14px;
    line-height: 16px;
}

.forecast-vertical-sources {
    min-width: 0;
    display: grid !important;
    gap: 4px;
}

.forecast-vertical-source-line {
    min-width: 0;
    display: grid !important;
    grid-template-columns: 25px 25px repeat(5, auto);
    align-items: center;
    column-gap: 2px;
    color: var(--forecast-text);
    font-size: clamp(11px, calc(3.5vw - 0.65px), 22px);
    line-height: 25px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.forecast-vertical-source {
    font-size: 15px;
    font-weight: 600;
}

.forecast-vertical-source--ec {
    color: var(--forecast-ec);
}

.forecast-vertical-source--wn {
    color: var(--forecast-wn);
}

.forecast-vertical-source-icon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

.forecast-vertical-source-icon .forecast-day-icon {
    width: 23px;
    height: 20px;
}

.forecast-vertical-source-emoji {
    font-size: 17px;
}

.forecast-vertical-unavailable {
    grid-column: 3 / -1;
    color: var(--forecast-muted);
}

.forecast-vertical-rain {
    color: var(--forecast-wn);
    text-align: right;
}

.forecast-vertical-chevron {
    color: var(--forecast-muted);
    font-size: 24px;
    text-align: right;
    transition: transform 120ms ease;
}

.forecast-vertical-button[aria-expanded="true"] .forecast-vertical-chevron {
    transform: rotate(90deg);
}

.forecast-vertical-list > .forecast-detail {
    margin-top: 0;
}

.forecast-detail {
    margin: 10px;
    padding: 12px;
    background: var(--forecast-surface);
    border: 1px solid var(--forecast-border);
    border-radius: 12px;
}

.forecast-detail[hidden],
.forecast-detail [hidden] {
    display: none;
}

.forecast-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.forecast-detail-header h2 {
    margin: 0;
    font-size: 18px;
}

.forecast-detail-close,
.forecast-hourly-toggle {
    min-height: 44px;
    border: 0;
    background: transparent;
    color: var(--forecast-ec);
    cursor: pointer;
}

.forecast-detail-close {
    min-width: 52px;
    color: var(--forecast-muted);
}

.forecast-detail-loading,
.forecast-detail-error {
    padding: 12px 0;
}

.forecast-detail-error {
    color: var(--forecast-error);
}

.forecast-detail-sources {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 8px;
}

.forecast-detail-sources section + section {
    padding-top: 12px;
    border-top: 1px solid var(--forecast-border);
}

.forecast-detail-source {
    margin: 0 0 2px;
    font-size: 14px;
}

.forecast-detail-updated {
    margin-bottom: 6px;
    color: var(--forecast-muted);
    font-size: 11px;
}

.forecast-period {
    padding: 7px 0;
    border-bottom: 1px solid var(--forecast-border);
    font-size: 13px;
    line-height: 1.35;
}

.forecast-period:last-child {
    border-bottom: 0;
}

.forecast-period strong {
    font-weight: 600;
}

.forecast-detail a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    color: var(--forecast-ec);
}

.forecast-hourly-toggle {
    margin-top: 8px;
    padding: 0;
}

.forecast-hourly-list {
    display: grid;
    grid-template-columns: 1fr;
}

.forecast-sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (min-width: 700px) {
    .forecast-detail-sources {
        grid-template-columns: 1fr 1fr;
    }

    .forecast-detail-sources section + section {
        padding-top: 0;
        padding-left: 14px;
        border-top: 0;
        border-left: 1px solid var(--forecast-border);
    }

    .forecast-hourly-list {
        grid-template-columns: 1fr 1fr;
        column-gap: 18px;
    }
}

@media (max-width: 360px) {
    .forecast-place {
        font-size: 23px;
    }

    .forecast-current-temperature {
        font-size: 32px;
    }

    .forecast-table th,
    .forecast-table td {
        width: 68px;
        min-width: 68px;
    }

    .forecast-table th:first-child,
    .forecast-table td:first-child {
        width: 76px;
        min-width: 76px;
    }

    .forecast-vertical-button {
        grid-template-columns: 50px minmax(0, 1fr) 15px;
        gap: 5px;
        padding-right: 6px;
        padding-left: 7px;
    }

    .forecast-vertical-source-line {
        grid-template-columns: 23px 23px repeat(5, auto);
        column-gap: 0;
    }

    .forecast-vertical-source {
        font-size: 14px;
    }
}

@media (max-width: 600px) {
    /* Keep the label column visible with seven of the fourteen days. */
    .forecast-table--source-rows {
        width: calc(200% - 70px);
        min-width: 0;
        max-width: 1078px;
    }

    .forecast-table--source-rows th,
    .forecast-table--source-rows td {
        width: auto;
        min-width: 0;
        padding-left: 1px;
        padding-right: 1px;
        font-size: clamp(12px, calc(5vw - 2px), 20px);
        white-space: nowrap;
    }

    /* The final row needs room for rain ranges such as 10–20. */
    .forecast-table--source-rows tbody tr:last-child td {
        font-size: clamp(11px, calc(5vw - 4.5px), 20px);
    }

    .forecast-table--source-rows th:first-child,
    .forecast-table--source-rows td:first-child {
        width: 70px;
        min-width: 70px;
        padding-left: 2px;
        padding-right: 2px;
    }

    .forecast-table--source-rows .forecast-day-button {
        padding-left: 0;
        padding-right: 0;
    }

    .forecast-table--source-rows .forecast-day-button strong {
        font-size: clamp(14px, 4.5vw, 20px);
    }

    .forecast-table--source-rows .forecast-date {
        font-size: clamp(10px, 3vw, 14px);
    }
}
