/* ================================================================
   Font Faces
   ================================================================ */

@font-face {
  font-family: 'iA Writer Quattro';
  src: url('/fonts/iAWriterQuattroS-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'iA Writer Quattro';
  src: url('/fonts/iAWriterQuattroS-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'iA Writer Quattro';
  src: url('/fonts/iAWriterQuattroS-Italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'iA Writer Quattro';
  src: url('/fonts/iAWriterQuattroS-BoldItalic.woff2') format('woff2');
  font-weight: 700; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'iA Writer Duo';
  src: url('/fonts/iAWriterDuoS-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'iA Writer Duo';
  src: url('/fonts/iAWriterDuoS-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'iA Writer Mono';
  src: url('/fonts/iAWriterMonoS-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'iA Writer Mono';
  src: url('/fonts/iAWriterMonoS-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Fira Code';
  src: url('/fonts/FiraCode-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

/* ================================================================
   Mashin Design System Tokens
   ================================================================ */

:root {
  /* mashin:tokens:landing-base:start (generated by `mix mashin.gen.css_tokens`; edit specs/design-tokens.json, not here; GAP-7871) */
  /* Typography */
  --m-font-prose: "iA Writer Quattro", Georgia, serif;
  --m-font-code: "iA Writer Mono", "SF Mono", "Fira Code", monospace;
  --m-font-ui: "iA Writer Duo", "SF Mono", monospace;

  /* Font sizes (14px base, scaled up for marketing) */
  --m-text-xs: 12px;
  --m-text-sm: 14px;
  --m-text-base: 16px;
  --m-text-lg: 20px;
  --m-text-xl: 28px;
  --m-text-2xl: 40px;
  --m-text-3xl: 56px;
  --m-text-4xl: 72px;

  /* Line heights */
  --m-leading-compact: 1.0;
  --m-leading-tight: 1.15;
  --m-leading-code: 1.5;
  --m-leading-body: 1.6;
  /* iA Writer family (Quattro/Duo/Mono share one vertical metrics table) natural
     leading floor: (hhea ascender 1025 - descender -275 + line gap 0) / unitsPerEm
     1000 = 1.3, measured with fontTools against the files in
     apps/mashin_web/priv/static/fonts. Line gap is 0, so nothing below this ratio
     is safe: ascenders/descenders clip. design-direction:10, design doc 2026-08-22
     section 5a. */
  --m-leading-ia-metric: 1.3;

  /* Letter-spacing (tracking). iA Writer has no optical-size axis (no `fvar` table,
     every cut is static, skeleton cut for body-text sizes), so display sizes show
     enlarged joins unless compensated in CSS. design doc 2026-08-22 sections 1a/5b. */
  --m-tracking-display: -0.025em;
  --m-tracking-body: 0;

  /* Spacing (8px grid) */
  --m-space-1: 8px;
  --m-space-2: 16px;
  --m-space-3: 24px;
  --m-space-4: 32px;
  --m-space-5: 40px;
  --m-space-6: 48px;
  --m-space-8: 64px;
  --m-space-12: 96px;
  --m-space-16: 128px;

  /* Borders */
  --m-radius-sm: 4px;
  --m-radius-md: 6px;
  --m-radius-lg: 8px;

  /* Motion */
  --m-transition-fast: 150ms ease-out;

  /* Shadows */
  --m-shadow-subtle: 0 2px 8px rgba(0, 0, 0, 0.06);
  /* mashin:tokens:landing-base:end */

  /* Colors: the app shell's own palette (m-base by day, m-dark by night), mirrored. */
  /* mashin:tokens:landing-palette-day:start (generated by `mix mashin.gen.css_tokens`; edit specs/design-tokens.json, not here; GAP-7871) */
  --m-bg: #ffffff;
  --m-surface: #eef6f1;
  --m-muted: #eef6f1;
  --m-text: #111314;
  --m-text-secondary: #5C5C5C;
  --m-text-tertiary: #6F6F6F;
  --m-border: #E8E8E8;
  /* mashin:tokens:landing-palette-day:end */
  /* mashin:tokens:landing-day:start (generated by `mix mashin.gen.css_tokens`; edit specs/design-tokens.json, not here; GAP-7871) */
  /* Roles the landing pages name. The accent these pages used was the brand's (the red, before
     brand-green:1), so it follows the brand: the green for marks and lines, its day text shade
     (4.5:1 on both day grounds) for words and fills; failure and error words are Karat refused. */
  --m-bg-secondary: var(--m-muted);
  --m-brand: #00978d;
  --m-brand-text: #007e75;
  --m-brand-text-hover: #005d56;
  --m-brand-fill: #007e75;
  --m-brand-fill-hover: #005d56;
  --m-brand-wash: rgba(0, 151, 141, 0.1);
  --m-refused: #cc1236;
  --m-refused-text: #cc1236;
  /* mashin:tokens:landing-day:end */
}

[data-theme="dark"] {
  /* mashin:tokens:landing-palette-night:start (generated by `mix mashin.gen.css_tokens`; edit specs/design-tokens.json, not here; GAP-7871) */
  --m-bg: #1A1A1E;
  --m-surface: #242428;
  --m-muted: #2E2E32;
  --m-text: #F0F0EC;
  --m-text-secondary: #A9A9A5;
  --m-text-tertiary: #969691;
  --m-border: #3A3A3E;
  /* mashin:tokens:landing-palette-night:end */
  /* mashin:tokens:landing-night:start (generated by `mix mashin.gen.css_tokens`; edit specs/design-tokens.json, not here; GAP-7871) */
  --m-brand: #00978d;
  --m-brand-text: #55cabf;
  --m-brand-text-hover: #28a79d;
  --m-brand-wash: rgba(0, 151, 141, 0.15);
  --m-refused: #e2625e;
  --m-refused-text: #b6bfc1;
  --m-shadow-subtle: 0 2px 8px rgba(0, 0, 0, 0.3);
  /* mashin:tokens:landing-night:end */
}

/* ================================================================
   Reset & Base
   ================================================================ */

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--m-font-prose);
  font-size: var(--m-text-base);
  line-height: var(--m-leading-body);
  color: var(--m-text);
  background-color: var(--m-bg);
  transition: background-color var(--m-transition-fast), color var(--m-transition-fast);
}

a {
  color: var(--m-brand-text);
  text-decoration: none;
  transition: color var(--m-transition-fast);
}

a:hover {
  color: var(--m-brand-text-hover);
}

code {
  font-family: var(--m-font-code);
  font-size: 0.9em;
  background: var(--m-muted);
  padding: 2px 6px;
  border-radius: var(--m-radius-sm);
}

/* ================================================================
   Layout
   ================================================================ */

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--m-space-4);
}

.container--narrow {
  max-width: 800px;
}

.section {
  padding: var(--m-space-12) 0;
}

.section--surface {
  background: var(--m-surface);
}

/* ================================================================
   Navigation
   ================================================================ */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  border-bottom: 1px solid var(--m-border);
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--m-bg) 85%, transparent);
}

.nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav__logo {
  display: flex;
  align-items: center;
  gap: var(--m-space-1);
  font-family: var(--m-font-ui);
  font-size: var(--m-text-lg);
  color: var(--m-text);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.nav__logo:hover {
  color: var(--m-text);
}

.nav__logo-symbol {
  display: flex;
  align-items: center;
  font-family: 'Fira Code', monospace;
  color: var(--m-brand);
  font-size: 18px;
  letter-spacing: -0.02em;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: var(--m-space-4);
  list-style: none;
}

.nav__link {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-sm);
  color: var(--m-text-secondary);
  text-decoration: none;
  transition: color var(--m-transition-fast);
}

.nav__link:hover {
  color: var(--m-text);
}

.nav__theme-toggle {
  background: none;
  border: 1px solid var(--m-border);
  border-radius: var(--m-radius-md);
  padding: 6px 10px;
  cursor: pointer;
  color: var(--m-text-secondary);
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  transition: all var(--m-transition-fast);
}

.nav__theme-toggle:hover {
  border-color: var(--m-text-tertiary);
  color: var(--m-text);
}

.nav__hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-direction: column;
  gap: 4px;
}

.nav__hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--m-text);
  border-radius: 1px;
  transition: all var(--m-transition-fast);
}

