:root {
  --paper: #f6f6f7;
  --paper-raised: #ffffff;
  --ink: #403e43;
  --ink-soft: #6b6870;
  --ink-faint: #9995a0;
  --rule: #e3e2e4;
  --rule-soft: #eeedef;
  --accent: #8e2c3b;
  --accent-tint: #f1e7e8;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --measure: 34rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1a1d; --paper-raised: #232227; --ink: #e8e6e8; --ink-soft: #a5a2a8;
    --ink-faint: #736f78; --rule: #302e34; --rule-soft: #26242a; --accent: #cd5a6d; --accent-tint: #2b2023;
  }
}
:root[data-theme="dark"] {
  --paper: #1b1a1d; --paper-raised: #232227; --ink: #e8e6e8; --ink-soft: #a5a2a8;
  --ink-faint: #736f78; --rule: #302e34; --rule-soft: #26242a; --accent: #cd5a6d; --accent-tint: #2b2023;
}
:root[data-theme="light"] {
  --paper: #f6f6f7; --paper-raised: #ffffff; --ink: #403e43; --ink-soft: #6b6870;
  --ink-faint: #9995a0; --rule: #e3e2e4; --rule-soft: #eeedef; --accent: #8e2c3b; --accent-tint: #f1e7e8;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 1.14rem; line-height: 1.72;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { animation: none !important; transition: none !important; } }

.wrap { max-width: 46rem; margin: 0 auto; padding: 0 1.75rem; }
.col { max-width: var(--measure); }
.eyebrow { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); margin: 0 0 1.4rem; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.masthead { border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: saturate(1.1) blur(6px); }
.masthead .wrap { display: flex; align-items: baseline; justify-content: space-between; padding-top: 0.95rem; padding-bottom: 0.95rem; }
.brand { font-weight: 600; font-size: 1.06rem; letter-spacing: 0.01em; text-decoration: none; color: var(--ink); }
.brand sup { color: var(--accent); font-family: var(--mono); font-size: 0.6em; font-weight: 500; }
.masthead nav { display: flex; gap: 1.4rem; font-family: var(--mono); font-size: 0.76rem; letter-spacing: 0.02em; }
.masthead nav a { color: var(--ink-soft); text-decoration: none; }
.masthead nav a:hover { color: var(--accent); }

.hero { padding: clamp(3.4rem, 9vw, 6.2rem) 0 clamp(2.6rem, 6vw, 4rem); }
.hero h1 { font-weight: 600; font-size: clamp(2.15rem, 5.4vw, 3.7rem); line-height: 1.08; letter-spacing: -0.012em; text-wrap: balance; margin: 0 0 1.5rem; }
.lede { font-size: 1.2rem; color: var(--ink-soft); margin: 0 0 2rem; }
.lede em { color: var(--ink); font-style: italic; }
.actions { display: flex; flex-wrap: wrap; gap: 0.7rem 1rem; align-items: center; }
.btn { font-family: var(--mono); font-size: 0.82rem; letter-spacing: 0.02em; text-decoration: none; padding: 0.62rem 1.05rem; border: 1px solid var(--ink); color: var(--paper); background: var(--ink); display: inline-flex; align-items: center; gap: 0.5rem; transition: transform 0.15s ease, background 0.15s ease; }
.btn:hover { transform: translateY(-1px); background: var(--accent); border-color: var(--accent); color: #fff; }
.btn .arw { transition: transform 0.15s ease; }
.btn:hover .arw { transform: translateX(3px); }
.btn-ghost { color: var(--ink); background: transparent; }
.btn-ghost:hover { color: #fff; }

.ref { font-family: var(--mono); color: var(--accent); text-decoration: none; font-weight: 500; vertical-align: super; font-size: 0.62em; padding: 0 0.06em; }
.hero h1 .ref { font-size: 0.42em; }
.ref:hover { text-decoration: underline; }

.rule-titled { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 1rem; margin: clamp(3rem, 7vw, 4.5rem) 0 2rem; }
.rule-titled h2 { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.76rem; font-weight: 500; color: var(--ink-soft); margin: 0; white-space: nowrap; }
.rule-titled::after { content: ""; height: 1px; background: var(--rule); }

section p { max-width: var(--measure); }
.idea p { font-size: 1.16rem; }
.idea em, section em { font-style: italic; color: var(--ink); }

ol.notes { list-style: none; counter-reset: note; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.2rem; }
ol.notes li { counter-increment: note; display: grid; grid-template-columns: 2.4rem 1fr; gap: 0.4rem 0.9rem; padding: 1.1rem 0.9rem 1.1rem 0.6rem; border-radius: 3px; transition: background 0.4s ease; scroll-margin-top: 5rem; }
ol.notes li::before { content: counter(note); font-family: var(--mono); font-size: 0.85rem; color: var(--accent); padding-top: 0.28rem; text-align: right; }
ol.notes li:target { background: var(--accent-tint); }
ol.notes h3 { margin: 0 0 0.25rem; font-size: 1.16rem; font-weight: 600; letter-spacing: -0.005em; }
ol.notes p { margin: 0; color: var(--ink-soft); font-size: 1.02rem; max-width: 30rem; }

.pull { margin: clamp(3.4rem, 8vw, 5rem) 0; }
.pull blockquote { margin: 0; border-left: 2px solid var(--accent); padding: 0.2rem 0 0.2rem 1.4rem; font-size: clamp(1.5rem, 3.6vw, 2.15rem); line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
.pull cite { display: block; margin-top: 0.9rem; font-family: var(--mono); font-style: normal; font-size: 0.76rem; letter-spacing: 0.03em; color: var(--ink-faint); text-transform: uppercase; }

.colophon { background: var(--paper-raised); border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; margin-top: 1.5rem; }
.colophon .bar { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 1rem; border-bottom: 1px solid var(--rule); font-family: var(--mono); font-size: 0.72rem; color: var(--ink-faint); letter-spacing: 0.04em; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rule); }
.colophon pre { margin: 0; padding: 1.1rem 1.2rem; overflow-x: auto; font-family: var(--mono); font-size: 0.82rem; line-height: 1.85; color: var(--ink); }
.colophon pre .c { color: var(--ink-faint); }
.colophon pre .p { color: var(--accent); }
code { font-family: var(--mono); font-size: 0.88em; }
.note-line { font-size: 0.92rem; color: var(--ink-soft); margin-top: 1rem; }

footer { border-top: 1px solid var(--rule); margin-top: clamp(3.5rem, 8vw, 5.5rem); padding: 2.2rem 0 3rem; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; align-items: baseline; }
footer .colo { font-family: var(--mono); font-size: 0.74rem; color: var(--ink-faint); letter-spacing: 0.02em; max-width: 26rem; line-height: 1.7; }
footer nav { display: flex; gap: 1.3rem; font-family: var(--mono); font-size: 0.76rem; }
footer nav a { color: var(--ink-soft); text-decoration: none; }
footer nav a:hover { color: var(--accent); }

.reveal { animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.reveal.d2 { animation-delay: 0.08s; }
.reveal.d3 { animation-delay: 0.16s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* Homepage */
.intro { padding: clamp(3.4rem, 9vw, 5.6rem) 0 1rem; }
.intro h1 { font-weight: 600; font-size: clamp(2rem, 5vw, 3.1rem); line-height: 1.1; letter-spacing: -0.01em; margin: 0 0 1.2rem; text-wrap: balance; }
.intro p { font-size: 1.18rem; color: var(--ink-soft); max-width: var(--measure); }
ol.works { list-style: none; counter-reset: work; margin: 0; padding: 0; }
ol.works li { counter-increment: work; border-top: 1px solid var(--rule); }
ol.works li:last-child { border-bottom: 1px solid var(--rule); }
ol.works a { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 0.3rem 1rem; padding: 1.4rem 0.4rem; text-decoration: none; color: var(--ink); transition: padding 0.18s ease, color 0.18s ease; }
ol.works a:hover { padding-left: 1rem; color: var(--accent); }
ol.works .name { font-size: 1.3rem; font-weight: 600; }
ol.works .go { font-family: var(--mono); font-size: 0.74rem; color: var(--ink-faint); letter-spacing: 0.03em; }
ol.works a:hover .go { color: var(--accent); }
ol.works .desc { grid-column: 1 / -1; color: var(--ink-soft); font-size: 1.02rem; max-width: 34rem; }

@media (max-width: 560px) {
  ol.notes li { grid-template-columns: 1.6rem 1fr; padding: 0.9rem 0.4rem; }
  .masthead nav { gap: 1rem; }
}
