:root {
    color-scheme: light;
    --paper: #fff;
    --panel: #f4f1ed;
    --ink: #222;
    --muted: #57544f;
    --line: #d8d5d0;
    --accent: #222;
    --gutter: clamp(18px, 4.5vw, 64px);
    --serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
    --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font: 400 1rem/1.55 system-ui, sans-serif;
    color: var(--ink);
    background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, p { margin: 0; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

body {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100vh;
    height: 100dvh;
}

main {
    min-height: 0;
    overflow-y: auto;
    scroll-padding-block: 18px;
}

main:focus-visible { outline-offset: -3px; }

.shell {
    width: min(100%, 1312px);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.skip-link {
    position: fixed;
    z-index: 2;
    inset: .5rem auto auto .5rem;
    padding: .625rem 1rem;
    transform: translateY(-180%);
    color: var(--paper);
    background: var(--accent);
}

.skip-link:focus { transform: none; }

.masthead { border-bottom: 1px solid var(--line); }

.header-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    min-height: 64px;
}

.wordmark {
    justify-self: start;
    font-size: 1.1875rem;
    font-weight: 650;
    letter-spacing: -.06em;
    line-height: 1;
    text-decoration: none;
}

.navigation {
    display: flex;
    gap: clamp(16px, 3vw, 40px);
}

.navigation a, .language, .dock a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: .875rem;
    text-decoration: none;
}

.navigation a:hover, .language:hover, .dock a:hover {
    text-decoration: underline;
    text-underline-offset: .25em;
}

.language {
    justify-self: end;
    justify-content: center;
    min-width: 44px;
    margin-inline-end: -9px;
    color: var(--accent);
    font-family: var(--mono);
}

.dock {
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
}

.dock-inner, .dock-credit {
    display: flex;
    align-items: center;
}

.dock-inner {
    justify-content: space-between;
    gap: 12px;
    min-height: 58px;
    padding-block: 6px;
}

.dock-credit {
    flex-wrap: wrap;
    column-gap: 14px;
    color: var(--muted);
}

.dock-credit a { font-weight: 700; }
.dock-credit small { font-size: .8125rem; }

.opening {
    display: grid;
    justify-items: center;
    align-content: center;
    min-height: clamp(440px, calc(100dvh - 124px), 850px);
    padding-block: clamp(48px, 10dvh, 110px);
    text-align: center;
}

.label {
    color: var(--accent);
    font: 500 .875rem/1.4 var(--mono);
}

h1, h2 {
    font-family: var(--serif);
    font-weight: 400;
    letter-spacing: -.035em;
}

h1 {
    max-width: 15ch;
    margin-top: 20px;
    font-size: clamp(3rem, 6.5vw, 6.15rem);
    line-height: .96;
    text-wrap: balance;
}

.hero-lead {
    max-width: 49ch;
    margin-top: 24px;
    color: var(--muted);
    font-size: clamp(1.0625rem, 1.45vw, 1.225rem);
}

.brief-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: min(100%, 530px);
    gap: 10px 20px;
    margin-top: 34px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    text-decoration: none;
    text-align: left;
}

.brief-entry strong {
    color: var(--accent);
    font-size: .9rem;
    text-decoration: underline;
    text-underline-offset: .25em;
    white-space: nowrap;
}

.brief-entry:hover { border-color: var(--accent); }

.chapter, .section-grid {
    display: grid;
    grid-template-columns: minmax(0, .65fr) minmax(0, 1fr);
    gap: 18px clamp(20px, 8vw, 128px);
    width: min(100%, 1000px);
    margin-inline: auto;
    border-top: 1px solid var(--line);
}

.chapter {
    min-height: min(610px, 76dvh);
    align-content: center;
    padding-block: clamp(45px, 9dvh, 100px);
}

.chapter .label { padding-top: .65em; }

.chapter h2, .section-grid h2 {
    font-size: clamp(2.35rem, 4.75vw, 4.65rem);
    line-height: 1;
    text-wrap: pretty;
}

.chapter-copy > p, .contact-copy, .steps p {
    color: var(--muted);
}

.chapter-copy > p {
    max-width: 40ch;
    margin-top: 18px;
    font-size: clamp(1.0625rem, 1.65vw, 1.25rem);
}

.chapter-copy > a { display: inline-block; margin-top: 18px; }
.text-link { color: var(--accent); text-underline-offset: .23em; }
.text-link:hover { text-decoration-thickness: 2px; }

