:root {
    --color-bg: #f2ecd9;
    --color-text: #232323;
    --color-muted: #655e46;
    --color-accent: #000000;
    --color-border: #DED7C1;
    --color-code-bg: #DED7C1;
    --max-width: 52rem;
}

body {
    font-family: system-ui, sans-serif;
    font-size: 1.1rem;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    margin: 0;
    padding: 0;
}

/* ── Layout ── */

main {
    max-width: var(--max-width);
    margin: 4rem auto;
    padding: 0 2rem;
}

/* ── TOC ── */

.toc {
    position: fixed;
    top: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    z-index: 100;
}

.toc-link {
    font-size: 0.75rem;
    color: var(--color-muted);
    text-decoration: none;
    transition: color 0.1s;
}

.toc-link:hover,
.toc-link.active {
    color: var(--color-accent);
    font-weight: 700;
}

.toc-exercise {
    font-size: 0.75rem;
    color: var(--color-muted);
    text-decoration: none;
    padding-left: 0.75rem;
}

.toc-exercise:hover,
.toc-exercise.active {
    color: var(--color-muted);
    font-weight: 700;
}

/* ── Typography ── */

h1,
h2,
h3,
h4 {
    color: var(--color-accent);
    line-height: 1.2;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 2rem 0 1rem;
}

h2 {
    font-size: 2rem;
    font-weight: 700;
    margin: 2rem 0 1rem;
}

h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 1.5rem 0 0.5rem;
}

header {
    margin-bottom: 4rem;
}



section {
    margin-bottom: 4rem;
}

.village-banner {
    width: 100%;
    aspect-ratio: 4 / 1;
    border-radius: 8px;
    overflow: hidden;
    margin: 0 0 2rem;
}

p {
    margin-bottom: 1.5rem;
}

a {
    color: inherit;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

/* ── Exercises ── */

.exercise {
    margin: 4rem 0;
}

.exercise-header {
    margin-bottom: 1rem;
    font-weight: 700;
}

.exercise-meta {
    font-weight: 400;
    color: var(--color-muted);
}

.exercise img {
    width: 100%;
    height: auto;
    margin: 1.5rem 0;
}

.image-placeholder {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--color-code-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1.5rem 0;
    color: var(--color-muted);
    font-size: 0.75rem;
}

/* ── Elements ── */

.note,
.lazy-mode,
.reference {
    background: var(--color-code-bg);
    padding: 1.5rem;
    margin: 1.5rem 0;
}

pre {
    background: var(--color-code-bg);
    padding: 1rem;
    overflow-x: auto;
    font-size: 0.75rem;
}

code {
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    background: var(--color-code-bg);
    padding: 0.2em 0.4em;
    font-size: 1em;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}

th,
td {
    text-align: left;
    padding: 0.5rem;
    padding-left: 0;
    border-bottom: 1px solid var(--color-border);
}

th {
    color: var(--color-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Responsive ── */

@media (max-width: 900px) {
    .toc {
        display: none;
    }
}

@media print {
    .toc {
        display: none;
    }

    body {
        background: white;
    }
}

/* ── Flowchart ── */

.flowchart {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 2rem 0 3rem;
    flex-wrap: wrap;
}

.flowchart__step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    background: var(--color-code-bg);
    border-radius: 6px;
    padding: 0.75rem 1.5rem;
    min-width: 5rem;
}

.flowchart__label {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-accent);
}

.flowchart__sub {
    font-size: 0.7rem;
    color: var(--color-muted);
}

.flowchart__arrow {
    font-size: 1.25rem;
    color: var(--color-muted);
    flex-shrink: 0;
}

/* ── Carousel ── */

.carousel-region {
    margin: 2rem 0;
    margin-right: calc(-50vw + var(--max-width) / 2);
    padding: 0 0 1rem 0;
}

@media (max-width: 56rem) {
    .carousel-region {
        margin-right: -2rem;
    }
}

.carousel {
    display: flex;
    gap: 1.25rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scroll-padding-inline: 0;
    padding: 0;
    align-items: stretch;
    scroll-marker-group: after;
    scrollbar-width: none;

    &::scroll-marker-group {
        display: flex;
        justify-content: flex-start;
        gap: 0.5rem;
        padding-block: 1rem;
        block-size: 44px;
    }

    &::after {
        content: "";
        display: block;
        flex-shrink: 0;
        inline-size: 1px;
    }
}

.carousel__slide {
    flex: 0 0 min(500px, 85%);
    scroll-snap-align: start;
    scroll-snap-stop: always;
    container-type: scroll-state;
    display: flex;
    flex-direction: column;
}

.carousel__slide::scroll-marker {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-border);
    transition: background 0.2s;
}

.carousel__slide::scroll-marker:target-current {
    background: var(--color-text);
}

.carousel__card {
    background: var(--color-code-bg);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    height: 100%;
    box-sizing: border-box;
    transition: opacity 0.3s ease, filter 0.3s ease;
    display: flex;
    flex-direction: column;
}

@container scroll-state(snapped: none) {
    .carousel__card {
        opacity: 0.5;
        filter: grayscale(0.3);
    }
}

.carousel__card p {
    font-size: 0.75rem;
    line-height: 1.45;
    margin-bottom: 0.75rem;
}

.carousel__card .image-placeholder {
    margin: 0;
    border-radius: 4px;
    aspect-ratio: 16 / 9;
}

.carousel__card .iframe-container {
    margin-top: auto;
    height: 340px;
    border-radius: 4px;
}

.iframe-container {
    width: 100%;
    height: 750px;
    background: var(--color-code-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1.5rem 0;
}

video {
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5rem 0;
    display: block;
}