:root {
  color-scheme: light;
  --paper: #f6f7f3;
  --white: #fff;
  --ink: #16313e;
  --muted: #4d6269;
  --edge: #d6e0db;
  --teal: #12675e;
  --teal-edge: #b8d5ce;
  --teal-wash: #e8f3ee;
  --amber: #ffd078;
  --dark: #142e3b;
  --danger: #a02e33;
  --body: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --display: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 0; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 1rem/1.58 var(--body); }
a { color: var(--teal); text-underline-offset: .19em; }
a:hover { color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .48; cursor: default; }
:focus-visible { outline: 3px solid #0c8273; outline-offset: 3px; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.1; overflow-wrap: anywhere; }
h1, h2 { letter-spacing: -.04em; font-family: var(--display); }
ul, ol { padding-inline-start: 1.45em; }
.shell { width: min(1180px, calc(100% - 72px)); margin-inline: auto; }
.skip-link { position: absolute; inset: 8px auto auto 8px; padding: 9px 14px; background: var(--white); z-index: 9; transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }

.site-header { border-bottom: 1px solid var(--edge); }
.header-inner { display: flex; justify-content: space-between; align-items: center; gap: 22px; min-height: 72px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; font-size: 1.08rem; letter-spacing: -.035em; text-decoration: none; white-space: nowrap; }
.brand img { width: 34px; height: 34px; }
.site-nav, .footer-nav { display: flex; flex-wrap: wrap; gap: 10px 25px; align-items: center; }
.site-nav a, .footer-nav a { font-size: .92rem; color: var(--muted); text-decoration: none; font-weight: 650; }
.site-nav a:hover, .footer-nav a:hover { color: var(--teal); text-decoration: underline; }
.site-footer { margin-top: 70px; border-top: 1px solid var(--edge); }
.footer-inner { padding-block: 28px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px 25px; }

.hero { overflow: hidden; position: relative; display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1fr); margin-top: 30px; background: var(--dark); color: #f4faf6; border-radius: 18px; }
.hero-copy { padding: clamp(28px, 4.6vw, 69px); align-self: center; min-width: 0; }
.hero h1 { font-size: clamp(3.1rem, 6.3vw, 6.35rem); line-height: .93; letter-spacing: -.067em; }
.hero h1 em { color: var(--amber); font-family: Georgia, serif; font-size: .84em; font-weight: 400; letter-spacing: -.085em; display: block; }
.hero p { margin-top: 22px; color: #c8dcd9; max-width: 32ch; }
.hero-actions { margin-top: 24px; display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; }
.hero-actions a { min-height: 44px; }
.hero-actions .hero-secondary { color: #e7f1ec; display: inline-flex; align-items: center; font-weight: 650; }
.hero .button { background: var(--amber); color: var(--dark); border-color: var(--amber); }
.hero a:focus-visible { outline-color: var(--amber); }
.hero-graphic { margin: 0; padding: 24px 30px 22px 0; align-self: center; min-width: 0; }
.hero-graphic svg { width: 100%; height: auto; border: 1px solid #395461; border-radius: 12px; }
.hero-graphic figcaption { padding-top: 9px; color: #b8cfcc; font: .79rem/1.5 var(--mono); }

.index-section { margin-top: 56px; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 9px 25px; margin-bottom: 17px; }
.section-heading h2 { font-size: clamp(1.85rem, 3vw, 2.85rem); }
.section-heading p { color: var(--muted); }
.tool-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tool-card { display: flex; flex-direction: column; gap: 9px; min-height: 180px; padding: 18px; background: var(--white); color: var(--ink); text-decoration: none; border: 1px solid var(--edge); border-radius: 11px; }
.tool-card:hover { border-color: var(--teal); background: #f9fcf9; }
.card-top { display: flex; align-items: center; justify-content: space-between; color: var(--teal); gap: 12px; }
.card-top svg { width: 30px; height: 30px; }
.card-top span { font-size: 1.2rem; }
.tool-card h3 { font-size: 1.18rem; letter-spacing: -.02em; }
.tool-card p { color: var(--muted); font-size: .93rem; line-height: 1.48; }

.example-index { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 9px 13px; }
.example-index details, .faq-list details { border: 1px solid var(--edge); border-radius: 9px; background: var(--white); }
summary { cursor: pointer; font-weight: 730; }
.example-index summary, .faq-list summary { padding: 12px 15px; overflow-wrap: anywhere; }
.example-index ul { margin: 0 15px 13px; }
.example-index li + li { margin-top: 4px; }
.example-index li a { font-size: .95rem; }

.breadcrumbs { margin-top: 23px; }
.breadcrumbs ol { list-style: none; margin: 0; padding: 0; display: flex; gap: 5px 9px; flex-wrap: wrap; color: var(--muted); align-items: center; font-size: .87rem; }
.breadcrumbs li { overflow-wrap: anywhere; }
.breadcrumbs li + li::before { content: "/"; margin-right: 9px; color: #718185; }
.page-intro { margin: 29px 0 24px; max-width: 880px; }
.place { margin-bottom: 7px; color: var(--teal); font-weight: 750; letter-spacing: .025em; }
.page-intro h1 { font-size: clamp(2.15rem, 4.7vw, 4.35rem); line-height: .99; }
.page-intro .lead { margin-top: 13px; color: var(--muted); font-size: clamp(1rem, 1.8vw, 1.19rem); max-width: 70ch; }
.scenario { max-width: 73ch; margin-bottom: 22px; padding: 13px 16px; border-left: 3px solid var(--teal); background: var(--teal-wash); }
.scenario p + p { margin-top: 7px; }

.calculator-grid { display: grid; grid-template-columns: minmax(268px, .79fr) minmax(0, 1.67fr); gap: 14px; align-items: start; }
.calculator-grid > * { min-width: 0; }
.controls, .readout { min-width: 0; border: 1px solid var(--edge); border-radius: 13px; background: var(--white); }
.controls { padding: clamp(13px, 2.2vw, 22px); }
.control-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 14px; }
.control-head h2, .readout-head h2 { font-size: 1.3rem; letter-spacing: -.025em; }
.unit-picker { display: inline-flex; gap: 2px; padding: 3px; background: var(--paper); border: 1px solid var(--edge); border-radius: 8px; }
.unit-picker button { color: var(--muted); font-size: .84rem; font-weight: 700; padding: 5px 10px; border: 1px solid transparent; border-radius: 6px; background: transparent; }
.unit-picker button[aria-pressed="true"] { color: var(--teal); background: var(--white); border-color: var(--teal-edge); }
.unit-help { margin: 10px 0 15px; font-size: .85rem; color: var(--muted); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 10px; }
.field { min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 3px; color: var(--ink); font-size: .88rem; font-weight: 750; line-height: 1.32; overflow-wrap: anywhere; }
.field-unit { margin-left: 3px; color: var(--teal); font: .79rem/1.2 var(--mono); }
.field-unit:empty { display: none; }
.field input, .field select, .share input, .share select { display: block; min-width: 0; width: 100%; max-width: 100%; min-height: 42px; padding: 7px 8px; border: 1px solid #b3c6c3; border-radius: 7px; color: var(--ink); background: #fbfdfa; font-size: .94rem; }
.field input[type="date"], .field input[type="time"] { font-size: .87rem; }
.field [aria-invalid="true"] { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.field-hint, .field-error { display: block; margin-top: 4px; font-size: .77rem; line-height: 1.42; }
.field-hint { color: var(--muted); }
.field-error { color: var(--danger); font-weight: 680; }
.field-error:empty, .field-hint:empty { display: none; }
.control-footer { margin-top: 15px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 6px 11px; border: 1px solid #b8cbc7; border-radius: 7px; background: #f9fcfa; color: var(--ink); text-decoration: none; font-weight: 750; line-height: 1.25; font-size: .89rem; text-align: center; }
.button:hover:not(:disabled) { background: var(--teal-wash); border-color: var(--teal); }
.button-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.button-primary:hover:not(:disabled) { color: var(--ink); }
.hero .button:hover { background: #ffe2a2; border-color: #ffe2a2; }
.readout-head { padding: 14px 17px 10px; }
.diagram { margin: 0 12px; container-type: inline-size; }
.diagram svg { width: 100%; height: auto; }
.readout-body { padding: 15px 16px 16px; }
.metrics { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.metric { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 5px; padding: 10px; border-radius: 8px; background: #f1f6f3; }
.metric:first-child { background: var(--teal-wash); }
.metric dt { color: var(--muted); font-size: .78rem; line-height: 1.27; font-weight: 700; }
.metric dd { margin: 0; color: var(--ink); font-size: clamp(.94rem, 1.7vw, 1.25rem); font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.result-note { margin: 11px 0 16px; color: var(--muted); font-size: .89rem; }
.data-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .85rem; line-height: 1.35; }
.data-table + .data-table { margin-top: 16px; }
.data-table caption { padding-bottom: 6px; text-align: start; font-weight: 750; color: var(--ink); }
.data-table th, .data-table td { overflow-wrap: anywhere; vertical-align: top; text-align: start; border-bottom: 1px solid var(--edge); padding: 6px 5px; }
.data-table thead th { color: var(--muted); font-weight: 650; }
.data-table tbody th { font-weight: 750; }
.data-table td { color: var(--ink); }
.validation { color: var(--danger); margin-bottom: 12px; font-weight: 680; }
.action-area { padding: 0 16px 13px; margin-top: 1px; }
.action-row { display: flex; gap: 6px; flex-wrap: wrap; }
.status { color: var(--teal); font-size: .85rem; margin-top: 6px; }
.status:empty { margin-top: 0; }
.share { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 6px 8px; margin-top: 11px; }
.share label { font-size: .85rem; font-weight: 700; }
.share .share-format { grid-column: 1 / -1; max-width: 250px; }
.share p { grid-column: 1 / -1; color: var(--muted); font-size: .8rem; }
.share input { font: .78rem var(--mono); }
.print-only { display: none; }
.no-script { margin: 9px 16px 12px; color: var(--muted); }

.article-lower { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); align-items: start; gap: 29px 46px; margin-top: 40px; }
.prose { max-width: 73ch; }
.prose h2, .related h2 { margin-bottom: 10px; font-size: clamp(1.43rem, 2.7vw, 2rem); }
.prose p + p { margin-top: 10px; }
.prose section + section { margin-top: 26px; }
.related { padding: 17px; border: 1px solid var(--edge); border-radius: 10px; background: var(--white); }
.related ul { margin: 0; }
.related li + li { margin-top: 6px; }
.faq-list { display: grid; gap: 7px; }
.faq-list p { padding: 0 15px 13px; color: var(--muted); }
.info-page { min-height: 42vh; }
.info-page .prose { margin-bottom: 32px; }
.info-page .button { margin-top: 15px; }

@media (max-width: 1020px) {
  .shell { width: calc(100% - 44px); }
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-copy { padding: 34px; }
  .hero-graphic { padding: 18px 17px 17px 0; }
  .hero h1 { font-size: clamp(3.2rem, 7.3vw, 5.5rem); }
}
@media (max-width: 720px) {
  .shell { width: calc(100% - 30px); }
  .hero { grid-template-columns: minmax(0, 1fr); margin-top: 18px; }
  .hero-copy { padding: 29px 23px 10px; }
  .hero p { margin-top: 13px; }
  .hero-actions { margin-top: 14px; }
  .hero-graphic { padding: 12px 15px 14px; }
  .header-inner { flex-wrap: wrap; justify-content: space-between; gap: 5px 18px; padding-block: 9px; }
  .site-nav { gap: 7px 16px; }
  .site-nav a { font-size: .86rem; }
  .index-section, .site-footer { margin-top: 35px; }
  .calculator-grid, .article-lower { grid-template-columns: minmax(0, 1fr); }
  .article-lower { gap: 24px; }
  .tool-card { min-height: 166px; padding: 13px; }
  .page-intro { margin-top: 21px; }
}
@media (max-width: 480px) {
  .header-inner { justify-content: flex-start; }
  .site-nav { flex-basis: 100%; padding-bottom: 2px; }
  .example-index { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .data-table { font-size: .76rem; }
  .data-table th, .data-table td { padding-inline: 3px; }
  .diagram { margin-inline: 8px; }
}
@media (max-width: 342px) {
  .tool-grid, .fields { grid-template-columns: 1fr; }
}
@media print {
  @page { margin: 12mm; }
  body { background: white; color: #122a36; font-size: 10pt; }
  .shell { width: 100%; }
  .site-header, .site-footer, .breadcrumbs, .skip-link, .controls, .action-area,
  .article-lower, .no-script, .scenario [data-exercise] { display: none !important; }
  .page-intro { margin: 0 0 10pt; }
  .page-intro h1 { font-size: 24pt; }
  .page-intro .lead { font-size: 10pt; }
  .scenario { margin-bottom: 8pt; }
  .calculator-grid { display: block; }
  .readout { border: 0; }
  .readout-head { padding: 0 0 6pt; }
  .diagram { margin: 0; }
  .diagram svg { width: 95mm; height: auto; break-inside: avoid; print-color-adjust: exact; }
  .readout-body { padding: 7pt 0 0; }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric { padding: 4pt; border: 1px solid var(--edge); break-inside: avoid; }
  .metric dd { font-size: 10pt; }
  .result-note { margin: 5pt 0; font-size: 9pt; }
  .data-table { font-size: 8pt; }
  .data-table th, .data-table td { padding-block: 2pt; }
  .data-table tr { break-inside: avoid; }
  .print-only { display: block; }
  .print-only h2 { font-size: 12pt; margin-bottom: 3pt; }
  .print-only dl { display: flex; flex-wrap: wrap; gap: 3pt 14pt; margin: 0 0 10pt; }
  .print-only dl div { display: flex; gap: 4pt; margin: 0; }
  .print-only dt { font-weight: 700; }
  .print-only dd { margin: 0; }
}
