/* 1. Fonts */

@font-face {
  font-family: "AHN";
  src: url("../fonts/ahn-var.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "AHN";
  src: url("../fonts/ahn-italic-var.woff2") format("woff2");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "AHM";
  src: url("../fonts/ahm-var.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/source-serif-4.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/source-serif-4-italic.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "LM Math";
  src: url("../fonts/lm-math.woff2") format("woff2");
  font-display: swap;
}

/* 2. Tokens */

:root {
  --paper: #ffffff;
  --ink: #121212;
  --ink-2: #555a60;
  --ink-3: #8a8f96;
  --a: #121212;
  --b: #1f3fbf;
  --alarm: #b3261e;
  --field: #eef0f3;
  --field-hover: #e4e7ec;
  --wash-b: #e8ecfa;

  --s-1: 0.8rem;
  --s0: 1rem;
  --s1: 1.25rem;
  --s2: 1.5625rem;
  --s3: 1.953rem;
  --s4: 2.441rem;
  --s5: 3.052rem;
  --s6: 4.768rem;

  --lead: 1.55;
  --measure: 36rem;
  --margin-col: 17rem;
  --gap: 3rem;
  --gutter: clamp(1.25rem, 7vw, 9rem);
  --v1: 0.75rem;
  --v2: 1.5rem;
  --v3: 3rem;
  --v4: 6rem;

  --text: "AHN", system-ui, sans-serif;
  --mono: "AHM", ui-monospace, monospace;
  --serif: "Source Serif 4", Georgia, serif;
  --math: "LM Math", "Latin Modern Math", "STIX Two Math", math;
}

/* 3. Base */

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

[hidden] {
  display: none !important;
}

html {
  font-size: clamp(17px, 15.5px + 0.25vw, 20px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: var(--s0);
  line-height: var(--lead);
  font-kerning: normal;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

h2 {
  font-size: var(--s2);
  margin: var(--v4) 0 var(--v1);
}

h3 {
  font-size: var(--s1);
  margin: var(--v3) 0 var(--v1);
}

p,
ul,
ol,
figure,
blockquote {
  margin: 0 0 var(--v2);
}

p {
  text-wrap: pretty;
  hyphens: manual;
}

ul,
ol {
  padding-left: 1.25em;
}

li + li {
  margin-top: 0.4em;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--ink-3);
}

a:hover {
  color: var(--b);
  text-decoration-color: currentColor;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--b);
  outline-offset: 2px;
}

em {
  font-style: italic;
}

strong {
  font-weight: 700;
}

p strong,
li strong,
dd strong {
  font-weight: inherit;
  color: var(--b);
}

abbr {
  text-decoration: none;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.04em;
}

code,
kbd,
samp,
.num {
  font-family: var(--mono);
  font-size: 0.92em;
  font-variant-numeric: tabular-nums slashed-zero;
}

math {
  font-family: var(--math);
  font-size: 1.2em;
}

::selection {
  background: var(--wash-b);
}

/* 4. Page frame */

.site {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) minmax(0, auto) minmax(max-content, 1fr);
  align-items: center;
  gap: 1.5rem;
  min-height: 3.5rem;
  padding: 0.5rem var(--gutter);
  font-family: var(--mono);
  font-size: var(--s-1);
}

.site a {
  text-decoration: none;
}

.site a:hover {
  text-decoration: underline;
}

.site [aria-current] {
  color: var(--ink-3);
}

.site.on-cover .home {
  color: var(--ink);
}

.site .home {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-weight: 700;
  justify-self: start;
}

.mark {
  width: 1.5em;
  height: 1.5em;
  flex: none;
}

main {
  padding: var(--v4) var(--gutter) var(--v4);
}

[id] {
  scroll-margin-top: 4.5rem;
}

.text {
  max-width: var(--measure);
  margin-inline: auto;
}

/* 5. Chapter opening */

.opening {
  margin-bottom: var(--v4);
}

.chapter-no {
  display: block;
  font-family: var(--mono);
  font-weight: 200;
  font-size: var(--s6);
  line-height: 1;
  color: var(--b);
  font-variant-numeric: tabular-nums slashed-zero;
  margin-bottom: var(--v2);
}

.opening h1 {
  font-size: clamp(var(--s4), 2rem + 2.4vw, var(--s6));
  line-height: 1.02;
  letter-spacing: -0.025em;
  max-width: 14ch;
  margin: 0 0 var(--v2);
}

.standfirst {
  font-size: var(--s1);
  line-height: 1.45;
  color: var(--b);
  max-width: 30rem;
}

.claim {
  font-size: var(--s1);
  font-weight: 600;
  line-height: 1.35;
  color: var(--b);
  max-width: 30ch;
  margin: var(--v2) 0;
}

/* 6. The maths: closed by default, opened on demand, in the reading column */

.maths {
  font-size: var(--s-1);
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0 0 var(--v2);
}

.maths summary {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-height: 2.75rem;
  cursor: pointer;
  list-style: none;
  background: var(--field);
  font-family: var(--text);
  font-size: var(--s0);
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  user-select: none;
}

.maths[open] + .maths {
  margin-top: var(--v2);
}

.maths summary::-webkit-details-marker {
  display: none;
}

.maths summary::before {
  content: "∑";
  flex: 0 0 2.75rem;
  align-self: stretch;
  display: grid;
  place-items: center;
  padding-bottom: 0.27em;
  background: var(--b);
  color: var(--paper);
  font-family: var(--serif);
  font-size: var(--s1);
  font-weight: 400;
}

.maths.settings summary::before {
  content: "≡";
  font-family: var(--text);
}

.maths summary::after {
  content: "";
  flex: 0 0 2.75rem;
  align-self: stretch;
  margin-inline-start: auto;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23121212' stroke-width='1.6'/%3E%3C/svg%3E") center / 0.75rem no-repeat;
  transition: transform 200ms ease-out;
}

.maths[open] summary::after {
  transform: rotate(180deg);
}

.maths summary:hover {
  background: var(--field-hover);
}

.maths[open] summary {
  margin-bottom: var(--v2);
}

.maths[open] > :not(summary) {
  padding-left: 0.8rem;
  animation: reveal 240ms ease-out both;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(-0.4rem);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .maths[open] > :not(summary) {
    animation: none;
  }
}

.maths p,
.maths ul {
  margin-bottom: var(--v1);
}

.maths p,
.maths li {
  font-family: var(--serif);
  font-size: var(--s0);
  line-height: 1.5;
  color: var(--ink);
}

.maths math {
  color: var(--ink);
}

.maths math[display="block"] {
  margin: var(--v1) 0;
  overflow-x: auto;
  overflow-y: hidden;
}



/* 7. Figures and interactives */

figure {
  margin: var(--v3) 0;
}

figcaption {
  font-size: var(--s-1);
  color: var(--ink-2);
  margin-top: var(--v1);
  max-width: var(--measure);
}

figcaption b {
  color: var(--ink);
}

canvas,
svg.chart {
  display: block;
  width: 100%;
  height: auto;
}

.key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  font-family: var(--mono);
  font-size: var(--s-1);
  margin-top: var(--v1);
}

.key span {
  white-space: nowrap;
}

.key .a {
  color: var(--a);
}

.key .b {
  color: var(--b);
}

.key .alarm {
  color: var(--alarm);
}

.key span::before {
  content: "";
  display: inline-block;
  width: 1.25em;
  height: 3px;
  background: currentColor;
  vertical-align: middle;
  margin-right: 0.4em;
}

