:root {
  color-scheme: light;
  --bg: #edf2f6;
  --paper: #fff;
  --ink: #101e30;
  --muted: #41576d;
  --navy: #122b44;
  --line: #d3dee7;
  --line-strong: #a9bccd;
  --accent: #174fb8;
  --accent-soft: #e6effc;
  --mint: #5be2bb;
  --blue: #90b8ff;
  --amber: #ffd18e;
  --warn: #783f10;
  --warn-bg: #fff2da;
  --danger: #a41b22;
  --font: "Avenir Next", Avenir, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 1rem; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 1rem/1.55 var(--font); }
button, input, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button[disabled] { cursor: default; opacity: .55; }
button, input, select { min-width: 0; }
[hidden] { display: none !important; }
input, select, button { touch-action: manipulation; }
a { color: var(--accent); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: .125em; }
:focus-visible { outline: 3px solid #2c6ce1; outline-offset: 3px; }
h1, h2, h3, p, dl, figure { margin: 0; }
h1, h2, h3 { font-weight: 700; line-height: 1.12; letter-spacing: -.032em; }
h1 { font-size: clamp(2rem, 3.85vw, 3.35rem); text-wrap: balance; }
h2 { font-size: clamp(1.45rem, 2.5vw, 2.1rem); }
h3 { font-size: 1.18rem; }
p + p { margin-top: .65rem; }
ul { padding-inline-start: 1.35rem; margin: .5rem 0; }
svg { display: block; max-width: 100%; height: auto; }
.wrapper { width: min(100% - 3.5rem, 73rem); margin-inline: auto; }
.skip { position: absolute; top: .6rem; left: .7rem; padding: .55rem .85rem; background: var(--paper); transform: translateY(-180%); z-index: 2; }
.skip:focus { transform: translateY(0); }
.sr-only { position: absolute; inline-size: 1px; block-size: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }

.site-header { background: var(--paper); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; min-height: 4.35rem; justify-content: space-between; align-items: center; gap: .8rem; }
.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--ink); font-weight: 700; font-size: 1.2rem; letter-spacing: -.04em; text-decoration: none; white-space: nowrap; }
.brand svg { flex: none; width: 2rem; }
.site-links { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem clamp(.7rem, 3vw, 1.55rem); font-size: .94rem; }
.site-links a, .footer-links a { color: var(--muted); font-weight: 650; text-decoration: none; }
.site-links a:hover, .footer-links a:hover { color: var(--accent); text-decoration: underline; }
.site-footer { margin-top: clamp(2.7rem, 7vw, 5rem); padding: 1.5rem 0 2rem; border-top: 1px solid var(--line); }
.footer-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .7rem 1.2rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: .6rem 1.25rem; }
.badge-text { color: var(--muted); font-size: .9rem; }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .87fr); align-items: center; gap: clamp(1.5rem, 5vw, 4rem); padding: clamp(2.2rem, 6.7vw, 5.4rem) 0; }
.hero h1 { margin-bottom: 1rem; font-size: clamp(2.45rem, 4.95vw, 4.65rem); line-height: 1.04; letter-spacing: -.052em; text-wrap: wrap; }
.hero h1 span { display: block; }
.hero-lead { max-width: 32rem; color: var(--muted); font-size: clamp(1.05rem, 1.9vw, 1.25rem); }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; margin-top: 1.45rem; }
.instrument { margin: 0; padding: 1.05rem .8rem .7rem; color: var(--ink); background: var(--paper); border: 1px solid var(--line-strong); border-top: 3px solid var(--accent); border-radius: .7rem; box-shadow: 0 8px 24px #122b4414; }
.instrument-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .25rem .65rem; padding: .15rem .65rem .45rem; border-bottom: 1px solid var(--line); }
.instrument-title { font-weight: 700; }
.instrument-data { color: #0f765d; font: 600 .86rem/1.35 var(--mono); }
.instrument-link { margin: .2rem .65rem .25rem; font-size: .875rem; }
.instrument-link a { color: var(--accent); }
.home-section { padding-block: 1.5rem 2.5rem; border-top: 1px solid var(--line-strong); }
.home-section > h2 { margin-bottom: 1rem; }
.topic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.4rem .7rem; }
.topic:first-child { grid-column: 1 / -1; }
.topic:not(:first-child) .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.topic > h3 { margin-bottom: .55rem; }
.card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .7rem; }
.tool-card { display: flex; flex-direction: column; min-width: 0; gap: .4rem; padding: 1rem; background: var(--paper); border: 1px solid var(--line); border-top: 3px solid #386bb6; border-radius: .45rem; color: var(--ink); text-decoration: none; }
.tool-card:hover, .tool-card:focus-visible { border-color: var(--accent); background: #f9fcff; text-decoration: none; }
.tool-card strong { color: var(--accent); font-size: 1.04rem; line-height: 1.25; }
.tool-card > span { color: var(--muted); font-size: .91rem; }
.guide-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.guide-group, .text-panel, .calc-panel, .support-panel { background: var(--paper); border: 1px solid var(--line); border-radius: .65rem; }
.guide-group { padding: 1rem 1.15rem; }
.guide-group > h3 { margin-bottom: .45rem; }
.guide-links { margin: 0; padding: 0; list-style: none; }
.guide-links li + li { border-top: 1px solid var(--line); }
.guide-links a { display: block; padding: .55rem .1rem; color: var(--accent); text-decoration: none; line-height: 1.4; }
.guide-links a:hover { text-decoration: underline; }

.page-lead { padding: 1.7rem 0 1.35rem; }
.breadcrumb { margin: 0 0 .7rem; color: var(--muted); font-size: .9rem; }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: .3rem .65rem; margin: 0; padding: 0; list-style: none; }
.breadcrumb li + li::before { content: "/"; margin-inline-end: .65rem; color: #637d95; }
.page-lead h1 { max-width: 57rem; }
.page-lead p { max-width: 48rem; margin-top: .65rem; color: var(--muted); font-size: 1.08rem; }
.guide-lead p:last-child { font-size: 1rem; }
.guide-lead .experiment { padding-left: .75rem; border-left: 3px solid #4581da; }
.workspace { display: grid; grid-template-columns: minmax(0, .87fr) minmax(0, 1.13fr); align-items: start; gap: 1rem; }
.calc-panel { min-width: 0; padding: clamp(.85rem, 2vw, 1.25rem); }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .45rem .65rem; margin-bottom: .9rem; }
.panel-head h2, #result-heading { font-size: 1.42rem; }
.input-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.button.jump-to-results { display: none; }
.unit-toggle { display: flex; gap: .1rem; min-inline-size: 0; padding: .14rem; margin: 0; border: 1px solid var(--line-strong); border-radius: .45rem; background: var(--bg); }
.unit-toggle label { position: relative; display: block; cursor: pointer; }
.unit-toggle label span { display: block; color: var(--muted); font-weight: 650; font-size: .87rem; padding: .32rem .65rem; border-radius: .3rem; white-space: nowrap; }
.unit-toggle input:checked + span { background: var(--navy); color: #fff; }
.unit-toggle input:focus-visible + span { outline: 3px solid #2c6ce1; outline-offset: 3px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .64rem .7rem; }
.field { display: grid; grid-template-rows: subgrid; grid-row: span 3; row-gap: .21rem; align-items: start; min-width: 0; }
.field > label { align-self: end; display: block; font-size: .89rem; font-weight: 600; line-height: 1.25; }
.control { display: flex; position: relative; align-items: center; min-width: 0; min-height: 2.6rem; gap: .3rem; padding: 0 .65rem; border: 1px solid var(--line-strong); border-radius: .35rem; background: #f9fbfd; }
.control:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px #2c6ce141; }
.control:has([aria-invalid="true"]) { border-color: var(--danger); }
.control input, .control select { flex: 1; width: 100%; align-self: stretch; border: 0; background: transparent; padding: .5rem 0; outline: 0; font-size: .96rem; }
.control input { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.control input::-webkit-inner-spin-button { appearance: none; }
.control input[type="number"] { appearance: textfield; }
.control select, .share-format select { appearance: none; padding-right: 1.1rem; }
.control:has(select)::after, .share-format::after { content: ""; pointer-events: none; position: absolute; right: .7rem; top: calc(50% - .26rem); width: .5rem; height: .5rem; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.field-unit, .field-hint, .field-error { color: var(--muted); font-size: .8rem; line-height: 1.35; }
.field-unit { flex: none; white-space: nowrap; pointer-events: none; }
.field-hint, .field-error { display: block; }
.field-error { color: var(--danger); font-weight: 650; }
.input-status, .action-status { color: var(--muted); margin-top: .6rem; font-size: .88rem; }
.input-status { color: var(--danger); font-weight: 650; }
.input-status:empty, .action-status:empty { display: none; }
.form-actions, .result-actions { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: 1rem; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: .3rem; min-height: 2.65rem; padding: .47rem .72rem; border-radius: .38rem; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); text-decoration: none; font-size: .89rem; font-weight: 700; line-height: 1.25; }
.button:hover:not([disabled]) { background: var(--accent-soft); border-color: #7e9dcc; text-decoration: none; }
.button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.button.primary:hover:not([disabled]) { border-color: #123c93; background: #123c93; }
.button.small { min-height: 2.35rem; padding: .41rem .63rem; }
#result-heading { margin-bottom: .8rem; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; margin-bottom: .7rem; }
.summary-grid:empty { display: none; }
.metric { min-width: 0; padding: .68rem .55rem; background: #eaf2fa; border-top: 3px solid #5492dc; border-radius: .28rem; display: flex; flex-direction: column; justify-content: space-between; gap: .28rem; }
.metric:first-child { background: #dff4f0; border-color: #258570; }
.metric dt { color: #304d63; font-size: .85rem; font-weight: 650; line-height: 1.22; }
.metric dd { margin: 0; color: var(--navy); overflow-wrap: anywhere; font: 700 clamp(.94rem, 2vw, 1.28rem)/1.17 var(--mono); letter-spacing: -.055em; }
.plot-frame { background: var(--paper); color: var(--ink); border: 1px solid var(--line-strong); border-top: 3px solid var(--accent); padding: .6rem .42rem .32rem; border-radius: .43rem; }
.plot-frame figcaption { margin-inline: .55rem; font-size: .93rem; font-weight: 680; }
#live-diagram > svg { width: 100%; }
.plot-invalid { padding: .7rem .55rem .85rem; color: var(--muted); }
.plot-legend { display: flex; flex-wrap: wrap; gap: .25rem .75rem; margin: .15rem .55rem .3rem; font-size: .84rem; }
.plot-legend:empty { display: none; }
.plot-legend span { display: flex; align-items: center; gap: .25rem; }
.swatch { width: .65rem; height: .65rem; border-radius: .15rem; }
.swatch.mint { background: #0f8a6e; }
.swatch.blue { background: #174fb8; }
.swatch.amber { background: #c66c12; }
.detail-rows { margin-top: .7rem; }
.detail-rows > div, .print-values > div { display: flex; justify-content: space-between; align-items: baseline; gap: .15rem .45rem; border-bottom: 1px solid var(--line); padding: .3rem 0; }
.detail-rows dt { color: var(--muted); }
.detail-rows dd, .print-values dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 660; overflow-wrap: anywhere; }
.detail-rows, .data-table { font-size: .91rem; }
.result-note { margin-top: .75rem; padding: .55rem .7rem; border-left: 3px solid #ba701f; background: var(--warn-bg); color: var(--warn); font-size: .9rem; }
.data-table { width: 100%; margin-top: .75rem; border-collapse: collapse; text-align: left; font-variant-numeric: tabular-nums; }
.data-table caption { text-align: left; font-weight: 700; color: var(--ink); padding: .2rem 0; }
.data-table th, .data-table td { text-align: right; border-bottom: 1px solid var(--line); padding: .3rem .25rem; font-weight: 500; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table thead th { background: var(--accent-soft); color: var(--ink); font-weight: 670; }
.share-panel { margin-top: .6rem; padding: .65rem; background: #eef4fc; border-left: 3px solid #4581da; }
.share-row { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; }
.share-row > label { font-size: .86rem; font-weight: 670; }
.share-row > input { flex: 1 1 12ch; min-width: 0; padding: .34rem .45rem; border: 1px solid var(--line-strong); border-radius: .3rem; background: white; font-size: .85rem; }
.share-format { position: relative; border: 1px solid var(--line-strong); border-radius: .3rem; background: white; }
.share-format select { padding: .35rem 1.55rem .35rem .45rem; background: transparent; border: 0; font-size: .85rem; }
.print-inputs { display: none; }

.support { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; margin-top: 1rem; align-items: start; }
.support-panel, .text-panel { min-width: 0; padding: 1.1rem 1.25rem; }
.support-panel h2 { font-size: 1.36rem; margin-bottom: .6rem; }
.support-panel p, .support-panel summary, .text-panel p { color: var(--muted); }
.support-panel .sources { margin-top: .8rem; }
.support-panel .sources a { font-size: .92rem; }
details { padding: .55rem 0; border-top: 1px solid var(--line); }
summary { cursor: pointer; font-weight: 680; line-height: 1.35; }
details p { padding-left: .9rem; margin-top: .4rem; }
.more-guides { margin-top: 1rem; }
.scroll-target { scroll-margin-top: 1.1rem; }
.text-panel { max-width: 52rem; }
.text-panel h2 { font-size: 1.3rem; margin: 1.1rem 0 .35rem; }
.text-panel h2:first-child { margin-top: 0; }
.text-panel ul { color: var(--muted); }

@media (max-width: 940px) {
  .wrapper { width: min(100% - 2.25rem, 73rem); }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .button.jump-to-results { display: inline-flex; }
}

@media (max-width: 660px) {
  .wrapper { width: calc(100% - 1.5rem); }
  .header-inner { gap: .25rem .55rem; min-height: 3.6rem; }
  .brand { font-size: 1.1rem; gap: .32rem; }
  .brand svg { width: 1.65rem; }
  .site-links { gap: .22rem .65rem; font-size: .83rem; }
  .hero, .guide-grid, .support { grid-template-columns: minmax(0, 1fr); }
  .topic-grid { grid-template-columns: minmax(0, 1fr); }
  .hero { gap: 1.35rem; }
  .plot-frame { padding: .55rem .25rem .32rem; }
}

@media (max-width: 360px) {
  .header-inner { flex-wrap: wrap; padding-block: .4rem; }
  .field-grid, .card-grid, .topic:not(:first-child) .card-grid { grid-template-columns: minmax(0, 1fr); }
  .metric { padding-inline: .35rem; }
}

@media print {
  @page { size: letter; margin: .48in .55in; }
  :root { --bg: #fff; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  body { font-size: 10pt; }
  .wrapper { width: 100%; }
  .skip, .site-links, .site-footer, #worksheet, .result-actions, .share-panel, .action-status,
  .worksheet-page .support, .worksheet-page .more-guides, .worksheet-page .breadcrumb, .hero-actions { display: none !important; }
  .site-header { border: 0; }
  .header-inner { min-height: auto; }
  .brand svg { width: 1.3rem; }
  .page-lead { padding: .5rem 0; }
  h1, .hero h1 { font-size: 22pt; }
  .page-lead p { font-size: 10pt; }
  .workspace, .support { display: block; }
  .calc-panel { border: 0; padding: .3rem 0; }
  .summary-grid, .plot-frame, .metric, .print-values > div, .result-note, .guide-group,
  .data-table tr { break-inside: avoid; }
  .metric dd { font-size: 12pt; }
  .detail-rows { margin-top: .45rem; }
  .detail-rows > div, .print-values > div, .data-table th, .data-table td { padding: .12rem .15rem; }
  .plot-frame { max-width: 30rem; margin-inline: auto; }
  .plot-frame figcaption, .plot-legend { font-size: 8pt; }
  .print-inputs { display: block; margin-top: .7rem; }
  .print-inputs h2 { font-size: 12pt; }
  .print-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: .6rem; font-size: 9pt; }
  .hero { padding-block: .8rem; }
  .instrument { box-shadow: none; }
}
