:root {
  color-scheme: light;
  --navy: #1e3a5f;
  --ink: #162f49;
  --muted: #466078;
  --teal: #0d9488;
  --teal-ink: #096f67;
  --crimson: #be185d;
  --background: #f8fafc;
  --white: #fff;
  --pale: #edf8f8;
  --line: #d6e3ec;
  --display: "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  --body: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --round: 14px;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 1rem; }
body { margin: 0; background: var(--background); color: var(--ink); font: 1rem/1.6 var(--body); }
main { min-height: 63vh; }
a { color: var(--teal-ink); text-underline-offset: 0.18em; text-decoration-thickness: 0.08em; }
a:hover { text-decoration-thickness: 0.15em; }
:focus-visible { outline: 3px solid var(--crimson); outline-offset: 3px; }
h1, h2, h3, p, figure { margin: 0; }
p + p { margin-top: 0.85em; }
h1, h2, h3 { font-family: var(--display); color: var(--navy); font-weight: 700; line-height: 1.15; }
h1 { font-size: clamp(2.15rem, 4.4vw, 4.35rem); letter-spacing: -0.042em; overflow-wrap: anywhere; }
h2 { font-size: clamp(1.5rem, 3vw, 2.2rem); letter-spacing: -0.035em; }
h3 { font-size: 1.1rem; letter-spacing: -0.01em; }
ul, ol, dl { margin-block: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.52; }
.wrap { width: min(calc(100% - 48px), 1250px); margin-inline: auto; }
.sr-only, .skip:not(:focus) {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.skip:focus { position: absolute; z-index: 5; top: 0.4rem; left: 0.4rem; padding: 0.65rem; background: var(--white); }
.print-only { display: none; }

.site-header { background: var(--white); border-top: 4px solid var(--teal); border-bottom: 1px solid var(--line); }
.header-row, .footer-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.header-row { min-height: 69px; }
.brand { display: inline-flex; align-items: center; gap: 0.58rem; color: var(--navy); text-decoration: none; font: 700 1.2rem/1 var(--display); letter-spacing: -0.04em; }
.brand-mark { display: grid; place-items: center; height: 36px; width: 36px; border-radius: 10px; background: var(--navy); color: #b9efea; flex: 0 0 36px; }
.site-nav, .footer-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.4rem; }
.site-nav a, .footer-links a { text-decoration: none; color: var(--navy); font-weight: 650; font-size: 0.92rem; }
.site-nav a:hover, .footer-links a:hover { text-decoration: underline; }
.site-footer { border-top: 1px solid var(--line); background: var(--white); margin-top: 3.25rem; }
.footer-row { padding-block: 1.5rem; }
.footer-title { color: var(--navy); font: 750 1rem var(--display); }
.footer-row p { color: var(--muted); font-size: 0.86rem; }

.home-hero { padding-block: clamp(2.8rem, 7vw, 6.1rem) clamp(2.6rem, 6vw, 5rem); border-bottom: 1px solid var(--line); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: center; gap: clamp(1.4rem, 5vw, 4.75rem); }
.home-heading { max-width: 11.2ch; }
.hero-copy { margin-top: 1.2rem; max-width: 39ch; font-size: clamp(1.03rem, 1.4vw, 1.22rem); color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.65rem 1.05rem; margin-top: 1.4rem; }
.action {
  display: inline-flex; justify-content: center; align-items: center; min-height: 42px; padding: 0.44rem 0.8rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--white); color: var(--navy); text-decoration: none;
  font-weight: 680; font-size: 0.875rem; line-height: 1.3; text-align: center;
}
.action:hover:not(:disabled) { background: var(--pale); border-color: var(--teal); }
.action.primary { background: var(--navy); border-color: var(--navy); color: var(--white); }
.action.primary:hover:not(:disabled) { background: var(--teal-ink); border-color: var(--teal-ink); }
.hero-actions .action { padding-inline: 1.05rem; }
.hero-diagram { min-width: 0; background: var(--white); border: 1px solid var(--line); padding: clamp(0.65rem, 2vw, 1.15rem); border-radius: 21px; box-shadow: 0 12px 38px #1e3a5f0b; }
.hero-diagram figcaption { color: var(--muted); font-size: 0.88rem; padding: 0.6rem 0.2rem 0; }
.hero-diagram svg, .diagram svg { width: 100%; height: auto; display: block; }

.section { padding-top: clamp(2.1rem, 5vw, 4rem); }
.section h2 { margin-bottom: 1rem; }
.calc-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.8rem; }
.tool-card { display: flex; flex-direction: column; align-items: flex-start; gap: 0.65rem; padding: 1rem; color: var(--ink); text-decoration: none; background: var(--white); border: 1px solid var(--line); border-radius: var(--round); }
.tool-card:hover { border-color: var(--teal); box-shadow: 0 4px 20px #1e3a5f0c; }
.tool-card:hover h3 { text-decoration: underline; text-underline-offset: 0.16em; }
.icon-chip { background: var(--pale); color: var(--teal-ink); border-radius: 9px; padding: 0.42rem; display: grid; place-items: center; }
.tool-card p { font-size: 0.91rem; color: var(--muted); line-height: 1.5; }
.tool-card code { color: var(--teal-ink); font-size: 0.82rem; margin-top: auto; }
code { font-family: var(--mono); overflow-wrap: anywhere; }
.guide-catalog { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; align-items: start; }
.guide-group { border: 1px solid var(--line); background: var(--white); border-radius: var(--round); }
.guide-group summary { padding: 1rem; cursor: pointer; color: var(--navy); font-family: var(--display); font-weight: 700; }
.guide-group ul { padding: 0 1rem 1rem 2.2rem; }
.guide-group li + li { margin-top: 0.35rem; }

.page-intro { padding-block: clamp(1.25rem, 3.5vw, 2.5rem); border-bottom: 1px solid var(--line); background: #eef5f9; }
.page-intro h1 { max-width: 31ch; font-size: clamp(2rem, 4vw, 3.4rem); }
.page-intro .lead { margin-top: 0.7rem; max-width: 68ch; color: var(--muted); font-size: 1.06rem; }
.crumbs { display: flex; flex-wrap: wrap; gap: 0.12rem 0.48rem; align-items: baseline; margin-bottom: 0.75rem; color: var(--muted); font-size: 0.88rem; }
.crumbs a { font-weight: 650; }
.formula { display: inline-block; margin-top: 0.8rem; padding: 0.25rem 0.55rem; background: #dceff1; color: var(--navy); border-radius: 5px; font-size: 0.88rem; }
.bench { padding-top: 1.2rem; }
.safety { margin-bottom: 0.85rem; padding: 0.7rem 0.9rem; border-left: 4px solid var(--crimson); background: #fbecf4; color: #702144; font-size: 0.94rem; }
.bench-grid { display: grid; grid-template-columns: minmax(0, 0.84fr) minmax(0, 1.16fr); align-items: start; gap: 0.85rem; }
.panel { border: 1px solid var(--line); background: var(--white); border-radius: var(--round); min-width: 0; }
.panel-body { padding: clamp(0.85rem, 2vw, 1.35rem); }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.4rem 0.7rem; margin-bottom: 0.8rem; }
.panel-head h2 { font-size: 1.38rem; }
.panel-head p { color: var(--muted); font-size: 0.82rem; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 0.8rem 0.7rem; }
.field { display: grid; min-width: 0; }
.field label { color: var(--navy); font-size: 0.875rem; font-weight: 680; line-height: 1.28; margin-bottom: 0.35rem; }
.field small { margin-top: 0.22rem; color: var(--muted); font-size: 0.8rem; line-height: 1.32; }
.field input, .field select, .share-url {
  width: 100%; min-width: 0; min-height: 43px; border: 1px solid #9bb1c4; border-radius: 7px;
  padding: 0.35rem 0.55rem; background: #fbfdff; color: var(--ink);
}
.field input, .share-url { font-family: var(--mono); }
.field select { height: 43px; appearance: none; padding-right: 1.65rem; text-overflow: ellipsis; }
.field:has(select) { position: relative; grid-template-rows: auto auto auto; }
.field:has(select)::after {
  content: ""; width: 7px; height: 7px; border: solid var(--teal-ink); border-width: 0 2px 2px 0;
  transform: rotate(45deg); justify-self: end; align-self: center; margin: -3px 13px 0 0; pointer-events: none; grid-area: 2 / 1;
}
.field select { grid-area: 2 / 1; }
.field select:focus, .field input:focus { background-color: var(--white); }
.error { border-radius: 8px; background: #fff0f4; border: 1px solid #eeb7cd; color: #81143f; padding: 0.75rem 0.85rem; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.3rem 0.9rem; margin-bottom: 0.85rem; }
.metric { min-width: 0; padding: 0.45rem 0.1rem; border-bottom: 1px solid var(--line); }
.metric dt { color: var(--muted); font-size: 0.86rem; line-height: 1.3; }
.metric dd { display: flex; align-items: baseline; gap: 0.25rem 0.45rem; flex-wrap: wrap; margin: 0; }
.metric-value { color: var(--navy); font: 710 1.17rem/1.35 var(--mono); overflow-wrap: anywhere; }
.metric-unit { color: var(--muted); font-size: 0.86rem; }
.metric-primary { grid-column: 1 / -1; padding: 0.65rem 0.85rem; margin-bottom: 0.24rem; background: var(--navy); border: 0; border-radius: 9px; }
.metric-primary dt, .metric-primary .metric-unit { color: #e4f4f7; }
.metric-primary .metric-value { color: var(--white); font-size: clamp(1.7rem, 4.4vw, 2.4rem); }
.metric-primary .metric-unit { font: 650 0.98rem var(--mono); }
.diagram { min-width: 0; }
.diagram figcaption { color: var(--muted); font-size: 0.88rem; line-height: 1.38; margin-top: 0.38rem; }
.tube { cursor: pointer; }
.tube:hover .tube-focus, .tube:focus-visible .tube-focus, .tube[aria-pressed="true"] .tube-focus { fill: #eaf6ff; stroke: var(--crimson); stroke-width: 2; }
.results-table { width: 100%; table-layout: fixed; border-collapse: collapse; margin-top: 0.9rem; font-size: 0.85rem; overflow-wrap: anywhere; line-height: 1.35; }
.results-table caption { text-align: left; font-family: var(--display); font-weight: 750; color: var(--navy); font-size: 1.03rem; padding-bottom: 0.35rem; }
.results-table th, .results-table td { padding: 0.42rem 0.35rem; border-bottom: 1px solid var(--line); text-align: left; }
.results-table thead { background: var(--pale); }
.results-table thead small { color: var(--muted); display: block; font-weight: 500; font-size: 0.8rem; }
.results-table tbody td { font-family: var(--mono); }
.exports { display: flex; flex-wrap: wrap; gap: 0.38rem; border-top: 1px solid var(--line); margin-top: 0.85rem; padding-top: 0.75rem; }
.message { color: var(--teal-ink); font-size: 0.88rem; margin-top: 0.35rem; overflow-wrap: anywhere; }
.message:empty { display: none; }
.share-url { font-size: 0.82rem; margin-top: 0.3rem; }

.reading { width: min(100%, 820px); }
.reading > section, .article-page > section { margin-top: 1.65rem; }
.reading h2, .article-page h2 { margin-bottom: 0.65rem; }
.reading p, .article-page p { max-width: 74ch; }
.steps { padding-left: 1.8rem; }
.steps li { padding: 0.35rem 0 0.55rem 0.3rem; break-inside: avoid; }
.steps li::marker { color: var(--teal-ink); font-family: var(--mono); font-weight: 750; }
.steps h3 { margin-bottom: 0.25rem; }
.steps p { overflow-wrap: anywhere; }
.method-notes { padding-left: 1.45rem; color: var(--muted); }
.method-notes li { margin-top: 0.25rem; }
.faq { background: var(--white); border: 1px solid var(--line); border-radius: 9px; }
.faq + .faq { margin-top: 0.45rem; }
.faq summary { padding: 0.75rem 0.9rem; cursor: pointer; color: var(--navy); font-weight: 675; }
.faq p { padding: 0 0.9rem 0.8rem; margin: 0; }
.related { padding-left: 1.35rem; }
.related li + li { margin-top: 0.32rem; }
.article-page { padding-bottom: 0.4rem; }
.article-page .action { margin-top: 1rem; }

@media (max-width: 1050px) {
  .calc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 810px) {
  .bench-grid { grid-template-columns: minmax(0, 1fr); }
  .guide-catalog { gap: 0.6rem; }
}
@media (max-width: 650px) {
  .wrap { width: calc(100% - 28px); }
  .header-row { gap: 0.45rem; min-height: 61px; }
  .site-nav { gap: 0.38rem 0.7rem; }
  .site-nav a { font-size: 0.8rem; }
  .brand { font-size: 1.08rem; gap: 0.38rem; }
  .brand-mark { width: 29px; height: 29px; flex-basis: 29px; border-radius: 7px; }
  .brand-mark svg { width: 19px; height: 19px; }
  .hero-grid, .guide-catalog { grid-template-columns: minmax(0, 1fr); }
  .home-heading { max-width: 14ch; }
  .hero-diagram { max-width: 535px; }
  .calc-grid { gap: 0.55rem; }
  .tool-card { padding: 0.75rem; }
  .tool-card h3 { font-size: 1rem; }
  .tool-card p { font-size: 0.86rem; }
  .field:has(> select):not([data-field$="Unit"], [data-field="fold"]) { grid-column: 1 / -1; }
  .footer-row { flex-direction: column; align-items: flex-start; gap: 0.7rem; }
  .results-table th, .results-table td { padding-inline: 0.2rem; }
}
@media (max-width: 360px) {
  .header-row { flex-wrap: wrap; padding-block: 0.55rem; }
  .fields, .calc-grid { grid-template-columns: minmax(0, 1fr); }
}
@page { margin: 14mm; }
@media print {
  body { background: #fff; color: #162f49; font-size: 10pt; }
  .wrap { width: 100%; }
  .site-header, .site-footer, .skip, .crumbs, .exports, .message, .reading > section:not(.print-method), .input-panel, .panel-head p { display: none; }
  .print-only { display: block; }
  .page-intro { background: #fff; padding: 0 0 0.45rem; }
  .page-intro h1 { max-width: none; font-size: 20pt; }
  .page-intro .lead { font-size: 10pt; }
  .bench { padding-top: 0.6rem; }
  .bench-grid { display: block; }
  .panel { border: 0; }
  .panel-body { padding: 0; }
  .panel-head { margin-bottom: 0.3rem; }
  .print-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.3rem 0.55rem; margin-bottom: 0.65rem; }
  .print-inputs div { border-bottom: 1px solid var(--line); break-inside: avoid; }
  .print-inputs dt { color: var(--muted); font-size: 8.5pt; }
  .print-inputs dd { margin: 0; font-weight: 680; }
  .metric-primary { grid-column: auto; background: var(--pale); padding: 0.45rem 0.1rem; }
  .metric-primary dt, .metric-primary .metric-unit, .metric-primary .metric-value { color: var(--navy); }
  .metric-primary .metric-value { font-size: 1.17rem; }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric { break-inside: avoid; }
  .diagram { max-width: 112mm; margin: 0 auto; break-inside: avoid; }
  .results-table tr { break-inside: avoid; }
  .print-method h2 { font-size: 15pt; }
  .safety { font-size: 9pt; }
}
