:root {
  color-scheme: light;
  --page: #edf3f0;
  --paper: #fff;
  --ink: #122f35;
  --muted: #486269;
  --teal: #00695e;
  --teal-light: #e2f2eb;
  --rule: #d0ddd8;
  --plot: #0c2b32;
  --plot-rule: #23484f;
  --plot-muted: #b4ccca;
  --lime: #c8ed83;
  --warn: #7a360d;
  --warn-fill: #fff3e3;
  --error: #9a3226;
  --ui: "Avenir Next", Avenir, system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
  --gutter: clamp(16px, 4vw, 54px);
  --max-width: 1440px;
}

* { box-sizing: border-box; }
html { min-width: 0; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font: 400 16px/1.55 var(--ui);
}
[hidden] { display: none !important; }
button, input, select { font: inherit; }
h1, h2, h3, p, dl, figure { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
a { color: var(--teal); text-underline-offset: 0.22em; }
a:hover { color: var(--ink); }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}
svg { display: block; }
section[id], div[id] { scroll-margin-top: 24px; }

.container {
  width: min(100%, var(--max-width));
  padding-inline: var(--gutter);
  margin-inline: auto;
}
.sr-only, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link:focus {
  position: absolute;
  inset: 8px auto auto 8px;
  padding: 9px 14px;
  z-index: 1;
  background: var(--paper);
}
.site-header { border-bottom: 1px solid var(--rule); background: var(--paper); }
.header-inner {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  column-gap: 25px;
  row-gap: 5px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 21px;
  font-weight: 750;
  letter-spacing: -0.045em;
  text-decoration: none;
}
.brand-accent { color: var(--teal); }
.brand-icon { width: 35px; height: 35px; }
.site-header nav, .site-footer nav { display: flex; flex-wrap: wrap; gap: 3px 26px; }
.site-header nav a, .site-footer nav a {
  display: inline-block;
  color: var(--muted);
  font-size: 0.89rem;
  font-weight: 650;
  padding-block: 9px;
  text-decoration: none;
}
.site-header nav a:hover, .site-footer nav a:hover, a[aria-current="page"] { color: var(--teal); text-decoration: underline; }
.site-footer { margin-top: 68px; border-top: 1px solid var(--rule); }
.footer-inner { display: flex; justify-content: space-between; gap: 12px 32px; padding-block: 26px 30px; }
.footer-inner p { color: var(--muted); font-size: 0.88rem; margin-top: 5px; }
.footer-brand { color: var(--ink); text-decoration: none; font-weight: 750; letter-spacing: -0.03em; }

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  align-items: center;
  gap: clamp(28px, 5vw, 78px);
  padding-block: clamp(38px, 6vw, 84px) 30px;
}
.home-hero h1 {
  font-size: clamp(2.6rem, 5.5vw, 5.75rem);
  font-weight: 740;
  letter-spacing: -0.079em;
  line-height: 0.98;
  text-wrap: initial;
}
.hero-copy p {
  max-width: 40ch;
  margin-block: 21px 25px;
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.16rem);
}
.hero-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 11px 19px; }
.text-link { font-size: 0.92rem; font-weight: 700; }
.home-plot {
  min-width: 0;
  border: 1px solid var(--plot-rule);
  border-radius: 13px;
  background: var(--plot);
  overflow: hidden;
}
.featured-diagram svg, .diagram-art svg { width: 100%; height: auto; }
.home-plot figcaption { border-top: 1px solid var(--plot-rule); }
.home-plot figcaption a {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  color: var(--lime);
  font-size: 0.93rem;
  font-weight: 650;
  text-decoration: none;
}
.home-plot figcaption a:hover { color: var(--paper); text-decoration: underline; }
.home-plot figcaption a:focus-visible { outline-color: var(--lime); outline-offset: -3px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease;
}
.button:not(:disabled):hover { border-color: var(--teal); background: var(--teal-light); }
.button.primary { border-color: var(--teal); background: var(--teal); color: var(--paper); }
.button.primary:hover { background: var(--ink); color: var(--paper); }
.button.compact { min-height: 36px; padding-inline: 11px; font-size: 0.84rem; }
.button:disabled { opacity: 0.48; cursor: default; }
.use-notice {
  padding: 11px 14px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--teal);
  border-radius: 4px;
  background: #e5efea;
  color: var(--muted);
  font-size: 0.875rem;
}
.use-notice strong { color: var(--ink); }
.home-section { margin-top: 44px; }
.section-heading { padding-bottom: 13px; }
.section-heading h2, .worksheet-section h2, .reading h2 {
  font-size: clamp(1.45rem, 2.5vw, 2.05rem);
  font-weight: 740;
  letter-spacing: -0.05em;
  line-height: 1.16;
}
.section-heading p { margin-top: 7px; color: var(--muted); }
.tool-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.tool-grid li { min-width: 0; }
.tool-card {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  min-height: 108px;
  height: 100%;
  padding: 16px 12px 14px 14px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
}
.tool-card:hover, .tool-card:focus-visible { border-color: var(--teal); }
.tool-card:hover strong { color: var(--teal); text-decoration: underline; }
.tool-icon { width: 31px; height: 31px; color: var(--teal); }
.card-copy { display: flex; flex-direction: column; gap: 4px; }
.card-copy strong { line-height: 1.23; font-weight: 730; }
.card-copy span { color: var(--muted); font-size: 0.85rem; line-height: 1.4; }
.card-arrow { color: var(--teal); font-size: 0.95rem; line-height: 1.25; }
.guide-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px 24px; }
.guide-group { border-top: 1px solid var(--rule); padding-top: 11px; }
.guide-group h3 { font-size: 1rem; font-weight: 700; }
.guide-group h3 a { color: var(--ink); text-decoration: none; }
.guide-group h3 a:hover { text-decoration: underline; }
.guide-group ul, .related-examples { margin: 7px 0 0; padding: 0; list-style: none; }
.guide-group li { margin-top: 7px; font-size: 0.89rem; line-height: 1.45; }