/* ================================================================
   Hero
   ================================================================ */

.hero {
  padding-top: calc(56px + var(--m-space-16));
  padding-bottom: var(--m-space-12);
  text-align: center;
}

.hero__tag {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  color: var(--m-brand-text);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: var(--m-space-3);
}

.hero__headline {
  font-family: var(--m-font-prose);
  font-size: var(--m-text-3xl);
  font-weight: 700;
  line-height: var(--m-leading-tight);
  letter-spacing: -0.03em;
  max-width: 800px;
  margin: 0 auto var(--m-space-4);
}

.hero__subheadline {
  font-size: var(--m-text-lg);
  color: var(--m-text-secondary);
  line-height: var(--m-leading-body);
  max-width: 640px;
  margin: 0 auto var(--m-space-6);
}

.hero__actions {
  display: flex;
  gap: var(--m-space-2);
  justify-content: center;
  flex-wrap: wrap;
}

/* ================================================================
   Buttons
   ================================================================ */

.btn {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-sm);
  padding: 12px 28px;
  border-radius: var(--m-radius-md);
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all var(--m-transition-fast);
}

.btn--primary {
  background: var(--m-brand-fill);
  color: #FFFFFF;
}

.btn--primary:hover {
  background: var(--m-brand-fill-hover);
  color: #FFFFFF;
}