/* 8. Controls (boxes only for things you can click) */

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12.5rem, 1fr));
  gap: var(--v2) 1.25rem;
  margin: var(--v2) 0 var(--v3);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field > span:first-child {
  font-size: var(--s-1);
  color: var(--ink-2);
  line-height: 1.3;
}

input,
select,
button {
  font: inherit;
  color: inherit;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: var(--field);
  padding: 0.55rem 0.7rem;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums slashed-zero;
}

input[type="number"],
input[type="text"] {
  -webkit-appearance: none;
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0h10L5 6z' fill='%23121212'/%3E%3C/svg%3E");
  background-position: right 0.75rem center;
  background-size: 0.6rem 0.36rem;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

select::-ms-expand {
  display: none;
}

input:hover,
select:hover {
  background-color: var(--field-hover);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--b);
}

button,
a.button {
  display: inline-block;
  border: 0;
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-family: var(--mono);
  font-size: var(--s-1);
  line-height: 1.3;
  text-decoration: none;
}

button:hover,
a.button:hover {
  background: var(--b);
  color: var(--paper);
}

button.quiet {
  background: var(--field);
  color: var(--ink);
}

button.quiet:hover {
  background: var(--field-hover);
}

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.seg label {
  cursor: pointer;
}

.seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.seg span {
  display: block;
  background: var(--field);
  padding: 0.55rem 0.8rem;
  font-family: var(--mono);
  font-size: var(--s-1);
}

.seg label:hover span {
  background: var(--field-hover);
}

.seg input:checked + span {
  background: var(--ink);
  color: var(--paper);
}

.seg input:focus-visible + span {
  outline: 2px solid var(--b);
  outline-offset: 2px;
}

/* 9. Results */

.result {
  margin: var(--v3) 0;
}

.big {
  font-family: var(--mono);
  font-weight: 300;
  font-size: clamp(var(--s3), 1.4rem + 1.2vw, var(--s4));
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums slashed-zero;
  margin: 0 0 var(--v1);
}

.big small {
  display: block;
  margin-top: 0.4rem;
  line-height: 1.4;
  font-family: var(--text);
  font-size: var(--s0);
  font-weight: 400;
  letter-spacing: 0;
  color: var(--ink-2);
}

.readout {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: var(--v2) 2rem;
  margin: var(--v2) 0 var(--v3);
}

.readout.rows {
  grid-template-columns: 1fr;
}

.readout div {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
}

.readout dt {
  font-size: var(--s-1);
  color: var(--ink-2);
}

.readout dd {
  margin: 0;
  font-family: var(--mono);
  font-size: var(--s2);
  font-variant-numeric: tabular-nums slashed-zero;
  line-height: 1.2;
}

.verdict {
  font-size: var(--s1);
  font-weight: 500;
  line-height: 1.4;
  max-width: var(--measure);
}

.alarm {
  color: var(--alarm);
}

.is-b {
  color: var(--b);
}

.note {
  font-size: var(--s-1);
  color: var(--ink-2);
  max-width: var(--measure);
}

table {
  border-collapse: collapse;
  font-variant-numeric: tabular-nums slashed-zero;
  margin: 0 0 var(--v2);
}

th,
td {
  text-align: right;
  padding: 0.35rem 1.25rem 0.35rem 0;
  vertical-align: baseline;
}

th:first-child,
td:first-child {
  text-align: left;
}

thead th {
  font-weight: 400;
  font-size: var(--s-1);
  color: var(--ink-2);
}

tbody td {
  font-family: var(--mono);
  font-size: 0.92em;
}

a.term {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--ink-3);
  text-underline-offset: 0.2em;
}

a.term:hover {
  text-decoration-color: currentColor;
}

.glossary > div {
  scroll-margin-top: 5rem;
}

table.facts td {
  font-family: inherit;
  font-size: inherit;
  text-align: left;
}

table.facts td:last-child {
  font-family: var(--mono);
  font-size: 0.92em;
  text-align: right;
  padding-right: 0;
}

table.facts th {
  text-align: left;
}

table.facts th:last-child {
  text-align: right;
  padding-right: 0;
}

table.facts td[rowspan] {
  color: var(--ink-2);
}

.scroll-x {
  position: relative;
  overflow-x: auto;
}

/* 10. Contents and lists of chapters */

.toc {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--v4);
}

.toc li {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  column-gap: 0.5rem;
  margin: 0 0 var(--v2);
}

.toc .no {
  font-family: var(--mono);
  font-weight: 200;
  font-size: var(--s3);
  line-height: 1;
  color: var(--b);
  font-variant-numeric: tabular-nums slashed-zero;
}

.toc .t {
  font-size: var(--s1);
  font-weight: 700;
  line-height: 1.25;
}

.toc .t a {
  text-decoration: none;
}

.toc .t a:hover {
  text-decoration: underline;
}

.toc .d {
  grid-column: 2;
  color: var(--ink-2);
  font-size: var(--s0);
  max-width: 34rem;
}

.in-chapter {
  margin: 0 0 var(--v3);
}

.in-chapter ol {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: sec;
}

.in-chapter li {
  counter-increment: sec;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.5rem;
  margin: 0 0 0.35rem;
  font-size: var(--s-1);
  line-height: 1.35;
}

.in-chapter li::before {
  content: counter(sec, decimal-leading-zero);
  font-family: var(--mono);
  color: var(--b);
}

.in-chapter a {
  color: var(--ink);
  text-decoration: none;
}

.in-chapter a:hover {
  color: var(--b);
  text-decoration: underline;
}

.toc .soon .no,
.toc .soon .t {
  color: var(--ink-3);
}

.toc .soon .t::after {
  content: "in writing";
  display: block;
  font-family: var(--mono);
  font-weight: 400;
  font-size: var(--s-1);
}

.part {
  font-family: var(--mono);
  font-size: var(--s-1);
  font-weight: 700;
  color: var(--ink-2);
  margin: 0 0 var(--v2);
}

.cover h1 {
  font-size: clamp(var(--s5), 2rem + 5vw, 7.5rem);
  line-height: 0.95;
  letter-spacing: -0.035em;
  margin: 0 0 var(--v2);
  max-width: 9ch;
}

.motto {
  font-size: var(--s3);
  line-height: 1.2;
  letter-spacing: -0.015em;
  max-width: 22ch;
  margin: 0 0 var(--v1);
}

.motto .is-b {
  display: block;
}

.attribution {
  max-width: 34ch;
  font-size: var(--s-1);
  line-height: 1.45;
  color: var(--ink-2);
  text-wrap: balance;
  margin-bottom: var(--v4);
}

/* 11. Chapter end */

.sources {
  font-size: var(--s-1);
  color: var(--ink-2);
  margin-top: var(--v4);
}

.sources h2 {
  font-size: var(--s0);
  color: var(--ink);
  margin: 0 0 var(--v1);
}

.sources li {
  margin-bottom: 0.5em;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--v2) 2rem;
  margin-top: var(--v4);
  max-width: var(--measure);
}

.pager a {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  font-size: var(--s1);
  font-weight: 700;
  line-height: 1.25;
  max-width: 16rem;
}

.pager a span {
  font-family: var(--mono);
  font-size: var(--s-1);
  font-weight: 400;
  color: var(--ink-2);
}

.pager a:last-child {
  text-align: right;
  margin-left: auto;
}

