:root {
  --hww-paper: #f4ecd8;
  --hww-paper-light: #fbf6ea;
  --hww-ink: #1c1712;
  --hww-muted: #756a57;
  --hww-rule: rgba(28, 23, 18, 0.32);
  --hww-amendment: #d94b2b;
  --hww-evidence: #1e64c8;
  --hww-doctrine: #eca40e;
  --font-display: 'Unbounded', system-ui, sans-serif;
  --font-body: 'Jost', system-ui, sans-serif;
  --font-mono: 'Space Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body.how-we-work-page {
  margin: 0;
  overflow-x: hidden;
  background: var(--hww-paper);
  color: var(--hww-ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body.how-we-work-page::before {
  position: fixed;
  z-index: 1000;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitchTiles'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.32'/%3E%3C/svg%3E");
  content: '';
  mix-blend-mode: multiply;
  opacity: 0.035;
}

.how-we-work-page ::selection { background: var(--hww-amendment); color: #fff; }

.hww-version-bar {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px var(--chrome-x);
  border-bottom: 1px solid var(--hww-ink);
  background: var(--hww-paper);
  font: 700 10px/1.4 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hww-version-bar__current { color: var(--hww-amendment); }

.hww-shell {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  max-width: 1440px;
  margin: 0 auto;
  border-right: 1px solid var(--hww-rule);
  border-left: 1px solid var(--hww-rule);
}

.hww-rail {
  align-self: start;
  position: sticky;
  top: 24px;
  display: flex;
  min-height: calc(100vh - 48px);
  flex-direction: column;
  justify-content: flex-start;
  padding: 40px 24px;
  border-right: 1px solid var(--hww-ink);
  font-family: var(--font-mono);
}

.hww-kicker,
.hww-section-label,
.hww-mobile-toc summary {
  font: 700 11px/1.45 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hww-toc__label {
  margin: 0 0 18px;
  color: var(--hww-muted);
  font: 700 10px/1.4 var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hww-toc {
  display: grid;
  border-bottom: 1px solid var(--hww-rule);
}

.hww-toc a {
  display: flex;
  min-height: 50px;
  align-items: center;
  padding: 13px 14px;
  border-top: 1px solid var(--hww-rule);
  color: var(--hww-muted);
  font-size: 12px;
  line-height: 1.45;
  text-decoration: none;
  transition: background-color 120ms ease-out, color 120ms ease-out;
}

.hww-toc a:hover,
.hww-toc a:focus-visible {
  background: rgba(251, 246, 234, 0.65);
  color: var(--hww-ink);
}

.hww-toc a:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid var(--hww-doctrine);
  outline-offset: -3px;
}

.hww-toc a[aria-current='true'] {
  padding-left: 10px;
  border-left: 4px solid var(--hww-amendment);
  background: var(--hww-paper-light);
  color: var(--hww-ink);
  font-weight: 700;
}

.hww-mobile-toc a[aria-current='true'] {
  color: var(--hww-amendment);
  font-weight: 700;
}

.hww-main { min-width: 0; }

.hww-hero {
  min-height: 780px;
  padding: clamp(48px, 6vw, 80px) clamp(36px, 7vw, 96px) 64px;
  border-bottom: 2px solid var(--hww-ink);
}

.hww-preamble {
  display: flex;
  max-width: 780px;
  gap: 16px;
  margin-bottom: 48px;
  font-size: 17px;
  line-height: 1.6;
}

.hww-preamble::before {
  width: 6px;
  flex: 0 0 6px;
  background: var(--hww-amendment);
  content: '';
}

.hww-preamble p { margin: 0; }

.hww-kicker { margin: 0 0 16px; color: var(--hww-amendment); }

.hww-hero h1 {
  max-width: 850px;
  margin: 0;
  font: 700 clamp(56px, 7vw, 96px)/0.98 var(--font-display);
  letter-spacing: -0.055em;
}

html[data-locale="en"] .hww-hero h1 {
  white-space: nowrap;
}

.hww-hero__thesis {
  display: grid;
  grid-template-columns: minmax(160px, 0.35fr) minmax(0, 0.9fr);
  gap: 40px;
  max-width: 1010px;
  margin-top: 54px;
  padding-top: 30px;
  border-top: 2px solid var(--hww-ink);
}

.hww-section-label { color: var(--hww-muted); }

.hww-hero__thesis strong {
  font-size: clamp(21px, 2vw, 28px);
  line-height: 1.35;
}

.hww-hero__mission {
  display: flex;
  max-width: 1010px;
  align-items: end;
  justify-content: space-between;
  gap: 48px;
  margin-top: 54px;
}

.hww-hero__mission p { max-width: 650px; margin: 0; color: var(--hww-muted); }

.hww-hero__maxim {
  flex: none;
  color: var(--hww-amendment);
  font: 700 13px/1.65 var(--font-mono);
  text-align: right;
}

.hww-mobile-toc { display: none; }

.hww-document {
  padding: 78px clamp(36px, 7vw, 96px) 120px;
}

.hww-document__intro {
  max-width: 760px;
  margin: 0 0 78px;
  padding: 26px 28px;
  border: 1px solid var(--hww-ink);
  background: var(--hww-paper-light);
}

.hww-document__intro p { margin: 0; }

.hww-document__intro ol { margin: 22px 0 0; padding-left: 24px; }

.hww-document__intro li + li { margin-top: 10px; }

.hww-document__intro strong { font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.02em; }

.hww-document__intro > hr { display: none; }

.hww-article {
  max-width: 760px;
  counter-reset: hww-principle;
}

.hww-article h1 { scroll-margin-top: 64px; }

.hww-article h2,
.hww-article h3 { scroll-margin-top: 24px; }

.hww-article h1 {
  margin: 110px 0 24px;
  padding-top: 24px;
  border-top: 3px solid var(--hww-ink);
  font: 700 clamp(32px, 3vw, 44px)/1.08 var(--font-display);
  letter-spacing: -0.045em;
}

.hww-article h1:first-child { margin-top: 0; }

.hww-article h2 {
  margin: 68px 0 18px;
  font: 700 clamp(25px, 2.6vw, 34px)/1.18 var(--font-display);
  letter-spacing: -0.035em;
}

.hww-article h3 {
  margin: 46px 0 14px;
  font: 700 20px/1.3 var(--font-body);
}

.hww-article p { margin: 0 0 1.15em; }

.hww-article > p:first-of-type,
.hww-article h1 + p em { color: var(--hww-muted); }

.hww-article strong { font-weight: 700; }

.hww-article ul,
.hww-article ol { margin: 20px 0 28px; padding-left: 26px; }

.hww-article li { padding-left: 4px; }
.hww-article li + li { margin-top: 9px; }

.hww-article blockquote {
  margin: 48px 0;
  padding: 28px 0 28px 30px;
  border-left: 6px solid var(--hww-amendment);
  color: var(--hww-ink);
  font-size: 23px;
  line-height: 1.45;
}

.hww-article blockquote p { margin: 0; }

.hww-article hr {
  height: 1px;
  margin: 72px 0;
  border: 0;
  background: var(--hww-rule);
}

.hww-article code { font-family: var(--font-mono); }

.hww-article #part-one-the-constitution,
.hww-article #part-two-the-compacts,
.hww-article #part-three-operating-notes,
.hww-article #part-four-doctrine-and-mechanisms,
.hww-article #amendment,
.hww-article #what-makes-this-real { position: relative; }

.hww-article #part-one-the-constitution::before,
.hww-article #part-two-the-compacts::before,
.hww-article #part-three-operating-notes::before,
.hww-article #part-four-doctrine-and-mechanisms::before,
.hww-article #amendment::before,
.hww-article #what-makes-this-real::before {
  position: absolute;
  top: -31px;
  left: 0;
  color: var(--hww-amendment);
  font: 700 10px/1 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hww-article #part-one-the-constitution::before { content: attr(data-layer-label); }
.hww-article #part-two-the-compacts::before { content: attr(data-layer-label); color: var(--hww-evidence); }
.hww-article #part-three-operating-notes::before { content: attr(data-layer-label); color: var(--hww-muted); }
.hww-article #part-four-doctrine-and-mechanisms::before { content: attr(data-layer-label); color: #a96f00; }
.hww-article #amendment::before { content: attr(data-layer-label); }
.hww-article #what-makes-this-real::before { content: attr(data-layer-label); }

.hww-changelog {
  max-width: 760px;
  margin-top: 100px;
  padding-top: 28px;
  border-top: 2px solid var(--hww-ink);
}

.hww-changelog h2 { margin: 0 0 18px; font: 700 24px/1.2 var(--font-display); }
.hww-changelog p { margin: 0; color: var(--hww-muted); }

@media (min-width: 901px) {
  html[data-locale="en"] .hww-article #part-one-the-constitution,
  html[data-locale="en"] .hww-article #part-two-the-compacts,
  html[data-locale="en"] .hww-article #part-three-operating-notes { white-space: nowrap; }

  html[data-locale="en"] .hww-article [id='7-respect-comes-from-judgment-not-title'],
  html[data-locale="en"] .hww-article #one-operating-system-for-humans-and-agents {
    font-size: clamp(20px, 1.875vw, 27px);
    white-space: nowrap;
  }
}

@media (max-width: 900px) {
  .hww-version-bar { padding-inline: 18px; }
  .hww-version-bar span:last-child { display: none; }
  .hww-shell { display: block; border: 0; }
  .hww-rail { display: none; }
  .hww-hero { min-height: 0; padding: 32px 16px 42px; }
  .hww-preamble { margin-bottom: 36px; font-size: 15px; line-height: 1.5; }
  .hww-hero h1 { font-size: clamp(40px, 12vw, 56px); }
  .hww-hero__thesis { grid-template-columns: 1fr; gap: 14px; margin-top: 38px; padding-top: 24px; }
  .hww-hero__thesis strong { font-size: 20px; line-height: 1.4; }
  .hww-hero__mission { display: block; margin-top: 36px; }
  .hww-hero__maxim { margin-top: 30px; text-align: left; }
  .hww-mobile-toc { display: block; margin: 24px 16px 0; border: 1px solid var(--hww-ink); }
  .hww-mobile-toc summary { padding: 16px; cursor: pointer; list-style-position: inside; }
  .hww-mobile-toc nav { display: grid; gap: 0; padding: 0 16px 16px; }
  .hww-mobile-toc a { padding: 11px 0; border-top: 1px solid var(--hww-rule); color: var(--hww-ink); font: 400 12px/1.4 var(--font-mono); text-decoration: none; }
  .hww-document { padding: 42px 16px 80px; }
  .hww-document__intro { margin-bottom: 58px; padding: 20px; }
  .hww-article h1 { margin-top: 82px; font-size: 34px; white-space: normal; }
  .hww-article h2 { margin-top: 52px; font-size: 26px; }
  .hww-article blockquote { padding-left: 20px; font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hww-toc a { transition: none; }
}