.btn--secondary {
  background: transparent;
  color: var(--m-text);
  border: 1px solid var(--m-border);
}

.btn--secondary:hover {
  background: var(--m-surface);
  border-color: var(--m-text-tertiary);
}

/* ================================================================
   Paradigm Contrast
   ================================================================ */

.paradigm {
  text-align: center;
}

.paradigm__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--m-space-4);
  max-width: 800px;
  margin: var(--m-space-6) auto 0;
}

.paradigm__card {
  padding: var(--m-space-4);
  border: 1px solid var(--m-border);
  border-radius: var(--m-radius-lg);
  text-align: left;
}

.paradigm__card--old {
  opacity: 0.6;
}

.paradigm__card--new {
  border-color: var(--m-brand);
  background: var(--m-brand-wash);
}

.paradigm__card-label {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--m-text-tertiary);
  margin-bottom: var(--m-space-2);
}

.paradigm__card--new .paradigm__card-label {
  color: var(--m-brand-text);
}

.paradigm__card-text {
  font-size: var(--m-text-base);
  line-height: var(--m-leading-body);
}

/* ================================================================
   Section Headers
   ================================================================ */

.section__tag {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--m-brand-text);
  margin-bottom: var(--m-space-2);
}

.section__title {
  font-size: var(--m-text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: var(--m-leading-tight);
  margin-bottom: var(--m-space-2);
}

.section__subtitle {
  font-size: var(--m-text-lg);
  color: var(--m-text-secondary);
  max-width: 640px;
}

.section--center {
  text-align: center;
}

.section--center .section__subtitle {
  margin: 0 auto;
}

/* ================================================================
   Pillars
   ================================================================ */

.pillars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--m-space-4);
  margin-top: var(--m-space-8);
}

.pillar {
  padding: var(--m-space-4);
  border: 1px solid var(--m-border);
  border-radius: var(--m-radius-lg);
  transition: border-color var(--m-transition-fast);
}

.pillar:hover {
  border-color: var(--m-text-tertiary);
}

.pillar__number {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  color: var(--m-brand-text);
  margin-bottom: var(--m-space-2);
}

.pillar__title {
  font-size: var(--m-text-lg);
  font-weight: 600;
  margin-bottom: var(--m-space-1);
  letter-spacing: -0.01em;
}

.pillar__text {
  font-size: var(--m-text-sm);
  color: var(--m-text-secondary);
  line-height: var(--m-leading-body);
}

/* ================================================================
   One-Line Test
   ================================================================ */

.one-line-test__content {
  max-width: 800px;
  margin: 0 auto;
}

.one-line-test__description {
  font-size: var(--m-text-lg);
  color: var(--m-text-secondary);
  margin-bottom: var(--m-space-6);
  max-width: 640px;
}

.code-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--m-space-3);
}

.code-block {
  background: var(--m-surface);
  border: 1px solid var(--m-border);
  border-radius: var(--m-radius-lg);
  overflow: hidden;
}