.pager a:hover {
  color: var(--b);
}

footer.site-foot {
  padding: 0 var(--gutter) var(--v3);
  font-size: var(--s-1);
  color: var(--ink-2);
}

footer.site-foot p {
  margin: 0;
}

/* 12. Print */

@media print {
  .site,
  .pager,
  .controls,
  button {
    display: none;
  }

  main {
    padding: 0;
  }
}

/* 13. Utilities and tool specifics */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

table.inputs td {
  padding: 0.25rem 0.5rem 0.25rem 0;
}

table.inputs input {
  min-width: 6rem;
}

table.inputs tbody th {
  font-weight: 400;
  padding-right: 1rem;
  white-space: nowrap;
}

.muted {
  opacity: 0.45;
}

.arm-result + .arm-result {
  margin-top: var(--v3);
}

[data-widget] {
  margin: var(--v3) 0;
}

.cycle {
  position: relative;
  aspect-ratio: 1;
  max-width: 34rem;
  margin: 0 auto;
}

.cycle svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.cycle ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.cycle li {
  position: absolute;
  width: 46%;
  margin: 0;
  text-align: center;
  font-size: clamp(0.72rem, 3vw, var(--s-1));
  line-height: 1.35;
  color: var(--ink-2);
  text-wrap: balance;
}

.cycle li b {
  display: block;
  font-size: clamp(0.75rem, 3.6vw, var(--s1));
  line-height: 1.2;
  color: var(--ink);
}

.cycle li.q b {
  color: var(--b);
}

.cycle .n {
  top: 0;
  left: 27%;
}

.cycle .s {
  bottom: 0;
  left: 27%;
}

.cycle .e {
  top: 50%;
  right: 0;
  width: 30%;
  transform: translateY(-50%);
}

.cycle .w {
  top: 50%;
  left: 0;
  width: 30%;
  transform: translateY(-50%);
}

.cycle .hub {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34%;
  transform: translate(-50%, -50%);
  margin: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--ink-3);
}


sub,
sup {
  font-size: max(12px, 0.8em);
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sup {
  top: -0.45em;
}

sub {
  bottom: -0.25em;
}

.hint {
  font-size: var(--s-1);
  line-height: 1.4;
  color: var(--ink-3);
}

.maths.settings {
  font-size: var(--s0);
  color: var(--ink);
  margin-bottom: var(--v3);
}

.maths.settings p,
.maths.settings li {
  font-family: var(--text);
}

.maths.settings[open] > :not(summary) {
  padding-left: 0;
}

.advice li {
  max-width: var(--measure);
}

.meter {
  height: 0.75rem;
  background: var(--field);
  margin: var(--v1) 0 var(--v2);
}

.meter span {
  display: block;
  height: 100%;
  background: var(--b);
  transform-origin: left center;
  transition: transform 200ms ease-out;
}

.steps {
  list-style: none;
  padding: 0;
  counter-reset: step;
  margin: var(--v3) 0;
}

.steps > li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  column-gap: 0.5rem;
  margin: 0 0 var(--v2);
}

.steps > li::before {
  content: counter(step, decimal-leading-zero);
  font-family: var(--mono);
  font-weight: 200;
  font-size: var(--s3);
  line-height: 1;
  color: var(--b);
}

.steps b {
  display: block;
  font-size: var(--s1);
  line-height: 1.25;
}

.steps p {
  grid-column: 2;
  margin: 0.25rem 0 0;
  color: var(--ink-2);
}

.steps .k {
  display: block;
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--b);
}

.stages {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--v2) 2rem;
  margin: var(--v3) 0;
}

.stages h3 {
  margin: 0 0 0.25rem;
  color: var(--b);
}

.stages p {
  margin: 0 0 0.5rem;
  color: var(--ink-2);
}


.template {
  font-family: var(--mono);
  font-size: var(--s-1);
  line-height: 1.6;
  padding-left: 1.25rem;
  white-space: pre-wrap;
  margin: var(--v2) 0;
}

@media (prefers-reduced-motion: reduce) {
  .meter span {
    transition: none;
  }
}

.said {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.1em;
  line-height: 1.4;
}

.hyp {
  max-width: var(--measure);
  margin: var(--v1) 0 var(--v3);
  font-family: var(--serif);
  font-size: calc(var(--s1) * 1.08);
  line-height: 1.5;
}

.hyp .part {
  display: inline;
  font: inherit;
  color: inherit;
  margin: 0;
  letter-spacing: normal;
  text-transform: none;
}

.hyp b {
  font-family: var(--serif);
  font-weight: 400;
  color: var(--ink);
}

.hyp i {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  color: var(--b);
}

.examples h4 {
  font-size: var(--s0);
  margin: var(--v3) 0 var(--v1);
}

.hypothesis-out {
  max-width: var(--measure);
}

.controls.stack {
  grid-template-columns: 1fr;
  max-width: var(--measure);
}

input[type="text"] {
  font-family: var(--text);
}

.credits {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--v2);
}

.credits li {
  margin: 0 0 var(--v1);
}

.credits span {
  display: block;
  font-weight: 700;
}

.byline {
  font-family: var(--mono);
  font-size: var(--s0);
  color: var(--ink);
  margin: 0 0 var(--v2);
}

.rates {
  list-style: none;
  padding: 0;
  margin: 0;
}

.rates li {
  display: grid;
  grid-template-columns: 8rem 1fr;
  grid-template-areas: "who v" "track track";
  column-gap: 1rem;
  margin: 0 0 var(--v1);
}

.rates .who {
  grid-area: who;
}

.rates .v {
  grid-area: v;
  text-align: right;
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--ink-2);
}

.rates .track {
  grid-area: track;
  display: block;
  height: 1.1rem;
  background: var(--field);
  margin-top: 0.2rem;
}

.rates .track span {
  display: block;
  height: 100%;
  background: var(--b);
}

.key.squares span::before {
  width: 0.8em;
  height: 0.8em;
  vertical-align: -0.05em;
}

.key .field {
  display: inline;
  color: var(--ink-2);
}

.key .field::before {
  background: var(--field) !important;
}

.key .missed {
  color: var(--b);
}

.key .missed::before {
  background: transparent !important;
  box-shadow: inset 0 0 0 1.5px var(--b);
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--v2) 1.5rem;
  margin: var(--v2) 0;
}

.split h3 {
  margin: 0 0 0.25rem;
  font-size: var(--s0);
}

.split .is-b {
  color: var(--b);
}

.split p {
  white-space: pre-line;
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--ink-2);
  margin: var(--v1) 0 0;
}

.dots {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 0.7rem));
  grid-auto-rows: auto;
  align-content: start;
  gap: 3px;
  min-height: calc(5 * 0.7rem + 4 * 3px);
}

.dot {
  aspect-ratio: 1;
  background: var(--field);
}

.dot.is-ret {
  background: var(--ink);
}

[data-group="B"] .dot.is-ret {
  background: var(--b);
}

.dot.is-left {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--alarm);
  opacity: 0.6;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: var(--v1) 0;
}

button[aria-pressed="false"] {
  background: var(--field);
  color: var(--ink);
}

button[aria-pressed="false"]:hover {
  background: var(--field-hover);
}

button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.learned {
  margin-top: var(--v4);
}

.learned h2 {
  margin: 0 0 var(--v2);
  font-family: var(--mono);
  font-size: var(--s-1);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--b);
}

.learned ul {
  list-style: none;
  padding: 0;
  counter-reset: learned;
}

