:root {
    --bg: #f4f3ef;
    --paper: #fbfaf7;
    --ink: #111111;
    --ink-soft: #343434;
    --muted: #6d6a64;
    --rule: #cfcac1;
    --rule-strong: #9d968a;
    --field: #ffffff;
    --accent: #202733;
    --accent-muted: #e8eaed;
    --measure: 780px;
    --wrap: 1120px;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --serif: Georgia, "Times New Roman", Times, serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.58;
    text-rendering: optimizeLegibility;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(17, 17, 17, 0.028) 1px, transparent 1px),
        linear-gradient(90deg, rgba(17, 17, 17, 0.022) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.42), transparent 72%);
}

img {
    display: block;
    max-width: 100%;
}

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

button,
input,
select,
textarea {
    font: inherit;
}

.wrap {
    width: calc(100% - 40px);
    max-width: var(--wrap);
    margin: 0 auto;
}

.site-header {
    border-bottom: 1px solid var(--rule);
    background: rgba(244, 243, 239, 0.94);
    position: sticky;
    top: 0;
    z-index: 20;
}

.header-row {
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.back-link,
.header-links a,
.button {
    text-decoration: none;
}

.back-link {
    font-weight: 620;
    letter-spacing: 0.01em;
}

.header-links {
    display: flex;
    gap: 18px;
    color: var(--muted);
    font-size: 0.9rem;
}

.header-links a {
    border-bottom: 1px solid transparent;
}

.header-links a:hover {
    color: var(--ink);
    border-bottom-color: var(--ink);
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, var(--measure)) minmax(220px, 1fr);
    column-gap: 72px;
    row-gap: 28px;
    padding: 72px 0 46px;
    border-bottom: 1px solid var(--rule);
}

.eyebrow {
    grid-column: 1 / -1;
    margin: 0 0 -10px;
    color: var(--muted);
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    grid-column: 1;
    max-width: 820px;
    min-width: 0;
    font-family: var(--serif);
    font-size: clamp(2.55rem, 6vw, 5.8rem);
    font-weight: 500;
    line-height: 0.94;
    overflow-wrap: normal;
}

.lead {
    grid-column: 1;
    max-width: var(--measure);
    min-width: 0;
    margin: 0;
    color: var(--ink-soft);
    font-size: 1.05rem;
    line-height: 1.68;
}

.paper-meta {
    grid-column: 2;
    grid-row: 2 / span 2;
    align-self: start;
    margin: 0;
    border-top: 2px solid var(--ink);
    font-size: 0.92rem;
}

.paper-meta div {
    padding: 13px 0 14px;
    border-bottom: 1px solid var(--rule);
}

.paper-meta dt {
    margin: 0 0 3px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.paper-meta dd {
    margin: 0;
    color: var(--ink-soft);
}

.hero-actions {
    grid-column: 1 / -1;
}

.hero-actions,
.control-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

.button,
.chip {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 13px;
    border: 1px solid var(--rule-strong);
    border-radius: 0;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
}

.button:hover,
.chip:hover {
    background: var(--accent-muted);
}

.button-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
}

.button-primary:hover {
    background: #0f1520;
}

.facts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0;
    border-bottom: 1px solid var(--rule);
}

.facts article {
    min-height: 190px;
    padding: 24px 22px 26px 0;
    border-right: 1px solid var(--rule);
}

.facts article + article {
    padding-left: 22px;
}

.facts article:last-child {
    border-right: 0;
}

h2 {
    font-size: 1.24rem;
    font-weight: 640;
    line-height: 1.16;
}