.breadcrumbs { padding-block: 19px 17px; font-size: 0.81rem; color: var(--muted); }
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 2px 0; list-style: none; padding: 0; margin: 0; }
.breadcrumbs li + li::before { content: '/'; margin-inline: 9px; color: #627a7a; }
.breadcrumbs a { text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.page-heading { margin-bottom: 17px; }
.page-heading h1, .reading h1, .missing h1 {
  max-width: 30ch;
  font-size: clamp(2.2rem, 4.4vw, 4.15rem);
  line-height: 1.045;
  font-weight: 740;
  letter-spacing: -0.065em;
  text-wrap: pretty;
}
.page-heading h1 { max-width: 27ch; font-size: clamp(2.06rem, 3.6vw, 3.55rem); text-wrap: balance; }
.lead { margin-top: 12px; max-width: 76ch; color: var(--muted); font-size: 1.05rem; }
.example-tool { margin-top: 10px; font-size: 0.88rem; font-weight: 650; }
.missing { padding-top: clamp(44px, 10vw, 120px); padding-bottom: clamp(20px, 6vw, 70px); }
.missing .hero-actions { margin-top: 21px; }
.reading { max-width: 790px; }
.reading h2 { margin-top: 29px; margin-bottom: 8px; }
.reading p + p { margin-top: 12px; }
.reading .use-notice { margin-top: 20px; }
.reference-list { padding-left: 20px; }
.reference-list li { margin-block: 9px; }
.reference-list strong { font-weight: 650; }
.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 0.9fr) minmax(0, 1.3fr);
  gap: clamp(12px, 1.9vw, 27px);
  align-items: start;
  margin-top: 16px;
}
.input-panel, .readout-panel, .worksheet-actions {
  min-width: 0;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: var(--paper);
}
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 47px;
  padding: 8px 15px;
  border-bottom: 1px solid var(--rule);
}
.panel-heading h2, .diagram-heading h2 {
  font-size: 1.08rem;
  letter-spacing: -0.025em;
  font-weight: 750;
}
.jump-results { display: none; font-size: 0.82rem; font-weight: 650; }
.input-panel noscript p { margin: 12px 15px 0; }
.input-body { padding: 12px 15px 17px; }
.unit-bar {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  padding-bottom: 13px;
  margin-bottom: 13px;
  border-bottom: 1px solid var(--rule);
}
.unit-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
  padding: 3px 5px 3px 8px;
  border: 1px solid #d7e5df;
  border-radius: 5px;
  background: #eff5f1;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 650;
}
.unit-control select {
  max-width: 100%;
  height: 27px;
  padding: 1px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.76rem;
}
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 10px; }
.field { min-width: 0; }
.field-grid > .field:has(:is(#field-rule, #field-alternate)) { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 4px; font-size: 0.85rem; font-weight: 720; line-height: 1.24; }
.optional { color: var(--muted); font-size: 0.69rem; font-weight: 550; }
.control { position: relative; }
input[data-field], .field select, .share-row input {
  width: 100%;
  min-width: 0;
  min-height: 39px;
  padding: 7px 8px;
  border: 1px solid #aebfba;
  border-radius: 5px;
  background: #fbfdfc;
  color: var(--ink);
  text-overflow: ellipsis;
}
input[data-field], .share-row input {
  font-family: var(--mono);
  font-size: 0.9rem;
}
.field select { padding-right: 19px; font-size: 0.85rem; }
.input-unit {
  position: absolute;
  top: 50%;
  right: 7px;
  max-width: 49%;
  padding-left: 3px;
  transform: translateY(-50%);
  background: #fbfdfc;
  color: var(--muted);
  font: 500 0.72rem/1.1 var(--mono);
  pointer-events: none;
}
.control:has(.input-unit) input { padding-right: 47px; }
.hint, .field-error { display: block; margin-top: 4px; font-size: 0.74rem; line-height: 1.38; color: var(--muted); }
.field-error { color: var(--error); font-weight: 650; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--error); outline-color: var(--error); }
.preset-choice { margin-bottom: 12px; }
.input-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 9px 15px;
  border-top: 1px solid var(--rule);
}
.validation { flex: 1 1 125px; color: var(--error); font-size: 0.82rem; font-weight: 650; }