.learned li {
  counter-increment: learned;
  position: relative;
  padding-left: 2.5rem;
  margin-bottom: var(--v2);
  font-size: var(--s1);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.005em;
}

.learned li::before {
  content: counter(learned, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0.28em;
  line-height: calc(1.35 * var(--s1));
  font-family: var(--mono);
  font-size: var(--s-1);
  font-weight: 700;
  color: var(--b);
}

.names {
  margin: var(--v2) 0;
}

.names div {
  margin: 0 0 var(--v1);
}

.names dt {
  font-weight: 700;
}

.names dd {
  margin: 0;
  color: var(--ink-2);
}

.dots.trig {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  gap: 3px;
  max-width: 28rem;
  margin: var(--v2) 0 var(--v1);
}

.dots.trig .dot {
  width: auto;
  height: auto;
  aspect-ratio: 1;
}

.dot.is-trig {
  background: var(--b);
}

.stepper {
  display: grid;
  grid-template-columns: 2.4rem 1fr 2.4rem;
  gap: 0.5rem;
  align-items: center;
}

.stepper button {
  padding: 0;
  height: 2.4rem;
  font-size: var(--s1);
  line-height: 1;
}

.field b[data-out] {
  font-family: var(--mono);
  font-weight: 400;
  color: var(--ink);
}

.cases-plot {
  --text-col: 15rem;
  --col-gap: 1.5rem;
  margin: var(--v2) 0;
}

.cases {
  list-style: none;
  padding: 0;
  margin: 0;
}

.cases li {
  display: grid;
  grid-template-columns: var(--text-col) minmax(0, 1fr);
  gap: 0 var(--col-gap);
  margin: 0;
}

.case-text {
  padding: var(--v1) 0;
}

.case-text b {
  display: block;
  line-height: 1.3;
}

.case-text .nums {
  display: block;
  margin-top: 0.2rem;
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--ink);
}

.case-text .tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.8rem;
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--ink-2);
}

.case-text .tags {
  flex-direction: column;
}

.case-text .what {
  display: block;
  margin-top: 0.3rem;
  font-size: var(--s-1);
  line-height: 1.4;
  color: var(--ink-2);
}

.cases .track,
.anatomy .track {
  position: relative;
  display: block;
  min-height: 1.6rem;
}

.cases .zero,
.cases .worth,
.anatomy .zero,
.anatomy .worth {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 1.5px dashed var(--ink-3);
}

.cases .worth,
.anatomy .worth {
  border-left: 1.5px solid var(--b);
  opacity: 0.5;
}

.cases .ci,
.anatomy .ci {
  position: absolute;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  background: var(--ink);
}

.cases .pt,
.anatomy .pt {
  position: absolute;
  top: 50%;
  width: 0.75rem;
  height: 0.75rem;
  margin: -0.375rem 0 0 -0.375rem;
  border-radius: 50%;
  background: var(--ink);
}

.cases .b,
.anatomy .b {
  background: var(--b);
}

.cases .alarm {
  background: var(--alarm);
}

.cases-plot .axis,
.cases-head {
  margin-left: calc(var(--text-col) + var(--col-gap));
}

.axis,
.cases-head,
.anat-top,
.anat-ends {
  position: relative;
  height: 1.4rem;
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--ink-2);
}

.axis span,
.cases-head span,
.anat-top span,
.anat-ends span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}

.axis span:first-child {
  transform: none;
}

.axis span:last-child {
  transform: translateX(-100%);
}

.cases-plot .axis span,
.anatomy .axis span {
  transform: translateX(-50%);
}

.axis .z {
  color: var(--ink);
  font-weight: 700;
}

.axis .w {
  color: var(--b);
  font-weight: 700;
}

.cases-head {
  height: 2.6rem;
}

.cases-head .zero-l {
  transform: translateX(-100%);
  padding-right: 0.4rem;
}

.cases-head .worth-l {
  transform: none;
  padding-left: 0.4rem;
  color: var(--b);
}

.anatomy {
  margin: var(--v2) 0 var(--v1);
}

.anatomy .track {
  min-height: 2.2rem;
}

.anat-top span {
  color: var(--b);
  font-weight: 700;
}

.anat-key {
  margin-top: var(--v2);
}

@media (max-width: 640px) {
  .cases li {
    grid-template-columns: 1fr;
  }

  .case-text {
    padding-bottom: 0.3rem;
  }

  .cases .track {
    margin-bottom: var(--v1);
  }

  .cases-plot .axis,
  .cases-head {
    margin-left: 0;
  }

  .cases-head {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1rem;
    height: auto;
    margin-bottom: var(--v1);
  }

  .cases-head span,
  .cases-head .zero-l,
  .cases-head .worth-l {
    position: static;
    transform: none;
    padding: 0;
  }
}

.rungs {
  list-style: none;
  padding: 0;
  margin: var(--v3) 0;
}

.rungs li {
  display: grid;
  grid-template-columns: 3rem 1fr;
  column-gap: 0.75rem;
  margin: 0 0 var(--v3);
}

.rungs .lvl {
  font-family: var(--mono);
  font-weight: 200;
  font-size: var(--s4);
  line-height: 1;
  color: var(--b);
  opacity: calc(0.25 + var(--level) * 0.1875);
}

.rungs h3 {
  margin: 0 0 0.25rem;
}

.rungs p {
  margin: 0 0 0.4rem;
}

.rungs .eg {
  color: var(--ink);
}

.rungs .meter {
  height: auto;
  background: none;
  margin: 0.5rem 0 0;
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--ink-2);
}

.rungs .meter span {
  display: block;
  height: 0.5rem;
  margin-bottom: 0.3rem;
  background: linear-gradient(to right, var(--b) calc(var(--level) * 25%), var(--field) calc(var(--level) * 25%));
}

@media (min-width: 900px) {
  .rungs li {
    margin-left: calc((var(--level) - 1) * 1.5rem);
  }
}

textarea {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: var(--field);
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-family: var(--text);
  color: inherit;
  resize: vertical;
}

textarea:hover {
  background-color: var(--field-hover);
}

textarea:focus-visible {
  outline: 2px solid var(--b);
  outline-offset: 2px;
}

.examples dd {
  color: var(--ink);
}

.prereg dl {
  margin: var(--v2) 0;
}

.prereg dl > div {
  display: grid;
  grid-template-columns: 1fr;
  margin: 0 0 var(--v1);
}

.prereg dt {
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--b);
}

.prereg dd {
  margin: 0;
}

@media (min-width: 640px) {
  .prereg dl > div {
    grid-template-columns: 10rem 1fr;
    column-gap: 1.5rem;
  }

  .prereg dt {
    padding-top: 0.2em;
  }
}

.catalogue {
  margin: var(--v3) 0;
}

.catalogue > div {
  margin-bottom: var(--v3);
}

.catalogue h3 {
  margin: 0;
  font-size: var(--s1);
}

.catalogue .role {
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--b);
  margin: 0.2rem 0 var(--v1);
}

.catalogue dl {
  margin: 0;
}

.catalogue dl > div {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 0 1rem;
  align-items: baseline;
  margin: 0 0 0.35rem;
}

.catalogue dt {
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--ink-2);
}

.catalogue dl > div:first-child dt,
.catalogue dl > div:first-child dd {
  color: var(--ink);
  font-weight: 600;
}

.catalogue dd {
  margin: 0;
  color: var(--ink);
}