.steps { margin-top: 24px; }

.steps article + article {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.steps h3 { font-size: 1rem; font-weight: 650; }

.section-grid { padding-block: clamp(36px, 6vw, 75px); }
.section-grid h2 { font-size: clamp(1.95rem, 3.2vw, 3rem); }

.button, .dock .dock-action, .project-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 14px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--paper);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
}

.button { margin-top: 12px; }
.dock-action { white-space: nowrap; }
:is(.button, .dock-action, .project-action):hover { background: #444; }



.source-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-top: 9px;
}

[hidden] { display: none !important; }

.planner {
    width: min(calc(100% - 32px), 770px);
    height: min(810px, calc(100dvh - 36px));
    max-width: none;
    max-height: none;
    padding: 0;
    border: 1px solid var(--line);
    color: var(--ink);
    background: var(--paper);
}

.planner::backdrop { background: rgb(31 35 27 / 42%); }

.planner-frame {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100%;
}

.planner-head, .planner-dock {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px clamp(16px, 4vw, 34px);
}

.planner-head {
    border-bottom: 1px solid var(--line);
}

.planner-head h2, .answer h3 {
    font: 620 1rem/1.3 system-ui, sans-serif;
    letter-spacing: 0;
}

.quiet, .topic {
    min-height: 44px;
    border: 0;
    color: var(--accent);
    background: none;
    font: inherit;
    cursor: pointer;
}

.quiet { text-decoration: underline; text-underline-offset: .25em; }

.planner-body {
    overflow-y: auto;
    scroll-padding-block: 14px;
    padding: clamp(22px, 5vw, 36px) clamp(16px, 4vw, 34px);
}

.planner-prompt {
    font: 400 clamp(1.75rem, 4vw, 2.65rem)/1.1 var(--serif);
    letter-spacing: -.025em;
}

.planner-prompt:focus { outline: 0; }
.hint, .price-note { color: var(--muted); font-size: .875rem; }
.hint { margin-top: 8px; }

.topics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-block: 16px 18px;
}

.topic {
    padding: 5px 11px;
    border: 1px solid var(--line);
    font-size: .9rem;
}

.topic:hover { border-color: var(--accent); }

.topic[aria-pressed="true"] {
    color: var(--paper);
    border-color: var(--accent);
    background: var(--accent);
}

.answer { padding: clamp(15px, 3vw, 22px); background: var(--panel); }
.answer > p { margin-top: 6px; color: var(--muted); }
.options { margin-top: 14px; }

.option {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) max-content;
    align-items: start;
    gap: 2px 10px;
    padding-block: 12px;
    border-top: 1px solid var(--line);
    cursor: pointer;
}

.option input {
    width: 18px;
    height: 18px;
    margin: 4px 0 0;
    accent-color: var(--accent);
}

.option-copy { display: grid; gap: 4px; }
.option-copy span { color: var(--muted); font-size: .925rem; }

.option-price {
    font-size: .875rem;
    font-weight: 620;
    white-space: nowrap;
}

.vendor-link, .language-note { font-size: .875rem; }
.price-note { margin-top: 13px; }

.planner-dock {
    border-top: 1px solid var(--line);
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.plan-total { font-size: .875rem; }
.plan-total p:last-child { font-weight: 620; }

.project-action { cursor: pointer; font-size: .9rem; white-space: nowrap; }
.project-action:disabled { opacity: .58; cursor: default; }
.project-action:disabled:hover { background: var(--accent); }

.chosen {
    display: grid;
    gap: 0;
    margin: 20px 0 0;
    padding: 0;
    list-style: none;
    border-bottom: 1px solid var(--line);
}

.chosen li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding-block: 9px;
    border-top: 1px solid var(--line);
}

.chosen strong { white-space: nowrap; }

.note-label {
    display: block;
    margin-top: 20px;
    font-weight: 620;
}

.note-label span { color: var(--muted); font-weight: 400; }

textarea {
    display: block;
    width: 100%;
    margin-top: 7px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 0;
    color: var(--ink);
    background: transparent;
    font: inherit;
    resize: vertical;
}

.review-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0 14px; }

@media (max-width: 650px) {
    .opening { min-height: min(640px, max(460px, calc(100dvh - 150px))); }
    .chapter, .section-grid { grid-template-columns: minmax(0, 1fr); }
    .chapter { min-height: auto; padding-block: 62px; }
    .chapter .label { padding-top: 0; }
}

