:root {
    color-scheme: light;
    --paper: #f7f3eb;
    --ink: #272a27;
    --muted: #63685f;
    --accent: #9b4127;
    --rule: #d9d1c3;
    --soft: #eee8dc;
    --code: #202923;
    --code-ink: #f5f4e9;
    --serif: Georgia, "Times New Roman", serif;
    --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 1.5rem;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--serif);
    font-size: 1.125rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

main {
    width: min(100% - 3rem, 48rem);
    margin: 0 auto;
    padding: 2rem 0 4rem;
}

a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.19em;
}

a:hover {
    text-decoration-thickness: 2px;
}

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 5px;
    border-radius: 2px;
}

.skip-link {
    position: absolute;
    top: -5rem;
    left: 1rem;
    padding: 0.5rem 1rem;
    background: var(--paper);
    font-family: var(--sans);
}

.skip-link:focus {
    top: 0.5rem;
}

.course-nav,
.eyebrow,
.meta,
.section-number,
figcaption,
.source-note,
footer {
    font-family: var(--sans);
    font-size: 0.8rem;
    line-height: 1.5;
}

.course-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--rule);
}

.course-nav a {
    color: var(--ink);
}

header {
    padding: 3rem 0 1.5rem;
}

.eyebrow {
    color: var(--accent);
    font-weight: 650;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    line-height: 1.18;
    text-wrap: balance;
}

h1 {
    max-width: 13ch;
    margin: 0.8rem 0 1rem;
    font-size: clamp(2.7rem, 7vw, 4.3rem);
    font-weight: 400;
    letter-spacing: -0.045em;
}

h2 {
    margin: 0 0 1rem;
    font-size: 1.85rem;
    font-weight: 400;
    letter-spacing: -0.02em;
}

h3 {
    margin: 0 0 0.75rem;
    font-size: 1.3rem;
}

p {
    margin: 0 0 1rem;
}

.lead {
    max-width: 39rem;
    font-size: 1.3rem;
    line-height: 1.5;
}

.meta,
.source-note {
    color: var(--muted);
}

section {
    margin-top: 2.4rem;
}

.section-number {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--accent);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

code,
pre {
    font-family: var(--mono);
    font-size: 0.85em;
}

:not(pre) > code {
    padding: 0.05em 0.15em;
    border-radius: 2px;
    background: var(--soft);
    overflow-wrap: anywhere;
}

pre {
    margin: 1.25rem 0;
    padding: 1.25rem 1.4rem;
    overflow-x: auto;
    border-radius: 4px;
    background: var(--code);
    color: var(--code-ink);
    line-height: 1.65;
    tab-size: 4;
}

pre code {
    font-size: 1em;
}

figure {
    margin: 1.5rem 0;
}

figure pre {
    margin-bottom: 0.65rem;
}

figcaption {
    color: var(--muted);
}

.table-wrap {
    max-width: 100%;
    margin: 1.25rem 0;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.94rem;
    line-height: 1.5;
    text-align: left;
}

th,
td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--rule);
    vertical-align: top;
}

th {
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 650;
    background: var(--soft);
}

th:first-child,
td:first-child {
    padding-left: 0.6rem;
}

.callout {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    border-left: 3px solid var(--accent);
    background: var(--soft);
}

.callout p:last-child,
details p:last-child {
    margin-bottom: 0;
}

.exercise {
    margin: 1.5rem 0;
    padding-top: 1.5rem;
    border-top: 1px solid var(--rule);
}

details {
    margin: 1rem 0;
    padding: 0.85rem 1rem;
    border: 1px solid var(--rule);
    border-radius: 3px;
}

summary {
    color: var(--accent);
    font-family: var(--sans);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

details[open] summary {
    margin-bottom: 1rem;
}

ul,
ol {
    padding-left: 1.4rem;
}

li + li {
    margin-top: 0.45rem;
}

dl {
    margin: 1rem 0;
}

dt {
    margin-top: 1rem;
    font-weight: 700;
}

dd {
    margin: 0.15rem 0 0;
}

.reference h1 {
    max-width: 18ch;
    font-size: clamp(2.3rem, 6vw, 3.5rem);
}

footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--rule);
    color: var(--muted);
}

@media (max-width: 520px) {
    body {
        font-size: 1.05rem;
    }

    main {
        width: calc(100% - 2rem);
        padding-top: 1rem;
    }

    header {
        padding-top: 2rem;
    }

    pre {
        padding: 1rem;
        font-size: 0.77em;
    }

    th,
    td {
        padding: 0.6rem 0.4rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

@page {
    size: auto;
    margin: 16mm;
}

@media print {
    body {
        background: white;
        color: black;
        font-size: 10.5pt;
        line-height: 1.4;
    }

    main {
        width: 100%;
        max-width: none;
        padding: 0;
    }

    .course-nav,
    .skip-link {
        display: none;
    }

    header {
        padding: 0 0 0.5rem;
    }

    h1,
    .reference h1 {
        max-width: none;
        margin: 0.4rem 0 0.7rem;
        font-size: 28pt;
    }

    h2 {
        font-size: 17pt;
    }

    h3 {
        font-size: 12pt;
    }

    h1,
    h2,
    h3,
    summary,
    dt {
        break-after: avoid;
    }

    p,
    li,
    dd {
        orphans: 3;
        widows: 3;
    }

    section {
        margin-top: 1.4rem;
    }

    .lead {
        font-size: 12pt;
    }

    a {
        color: inherit;
    }

    pre {
        overflow: visible;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
        padding: 0.7rem;
        border: 1px solid #bbb;
        background: #f6f6f6;
        color: black;
        font-size: 8.5pt;
        line-height: 1.4;
        break-inside: avoid;
    }

    .table-wrap {
        overflow: visible;
    }

    table {
        font-size: 9.5pt;
    }

    tr,
    .callout {
        break-inside: avoid;
    }

    .source-note,
    footer,
    figcaption,
    .meta {
        font-size: 8pt;
        color: #444;
    }

    footer {
        margin-top: 1.5rem;
    }
}
