/* SizeBench v2 — "fast tool" layout: sticky search header, calculator card with inline results above the fold,
   related-calculator chips right after results, reading column + sticky sidebar. System fonts only (zero font requests). */
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --ink: #111827;
  --muted: #5b6475;
  --line: #e2e6ec;
  --accent: #1f5eff;          /* volt blue: every clickable thing */
  --accent-ink: #ffffff;
  --accent-soft: #eaf0ff;
  --brand: #ffc21a;           /* tape-measure amber, logo + result highlight only */
  --good: #0f7a55; --good-soft: #e5f6ef;
  --warn: #9a5b00; --warn-soft: #fff4dc;
  --bad: #c0262d;  --bad-soft: #fdeaea;
  --shadow: 0 1px 2px rgba(17,24,39,.05), 0 4px 16px rgba(17,24,39,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --r: 12px;
  --wrap: 1180px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --surface: #151a22; --surface-2: #1b212b; --ink: #e8ecf2; --muted: #9ba5b4; --line: #262d38;
    --accent: #6f9bff; --accent-ink: #0d1117; --accent-soft: #17223a; --brand: #ffc21a;
    --good: #4cc9a0; --good-soft: #10271f; --warn: #f2b84b; --warn-soft: #2a2110; --bad: #ff7a7f; --bad-soft: #2c1517;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --surface: #151a22; --surface-2: #1b212b; --ink: #e8ecf2; --muted: #9ba5b4; --line: #262d38;
  --accent: #6f9bff; --accent-ink: #0d1117; --accent-soft: #17223a; --brand: #ffc21a;
  --good: #4cc9a0; --good-soft: #10271f; --warn: #f2b84b; --warn-soft: #2a2110; --bad: #ff7a7f; --bad-soft: #2c1517;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding-inline: 16px; }
h1, h2, h3 { line-height: 1.2; text-wrap: balance; margin: 0; letter-spacing: -0.015em; }
h1 { font-size: clamp(28px, 4vw, 38px); font-weight: 800; }
h2 { font-size: 24px; font-weight: 750; margin-top: 36px; scroll-margin-top: 80px; }
h3 { font-size: 18px; font-weight: 700; margin-top: 22px; }
.num, .mono { font-variant-numeric: tabular-nums; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-row { display: flex; align-items: center; gap: 16px; height: 62px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; color: var(--ink); letter-spacing: -0.02em; white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo svg { width: 28px; height: 28px; flex: none; }
.logo b { color: var(--accent); font-weight: 800; }
.hsearch { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
.hsearch input, .bigsearch input {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  font: 15px var(--font); padding: 10px 14px 10px 38px; border-radius: 999px; outline: none;
}
.hsearch input:focus, .bigsearch input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
.hsearch svg, .bigsearch svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.sresults {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 6px; max-height: 360px; overflow: auto; z-index: 30;
}
.sresults a { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; border-radius: 8px; color: var(--ink); }
.sresults a:hover, .sresults a.on { background: var(--accent-soft); text-decoration: none; }
.sresults small { color: var(--muted); white-space: nowrap; }
.catnav { border-top: 1px solid var(--line); }
.catnav .wrap { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.catnav a { color: var(--muted); font-size: 14px; font-weight: 600; padding: 10px 12px; white-space: nowrap; border-bottom: 2px solid transparent; }
.catnav a:hover { color: var(--ink); text-decoration: none; }
.catnav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Page grid ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; padding-block: 20px 40px; }
.main { min-width: 0; }
.sidebar { display: grid; gap: 18px; align-content: start; position: sticky; top: 130px; align-self: start; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--muted); }
.lede { color: var(--muted); font-size: 17px; margin: 8px 0 0; max-width: 64ch; }
.meta { font-size: 13px; color: var(--muted); margin-top: 8px; display: flex; gap: 14px; flex-wrap: wrap; }
.meta span::before { content: "✓ "; color: var(--good); font-weight: 700; }

/* ---------- Calculator card ---------- */
.calc-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); margin-top: 18px; overflow: hidden; }
.calc { padding: 20px; display: grid; gap: 16px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; align-items: start; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .flabel { font-size: 14px; font-weight: 650; color: var(--ink); }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.input-unit {
  display: flex; align-items: stretch; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}
.input-unit:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.input-unit:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input-unit input { border: 0; background: transparent; color: var(--ink); font: 600 17px var(--font); font-variant-numeric: tabular-nums; padding: 11px 12px; width: 100%; min-width: 0; outline: none; }
.input-unit .unit { padding: 0 12px; font-size: 14px; font-weight: 600; color: var(--muted); display: flex; align-items: center; white-space: nowrap; background: var(--surface-2); border-left: 1px solid var(--line); border-radius: 0 9px 9px 0; }
.input-unit select { border: 0; border-left: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: 600 14px var(--font); padding: 0 10px; border-radius: 0 9px 9px 0; cursor: pointer; outline: none; }
.field > select { border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: 600 16px var(--font); padding: 11px 12px; width: 100%; cursor: pointer; }
.field > select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); outline: none; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; width: fit-content; max-width: 100%; }
.seg button { font: 650 14px var(--font); padding: 8px 14px; border-radius: 9px; cursor: pointer; border: 0; background: transparent; color: var(--muted); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(17,24,39,.12); }
.check { display: flex; gap: 10px; align-items: center; font-size: 15px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Results */
.results { border-top: 1px solid var(--line); background: var(--surface-2); padding: 20px; display: grid; gap: 14px; }
.res-main { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.res-label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.big { font-size: clamp(36px, 6vw, 52px); font-weight: 850; line-height: 1.05; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.big small { font-size: .42em; font-weight: 700; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.big mark { background: linear-gradient(transparent 62%, color-mix(in srgb, var(--brand) 55%, transparent) 62%); color: inherit; padding: 0 2px; }
.status { font-size: 14px; font-weight: 700; padding: 6px 12px; border-radius: 999px; }
.status.ok { background: var(--good-soft); color: var(--good); }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.status.bad { background: var(--bad-soft); color: var(--bad); }
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 0; }
.res-grid div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.res-grid dt { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.res-grid dd { margin: 2px 0 0; font-size: 17px; font-weight: 750; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.res-note { font-size: 14px; color: var(--muted); margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { font: 650 14px var(--font); padding: 9px 14px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
/* Discreet legal note under every result */
.fineprint { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
.fineprint a { color: var(--muted); text-decoration: underline; }
.foot-bottom span:first-child { max-width: 80ch; }
.steps { border-top: 1px dashed var(--line); padding-top: 12px; }
.steps summary { cursor: pointer; font-weight: 700; font-size: 15px; color: var(--accent); }
.steps ol { margin: 10px 0 0; padding-left: 22px; display: grid; gap: 6px; font-size: 15px; }
.steps code { font: 14px var(--mono); background: var(--surface); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }

/* Related chips (click driver) */
.related { margin-top: 18px; }
.related h2 { font-size: 15px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); font-size: 14px; font-weight: 600; }
.chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.chip::after { content: "→"; color: var(--accent); }

/* Ads */
.ad { margin-block: 24px; }
.ad-label { font-size: 11px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; text-align: center; margin-bottom: 4px; }
.ad-ph { background: repeating-linear-gradient(45deg, var(--surface-2) 0 10px, var(--surface) 10px 20px); border: 1px dashed var(--line); border-radius: var(--r); min-height: 110px; display: grid; place-items: center; color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.sidebar .ad-ph { min-height: 250px; }

.ad ins.adsbygoogle { min-height: 250px; }
.ad-in_article ins.adsbygoogle, .ad-in_article_2 ins.adsbygoogle { min-height: 200px; }
.ad-multiplex ins.adsbygoogle { min-height: 300px; }
.ad:has(ins[data-ad-status="unfilled"]) { display: none; }
@media (max-width: 960px) { .sidebar .ad { display: none; } }

/* Article */
.article { max-width: 72ch; }
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 18px; margin-top: 28px; }
.toc strong { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.toc ol { margin: 8px 0 0; padding-left: 20px; columns: 2 220px; font-size: 15px; }
.formula { font: 15px/1.75 var(--mono); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; overflow-x: auto; white-space: pre; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin-top: 10px; }
.faq summary { cursor: pointer; font-weight: 700; }
.faq details p { margin: 8px 0 0; color: var(--ink); }
.side-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.side-box h3 { margin: 0 0 8px; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.side-box ul { list-style: none; margin: 0; padding: 0; display: grid; }
.side-box li a { display: block; padding: 7px 0; border-bottom: 1px solid var(--line); color: var(--ink); font-weight: 600; font-size: 15px; }
.side-box li:last-child a { border-bottom: 0; }
.side-box li a:hover { color: var(--accent); text-decoration: none; }

/* ---------- Home & category ---------- */
.hero { padding-block: 44px 20px; text-align: left; }
.hero h1 { font-size: clamp(32px, 5.5vw, 54px); max-width: 18ch; letter-spacing: -0.03em; }
.hero h1 b { color: var(--accent); }
.bigsearch { position: relative; max-width: 620px; margin-top: 20px; }
.bigsearch input { font-size: 17px; padding: 15px 18px 15px 44px; background: var(--surface); box-shadow: var(--shadow); }
.bigsearch svg { left: 16px; width: 18px; height: 18px; }
.popular { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.popular > span { font-size: 13px; color: var(--muted); font-weight: 600; margin-right: 4px; }
.cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); gap: 16px; margin-top: 28px; }
.cat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: grid; gap: 10px; align-content: start; }
.cat-head { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.cat-head:hover { text-decoration: none; color: var(--accent); }
.cat-ico { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.cat-ico svg { width: 20px; height: 20px; }
.cat-head h2 { font-size: 18px; margin: 0; }
.cat-card ul { list-style: none; margin: 0; padding: 0; display: grid; }
.cat-card li a { display: flex; justify-content: space-between; padding: 7px 0; border-top: 1px solid var(--line); color: var(--ink); font-size: 15px; font-weight: 550; }
.cat-card li a::after { content: "›"; color: var(--muted); }
.cat-card li a:hover { color: var(--accent); text-decoration: none; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-top: 18px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 4px; color: var(--ink); transition: transform .12s, border-color .12s, box-shadow .12s; }
.tile:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); text-decoration: none; }
.tile strong { font-size: 16px; }
.tile span { font-size: 14px; color: var(--muted); }
.tile em { font-style: normal; font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.page { max-width: 72ch; padding-block: 20px 40px; }

/* Footer */
.site-footer { margin-top: 40px; background: var(--surface); border-top: 1px solid var(--line); padding-block: 28px; font-size: 14px; color: var(--muted); }
.foot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 20px; }
.foot-grid h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink); margin: 0 0 8px; }
.foot-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.foot-grid a { color: var(--muted); }
.foot-bottom { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; }
}
@media (max-width: 560px) {
  .header-row { height: auto; padding-block: 10px; flex-wrap: wrap; }
  .hsearch { order: 3; max-width: none; flex-basis: 100%; }
  .calc, .results { padding: 16px; }
  .field-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-row > .field:only-child { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { *, html { transition: none !important; scroll-behavior: auto !important; } }