.code-block__header {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  padding: var(--m-space-1) var(--m-space-2);
  border-bottom: 1px solid var(--m-border);
  color: var(--m-text-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.code-block__header-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.code-block--fail .code-block__header-dot {
  background: var(--m-refused);
}

.code-block--pass .code-block__header-dot {
  background: #27AE60;
}

[data-theme="dark"] .code-block--pass .code-block__header-dot {
  background: #6BCB77;
}

.code-block__body {
  padding: var(--m-space-2);
  font-family: var(--m-font-code);
  font-size: var(--m-text-sm);
  line-height: var(--m-leading-code);
  overflow-x: auto;
}

.code-block__body pre {
  margin: 0;
}

.code-comment { color: var(--m-text-tertiary); }
.code-string { color: #27AE60; }
[data-theme="dark"] .code-string { color: #6BCB77; }
.code-keyword { color: var(--m-brand-text); }
.code-fn { color: #2D9CDB; }
[data-theme="dark"] .code-fn { color: #74B9FF; }

.code-verdict {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  padding: var(--m-space-1) var(--m-space-2);
  border-top: 1px solid var(--m-border);
  color: var(--m-text-tertiary);
}

.code-block--fail .code-verdict { color: var(--m-refused-text); }
.code-block--pass .code-verdict { color: #27AE60; }
[data-theme="dark"] .code-block--pass .code-verdict { color: #6BCB77; }

/* ================================================================
   Stats
   ================================================================ */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--m-space-4);
  margin-top: var(--m-space-8);
}

.stat { text-align: center; }

.stat__number {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-2xl);
  font-weight: 700;
  color: var(--m-text);
  letter-spacing: -0.03em;
}

.stat__label {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  color: var(--m-text-tertiary);
  margin-top: 4px;
}

/* ================================================================
   Progression
   ================================================================ */

.progression {
  margin-top: var(--m-space-8);
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

.progression__item {
  display: flex;
  align-items: center;
  gap: var(--m-space-3);
  padding: var(--m-space-2) 0;
  border-bottom: 1px solid var(--m-border);
}

.progression__item:last-child { border-bottom: none; }

.progression__layer {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-sm);
  font-weight: 600;
  min-width: 200px;
}

.progression__absorbed {
  font-size: var(--m-text-sm);
  color: var(--m-text-secondary);
}

.progression__item--current .progression__layer { color: var(--m-brand-text); }

.progression__item--current {
  background: var(--m-brand-wash);
  margin: 0 calc(-1 * var(--m-space-2));
  padding: var(--m-space-2);
  border-radius: var(--m-radius-md);
  border-bottom: none;
}

/* ================================================================
   Audience Cards
   ================================================================ */

.audience-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--m-space-4);
  margin-top: var(--m-space-8);
}

.audience-card {
  padding: var(--m-space-5);
  border: 1px solid var(--m-border);
  border-radius: var(--m-radius-lg);
}

.audience-card__label {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--m-brand-text);
  margin-bottom: var(--m-space-2);
}

.audience-card__headline {
  font-size: var(--m-text-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: var(--m-leading-tight);
  margin-bottom: var(--m-space-2);
}

.audience-card__text {
  font-size: var(--m-text-sm);
  color: var(--m-text-secondary);
  line-height: var(--m-leading-body);
}

/* ================================================================
   Research Papers
   ================================================================ */

.research-grid {
  display: grid;
  gap: var(--m-space-3);
  margin-top: var(--m-space-6);
}

.research-card {
  padding: var(--m-space-4);
  border: 1px solid var(--m-border);
  border-radius: var(--m-radius-lg);
  transition: border-color var(--m-transition-fast);
}

.research-card:hover {
  border-color: var(--m-text-tertiary);
}

.research-card__id {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  color: var(--m-brand-text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--m-space-1);
}

.research-card__title {
  font-size: var(--m-text-base);
  font-weight: 600;
  margin-bottom: var(--m-space-1);
  line-height: var(--m-leading-tight);
}

.research-card__title a {
  color: var(--m-text);
  text-decoration: none;
}

.research-card__title a:hover {
  color: var(--m-brand-text);
}

.research-card__meta {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  color: var(--m-text-tertiary);
  margin-bottom: var(--m-space-1);
}

.research-card__abstract {
  font-size: var(--m-text-sm);
  color: var(--m-text-secondary);
  line-height: var(--m-leading-body);
}

/* ================================================================
   Comparison Table
   ================================================================ */

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--m-space-6);
  font-size: var(--m-text-sm);
}

.comparison-table th,
.comparison-table td {
  text-align: left;
  padding: var(--m-space-1) var(--m-space-2);
  border-bottom: 1px solid var(--m-border);
}

.comparison-table th {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--m-text-tertiary);
  font-weight: 500;
}

