/* ==========================================================================
   Perrette — shared stylesheet
   Two colour systems live here and they never mix:
     · the brand   — béton and ink. No hue. Carries the site itself.
     · the domains — eight colours, one per field of analysis. Identity only.
   Change a token, it changes everywhere. Never hard-code a colour in a page.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Brand tokens — light
   -------------------------------------------------------------------------- */
:root {
  --paper:        #F2F1ED;   /* béton */
  --surface:      #FFFFFF;
  --sunk:         #E7E6E0;
  --deep:         #1B1C19;
  --deep-surface: #24251F;

  --ink:   #1B1C19;
  --ink-2: #4E524C;
  --ink-3: #8B8F88;
  --on-deep:   #EDECE6;
  --on-deep-2: #A9ADA4;
  --on-deep-3: #7A7E76;

  --rule:      #D8D6CF;
  --rule-firm: #B9B7AE;
  --rule-deep: #33342D;

  /* the geometric socle — pale by design, never carries text */
  --socle:      #ADCAB8;
  --socle-soft: #DCE9E1;

  /* Eight domains, in the fixed order that keeps neighbours separable. */
  --d-fire:   #BC5146;  --t-fire:   #FEE7E3;
  --d-vent:   #6195E3;  --t-vent:   #E2EEFF;
  --d-struct: #A4366F;  --t-struct: #FFE5EF;
  --d-acou:   #8D900E;  --t-acou:   #EDF0D3;
  --d-carbon: #009AB0;  --t-carbon: #D1F4FC;
  --d-energy: #B48215;  --t-energy: #FBEBD1;
  --d-optim:  #7A65C2;  --t-optim:  #EDEAFD;
  --d-crowd:  #369B64;  --t-crowd:  #D9F5E2;

  --font-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-body:    "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --step--1: clamp(0.80rem, 0.78rem + 0.10vw, 0.87rem);
  --step-0:  clamp(1.00rem, 0.96rem + 0.18vw, 1.12rem);
  --step-1:  clamp(1.20rem, 1.12rem + 0.36vw, 1.44rem);
  --step-2:  clamp(1.50rem, 1.34rem + 0.72vw, 2.00rem);
  --step-3:  clamp(1.95rem, 1.62rem + 1.45vw, 2.90rem);
  --step-4:  clamp(2.45rem, 1.85rem + 2.70vw, 4.30rem);

  --frame: 1140px;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --prose: 64ch;
}

/* --------------------------------------------------------------------------
   2. Brand tokens — dark
   Domain colours are re-stepped for the dark surface, not flipped.
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #131412;
    --surface:      #1B1D19;
    --sunk:         #0E0F0D;
    --deep:         #080907;
    --deep-surface: #14150F;

    --ink:   #E9E9E3;
    --ink-2: #A9ADA4;
    --ink-3: #787C74;
    --on-deep:   #E9E9E3;
    --on-deep-2: #A9ADA4;
    --on-deep-3: #787C74;

    --rule:      #2A2C27;
    --rule-firm: #3E413A;
    --rule-deep: #22241E;

    --socle:      #6E8C79;
    --socle-soft: #1B2A21;

    --d-fire:   #CD6055;  --t-fire:   #40201C;
    --d-vent:   #5393F1;  --t-vent:   #1A2A43;
    --d-struct: #AD4B7B;  --t-struct: #3D1F2D;
    --d-acou:   #989B23;  --t-acou:   #2B2C0C;
    --d-carbon: #1FA5BB;  --t-carbon: #003038;
    --d-energy: #BE8912;  --t-energy: #372709;
    --d-optim:  #8774CB;  --t-optim:  #2B2541;
    --d-crowd:  #2EAD6D;  --t-crowd:  #12311F;
  }
}

:root[data-theme="dark"] {
  --paper:        #131412;
  --surface:      #1B1D19;
  --sunk:         #0E0F0D;
  --deep:         #080907;
  --deep-surface: #14150F;

  --ink:   #E9E9E3;
  --ink-2: #A9ADA4;
  --ink-3: #787C74;
  --on-deep:   #E9E9E3;
  --on-deep-2: #A9ADA4;
  --on-deep-3: #787C74;

  --rule:      #2A2C27;
  --rule-firm: #3E413A;
  --rule-deep: #22241E;

  --socle:      #6E8C79;
  --socle-soft: #1B2A21;

  --d-fire:   #CD6055;  --t-fire:   #40201C;
  --d-vent:   #5393F1;  --t-vent:   #1A2A43;
  --d-struct: #AD4B7B;  --t-struct: #3D1F2D;
  --d-acou:   #989B23;  --t-acou:   #2B2C0C;
  --d-carbon: #1FA5BB;  --t-carbon: #003038;
  --d-energy: #BE8912;  --t-energy: #372709;
  --d-optim:  #8774CB;  --t-optim:  #2B2541;
  --d-crowd:  #2EAD6D;  --t-crowd:  #12311F;
}

/* --------------------------------------------------------------------------
   3. Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.62;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 620;
  line-height: 1.06;
  letter-spacing: -.022em;
  text-wrap: balance;
  margin: 0;
}
p { margin: 0; }

a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--ink-2); }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 2px; }
img, svg { max-width: 100%; }

/* --------------------------------------------------------------------------
   4. Frame and bands
   -------------------------------------------------------------------------- */
