:root {
  --ink: #142a29;
  --ink-soft: #2f4a47;
  --paper: #f3efe6;
  --paper-deep: #e8e0d2;
  --line: #c9c0b2;
  --yellow: #f0b34a;
  --coral: #db5b43;
  --mint: #76b9a9;
  --white: #fffdf8;
  --shadow: 0 18px 48px rgba(20, 42, 41, .13);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

a {
  color: inherit;
  text-decoration-thickness: .12em;
  text-underline-offset: .18em;
}

a:hover { color: var(--coral); }

code, .eyebrow, .brand-copy, .figure-kicker, .section-kicker, .node-type, .micro-label, .demo-topline, .stat-label, .source-stamp, .route-number {
  font-family: "Courier New", Courier, monospace;
}

code { overflow-wrap: anywhere; }

.skip-link {
  position: fixed;
  z-index: 10;
  top: .75rem;
  left: .75rem;
  padding: .7rem 1rem;
  color: var(--ink);
  background: var(--yellow);
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1rem clamp(1rem, 3vw, 3.5rem);
  border-bottom: 1px solid var(--line);
}

.project-mark, .top-nav, .language-nav {
  display: flex;
  align-items: center;
}

.project-mark {
  gap: .75rem;
  color: var(--ink);
  text-decoration: none;
}

.mark-box {
  display: grid;
  width: 2.4rem;
  height: 2.4rem;
  place-items: center;
  color: var(--ink);
  background: var(--yellow);
  border: 2px solid var(--ink);
  font-weight: 800;
}

.brand-copy {
  color: var(--ink-soft);
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.top-nav { gap: 1.25rem; font-weight: 700; }
.top-nav > a { text-decoration: none; }
.language-nav { gap: .55rem; font-family: "Courier New", monospace; font-size: .78rem; }
.language-nav span { color: var(--coral); }
.language-nav a { text-decoration: none; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, .93fr) minmax(0, 1.07fr);
  max-width: 1440px;
  margin: 0 auto;
  background: var(--ink);
}

.hero-copy {
  min-width: 0;
  padding: clamp(2rem, 5vw, 5rem) clamp(1rem, 4vw, 4.5rem) 3rem;
  color: var(--white);
}

.eyebrow {
  margin: 0 0 1.35rem;
  color: var(--yellow);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .11em;
  line-height: 1.5;
  text-transform: uppercase;
}

h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; }
h1, h2, h3, p { overflow-wrap: anywhere; }

h1 {
  max-width: 10ch;
  margin: 0;
  color: var(--white);
  font-size: clamp(3.15rem, 7vw, 6.7rem);
  letter-spacing: -.065em;
  line-height: .9;
}

.deck {
  max-width: 42rem;
  margin: 2rem 0 1rem;
  color: #e7eee9;
  font-size: clamp(1.05rem, 1.7vw, 1.3rem);
  line-height: 1.48;
}

.reader-gain { margin: 0; color: var(--yellow); font-size: 1rem; }
.continuation-cue { margin: .8rem 0 0; color: #b9c9c0; font-size: .94rem; }

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .7rem;
  margin: 2rem 0 1.25rem;
}

.hero-stat {
  min-width: 0;
  min-height: 9.6rem;
  padding: .9rem .8rem;
  border-top: 4px solid var(--yellow);
  background: rgba(255, 253, 248, .08);
}

.hero-stat strong {
  display: block;
  margin: .45rem 0 .2rem;
  color: var(--white);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 4vw, 3.5rem);
  letter-spacing: -.06em;
  line-height: 1;
}

