:root {
    color-scheme: light;
    --bg: #f6f2e9;
    --panel: rgba(255, 252, 246, 0.92);
    --text: #1f1d1a;
    --muted: #5d574f;
    --border: #d7cfc2;
    --accent: #3f6b45;
    --accent-soft: rgba(63, 107, 69, 0.12);
    --shadow: 0 10px 30px rgba(47, 39, 28, 0.06);
    --focus: #1d5fbf;
    --header-offset: 5.75rem;
    --body-font: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
    --ui-font: "Segoe UI Variable", "Avenir Next", "Helvetica Neue", Arial, sans-serif;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #171819;
    --panel: rgba(27, 29, 31, 0.92);
    --text: #eef0eb;
    --muted: #b9beb5;
    --border: #32363a;
    --accent: #8bc591;
    --accent-soft: rgba(139, 197, 145, 0.16);
    --shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
    --focus: #9fcbff;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--body-font);
    font-size: 1.0625rem;
    line-height: 1.7;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--accent);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.16em;
}

a:hover {
    text-decoration-thickness: 0.12em;
}

a:focus-visible,
button:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -3rem;
    z-index: 20;
    padding: 0.6rem 0.9rem;
    border-radius: 0.4rem;
    background: var(--text);
    color: var(--bg);
    font-family: var(--ui-font);
    text-decoration: none;
}

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

.site-shell {
    width: min(1100px, calc(100% - 2rem));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
    backdrop-filter: blur(10px);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.95rem 0;
}

.brand-block {
    min-width: 0;
}

.site-brand {
    display: inline-block;
    color: var(--text);
    font-family: var(--ui-font);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-decoration: none;
}

.site-tagline {
    margin: 0.1rem 0 0;
    color: var(--muted);
    font-family: var(--ui-font);
    font-size: 0.88rem;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-family: var(--ui-font);
}

.site-nav__link,
.theme-toggle {
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1;
}

.site-nav__link {
    padding: 0.6rem 0.85rem;
    text-decoration: none;
}

.site-nav__link:hover,
.site-nav__link.is-current {
    background: var(--accent-soft);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem 0.8rem;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
}

.theme-toggle:hover {
    background: var(--accent-soft);
}

.theme-toggle__icon {
    font-size: 1rem;
}

.page {
    padding: 2.2rem 0 4rem;
}

.page-grid {
    display: grid;
    grid-template-columns: minmax(14rem, 18rem) minmax(0, 1fr);
    gap: 2.5rem;
    align-items: start;
}

.toc__inner {
    position: sticky;
    top: calc(var(--header-offset) + 0.5rem);
}

.eyebrow {
    margin: 0 0 0.5rem;
    color: var(--muted);
    font-family: var(--ui-font);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.page-title,
.document h2,
.not-found h1 {
    font-family: var(--ui-font);
    line-height: 1.2;
}

.page-title {
    margin: 0;
    font-size: clamp(1.7rem, 1.2rem + 1.4vw, 2.3rem);
}

.lede,
.intro p,
.not-found p {
    max-width: 65ch;
}

.toc-nav {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.toc-list {
    margin: 0;
    padding-left: 1.25rem;
}

.toc-list li + li {
    margin-top: 0.55rem;
}

.toc-list a {
    color: var(--muted);
    text-decoration: none;
}

.toc-list a:hover,
.toc-list a:focus-visible {
    color: var(--accent);
    text-decoration: underline;
}

.document {
    max-width: 72ch;
}

.intro {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.placeholder-note {
    padding-left: 0.85rem;
    border-left: 3px solid var(--accent);
    color: var(--muted);
}

.rule-section {
    padding-top: 1.75rem;
    margin-top: 1.75rem;
    border-top: 1px solid var(--border);
    scroll-margin-top: calc(var(--header-offset) + 1rem);
}

.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
}

.document h2 {
    margin: 0;
    font-size: clamp(1.3rem, 1.12rem + 0.5vw, 1.6rem);
}

.anchor-link {
    color: var(--muted);
    font-family: var(--ui-font);
    font-size: 0.95rem;
    text-decoration: none;
}

.anchor-link:hover,
.anchor-link:focus-visible {
    color: var(--accent);
}

.rule-list {
    margin: 0;
    padding-left: 1.4rem;
}

.rule-list li + li {
    margin-top: 0.8rem;
}

.page--narrow {
    max-width: 72ch;
}

.not-found {
    padding-top: 2rem;
}

@media (max-width: 820px) {
    :root {
        --header-offset: 6.5rem;
    }

    .site-header__inner,
    .site-nav {
        align-items: flex-start;
    }

    .site-header__inner {
        flex-direction: column;
    }

    .page-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .toc__inner {
        position: static;
    }

    .toc-nav {
        border-bottom: 1px solid var(--border);
        padding-bottom: 1rem;
    }
}

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

    .site-shell {
        width: min(100% - 1.25rem, 1100px);
    }

    .site-nav {
        width: 100%;
        justify-content: space-between;
    }

    .section-heading {
        align-items: center;
    }
}