.facts h2 {
    margin-bottom: 32px;
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

p {
    margin: 0;
}

.facts p,
.section-heading p,
figcaption,
.footer-note p,
.prompt-meta p {
    color: var(--muted);
}

.section {
    padding: 54px 0;
    border-bottom: 1px solid var(--rule);
}

.section-heading {
    display: grid;
    grid-template-columns: 260px minmax(0, var(--measure));
    gap: 48px;
    align-items: start;
    margin-bottom: 28px;
}

.section-heading p {
    max-width: var(--measure);
}

.assay-box {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    border-top: 1px solid var(--ink);
    border-bottom: 1px solid var(--rule);
    background: var(--paper);
}

pre {
    margin: 0;
    min-height: 172px;
    overflow-x: auto;
    padding: 24px;
    border-right: 1px solid var(--rule);
    background: #f0eee8;
    font-size: 0.94rem;
    line-height: 1.7;
}

code,
textarea,
input,
select {
    font-family: var(--mono);
}

.compact-list {
    margin: 0;
    padding: 22px 24px 22px 40px;
    color: var(--ink-soft);
}

.compact-list li + li {
    margin-top: 10px;
}

.figure-grid {
    display: grid;
    gap: 34px;
}

.figure {
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--ink);
    background: var(--paper);
}

.figure img {
    width: 100%;
    border-right: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
    border-left: 1px solid var(--rule);
    background: #ffffff;
}

figcaption {
    max-width: var(--measure);
    padding: 12px 0 0;
    font-size: 0.92rem;
}

.demo-grid {
    display: grid;
    grid-template-columns: 330px minmax(0, 1fr);
    border-top: 1px solid var(--ink);
    border-bottom: 1px solid var(--rule);
    background: var(--paper);
}

.controls,
.prompt-panel {
    padding: 20px;
}

.controls {
    display: grid;
    gap: 15px;
    border-right: 1px solid var(--rule);
}

.controls label {
    display: grid;
    gap: 6px;
}

.controls span {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 750;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--rule);
    border-radius: 0;
    background: var(--field);
    color: var(--ink);
}

input,
select {
    min-height: 38px;
    padding: 0 10px;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.preset-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    min-height: 31px;
    min-width: 42px;
    padding: 0 10px;
    border-color: var(--rule);
    background: #f4f2ed;
}

.chip.is-active {
    border-color: var(--accent);
    background: var(--accent-muted);
}

.prompt-panel {
    display: grid;
    gap: 12px;
}

.prompt-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.prompt-meta p {
    font-family: var(--mono);
    font-size: 0.83rem;
}

textarea {
    min-height: 440px;
    resize: vertical;
    padding: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
}

.footer-note {
    padding-bottom: 64px;
    border-bottom: 0;
}

.footer-note p {
    max-width: var(--measure);
}

@media (max-width: 980px) {
    .hero {
        grid-template-columns: 1fr;
        row-gap: 22px;
        padding-top: 52px;
    }

    .paper-meta,
    .lead,
    h1,
    .eyebrow,
    .hero-actions {
        grid-column: 1;
        grid-row: auto;
    }

    .paper-meta {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0;
    }

    .paper-meta div {
        padding-right: 16px;
    }

    .facts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .facts article:nth-child(2) {
        border-right: 0;
    }

    .facts article:nth-child(n + 3) {
        border-top: 1px solid var(--rule);
    }

    .section-heading,
    .assay-box,
    .demo-grid {
        grid-template-columns: 1fr;
    }

    pre,
    .controls {
        border-right: 0;
        border-bottom: 1px solid var(--rule);
    }
}

@media (max-width: 680px) {
    body {
        font-size: 14px;
    }

    .wrap {
        width: calc(100% - 36px);
        max-width: var(--wrap);
    }

    .header-row,
    .prompt-meta {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero {
        padding: 38px 0 34px;
    }

    h1 {
        font-size: 2.08rem;
        line-height: 1.02;
        overflow-wrap: break-word;
    }

    .lead {
        font-size: 0.98rem;
        line-height: 1.62;
    }

    .paper-meta,
    .facts {
        grid-template-columns: 1fr;
    }

    .facts article,
    .facts article + article,
    .facts article:nth-child(2),
    .facts article:last-child {
        min-height: 0;
        padding: 20px 0;
        border-right: 0;
        border-top: 1px solid var(--rule);
    }

    .facts article:first-child {
        border-top: 0;
    }

    .facts h2 {
        margin-bottom: 10px;
    }

    .section {
        padding: 38px 0;
    }

    .section-heading {
        gap: 12px;
    }

    textarea {
        min-height: 360px;
    }
}
