/* Layout: a working bench — slim header band, tool card with inputs left and live results right, guides set as a single readable column. */
:root {
  --bg: #F2F4EF;
  --surface: #FFFFFF;
  --field: #F8FAF6;
  --ink: #1C2823;
  --muted: #5A6A62;
  --line: #D7DED8;
  --accent: #A9640B;
  --accent-strong: #8A4F05;
  --accent-ink: #FFFFFF;
  --accent-soft: #F5E6CC;
  --warn: #9E3F1A;
  --warn-soft: #F7E1D6;
  --ok: #2E6A4E;
  --ok-soft: #DDEDE3;
  --f-display: "Young Serif", Georgia, "Times New Roman", serif;
  --f-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101513; --surface: #171E1B; --field: #131A17; --ink: #E5EBE7; --muted: #97A79F; --line: #29342F;
    --accent: #E2A143; --accent-strong: #F0B65E; --accent-ink: #1A1206; --accent-soft: #33281A;
    --warn: #F0906A; --warn-soft: #3A231A; --ok: #7DC4A0; --ok-soft: #1C3127;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101513; --surface: #171E1B; --field: #131A17; --ink: #E5EBE7; --muted: #97A79F; --line: #29342F;
  --accent: #E2A143; --accent-strong: #F0B65E; --accent-ink: #1A1206; --accent-soft: #33281A;
  --warn: #F0906A; --warn-soft: #3A231A; --ok: #7DC4A0; --ok-soft: #1C3127;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.6;
}
img, svg { max-width: 100%; }
a { color: var(--accent-strong); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.narrow { max-width: 760px; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; padding-block: 14px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand svg { width: 26px; height: 26px; flex: none; }
.brand-name { font-family: var(--f-display); font-size: 1.35rem; line-height: 1; }
.nav { display: flex; gap: 4px 18px; flex-wrap: wrap; font-size: 0.95rem; }
.nav a { color: var(--muted); text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* Page heading */
.page-head { padding-block: 40px 20px; }
.eyebrow { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-strong); margin: 0 0 8px; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 400; line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.7rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.7rem); }
h3 { font-size: 1.15rem; }
.lede { font-size: 1.1rem; color: var(--muted); max-width: 62ch; margin: 12px 0 0; }

/* Calculator */
.calc {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.calc-inputs { padding: 24px; display: grid; gap: 18px; align-content: start; }
.calc-results { padding: 24px; background: var(--field); border-left: 1px solid var(--line); display: grid; gap: 16px; align-content: start; }
@media (max-width: 820px) {
  .calc { grid-template-columns: minmax(0, 1fr); }
  .calc-results { border-left: 0; border-top: 1px solid var(--line); }
}
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .group-label { font-size: 0.9rem; font-weight: 600; }
.hint { font-size: 0.84rem; color: var(--muted); margin: 0; line-height: 1.45; }
.input-unit { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 8px; background: var(--field); overflow: hidden; }
.input-unit:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-unit input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; font-variant-numeric: tabular-nums; padding: 10px 12px; }
.input-unit input:focus { outline: none; }
.input-unit .unit { display: flex; align-items: center; padding: 0 12px; color: var(--muted); font-size: 0.9rem; border-left: 1px solid var(--line); white-space: nowrap; }
.input-unit .unit.pre { border-left: 0; border-right: 1px solid var(--line); padding-right: 10px; }
select {
  font: inherit; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%;
}
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 3px; background: var(--field); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { padding: 6px 12px; border-radius: 6px; font-size: 0.9rem; cursor: pointer; color: var(--muted); }
.seg input:checked + label { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.12); font-weight: 600; }
.seg input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 1px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 6px; }
legend { padding: 0; font-size: 0.9rem; font-weight: 600; margin-bottom: 6px; }

details.adv { border-top: 1px dashed var(--line); padding-top: 12px; }
details.adv summary { cursor: pointer; font-size: 0.9rem; color: var(--muted); }
details.adv[open] summary { margin-bottom: 12px; }

/* Results */
.res-title { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0; }
.res-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; min-width: 0; }
.stat .k { font-size: 0.84rem; color: var(--muted); }
.stat .v { font-size: 1.55rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; overflow-wrap: anywhere; }
.stat .s { font-size: 0.84rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.stat.lead { border-color: var(--accent); background: var(--accent-soft); }
.res-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.res-table td { padding: 7px 0; border-bottom: 1px solid var(--line); }
.res-table td:last-child { text-align: right; font-weight: 600; }
.res-table tr.total td { border-bottom: 0; border-top: 2px solid var(--ink); font-weight: 700; }
.res-table .sub { color: var(--muted); font-weight: 400; }
.note { font-size: 0.88rem; padding: 10px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); margin: 0; }
.note.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.note.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.empty { color: var(--muted); font-size: 0.95rem; }

.gauge { display: grid; gap: 6px; }
.gauge-track { position: relative; height: 10px; border-radius: 99px; background: var(--line); }
.gauge-fill { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--accent); transition: width 0.25s ease; }
.gauge-fill.over { background: var(--warn); }
.gauge-max { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); }
.gauge-scale { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
}
.btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.copied { font-size: 0.85rem; color: var(--ok); }

/* Sections */
.section { padding-block: 40px; }
.section + .section { padding-top: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-top: 18px; }
.card { display: grid; gap: 6px; align-content: start; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.card:hover { border-color: var(--accent); color: var(--ink); }
.card .card-kicker { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-strong); }
.card p { margin: 0; color: var(--muted); font-size: 0.95rem; }

/* Prose (guides, about) */
.prose { max-width: 68ch; }
.prose > * + * { margin-top: 1em; }
.prose h2 { margin-top: 1.8em; }
.prose h3 { margin-top: 1.4em; }
.prose p, .prose ul, .prose ol { margin-bottom: 0; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 0.35em; }
.prose .callout { padding: 14px 16px; border-radius: 8px; background: var(--accent-soft); }
.prose code { font-size: 0.92em; background: var(--field); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; }
.formula { font-variant-numeric: tabular-nums; padding: 12px 16px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 8px 8px 0; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.data { width: 100%; border-collapse: collapse; font-size: 0.93rem; font-variant-numeric: tabular-nums; }
.data th, .data td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; background: var(--field); }
.data tr:last-child td { border-bottom: 0; }
.data td.num, .data th.num { text-align: right; }
.meta { font-size: 0.88rem; color: var(--muted); }
.sources { font-size: 0.9rem; }
.related { margin-top: 2em; padding-top: 1.2em; border-top: 1px solid var(--line); }

/* Ad slots: hidden on the live site until AdSense is approved and code is added. */
.ad-slot { display: none; }
.show-ad-slots .ad-slot {
  display: flex; align-items: center; justify-content: center; min-height: 100px; margin-block: 24px;
  border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase;
}

/* Footer */
.site-footer { border-top: 1px solid var(--line); margin-top: 40px; background: var(--surface); }
.site-footer .wrap { padding-block: 24px; display: grid; gap: 10px; font-size: 0.9rem; color: var(--muted); }
.footer-links { display: flex; gap: 6px 18px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
