:root {
  --bg: #f1f5f4;
  --surface: #ffffff;
  --ink: #13282b;
  --muted: #4a6064;
  --line: #d5e0de;
  --link: #0a5a6b;
  --accent: #e3a008;
  --accent-ink: #3a2800;
  --panel: #0f3a42;
  --panel-ink: #eaf4f2;
  --panel-muted: #a9c7c6;
  --focus: #0a5a6b;
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --sans: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b1a1d;
    --surface: #11272b;
    --ink: #e6f0ee;
    --muted: #9db4b2;
    --line: #26403f;
    --link: #6cc4d6;
    --accent-ink: #1c1300;
    --panel: #0a2d34;
    --focus: #6cc4d6;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
}
a { color: var(--link); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--bg); padding: 0.6rem 1rem; z-index: 10; }
.skip:focus { left: 0; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 740px; }

/* header */
.site-head { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-head .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem; padding-top: 14px; padding-bottom: 14px; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; font-family: var(--serif); font-size: 1.55rem; font-weight: 600; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.brand svg { width: 28px; height: 28px; flex: none; }
.nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.4rem; }
.nav a { color: var(--ink); text-decoration: none; font-weight: 500; padding: 0.25rem 0; border-bottom: 2px solid transparent; }
.nav a:hover, .nav a[aria-current='page'] { border-bottom-color: var(--accent); }

/* typography */
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; letter-spacing: -0.012em; font-weight: 600; margin: 0; }
h1 { font-size: clamp(2rem, 4.6vw, 3.1rem); }
h2 { font-size: clamp(1.45rem, 3vw, 1.9rem); margin-top: 2.6rem; margin-bottom: 0.7rem; }
h3 { font-size: 1.28rem; margin-top: 1.9rem; margin-bottom: 0.4rem; }
p { margin: 0 0 1.05rem; }
.lead { font-size: 1.2rem; color: var(--muted); max-width: 40rem; }
.crumbs { font-size: 0.92rem; color: var(--muted); margin: 1.4rem 0 0.9rem; }
.crumbs a { color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 0.2rem 1.4rem; color: var(--muted); font-size: 0.95rem; margin: 0.9rem 0 0; }

/* hero */
.hero { padding: 3rem 0 2.6rem; }
.hero .grid { display: grid; gap: 2.2rem; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 880px) { .hero .grid { grid-template-columns: 1.15fr 1fr; gap: 3.2rem; } }
.hero h1 { margin-bottom: 1.1rem; max-width: 15ch; }
.hero .actions { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 1.6rem; }
.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; padding: 0.7rem 1.2rem; border-radius: 6px; border: 0; font-size: 1rem; cursor: pointer; font-family: var(--sans); }
.btn:hover { filter: brightness(0.95); }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }

/* calculator surfaces */
.quick, .calc-result { background: var(--panel); color: var(--panel-ink); border-radius: 10px; padding: 1.4rem; }
.quick h2 { color: var(--panel-ink); margin: 0 0 0.3rem; font-size: 1.35rem; }
.quick p.sub { color: var(--panel-muted); font-size: 0.95rem; margin-bottom: 1rem; }
.quick .row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.7rem; margin-bottom: 1.1rem; }
.quick label { display: block; font-size: 0.82rem; color: var(--panel-muted); margin-bottom: 0.2rem; line-height: 1.3; }
.quick input { width: 100%; font: inherit; padding: 0.55rem 0.6rem; border-radius: 6px; border: 1px solid #3c6a70; background: #0b2c33; color: var(--panel-ink); }
.result-head { font-family: var(--serif); font-size: 1.55rem; line-height: 1.25; margin: 0 0 0.9rem; color: #ffd36b; }
.result-rows { margin: 0; }
.result-rows div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.5rem 0; border-top: 1px solid rgba(255, 255, 255, 0.16); font-size: 0.98rem; }
.result-rows dt { color: var(--panel-muted); margin: 0; }
.result-rows dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.result-note { color: var(--panel-muted); font-size: 0.92rem; margin: 0.9rem 0 0; }
.result-empty { color: var(--panel-muted); margin: 0; }

/* tool layout */
.tool-grid { display: grid; gap: 1.6rem; grid-template-columns: 1fr; margin: 1.6rem 0 0.5rem; align-items: start; }
@media (min-width: 900px) { .tool-grid { grid-template-columns: 1.05fr 0.95fr; } .calc-result { position: sticky; top: 16px; } }
.calc-form { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1.4rem; }
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-weight: 600; font-size: 0.97rem; margin-bottom: 0.25rem; }
.control { display: flex; align-items: stretch; }
.control input, .control select, .calc-form select { font: inherit; width: 100%; padding: 0.6rem 0.7rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); min-width: 0; }
.control input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.control .unit { display: inline-flex; align-items: center; padding: 0 0.75rem; border: 1px solid var(--line); border-left: 0; border-radius: 0 6px 6px 0; background: var(--surface); color: var(--muted); font-size: 0.92rem; white-space: nowrap; }
.control select { border-radius: 6px; }
.hint { font-size: 0.88rem; color: var(--muted); margin: 0.3rem 0 0; line-height: 1.45; }
.form-top { display: grid; gap: 0.9rem; grid-template-columns: 1fr; margin-bottom: 1.2rem; padding-bottom: 1.2rem; border-bottom: 1px solid var(--line); }
.reset { background: none; border: 0; color: var(--link); font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }

