:root {
  --bg: #F8F9FC;
  --white: #FFFFFF;
  --text: #1A1A1A;
  --muted: #5F5F5F;
  --label: #9A9A9A;
  --border: #E5E6EA;
  --border-strong: #D8D9DD;
  --soft: #EFF1F5;
  --soft-2: #E8EAEF;
  --black: #1A1A1A;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  scroll-behavior: smooth;
}

.page {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* Top */
.top {
  padding: 2rem 0 0;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  transition: color 120ms ease;
}
.back:hover { color: var(--text); }

/* Breadcrumb */
.crumbs {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 13.5px;
  font-weight: 500;
}
.crumb {
  color: var(--muted);
  text-decoration: none;
  transition: color 120ms ease;
}
.crumb:hover { color: var(--text); }
.crumb-current { color: var(--text); }
.crumb-sep {
  color: var(--label);
  font-weight: 400;
}

/* Article header */
.article-header {
  padding: 4rem 0 2.5rem;
}

.kicker {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--label);
  font-weight: 500;
  margin-bottom: 1.25rem;
}

.article-header h1 {
  font-size: 44px;
  font-weight: 500;
  letter-spacing: -0.025em;
  margin: 0 0 1rem;
  line-height: 1.1;
}

.lede {
  font-size: 18px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 620px;
  margin: 0 0 2rem;
  letter-spacing: -0.005em;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.meta-pill {
  font-size: 12px;
  padding: 0.35rem 0.7rem;
  background: rgba(26, 26, 26, 0.045);
  border: 1px solid rgba(26, 26, 26, 0.06);
  border-radius: 999px;
  color: var(--text);
  line-height: 1.3;
}
.meta-pill .meta-label {
  color: var(--muted);
  font-weight: 400;
}

/* Hero pipeline (sticky scrubber) */
.hero-pipeline {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(248, 249, 252, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  margin: 0 -2rem;
  padding: 0 2rem;
}

.hero-pipeline-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.1rem 0 0.85rem;
}

.pipeline-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  align-items: center;
}

.pipeline-line {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 11px;
  height: 1px;
  background: var(--border-strong);
  z-index: 0;
}

.stage {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  position: relative;
  z-index: 1;
  color: var(--muted);
  transition: color 160ms ease;
}

.stage-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--text);
  transition: background 160ms ease, transform 160ms ease;
}

.stage-num {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--label);
}

.stage-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: -0.005em;
  transition: color 160ms ease;
}

.stage:hover .stage-name { color: var(--text); }
.stage:hover .stage-dot { transform: scale(1.15); }

.stage.active .stage-dot {
  background: var(--text);
}
.stage.active .stage-name {
  color: var(--text);
}
.stage.active .stage-num {
  color: var(--text);
}

.pipeline-hint {
  font-size: 11px;
  color: var(--label);
  text-align: center;
  margin: 0.85rem 0 0;
  letter-spacing: 0.01em;
}

/* Developed within MimicLabs attribution */
.developed-within {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.55em;
  margin: 0 0 1.1rem;
  text-align: center;
}

.dw-label {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--label);
  font-weight: 500;
}

.wordmark-grad {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;

  background-image: linear-gradient(
    90deg,
    #E63888   0%,
    #F0AB00  50%,
    #032366 100%,
    #F0AB00 150%,
    #E63888 200%
  );
  background-size: 300% 100%;
  background-repeat: no-repeat;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          color: transparent;

  animation: wordmarkBleed 14s ease-in-out infinite;
}

@keyframes wordmarkBleed {
  0%   { background-position:   0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position:   0% 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .wordmark-grad { animation: none; background-position: 0% 50%; }
}

/* Article body */
.article {
  padding: 3rem 0 4rem;
}

.prose {
  max-width: 620px;
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--text);
}

.prose p {
  margin: 0 0 1.1rem;
}
.prose p.muted {
  color: var(--muted);
  font-style: normal;
}
.prose ul {
  margin: 0 0 1.2rem;
  padding-left: 1.1rem;
}
.prose li {
  margin-bottom: 0.5rem;
}
.prose strong {
  font-weight: 600;
}
.prose em {
  font-style: italic;
}
.prose code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
  padding: 1px 5px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
}