.comparison-table td:first-child { color: var(--m-text-secondary); }
.comparison-table td:last-child { font-weight: 600; color: var(--m-brand-text); }
.comparison-table .advisory { color: var(--m-text-tertiary); font-weight: 400; }

/* ================================================================
   CTA Section
   ================================================================ */

.cta-section {
  text-align: center;
  padding: var(--m-space-16) 0;
}

.cta-section__title {
  font-size: var(--m-text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--m-space-2);
}

.cta-section__subtitle {
  font-size: var(--m-text-lg);
  color: var(--m-text-secondary);
  margin-bottom: var(--m-space-5);
}

/* ================================================================
   Newsletter Form
   ================================================================ */

.newsletter-form {
  display: flex;
  gap: var(--m-space-1);
  max-width: 440px;
  margin: var(--m-space-4) auto 0;
}

.newsletter-form__input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--m-border);
  border-radius: var(--m-radius-md);
  background: var(--m-bg);
  color: var(--m-text);
  font-family: var(--m-font-ui);
  font-size: var(--m-text-sm);
  outline: none;
  transition: border-color var(--m-transition-fast);
}

.newsletter-form__input:focus {
  border-color: var(--m-brand);
}

.newsletter-form__input::placeholder {
  color: var(--m-text-tertiary);
}

.newsletter-form__status {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  margin-top: var(--m-space-1);
  text-align: center;
}

.newsletter-form__status--success { color: #27AE60; }
.newsletter-form__status--error { color: var(--m-refused-text); }

/* ================================================================
   Footer
   ================================================================ */

.footer {
  border-top: 1px solid var(--m-border);
  padding: var(--m-space-6) 0;
}

.footer__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer__left {
  display: flex;
  align-items: center;
  gap: var(--m-space-1);
  font-family: var(--m-font-ui);
  font-size: var(--m-text-sm);
  color: var(--m-text-secondary);
}

.footer__left-symbol {
  color: var(--m-brand);
  font-family: 'Fira Code', monospace;
  font-size: 14px;
}

.footer__links {
  display: flex;
  gap: var(--m-space-3);
  list-style: none;
}

.footer__link {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  color: var(--m-text-tertiary);
  text-decoration: none;
}

/* ── Prose (blog articles) ──────────────────────────────── */

/* Prose uses !important to override app.css cascade */
.prose {
  font-family: 'iA Writer Quattro', Georgia, serif !important;
  font-size: 18px !important;
  line-height: 1.5 !important;
  color: var(--m-text);
}

.prose p {
  margin-top: 0;
  margin-bottom: 1.4em;
}

.prose h2 {
  font-family: 'iA Writer Quattro', Georgia, serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 2.5em;
  margin-bottom: 0.6em;
  line-height: 1.3;
  color: var(--m-text);
}

.prose h3 {
  font-family: 'iA Writer Quattro', Georgia, serif;
  font-size: 21px;
  font-weight: 700;
  margin-top: 2em;
  margin-bottom: 0.5em;
  line-height: 1.4;
  color: var(--m-text);
}

.prose h4 {
  font-family: 'iA Writer Quattro', Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  margin-top: 1.5em;
  margin-bottom: 0.4em;
}

.prose strong {
  font-weight: 700;
  color: var(--m-text);
}

.prose em {
  font-style: italic;
}

.prose a {
  color: var(--m-brand-text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.prose a:hover {
  color: var(--m-brand-text-hover);
}

.prose blockquote {
  border-left: 3px solid var(--m-brand);
  padding-left: 1.25em;
  margin: 1.5em 0;
  color: var(--m-text-secondary);
  font-style: italic;
}

.prose ul, .prose ol {
  margin-top: 0;
  margin-bottom: 1.4em;
  padding-left: 1.75em;
}

.prose li {
  margin-bottom: 0.4em;
  line-height: 1.7;
}

.prose code {
  font-family: 'Fira Code', 'iA Writer Mono', monospace;
  font-size: 0.85em;
  background: var(--m-bg-secondary);
  padding: 0.2em 0.45em;
  border-radius: 4px;
  word-break: break-word;
}

.prose pre {
  font-family: 'Fira Code', 'iA Writer Mono', monospace;
  font-size: 14px;
  line-height: 1.65;
  background: var(--m-bg-secondary);
  border: 1px solid var(--m-border);
  border-radius: 8px;
  padding: 1.25em 1.5em;
  margin: 1.75em 0;
  overflow-x: auto;
  white-space: pre;
}

.prose pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  border-radius: 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.75em 0;
  font-size: 15px;
  line-height: 1.5;
}

.prose th, .prose td {
  border: 1px solid var(--m-border);
  padding: 0.65em 1em;
  text-align: left;
}

.prose th {
  font-weight: 700;
  background: var(--m-bg-secondary);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--m-border);
  margin: 3em 0;
}

.prose img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1.75em 0;
}

