.page-width {
    width: min(var(--page-width), calc(100% - 28px));
    margin-inline: auto;
}

/* Header */

.site-header {
    position: sticky;
    z-index: 90;
    top: 0;
    anchor-name: --site-header;

    background: var(--background);

    border-bottom: 1px solid var(--button-hover-background);
}

.site-header-inner {
    min-height: 64px;

    padding-block: 8px;

    display: grid;
    grid-template-columns:
        26px calc(var(--field-width) - 26px - var(--column-gap))
        repeat(3, var(--field-width));
    grid-template-areas: 'menu brand brand volume reference';

    column-gap: var(--column-gap);

    align-items: center;
    justify-content: start;
}

.nav-toggle {
    position: relative;
    grid-area: menu;

    width: 26px;
    height: 26px;
    padding: 5px;

    flex: none;

    border-color: transparent;
    background: transparent;
}

.nav-toggle-icon {
    position: absolute;
    top: 50%;
    left: 50%;

    display: block;
    width: 16px;
    height: 16px;

    transform: translate(-50%, -50%);
}

.nav-toggle-icon::before,
.nav-toggle-icon::after {
    position: absolute;
    left: 0;

    width: 16px;
    height: 2px;

    background: currentColor;
    content: '';

    transition:
        opacity 160ms ease,
        transform 160ms ease,
        width 160ms ease,
        left 160ms ease,
        top 160ms ease,
        box-shadow 160ms ease;
}

.nav-toggle-icon::before {
    top: 2px;
    box-shadow:
        0 5px currentColor,
        0 10px currentColor;
}

.nav-toggle-icon::after {
    top: 7px;
    opacity: 0;
}

body.nav-open .nav-toggle-icon::before,
body.nav-open .nav-toggle-icon::after {
    left: 1px;
    top: 7px;
    width: 14px;
    box-shadow: none;
}

body.nav-open .nav-toggle-icon::before {
    transform: rotate(45deg);
}

body.nav-open .nav-toggle-icon::after {
    opacity: 1;
    transform: rotate(-45deg);
}

.site-title {
    grid-area: brand;

    margin: 0;

    font-size: 28px;
    font-weight: 700;

    white-space: nowrap;
}

.site-title a {
    color: inherit;
    text-decoration: none;
}

.global-volume {
    grid-area: volume;
    min-width: 0;
}

.global-reference {
    grid-area: reference;
    min-width: 0;
}

.global-volume > label,
.global-reference > label {
    display: block;

    margin-bottom: 5px;

    color: var(--muted);

    font-size: 12px;
    line-height: 1.2;
}

.global-volume-controls {
    width: var(--control-width);
    max-width: 100%;

    display: flex;
    align-items: center;

    gap: 6px;
}

.global-volume-button,
.global-mic-button {
    width: 24px;
    height: 24px;
    padding: 0;

    display: inline-grid;
    flex: none;
    place-items: center;
}

.global-volume-button {
    font-size: 16px;
}

.global-volume-controls input {
    width: 0;
    min-width: 0;
    height: 32px;
    margin: 0;

    flex: 1;
}

.global-mic-button[aria-pressed='true'] {
    border-color: var(--mic-accent);
    color: var(--mic-accent);
}

.global-mic-icon {
    width: 18px;
    height: 18px;

    display: block;
}

.global-mic-icon-on,
.global-mic-button[aria-pressed='true'] .global-mic-icon-off {
    display: none;
}

.global-mic-button[aria-pressed='true'] .global-mic-icon-on {
    display: block;
}

.global-reference-controls {
    width: var(--control-width);
    max-width: 100%;

    display: flex;
    align-items: center;

    gap: 6px;
}

.global-reference-controls input {
    width: 0;
    min-width: 0;

    flex: 1;
}

.global-reference-controls button {
    flex: none;

    padding-inline: 8px;
}

/* Navigation drawer */

.site-nav {
    position: fixed;
    position-anchor: --site-header;
    z-index: 2;

    top: anchor(bottom);
    bottom: var(--footer-height);
    left: 0;
    width: max-content;
    max-width: calc(100vw - 20px);

    overflow-y: auto;

    border-right: 1px solid var(--border);

    background: var(--surface);
    box-shadow: 6px 0 14px rgb(0 0 0 / 0.28);

    transform: translateX(-100%);
    visibility: hidden;

    transition:
        transform 180ms ease,
        visibility 0s linear 180ms;
}