/* Stage section */
.stage-section,
.cross-section,
.closing {
  padding: 4.5rem 0 1rem;
  scroll-margin-top: 80px;
}

.stage-header {
  margin-bottom: 2rem;
  max-width: 620px;
}

.stage-tag {
  display: inline-block;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 0.85rem;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--white);
}

.stage-section h2,
.cross-section h2,
.closing h2 {
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.018em;
  margin: 0 0 0.85rem;
  line-height: 1.2;
}

.stage-sub {
  font-size: 16px;
  line-height: 1.55;
  color: var(--muted);
  margin: 0;
  max-width: 620px;
}

/* Stage 1 grid: prose + diagram */
.stage-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 3rem;
  align-items: start;
}

.diagram-card {
  background: var(--white);
  border: 1px solid var(--border);
  padding: 1.25rem;
  position: sticky;
  top: 110px;
}

.diagram-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--label);
  font-weight: 500;
  margin-bottom: 1rem;
}

.extract-cols {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  align-items: center;
}

.extract-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.col-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 500;
}

.col-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
}

.block {
  height: 14px;
  border-radius: 1px;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.02em;
  text-transform: lowercase;
}
.block.chrome {
  background: var(--soft-2);
  color: var(--label);
}
.block.doc {
  background: var(--text);
  color: var(--white);
  height: 28px;
  font-size: 10px;
}

.extract-arrow {
  font-size: 14px;
  color: var(--muted);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

.col-stat {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

/* Length table */
.length-table {
  border: 1px solid var(--border);
  background: var(--white);
  margin: 1.25rem 0 2rem;
  font-size: 13px;
  max-width: 620px;
}

.length-row {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, 1fr);
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.length-row:last-child { border-bottom: 0; }

.length-row > div {
  padding: 0.7rem 0.9rem;
  border-right: 1px solid var(--border);
}
.length-row > div:last-child { border-right: 0; }

.length-row.length-head > div {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 500;
  background: var(--soft);
}

.length-row .yes,
.length-row .no {
  text-align: center;
  font-size: 12px;
}
.length-row .yes { color: var(--text); }
.length-row .no { color: var(--label); }

/* Lexicon tiers */
.lexicon-tiers {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin: 1.25rem 0 2rem;
  border: 1px solid var(--border);
  background: var(--white);
  max-width: 620px;
}

.lex-tier {
  display: grid;
  grid-template-columns: 60px 1fr;
  border-bottom: 1px solid var(--border);
}
.lex-tier:last-child { border-bottom: 0; }

.lex-w {
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--soft);
  border-right: 1px solid var(--border);
  font-family: 'Inter', sans-serif;
}

.lex-body {
  padding: 0.95rem 1.1rem;
}

.lex-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.3rem;
  letter-spacing: -0.005em;
}
.lex-note {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}

/* Compact tier table */
.tier-compact {
  display: grid;
  gap: 0;
  margin: 1.5rem 0 2rem;
  max-width: 620px;
  border: 1px solid var(--border);
  background: var(--white);
}

.tc-row {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 0.8fr 1.6fr;
  gap: 1rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  align-items: center;
  font-size: 13.5px;
}

.tc-row:last-child { border-bottom: none; }

.tc-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--label);
  background: var(--soft);
  font-weight: 500;
}

.tc-tier {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 500;
  color: var(--text);
}

.tc-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--soft);
  border: 1px solid var(--border);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text);
}

.tc-model, .tc-reason {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
}

.tc-use {
  color: var(--text);
  line-height: 1.5;
}

@media (max-width: 640px) {
  .tc-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 1rem;
  }
  .tc-head { display: none; }
  .tc-tier { grid-column: 1 / -1; font-size: 14px; }
  .tc-use { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
}

/* Validation rules */
.rules {
  display: grid;
  gap: 0.5rem;
  margin: 1.5rem 0 2rem;
  max-width: 620px;
}