table.roles {
  width: 100%;
  table-layout: fixed;
}

table.roles th:first-child {
  width: 34%;
}

table.roles th,
table.roles td {
  text-align: center;
  padding: 0.45rem 0.2rem;
}

table.roles thead th {
  font-size: var(--s-1);
  white-space: nowrap;
}

table.roles tbody th {
  text-align: left;
  font-weight: 400;
  padding-right: 0.75rem;
}

@media (max-width: 640px) {
  table.roles {
    min-width: 34rem;
  }
}

.role-dot {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  vertical-align: middle;
}

.role-dot.lead {
  background: var(--b);
}

.role-dot.helps {
  box-shadow: inset 0 0 0 1.5px var(--b);
}

.maturity li {
  grid-template-columns: 5rem 1fr;
}

/* 15. Pre-registration sheet */

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.sheet {
  max-width: 46rem;
  margin: var(--v3) auto 0;
}

.sheet-kicker {
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--b);
  margin: 0 0 var(--v1);
}

.sheet label {
  display: block;
}

.sheet label > span {
  display: block;
  font-size: var(--s-1);
  color: var(--ink-2);
  margin-bottom: 0.25rem;
}

.sheet textarea {
  display: block;
  width: 100%;
  min-height: 2.4rem;
  padding: 0.45rem 0.6rem;
  border: 0;
  border-radius: 0;
  background: var(--field);
  font-family: var(--text);
  font-size: var(--s0);
  line-height: 1.4;
  color: var(--ink);
  resize: none;
  overflow: hidden;
}

.sheet textarea[rows="2"] {
  min-height: 3.8rem;
}

.sheet textarea:focus {
  outline: 2px solid var(--b);
  outline-offset: 0;
  background: var(--paper);
}

.sheet textarea::placeholder {
  color: var(--ink-3);
}

.sheet-title textarea {
  font-size: var(--s2);
  font-weight: 700;
  min-height: 3rem;
}

.sheet-row,
.sheet-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--v1) 1rem;
  margin-top: var(--v1);
}

.sheet-row,
.sheet-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sheet-grid .sheet-wide {
  grid-column: 1 / -1;
}

.sheet section {
  margin-top: var(--v3);
}

.sheet h2 {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: var(--s1);
  margin: 0 0 var(--v1);
}

.sheet h2 span {
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--b);
}

.sheet-hyp label {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.4rem;
}

.sheet-hyp b {
  font-family: var(--mono);
  font-size: var(--s-1);
  font-weight: 400;
  color: var(--b);
  text-align: right;
}

.sheet-hyp textarea {
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--s1);
}

.sheet > section > .sheet-wide {
  margin-top: var(--v1);
}

.sheet-after h2 {
  color: var(--ink-2);
}

@media (max-width: 600px) {
  .sheet-row,
  .sheet-grid,
  .sheet-grid.three {
    grid-template-columns: 1fr;
  }

  .sheet-hyp label {
    display: block;
  }

  .sheet-hyp b {
    display: block;
    text-align: left;
    margin-bottom: 0.25rem;
  }
}

@media print {
  @page {
    size: A4;
    margin: 12mm 14mm;
  }

  html {
    font-size: 8.5pt;
  }

  .sheet textarea:focus {
    outline: 0;
    background: var(--field);
  }

  body:has(.sheet) .opening,
  body:has(.sheet) .sheet-actions,
  body:has(.sheet) .hint,
  body:has(.sheet) .site-foot {
    display: none;
  }

  .sheet {
    max-width: none;
    margin: 0;
  }

  .sheet section {
    margin-top: 0.9rem;
    break-inside: avoid;
  }

  .sheet h2 {
    margin-bottom: 0.4rem;
  }

  .sheet-row,
  .sheet-grid {
    gap: 0.5rem 0.8rem;
    margin-top: 0.4rem;
  }

  .sheet textarea {
    min-height: 1.6rem;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .sheet textarea::placeholder {
    color: transparent;
  }

  .sheet textarea[rows="2"] {
    min-height: 2.8rem;
  }

  .sheet-row,
  .sheet-grid,
  .sheet-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sheet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sheet-hyp label {
    display: grid;
    grid-template-columns: 9rem 1fr;
    margin-bottom: 0.2rem;
  }

  .sheet-hyp b {
    display: block;
    text-align: right;
  }
}

/* 16. Chapter 0: hero picture, what an experiment needs */

.hero-art {
  max-width: 40rem;
  margin: 0 auto var(--v1);
}

.hero-top {
  display: block;
  width: 100%;
  height: auto;
}

.hero-top.m {
  display: none;
}

.hero-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 1rem;
}

.hero-row figure {
  margin: 0;
  padding: 0 4%;
}

.hero-row svg {
  display: block;
  width: 100%;
  height: auto;
}

.hero-row figcaption {
  margin-top: 0.5rem;
  text-align: center;
  font-weight: 700;
  font-size: var(--s0);
  color: var(--ink);
}

.hero-row .is-b figcaption {
  color: var(--b);
}

.hero-mid {
  margin: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: var(--s-1);
  line-height: 1.6;
  color: var(--ink-2);
}

.hero-mid b {
  display: block;
  margin-top: 0.6rem;
  color: var(--b);
}

@media (max-width: 560px) {
  .hero-top.d {
    display: none;
  }

  .hero-top.m {
    display: block;
  }

  .hero-row {
    grid-template-columns: 1fr 1fr;
  }

  .hero-row figure {
    padding: 0 4%;
  }

  .hero-mid {
    grid-row: 2;
    grid-column: 1 / -1;
  }
}

var {
  font-family: var(--serif);
  font-size: 1.1em;
}

.needs {
  list-style: none;
  padding: 0;
  margin: var(--v2) 0 var(--v3);
  counter-reset: needs;
}

.needs li {
  counter-increment: needs;
  position: relative;
  padding-left: 2.5rem;
  margin-bottom: var(--v2);
}

.needs li::before {
  content: counter(needs);
  position: absolute;
  left: 0;
  top: -0.1em;
  font-family: var(--mono);
  font-size: var(--s3);
  font-weight: 200;
  line-height: 1;
  color: var(--b);
}

.needs a {
  font-family: var(--mono);
  font-size: var(--s-1);
  white-space: nowrap;
}


/* 17. How to read a figure */

.howto {
  max-width: var(--measure);
  margin: 0 0 var(--v2);
  font-size: var(--s0);
  line-height: 1.5;
  color: var(--ink);
}

.howto b {
  display: block;
  margin-bottom: 0.25rem;
  font-family: var(--mono);
  font-size: var(--s-1);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--b);
}

.field-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.field-row b {
  font-family: var(--mono);
  font-weight: 400;
  color: var(--ink);
  white-space: nowrap;
}

[data-out="mde-abs"] {
  font-size: var(--s-1);
  color: var(--ink-2);
}

svg.chart {
  display: block;
  width: 100%;
  height: auto;
  margin: var(--v1) 0;
  font-family: var(--mono);
}

svg.chart .tick {
  font-size: 12px;
  fill: var(--ink-2);
}

svg.chart .val {
  font-size: 13px;
  font-weight: 700;
  fill: var(--ink);
}

svg.chart .bar {
  fill: var(--ink);
}

svg.chart .bar.alarm {
  fill: var(--alarm);
}

svg.chart .ref {
  stroke: var(--ink-3);
  stroke-dasharray: 3 4;
}

/* 18. Sample ratio gauge */

