:root {
  --night: #08131a;
  --night-soft: #10242d;
  --paper: #f8f1df;
  --paper-soft: #d7d4c8;
  --mint: #83d0b7;
  --blue: #83b6d1;
  --amber: #dfaa55;
  --line: #29434f;
  --dark-ink: #173443;
}

* { box-sizing: border-box; }
html { color-scheme: dark; scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--paper);
  background:
    radial-gradient(circle at 15% 0%, rgba(47, 105, 119, .38), transparent 38rem),
    radial-gradient(circle at 90% 55%, rgba(223, 170, 85, .13), transparent 32rem),
    var(--night);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.6;
}

a { color: var(--mint); text-underline-offset: .2em; }
a:hover { color: var(--amber); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

main, footer { width: min(76rem, calc(100% - 2rem)); margin: 0 auto; }
main { padding: 2rem 0 6rem; }
.back { display: inline-block; margin-bottom: 3rem; font-size: .88rem; }
.hero { max-width: 64rem; padding: 5rem 0 2rem; }
.eyebrow {
  margin: 0 0 .8rem;
  color: var(--amber);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
h1, h2, h3 { font-family: "Iowan Old Style", Georgia, serif; line-height: 1.08; }
h1 { max-width: 13ch; margin: 0 0 1.3rem; font-size: clamp(3.3rem, 10vw, 7.2rem); font-weight: 500; letter-spacing: -.045em; }
h2 { margin: 0 0 .75rem; font-size: clamp(2rem, 5vw, 3.4rem); }
h3 { margin: 0 0 .55rem; font-size: 1.35rem; }
p { margin: 0 0 1.15rem; }
.lead { max-width: 46rem; color: var(--paper-soft); font: 1.35rem/1.6 "Iowan Old Style", Georgia, serif; }
.boundary {
  max-width: 60rem;
  padding: 1rem 1.2rem;
  border-left: 3px solid var(--amber);
  color: var(--paper-soft);
  background: rgba(16, 36, 45, .72);
}
.no-script { width: min(76rem, calc(100% - 2rem)); margin: 1rem auto 0; }
.thread {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .4rem;
  margin: 2.5rem 0 0;
  padding: 0;
  list-style: none;
}
.thread li { padding: .65rem .8rem; border-top: 1px solid var(--line); color: var(--paper-soft); font-size: .82rem; }
.thread strong { display: block; color: var(--paper); font-size: 1rem; }
.lab-section { margin: 6rem 0; }
.section-intro { max-width: 52rem; margin-bottom: 2rem; }
.instrument {
  display: grid;
  grid-template-columns: minmax(17rem, .8fr) minmax(20rem, 1.2fr);
  gap: 1rem;
}
.panel {
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: rgba(16, 36, 45, .78);
  box-shadow: 0 1.4rem 4rem rgba(0, 0, 0, .18);
}
.control { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; margin: 0 0 1.25rem; }
.control label { font-weight: 700; }
.control output { color: var(--amber); font-variant-numeric: tabular-nums; }
.control input { grid-column: 1 / -1; width: 100%; accent-color: var(--mint); }
.hint { color: var(--paper-soft); font-size: .82rem; }
.plot { min-height: 15rem; margin: 0 0 1rem; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.plot path:not(.axis) { fill: none; stroke-width: 4; stroke-linecap: round; }
.plot .axis { fill: none; stroke: #506874; stroke-width: 1; }
.plot text { fill: var(--paper-soft); font: 12px ui-sans-serif, system-ui, sans-serif; }
.plot .series-label { fill: var(--paper); font-weight: 800; }
.numbers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; margin: 0 0 1rem; }
.number { padding: .8rem; border: 1px solid var(--line); border-radius: .75rem; }
.number span { display: block; color: var(--paper-soft); font-size: .73rem; text-transform: uppercase; letter-spacing: .09em; }
.number strong { color: var(--mint); font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.meaning { margin: 0; color: var(--paper-soft); }
.equation { display: inline-block; padding: .25rem .55rem; border-radius: .4rem; background: #061017; color: var(--mint); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.cross-boundary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.cross-boundary article { padding: 1.2rem; border-top: 2px solid var(--blue); background: rgba(16, 36, 45, .56); }
.lab-local { max-width: 52rem; margin-top: 1rem; }
.karma-form { display: grid; gap: 1rem; }
select, textarea {
  width: 100%;
  padding: .8rem;
  border: 1px solid var(--line);
  border-radius: .6rem;
  color: var(--paper);
  background: #071219;
  font: inherit;
}
textarea { min-height: 6rem; resize: vertical; }
button {
  justify-self: start;
  padding: .75rem 1rem;
  border: 1px solid var(--mint);
  border-radius: 999px;
  color: var(--night);
  background: var(--mint);
  font: 750 .9rem/1 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
}
button.secondary { color: var(--paper); background: transparent; border-color: var(--line); }
.trace { max-height: 30rem; overflow: auto; padding: 1rem; border: 1px solid var(--line); border-radius: .75rem; background: #061017; color: var(--paper-soft); white-space: pre-wrap; }
.principles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.principles article { padding: 1.4rem; border: 1px solid var(--line); border-radius: 1rem; }
.principles article:last-child { border-color: var(--amber); }
.receipt { overflow-wrap: anywhere; color: var(--paper-soft); font-size: .86rem; }
footer { padding: 2rem 0; border-top: 1px solid var(--line); color: var(--paper-soft); font-size: .85rem; }

@media (max-width: 48rem) {
  .thread { grid-template-columns: 1fr 1fr; }
  .instrument, .cross-boundary, .principles { grid-template-columns: 1fr; }
  .numbers { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