.frame { width: 100%; max-width: var(--frame); margin-inline: auto; padding-inline: var(--gutter); }

.band { padding-block: clamp(3.5rem, 8vw, 7rem); border-top: 1px solid var(--rule); }
.band--first { border-top: 0; }
.band--sunk  { background: var(--sunk); }
.band--deep  { background: var(--deep); color: var(--on-deep); border-top-color: var(--rule-deep); }
.band--deep h2, .band--deep h3 { color: var(--on-deep); }

.sechead { display: flex; flex-direction: column; gap: .9rem; max-width: 26rem; }
.sechead--wide { max-width: 30rem; }

.eyebrow {
  font-family: var(--font-mono); font-size: var(--step--1); font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3);
  display: flex; align-items: center; gap: .7rem;
}
.eyebrow::before { content: ""; width: 1.6rem; height: 1px; background: var(--rule-firm); flex: none; }
.band--deep .eyebrow { color: var(--on-deep-3); }

h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); letter-spacing: -.012em; }

.lede { font-size: var(--step-1); line-height: 1.5; color: var(--ink-2); max-width: var(--prose); }
.band--deep .lede { color: var(--on-deep-2); }

.prose { max-width: var(--prose); display: flex; flex-direction: column; gap: 1.1em; }
.prose p { color: var(--ink-2); }
.band--deep .prose p { color: var(--on-deep-2); }

/* --------------------------------------------------------------------------
   5. Masthead
   -------------------------------------------------------------------------- */
.masthead {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.masthead__inner { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; height: 4.25rem; }

.wordmark {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--font-display); font-weight: 700; font-size: 1.06rem;
  letter-spacing: .005em; color: var(--ink); text-decoration: none;
}
.wordmark:hover { color: var(--ink); }
.wordmark svg { display: block; flex: none; }
.wm { fill: var(--ink); }

.nav { display: flex; align-items: center; gap: clamp(1rem, 2.5vw, 2rem); }
.nav a {
  font-family: var(--font-display); font-size: .94rem; font-weight: 500;
  color: var(--ink-2); text-decoration: none; white-space: nowrap;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); }
.nav a[aria-current="page"]::after { content: ""; display: block; height: 2px; margin-top: 3px; background: var(--ink); }

/* Download exists, is visible, and is not available yet. */
.nav a.nav__soon { color: var(--ink-3); }
.nav a.nav__soon:hover { color: var(--ink-2); }

/* Below 780px the five items no longer fit beside the wordmark. They drop to a
   second row that scrolls sideways — the same pattern as .viewer__bar — so every
   section stays visible instead of being folded into a menu. The negative margin
   lets the row reach the screen edges while keeping the gutter as padding, so the
   last item can be scrolled fully into view. */
@media (max-width: 780px) {
  .masthead__inner {
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    height: auto; gap: 0; padding-block: .75rem 0;
  }
  .nav {
    gap: 1.25rem;
    margin-inline: calc(var(--gutter) * -1);
    padding: .5rem var(--gutter) .6rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
}

/* --------------------------------------------------------------------------
   6. Buttons — ink, never a domain colour
   -------------------------------------------------------------------------- */
.actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.btn {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--font-display); font-size: .95rem; font-weight: 560;
  padding: .72rem 1.15rem; border-radius: 2px; border: 1px solid transparent;
  text-decoration: none; transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}