.gauge {
  --band-l: 40%;
  --band-r: 60%;
  --dot: 50%;
  margin: var(--v2) 0 var(--v1);
}

.gauge-track {
  position: relative;
  height: 2.5rem;
}

.gauge-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: var(--ink-3);
}

.gauge-band {
  position: absolute;
  top: 0.5rem;
  bottom: 0.5rem;
  left: var(--band-l);
  right: calc(100% - var(--band-r));
  background: var(--field);
}

.gauge-mid {
  position: absolute;
  left: 50%;
  top: 0.25rem;
  bottom: 0.25rem;
  width: 2px;
  margin-left: -1px;
  background: var(--ink);
}

.gauge-dot {
  position: absolute;
  left: var(--dot);
  top: 50%;
  width: 1rem;
  height: 1rem;
  margin: -0.5rem 0 0 -0.5rem;
  border-radius: 50%;
  background: var(--b);
}

.gauge.is-bad .gauge-dot {
  background: var(--alarm);
}

.gauge-scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--ink-2);
}

.gauge-key {
  margin: 0.25rem 0 0;
  text-align: center;
  font-size: var(--s-1);
  color: var(--ink-2);
}

.key .dashed::before {
  height: 0;
  border-top: 2px dashed currentColor;
  background: none;
}

.key + .verdict,
canvas + .verdict {
  margin-top: var(--v2);
}

.key.round span::before {
  border-radius: 50%;
}

/* 19. Cover: books and people */

.books {
  list-style: none;
  padding: 0;
  margin: var(--v2) 0 var(--v3);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
}

.books li {
  margin: 0;
  padding: 0;
}

.books a {
  display: block;
  color: var(--ink);
  text-decoration: none;
}

.books cite {
  display: block;
  margin-top: 0.6rem;
  font-style: normal;
  font-weight: 700;
  line-height: 1.25;
}

.books a:hover cite {
  color: var(--b);
}

.books .by {
  display: block;
  margin-top: 0.2rem;
  font-size: var(--s-1);
  color: var(--ink-2);
}

.bookcover {
  position: relative;
  display: block;
  aspect-ratio: 2 / 3;
  background: var(--field);
  overflow: hidden;
  transition: transform 200ms ease-out;
}

.books a:hover .bookcover {
  transform: translateY(-4px);
}



.bookcover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.people {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--v2);
}

.people li {
  margin-bottom: var(--v1);
}

.people b {
  font-weight: 700;
}

@media (max-width: 480px) {
  .books {
    gap: 0.8rem;
  }
}

/* 20. Interactive panels: one tinted box per widget, padding outside the text column */

:root {
  --panel: #f6f7f9;
  --bleed: clamp(1rem, 3vw, 2rem);
}

[data-widget]:not([data-widget="sheet"]) {
  background: var(--panel);
  margin-inline: calc(-1 * var(--bleed));
  padding: var(--v2) var(--bleed);
}

[data-widget] .howto {
  margin-bottom: var(--v2);
}

[data-widget] button.quiet,
[data-widget] button[aria-pressed="false"],
[data-widget] .seg span,
[data-widget] select,
[data-widget] input[type="number"],
[data-widget] input[type="text"],
[data-widget] textarea {
  background-color: var(--paper);
}

[data-widget] button.quiet:hover,
[data-widget] button[aria-pressed="false"]:hover,
[data-widget] .seg label:hover span {
  background-color: var(--field-hover);
}

[data-widget] .seg input:checked + span {
  background: var(--ink);
}

[data-widget] .dot:not([class*="is-"]) {
  background: var(--field-hover);
}

[data-widget] figcaption {
  margin-top: var(--v2);
}

[data-widget] > :last-child {
  margin-bottom: 0;
}

.toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: 0 0 var(--v2);
}

.toggle button,
.seg span {
  padding: 0.55rem 0.8rem;
  font-family: var(--mono);
  font-size: var(--s-1);
  line-height: 1.3;
}

.toggle button[aria-pressed="true"]:hover {
  background: var(--ink);
}

.cases .grid,
.anatomy .grid {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 1px solid var(--field-hover);
}

.axis-title {
  margin: 0.2rem 0 0;
  text-align: right;
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--ink-2);
}

.cases-plot .axis-title {
  margin-left: calc(var(--text-col) + var(--col-gap));
}

.cases li + li .case-text,
.cases li + li .track {
  border-top: 0;
}

@media (max-width: 640px) {
  .cases-plot .axis-title {
    margin-left: 0;
  }
}

.cases-head.static {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.5rem;
  height: auto;
  margin: 0 0 var(--v1);
}

.cases-head.static span,
.cases-head.static .zero-l,
.cases-head.static .worth-l {
  position: static;
  transform: none;
  padding: 0;
}

/* 21. Hypothesis builder */

.builder textarea {
  min-height: 2.6rem;
  resize: none;
  overflow: hidden;
  line-height: 1.45;
}

.builder-out {
  margin-top: var(--v3);
}

.ladder {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  list-style: none;
  padding: 0;
  margin: 0 0 var(--v1);
}

.ladder li {
  margin: 0;
  padding: 0 0 0.4rem;
  border-bottom: 4px solid var(--field-hover);
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--ink-3);
}

.ladder li.is-b {
  border-bottom-color: var(--b);
  color: var(--b);
}

.level {
  max-width: var(--measure);
  margin: 0 0 var(--v2);
  color: var(--ink-2);
}

.level b {
  color: var(--ink);
  font-weight: 700;
}

/* 22. Header: chapter title when stuck, contents menu */

.site-title {
  contain: layout paint;
  will-change: opacity, transform;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: var(--text);
  font-size: var(--s0);
  font-weight: 600;
  opacity: 0;
  transform: translateY(0.5rem);
}

.site-no {
  font-family: var(--mono);
  font-weight: 400;
  color: var(--b);
  margin-right: 0.4rem;
}

.menu-btn {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  background: transparent;
  color: var(--ink);
}

.menu-btn:hover {
  background: var(--field);
  color: var(--ink);
}

.burger {
  position: relative;
  display: inline-block;
  width: 1.1rem;
  height: 0.8rem;
}

.burger i {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: currentColor;
  transition: transform 200ms ease-out, opacity 200ms ease-out;
}

.burger i:nth-child(1) {
  top: 0;
}

.burger i:nth-child(2) {
  top: calc(50% - 1px);
}

.burger i:nth-child(3) {
  bottom: 0;
}

.site.is-open .burger i:nth-child(1) {
  transform: translateY(calc(0.4rem - 1px)) rotate(45deg);
}

.site.is-open .burger i:nth-child(2) {
  opacity: 0;
}

.site.is-open .burger i:nth-child(3) {
  transform: translateY(calc(-0.4rem + 1px)) rotate(-45deg);
}

.site-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: calc(100vh - 3.5rem);
  overflow-y: auto;
  padding: var(--v2) var(--gutter) var(--v3);
  background: var(--paper);
  font-family: var(--text);
  font-size: var(--s0);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-0.5rem);
  transition: opacity 200ms ease-out, transform 200ms ease-out, visibility 0s linear 200ms;
}

.site.is-open .site-menu {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 200ms ease-out, transform 200ms ease-out, visibility 0s;
}

.menu-cols {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--v2) 2rem;
}

.menu-part {
  margin: 0 0 var(--v1);
  font-family: var(--mono);
  font-size: var(--s-1);
  font-weight: 700;
  color: var(--ink-2);
}