body.nav-open .site-nav {
    transform: translateX(0);
    visibility: visible;

    transition-delay: 0s;
}

.nav-list {
    width: max-content;
    min-width: 180px;
    max-width: 100%;
    min-height: 100%;

    display: flex;
    flex-direction: column;

    padding: 4px 0;
    margin: 0;

    list-style: none;
}

.nav-list > li {
    width: 100%;
}

.nav-item {
    width: 100%;
    min-height: 30px;

    padding: 0 10px;

    border: 0;
    border-left: 3px solid transparent;
    border-radius: var(--border-radius);

    background: transparent;
    color: var(--muted);

    text-align: left;
}

.nav-item.is-active {
    border-left-color: var(--text);

    background: var(--button-hover-background);
    color: var(--text);
}

.site-nav .nav-item:hover:not(:disabled),
.nav-modes button:hover:not(:disabled) {
    background: var(--button-hover-background);
    color: var(--text);
}

.nav-group {
    width: 100%;
}

.nav-modes {
    display: grid;

    padding: 0 0 4px 14px;
    margin: 0;

    list-style: none;
}

.nav-modes li {
    width: 100%;
}

.nav-modes button {
    width: 100%;
    min-height: 26px;
    padding: 2px 10px;

    border: 0;
    border-left: 1px solid var(--border);
    border-radius: 0;

    background: transparent;
    color: var(--muted);

    text-align: left;
}

.nav-modes button.is-active {
    border-left-color: var(--text);
    color: var(--text);
}

/* Main */

main {
    flex: 1;

    padding-block: var(--main-padding);
}

.section-panel[hidden] {
    display: none;
}

.sr-only {
    position: absolute;

    width: 1px;
    height: 1px;

    padding: 0;
    margin: -1px;

    overflow: hidden;
    clip-path: inset(50%);

    white-space: nowrap;

    border: 0;
}

.blurb {
    margin: 5px 0 0;

    color: var(--muted);
    line-height: 1.4;
}

/* Footer */

footer {
    position: fixed;
    z-index: 100;

    right: 0;
    bottom: 0;
    left: 0;
    height: var(--footer-height);

    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 0 1rem;

    font-size: 0.85rem;

    color: var(--muted);
    background: var(--surface);

    border-top: 1px solid var(--button-hover-background);

    line-height: 1.6;
}

.footer-source {
    text-align: left;
}

.footer-socials {
    text-align: right;
    padding-top: 2px;
}

footer a {
    color: var(--muted);
}

footer a:hover {
    text-decoration: none;
}

@media (hover: hover) {
    .nav-item:hover:not(:disabled) {
        background: transparent;
        color: var(--text);
    }
}

@media (max-width: 1060px) {
    .site-header-inner {
        grid-template-columns:
            26px calc(var(--field-width) - 26px - var(--column-gap))
            repeat(2, var(--field-width));
        grid-template-areas: 'menu brand volume reference';
    }
}

@media (max-width: 800px) {
    .site-header-inner {
        grid-template-columns:
            26px calc(var(--field-width) - 26px - var(--column-gap))
            var(--field-width);
        grid-template-areas:
            'menu brand brand'
            'volume volume reference';

        row-gap: 8px;
    }
}

@media (max-width: 560px) {
    .page-width {
        width: calc(100% - 16px);
    }

    .site-title {
        min-width: 0;

        font-size: clamp(18px, 5.5vw, 28px);
        white-space: nowrap;
    }

    .global-reference-controls button {
        padding-inline: 6px;
    }

    footer {
        gap: 12px;

        white-space: nowrap;
    }

    .footer-source {
        flex: none;
        font-size: 0.75rem;
    }

    .footer-socials {
        min-width: 0;

        overflow: hidden;

        text-overflow: ellipsis;
    }
}

@media (max-width: 340px) {
    .site-header-inner {
        grid-template-columns: 26px minmax(0, 1fr);
        grid-template-areas:
            'menu brand'
            'volume volume'
            'reference reference';
    }

    .site-title {
        font-size: 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-nav,
    .nav-toggle-icon::before,
    .nav-toggle-icon::after {
        transition: none;
    }
}
