.site-header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    height: var(--header-height);
    padding: 0 var(--page-gutter);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
}

.site-header__logo {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-strong);
    letter-spacing: var(--letter-tight);
}

.site-header__logo:hover {
    text-decoration: none;
}

.site-header__nav {
    display: flex;
    gap: var(--space-8);
    margin-left: auto;
    margin-right: auto;
}

.site-header__nav-link {
    position: relative;
    padding-bottom: var(--space-1);
    color: var(--color-text-base);
    white-space: nowrap;
    transition: color var(--motion-base) var(--motion-ease);
}

.site-header__nav-link::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 3px;
    background: var(--color-accent);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transform: scaleX(0);
    transform-origin: center;
    transition: transform var(--motion-pill) var(--ease-decelerate);
}

.site-header__nav-link:hover {
    text-decoration: none;
    color: var(--color-text-strong);
}

.site-header__nav-link:hover::after {
    transform: scaleX(0.5);
}

.site-header__nav-link.is-active {
    color: var(--color-text-strong);
    font-weight: var(--font-weight-medium);
}

.site-header__nav-link.is-active::after {
    transform: scaleX(1);
}

.site-header__burger {
    display: none;
    align-items: center;
    justify-content: center;
    width: var(--control-height);
    height: var(--control-height);
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--color-text-base);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition:
        border-color var(--motion-base) var(--motion-ease),
        background var(--motion-base) var(--motion-ease);
}

/* hover: hover only - on touch the :hover state sticks after a tap and
   leaves a lingering box around the burger. */
@media (hover: hover) {
    .site-header__burger:hover {
        border-color: var(--color-border-strong);
    }
}

.site-header__burger:focus-visible {
    outline: var(--focus-ring-width) solid var(--color-accent);
    outline-offset: var(--focus-ring-offset);
}

.site-header__burger-line {
    transform-box: fill-box;
    transform-origin: center;
    transition:
        transform var(--motion-slow) var(--motion-ease),
        opacity var(--motion-fast) var(--motion-ease);
}

.site-header__burger[aria-expanded="true"] .site-header__burger-line--top {
    transform: translateY(5px) rotate(45deg);
}

.site-header__burger[aria-expanded="true"] .site-header__burger-line--mid {
    opacity: 0;
}

.site-header__burger[aria-expanded="true"] .site-header__burger-line--bot {
    transform: translateY(-5px) rotate(-45deg);
}

.content {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--space-8) var(--page-gutter) var(--space-12);
}

/* hidden keeps inactive panels in the DOM (state survives a switch) but
   out of layout, paint and assistive tech. */
.tab-panel[hidden] {
    display: none;
}

.tab-panel > .section + .section {
    margin-top: var(--space-12);
    padding-top: var(--space-12);
    border-top: 1px solid var(--color-border);
}

.section__title {
    font-size: var(--font-size-lg);
}

.section__lede {
    margin-top: var(--space-1);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    text-align: justify;
    text-wrap: pretty;
}

.section__body {
    margin-top: var(--space-5);
}

.section__header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.section__heading {
    min-width: 0;
}

.section__header-tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-left: auto;
}

.section__toolbar {
    margin-top: var(--space-4);
    display: flex;
    align-items: flex-end;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.section__toolbar-control {
    flex: 0 0 auto;
}

.section__toolbar-meta {
    margin: 0;
    padding-bottom: 6px;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.load-error {
    margin-top: var(--space-8);
    padding: var(--space-6);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}

.load-error__title {
    font-size: var(--font-size-lg);
    margin-bottom: var(--space-2);
}

.load-error__body {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    line-height: var(--line-normal);
}

.load-error__retry {
    margin-top: var(--space-4);
    height: var(--control-height);
    padding: 0 var(--space-4);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text-base);
    font: inherit;
    font-size: var(--font-size-control);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: border-color var(--motion-base) var(--motion-ease);
}

.load-error__retry:hover:not(:disabled) {
    border-color: var(--color-text-muted);
}

.load-error__retry:focus-visible {
    outline: var(--focus-ring-width) solid var(--color-accent);
    outline-offset: var(--focus-ring-offset);
}

.load-error__retry:disabled {
    color: var(--color-text-subtle);
    cursor: progress;
}

.skeleton {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--color-track);
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.55) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

/* The light-theme band would glare on near-black dark surfaces. */
html[data-theme="dark"] .skeleton::after {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.07) 50%,
        rgba(255, 255, 255, 0) 100%
    );
}

@keyframes skeleton-shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-4);
}

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

.skeleton--card {
    height: 168px;
    border: 1px solid var(--color-border);
}

.skeleton--chart {
    height: var(--chart-min-height);
}

.skeleton--control {
    width: 200px;
    max-width: 100%;
    height: var(--control-height);
}

.skeleton--diff {
    height: 360px;
}

.site-footer {
    margin-top: var(--space-12);
    padding: var(--space-6) var(--page-gutter) var(--space-8);
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.site-footer__inner {
    max-width: var(--content-max);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-5);
    text-align: center;
}

.site-footer p {
    margin: 0;
}

.site-footer a {
    color: var(--color-text-base);
    text-decoration: underline;
    text-decoration-color: var(--color-border-strong);
    text-underline-offset: 3px;
    transition: color var(--motion-base) var(--motion-ease);
}