.prose > *:first-child {
  margin-top: 0;
}

.prose > *:last-child {
  margin-bottom: 0;
}

.footer__link:hover { color: var(--m-text); }

/* ================================================================
   Treatise
   ================================================================ */

/* Hero */
.treatise-hero {
  padding-top: calc(56px + var(--m-space-12));
  padding-bottom: var(--m-space-8);
  text-align: center;
  border-bottom: 1px solid var(--m-border);
}

.treatise-hero__tag {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  color: var(--m-brand-text);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: var(--m-space-3);
}

.treatise-hero__title {
  font-family: var(--m-font-prose);
  font-size: var(--m-text-2xl);
  font-weight: 700;
  line-height: var(--m-leading-tight);
  letter-spacing: -0.03em;
  margin-bottom: var(--m-space-2);
  color: var(--m-text);
}

.treatise-hero__author {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-base);
  color: var(--m-text-secondary);
  margin-bottom: var(--m-space-3);
  letter-spacing: 0.02em;
}

.treatise-hero__description {
  font-size: var(--m-text-lg, 1.125rem);
  color: var(--m-text-secondary);
  line-height: var(--m-leading-body);
  max-width: 640px;
  margin: 0 auto var(--m-space-2);
}

.treatise-hero__stats {
  font-family: 'Fira Code', 'JetBrains Mono', monospace;
  font-size: var(--m-text-xs, 0.75rem);
  color: var(--m-text-tertiary);
  letter-spacing: 0.02em;
  margin: 0 auto var(--m-space-6);
}

/* Entry point cards */
.treatise-hero__entries {
  display: flex;
  gap: var(--m-space-2);
  justify-content: center;
  flex-wrap: wrap;
  max-width: 720px;
  margin: 0 auto;
}

.treatise-entry {
  flex: 1 1 200px;
  max-width: 240px;
  padding: var(--m-space-3);
  border: 1px solid var(--m-border);
  border-radius: var(--m-radius-md);
  text-align: left;
  display: flex;
  flex-direction: column;
  transition: border-color var(--m-transition-fast), background var(--m-transition-fast);
}

.treatise-entry:hover {
  border-color: var(--m-brand);
  background: var(--m-brand-wash);
}

.treatise-entry__link {
  text-decoration: none;
  flex: 1;
}

.treatise-entry__label {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-sm);
  font-weight: 600;
  color: var(--m-text);
  margin-bottom: 4px;
}

.treatise-entry:hover .treatise-entry__label {
  color: var(--m-brand-text);
}

.treatise-entry__desc {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  color: var(--m-text-tertiary);
  line-height: 1.4;
}

.treatise-entry__download {
  display: inline-block;
  margin-top: var(--m-space-2);
  font-family: var(--m-font-code);
  font-size: var(--m-text-xs);
  color: var(--m-text-tertiary);
  text-decoration: none;
}

.treatise-entry__download:hover {
  color: var(--m-brand-text);
}

/* Layout: sidebar + content */
.treatise-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: var(--m-space-8);
  padding-top: var(--m-space-6);
  padding-bottom: var(--m-space-12);
  max-width: 1120px;
}

/* Sidebar */
.treatise-sidebar {
  position: relative;
}

.treatise-sidebar__toggle {
  display: none;
}

.treatise-toc {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: var(--m-space-2);
  scrollbar-width: thin;
  scrollbar-color: var(--m-border) transparent;
}