.table-section { min-width: 0; margin-bottom: 16px; }
.field-grid + .table-section { margin-block: 16px 0; }
.table-section h3 { font-size: 0.93rem; font-weight: 750; text-wrap: wrap; }
.table-hint { margin-block: 1px 8px; }
.edit-table { width: 100%; table-layout: fixed; border-collapse: collapse; }
.station-table th:first-child { width: 42%; }
.edit-table th:last-child { width: 28px; }
.edit-table th {
  padding: 2px 3px 3px 0;
  color: var(--muted);
  text-align: left;
  vertical-align: bottom;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.14;
}
.table-unit { font: 500 0.65rem/1.13 var(--mono); white-space: nowrap; }
.edit-table td { padding: 2px 3px 2px 0; }
.edit-table input[data-field] { min-height: 33px; padding: 4px 5px; font-size: 0.82rem; }
.edit-table input[data-field$=".name"] { font-family: var(--ui); }
.table-action { vertical-align: middle; }
.remove-row {
  width: 26px;
  min-height: 32px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  color: var(--muted);
  font-size: 1.17rem;
  line-height: 1;
  cursor: pointer;
}
.remove-row:hover:not(:disabled) { color: var(--error); border-color: var(--error); }
.remove-row:disabled { opacity: 0.45; cursor: default; }
.add-row { margin-top: 7px; }
.table-errors { padding-bottom: 5px; }

.analysis-panel { display: grid; gap: 10px; min-width: 0; }
.diagram-card { min-width: 0; border: 1px solid var(--plot-rule); border-radius: 9px; background: var(--plot); color: #effbfa; }
.diagram-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px 12px;
  padding: 10px 15px;
  border-bottom: 1px solid var(--plot-rule);
}
.live-chip { flex-shrink: 0; color: var(--lime); font: 600 0.72rem/1.15 var(--mono); }
.diagram-art { padding-inline: 2px; }
.diagram-card figcaption { padding: 8px 15px 10px; border-top: 1px solid var(--plot-rule); color: var(--plot-muted); font-size: 0.78rem; }
.primary-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.primary-metric { min-width: 0; padding: 12px 15px; }
.primary-metric + .primary-metric { border-left: 1px solid var(--rule); }
.primary-metric dt, .metric dt { color: var(--muted); font-size: 0.79rem; line-height: 1.3; font-weight: 670; }
.primary-metric dd, .metric dd { margin: 3px 0 0; }
.primary-metric .metric-value {
  color: var(--teal);
  font: 720 clamp(1.12rem, 2.04vw, 1.69rem)/1.22 var(--mono);
  letter-spacing: -0.055em;
  overflow-wrap: anywhere;
}
.primary-metric small, .metric small { display: block; margin-top: 3px; color: var(--muted); font-size: 0.73rem; line-height: 1.28; }
.result-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0 15px; }
.metric { padding: 9px 0; min-width: 0; border-top: 1px solid var(--rule); }
.result-list .metric:nth-child(odd) { padding-right: 12px; }
.metric-value { font: 650 0.92rem/1.3 var(--mono); overflow-wrap: anywhere; }
.result-notes { list-style: none; padding: 0; margin: 0 15px 9px; }
.result-note { padding: 6px 9px; background: var(--teal-light); color: var(--ink); font-size: 0.81rem; border-radius: 4px; }
.result-note.warning { background: var(--warn-fill); color: var(--warn); }
.result-note + .result-note { margin-top: 4px; }
.empty-result { padding: 13px 15px; color: var(--muted); }
.moments { padding: 7px 15px 9px; border-top: 1px solid var(--rule); }
.moments .result-list { margin-top: 7px; padding: 0; }
.moments summary { font-size: 0.83rem; color: var(--teal); font-weight: 700; cursor: pointer; }