.btn--solid { background: var(--ink); color: var(--paper); }
.btn--solid:hover { background: var(--ink-2); color: var(--paper); }
.btn--line { border-color: var(--rule-firm); color: var(--ink); background: transparent; }
.btn--line:hover { border-color: var(--ink-2); color: var(--ink); }

/* On a dark band an ink button would sink into the background. */
.band--deep .btn--solid { background: var(--on-deep); color: var(--deep); }
.band--deep .btn--solid:hover { background: var(--on-deep-2); color: var(--deep); }
.band--deep .btn--line { border-color: var(--rule-deep); color: var(--on-deep); }
.band--deep .btn--line:hover { border-color: var(--on-deep-3); color: var(--on-deep); }

/* --------------------------------------------------------------------------
   7. Hero
   -------------------------------------------------------------------------- */
.hero { padding-block: clamp(3rem, 7vw, 6rem) clamp(3rem, 7vw, 5.5rem); }
.hero__grid { display: grid; gap: clamp(2.5rem, 5vw, 4rem); grid-template-columns: 1fr; align-items: center; }
@media (min-width: 940px) { .hero__grid { grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); } }
.hero__text { display: flex; flex-direction: column; gap: 1.5rem; }
.hero h1 { font-size: var(--step-4); font-weight: 680; letter-spacing: -.03em; line-height: .99; max-width: 17ch; }
.hero__sub { font-size: var(--step-1); line-height: 1.5; color: var(--ink-2); max-width: 42ch; }

/* --------------------------------------------------------------------------
   8. The viewer — one plan, four questions
   -------------------------------------------------------------------------- */
.viewer { border: 1px solid var(--rule); background: var(--surface); border-radius: 3px; overflow: hidden; display: flex; flex-direction: column; }
.viewer__bar { display: flex; border-bottom: 1px solid var(--rule); overflow-x: auto; scrollbar-width: none; }
.viewer__bar::-webkit-scrollbar { display: none; }
.viewer__tab {
  appearance: none; background: transparent; border: 0; border-right: 1px solid var(--rule);
  padding: .7rem .95rem; font-family: var(--font-mono); font-size: .7rem;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3);
  cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: .45rem;
  transition: color 140ms ease, background-color 140ms ease;
}
.viewer__tab i { width: .5rem; height: .5rem; display: block; flex: none; }
.viewer__tab:hover { color: var(--ink-2); }
.viewer__tab[aria-selected="true"] { color: var(--ink); background: var(--sunk); }
.viewer__stage { position: relative; }
.viewer__stage svg { display: block; width: 100%; height: auto; }
.overlay { opacity: 0; transition: opacity 420ms ease; }
.overlay.is-on { opacity: 1; }
.viewer__foot {
  border-top: 1px solid var(--rule); padding: .7rem .95rem;
  display: flex; gap: .9rem; align-items: baseline; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: .72rem; color: var(--ink-3);
}
.viewer__caption { color: var(--ink-2); }

/* --------------------------------------------------------------------------
   9. The eight domains
   -------------------------------------------------------------------------- */
.domains { margin-top: 2.75rem; border-top: 1px solid var(--rule-firm); }
.domain {
  display: grid; grid-template-columns: 1fr; gap: .3rem .75rem;
  padding: 1.15rem 0; border-bottom: 1px solid var(--rule); align-items: baseline;
}
@media (min-width: 780px) { .domain { grid-template-columns: 1.15rem 14rem minmax(0, 1fr); gap: 1.5rem; align-items: baseline; } }
.domain__dot { width: .7rem; height: .7rem; display: block; flex: none; }
.domain__name { font-family: var(--font-display); font-weight: 580; font-size: 1.02rem; color: var(--ink); }
.domain__q { color: var(--ink-2); font-size: .97rem; }

/* --------------------------------------------------------------------------
   10. Principles
   -------------------------------------------------------------------------- */
