:root {
  color-scheme: light;
  --page: #efeee9;
  --panel: #fdfcf8;
  --panel-deep: #e9e7e0;
  --input: #fffefa;
  --ink: #242a2e;
  --muted: #515d62;
  --line: #d2d3cc;
  --line-strong: #a7aea9;
  --link: #8e3514;
  --accent: #ff914d;
  --accent-hover: #ffac72;
  --icon-back: #fae3d2;
  --focus: #a2431b;
  --danger-bg: #542c22;
  --danger-text: #ffdbbe;
  --graphite: #20262a;
  --heading: "Avenir Next Condensed", "Arial Narrow", "Liberation Sans Narrow", "Roboto Condensed", system-ui, sans-serif;
  --body: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --mono: "SFMono-Regular", "SF Mono", Menlo, "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #171b1e;
  --panel: #21282c;
  --panel-deep: #1b2124;
  --input: #1a2023;
  --ink: #f4f0e9;
  --muted: #afbdbe;
  --line: #3d4a4d;
  --line-strong: #637073;
  --link: #ffad75;
  --icon-back: #452d23;
  --focus: #ffb478;
}

* { box-sizing: border-box; }
html { min-width: 280px; }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 1rem/1.55 var(--body); }
[hidden] { display: none !important; }
h1, h2, h3, p, figure, dl, dd { margin: 0; }
h1, h2, h3 { font-family: var(--heading); line-height: 1.06; letter-spacing: -.018em; }
h1 { font-size: clamp(2rem, 4.2vw, 3.5rem); font-weight: 700; }
h2 { font-size: clamp(1.45rem, 2.5vw, 2.15rem); font-weight: 700; }
h3 { font-size: 1.34rem; font-weight: 700; }
a { color: var(--link); text-underline-offset: .19em; }
a:hover { text-decoration-thickness: .13em; }
button, input, select { font: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 3px;
}
button, select, summary { cursor: pointer; }
button:disabled, select:disabled { cursor: default; opacity: .6; }
button {
  padding: .5rem .74rem;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: .28rem;
  font-size: .81rem;
  font-weight: 700;
  line-height: 1.23;
  min-height: 2.45rem;
}
button:hover:not(:disabled) { border-color: var(--link); color: var(--link); }
.shell { width: min(100% - 3.25rem, 1200px); margin-inline: auto; }
.visually-hidden, .skip:not(:focus) {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip:focus {
  position: fixed; z-index: 10; top: .5rem; left: .5rem; padding: .65rem; background: var(--panel);
}
#calculators, #guides, #results-title { scroll-margin-top: 1rem; }

.topbar {
  color: #f4f1eb; background: #1c2226; border-bottom: 1px solid #3c464a;
  --focus: #ffb478;
}
.topbar-inner { display: flex; align-items: center; min-height: 4.25rem; gap: 1.3rem; }
.brand { display: inline-flex; align-items: center; gap: .62rem; color: inherit; text-decoration: none; white-space: nowrap; }
.brand > span:last-child, .footer .brand { font: 700 1.48rem/1 var(--heading); letter-spacing: -.025em; }
.brand-mark {
  width: 2.05rem; height: 2.05rem; display: grid; place-items: center;
  background: var(--accent); color: #22282c; border-radius: .28rem;
}
.brand-mark svg { width: 1.28rem; height: 1.28rem; }
.brand-end { color: #ff9e5c; }
.main-nav { display: flex; margin-left: auto; gap: 1.5rem; align-items: center; }
.main-nav a { color: #f0ece5; text-decoration: none; font-size: .9rem; font-weight: 600; }
.main-nav a:hover { color: #ffad75; }
.theme-button {
  background: #30393e; border-color: #566166; color: #e8e6df;
  width: 2.4rem; display: grid; place-items: center; padding: .35rem; flex: 0 0 auto;
}
.theme-button:hover:not(:disabled) { border-color: #ffb478; color: #ffb478; }
.theme-button svg { width: 1.15rem; height: 1.15rem; }
:root[data-theme="dark"] .theme-moon, :root:not([data-theme="dark"]) .theme-sun { display: none; }

.hero, .instrument {
  --focus: #ffb478;
  --plot-rule: #465458;
  --plot-hot: #ff9b59;
  --plot-cold: #8cccce;
  --plot-text: #bdcacc;
  --plot-zone: #305356;
  --plot-neutral: #839094;
  color: #f4f0e9;
}
.hero {
  background: var(--graphite);
  margin-top: 1.75rem;
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(1.3rem, 3.7vw, 3.7rem);
  padding: clamp(1.65rem, 4.25vw, 3.7rem);
  border-radius: .45rem;
  border: 1px solid #455053;
}
.hero h1 { font-size: clamp(2.65rem, 4.7vw, 4.42rem); letter-spacing: -.033em; line-height: 1; }
.hero-copy p { max-width: 37ch; margin-top: 1rem; color: #d2d8d5; font-size: clamp(.97rem, 1.36vw, 1.12rem); }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.05rem; margin-top: 1.45rem; }
.button {
  min-height: 2.75rem; padding: .61rem .85rem; font-weight: 700;
  text-decoration: none; border-radius: .24rem; display: inline-flex; align-items: center; gap: .65rem;
}
.button-hot { color: #211d1a; background: var(--accent); }
.button-hot:hover { background: var(--accent-hover); }
.hero-guide-link { color: #fbc19b; font-size: .9rem; font-weight: 700; white-space: nowrap; }
.hero-drawing {
  background-color: #1b2226;
  background-image: linear-gradient(#303b40 1px, transparent 1px), linear-gradient(90deg, #303b40 1px, transparent 1px);
  background-size: 19px 19px;
  border: 1px solid #576367;
  padding: .73rem .9rem;
  border-radius: .32rem;
  color: #d6dede;
  text-decoration: none;
  min-width: 0;
}
.hero-drawing:hover { border-color: #ff9b59; }
.drawing-head, .drawing-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: .2rem .55rem;
  padding-block: .26rem; font: 650 .72rem/1.25 var(--mono);
}
.drawing-head { text-transform: uppercase; }
.drawing-head span:last-child, .drawing-foot span:last-child { color: #ffb986; }
.drawing-foot { align-items: end; border-top: 1px solid #465458; padding-top: .55rem; }

.catalog, .guide-index { margin-top: clamp(2.15rem, 4.7vw, 4rem); }
.section-head {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: .4rem 1.15rem;
  margin-bottom: .95rem; padding-bottom: .6rem; border-bottom: 1px solid var(--line-strong);
}
.section-head p { color: var(--muted); font-size: .92rem; }
.tool-grid, .guide-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem;
}
.tool-card {
  display: flex; flex-direction: column; gap: .35rem;
  position: relative; padding: 1rem;
  background: var(--panel); color: var(--ink); text-decoration: none;
  border: 1px solid var(--line); border-radius: .32rem; min-width: 0;
}
.tool-card:hover { border-color: var(--focus); }
.tool-card-top { display: flex; justify-content: space-between; align-items: flex-start; color: var(--link); margin-bottom: .35rem; }
.tool-icon {
  width: 2.32rem; height: 2.32rem; display: grid; place-items: center; flex: 0 0 auto;
  border-radius: .25rem; background: var(--icon-back); color: var(--link);
}
.tool-icon svg { width: 1.46rem; height: 1.46rem; }
.tool-card strong { font: 700 1.34rem/1.12 var(--heading); }
.tool-card-description { color: var(--muted); font-size: .84rem; line-height: 1.45; }
.guide-grid { gap: 1.15rem; }
.guide-group { border-top: 3px solid var(--line-strong); padding-top: .72rem; min-width: 0; }
.guide-group h3 { margin-bottom: .5rem; }
.guide-links { padding: 0; margin: 0; list-style: none; }
.guide-links li { border-bottom: 1px solid var(--line); }
.guide-links li a { display: block; padding: .46rem 0; font-size: .875rem; line-height: 1.36; }
.home-method {
  margin-block: 3rem 3.6rem; border-top: 1px solid var(--line-strong); padding-top: 1.1rem;
  display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 1.5rem;
}
.home-method p { margin: .55rem 0; color: var(--muted); }

.breadcrumb {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem;
  margin-block: 1.25rem .85rem; color: var(--muted); font-size: .81rem; font-weight: 650;
}
.tool-intro {
  display: flex; gap: .8rem; align-items: flex-start;
  max-width: 67rem; margin-bottom: 1.2rem;
}
.tool-intro .tool-icon { margin-top: .11rem; width: 2.7rem; height: 2.7rem; }
.tool-intro .tool-icon svg { width: 1.62rem; height: 1.62rem; }
.tool-intro h1 { overflow-wrap: anywhere; }
.tool-intro p { max-width: 70ch; margin-top: .48rem; color: var(--muted); font-size: .97rem; }
.jump-results { display: none; }
.workbench {
  display: grid; align-items: start; grid-template-columns: minmax(0, 1.04fr) minmax(0, 1fr);
  gap: clamp(.85rem, 2.1vw, 1.6rem);
}
.input-pane, .output-pane { border: 1px solid var(--line-strong); border-radius: .4rem; min-width: 0; }
.input-pane { background: var(--panel); }
.output-pane { background: var(--graphite); border-color: #4f5c61; }
.pane-head {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  min-height: 3.65rem; padding: .52rem 1rem; border-bottom: 1px solid var(--line);
}
.pane-head h2 { font-size: 1.62rem; }
.output-pane .pane-head { border-color: #455257; }
[data-result-state] { color: #bed2d2; font: 650 .74rem/1.25 var(--mono); text-align: right; }
#calculator { padding: 0 1rem .35rem; }
.calculator-fields, .input-group { padding: 0; margin: 0; min-inline-size: 0; border: 0; }
.preset-bar {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .72rem;
  padding: .83rem 0; margin-bottom: .15rem; border-bottom: 1px solid var(--line);
}
.preset-bar label { font-size: .82rem; font-weight: 700; }
.preset-bar select {
  color: var(--ink); background: var(--input); border: 1px solid var(--line-strong);
  border-radius: .26rem; min-width: 0; width: 100%; padding: .47rem .48rem; min-height: 2.5rem; font-size: .9rem;
}
.input-group { margin-top: .65rem; padding-bottom: .85rem; }
.input-group + .input-group { margin-top: .33rem; }
.input-group legend {
  width: 100%; color: var(--muted); margin-bottom: .52rem;
  padding: .14rem 0 .42rem; border-bottom: 1px solid var(--line);
  font-family: var(--heading); font-size: 1.12rem; font-weight: 700;
}
.group-note { font-size: .78rem; color: var(--muted); margin-bottom: .52rem; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .56rem .76rem; }
.field { min-width: 0; }
.field label { display: block; font-size: .79rem; font-weight: 600; margin-bottom: .26rem; line-height: 1.35; }
.field-control {
  display: flex; align-items: stretch; min-width: 0; min-height: 2.5rem;
  background: var(--input); border: 1px solid var(--line-strong); border-radius: .25rem;
}
.field-control:focus-within { border-color: var(--focus); }
.field-control input, .field-control select {
  flex: 1 1 0; min-width: 0; width: 100%; border: 0; border-radius: .22rem;
  padding: .36rem .48rem; background: transparent; color: var(--ink); font-size: .88rem;
}
.field-control input { font-family: var(--mono); font-variant-numeric: tabular-nums; appearance: textfield; }
.field-control input::-webkit-outer-spin-button, .field-control input::-webkit-inner-spin-button { appearance: none; margin: 0; }
.field-control select { font-weight: 550; }
.field-unit {
  flex: 0 0 auto; display: grid; place-items: center; padding-inline: .4rem;
  border-left: 1px solid var(--line); color: var(--muted); font: .69rem/1.15 var(--mono);
}
.field small { display: block; color: var(--muted); margin-top: .2rem; font-size: .72rem; line-height: 1.35; }
.no-script { font-size: .8rem; color: var(--muted); padding-inline: 1rem; padding-bottom: 1rem; }

#results { padding: .75rem 1rem .85rem; }
.primary-result {
  padding: .13rem 0 .52rem; display: grid; gap: .16rem; min-width: 0; color: #c4d0d0;
}
.primary-result > span { font-size: .86rem; font-weight: 660; }
.primary-result > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: .18rem .58rem; }
.primary-result strong {
  color: #ffac72; font: 740 clamp(1.85rem, 4.25vw, 3.28rem)/1.15 var(--mono);
  font-variant-numeric: tabular-nums; letter-spacing: -.04em; overflow-wrap: anywhere;
}
.primary-unit { color: #d6dedc; font: 630 .84rem/1.2 var(--mono); }
#calculation-error, .result-warnings {
  color: var(--danger-text); background: var(--danger-bg);
  border: 1px solid #8b553e; border-radius: .24rem; font-size: .79rem;
}
#calculation-error { margin: .85rem 1rem; padding: .62rem .7rem; }
.result-warnings { margin: 0 0 .65rem; padding: .45rem .65rem .45rem 1.7rem; }
.result-warnings li + li { margin-top: .22rem; }
.diagram-frame {
  background: #1a2125; border: 1px solid #435259; padding: .35rem .4rem .5rem; border-radius: .25rem;
}
.engineering-diagram { display: block; width: 100%; height: auto; max-height: 15.75rem; overflow: hidden; }
.diagram-frame figcaption { color: #c1cdcc; padding: .16rem .38rem .12rem; font-size: .73rem; line-height: 1.35; }
.svg-text { font-family: var(--mono); font-size: 12px; fill: var(--plot-text); }
.svg-hot { fill: var(--plot-hot); }
.svg-rule, .svg-outline, .svg-extension, .svg-ghost, .svg-dashed, .svg-tick {
  fill: none; stroke: var(--plot-rule); stroke-width: 1;
}
.svg-outline { stroke: #8b9ca1; stroke-width: 1.2; }
.svg-ghost { stroke: #718186; stroke-dasharray: 2.5 3; }
.svg-extension { stroke: #6e797d; stroke-dasharray: 2 4; }
.svg-dashed { stroke: #77868a; stroke-dasharray: 5 5; }
.svg-dimension { stroke: var(--plot-hot); stroke-width: 1.3; fill: none; }
.svg-cold { stroke: var(--plot-cold); stroke-width: 1.6; fill: none; }
.svg-pitch { stroke: var(--plot-hot); stroke-width: 2; fill: none; }
.svg-belt { stroke: var(--plot-hot); stroke-width: 3; stroke-linejoin: round; fill: none; }
.svg-point { fill: var(--plot-hot); stroke: #1a2125; stroke-width: 1.2; }
.svg-point-cold, .svg-fill-cold { fill: var(--plot-cold); }
.svg-zone, .svg-fill-zone { fill: var(--plot-zone); }
.svg-fill-neutral { fill: var(--plot-neutral); }
.svg-fill-hot { fill: var(--plot-hot); }
.svg-track { fill: var(--plot-rule); }
.svg-tick { stroke: #1a2125; }
.metric-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: .57rem;
}
.metric-grid > div { border-bottom: 1px solid #455257; padding: .5rem .4rem .47rem 0; min-width: 0; }
.metric-grid > div:nth-child(even) { border-left: 1px solid #455257; padding-left: .6rem; }
.metric-grid dt { color: #c1cecf; font-size: .73rem; line-height: 1.27; }
.metric-grid dd {
  margin-top: .15rem; font: 660 .85rem/1.28 var(--mono); font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.quote-table { width: 100%; border-collapse: collapse; font-size: .84rem; margin-top: .7rem; }
.quote-table caption { text-align: left; color: #e8e3d9; font-weight: 700; margin-bottom: .24rem; }
.quote-table th, .quote-table td { text-align: left; border-bottom: 1px solid #445157; padding: .32rem .2rem; }
.quote-table th[scope="row"] { font-weight: 520; }
.quote-table td, .quote-table thead th:last-child { text-align: right; }
.quote-table td { font-family: var(--mono); font-size: .79rem; }
.quote-table tbody tr:last-child { color: #ffb986; font-weight: 740; }
.export-actions {
  display: flex; flex-wrap: wrap; gap: .4rem; padding: .72rem 1rem 0; border-top: 1px solid #455257;
}
.export-actions button { color: #f4f0e8; border-color: #69787d; background: #283237; }
.export-actions button:hover:not(:disabled) { color: #ffb986; border-color: #ffb986; }
.action-status { font-size: .74rem; min-height: 1.6rem; padding: .19rem 1rem .35rem; color: #c3d0cf; }

.reading-grid {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: clamp(1.2rem, 5vw, 4rem); margin: 2.45rem 0;
}
.method p, .info-page p { margin-top: .65rem; max-width: 72ch; color: var(--muted); }
.method h3 { margin-top: 1.2rem; }
.method .example-result {
  padding: .56rem .66rem; background: var(--panel); border-left: 3px solid var(--accent);
  color: var(--ink); display: flex; flex-wrap: wrap; gap: .3rem .8rem;
}
.example-result span { font-family: var(--mono); }
.formulas {
  background: var(--panel); border: 1px solid var(--line); border-radius: .25rem;
  padding: .54rem .85rem .54rem 1.85rem; margin: .55rem 0 0;
}
.formulas code { font: .81rem/1.45 var(--mono); overflow-wrap: anywhere; }
.references { margin: .55rem 0 0; padding-left: 1.15rem; }
.references li { margin-block: .3rem; overflow-wrap: anywhere; }
.related section {
  border-top: 2px solid var(--line-strong); padding-top: .66rem; margin-bottom: 1.16rem;
}
.related h2 { font-size: 1.33rem; margin-bottom: .34rem; }
.tool-faq { margin: 2rem 0 3.5rem; max-width: 52rem; }
.tool-faq > h2 { margin-bottom: .65rem; }
.faq-list details { border-bottom: 1px solid var(--line-strong); padding: .58rem 0; }
.faq-list summary { line-height: 1.4; font-size: .92rem; font-weight: 700; }
.faq-list p { color: var(--muted); font-size: .9rem; margin: .45rem 0 .1rem; }
.info-page { max-width: 55rem; margin-block: 2rem 4rem; }
.info-page .breadcrumb { display: inline-block; margin-top: 0; }
.info-page section { margin-top: 1.52rem; }
.info-page h2 { font-size: 1.55rem; }
.info-page .info-lede { font-size: 1.1rem; }
.missing { min-height: 45vh; }

.footer {
  background: #1c2226; border-top: 1px solid #465157; color: #e8e6df; --focus: #ffb478;
}
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; padding-block: 1.2rem; }
.footer .brand { font-size: 1.19rem; }
.footer > div > span { color: #c4cccc; font-size: .82rem; }
.footer nav { display: flex; gap: 1.05rem; margin-left: auto; }
.footer nav a { color: #ffc297; font-size: .86rem; }
.footer .brand-mark { width: 1.64rem; height: 1.64rem; }

@media (max-width: 960px) {
  .tool-grid, .guide-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .shell { width: calc(100% - 1.6rem); }
  .hero { grid-template-columns: minmax(0, 1fr); margin-top: .85rem; padding: 1.25rem; gap: 1.1rem; }
  .hero h1 { font-size: clamp(2.43rem, 8.9vw, 3.5rem); }
  .hero-copy p { margin-top: .64rem; }
  .hero-actions { margin-top: .9rem; }
  .home-method, .workbench, .reading-grid { grid-template-columns: minmax(0, 1fr); }
  .jump-results { display: inline-block; margin-bottom: .68rem; font-size: .85rem; font-weight: 700; }
  .reading-grid { gap: 1.35rem; }
  .tool-intro { margin-bottom: .48rem; }
  .field-control input, .field-control select, .preset-bar select { font-size: 1rem; }
}
@media (max-width: 430px) {
  .topbar-inner { min-height: 3.75rem; gap: .6rem; }
  .brand { gap: .38rem; }
  .brand > span:last-child { font-size: 1.18rem; }
  .brand-mark { width: 1.55rem; height: 1.55rem; }
  .brand-mark svg { width: 1.04rem; height: 1.04rem; }
  .main-nav { gap: .57rem; }
  .main-nav a { font-size: .76rem; }
  .theme-button { min-height: 2.12rem; width: 2.12rem; }
  .theme-button svg { width: 1.02rem; height: 1.02rem; }
  .hero { padding: 1rem; }
  .hero-drawing { padding: .48rem; }
  .drawing-head, .drawing-foot { font-size: .62rem; }
  .tool-card { padding: .73rem; }
  .tool-card strong { font-size: 1.15rem; }
  .tool-card-description { font-size: .78rem; }
  .guide-grid { gap: .8rem; }
  .guide-links li a { font-size: .81rem; }
  .tool-intro { gap: .53rem; }
  .tool-intro .tool-icon { width: 2.05rem; height: 2.05rem; }
  .tool-intro .tool-icon svg { width: 1.28rem; height: 1.28rem; }
  .tool-intro h1 { font-size: 2rem; }
  .tool-intro p { font-size: .87rem; }
  #calculator, #results { padding-inline: .68rem; }
  .pane-head, .export-actions, .action-status { padding-inline: .68rem; }
  .field-grid { gap: .5rem; }
  .field-control input, .field-control select { padding-inline: .34rem; }
}
@media (max-width: 350px) {
  .topbar-inner { gap: .42rem; }
  .topbar .brand { gap: .32rem; }
  .topbar .brand > span:last-child { font-size: 1.02rem; }
  .topbar .brand-mark { width: 1.35rem; height: 1.35rem; }
  .main-nav { gap: .41rem; }
  .tool-grid, .guide-grid { grid-template-columns: minmax(0, 1fr); }
  .footer nav { margin-left: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .tool-card, .hero-drawing, .button-hot, button { transition: border-color .14s ease, background-color .14s ease; }
}
