:root {
  font: 16px/1.45 Arial, Helvetica, sans-serif;
  color: #19352f;
  background: #f5f5ee;
  --green: #146b56;
  --orange: #b55727;
  --muted: #566961;
  --line: #d6ded5;
  --cream: #fafaf5;
  --blue: #3b6fa0;
}
* { box-sizing: border-box; }
body { max-width: 1540px; margin: 0 auto; padding: 24px 32px; }
h1, h2, h3, p, figure { margin: 0; }
h1 { font: 700 clamp(28px, 3.2vw, 44px)/1.12 Georgia, serif; margin: 10px 0; }
h2 { font-size: 17px; line-height: 1.3; }
h3 { font-size: 19px; }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input { font: inherit; }
button { padding: 7px 11px; border: 1px solid var(--line); background: white; border-radius: 7px; color: inherit; cursor: pointer; line-height: 1.2; }
button:hover { border-color: var(--green); background: #edf5ef; }
button[aria-pressed="true"], button.primary { background: var(--green); color: white; border-color: var(--green); }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 3px solid #388978; outline-offset: 3px; }
[hidden] { display: none !important; }
.site-header { display: flex; justify-content: space-between; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.page-title { margin: 26px 0; }
.page-title > p:last-child { color: var(--muted); }
.eyebrow { font-size: 12px; letter-spacing: 1.3px; color: var(--orange); font-weight: 700; }
.tabs { display: flex; gap: 7px; align-items: center; margin-bottom: 13px; }
.tabs button { font-weight: 600; padding: 10px 14px; white-space: nowrap; }
.expand { margin-left: auto; font-size: 14px; }
.lab-shell { display: grid; grid-template-columns: 265px minmax(0, 1fr); gap: 12px; min-height: 0; }
.controls, .results { background: white; border: 1px solid var(--line); border-radius: 12px; min-width: 0; height: 550px; }
.controls { padding: 16px; overflow: auto; scrollbar-width: thin; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.section-heading button { font-size: 13px; padding: 5px 8px; }
.formula { padding: 9px 11px; background: #edf4ee; border-radius: 7px; font-size: 16px; line-height: 1.5; margin: 12px 0; }
.controls > .formula { font-size: 14px; padding: 8px; white-space: nowrap; }
.controls label { display: block; margin-top: 11px; }
.controls label b { font-family: Georgia, serif; font-style: italic; }
.controls output { float: right; font-variant-numeric: tabular-nums; font-weight: 600; }
input[type="range"] { width: 100%; display: block; accent-color: var(--green); height: 20px; cursor: pointer; margin: 4px 0; }
.presets { display: flex; gap: 6px; margin-top: 12px; }
.presets button { font-size: 14px; flex: 1; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 11px; }
.measurement-controls { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; }
.measurement-controls h2 { font-size: 16px; }
.measurement-controls button { margin-top: 10px; width: 100%; }
details { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
summary { cursor: pointer; font-size: 14px; font-weight: 600; }
#input-moments { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-top: 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
#input-moments span { display: flex; justify-content: space-between; }
.results { display: flex; flex-direction: column; overflow: hidden; }
.result-heading { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.result-heading a { font-size: 13px; white-space: nowrap; }
.result-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, .94fr); gap: 0; flex: 1; min-height: 0; }
.plots-column { display: grid; grid-template-rows: 1fr 1fr; min-width: 0; min-height: 0; padding: 10px 12px; gap: 14px; }
figure { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
figcaption { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.canvas-wrap { position: relative; flex: 1; min-height: 110px; }
canvas { display: block; width: 100%; height: 100%; }
.legend { font-size: 12px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; align-items: center; min-height: 22px; }
.legend > span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; height: 3px; width: 17px; background: var(--green); }
.legend .orange { background: var(--orange); }
.legend .blue { background: var(--blue); }
.legend .dashed { height: 0; border-top: 2px dashed var(--orange); background: transparent; }
.inspector { border-left: 1px solid var(--line); padding: 12px 14px; overflow: auto; scrollbar-width: thin; }
.inspector h3 { font-size: 16px; margin-bottom: 8px; }
.inspector p { margin: 8px 0; }
.inspector .formula { margin: 8px 0; font-size: 15px; padding: 8px 10px; }
.inspector .note { font-size: 13px; color: var(--muted); line-height: 1.4; }
.matrix-labels { display: flex; justify-content: space-between; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 5px; border-bottom: 1px solid #e5eae3; text-align: right; white-space: nowrap; }
th { color: var(--muted); background: var(--cream); font-weight: 600; }
th:first-child, td:first-child { text-align: left; }
table.matrix { font: 13px/1.4 Menlo, Consolas, monospace; }
.matrix td { padding: 6px 3px; }
.matrix th { font: 12px Arial, sans-serif; padding: 4px 3px; }
.matrix .rhs { border-left: 2px solid #c6d9cc; color: var(--green); font-weight: 600; padding-left: 8px; }
.table-scroll { overflow: auto; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 10px 0; }
.metrics > div { padding: 8px 9px; background: #f0f5ee; border-radius: 7px; min-width: 0; }
.metrics span { display: block; font-size: 12px; color: var(--muted); }
.metrics strong { font: 600 16px/1.5 Menlo, Consolas, monospace; white-space: nowrap; }
.parameters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.parameters > div { text-align: center; background: #f5f5ee; border-radius: 5px; padding: 6px 2px; }
.parameters span { display: block; color: var(--muted); font-size: 12px; }
.parameters strong { font-variant-numeric: tabular-nums; font-size: 15px; }
.step { margin: 11px 0 14px; }
.step-title { color: var(--green); font-size: 14px; font-weight: 700; }
.step .formula { overflow-wrap: anywhere; }
.unchanged { color: var(--muted); }
.scope { font-size: 13px; color: var(--muted); padding: 10px 13px; background: #e8f0e6; border-left: 3px solid var(--green); margin-top: 12px; }
.scope.error { background: #fff0e9; border-left-color: var(--orange); }
.explanation { margin-top: 36px; }
.explanation > h2 { font: 700 28px/1.3 Georgia, serif; margin-bottom: 20px; }
.explanation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px 34px; }
.explanation article p { margin-top: 10px; color: var(--muted); }
footer { display: flex; justify-content: space-between; gap: 20px; padding-top: 20px; border-top: 1px solid var(--line); margin-top: 34px; font-size: 13px; color: var(--muted); }
.embedded body { max-width: none; height: 100dvh; display: flex; flex-direction: column; padding: 8px; gap: 8px; }
.embedded .site-header, .embedded .page-title, .embedded .explanation, .embedded footer { display: none; }
.embedded .tabs { margin: 0; flex-shrink: 0; }
.embedded .tabs button { padding: 7px 11px; font-size: 15px; }
.embedded .lab-shell { flex: 1; grid-template-columns: 250px minmax(0, 1fr); gap: 8px; }
.embedded .controls, .embedded .results { height: 100%; }
.embedded .controls { padding: 12px; }
.embedded .controls > .formula { font-size: 13px; margin: 9px 0; }
.embedded .controls label { margin-top: 9px; }
.embedded .controls .hint { margin-top: 9px; }
.embedded .result-heading { padding: 9px 12px; }
.embedded .result-heading h2 { font-size: 16px; }
.embedded .plots-column { padding: 8px 10px; gap: 8px; }
.embedded .canvas-wrap { min-height: 80px; }
.embedded .inspector { padding: 9px 11px; }
.embedded .scope { margin: 0; padding: 6px 10px; flex-shrink: 0; font-size: 12px; }
.embedded .result-grid { grid-template-columns: minmax(0, 1fr) minmax(305px, .94fr); }
.lab-update .controls > label, .lab-update .controls > input, .lab-update #shape-description { display: none; }
.lab-update .controls > .presets { margin-top: 8px; }
.lab-update .measurement-controls { margin-top: 10px; padding-top: 10px; }
@media (max-width: 980px) {
  body { padding: 20px; }
  .lab-shell { grid-template-columns: 245px minmax(0, 1fr); }
  .result-grid { grid-template-columns: 1fr; overflow: auto; }
  .plots-column { min-height: 340px; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
  .inspector { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .result-heading { align-items: start; }
  .embedded .result-grid { grid-template-columns: 1fr; }
  .embedded .plots-column { min-height: 190px; }
  .embedded .result-heading a { font-size: 12px; }
}
@media (max-width: 680px) {
  body { padding: 14px; }
  .site-header { font-size: 13px; }
  .tabs { flex-wrap: wrap; }
  .tabs button { flex: 1; padding: 8px 7px; font-size: 13px; }
  .expand { display: none; }
  .lab-shell, .embedded .lab-shell { grid-template-columns: 1fr; }
  .controls, .results { height: auto; }
  .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 18px; overflow: visible; }
  .controls > * { grid-column: 1/-1; }
  .controls > label { grid-column: 1; margin-top: 6px; }
  .controls > input { grid-column: 2; margin-top: 6px; }
  .controls .presets { margin-top: 9px; }
  .controls .measurement-controls { margin-top: 8px; padding-top: 10px; }
  .controls .provenance { margin-top: 6px; }
  .results { overflow: visible; }
  .result-heading { flex-direction: column; gap: 4px; }
  .plots-column { min-height: 400px; grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .canvas-wrap { min-height: 140px; }
  .explanation-grid { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
  .embedded body { height: auto; min-height: 100dvh; }
  .embedded .controls, .embedded .results { height: auto; }
  .embedded .tabs button { font-size: 13px; padding: 7px 6px; }
  .embedded .plots-column { min-height: 400px; }
  .embedded .scope { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
@media print { .controls, .tabs, .site-header { display: none; } .lab-shell { display: block; } body { padding: 0; background: white; } .results { height: auto; } .result-grid { overflow: visible; } .plots-column { min-height: 420px; } }