.rule {
  appearance: none;
  background: var(--white);
  border: 1px solid var(--border);
  padding: 0;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  display: block;
  width: 100%;
  transition: border-color 120ms ease, background 120ms ease;
}
.rule:hover {
  border-color: var(--border-strong);
}

.rule-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.85rem 1rem;
}

.rule-num {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.rule-name {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text);
}

.rule-toggle {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px;
  color: var(--muted);
  width: 16px;
  text-align: center;
  transition: transform 160ms ease, color 160ms ease;
}

.rule-detail {
  display: none;
  padding: 0 1rem 0.95rem 2.4rem;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.6;
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
  margin: 0 0 0;
}
.rule-detail code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  padding: 1px 4px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
}

.rule.open .rule-detail { display: block; }
.rule.open .rule-toggle {
  transform: rotate(45deg);
  color: var(--text);
}
.rule.open {
  background: var(--soft);
}

/* SOUL grid */
.soul-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  margin: 1.5rem 0 2rem;
  max-width: 620px;
  border: 1px solid var(--border);
  background: var(--white);
}

.soul-tenet {
  padding: 1.1rem 1.2rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.soul-tenet:nth-child(2n) { border-right: 0; }
.soul-tenet:nth-last-child(-n+1):nth-child(odd) {
  grid-column: span 2;
  border-bottom: 0;
}
.soul-tenet:nth-last-child(2):nth-child(odd),
.soul-tenet:nth-last-child(1):nth-child(even) {
  border-bottom: 0;
}

.soul-num {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}

.soul-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.4rem;
  letter-spacing: -0.005em;
}

.soul-desc {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.55;
}

/* Dual-purpose lexicon grid */
.dual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1.5rem 0 2rem;
  max-width: 620px;
}

.dual-card {
  background: var(--white);
  border: 1px solid var(--border);
  padding: 1.1rem 1.2rem;
}

.dual-tag {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.dual-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.4rem;
  letter-spacing: -0.005em;
}

.dual-desc {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.55;
}

/* Closing */
.closing {
  padding: 4.5rem 0 2rem;
}

/* Footer */
.article-footer {
  padding: 2rem 0 4rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

/* Hover glossary */
.gloss {
  border-bottom: 1px dotted var(--text);
  cursor: help;
  transition: background 120ms ease;
}
.gloss:hover {
  background: var(--soft);
}

.glossary-tip {
  position: fixed;
  z-index: 100;
  background: var(--text);
  color: var(--white);
  padding: 0.7rem 0.9rem;
  max-width: 280px;
  font-size: 12.5px;
  line-height: 1.5;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease, transform 120ms ease;
  transform: translateY(4px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.12);
}
.glossary-tip.visible {
  opacity: 1;
  transform: translateY(0);
}
.tip-term {
  font-weight: 500;
  margin-bottom: 0.25rem;
  font-size: 12px;
  letter-spacing: 0.01em;
}
.tip-def {
  color: rgba(255,255,255,0.78);
  font-weight: 400;
}

/* Responsive */
@media (max-width: 760px) {
  .page { padding: 0 1.5rem; }
  .hero-pipeline { margin: 0 -1.5rem; padding: 0 1.5rem; }
  .article-header h1 { font-size: 32px; }
  .lede { font-size: 16px; }
  .stage-section h2,
  .cross-section h2,
  .closing h2 { font-size: 24px; }
  .stage-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .diagram-card {
    position: static;
  }
  .stage-name { font-size: 11px; }
  .stage-num { display: none; }
  .length-row {
    grid-template-columns: 1.2fr repeat(4, 1fr);
    font-size: 11px;
  }
  .length-row > div {
    padding: 0.55rem 0.5rem;
  }
  .soul-grid { grid-template-columns: 1fr; }
  .soul-tenet { border-right: 0; }
  .dual-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .pipeline-track {
    grid-template-columns: repeat(5, 1fr);
  }
  .stage-name {
    font-size: 10px;
    text-align: center;
  }
}
