:root {
  color-scheme: light;
  --navy: #0b2545;
  --teal: #0e7c7b;
  --teal-dark: #096261;
  --amber: #c87d28;
  --ink: #192f45;
  --muted: #4c6273;
  --surface: #f6f8fa;
  --line: #d6e1e8;
  --white: #fff;
  --mono: "SFMono-Regular", Menlo, Consolas, monospace;
  --body: "Avenir Next", Avenir, system-ui, sans-serif;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { background: var(--surface); scroll-padding-top: 20px; }
body { margin: 0; color: var(--ink); font-family: var(--body); line-height: 1.6; }
[hidden] { display: none !important; }
a { color: var(--teal-dark); text-underline-offset: 0.2em; }
a:hover { color: var(--navy); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.5; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }
h1, h2, h3, p, figure, dl, dd { margin: 0; }
h1, h2, h3 { color: var(--navy); line-height: 1.14; overflow-wrap: anywhere; }
h1 { font-size: clamp(2.15rem, 4.25vw, 4rem); letter-spacing: -0.055em; font-weight: 770; }
h2 { font-size: clamp(1.55rem, 2.5vw, 2.25rem); letter-spacing: -0.038em; font-weight: 750; }
h3 { font-size: 1.05rem; letter-spacing: -0.016em; font-weight: 700; }
p { overflow-wrap: anywhere; }
legend { max-width: 100%; }
.wrap { width: min(100% - 72px, 1260px); margin-inline: auto; }

.skip-link { position: absolute; z-index: 5; top: 8px; left: 8px; padding: 0.55rem 0.85rem; border-radius: 6px; background: var(--white); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.site-header { background: var(--white); border-bottom: 1px solid var(--line); }
.header-row, .footer-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 76px; }
.brand { display: inline-flex; align-items: center; gap: 0.62rem; color: var(--navy); text-decoration: none; font-size: 1.24rem; font-weight: 790; letter-spacing: -0.042em; }
.brand svg { flex: 0 0 auto; width: 36px; height: 36px; }
.site-header nav, .site-footer nav { display: flex; align-items: center; flex-wrap: wrap; gap: 0.55rem clamp(0.8rem, 3vw, 2rem); }
.site-header nav a, .site-footer nav a { text-decoration: none; color: var(--muted); font-weight: 680; font-size: 0.89rem; }
.site-header nav a:hover, .site-header nav a[aria-current], .site-footer nav a:hover { color: var(--teal-dark); text-decoration: underline; }
.site-footer { border-top: 1px solid var(--line); background: var(--white); margin-top: auto; }
.footer-row { min-height: 106px; }
.footer-row .brand { font-size: 1.1rem; }
.footer-row .brand svg { width: 30px; height: 30px; }

.home-hero { background: linear-gradient(115deg, #f9fcfd 0%, #ecf4f6 100%); border-bottom: 1px solid var(--line); }
.hero-layout { min-height: 510px; padding-block: 68px 54px; display: grid; grid-template-columns: minmax(0, 0.93fr) minmax(0, 1.07fr); align-items: center; gap: clamp(2rem, 6vw, 6rem); }
.hero-copy h1 { max-width: 13ch; font-size: clamp(3rem, 5.45vw, 5.4rem); line-height: 0.99; }
.hero-copy p { max-width: 39ch; color: var(--muted); margin-top: 1.5rem; font-size: clamp(1rem, 1.5vw, 1.19rem); }
.hero-actions, .output-actions, .on-page { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.hero-actions { margin-top: 1.8rem; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 0.55rem; padding: 0.64rem 0.95rem; min-height: 43px; border: 1px solid transparent; border-radius: 7px; font-size: 0.89rem; font-weight: 710; line-height: 1.25; text-decoration: none; text-align: center; transition: background-color 120ms, border-color 120ms; }
.button.primary { color: var(--white); background: var(--navy); }
.button.primary:hover { color: var(--white); background: var(--teal-dark); }
.button.secondary { color: var(--teal-dark); background: #e9f6f4; border-color: #abcfc9; }
.button.secondary:hover { background: #d8efec; border-color: var(--teal); }
.button.plain { background: var(--white); color: var(--navy); border-color: var(--line); }
.button.plain:hover { background: #edf4f7; border-color: #88a8b6; }
.hero-figure { min-width: 0; }
.hero-drawing { display: block; width: 100%; height: auto; box-shadow: 0 16px 30px #0b254520; border-radius: 17px; }
.hero-figure figcaption { margin-top: 0.6rem; text-align: right; font-size: 0.84rem; font-weight: 690; }

.home-section { padding-block: 3.75rem; }
.section-head { margin-bottom: 1.45rem; }
.section-head p { color: var(--muted); margin-top: 0.5rem; }
.tool-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.tool-card { padding: 1.25rem; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.tool-card:focus-within, .tool-card:hover { border-color: #88b4b6; }
.tool-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.6rem; margin-bottom: 0.8rem; }
.tool-card-top span { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.015em; font-weight: 700; text-align: right; }
.tool-icon { color: var(--teal-dark); flex: 0 0 auto; }
.tool-card h3 a { display: flex; align-items: center; justify-content: space-between; gap: 0.45rem; color: var(--navy); text-decoration: none; }
.tool-card h3 a:hover { color: var(--teal-dark); text-decoration: underline; }
.tool-card h3 span { color: var(--teal-dark); font-size: 1.15rem; }
.tool-card p { color: var(--muted); font-size: 0.86rem; margin-top: 0.55rem; }
.examples-section { background: #edf4f7; border-top: 1px solid var(--line); }
.examples-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.example-group { padding: 1.15rem 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
.example-group h3 a { color: var(--navy); }
.example-group ul, .related ul { list-style: none; padding: 0; margin: 0.65rem 0 0; }
.example-group li + li { border-top: 1px solid #e8eef3; }
.example-group li a { font-size: 0.88rem; display: block; padding-block: 0.43rem; }

.engineering-page, .info-page { padding-bottom: 3.9rem; }
.crumbs { padding-top: 1.25rem; color: var(--muted); font-size: 0.8rem; }
.crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; list-style: none; padding: 0; margin: 0; }
.crumbs li:not(:first-child)::before { content: "/"; color: #8195a4; margin-right: 0.45rem; }
.crumbs a { color: var(--teal-dark); }
.page-intro { padding-block: 1.4rem 1.8rem; }
.page-intro h1 { max-width: 24ch; margin-top: 0.3rem; }
.page-intro p { max-width: 70ch; margin-top: 0.85rem; color: var(--muted); font-size: clamp(1.02rem, 1.6vw, 1.18rem); }
.page-tool-label { display: flex; gap: 0.55rem; align-items: center; color: var(--teal-dark); font-size: 0.86rem; font-weight: 720; }
.page-tool-label .tool-icon { width: 26px; height: 26px; }
.on-page { margin-top: 0.95rem; column-gap: 1.2rem; }
.on-page a { font-size: 0.87rem; font-weight: 710; }

.workbench { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 1rem; align-items: start; }
.inputs-panel, .results-panel, .worked-math, .interpretation, .methodology, .faq, .related, .text-content {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0;
}
.inputs-panel, .results-panel { padding: clamp(1.08rem, 2.1vw, 1.65rem); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1.13rem; }
.panel-head h2 { font-size: 1.55rem; }
.results-label { color: var(--muted); font-size: 0.76rem; text-align: right; }
.unit-toggle { padding: 3px; display: flex; gap: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.unit-toggle button { border: 0; border-radius: 5px; padding: 0.34rem 0.69rem; min-height: 34px; background: transparent; color: var(--navy); font: 700 0.78rem var(--mono); }
.unit-toggle button[aria-pressed="true"] { background: var(--navy); color: var(--white); }
.input-group + .input-group { margin-top: 1.15rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.input-group h3, .input-group summary { font-size: 0.98rem; color: var(--navy); font-weight: 740; }
.optional summary { cursor: pointer; }
.input-group h3, .optional[open] summary { margin-bottom: 0.75rem; }
.form-grid, .month-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.82rem; }
.field, .month-fields { min-width: 0; }
.field label, .month-fields legend, .share-box label { display: block; font-size: 0.79rem; font-weight: 700; color: var(--ink); line-height: 1.27; margin-bottom: 0.3rem; overflow-wrap: anywhere; }
.field input, .field select, .share-box input { padding: 0.54rem 0.61rem; background: #fbfdfe; color: var(--navy); border: 1px solid #bacdd7; border-radius: 6px; width: 100%; min-width: 0; min-height: 43px; }
.field input, .share-box input { font-family: var(--mono); font-size: 0.84rem; line-height: 1.35; }
.field select { font-size: 0.81rem; text-overflow: ellipsis; }
.field input[aria-invalid="true"] { border-color: #b64528; background: #fff3ef; }
.input-shell { display: flex; align-items: stretch; min-width: 0; }
.input-shell:has(.input-unit) input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-unit { background: #ecf3f7; color: var(--muted); padding: 0 0.48rem; border: 1px solid #bacdd7; border-left: 0; border-radius: 0 6px 6px 0; display: flex; align-items: center; flex-shrink: 0; font: 0.66rem var(--mono); }
.field-hint { display: block; margin-top: 0.32rem; color: var(--muted); font-size: 0.74rem; line-height: 1.4; overflow-wrap: anywhere; }
.month-fields { border: 0; margin: 0; padding: 0; grid-column: 1 / -1; }
.month-fields + .month-fields { margin-top: 0.35rem; }
.month-fields .field-hint { margin: 0 0 0.55rem; }
.month-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.58rem; }
.month-grid input { min-height: 38px; }
.form-actions { margin-top: 1.3rem; }
.form-error, .no-script { background: #fff2e9; border: 1px solid #e7bb94; color: #733918; padding: 0.65rem; margin-top: 0.55rem; border-radius: 6px; font-size: 0.87rem; }

.major-reading { display: flex; flex-direction: column; gap: 0.25rem; background: var(--navy); color: var(--white); border-left: 4px solid var(--amber); border-radius: 8px; padding: 0.95rem 1.05rem; }
.major-reading span { color: #c6dce8; font-size: 0.86rem; font-weight: 670; }
.major-reading strong { font-family: var(--mono); font-size: clamp(1.7rem, 4vw, 2.75rem); line-height: 1.18; letter-spacing: -0.065em; overflow-wrap: anywhere; }
.result-status { display: flex; gap: 0.52rem; margin-block: 0.7rem 1.15rem; padding: 0.5rem 0.58rem; background: #eef4f8; color: #28465d; border-radius: 6px; font-size: 0.78rem; line-height: 1.38; }
.result-status span { width: 7px; height: 7px; margin-top: 0.29rem; border-radius: 50%; flex: 0 0 auto; background: currentColor; }
.result-status.good { color: #0e5c55; background: #e8f5f1; }
.result-status.warn { color: #754111; background: #fff2dd; }
.result-status.danger { color: #843825; background: #fff0ea; }
.chart-tabs { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.75rem; }
.chart-tabs button { border: 1px solid #c5d9e2; padding: 0.34rem 0.58rem; min-height: 34px; border-radius: 6px; background: #fff; color: var(--navy); font-size: 0.77rem; font-weight: 700; }
.chart-tabs button[aria-pressed="true"] { background: #e4f4f2; border-color: #8cbfba; color: #075e5b; }
.chart-card, .chart-surface { min-width: 0; }
.chart-card figcaption { font-size: 0.93rem; font-weight: 730; color: var(--navy); margin-bottom: 0.4rem; }
.plot-svg { display: block; width: 100%; height: auto; }
.chart-surface { border: 1px solid #e1eaf0; border-radius: 9px; }
.chart-legend { display: flex; gap: 0.2rem 0.75rem; flex-wrap: wrap; list-style: none; margin: 0.5rem 0 0; padding: 0; }
.chart-legend li { display: flex; gap: 0.38rem; align-items: center; color: var(--muted); font-size: 0.75rem; font-weight: 650; }
.swatch { display: inline-block; width: 15px; border-top: 3px solid var(--teal); border-radius: 2px; }
.swatch.navy { border-top-color: var(--navy); }
.swatch.amber { border-top-color: #a96015; }
.swatch.slate { border-top-color: #566c81; }
.swatch.dashed { border-top-style: dashed; }
.chart-caption { color: var(--muted); font-size: 0.76rem; margin-top: 0.4rem; }
.chart-inspector { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.1rem 0.55rem; align-items: center; margin-block: 0.65rem 0.4rem; }
.chart-inspector label { color: var(--ink); font-size: 0.75rem; font-weight: 710; }
.chart-inspector input { width: 100%; min-width: 0; accent-color: var(--teal-dark); }
.chart-inspector output { grid-column: 1 / -1; color: var(--muted); font: 0.7rem/1.45 var(--mono); min-height: 1.45em; overflow-wrap: anywhere; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin-top: 0.8rem; }
.metric-grid > div { border-top: 1px solid var(--line); padding: 0.55rem 0.45rem 0.55rem 0; min-width: 0; }
.metric-grid dt { color: var(--muted); font-size: 0.76rem; line-height: 1.3; overflow-wrap: anywhere; }
.metric-grid dd { color: var(--navy); font: 680 0.89rem/1.5 var(--mono); overflow-wrap: anywhere; }
.output-actions { padding-top: 0.8rem; margin-top: 0.6rem; border-top: 1px solid var(--line); }
.output-actions .button { min-height: 38px; padding: 0.48rem 0.61rem; font-size: 0.78rem; }
.feedback { color: var(--teal-dark); font-size: 0.8rem; }
.feedback:not(:empty), .share-box { margin-top: 0.55rem; }
.share-box input { font-size: 0.76rem; }
.quick-reading, .print-inputs { display: none; }
.chart-tab-caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.worked-math, .interpretation, .methodology, .faq, .related, .text-content { margin-top: 1rem; padding: clamp(1.15rem, 3vw, 2rem); }
.worked-math h2, .interpretation h2, .methodology h2, .faq h2, .related h2, .text-content h2 { font-size: clamp(1.28rem, 2.2vw, 1.85rem); }
.math-steps { list-style: none; counter-reset: step; padding: 0; margin: 0.9rem 0 0; }
.math-steps li { display: grid; grid-template-columns: 2rem minmax(0, 1fr); gap: 0.65rem; padding-block: 0.85rem; border-top: 1px solid var(--line); }
.math-steps li::before { counter-increment: step; content: counter(step); display: grid; width: 1.78rem; height: 1.78rem; place-items: center; border-radius: 50%; background: #e8f4f2; color: var(--teal-dark); font: 700 0.85rem var(--mono); }
.math-steps li p { margin-top: 0.38rem; color: var(--muted); font-size: 0.9rem; }
.math-steps .formula { font: 0.82rem/1.52 var(--mono); color: var(--navy); }
.monthly-table { margin-top: 1rem; }
.monthly-table table { border-collapse: collapse; table-layout: fixed; width: 100%; margin-top: 0.5rem; text-align: right; font-size: 0.83rem; }
.monthly-table caption { text-align: left; color: var(--muted); font-size: 0.78rem; margin-bottom: 0.35rem; }
.monthly-table th, .monthly-table td { padding: 0.44rem 0.32rem; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.monthly-table thead th { background: #edf4f7; color: var(--navy); }
.monthly-table th:first-child { text-align: left; }
.monthly-table td { font-family: var(--mono); }
.monthly-table tbody tr:nth-child(even) { background: #f8fafc; }
.interpretation p, .methodology p, .text-content p, .faq p { margin-top: 0.55rem; max-width: 82ch; color: var(--muted); font-size: 0.94rem; }
.methodology h3, .related h3, .text-content h2:not(:first-child) { margin-top: 1.15rem; }
.reference-list { padding-left: 1.2rem; margin: 0.48rem 0 0; font-size: 0.88rem; }
.faq h2 { margin-bottom: 0.65rem; }
.faq details { border-top: 1px solid var(--line); padding-block: 0.75rem; }
.faq details:last-child { padding-bottom: 0; }
.faq summary { cursor: pointer; color: var(--navy); font-weight: 710; font-size: 0.94rem; }
.link-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem 0.85rem; }
.link-grid li a { display: flex; justify-content: space-between; gap: 0.4rem; background: #edf4f7; padding: 0.56rem 0.7rem; border-radius: 6px; font-size: 0.86rem; font-weight: 650; }
.related-tools { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; }
.related-tools a { font-size: 0.86rem; }
.info-page { min-height: max(65vh, 430px); }
.info-page .text-content { margin-top: 0; }
.info-page .button { margin-top: 1.1rem; }
.error-page { min-height: 66vh; padding-block: 5rem; }
.error-page p:not(.error-number) { margin-block: 0.8rem 1rem; color: var(--muted); }
.error-page .error-number { font: 760 2rem var(--mono); color: var(--teal-dark); }
.error-page .button { margin: 0.2rem 0.3rem 0.2rem 0; }

@media (max-width: 1100px) {
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .month-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 880px) {
  .wrap { width: calc(100% - 48px); }
  .hero-layout { min-height: 0; padding-block: 3rem 2.4rem; gap: 1.8rem; }
  .hero-copy h1 { font-size: clamp(2.5rem, 6.3vw, 4.78rem); }
  .workbench { grid-template-columns: 1fr; }
  .quick-reading { position: sticky; top: 0.45rem; z-index: 2; display: flex; align-items: center; gap: 0.48rem; margin-bottom: 0.92rem; padding: 0.55rem 0.63rem; border: 1px solid #8cbfba; border-radius: 6px; color: var(--teal-dark); background: #e8f5f3; text-decoration: none; box-shadow: 0 3px 7px #0b254514; }
  .quick-reading span:first-child { flex: 1 1 auto; min-width: 0; font-size: 0.77rem; font-weight: 700; overflow-wrap: anywhere; }
  .quick-reading strong { font: 700 0.84rem var(--mono); text-align: right; overflow-wrap: anywhere; }
  .month-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 630px) {
  .wrap { width: calc(100% - 32px); }
  .header-row, .footer-row { align-items: flex-start; flex-direction: column; justify-content: center; gap: 0.52rem; padding-block: 0.68rem; min-height: 0; }
  .site-header nav, .site-footer nav { gap: 0.45rem 1.12rem; }
  .site-header nav a, .site-footer nav a { font-size: 0.8rem; min-height: 27px; }
  .brand { font-size: 1.15rem; }
  .brand svg { width: 31px; height: 31px; }
  .hero-layout, .tool-grid, .examples-grid, .link-grid { grid-template-columns: 1fr; }
  .hero-layout { padding-block: 2.2rem 1.65rem; gap: 1.45rem; }
  .hero-copy h1 { max-width: 14ch; font-size: clamp(2.5rem, 10.7vw, 4rem); }
  .hero-copy p { margin-top: 1rem; }
  .hero-actions { margin-top: 1.1rem; }
  .hero-figure figcaption { text-align: left; }
  .home-section { padding-block: 2.4rem; }
  .tool-card { padding: 1rem; }
  .page-intro { padding-block: 1rem 1.5rem; }
  .month-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .monthly-table table { font-size: 0.66rem; }
  .monthly-table th, .monthly-table td { padding: 0.36rem 0.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
@page { margin: 14mm; }
@media print {
  body, html { background: white; font-size: 10pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .wrap { width: 100%; }
  .site-header, .site-footer, .skip-link, .crumbs, .on-page, .inputs-panel, .output-actions, .feedback, .share-box,
  .results-label, .chart-tabs, .chart-inspector, .faq, .related, .print-hide { display: none !important; }
  .page-intro { padding: 0 0 9pt; }
  .page-intro h1 { max-width: none; font-size: 24pt; }
  .page-intro p, .page-tool-label { font-size: 10pt; }
  .engineering-page { padding: 0; }
  .workbench { display: block; }
  .results-panel, .worked-math, .interpretation, .methodology { border: 0; padding: 0; margin-top: 12pt; }
  .results-panel .panel-head { margin-bottom: 6pt; }
  .major-reading strong { font-size: 21pt; }
  .plot-svg { max-height: 57mm; }
  .chart-tab-caption { position: static; width: auto; height: auto; clip-path: none; white-space: normal; }
  .chart-card, .math-steps li, .metric-grid > div, .major-reading, .monthly-table tr, .interpretation { break-inside: avoid; }
  .metric-grid, .print-inputs .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .print-inputs { display: block; margin-block: 14pt; }
  .print-inputs dd { font-size: 8.4pt; }
  figure, p { orphans: 2; widows: 2; }
}
