:root {
  --ink: #152823;
  --muted: #607069;
  --paper: #f4f0e6;
  --paper-deep: #e9e2d2;
  --green: #173a37;
  --green-light: #2b5a51;
  --lime: #d9f15a;
  --coral: #ec725b;
  --line: rgba(21, 40, 35, 0.16);
  --code: #102925;
  --radius: 18px;
  color-scheme: light;
  font-family: "Aptos", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); line-height: 1.62; }
a { color: var(--green-light); text-underline-offset: 0.2em; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
code, pre, textarea {
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-variant-ligatures: none;
}
pre { overflow: auto; }
img { max-width: 100%; }

.skip-link {
  position: fixed; left: 1rem; top: -5rem; z-index: 100;
  background: var(--lime); color: var(--ink); padding: .7rem 1rem; font-weight: 700;
}
.skip-link:focus { top: 1rem; }

.site-frame { min-height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 2.1rem 1.7rem;
  background: var(--green); color: #f8f4e9; display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.08);
}
.brand { display: block; width: min(100%, 11rem); }
.brand-logo {
  display: block; width: 100%; height: auto; padding: .3rem; background: #fff;
  border-radius: .25rem;
}
.tagline { color: rgba(255,255,255,.55); font-size: .78rem; line-height: 1.45; margin: 1rem 0 2.2rem; max-width: 16rem; }
.sidebar nav { display: grid; gap: .25rem; }
.sidebar nav a {
  color: rgba(255,255,255,.72); text-decoration: none; padding: .64rem .75rem;
  border-radius: 9px; font-size: .92rem; transition: .15s ease;
}
.sidebar nav a:hover { color: white; background: rgba(255,255,255,.07); }
.sidebar nav a[aria-current="page"] { color: var(--ink); background: var(--lime); font-weight: 700; }
.sidebar-note { margin-top: auto; padding-top: 2rem; font-size: .73rem; color: rgba(255,255,255,.72); }
.sidebar-note small { display: block; margin-top: .35rem; color: rgba(255,255,255,.4); line-height: 1.4; }
.status-dot { display: inline-block; width: .55rem; height: .55rem; margin-right: .4rem; background: var(--lime); border-radius: 50%; box-shadow: 0 0 0 4px rgba(217,241,90,.1); }
.mobile-header { display: none; }

.document { width: 100%; min-width: 0; }
.document > section, .document > header, .document > article, .document > div, .document > nav, .document > aside {
  width: min(1060px, calc(100% - 6rem)); margin-left: auto; margin-right: auto;
}
.document footer {
  width: min(1060px, calc(100% - 6rem)); margin: 6rem auto 0; padding: 1.5rem 0 2.5rem;
  border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem;
}
.eyebrow, .chapter-kicker {
  color: var(--green-light); text-transform: uppercase; letter-spacing: .15em; font-size: .72rem; font-weight: 800;
}
.hero { min-height: 680px; padding: 7rem 0 5rem; position: relative; }
.hero::after {
  content: ""; position: absolute; right: -2rem; top: 4.5rem; width: 150px; height: 150px;
  border: 1px solid var(--coral); border-radius: 50%; opacity: .55; pointer-events: none;
}
h1, h2, h3 { line-height: 1.08; letter-spacing: -.035em; }
h1 { font-size: clamp(3rem, 7vw, 6.8rem); margin: .45rem 0 1.4rem; max-width: 880px; }
h2 { font-size: clamp(1.55rem, 3vw, 2.5rem); }
h3 { font-size: 1.12rem; }
.lede { color: var(--muted); font-size: clamp(1.05rem, 2vw, 1.33rem); max-width: 750px; }
.hero .lede { max-width: 660px; }
.hero-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin: 2.2rem 0 4rem; }
.button {
  display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--green);
  border-radius: 999px; padding: .75rem 1.15rem; cursor: pointer; text-decoration: none; font-weight: 750; transition: .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--green); color: white; }
.button.primary:hover { background: var(--green-light); }
.button.ghost { background: transparent; color: var(--green); }
.button.small { padding: .48rem .85rem; font-size: .85rem; }
.hero-code {
  background: var(--code); color: #eaf3e2; border-radius: var(--radius); padding: 1rem 1.4rem 1.35rem;
  max-width: 680px; box-shadow: 18px 18px 0 var(--paper-deep);
}
.code-label { color: var(--lime); font: 600 .68rem "Cascadia Code", monospace; text-transform: uppercase; letter-spacing: .12em; }
.hero-code pre { margin: 1rem 0 0; font-size: .86rem; line-height: 1.65; }