.site-menu ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.site-menu li {
  margin: 0 0 0.5rem;
}

.site-menu li a {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.5rem;
  line-height: 1.35;
  text-decoration: none;
}

.site-menu li a:hover {
  color: var(--b);
  text-decoration: none;
}

.site-menu .no {
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--b);
  padding-top: 0.15em;
}

.site-menu [aria-current="page"] {
  color: var(--ink-3);
}

.site-menu .has-sections {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 0.5rem;
  align-items: start;
}

.sec-btn {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: var(--s0);
  line-height: 1;
}

.sec-btn::before {
  content: "+";
}

.sec-btn[aria-expanded="true"]::before {
  content: "−";
}

.sec-btn:hover {
  background: var(--field);
  color: var(--ink);
}

.site-menu .menu-sections {
  grid-column: 1 / -1;
  margin: 0.4rem 0 0.4rem 2.5rem;
  font-size: var(--s-1);
}

.site-menu .menu-sections li {
  margin: 0 0 0.3rem;
}

.site-menu .menu-sections a {
  display: block;
  color: var(--ink-2);
}

.menu-foot {
  margin: var(--v2) 0 0;
  font-size: var(--s-1);
}

.site-scrim {
  position: fixed;
  inset: 0;
  z-index: 15;
  background: rgba(255, 255, 255, 0.85);
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease-out, visibility 0s linear 200ms;
}

.menu-open .site-scrim {
  opacity: 1;
  visibility: visible;
  transition: opacity 200ms ease-out, visibility 0s;
}

@media (max-width: 900px) {
  .menu-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .site {
    gap: 0.75rem;
    padding-inline: 0.75rem;
  }

  .menu-btn {
    padding-inline: 0.4rem;
    margin-right: -0.4rem;
  }

  .site:not(.on-cover) .home-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .menu-label {
    display: none;
  }

  .menu-cols {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-title,
  .burger i,
  .site-menu,
  .site-scrim {
    transition: none;
  }
}

[data-widget] .key .field::before {
  background: var(--field-hover) !important;
}

svg.chart .grid {
  stroke: var(--field-hover);
}

svg.chart polyline[class] {
  fill: none;
  stroke-width: 2;
}

svg.chart .s-ink {
  stroke: var(--ink);
  fill: var(--ink);
}

svg.chart .s-b {
  stroke: var(--b);
  fill: var(--b);
}

svg.chart .s-grey {
  stroke: var(--ink-3);
  fill: var(--ink-3);
}

svg.chart text.lab {
  stroke: none;
  font-size: 12px;
}

.anat-ends span {
  color: var(--b);
}

.anatomy .worth {
  opacity: 1;
  border-left-width: 2px;
  border-left-style: dashed;
}

.widget-title {
  margin: 0 0 var(--v2);
  font-size: var(--s1);
}

@media screen {
  form.sheet {
    background: var(--panel);
    padding: var(--v2) var(--bleed) var(--v3);
  }
}

@media print {
  form.sheet textarea {
    background: var(--field);
  }
}

@media print {
  form.sheet textarea {
    height: 1.6rem !important;
  }

  form.sheet textarea[rows="2"] {
    height: 2.8rem !important;
  }

  .sheet-hyp label {
    grid-template-columns: 9rem 1fr;
    margin-bottom: 0.25rem;
  }

  .sheet-hyp textarea {
    font-size: var(--s0);
  }
}

@supports (grid-template-rows: subgrid) {
  .controls:not(.stack) {
    row-gap: 0;
  }

  .controls:not(.stack) > .field {
    display: grid;
    grid-row: span 3;
    grid-template-rows: subgrid;
    row-gap: 0.35rem;
    align-content: start;
    padding-bottom: var(--v2);
  }

  .controls:not(.stack) > .field > .hint {
    align-self: start;
  }
}

.sheet h2 {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  column-gap: 0.5rem;
  align-items: center;
  font-size: var(--s1);
  line-height: 1.25;
}

.sheet h2 span {
  font-family: var(--mono);
  font-weight: 200;
  font-size: var(--s3);
  line-height: 1;
  color: var(--b);
  font-variant-numeric: tabular-nums slashed-zero;
}

form.sheet textarea {
  font-size: var(--s-1);
}

form.sheet .sheet-hyp textarea {
  font-size: var(--s0);
}

form.sheet .sheet-title textarea {
  font-size: var(--s1);
  min-height: 2.6rem;
}

/* Product cycle bars (chapter 9) */

.cycle-label {
  display: flex;
  justify-content: space-between;
  margin: var(--v1) 0 0.35rem;
  font-size: var(--s-1);
  color: var(--ink-2);
}

.cycle-label b {
  font-family: var(--mono);
  font-weight: 400;
  color: var(--ink);
}

.cycle-bar {
  display: flex;
  height: 1.75rem;
}

.cycle-bar span {
  min-width: 0;
  box-shadow: inset -2px 0 0 var(--paper);
}

.seg-design {
  background: var(--ink);
}

.seg-build {
  background: var(--ink-3);
}

.seg-test {
  background: var(--b);
}

.seg-read {
  background: var(--field-hover);
}

.cycle-key span {
  color: var(--ink-2);
}

.cycle-key .k-design::before {
  background: var(--ink);
}

.cycle-key .k-build::before {
  background: var(--ink-3);
}

.cycle-key .k-test::before {
  background: var(--b);
}

.cycle-key .k-read::before {
  background: var(--field-hover);
}

.sprints .axis {
  margin-top: 0.35rem;
}

/* 25. Wireframes (chapter 10) */

.wires {
  display: grid;
  grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr));
  gap: var(--v1) 1rem;
  margin: var(--v1) 0;
}

.wires.two {
  --n: 2;
  max-width: 28rem;
}

.wires.three {
  --n: 3;
}

@media (max-width: 560px) {
  .wires,
  .wires.three {
    --n: 2;
  }
}

.wire {
  margin: 0;
}

.wire svg {
  display: block;
  width: 100%;
  height: auto;
  font-family: var(--mono);
}

.wire figcaption {
  margin-top: 0.4rem;
  font-size: var(--s-1);
  line-height: 1.35;
  color: var(--ink-2);
}

.wire figcaption b {
  display: block;
  font-family: var(--mono);
  color: var(--ink);
}

.wire figcaption b.is-b {
  color: var(--b);
}

.shows {
  margin-top: var(--v2);
  font-size: var(--s0);
  line-height: 1.5;
  color: var(--ink);
}

.shows b {
  display: block;
  margin-bottom: 0.25rem;
  font-family: var(--mono);
  font-size: var(--s-1);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--b);
}

.wf-frame {
  fill: var(--paper);
  stroke: var(--ink-3);
  stroke-width: 1;
}

.wf-block {
  fill: var(--field-hover);
}

.wf-x {
  stroke: var(--paper);
  stroke-width: 1;
}

.wf-new {
  fill: var(--wash-b);
  stroke: var(--b);
  stroke-width: 1.2;
}

.wf-x-new {
  stroke: var(--b);
  stroke-width: 0.8;
  opacity: 0.5;
}

.wf-line {
  fill: var(--field-hover);
}

.wf-line-new {
  fill: var(--b);
}

.wf-t {
  fill: var(--ink-2);
}

.wf-t-b {
  fill: var(--ink);
  font-weight: 700;
}

.wf-t-new {
  fill: var(--b);
}