.principles { margin-top: 2.75rem; display: grid; gap: 1px; background: var(--rule-deep); border: 1px solid var(--rule-deep); grid-template-columns: 1fr; }
@media (min-width: 720px) { .principles { grid-template-columns: 1fr 1fr; } }
.principle { background: var(--deep); padding: clamp(1.5rem, 3vw, 2.25rem); display: flex; flex-direction: column; gap: .7rem; }
.principle h3 { font-size: 1.12rem; }
.principle p { color: var(--on-deep-2); font-size: .98rem; }

/* --------------------------------------------------------------------------
   11. Methods page
   -------------------------------------------------------------------------- */
.doc { display: grid; grid-template-columns: 1fr; gap: clamp(2rem, 5vw, 4rem); align-items: start; }
@media (min-width: 1000px) { .doc { grid-template-columns: 15rem minmax(0, 1fr); } }
.doc > *, .article > *, .chapter > * { min-width: 0; }

.toc { display: none; }
@media (min-width: 1000px) { .toc { display: block; position: sticky; top: 6rem; } }
.toc h2 { font-family: var(--font-mono); font-size: var(--step--1); font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 1rem; }
.toc ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .65rem; }
.toc a { font-family: var(--font-display); font-size: .92rem; line-height: 1.35; color: var(--ink-2); text-decoration: none; display: block; border-left: 2px solid var(--rule); padding-left: .8rem; }
.toc a:hover { color: var(--ink); border-left-color: var(--rule-firm); }
.toc a.is-current { color: var(--ink); border-left-color: var(--ink); }

.article { display: flex; flex-direction: column; gap: clamp(3rem, 6vw, 4.5rem); }
.chapter { display: flex; flex-direction: column; gap: 1.35rem; scroll-margin-top: 6rem; }
.chapter h2 { font-size: var(--step-2); max-width: 22ch; }
.chapter p { max-width: var(--prose); color: var(--ink-2); }
.chapter h3 { margin-top: .75rem; }
.chapter__no { font-family: var(--font-mono); font-size: var(--step--1); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }

.pullquote { border-left: 2px solid var(--rule-firm); padding-left: 1.25rem; font-size: var(--step-1); line-height: 1.45; color: var(--ink); max-width: 48ch; }

.list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: .75rem; max-width: var(--prose); }
.list li { padding-left: 1.35rem; position: relative; color: var(--ink-2); font-size: .99rem; }
.list li::before { content: ""; position: absolute; left: 0; top: .72em; width: .6rem; height: 1px; background: var(--rule-firm); }
.list strong { color: var(--ink); font-weight: 600; }

.fig { margin: .5rem 0 0; border: 1px solid var(--rule); background: var(--surface); border-radius: 3px; overflow: hidden; }
.fig__body { padding: clamp(1.25rem, 3vw, 2rem); overflow-x: auto; }
.fig__body svg { display: block; width: 100%; height: auto; min-width: 340px; }
.fig figcaption { border-top: 1px solid var(--rule); padding: .75rem 1rem; font-family: var(--font-mono); font-size: .73rem; line-height: 1.55; color: var(--ink-3); }
.fig figcaption b { color: var(--ink-2); font-weight: 500; }

.split { display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 3px; grid-template-columns: 1fr; overflow: hidden; }
@media (min-width: 720px) { .split { grid-template-columns: 1fr 1fr; } }
.split__col { background: var(--surface); padding: clamp(1.25rem, 3vw, 1.85rem); display: flex; flex-direction: column; gap: .9rem; }
.split__head { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .11em; text-transform: uppercase; color: var(--ink-3); display: flex; align-items: center; gap: .5rem; }
.split__head::before { content: ""; width: .5rem; height: .5rem; flex: none; }
.split__col--yes .split__head::before { background: var(--d-crowd); }
.split__col--no  .split__head::before { background: var(--d-fire); }
.split ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: .6rem; }
.split li { color: var(--ink-2); font-size: .97rem; }

.note { border: 1px solid var(--rule); border-left: 2px solid var(--rule-firm); background: var(--surface); padding: 1.1rem 1.35rem; border-radius: 2px; max-width: var(--prose); }
.note p { font-size: .95rem; color: var(--ink-2); }
.note__label { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .11em; text-transform: uppercase; color: var(--ink-3); display: block; margin-bottom: .4rem; }