.stats { display: grid; grid-template-columns: repeat(4,1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stats div { padding: 2rem 1rem; border-right: 1px solid var(--line); }
.stats div:last-child { border: 0; }
.stats strong { display: block; font-size: 2rem; letter-spacing: -.04em; }
.stats span { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.section-grid { display: grid; grid-template-columns: .8fr 1.2fr; gap: 6rem; padding: 7rem 0; }
.section-grid h2 { margin-top: .8rem; }
.feature-list { display: grid; }
.feature-list article { display: grid; grid-template-columns: 42px 1fr; column-gap: 1rem; padding: 1.5rem 0; border-top: 1px solid var(--line); }
.feature-list article > span { color: var(--coral); font: 700 .72rem "Cascadia Code", monospace; }
.feature-list h3, .feature-list p { margin: 0; }
.feature-list p { grid-column: 2; color: var(--muted); margin-top: .35rem; }
.callout { padding: 5rem 0; display: grid; grid-template-columns: .75fr 1.25fr; gap: 4rem; align-items: start; }

.page-header { padding: 6.2rem 0 3.5rem; border-bottom: 1px solid var(--line); margin-bottom: 3rem; }
.page-header.compact { padding-bottom: 2rem; }
.page-header h1 { font-size: clamp(3.2rem, 7vw, 6rem); margin-bottom: 1rem; }
.back-link { display: inline-block; margin-bottom: 2rem; font-size: .85rem; text-decoration: none; }
.chapter-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; padding: 1rem 0 3rem; }
.chapter-card {
  min-height: 230px; padding: 1.5rem; border: 1px solid var(--line); border-radius: var(--radius);
  color: inherit; text-decoration: none; background: rgba(255,255,255,.2); transition: .18s ease;
}
.chapter-card:hover { transform: translateY(-3px); border-color: var(--green-light); background: rgba(255,255,255,.48); }
.chapter-card > span { color: var(--coral); font: 700 .72rem "Cascadia Code", monospace; }
.chapter-card h2 { margin: 2rem 0 .7rem; }
.chapter-card p { color: var(--muted); margin: 0 0 1.2rem; }
.chapter-card .text-link { text-decoration: none; }
.provenance-note { margin-top: 2rem; margin-bottom: 3rem; background: var(--paper-deep); border-left: 4px solid var(--coral); padding: 1.2rem 1.4rem; border-radius: 0 12px 12px 0; }
.chapter-kicker { padding-top: 4rem; }
.prose { max-width: 800px; padding: 1rem 0 2rem; }
.prose h1 { font-size: clamp(2.8rem, 6vw, 5rem); margin: .5rem 0 3rem; }
.prose h2 { margin: 3.5rem 0 1rem; padding-top: .5rem; }
.prose h3 { margin-top: 2.5rem; }
.prose p, .prose li { max-width: 74ch; }
.prose pre { padding: 1.2rem; background: var(--code); color: #eaf3e2; border-radius: 12px; font-size: .86rem; line-height: 1.6; }
.prose pre a, .hero-code a { color: var(--lime); }
.prose code:not(pre code) { background: var(--paper-deep); padding: .15em .35em; border-radius: 4px; font-size: .88em; }
.prose blockquote { margin: 2rem 0; padding-left: 1.2rem; border-left: 3px solid var(--coral); color: var(--muted); }
.essay-header h1 { font-size: clamp(2.4rem, 5.5vw, 4.4rem); max-width: 18ch; }
.essay-toc {
  display: grid; gap: 1rem; margin: 0 0 2.5rem; padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--line);
}
.essay-toc ol {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem 2rem;
  margin: 0; padding: 0; list-style: none; counter-reset: essay-toc;
}
.essay-toc li { counter-increment: essay-toc; }
.essay-toc a {
  display: grid; grid-template-columns: 2rem 1fr; gap: .6rem; color: inherit;
  text-decoration: none; font-size: .92rem; line-height: 1.35;
}
.essay-toc a::before {
  content: counter(essay-toc, decimal-leading-zero); color: var(--coral);
  font: 700 .72rem "Cascadia Code", monospace;
}
.essay-toc a:hover { color: var(--green-light); }
.essay-prose h2 { padding-top: 2rem; border-top: 1px solid var(--line); }
.essay-prose a { font-weight: 650; }
.why-next p { color: var(--muted); max-width: 68ch; }
.why-next {
  display: grid; grid-template-columns: .8fr 1.2fr; gap: 4rem; align-items: start;
  padding: 4rem 0; border-top: 1px solid var(--line);
}
.why-next h2 { margin-top: .8rem; }
.why-next .hero-actions { margin: .5rem 0 0; }
.chapter-nav { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding: 1.5rem 0 3rem; }
.chapter-nav a { text-decoration: none; font-weight: 700; }
.legend { padding: 1rem 0 2.5rem; color: var(--muted); display: flex; gap: .65rem; align-items: center; flex-wrap: wrap; font-size: .85rem; }
.badge { display: inline-block; border-radius: 999px; padding: .22rem .58rem; text-transform: uppercase; letter-spacing: .08em; font-size: .61rem; font-weight: 800; }
.badge.normative { background: #cce8dc; color: #174b3c; }
.badge.provisional { background: #f6df94; color: #694d00; }
.badge.disputed { background: #f2c4bc; color: #712b20; }
.badge.recovered { background: #d9d5ed; color: #433a72; }
.badge.library { background: var(--green); color: white; }

.example-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 1rem; padding: 1rem 0 3rem; }
.example-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; min-height: 235px; display: flex; flex-direction: column; background: rgba(255,255,255,.22); }
.example-card .mono { color: var(--muted); font: .65rem "Cascadia Code", monospace; margin-left: .5rem; }
.example-card h2 { font-size: 1.2rem; margin: 1.5rem 0 .65rem; }
.example-card h2 a { color: inherit; text-decoration: none; }
.example-card p { color: var(--muted); font-size: .82rem; }
.text-link { margin-top: auto; text-decoration: none; font-weight: 700; font-size: .83rem; }
.filter-row { display: flex; gap: 1rem; align-items: center; padding: 1rem 0; }
.filter-row label { font-weight: 700; font-size: .82rem; }
.filter-row input, select {
  flex: 1; max-width: 500px; border: 1px solid var(--line); border-radius: 999px; padding: .7rem 1rem; background: rgba(255,255,255,.4); color: var(--ink);
}
.metadata { border-top: 1px solid var(--line); margin-top: 3rem; padding: 2rem 0; }
.metadata dl { display: grid; grid-template-columns: 130px 1fr; gap: .6rem 1.2rem; }
.metadata dt { color: var(--muted); font-size: .8rem; }
.metadata dd { margin: 0; overflow-wrap: anywhere; }

sutl-example, sutl-core-example { display: block; margin: 2rem 0; }
.example-fallback { border: 1px dashed var(--line); border-radius: 12px; padding: 1rem; color: var(--muted); }
.runner-card { border: 1px solid var(--line); border-radius: var(--radius); background: #fbf8f0; overflow: hidden; }
.runner-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.runner-head h3 { margin: 0 0 .3rem; }
.runner-head p { margin: 0; color: var(--muted); font-size: .75rem; }
.runner-editors { display: grid; grid-template-columns: 1fr 1fr; }
.runner-editors label, .editor-grid > label { display: grid; gap: .4rem; padding: 1rem; color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.runner-editors label + label { border-left: 1px solid var(--line); }
.runner-editors textarea, .editor-grid textarea {
  width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 8px; background: #fffdf7;
  color: var(--ink); padding: .75rem; line-height: 1.5; font-size: .78rem; text-transform: none; letter-spacing: 0; font-weight: 400;
}
.runner-output { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.runner-output > div { min-width: 0; padding: 1rem; }
.runner-output > div + div { border-left: 1px solid var(--line); }
.runner-output span, .result-panel > span { color: var(--muted); font-size: .68rem; text-transform: uppercase; font-weight: 800; letter-spacing: .08em; }
.runner-output pre { margin: .55rem 0 0; min-height: 3rem; font-size: .76rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.runner-actions { display: flex; gap: .55rem; align-items: center; padding: .8rem 1rem; background: var(--paper-deep); }
.runner-actions output { margin-left: auto; font-size: .75rem; font-weight: 700; }
.runner-card[data-state="success"] .runner-actions output { color: #196448; }
.runner-card[data-state="error"] .runner-actions output { color: #a33324; }

.playground { margin-top: 2rem; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fbf8f0; }
.playground-toolbar { display: flex; align-items: center; gap: .8rem; padding: 1rem; border-bottom: 1px solid var(--line); }
.playground-toolbar label { font-size: .8rem; font-weight: 700; }
.editor-grid { display: grid; grid-template-columns: repeat(3,1fr); }
.editor-grid > label + label { border-left: 1px solid var(--line); }
.result-panel { grid-column: 1 / -1; background: var(--code); color: #eaf3e2; padding: 1rem; }
.result-panel pre { min-height: 5rem; white-space: pre-wrap; }
.run-row { display: flex; align-items: center; gap: .75rem; padding: 1rem; }
.run-row output { margin-left: auto; font-size: .8rem; font-weight: 700; }
.evidence-scale { padding: 1rem 0 3rem; }
.evidence-scale > div { display: grid; grid-template-columns: 100px 1fr; align-items: start; gap: 1rem; border-top: 1px solid var(--line); padding: 1rem 0; }
.evidence-scale p { margin: 0; color: var(--muted); }
.core-intro {
  display: grid; grid-template-columns: .8fr 1.2fr; gap: 4rem; padding: 4rem 0;
  border-bottom: 1px solid var(--line);
}
.core-intro h2 { margin-top: .8rem; }
.core-intro p { color: var(--muted); max-width: 68ch; }
.core-showcase, .core-browser { padding: 4rem 0; }
.core-showcase { border-bottom: 1px solid var(--line); }
.core-showcase > h2, .core-browser > h2 { margin: .6rem 0 2rem; }
.core-declarations { border-top: 1px solid var(--line); }
.core-declaration { border-bottom: 1px solid var(--line); }
.core-declaration summary {
  display: flex; justify-content: space-between; gap: 1rem; align-items: center;
  padding: 1rem .25rem; cursor: pointer;
}
.core-declaration summary::marker { color: var(--coral); }
.core-declaration summary span:first-child { display: grid; gap: .15rem; }
.core-declaration summary strong { font: 700 .9rem "Cascadia Code", monospace; }
.core-declaration summary small { color: var(--muted); font-size: .78rem; }
.core-dependency-count {
  flex: none; color: var(--muted); font-size: .7rem; text-transform: uppercase;
  letter-spacing: .06em;
}
.core-declaration-body { padding: 0 1.2rem 1.5rem; }
.core-declaration-body p { color: var(--muted); font-size: .8rem; }
.core-declaration-body pre {
  max-height: 30rem; padding: 1rem; color: #eaf3e2; background: var(--code);
  border-radius: 12px; font-size: .74rem; line-height: 1.5;
}
.search-box { min-height: 300px; padding: 1rem 0 4rem; }
.not-found { padding: 8rem 0; }
.not-found h1 { font-size: clamp(2.5rem, 6vw, 5.5rem); }
.error-code { color: var(--coral); font: 800 clamp(5rem,15vw,12rem)/.8 "Cascadia Code", monospace; opacity: .35; }

@media (max-width: 980px) {
  .site-frame { grid-template-columns: 230px minmax(0,1fr); }
  .sidebar { padding: 1.7rem 1.2rem; }
  .document > section, .document > header, .document > article, .document > div, .document > nav, .document > aside, .document footer { width: min(100% - 3rem, 900px); }
  .example-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .callout, .section-grid { gap: 2rem; }
}

@media (max-width: 720px) {
  .mobile-header {
    display: flex; position: sticky; top: 0; z-index: 50; height: 60px; padding: 0 1rem;
    align-items: center; justify-content: space-between; background: var(--green); color: white;
  }
  .mobile-brand { display: block; width: 6.8rem; }
  .mobile-brand img { display: block; width: 100%; height: auto; padding: .15rem; background: #fff; border-radius: .2rem; }
  .nav-toggle { color: white; border: 1px solid rgba(255,255,255,.35); background: transparent; border-radius: 999px; padding: .35rem .75rem; }
  .site-frame { display: block; }
  .sidebar {
    position: fixed; z-index: 40; top: 60px; left: 0; right: 0; width: 100%; height: calc(100vh - 60px);
    transform: translateX(-102%); transition: transform .2s ease;
  }
  body.nav-open { overflow: hidden; }
  body.nav-open .sidebar { transform: translateX(0); }
  .brand, .tagline { display: none; }
  .document > section, .document > header, .document > article, .document > div, .document > nav, .document > aside, .document footer { width: calc(100% - 2rem); }
  .hero { min-height: auto; padding: 4rem 0; }
  .hero::after { width: 80px; height: 80px; top: 2rem; right: 0; }
  h1 { font-size: clamp(2.8rem, 14vw, 4.3rem); }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats div:nth-child(2) { border-right: 0; }
  .stats div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .section-grid, .callout, .why-next { grid-template-columns: 1fr; padding: 4rem 0; }
  .essay-toc ol { grid-template-columns: 1fr; }
  .core-intro { grid-template-columns: 1fr; gap: 1rem; }
  .core-declaration summary { align-items: start; }
  .chapter-grid, .example-grid { grid-template-columns: 1fr; }
  .page-header { padding-top: 4rem; }
  .runner-editors, .runner-output, .editor-grid { grid-template-columns: 1fr; }
  .runner-editors label + label, .runner-output > div + div, .editor-grid > label + label { border-left: 0; border-top: 1px solid var(--line); }
  .result-panel { grid-column: 1; }
  .playground-toolbar { align-items: stretch; flex-direction: column; }
  .playground-toolbar select { max-width: none; }
  .run-row { flex-wrap: wrap; }
  .run-row output { width: 100%; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