.treatise-toc::-webkit-scrollbar {
  width: 4px;
}

.treatise-toc::-webkit-scrollbar-track {
  background: transparent;
}

.treatise-toc::-webkit-scrollbar-thumb {
  background: var(--m-border);
  border-radius: 2px;
}

.treatise-toc__part {
  margin-bottom: var(--m-space-2);
}

.treatise-toc__part-link {
  display: block;
  font-family: var(--m-font-ui);
  font-size: var(--m-text-sm);
  font-weight: 600;
  color: var(--m-text);
  text-decoration: none;
  padding: 4px 0;
  transition: color var(--m-transition-fast);
  border-left: 2px solid transparent;
  padding-left: var(--m-space-2);
}

.treatise-toc__part-link:hover {
  color: var(--m-brand-text);
}

.treatise-toc__chapters {
  list-style: none;
  margin: 2px 0 0 0;
  padding: 0;
}

.treatise-toc__chapter-link {
  display: block;
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  color: var(--m-text-tertiary);
  text-decoration: none;
  padding: 3px 0 3px var(--m-space-3);
  border-left: 2px solid transparent;
  transition: color var(--m-transition-fast), border-color var(--m-transition-fast);
  line-height: 1.4;
}

.treatise-toc__chapter-link:hover {
  color: var(--m-text);
}

/* Active TOC item */
.treatise-toc--active {
  color: var(--m-brand-text) !important;
  border-left-color: var(--m-brand) !important;
}

/* Content */
.treatise-content {
  max-width: 720px;
  min-width: 0;
}

.treatise-content .prose h1 {
  font-family: var(--m-font-prose);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-top: 0;
  margin-bottom: 0.8em;
  line-height: 1.2;
  color: var(--m-text);
}

.treatise-content .prose h2 {
  scroll-margin-top: 80px;
}

.treatise-content .prose h3 {
  scroll-margin-top: 80px;
}

/* Part dividers */
.treatise-divider {
  text-align: center;
  padding: var(--m-space-8) 0;
}

.treatise-divider__ornament {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-sm);
  color: var(--m-text-tertiary);
  letter-spacing: 0.4em;
}

/* Back to top */
.treatise-part__back {
  margin-top: var(--m-space-6);
  padding-top: var(--m-space-3);
  border-top: 1px solid var(--m-border);
}

.treatise-back-link {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  color: var(--m-text-tertiary);
  text-decoration: none;
  transition: color var(--m-transition-fast);
}

.treatise-back-link:hover {
  color: var(--m-brand-text);
}

/* Diagrams */
.treatise-diagrams {
  display: flex;
  gap: var(--m-space-4);
  justify-content: center;
  flex-wrap: wrap;
  margin: var(--m-space-6) 0;
  padding: var(--m-space-4) 0;
  border-top: 1px solid var(--m-border);
  border-bottom: 1px solid var(--m-border);
}

.treatise-figure {
  flex: 1 1 300px;
  max-width: 480px;
  text-align: center;
}

.treatise-figure__img {
  width: 100%;
  height: auto;
  border-radius: var(--m-radius-md);
}

.treatise-figure__caption {
  margin-top: var(--m-space-2);
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  color: var(--m-text-tertiary);
  font-style: italic;
}

/* Treatise-specific prose overrides */
.treatise-content .prose blockquote {
  border-left: 3px solid var(--m-brand);
  padding: var(--m-space-2) var(--m-space-3);
  margin: 1.75em 0;
  background: var(--m-surface);
  border-radius: 0 var(--m-radius-md) var(--m-radius-md) 0;
  color: var(--m-text-secondary);
  font-style: italic;
}

.treatise-content .prose blockquote p:last-child {
  margin-bottom: 0;
}

.treatise-content .prose pre {
  font-family: 'Fira Code', var(--m-font-code);
}

.treatise-content .prose pre code {
  font-family: 'Fira Code', var(--m-font-code);
}

/* Treatise tables */
.treatise-content .prose table {
  font-size: 14px;
}

.treatise-content .prose th {
  font-family: var(--m-font-ui);
  white-space: nowrap;
}

/* Research page treatise card */
.research-treatise-card {
  padding: var(--m-space-5);
  border: 2px solid var(--m-brand);
  border-radius: var(--m-radius-lg);
  margin-bottom: var(--m-space-6);
  background: var(--m-brand-wash);
  transition: background var(--m-transition-fast);
}