/* article */
.article { padding-bottom: 2rem; }
.article ul, .article ol { padding-left: 1.3rem; margin: 0 0 1.1rem; }
.article li { margin-bottom: 0.4rem; }
.article table { width: 100%; border-collapse: collapse; margin: 1.2rem 0 1.5rem; font-size: 0.97rem; display: block; overflow-x: auto; }
.article th, .article td { text-align: left; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.article th { font-weight: 600; background: var(--surface); }
.article blockquote { margin: 1.3rem 0; padding: 0.2rem 0 0.2rem 1.1rem; border-left: 4px solid var(--accent); color: var(--muted); }
.article code { font-size: 0.93em; background: var(--surface); padding: 0.1rem 0.35rem; border-radius: 4px; border: 1px solid var(--line); }
.formula { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 0.9rem 1.1rem; border-radius: 6px; margin: 1.2rem 0; font-variant-numeric: tabular-nums; }
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem 1.2rem; margin: 1.6rem 0; }
.toc p { font-weight: 600; margin: 0 0 0.4rem; }
.toc ol { margin: 0; padding-left: 1.2rem; font-size: 0.98rem; }
.toc li { margin-bottom: 0.2rem; }

/* lists on home / hubs */
.section { padding: 2.2rem 0; }
.section h2 { margin-top: 0; }
.tool-list { list-style: none; margin: 1.2rem 0 0; padding: 0; display: grid; gap: 0 2.4rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .tool-list { grid-template-columns: 1fr 1fr; } }
.tool-list li { border-top: 1px solid var(--line); padding: 1rem 0; }
.tool-list a { font-family: var(--serif); font-size: 1.28rem; font-weight: 600; text-decoration: none; color: var(--ink); }
.tool-list a:hover { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 3px; }
.tool-list p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.99rem; }
.guide-list { list-style: none; margin: 1.2rem 0 0; padding: 0; }
.guide-list li { border-top: 1px solid var(--line); padding: 1rem 0; }
.guide-list a { font-family: var(--serif); font-size: 1.28rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.guide-list a:hover { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 3px; }
.guide-list p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.99rem; }
.guide-list small { color: var(--muted); }
.related { border-top: 1px solid var(--line); margin-top: 2.6rem; padding-top: 1.6rem; }
.related h2 { margin-top: 0; font-size: 1.4rem; }
.related ul { padding-left: 1.2rem; }
.byline-box { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.2rem; margin-top: 2rem; font-size: 0.97rem; color: var(--muted); }
.byline-box p { margin: 0; }
.notice { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 0.9rem 1.1rem; border-radius: 6px; margin: 1.4rem 0; font-size: 0.98rem; }

/* footer */
.site-foot { background: var(--surface); border-top: 1px solid var(--line); margin-top: 3rem; padding: 2.2rem 0 2.6rem; font-size: 0.97rem; color: var(--muted); }
.foot-grid { display: grid; gap: 1.6rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .foot-grid { grid-template-columns: 1.4fr 1fr 1fr; } }
.site-foot h2 { font-family: var(--sans); font-size: 0.98rem; margin: 0 0 0.5rem; color: var(--ink); letter-spacing: 0; }
.site-foot ul { list-style: none; padding: 0; margin: 0; }
.site-foot li { margin-bottom: 0.3rem; }
.site-foot a { color: var(--muted); }
.fine { margin-top: 1.6rem; padding-top: 1.2rem; border-top: 1px solid var(--line); font-size: 0.9rem; }

/* mobile result bar */
.result-bar { display: none; }
@media (max-width: 899px) {
  .result-bar { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--panel); color: #ffd36b; font-family: var(--serif); font-size: 1.1rem; line-height: 1.3; padding: 0.7rem 16px; box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.25); }
  body:has(.result-bar) { padding-bottom: 3.4rem; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media (max-width: 520px) { .quick .row { grid-template-columns: 1fr; } .result-rows div { flex-direction: column; gap: 0.1rem; } .result-rows dd { text-align: left; } }