@media (max-width: 500px) {
    .header-inner {
        grid-template: auto auto / 1fr auto;
        padding-top: 4px;
    }

    .navigation {
        grid-area: 2 / 1 / 3 / 3;
        gap: clamp(15px, 5.7vw, 28px);
    }

    .wordmark { font-size: 1.125rem; }
    .language { grid-area: 1 / 2; }
    .dock-credit { display: block; line-height: 1.25; }
    .dock-credit a { min-height: 24px; }
    .dock-credit small { display: block; }
    .dock .dock-action { padding-inline: 10px; }
    .brief-entry { padding-inline: 11px; }

    .planner {
        width: 100%;
        height: 100dvh;
        margin: 0;
        border: 0;
    }

    .option { grid-template-columns: auto minmax(0, 1fr); }
    .option-price { grid-column: 2; }
    .planner-dock { align-items: end; }
    .review-actions { gap: 0 8px; }
}

@media print {
    body { display: block; height: auto; }
    main { overflow: visible; }
    .opening, .chapter { min-height: auto; }
    .skip-link, .navigation, .language, .dock-action, .brief-entry, dialog { display: none; }
}

.ink-study {
    display: block;
    width: min(100%, 420px, 56dvh);
    height: auto;
    background: var(--panel);
}
.opening h1 { max-width: none; margin-top: 20px; font-size: clamp(1.8rem, 3vw, 2.8rem); }
.art-entry { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); text-underline-offset: .25em; }

@media (prefers-color-scheme: dark) {
    :root:not([data-preview-theme="light"]) {
        color-scheme: dark;
        --paper: #222;
        --panel: #2d2d2d;
        --ink: #989898;
        --muted: #898989;
        --line: #494949;
        --accent: #989898;
        --display-ink: #767676;
        --art-ink: #808080;
    }
    :root:not([data-preview-theme="light"]) .planner {
        --ink: #a4a4a4;
        --muted: #949494;
        --accent: #a4a4a4;
    }
    :root:not([data-preview-theme="light"]) :is(.option-copy span, .entry-copy, .chapter-copy p) { color: var(--ink); }
    :root:not([data-preview-theme="light"]) :is(.wordmark, .navigation, .language, .dock-credit a) { color: var(--muted); }
    :root:not([data-preview-theme="light"]) :is(.entry h1, .entry h2) { color: var(--display-ink); }
    :root:not([data-preview-theme="light"]) :is(.button, .dock-action, .project-action):hover { background: #aaa; }
}

.navigation a { text-transform: uppercase; letter-spacing: .04em; }

.opening { min-height: 100%; }
.chapter { min-height: auto; }

.folio { display:grid; grid-template-columns:1.12fr 1fr; gap:clamp(32px,7vw,110px); }
.plate { position:sticky; top:0; align-self:start; height:var(--reader,80dvh); display:grid; align-items:center; }
.plate .ink-study { width:min(100%,65dvh); aspect-ratio:1; }
.entry { min-height:var(--reader,80dvh); display:flex; flex-direction:column; align-items:flex-start; justify-content:center; gap:22px; padding-block:48px; }
.folio-label { font:12px/1.4 var(--mono); color:var(--muted); }
.entry :is(h1,h2) { margin:0; max-width:14ch; font-size:clamp(2.8rem,4.7vw,5.2rem); line-height:1.02; text-wrap:balance; }
.entry-copy { max-width:37ch; line-height:1.55; }
.entry a { min-height:44px; display:inline-flex; align-items:center; }
@media(max-width:700px) {
    .folio { display:block; }
    .plate { height:min(32dvh,250px); z-index:1; background:var(--paper); justify-items:center; padding-block:10px; }
    .plate .ink-study { width:auto; max-width:100%; height:100%; min-height:0; }
    .entry { min-height:calc(var(--reader,80dvh) - min(32dvh,250px)); gap:12px; padding:24px 0; scroll-margin-top:min(32dvh,250px); }
    .entry :is(h1,h2) { font-size:clamp(2.2rem,9vw,3.6rem); }
}

.plate .ink-study { background: transparent; }
:root[data-preview-theme="light"] {
    color-scheme: light;
    --paper: #fff;
    --panel: #f4f1ed;
    --ink: #222;
    --muted: #57544f;
    --line: #d8d5d0;
    --accent: #222;
}
:root[data-preview-theme="light"] :is(.button, .dock-action, .project-action):hover { background: #444; }

.entry .steps { margin-top:0; }