/* --------------------------------------------------------------------------
   12. SVG paint classes — colour through CSS, so drawings follow the theme
   -------------------------------------------------------------------------- */
svg text { font-family: var(--font-mono); letter-spacing: .09em; }
.p-wall   { stroke: var(--ink); }
.p-glass  { stroke: var(--socle); }
.f-socle  { fill: var(--socle); }
.s-rule   { stroke: var(--rule); }
.s-rulefirm { stroke: var(--rule-firm); }
.t-mute   { fill: var(--ink-3); }
.t-ink    { fill: var(--ink); }
.t-body   { fill: var(--ink-2); }
.f-ink    { fill: var(--ink); }
.f-socle-soft { fill: var(--socle-soft); }

.f-fire{fill:var(--d-fire)} .s-fire{stroke:var(--d-fire)} .t-fire{fill:var(--d-fire)}
.f-vent{fill:var(--d-vent)} .s-vent{stroke:var(--d-vent)} .t-vent{fill:var(--d-vent)}
.f-acou{fill:var(--d-acou)} .s-acou{stroke:var(--d-acou)} .t-acou{fill:var(--d-acou)}
.f-energy{fill:var(--d-energy)} .s-energy{stroke:var(--d-energy)} .t-energy{fill:var(--d-energy)}
.f-crowd{fill:var(--d-crowd)} .s-crowd{stroke:var(--d-crowd)} .t-crowd{fill:var(--d-crowd)}
.f-optim{fill:var(--d-optim)} .s-optim{stroke:var(--d-optim)} .t-optim{fill:var(--d-optim)}
.f-carbon{fill:var(--d-carbon)} .s-carbon{stroke:var(--d-carbon)}
.f-struct{fill:var(--d-struct)} .s-struct{stroke:var(--d-struct)}

/* --------------------------------------------------------------------------
   13. Footer
   -------------------------------------------------------------------------- */
.foot { border-top: 1px solid var(--rule); padding-block: 2.75rem 3.25rem; background: var(--paper); }
.foot__inner { display: flex; flex-wrap: wrap; gap: 1.5rem 3rem; align-items: flex-start; justify-content: space-between; }
.foot__col { display: flex; flex-direction: column; gap: .5rem; }
.foot__col a { color: var(--ink-2); text-decoration: none; font-size: .93rem; font-family: var(--font-display); }
.foot__col a:hover { color: var(--ink); }
.foot__label { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: .25rem; }
.foot__fine { font-family: var(--font-mono); font-size: .72rem; color: var(--ink-3); line-height: 1.7; max-width: 36ch; }

/* --------------------------------------------------------------------------
   14. Reference pages (Building science)
   -------------------------------------------------------------------------- */
.ref-head { display: flex; flex-direction: column; gap: .9rem; }
.ref-head .domain-tag {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--font-mono); font-size: .72rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3);
}
.ref-head .domain-tag i { width: .6rem; height: .6rem; display: inline-block; flex: none; }

.refdoc h2 {
  font-size: var(--step-2);
  margin-top: 1.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--rule-firm);
  scroll-margin-top: 6rem;
}
.refdoc h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.refdoc h3 {
  font-size: var(--step-1);
  margin-top: 2.2rem;
  scroll-margin-top: 6rem;
}
.refdoc h4 {
  font-family: var(--font-display);
  font-size: 1.06rem;
  font-weight: 620;
  letter-spacing: -.008em;
  margin-top: 2.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 6rem;
}
.refdoc h2 + h4, .refdoc h3 + h4 { border-top: 0; padding-top: .4rem; }
.refdoc p { max-width: var(--prose); color: var(--ink-2); margin-top: .8rem; }
.refdoc ul, .refdoc ol { max-width: var(--prose); color: var(--ink-2); margin: .8rem 0 0; padding-left: 1.3rem; display: flex; flex-direction: column; gap: .45rem; }
.refdoc li { padding-left: .2rem; }
.refdoc strong { color: var(--ink); font-weight: 600; }
.refdoc em { color: var(--ink-2); }

