:root {
  color-scheme: light;
  --paper: #f6f3e9;
  --white: #fffefa;
  --ink: #142e26;
  --muted: #486157;
  --pine: #173c32;
  --line: #cdd6c7;
  --accent: #f8da91;
  --serif: Georgia, 'Times New Roman', serif;
  font: 16px/1.55 system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
p, h1, h2, h3 { margin: 0; }
button, select, textarea { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; }
button, .primary, select { min-height: 44px; }
a { color: inherit; text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid #ba652f; outline-offset: 3px; }
.visually-hidden, .skip:not(:focus) {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.skip:focus { position: fixed; top: .5rem; left: .5rem; z-index: 2; padding: .65rem; background: var(--white); }
.mast, body > footer {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .45rem 1.6rem;
  padding: .65rem max(1rem, calc((100% - 76rem) / 2));
  background: var(--pine); color: #fcf9eb;
}
.mast nav { display: flex; flex-wrap: wrap; gap: .15rem 1.4rem; }
.mast nav a, body > footer > a { display: inline-flex; align-items: center; min-height: 44px; }
.brand { font: 1.3rem var(--serif); text-decoration: none; white-space: nowrap; letter-spacing: -.02em; }
.brand span { color: var(--accent); font-style: italic; }
.mast nav a { font-size: .88rem; }
main { width: min(76rem, calc(100% - 3.5rem)); margin-inline: auto; }
.intro { padding: clamp(2.65rem, 5vw, 4.5rem) 0 clamp(1.8rem, 3.3vw, 2.8rem); }
.eyebrow { font-size: .77rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; }
.intro h1, .guide h1 { margin: .45rem 0 .72rem; font-size: clamp(3.2rem, 7.5vw, 6.6rem); line-height: .96; letter-spacing: -.062em; }
.intro em { font-weight: 400; color: #466754; }
.intro > p:last-child { max-width: 58ch; color: var(--muted); font-size: clamp(1rem, 1.65vw, 1.15rem); }
.lab { scroll-margin-top: .8rem; }
.case-tabs {
  display: flex; flex-wrap: wrap; gap: .45rem; border-top: 1px solid var(--line);
  padding: .8rem 0;
}
.case-tabs button {
  border: 1px solid #aabdaf; border-radius: 99rem; background: transparent; padding: .5rem .94rem;
  font-size: .9rem; font-weight: 650;
}
.case-tabs button:hover { background: #e7ecdf; }
.case-tabs button[aria-pressed=true] { color: var(--white); background: var(--pine); border-color: var(--pine); }
.case-tabs #open-custom { margin-inline-start: auto; border-style: dashed; }
.custom {
  max-width: 45rem; padding: 1rem 1.2rem; margin: .25rem 0 1rem;
  border: 1px solid var(--line); border-radius: .45rem; background: var(--white);
}
.custom label { display: block; font-weight: 680; }
.custom p { font-size: .87rem; color: var(--muted); }
.custom textarea {
  display: block; width: 100%; margin: .65rem 0; padding: .6rem; resize: vertical;
  border: 1px solid #9bac9f; border-radius: .3rem; background: #fbfbf5;
}
.custom .error { color: #9a3228; margin-top: .7rem; font-weight: 650; }
.lab-grid { display: grid; grid-template-columns: minmax(0, 2.45fr) minmax(15.5rem, 1fr); gap: .75rem; align-items: stretch; }
.chart-sheet, .controls { border-radius: .55rem; min-width: 0; }
.chart-sheet { background: var(--white); border: 1px solid var(--line); padding: clamp(.9rem,2vw,1.55rem); }
.sheet-heading { display: flex; justify-content: space-between; align-items: start; flex-wrap: wrap; gap: .75rem 1rem; }
.sheet-heading > div { flex: 1 1 18rem; }
.sheet-heading h2, .controls h2, .readout h2, .lesson h2 { font-size: clamp(1.65rem, 3vw, 2.15rem); line-height: 1.05; letter-spacing: -.032em; }
.sheet-heading p, .chart-text, .readout > p { color: var(--muted); font-size: .88rem; margin-top: .4rem; }
.scale { display: grid; gap: .17rem; font-size: .73rem; color: var(--muted); }
.scale select { max-width: 100%; border: 1px solid #aabdaf; border-radius: .32rem; background: #fbfcf7; padding: .31rem .56rem; font-size: .84rem; }
.chart-key { display: flex; gap: .25rem 1rem; flex-wrap: wrap; margin: 1.15rem 0 .55rem; color: var(--muted); font-size: .79rem; }
.chart-key span { display: inline-flex; align-items: center; gap: .34rem; }
.model-mark { display: inline-block; width: 1rem; vertical-align: .22em; border-top: 2px dashed #b64f31; }
.model-mark.actual { width: .48rem; height: .48rem; border-radius: 50%; border: 0; background: var(--ink); }
.model-mark.linear { border-color: #7c482a; }
.model-mark.exponential { border-color: #215f88; }
.model-mark.plateau { border-color: #4e3b89; border-top-style: dotted; }
.canvas-wrap { background: #f9faf4; border: 1px solid #e2e8dc; border-radius: .3rem; }
#chart { display: block; width: 100%; height: clamp(235px, 32vw, 365px); }
.chart-text { min-height: 2.7em; }
.controls {
  display: flex; flex-direction: column; gap: .53rem; padding: clamp(1.05rem, 2vw, 1.55rem);
  background: var(--pine); color: #fafff0;
}
.controls h2 { margin-bottom: .28rem; }
.controls :focus-visible { outline-color: var(--accent); }
.range-label { display: flex; justify-content: space-between; gap: .5rem; font-size: .85rem; font-weight: 650; }
.range-label output { color: var(--accent); white-space: nowrap; }
.controls input[type=range] { width: 100%; min-height: 27px; margin: 0; accent-color: var(--accent); cursor: pointer; }
#split, .result-live { color: #daeadf; font-size: .81rem; }
.controls fieldset { min-width: 0; margin: .55rem 0 0; padding: .3rem 0 0; border: 0; }
.controls legend { font-size: .89rem; font-weight: 650; }
#model-options { display: grid; gap: .36rem; }
.model-option {
  display: flex; align-items: center; gap: .54rem; border: 1px solid #66877a;
  border-radius: .32rem; min-height: 47px; padding: .34rem .55rem; font-size: .89rem;
}
.model-option:has(input:enabled) { cursor: pointer; }
.model-option:has(input:checked) { border-color: var(--accent); background: #2c5042; }
.model-option:has(input:disabled):not(:has(input:checked)) { opacity: .78; }
.model-option input { margin: 0; accent-color: var(--accent); }
.model-option small { display: block; color: #d5e6dc; line-height: 1.18; font-size: .73rem; }
.model-option .model-mark, .model-card .model-mark { margin-right: .35rem; }
.controls .linear { border-color: #f6a584; }
.controls .exponential { border-color: #b9b6fd; }
.controls .plateau { border-color: #8fddc6; }
.button-row { display: flex; gap: .55rem; flex-wrap: wrap; }
.action-row { margin-top: .44rem; }
.primary, .secondary {
  display: inline-flex; justify-content: center; align-items: center; text-align: center;
  border: 1px solid transparent; border-radius: .32rem; padding: .56rem .75rem; font-weight: 700; text-decoration: none;
}
.primary { background: var(--accent); color: #253823; }
.primary:hover { background: #ffe7aa; }
.action-row .primary { width: 100%; }
.secondary { background: transparent; border-color: #9bac9f; }
.result-live { min-height: 2.75em; }
.readout { margin: 1.65rem 0 2.15rem; }
.model-readout { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .65rem; margin-top: .75rem; }
.model-card { padding: .84rem .9rem; background: var(--white); border: 1px solid var(--line); border-radius: .4rem; }
.model-card.best { background: #e6eedf; border-color: #829e82; }
.model-card h3 { font-size: 1.3rem; }
.model-card p { color: var(--muted); font-size: .82rem; margin-top: .14rem; }
.model-card .error-value { margin-top: .55rem; }
.error-value strong { color: var(--ink); font-size: 1.24rem; font-variant-numeric: tabular-nums; }
.model-card .best-label { color: #30503d; font-weight: 700; }
.detail-table { margin-top: .65rem; }
.detail-table summary { padding: .6rem 0; width: fit-content; font-weight: 650; }
.table-wrap { overflow: auto; }
table { width: 100%; min-width: 28rem; border-collapse: collapse; font-size: .84rem; font-variant-numeric: tabular-nums; }
caption { text-align: start; color: var(--muted); padding-bottom: .3rem; }
th, td { padding: .4rem .5rem; text-align: right; border-bottom: 1px solid var(--line); }
th:first-child { text-align: left; }
.test-row { background: #eaede8; }
.tester { color: var(--muted); font-size: .73rem; }
.lesson { padding: 1.1rem 0 2.85rem; border-top: 1px solid var(--line); }
.lesson p { max-width: 66ch; color: var(--muted); margin: .5rem 0; }
.lesson a { font-size: .9rem; font-weight: 650; }
.guide { width: min(43rem, calc(100% - 3.5rem)); padding-block: clamp(2.6rem, 8vw, 6rem); }
.guide h1 { font-size: clamp(3.1rem, 8vw, 5.4rem); }
.guide-lede { font-size: 1.17rem; }
.guide h2 { margin: 1.7rem 0 .4rem; font-size: 1.62rem; }
.guide ol { padding-left: 1.5rem; }
.guide li { margin: .4rem 0; }
.sources { margin: 1.7rem 0 1rem; padding-top: .8rem; border-top: 1px solid var(--line); color: var(--muted); }
.guide-action { width: fit-content; }
@media (max-width: 800px) {
  main, .guide { width: calc(100% - 2rem); }
  .lab-grid { grid-template-columns: minmax(0,1fr); }
  .case-tabs #open-custom { margin-inline-start: 0; }
  #chart { height: clamp(250px, 50vw, 350px); }
}
@media (max-width: 495px) {
  .mast { padding-top: .45rem; padding-bottom: .45rem; }
  .mast nav { gap: .15rem .75rem; }
  .intro h1, .guide h1 { font-size: clamp(2.8rem, 11vw, 3.6rem); }
  .case-tabs button { font-size: .8rem; padding-inline: .68rem; }
  .model-readout { grid-template-columns: minmax(0,1fr); }
  .chart-text { min-height: auto; }
}