.site-footer a:hover {
    color: var(--color-text-strong);
    text-decoration-color: var(--color-text-subtle);
}

.site-footer__sources-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
}

.site-footer__sources {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: baseline;
    gap: var(--space-1) var(--space-5);
}

.site-footer__source {
    display: inline-flex;
    align-items: baseline;
}

.site-footer__source-desc {
    margin-left: var(--space-1);
    color: var(--color-text-subtle);
    font-size: var(--font-size-xs);
}

.site-footer__source-desc::before {
    content: "(";
}

.site-footer__source-desc::after {
    content: ")";
}

.site-footer__bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: var(--space-2) var(--space-4);
}

/* The `a` qualifier lifts specificity past the generic .site-footer a
   underline rule above. */
a.site-footer__repo {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    text-decoration: none;
}

.site-footer__repo-icon {
    flex-shrink: 0;
    /* block strips the inline-baseline gap an SVG inherits. */
    display: block;
}

.site-footer__repo:hover .site-footer__repo-icon {
    color: var(--color-text-strong);
}

@media (max-width: 1024px) {
    .site-header {
        padding: 0 var(--space-5);
    }
    .content {
        padding-left: var(--space-5);
        padding-right: var(--space-5);
    }
}

@media (max-width: 900px) {
    .section__toolbar-control {
        width: 100%;
    }
    .tab-panel > .section + .section {
        margin-top: var(--space-6);
        padding-top: var(--space-6);
    }
    .section__body {
        margin-top: var(--space-4);
    }
}

@media (max-width: 720px) {
    .content {
        padding-top: var(--space-6);
        padding-bottom: var(--space-8);
    }
    .section__header {
        gap: var(--space-3);
    }
}

@media (max-width: 720px) {
    .site-header {
        position: sticky;
        top: 0;
        z-index: var(--z-header);
        justify-content: space-between;
    }
    .site-header__burger {
        display: inline-flex;
    }
    .site-header__logo,
    .site-header__actions {
        position: relative;
        z-index: var(--z-header);
    }
    .site-header__nav {
        position: fixed;
        inset: 0;
        z-index: var(--z-overlay);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        margin: 0;
        /* Clear the sticky header at the top; respect the home-bar safe
           area at the bottom. */
        padding:
            calc(var(--header-height) + var(--space-6))
            var(--page-gutter)
            calc(var(--space-12) + env(safe-area-inset-bottom, 0px));
        background: var(--color-bg);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    .site-header__nav:not(.is-open) {
        display: none;
    }
    .site-header__nav.is-open {
        animation: nav-overlay-in var(--motion-base) var(--motion-ease);
    }
    .site-header__nav.is-open .site-header__nav-link,
    .site-header__nav.is-open .site-nav__footer {
        animation: nav-item-in var(--motion-slow) var(--ease-decelerate)
            backwards;
    }
    .site-header__nav.is-open .site-header__nav-link:nth-of-type(1) {
        animation-delay: 0.04s;
    }
    .site-header__nav.is-open .site-header__nav-link:nth-of-type(2) {
        animation-delay: 0.08s;
    }
    .site-header__nav.is-open .site-header__nav-link:nth-of-type(3) {
        animation-delay: 0.12s;
    }
    .site-header__nav-link {
        position: relative;
        padding: var(--space-3) 0 var(--space-3) var(--space-4);
        border-radius: 0;
        font-size: var(--font-size-2xl);
        font-weight: var(--font-weight-semibold);
        letter-spacing: var(--letter-tight);
        color: var(--color-text-muted);
    }
    .site-header__nav-link::after {
        content: "";
        left: 0;
        right: auto;
        top: 50%;
        bottom: auto;
        width: 4px;
        height: 1.5em;
        border-radius: var(--radius-pill);
        background: var(--color-accent);
        transform: translateY(-50%) scaleY(0);
        transform-origin: center;
        transition: transform var(--motion-pill) var(--ease-decelerate);
    }
    .site-header__nav-link:hover {
        background: transparent;
        color: var(--color-text-strong);
    }
    .site-header__nav-link.is-active {
        background: transparent;
        color: var(--color-accent);
    }
    .site-header__nav-link.is-active::after {
        transform: translateY(-50%) scaleY(1);
    }
    .site-nav__footer {
        margin-top: auto;
        padding-top: var(--space-6);
        border-top: 1px solid var(--color-border);
    }
    /* Scroll-lock the page behind the overlay. */
    body.has-nav-open {
        overflow: hidden;
    }
}

@keyframes nav-overlay-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes nav-item-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 540px) {
    .content {
        padding: var(--space-5) var(--space-4) var(--space-6);
    }
    .tab-panel > .section + .section {
        margin-top: var(--space-5);
        padding-top: var(--space-5);
    }
    .section__body {
        margin-top: var(--space-3);
    }
    .section__header {
        gap: var(--space-2);
    }
    .section__lede {
        margin-top: 2px;
    }
    .site-footer {
        margin-top: var(--space-8);
        padding: var(--space-5) var(--space-4) var(--space-6);
    }
}

@media (max-width: 700px) {
    .site-footer__sources {
        flex-direction: column;
        align-items: center;
        gap: var(--space-1);
    }
}

@media (max-width: 380px) {
    .site-header__logo {
        font-size: var(--font-size-base);
    }
}