.refdoc .lead {
  font-family: var(--font-mono); font-size: .68rem; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3);
  display: inline-block; margin-right: .45rem;
}
.refdoc aside.mem {
  border-left: 2px solid var(--d-energy);
  background: var(--surface);
  border-top: 1px solid var(--rule); border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  padding: .85rem 1.1rem; margin-top: 1rem; max-width: var(--prose);
  font-size: .95rem; color: var(--ink-2); font-style: italic;
}
.refdoc aside.mem .lead { font-style: normal; display: block; margin-bottom: .3rem; }

.refdoc .tw { overflow-x: auto; margin-top: 1rem; border: 1px solid var(--rule); border-radius: 3px; background: var(--surface); }
.refdoc table { border-collapse: collapse; width: 100%; min-width: 34rem; font-size: .92rem; }
.refdoc th, .refdoc td { text-align: left; padding: .6rem .9rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.refdoc tr:last-child td { border-bottom: 0; }
.refdoc th {
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .09em;
  text-transform: uppercase; font-weight: 500; color: var(--ink-3);
  border-bottom: 1px solid var(--rule-firm); white-space: nowrap;
}
.refdoc td { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.refdoc td strong { color: var(--ink); }

.toc li.sub a { padding-left: 1.7rem; font-size: .85rem; }

/* hub cards */
.refs { display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); margin-top: 2.5rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .refs { grid-template-columns: 1fr 1fr; } }
.refcard { background: var(--surface); padding: clamp(1.4rem, 3vw, 2rem); display: flex; flex-direction: column; gap: .6rem; color: inherit; text-decoration: none; }
a.refcard:hover h3 { text-decoration: underline; text-underline-offset: .2em; }
.refcard .domain-tag { display: inline-flex; align-items: center; gap: .5rem; font-family: var(--font-mono); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.refcard .domain-tag i { width: .55rem; height: .55rem; display: inline-block; flex: none; }
.refcard h3 { font-size: 1.15rem; }
.refcard p { font-size: .95rem; color: var(--ink-2); }
.refcard .soon { font-family: var(--font-mono); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); border: 1px solid var(--rule-firm); border-radius: 2px; padding: .12rem .4rem; align-self: flex-start; }
.refcard--soon { opacity: .62; }

/* The same cards standing on a dark band \x{2014} the home closes on them. */
.band--deep .refs { background: var(--rule-deep); border-color: var(--rule-deep); }
.band--deep .refcard { background: var(--deep-surface); }
.band--deep .refcard h3 { color: var(--on-deep); }
.band--deep .refcard p { color: var(--on-deep-2); }
.band--deep .refcard .domain-tag, .band--deep .refcard .soon { color: var(--on-deep-3); }
.band--deep .refcard .soon { border-color: var(--rule-deep); }

/* Reference pages hold wide scrollable content (tables, diagrams); pin the
   page itself so sub-pixel rounding in those containers can never nudge the
   body sideways. */
.refdoc { overflow-x: clip; }

/* single-line diagrams and formulas in reference docs */
.refdoc pre.sld {
  font-family: var(--font-mono);
  font-size: .76rem;
  line-height: 1.5;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1rem 1.2rem;
  margin: 1rem 0 0;
  overflow-x: auto;
  white-space: pre;
  max-width: 100%;
}

/* --------------------------------------------------------------------------
   15. Reference diagrams — the Perrette single-line language
   -------------------------------------------------------------------------- */
.dgfig .fig__body svg { min-width: var(--dg-minw, 520px); }
.dg-box   { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.dg-plant { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.dg-zone  { fill: var(--sunk); stroke: var(--ink); stroke-width: 1.5; }
.dg-lab   { font-family: var(--font-mono); font-size: 13px; letter-spacing: .06em; fill: var(--ink); }
.dg-sub   { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .02em; fill: var(--ink-3); }
.dg-note  { font-family: var(--font-mono); font-size: 11px; letter-spacing: .02em; fill: var(--ink-3); }
.dg-lane  { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; fill: var(--ink-3); }
.dg-lanerule { stroke: var(--rule-firm); stroke-width: 1; }
.dg-line  { stroke-width: 2; }
.dg-flab  { font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em; }

.dg-air { stroke: var(--ink-2); }        .f-airm { fill: var(--ink-2); }   .dg-air-t { fill: var(--ink-2); }
.dg-oa  { stroke: var(--ink-3); }        .f-oam  { fill: var(--ink-3); }   .dg-oa-t  { fill: var(--ink-3); }
.dg-chw { stroke: var(--d-vent); }       .f-chwm { fill: var(--d-vent); }  .dg-chw-t { fill: var(--d-vent); }
.dg-hw  { stroke: var(--d-fire); }       .f-hwm  { fill: var(--d-fire); }  .dg-hw-t  { fill: var(--d-fire); }
.dg-cw  { stroke: var(--d-carbon); }     .f-cwm  { fill: var(--d-carbon); }.dg-cw-t  { fill: var(--d-carbon); }
.dg-ref { stroke: var(--d-optim); }      .f-refm { fill: var(--d-optim); } .dg-ref-t { fill: var(--d-optim); }

/* ladder navigation between fiches */
.ladder {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  margin-top: .9rem; padding: .6rem .9rem;
  border: 1px solid var(--rule); border-radius: 3px; background: var(--surface);
  font-family: var(--font-display); font-size: .85rem; flex-wrap: wrap;
}
.ladder a { color: var(--ink-2); text-decoration: none; }
.ladder a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: .2em; }
.ladder .ladder__all {
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3);
}

/* strengths / trade-offs inside fiches */
.refdoc .split.pc { margin-top: 1rem; }
.refdoc .split.pc ul { margin: 0; padding: 0; list-style: none; gap: .55rem; }
.refdoc .split.pc li { font-size: .93rem; }
.pc-note {
  font-family: var(--font-mono); font-size: .74rem; color: var(--ink-3);
  margin-top: .6rem; letter-spacing: .01em;
}

/* --------------------------------------------------------------------------
   16. Tools page — each tool on its own terms
   -------------------------------------------------------------------------- */
.tools { margin-top: 2.5rem; border-top: 1px solid var(--rule-firm); }
.tool { display: grid; grid-template-columns: 1fr; gap: .6rem; padding: 1.5rem 0; border-bottom: 1px solid var(--rule); }
@media (min-width: 860px) { .tool { grid-template-columns: 13rem minmax(0, 1fr); gap: 1.5rem; align-items: baseline; } }
.tool > * { min-width: 0; }
.tool__name { font-family: var(--font-display); font-weight: 580; font-size: 1.02rem; color: var(--ink); display: flex; align-items: baseline; gap: .6rem; }
.tool__name i { width: .7rem; height: .7rem; flex: none; display: block; }
/* Geometry is not one of the eight, so it carries no domain colour. */
.tool__dot--shared { background: transparent; box-shadow: inset 0 0 0 1.5px var(--rule-firm); }
.tool__q { color: var(--ink-2); font-size: .99rem; max-width: 54ch; }
.tool__terms { display: grid; grid-template-columns: 1fr; gap: .85rem 1.75rem; margin-top: .95rem; }
@media (min-width: 640px) { .tool__terms { grid-template-columns: 1fr 1fr; } }
.tool__term { font-size: .93rem; color: var(--ink-2); }
.tool__label { display: block; font-family: var(--font-mono); font-size: .64rem; letter-spacing: .11em; text-transform: uppercase; color: var(--ink-3); margin-bottom: .2rem; }

/* --------------------------------------------------------------------------
   17. Article index — one row per article, published or announced
   -------------------------------------------------------------------------- */
.index { margin-top: 2.5rem; border-top: 1px solid var(--rule-firm); }
.entry { display: grid; grid-template-columns: 1fr; gap: .5rem; padding: 1.6rem 0; border-bottom: 1px solid var(--rule); }
@media (min-width: 860px) { .entry { grid-template-columns: 11rem minmax(0, 1fr); gap: 1.5rem; align-items: baseline; } }
.entry > * { min-width: 0; }
.entry__meta { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .11em; text-transform: uppercase; color: var(--ink-3); }
.entry h3 { font-size: 1.2rem; max-width: 34ch; }
.entry p { color: var(--ink-2); font-size: .97rem; max-width: var(--prose); margin-top: .6rem; }
.entry__parts { margin-top: 1rem; }
.entry__parts li { font-size: .95rem; }
.entry__note { font-family: var(--font-mono); font-size: .74rem; color: var(--ink-3); letter-spacing: .02em; margin-top: 1rem; }