.research-treatise-card:hover {
  background: var(--m-surface);
}

.research-treatise-card__tag {
  font-family: var(--m-font-ui);
  font-size: var(--m-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--m-brand-text);
  margin-bottom: var(--m-space-1);
}

.research-treatise-card__title {
  font-size: var(--m-text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: var(--m-leading-tight);
  margin-bottom: var(--m-space-1);
}

.research-treatise-card__title a {
  color: var(--m-text);
  text-decoration: none;
}

.research-treatise-card__title a:hover {
  color: var(--m-brand-text);
}

.research-treatise-card__desc {
  font-size: var(--m-text-sm);
  color: var(--m-text-secondary);
  line-height: var(--m-leading-body);
  max-width: 640px;
}

.research-treatise-card__link {
  display: inline-block;
  margin-top: var(--m-space-2);
  font-family: var(--m-font-ui);
  font-size: var(--m-text-sm);
  font-weight: 600;
  color: var(--m-brand-text);
  text-decoration: none;
}

.research-treatise-card__link:hover {
  text-decoration: underline;
}

/* ================================================================
   Responsive
   ================================================================ */

@media (max-width: 768px) {
  .hero__headline { font-size: var(--m-text-2xl); }
  .hero__subheadline { font-size: var(--m-text-base); }
  .pillars { grid-template-columns: 1fr; }
  .code-comparison { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .audience-grid { grid-template-columns: 1fr; }
  .paradigm__grid { grid-template-columns: 1fr; }
  .progression__item {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .nav__hamburger { display: flex; }
  .nav__links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--m-bg);
    border-bottom: 1px solid var(--m-border);
    flex-direction: column;
    padding: var(--m-space-2) var(--m-space-4);
    gap: 0;
  }
  .nav__links--open { display: flex; }
  .nav__links li { padding: var(--m-space-1) 0; }
  .footer__inner {
    flex-direction: column;
    gap: var(--m-space-2);
  }
  .newsletter-form {
    flex-direction: column;
  }
}

/* Treatise responsive: tablet (sidebar collapses) */
@media (max-width: 960px) {
  .treatise-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .treatise-sidebar {
    position: relative;
    border-bottom: 1px solid var(--m-border);
    margin-bottom: var(--m-space-4);
  }

  .treatise-sidebar__toggle {
    display: flex;
    align-items: center;
    gap: var(--m-space-1);
    width: 100%;
    padding: var(--m-space-2) 0;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--m-font-ui);
    font-size: var(--m-text-sm);
    font-weight: 600;
    color: var(--m-text);
  }

  .treatise-sidebar__toggle-icon {
    font-size: 16px;
    color: var(--m-text-tertiary);
  }

  .treatise-toc {
    position: static;
    max-height: none;
    display: none;
    padding-bottom: var(--m-space-3);
  }

  .treatise-sidebar--open .treatise-toc {
    display: block;
  }

  .treatise-content {
    max-width: 100%;
  }
}

/* Treatise responsive: mobile */
@media (max-width: 768px) {
  .treatise-hero__title {
    font-size: var(--m-text-xl);
  }

  .treatise-hero__entries {
    flex-direction: column;
    align-items: center;
  }

  .treatise-entry {
    max-width: 100%;
    width: 100%;
  }

  .treatise-hero {
    padding-top: calc(56px + var(--m-space-8));
    padding-bottom: var(--m-space-6);
  }

  /* A wide table scrolls inside its own box instead of widening the page: the treatise's
     capability table is 704 px and pushed a 500 px page to 736 (GAP-7871). */
  .prose table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
  }
}

/* Print styles */
@media print {
  .treatise-sidebar,
  .nav,
  .footer,
  .treatise-hero__entries,
  .treatise-part__back {
    display: none !important;
  }

  .treatise-layout {
    grid-template-columns: 1fr;
  }

  .treatise-content {
    max-width: 100%;
  }

  .treatise-hero {
    padding-top: var(--m-space-4);
    border-bottom: none;
  }

  .treatise-divider {
    page-break-before: always;
    padding: var(--m-space-4) 0;
  }

  .prose pre {
    white-space: pre-wrap;
    word-wrap: break-word;
  }
}
