:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --text: #1d1f22;
  --muted: #5d636b;
  --border: #e3e0d8;
  --accent: #c2560c;
  --accent-ink: #ffffff;
  --accent-soft: #fdf0e6;
  --link: #a8470a;
  --ok: #1d6b3a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --maxw: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1d2024;
    --surface-2: #24282d;
    --text: #e9e7e3;
    --muted: #a3a8ae;
    --border: #33383e;
    --accent: #f08a3e;
    --accent-ink: #1b1206;
    --accent-soft: #2e2219;
    --link: #f5a266;
    --ok: #6fcf97;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.65 var(--font);
}
img { max-width: 100%; height: auto; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.nav { display: flex; gap: 4px 18px; flex-wrap: wrap; margin-left: auto; font-size: 15px; }
.nav a { color: var(--muted); text-decoration: none; padding: 4px 0; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); }
@media (max-width: 720px) {
  .site-header .wrap { padding-top: 10px; padding-bottom: 10px; }
  .nav { margin-left: 0; width: 100%; overflow-x: auto; flex-wrap: nowrap; white-space: nowrap; }
}

/* Breadcrumbs */
.crumbs { font-size: 14px; color: var(--muted); margin: 18px 0 6px; }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs li + li::before { content: "›"; margin-right: 6px; }
.crumbs a { color: var(--muted); }

h1, h2, h3 { line-height: 1.25; letter-spacing: -.015em; }
h1 { font-size: clamp(28px, 4.2vw, 40px); margin: 6px 0 10px; }
h2 { font-size: 25px; margin: 40px 0 12px; }
h3 { font-size: 19px; margin: 26px 0 8px; }
.lede { font-size: 18px; color: var(--muted); margin: 0 0 20px; max-width: 760px; }
.meta { font-size: 14px; color: var(--muted); margin-bottom: 18px; }

/* Layout */
.page-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; align-items: start; }
@media (max-width: 960px) { .page-grid { grid-template-columns: minmax(0, 1fr); } .sidebar { order: 2; } }
.sidebar { position: sticky; top: 16px; display: grid; gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.side-box { padding: 18px; }
.side-box h2 { font-size: 16px; margin: 0 0 10px; }
.side-box ul { list-style: none; margin: 0; padding: 0; font-size: 15px; }
.side-box li { padding: 5px 0; border-top: 1px solid var(--border); }
.side-box li:first-child { border-top: 0; }

/* Calculator */
.calc { padding: 22px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
@media (max-width: 720px) { .calc { grid-template-columns: minmax(0, 1fr); padding: 16px; } }
.calc fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.calc legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.field { margin-bottom: 14px; }
.field[hidden] { display: none; }
.field label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.input-row { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); overflow: hidden; }
.input-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-row input, .input-row select {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 17px; padding: 9px 12px; outline: none;
}
.input-row select { cursor: pointer; }
.unit { display: flex; align-items: center; padding: 0 12px; background: var(--surface-2); color: var(--muted); font-size: 14px; border-left: 1px solid var(--border); white-space: nowrap; }
.help { font-size: 13px; color: var(--muted); margin-top: 3px; }
.calc-actions { display: flex; gap: 10px; margin-top: 6px; }
.btn { font: inherit; font-size: 15px; font-weight: 600; border-radius: 8px; padding: 9px 16px; cursor: pointer; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--border); }
.results-panel { background: var(--accent-soft); border-radius: 8px; padding: 18px; align-self: start; }
.results-panel h2 { font-size: 16px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.res-primary { display: grid; gap: 12px; margin-bottom: 14px; }
.res-big { display: flex; flex-direction: column; }
.res-label { font-size: 14px; color: var(--muted); }
.res-value { font-size: 30px; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; }
.res-sub { font-size: 14px; color: var(--muted); }
.res-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.res-table th, .res-table td { padding: 7px 0; border-top: 1px solid rgba(127,127,127,.2); text-align: left; vertical-align: top; }
.res-table td { text-align: right; font-weight: 700; padding-left: 10px; }
.res-table th { font-weight: 500; }
.res-notes { margin: 12px 0 0; padding-left: 18px; font-size: 14px; color: var(--muted); }
.calc-error { color: #b42318; font-weight: 600; }
.calc-sticky { display: none; }
@media (max-width: 720px) {
  .calc-sticky {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: flex; align-items: center; gap: 18px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--accent); color: var(--accent-ink); border: 0; font: inherit; text-align: left; cursor: pointer;
    box-shadow: 0 -4px 16px rgba(0,0,0,.15); transition: transform .2s;
  }
  .calc-sticky.off { transform: translateY(110%); }
  .calc-sticky span { display: flex; flex-direction: column; line-height: 1.2; }
  .calc-sticky small { font-size: 12px; opacity: .85; }
  .calc-sticky b { font-size: 18px; }
  .calc-sticky em { margin-left: auto; font-style: normal; font-size: 13px; opacity: .9; }
}

/* Article */
.article { max-width: 760px; }
.article p, .article li { max-width: 72ch; }
.article table { width: 100%; border-collapse: collapse; margin: 14px 0 22px; font-size: 15px; background: var(--surface); }
.article th, .article td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.article thead th { background: var(--surface-2); }
.table-scroll { overflow-x: auto; }
.formula { background: var(--surface-2); border-left: 4px solid var(--accent); padding: 12px 16px; border-radius: 6px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 15px; overflow-x: auto; }
.callout { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--ok); padding: 12px 16px; border-radius: 6px; }
.faq details { border-top: 1px solid var(--border); padding: 12px 0; }
.faq details:last-child { border-bottom: 1px solid var(--border); }
.faq summary { font-weight: 700; cursor: pointer; }
.faq details p { margin: 8px 0 0; }

/* Ads */
.ad-slot { margin: 24px 0; min-height: 0; text-align: center; }
/* Hide slots (and their label) until AdSense actually fills them, e.g. before site approval. */
.ad-slot.has-ad:not(:has(ins[data-ad-status="filled"])) { margin: 0; }
.ad-slot.has-ad:not(:has(ins[data-ad-status="filled"])) .ad-label { display: none; }
.ad-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* Home */
.hero { padding: 44px 0 26px; }
.hero h1 { font-size: clamp(32px, 5vw, 50px); max-width: 820px; }
.hero p { font-size: 19px; color: var(--muted); max-width: 680px; margin: 0; }
.search { margin-top: 22px; max-width: 560px; }
.search input { width: 100%; font: inherit; font-size: 17px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.cat-block { margin: 34px 0; }
.cat-block h2 { margin: 0 0 4px; font-size: 22px; }
.cat-block > p { margin: 0 0 14px; color: var(--muted); }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.tile { display: block; padding: 16px 18px; text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile strong { display: block; font-size: 17px; margin-bottom: 4px; }
.tile span { display: block; font-size: 14px; color: var(--muted); line-height: 1.45; }
.trust { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 30px 0 10px; }
.trust div { padding: 16px; }
.trust strong { display: block; margin-bottom: 4px; }
.trust span { color: var(--muted); font-size: 15px; }

/* Footer */
.site-footer { margin-top: 60px; background: var(--surface); border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); }
.site-footer .wrap { padding-top: 28px; padding-bottom: 28px; display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
@media (max-width: 720px) { .site-footer .wrap { grid-template-columns: 1fr; } }
.site-footer h2 { font-size: 14px; color: var(--text); margin: 0 0 8px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { padding: 2px 0; }
.site-footer a { color: var(--muted); }
.prose { max-width: 760px; }
.embed-code { width: 100%; font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); resize: vertical; margin-bottom: 8px; }