.hero-stat span:last-child { display: block; color: #c6d5cc; font-size: .82rem; line-height: 1.3; }
.stat-doors { border-top-color: var(--mint); }
.stat-limit { border-top-color: var(--coral); }
.stat-label { display: block; color: #a9bbb1; font-size: .65rem; letter-spacing: .08em; line-height: 1.35; text-transform: uppercase; }

.source-stamp {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .55rem;
  margin-top: 1.2rem;
  color: #b9c9c0;
  font-size: .66rem;
  letter-spacing: .04em;
  line-height: 1.35;
  text-transform: uppercase;
}

.credibility { max-width: 42rem; margin: 1.1rem 0 0; color: #d8e2db; font-size: .88rem; }
.credibility a { color: var(--yellow); }

.join-figure {
  min-width: 0;
  margin: 0;
  padding: clamp(1rem, 3vw, 3.5rem);
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(20, 42, 41, .055) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(rgba(20, 42, 41, .055) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--paper);
}

.join-figure figcaption { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin-bottom: .8rem; }
.figure-kicker { color: var(--coral); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; }
.join-figure figcaption strong { margin-left: auto; font-family: Georgia, serif; font-size: clamp(2.8rem, 5vw, 5.4rem); letter-spacing: -.07em; line-height: .8; }
.join-figure figcaption > span:last-child { flex-basis: 100%; color: var(--ink-soft); font-size: .9rem; }

.join-paper {
  max-width: 680px;
  margin: 0 auto;
  padding: clamp(1rem, 2.7vw, 2rem);
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.demo-topline { display: flex; justify-content: space-between; gap: .8rem; color: var(--coral); font-size: .63rem; font-weight: 700; letter-spacing: .07em; line-height: 1.4; }
.demo-topline span:last-child { color: var(--ink-soft); text-align: right; }
.demo-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 1rem 0; border-bottom: 2px solid var(--ink); }
.node-label { color: var(--ink-soft); font-family: "Courier New", monospace; font-size: .73rem; }
.demo-row code { color: var(--ink); font-weight: 700; font-size: .88rem; }

.junction { position: relative; display: grid; grid-template-columns: 1fr 1fr; min-height: 2.4rem; }
.junction:before { content: ""; position: absolute; top: 0; left: 50%; width: 2px; height: 100%; background: var(--ink); }
.junction:after { content: ""; position: absolute; left: calc(50% - 5px); bottom: 0; width: 10px; height: 10px; background: var(--ink); transform: rotate(45deg); }
.junction span:first-child { border-right: 2px solid var(--ink); }
.junction i { position: absolute; top: 0; left: 22%; right: 22%; height: 2px; background: var(--ink); }

.state-switch { position: relative; }
.state-switch > input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.state-switch fieldset { margin: 0; padding: 0; border: 0; }
.state-switch legend { margin-bottom: .45rem; color: var(--ink-soft); font-size: .75rem; font-weight: 700; }
.choice-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.choice { min-width: 0; }
.choice label {
  display: grid;
  min-height: 2.75rem;
  place-items: center;
  padding: .55rem .65rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  cursor: pointer;
  font-family: "Courier New", monospace;
  font-size: .72rem;
  font-weight: 700;
  text-align: center;
}
.choice label:hover { border-color: var(--coral); }
.state-switch:has(#record-current:checked) label[for="record-current"], .state-switch:has(#record-historical:checked) label[for="record-historical"] { color: var(--white); background: var(--ink); border-color: var(--ink); }
.state-switch:has(#record-current:focus-visible) label[for="record-current"], .state-switch:has(#record-historical:focus-visible) label[for="record-historical"] { outline: 3px solid var(--coral); outline-offset: 3px; }

.join-state { margin-top: 1rem; }
.current-state { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: .65rem; }
.lookup-node { min-width: 0; min-height: 8.5rem; padding: .85rem; border: 2px solid var(--ink); }
.lookup-node .node-type { display: block; color: var(--ink-soft); font-size: .64rem; font-weight: 700; letter-spacing: .08em; }
.lookup-node strong { display: block; margin: .65rem 0 .45rem; font-family: "Courier New", monospace; font-size: .84rem; overflow-wrap: anywhere; }
.lookup-node small { display: block; color: var(--ink-soft); font-size: .75rem; line-height: 1.35; }
.uprn-node { background: #f8dda4; }
.inspire-node { background: #b9ddd1; }
.historical-state { display: none; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .8rem; padding: .75rem; background: #f4d3c9; border: 2px solid var(--coral); }
.historical-state p { grid-column: 1 / -1; margin: .3rem 0 0; color: var(--ink-soft); font-size: .82rem; }
.stop-node { min-height: auto; background: var(--white); border-color: var(--coral); }
.stop-mark { color: var(--coral); font-family: Georgia, serif; font-size: 3rem; line-height: 1; }
.state-notes { margin-top: .8rem; }
.state-note { margin: 0; color: var(--ink-soft); font-size: .8rem; line-height: 1.4; }
.state-note.historical { display: none; }
.state-switch:has(#record-historical:checked) .current-state, .state-switch:has(#record-historical:checked) .state-note.current { display: none; }
.state-switch:has(#record-historical:checked) .historical-state, .state-switch:has(#record-historical:checked) .state-note.historical { display: grid; }
.state-switch:has(#record-current:checked) .state-note.current { display: block; }
.join-footnote { margin: 1rem 0 0; color: var(--ink-soft); font-size: .7rem; }

.scope-ribbon {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.1rem clamp(1rem, 4vw, 4.5rem);
  color: var(--ink);
  background: var(--yellow);
}
.scope-ribbon p { max-width: 70rem; margin: 0; font-size: .92rem; }
.ribbon-mark { display: grid; width: 1.65rem; height: 1.65rem; flex: 0 0 auto; place-items: center; color: var(--yellow); background: var(--ink); border-radius: 50%; font-weight: 800; }

.section-rail {
  display: flex;
  gap: 0;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 4.5rem);
  overflow-x: auto;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.section-rail a { min-height: 2.75rem; padding: .7rem .9rem; color: var(--ink-soft); font-family: "Courier New", monospace; font-size: .7rem; font-weight: 700; text-decoration: none; white-space: nowrap; }
.section-rail a:first-child { padding-left: 0; }
.section-rail a:hover { color: var(--coral); }

.chapter { display: grid; grid-template-columns: minmax(3.5rem, .22fr) minmax(0, 1fr); gap: clamp(1rem, 4vw, 4rem); max-width: 1000px; margin: 0 auto; padding: clamp(3.5rem, 7vw, 7rem) clamp(1rem, 3vw, 2rem); }
.chapter-tinted { max-width: none; padding-right: max(1rem, calc((100% - 1000px) / 2 + 2rem)); padding-left: max(1rem, calc((100% - 1000px) / 2 + 2rem)); background: var(--paper-deep); }
.chapter-number { color: var(--coral); font-family: "Courier New", monospace; font-size: .8rem; font-weight: 700; letter-spacing: .12em; }
.chapter-body { min-width: 0; }
.section-kicker { margin: 0 0 .7rem; color: var(--coral); font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
h2 { max-width: 18ch; margin: 0 0 1rem; color: var(--ink); font-size: clamp(2.2rem, 5vw, 4.5rem); letter-spacing: -.055em; line-height: .98; }
.lead { max-width: 46rem; margin: 0; color: var(--ink-soft); font-size: clamp(1.03rem, 1.7vw, 1.2rem); line-height: 1.55; }

.route-lines { max-width: 720px; margin: 2rem 0 1.4rem; }
.route-line { display: grid; grid-template-columns: 2.4rem minmax(0, .85fr) minmax(0, 1.15fr); align-items: center; gap: .75rem; min-height: 3.5rem; padding: .7rem 1rem; background: var(--white); border: 1px solid var(--line); }
.route-active { background: #b9ddd1; border-color: var(--ink); box-shadow: 7px 7px 0 var(--coral); }
.route-number { color: var(--coral); font-size: .7rem; font-weight: 700; }
.route-line strong { font-family: Georgia, serif; font-size: 1.05rem; }
.route-line code { color: var(--ink-soft); font-size: .72rem; }
.route-arrow { height: 1.7rem; padding-left: 1.5rem; color: var(--coral); font-size: 1.4rem; line-height: 1.7rem; }

.annotation { display: flex; gap: .65rem; max-width: 50rem; margin: 1.25rem 0 0; color: var(--ink-soft); font-size: .9rem; }
.annotation > span { color: var(--coral); font-size: 1.1rem; font-weight: 700; }
.meaning-grid, .boundary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 2rem; }
.meaning-card, .boundary-card { min-width: 0; padding: 1.4rem; background: var(--white); border-top: 6px solid var(--yellow); }
.meaning-inspire { border-top-color: var(--mint); }
.meaning-card h3, .boundary-card h3 { margin: .6rem 0 .45rem; font-size: 2rem; letter-spacing: -.04em; line-height: 1; }
.meaning-card p, .boundary-card p { margin: .55rem 0 0; color: var(--ink-soft); }
.small-note { font-size: .8rem; }
.card-index, .boundary-index { display: inline-grid; width: 1.8rem; height: 1.8rem; place-items: center; color: var(--white); background: var(--ink); font-family: "Courier New", monospace; font-size: .72rem; font-weight: 700; }
.callout { max-width: 700px; margin-top: 1.5rem; padding: 1rem 1.2rem; color: var(--ink); background: #f8dda4; border-left: 5px solid var(--coral); }

.before-after { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: 1rem; margin-top: 2rem; }
.before-after-card { min-width: 0; padding: 1.4rem; background: var(--ink); color: var(--white); }
.before-after-card strong { display: block; margin-top: .7rem; font-family: Georgia, serif; font-size: 1.7rem; line-height: 1.05; }
.before-after-card p { margin: .8rem 0 0; color: #c8d5cd; font-size: .9rem; }
.muted-card { color: var(--ink); background: var(--white); border: 1px solid var(--line); }
.muted-card p { color: var(--ink-soft); }
.micro-label { color: var(--yellow); font-size: .65rem; font-weight: 700; letter-spacing: .1em; }
.muted-card .micro-label { color: var(--coral); }
.before-after-divider { display: grid; place-items: center; color: var(--coral); font-family: Georgia, serif; font-size: 2rem; }

.fanout { display: grid; grid-template-columns: minmax(0, .75fr) 80px minmax(0, 1.25fr); align-items: center; gap: 1rem; margin-top: 2rem; padding: 1.4rem; background: var(--white); border: 1px solid var(--line); }
.fanout-source { padding: 1rem; background: var(--ink); color: var(--white); }
.fanout-source span, .fanout-targets span { display: block; font-family: "Courier New", monospace; font-size: .72rem; font-weight: 700; overflow-wrap: anywhere; }
.fanout-source small, .fanout-targets small { display: block; margin-top: .45rem; color: #c5d5cc; font-size: .73rem; line-height: 1.3; }
.fanout-targets { display: grid; gap: .65rem; }
.fanout-targets span { padding: .75rem; background: #b9ddd1; color: var(--ink); border: 1px solid var(--ink); }
.fanout-targets small { color: var(--ink-soft); font-family: Arial, sans-serif; font-weight: 400; }
.fanout-lines { position: relative; display: grid; gap: 1.15rem; }
.fanout-lines i { display: block; height: 2px; background: var(--coral); }
.fanout-lines i:first-child { transform: translateY(-7px) rotate(-21deg); }
.fanout-lines i:last-child { transform: translateY(7px) rotate(21deg); }

.use-ladder { display: grid; gap: .65rem; max-width: 720px; margin-top: 2rem; }
.use-step { display: grid; grid-template-columns: 2.6rem 1fr; gap: .8rem; align-items: start; padding: .85rem; background: var(--white); border-left: 5px solid var(--mint); }
.use-step > span { display: grid; width: 2rem; height: 2rem; place-items: center; color: var(--white); background: var(--ink); font-family: "Courier New", monospace; font-weight: 700; }
.use-step strong { font-family: Georgia, serif; font-size: 1.25rem; }
.use-step p { margin: .15rem 0 0; color: var(--ink-soft); font-size: .9rem; }

.boundary-in { border-top-color: var(--mint); }
.boundary-out { border-top-color: var(--coral); }

.table-wrap { margin-top: 2rem; overflow-x: auto; background: var(--white); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; text-align: left; }
caption { padding: 1rem 1.1rem .7rem; color: var(--ink); font-family: Georgia, serif; font-size: 1.25rem; font-weight: 700; text-align: left; }
th, td { padding: .8rem 1rem; border-top: 1px solid var(--line); vertical-align: top; }
thead th { color: var(--ink-soft); font-family: "Courier New", monospace; font-size: .68rem; letter-spacing: .07em; text-transform: uppercase; }
tbody th { font-family: Georgia, serif; font-size: 1rem; }
tbody td { color: var(--ink-soft); font-size: .87rem; }
.method-note { margin: 1.2rem 0 0; color: var(--ink-soft); font-size: .86rem; }
.method-note code { color: var(--ink); font-family: "Courier New", monospace; font-size: .78rem; }
.source-list { margin-top: 2rem; padding-top: 1.3rem; border-top: 2px solid var(--ink); }
.source-list h3 { margin: 0 0 .65rem; font-size: 1.6rem; }
.source-list ul { margin: 0; padding-left: 1.2rem; color: var(--ink-soft); }
.source-list li { margin: .55rem 0; }
.update-note { margin: 1.5rem 0 0; padding-top: 1rem; color: var(--ink-soft); border-top: 1px dashed var(--line); font-size: .86rem; }

.site-footer { display: flex; justify-content: space-between; gap: 1rem; max-width: 1440px; margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 3.5rem); color: var(--ink-soft); border-top: 1px solid var(--line); font-size: .82rem; }
.site-footer p { margin: 0; }

.not-found { max-width: 720px; margin: 0 auto; padding: 10vh 1rem; }
.not-found h1 { max-width: 14ch; color: var(--ink); font-size: clamp(3rem, 8vw, 6rem); }
.not-found p { color: var(--ink-soft); }
.back-link { display: inline-block; min-height: 2.75rem; padding: .65rem .9rem; color: var(--ink); background: var(--yellow); font-weight: 700; }

:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
  .join-figure { padding-top: 2rem; }
  .scope-ribbon { grid-column: auto; }
  .chapter { grid-template-columns: 2.5rem minmax(0, 1fr); }
  .chapter-tinted { padding-right: clamp(1rem, 3vw, 2rem); padding-left: clamp(1rem, 3vw, 2rem); }
}

@media (max-width: 620px) {
  .topbar { align-items: flex-start; }
  .top-nav { gap: .7rem; flex-direction: column; align-items: flex-end; }
  .brand-copy { display: none; }
  .hero-copy { padding-top: 2rem; }
  h1 { max-width: 8ch; font-size: clamp(3.15rem, 17vw, 5rem); }
  .deck { margin-top: 1.5rem; font-size: 1.05rem; }
  .hero-stats { grid-template-columns: 1fr; gap: .55rem; }
  .hero-stat { min-height: auto; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .45rem .8rem; padding: .8rem; }
  .hero-stat strong { grid-row: span 2; grid-column: 2; margin: 0; font-size: 2.6rem; }
  .hero-stat .stat-label { grid-column: 1; }
  .hero-stat span:last-child { grid-column: 1; }
  .source-stamp { grid-template-columns: 1fr; gap: .35rem; }
  .join-figure { padding: 1rem; }
  .join-figure figcaption strong { margin-left: 0; }
  .join-paper { padding: 1rem; }
  .demo-topline { flex-direction: column; gap: .2rem; }
  .demo-topline span:last-child { text-align: left; }
  .demo-row { display: block; }
  .demo-row code { display: block; margin-top: .4rem; }
  .current-state, .meaning-grid, .boundary-grid { grid-template-columns: 1fr; }
  .before-after { grid-template-columns: 1fr; }
  .before-after-divider { min-height: 1.5rem; }
  .fanout { grid-template-columns: 1fr; gap: .7rem; }
  .fanout-lines { grid-template-columns: 1fr 1fr; gap: .5rem; min-height: 1.1rem; }
  .fanout-lines i:first-child, .fanout-lines i:last-child { transform: none; }
  .fanout-lines i:first-child { transform: rotate(22deg); }
  .fanout-lines i:last-child { transform: rotate(-22deg); }
  .route-line { grid-template-columns: 2rem 1fr; gap: .55rem; }
  .route-line code { grid-column: 2; }
  .chapter { gap: .8rem; padding-top: 3.4rem; padding-bottom: 3.4rem; }
  h2 { font-size: clamp(2.2rem, 12vw, 3.5rem); }
  .site-footer { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