.wf-new + .wf-t-light,
.wf-t-light {
  fill: var(--b);
}

.wf-btn {
  fill: var(--ink);
}

.wf-btn-new {
  fill: var(--b);
}

.wf-btn-ghost {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1;
}

.wf-bt {
  fill: var(--paper);
  font-weight: 700;
}

.wf-bt-ghost {
  fill: var(--ink);
  font-weight: 700;
}

.wf-dot {
  fill: var(--alarm);
}

.wf-dot-t {
  fill: var(--paper);
  font-weight: 700;
}

.wf-play {
  fill: var(--paper);
}

.wf-ring {
  fill: none;
  stroke: var(--b);
  stroke-width: 1.2;
  stroke-dasharray: 3 3;
}

.wf-btn-off {
  fill: var(--ink-3);
}

.wf-dark .wf-block,
.wf-dark .wf-line {
  fill: var(--paper);
  opacity: 0.8;
}

.wf-dark .wf-frame {
  stroke: none;
}

/* 26. Combination grid (chapter 10) */

.combo {
  width: 100%;
  max-width: 34rem;
  border-collapse: separate;
  border-spacing: 4px;
  table-layout: fixed;
  margin: var(--v1) 0;
  font-family: var(--mono);
  font-size: var(--s-1);
}

.combo th {
  padding: 0 0.5rem 0 0;
  vertical-align: middle;
  font-weight: 700;
  text-align: left;
  line-height: 1.2;
}

.combo thead th {
  padding: 0 0 0.25rem;
  font-weight: 400;
  color: var(--ink-2);
}

.combo col.lab {
  width: 6.25rem;
}

.combo td {
  padding: 0;
  background: var(--field);
}

.combo td svg {
  display: block;
  width: 100%;
  height: auto;
}

.combo td path {
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 1;
}

.combo td path.play {
  fill: var(--ink-3);
  stroke: none;
}

.combo thead td {
  background: none;
}

.combo td.was {
  background: var(--paper);
  box-shadow: inset 0 0 0 2px var(--ink);
}

.combo td.win {
  background: var(--b);
}

.combo td.win path {
  stroke: var(--paper);
}

.key .was::before {
  background: none;
  box-shadow: inset 0 0 0 2px var(--ink);
}

.wf-knob {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 1.2;
}

/* 27. Bell curves (chapter 3) */

svg.bells .pow {
  fill: var(--wash-b);
}

svg.bells .tail {
  fill: var(--alarm);
}

svg.bells .crit {
  stroke: var(--ink-3);
  stroke-width: 1.2;
  stroke-dasharray: 4 3;
}

svg.bells text.alarm {
  fill: var(--alarm);
  stroke: none;
}

svg.bells text.pw {
  font-weight: 700;
}

.cases .ci.open::after {
  content: "";
  position: absolute;
  right: -1px;
  top: 50%;
  border: 6px solid transparent;
  border-left-color: var(--ink);
  border-right-width: 0;
  transform: translateY(-50%);
}

svg.bells .crit.b {
  stroke: var(--b);
}

/* 28. The maths, slowly: a second reveal inside the first */

.maths .slow {
  margin: 0 0 var(--v2);
  border-left: 2px solid var(--b);
  padding-left: 0.8rem;
}

.maths .slow summary {
  display: block;
  min-height: 0;
  margin: 0;
  padding: 0.3rem 0;
  background: none;
  font-family: var(--mono);
  font-size: var(--s-1);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--b);
}

.maths .slow summary::before {
  content: "+ ";
  display: inline;
  padding: 0;
  background: none;
  color: inherit;
  font: inherit;
}

.maths .slow[open] summary::before {
  content: "− ";
}

.maths .slow summary::after {
  content: none;
}

.maths .slow summary:hover {
  background: none;
  text-decoration: underline;
}

.maths .slow[open] summary {
  margin-bottom: var(--v1);
}

.maths .slow p,
.maths .slow dd {
  font-family: var(--text);
  font-size: var(--s0);
  line-height: 1.5;
  color: var(--ink);
}

.maths .slow p b {
  display: block;
  font-family: var(--mono);
  font-size: var(--s-1);
  color: var(--ink-2);
}

.letters {
  margin: 0 0 var(--v1);
}

.letters div {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 0 0.75rem;
  margin: 0 0 0.5rem;
}

.letters dt {
  font-family: var(--math);
  font-size: var(--s1);
  line-height: 1.25;
  color: var(--b);
}

.letters dd {
  margin: 0;
}

/* 29. The coin (chapter 0) */

svg.toss {
  max-width: 28rem;
  margin: 0 0 var(--v1);
}

svg.toss .face {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 2;
}

svg.toss .edge {
  fill: var(--ink);
}

svg.toss .rim {
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 1;
}

svg.toss .b {
  stroke: var(--b);
}

svg.toss .side {
  font-family: var(--text);
  font-size: 20px;
  font-weight: 700;
  fill: var(--ink);
}

svg.toss .side.b {
  fill: var(--b);
  stroke: none;
}

svg.toss .arc {
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 1.5;
}

svg.toss .spin {
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 1.2;
  stroke-dasharray: 3 3;
}

/* 29. Figures drawn by scripts/figs.py */

svg.chart .who {
  fill: var(--ink-3);
}

svg.chart .who.a {
  fill: var(--ink);
}

svg.chart .who.b {
  fill: var(--b);
}

svg.chart .coin {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 1.5;
}

svg.chart .coin.b {
  stroke: var(--b);
}

svg.chart .side {
  font-size: 12px;
  font-weight: 700;
  fill: var(--ink);
}

svg.chart .side.b {
  fill: var(--b);
}

svg.chart .guide {
  stroke: var(--ink-3);
  stroke-width: 0.8;
  stroke-dasharray: 2 3;
}

svg.chart .sq-ret {
  fill: var(--ink);
}

svg.chart .sq-new {
  fill: var(--field-hover);
}

svg.chart .sq-buy {
  fill: var(--b);
}

svg.chart .live {
  fill: var(--field);
}

svg.chart .zone {
  fill: var(--wash-b);
}

svg.chart .pt-ink {
  fill: var(--ink);
}

svg.chart .pt-b {
  fill: var(--b);
}

svg.chart .pt-alarm {
  fill: var(--alarm);
}

svg.chart .axis-l {
  stroke: var(--ink-3);
}

svg.chart .span {
  stroke: var(--ink);
  stroke-width: 1.5;
}

svg.chart .crit {
  stroke: var(--ink-3);
  stroke-width: 1.2;
  stroke-dasharray: 4 3;
}

svg.chart .crit.b {
  stroke: var(--b);
}

svg.chart .obs {
  stroke: var(--alarm);
  stroke-width: 2;
}

svg.chart .bar-b {
  fill: var(--b);
}

svg.chart .bar-f {
  fill: var(--field-hover);
}

svg.chart .bar-alarm {
  fill: var(--alarm);
}

svg.chart text.alarm {
  fill: var(--alarm);
}

svg.chart polyline.none {
  stroke: none;
}

.wf-bt-sub {
  font-weight: 400;
}

.wf-fold {
  stroke: var(--alarm);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}

.wf-trig {
  fill: var(--alarm);
}

.wf-ret {
  fill: var(--ink);
}

/* 30. Section openings: the paragraph after a heading says what the section is about to do */

.lead {
  font-size: var(--s1);
  line-height: 1.45;
  color: var(--b);
  max-width: 34rem;
}