.worksheet-actions { padding: 8px 12px; }
.button-row { display: flex; flex-wrap: wrap; gap: 6px; }
.share-panel { padding-top: 9px; }
.share-panel label { display: block; margin-bottom: 4px; font-size: 0.8rem; font-weight: 700; }
.share-row { display: flex; align-items: center; gap: 6px; }
.share-row input { flex: 1; min-height: 36px; font-size: 0.77rem; }
.share-row button { flex-shrink: 0; }
.action-status { color: var(--muted); margin-top: 5px; font-size: 0.79rem; line-height: 1.3; }
.action-status:empty { margin-top: 0; }
.print-inputs { display: none; }

.worksheet-reading { max-width: 810px; margin-top: 30px; }
.worksheet-section { padding-block: 18px 19px; border-top: 1px solid var(--rule); }
.worksheet-section h2 { margin-bottom: 8px; }
.worksheet-section p + p { margin-top: 8px; }
.try-it {
  margin-top: 10px;
  padding: 8px 11px;
  border-left: 3px solid var(--teal);
  background: #e1efe7;
}
.try-it h3 { color: var(--teal); font-size: 0.91rem; font-weight: 740; }
.faq { border-bottom: 1px solid var(--rule); }
.faq:last-child { border-bottom: 0; }
.faq summary {
  cursor: pointer;
  padding-block: 9px;
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 700;
}
.faq summary::marker { color: var(--teal); }
.faq > p { padding: 0 0 9px 15px; color: var(--muted); }
.related-examples li { margin-top: 5px; }

@media (max-width: 1120px) {
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-card { min-height: 88px; }
  .guide-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 850px) {
  .home-hero { grid-template-columns: minmax(0, 1fr); }
  .home-hero h1 { font-size: clamp(2.75rem, 9vw, 4.6rem); }
  .home-plot { max-width: 660px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .jump-results { display: inline; }
  .primary-metric .metric-value { font-size: clamp(1.12rem, 3.2vw, 1.6rem); }
  .analysis-panel { gap: 8px; }
}
@media (max-width: 620px) {
  .guide-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .footer-inner { flex-direction: column; }
  .site-footer { margin-top: 39px; }
}
@media (max-width: 500px) {
  .header-inner { flex-wrap: wrap; justify-content: flex-start; padding-block: 8px 4px; }
  .site-header nav { width: 100%; gap: 3px 19px; }
  .site-header nav a { padding-block: 5px; }
  .tool-grid { grid-template-columns: minmax(0, 1fr); }
  .tool-card { min-height: 0; }
  .home-section { margin-top: 31px; }
  .home-hero { padding-top: 29px; }
  .reading .lead, .page-heading .lead { font-size: 1rem; }
  .input-body { padding-inline: 11px; }
  .field-grid > .field:has(:is(#field-model, #field-mode, #field-fuelType, #field-coordMode)) { grid-column: 1 / -1; }
  .primary-metric { padding-inline: 11px; }
  .diagram-heading { padding-inline: 11px; }
  .input-panel, .worksheet-actions, .readout-panel { border-radius: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}

@page { margin: 13mm; }
@media print {
  :root { --page: #fff; --ink: #11292d; --muted: #344d4e; --rule: #bbc9c7; }
  body { background: white; font-size: 10pt; }
  .container { max-width: none; padding: 0; }
  .site-header, .site-footer, .breadcrumbs, .skip-link, .hero-actions, .input-panel,
  .worksheet-actions, .worksheet-reading, .example-tool, .live-chip { display: none !important; }
  .workspace, .analysis-panel { display: block; margin-top: 8px; }
  .print-inputs { display: block; margin-top: 12px; }
  .print-inputs h2, .print-inputs h3 { margin-block: 5px; font-size: 13pt; }
  .print-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .print-values div { padding: 4px 5px 4px 0; border-top: 1px solid var(--rule); }
  .print-values dt { margin: 0; color: var(--muted); }
  .print-values dd { margin: 0; font: 650 9pt/1.3 var(--mono); }
  .page-heading, .reading, .missing { padding: 0; margin-bottom: 8px; }
  .page-heading h1, .reading h1, .missing h1, .home-hero h1 { font-size: 23pt; }
  .lead { font-size: 10pt; margin-top: 4px; }
  .use-notice { padding: 5px 7px; font-size: 8pt; }
  .diagram-card, .primary-results, .metric, .tool-card, .guide-group, .print-values div { break-inside: avoid; }
  .diagram-card { max-width: 490px; margin-bottom: 8px; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .diagram-heading, .diagram-card figcaption { padding-block: 4px; }
  .panel-heading { min-height: 0; padding-block: 3px; }
  .primary-metric { padding-block: 6px; }
  .primary-metric .metric-value { font-size: 13pt; }
  .metric { padding-block: 4px; }
  .metric-value { font-size: 9pt; }
  .home-hero { display: block; padding: 0 0 10px; }
  .home-plot { max-width: 440px; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .home-section { margin-top: 18px; }
  .tool-card { min-height: 0; }
  .guide-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
