/* ==========================================================================
   CalcBoxes — shared stylesheet
   Aesthetic: "Precision Instrument" — warm paper, hairline borders,
   one confident orange accent, tabular-mono result as the hero.
   ========================================================================== */

/* ---------- Design tokens ------------------------------------------------ */
:root {
  /* Warm neutral surfaces */
  --bg:            #FCFBF9;   /* warm paper, not flat white */
  --surface:       #FFFFFF;   /* cards read brighter than the page */
  --surface-sunken:#F4F1EC;   /* warm sand — tables, muted blocks */
  --border:        #E9E4DB;   /* hairline */
  --border-strong: #D6CFC4;

  /* Ink */
  --ink:        #1A1714;      /* near-black, warm */
  --ink-muted:  #57514A;      /* AA on --bg (~7:1) */
  --ink-subtle: #6E675D;      /* hints — AA on --bg (~5:1) */

  /* Accent — calculator-key orange */
  --accent:        #E8590C;
  --accent-hover:  #C2410C;
  --accent-ink:    #9A3412;   /* orange text that meets AA on light bg */
  --accent-soft:   #FDEBD8;   /* tint — active states, badges */
  --accent-softer: #FEF6EE;

  /* Semantic (always paired with text/icon, never colour alone) */
  --good:     #15803D;  --good-soft:  #E7F4EC;
  --warn:     #B45309;  --warn-soft:  #FBF0DD;
  --bad:      #B91C1C;  --bad-soft:   #FBE9E9;
  --info:     #1D4ED8;  --info-soft:  #E8EEFD;

  /* Radius */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* Elevation — used sparingly */
  --shadow-card: 0 1px 2px rgba(26,23,20,.04), 0 10px 30px -16px rgba(26,23,20,.16);
  --shadow-pop:  0 4px 12px -2px rgba(26,23,20,.12), 0 16px 40px -12px rgba(26,23,20,.18);

  /* Type */
  --font-sans: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* Spacing scale (4 / 8) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px;

  /* Layout */
  --maxw: 1120px;
  --measure: 680px;       /* readable column for the tool + prose */
  --nav-h: 60px;

  --ring: 0 0 0 3px rgba(232,89,12,.35);
}

/* ---------- Reset / base ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

[hidden] { display: none !important; }   /* beat class rules like .input-affix / .stats */

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

img, svg { display: block; max-width: 100%; }
svg { fill: none; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, button { font-family: inherit; }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}

/* tabular figures everywhere numbers matter */
.mono, .result__value, .stat__value, td.num, .conv-table td {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
}

/* ---------- Skip link ---------------------------------------------------- */
.skip-link {
  position: absolute; left: var(--s-3); top: -60px;
  background: var(--ink); color: #fff; padding: 10px 16px;
  border-radius: var(--r-sm); z-index: 1000; transition: top .15s ease;
}
.skip-link:focus { top: var(--s-3); text-decoration: none; }

/* ---------- Layout containers ------------------------------------------- */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--s-4); }

main { flex: 1 0 auto; }

/* Tool page grid: single column on mobile, content + sticky ad rail on desktop */
.page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-6);
  padding-block: var(--s-6) var(--s-8);
}
.page__main { min-width: 0; max-width: var(--measure); margin-inline: auto; width: 100%; }

@media (min-width: 1024px) {
  .page { grid-template-columns: minmax(0,1fr) 300px; align-items: start; }
  .page__main { margin-inline: 0; max-width: none; }
  .page__rail { position: sticky; top: calc(var(--nav-h) + var(--s-4)); }
}

/* ---------- Header / nav ------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(252,251,249,.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav {
  height: var(--nav-h);
  display: flex; align-items: center; gap: var(--s-4);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; letter-spacing: -.02em; font-size: 1.125rem;
  color: var(--ink); text-decoration: none; flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  background: var(--ink); color: var(--accent);
  border-radius: 8px;
}
.brand__mark svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.2; }
.brand b { color: var(--accent); }

.nav__links {
  display: flex; align-items: center; gap: 2px;
  margin-left: auto;
  list-style: none; padding: 0;
}
.nav__links a {
  display: inline-block; padding: 8px 12px; border-radius: var(--r-sm);
  color: var(--ink-muted); font-weight: 500; font-size: .92rem;
  text-decoration: none; transition: background .15s ease, color .15s ease;
}
.nav__links a:hover { background: var(--surface-sunken); color: var(--ink); text-decoration: none; }
.nav__links a[aria-current="page"] { color: var(--accent-ink); background: var(--accent-soft); }

.nav__more { position: relative; }
.nav__toggle {
  display: none;
  margin-left: auto;
  width: 44px; height: 44px; border: 1px solid var(--border);
  background: var(--surface); border-radius: var(--r-sm);
  align-items: center; justify-content: center;
}
.nav__toggle svg { width: 22px; height: 22px; stroke: var(--ink); stroke-width: 2; }

@media (max-width: 860px) {
  .nav__toggle { display: inline-flex; }
  .nav__links {
    position: absolute; left: 0; right: 0; top: var(--nav-h);
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-pop);
    padding: var(--s-3); margin: 0;
    max-height: 0; overflow: hidden; opacity: 0; pointer-events: none;
    transition: max-height .25s ease, opacity .2s ease;
  }
  .nav__links.open { max-height: 80vh; overflow-y: auto; opacity: 1; pointer-events: auto; }
  .nav__links a { padding: 12px 14px; font-size: 1rem; }
}

/* ---------- Footer ------------------------------------------------------- */
.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: var(--s-8);
}
.footer__grid {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: var(--s-6);
  padding-block: var(--s-7) var(--s-6);
}
.footer__col h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-subtle); margin-bottom: var(--s-3); font-weight: 700; }
.footer__col ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.footer__col a { color: var(--ink-muted); font-size: .92rem; text-decoration: none; }
.footer__col a:hover { color: var(--accent-ink); text-decoration: underline; }
.footer__brand p { color: var(--ink-subtle); font-size: .9rem; max-width: 30ch; margin-top: var(--s-2); }
.footer__bottom { border-top: 1px solid var(--border); padding-block: var(--s-4); display: flex; flex-wrap: wrap; gap: var(--s-3); justify-content: space-between; color: var(--ink-subtle); font-size: .85rem; }

@media (max-width: 720px) {
  .footer__grid { grid-template-columns: 1fr 1fr; gap: var(--s-5); }
  .footer__brand { grid-column: 1 / -1; }
}

/* ---------- Tool card (the hero) ---------------------------------------- */
.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: var(--s-6);
  position: relative;
  overflow: hidden;
}
/* signature orange tick along the top edge */
.tool::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), #F59E0B);
}
@media (max-width: 520px) { .tool { padding: var(--s-5) var(--s-4); border-radius: var(--r); } }

.tool__head { margin-bottom: var(--s-5); }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent-ink); background: var(--accent-soft);
  padding: 4px 10px; border-radius: var(--r-pill); margin-bottom: var(--s-3);
}
.eyebrow svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 2.2; }

h1.tool__title { font-size: clamp(1.6rem, 4vw, 2.1rem); line-height: 1.12; letter-spacing: -.025em; font-weight: 800; }
.tool__sub { color: var(--ink-muted); margin-top: var(--s-2); font-size: 1.02rem; }

/* ---------- Form fields -------------------------------------------------- */
.field { margin-bottom: var(--s-5); }
.field:last-child { margin-bottom: 0; }
.field__label {
  display: flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: .95rem; margin-bottom: 6px; color: var(--ink);
}
.field__hint { color: var(--ink-subtle); font-size: .85rem; margin-top: 6px; line-height: 1.45; }
.field__error { color: var(--bad); font-size: .85rem; margin-top: 6px; display: none; align-items: center; gap: 6px; font-weight: 500; }
.field__error svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 2.2; flex: none; }
.field.has-error .field__error { display: flex; }
.field.has-error .input, .field.has-error input { border-color: var(--bad); }

.input, input[type="text"], input[type="number"], input[type="date"],
input[type="search"], input[type="email"], input[type="tel"], select {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-size: 1.05rem;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
  -moz-appearance: textfield;
}
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input:hover, input:hover, select:hover { border-color: var(--ink-subtle); }
.input:focus, input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input[type="date"] { appearance: none; }
select {
  appearance: none; cursor: pointer; padding-right: 40px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%236E675D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
}

/* input with a unit/affix */
.input-group { position: relative; display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--r-sm); }
.input-affix {
  display: inline-flex; align-items: center; padding: 0 14px;
  background: var(--surface-sunken); border: 1.5px solid var(--border-strong);
  color: var(--ink-muted); font-weight: 600; font-size: .95rem; white-space: nowrap;
}
.input-group .input-affix:first-child { border-right: 0; border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group .input-affix:last-child  { border-left: 0;  border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.input-group .input:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group .input:not(:last-child)  { border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* two/three fields in a row */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.field-row--3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 460px) { .field-row, .field-row--3 { grid-template-columns: 1fr; } }

/* ---------- Buttons ------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 52px; padding: 0 22px;
  border: 1.5px solid transparent; border-radius: var(--r-sm);
  font-weight: 600; font-size: 1rem; line-height: 1;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); text-decoration: none; }
.btn--ghost { background: var(--surface); border-color: var(--border-strong); color: var(--ink); }
.btn--ghost:hover { background: var(--surface-sunken); text-decoration: none; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Segmented control / tabs ------------------------------------ */
.segmented {
  display: inline-flex; padding: 4px; gap: 4px;
  background: var(--surface-sunken); border-radius: var(--r-sm);
  border: 1px solid var(--border);
}
.segmented[role="tablist"] { width: 100%; }
.segmented button, .segmented [role="tab"] {
  flex: 1; appearance: none; background: transparent; border: 0;
  padding: 9px 14px; border-radius: 6px; font-weight: 600; font-size: .9rem;
  color: var(--ink-muted); transition: background .15s ease, color .15s ease;
  min-height: 40px;
}
.segmented [aria-selected="true"], .segmented .is-active {
  background: var(--surface); color: var(--accent-ink);
  box-shadow: 0 1px 2px rgba(26,23,20,.08);
}

/* ---------- Result hero -------------------------------------------------- */
.result {
  margin-top: var(--s-5);
  background: linear-gradient(180deg, var(--accent-softer), var(--surface));
  border: 1px solid var(--accent-soft);
  border-radius: var(--r);
  padding: var(--s-5);
  text-align: center;
  position: relative;
}
.result__label { font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); }
.result__value {
  font-weight: 700; letter-spacing: -.03em; color: var(--ink);
  font-size: clamp(2.4rem, 9vw, 3.6rem); line-height: 1.05; margin-top: 8px;
  word-break: break-word;
}
.result__value .unit { font-size: .42em; font-weight: 600; color: var(--ink-muted); letter-spacing: 0; }
.result__sub { color: var(--ink-muted); margin-top: 8px; font-size: 1rem; }
.result__sub b { color: var(--accent-ink); font-family: var(--font-mono); }

/* secondary stat grid */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--s-2);
  margin-top: var(--s-4);
}
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: var(--s-3); text-align: center;
}
.stat__value { font-weight: 700; font-size: 1.4rem; color: var(--ink); }
.stat__label { font-size: .78rem; color: var(--ink-subtle); margin-top: 2px; }

/* ---------- Info tooltip ------------------------------------------------- */
.info {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface-sunken); border: 1px solid var(--border-strong);
  color: var(--ink-subtle); font-size: 11px; font-weight: 700; cursor: help;
  position: relative; flex: none;
}
.info:focus-visible { box-shadow: var(--ring); }
.info__bubble {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 240px;
  background: var(--ink); color: #fff; font-size: .8rem; font-weight: 400; line-height: 1.45;
  padding: 8px 11px; border-radius: var(--r-sm);
  opacity: 0; visibility: hidden; transition: opacity .15s ease, visibility .15s ease;
  z-index: 50; text-align: left; box-shadow: var(--shadow-pop);
}
.info__bubble::after { content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--ink); }
.info:hover .info__bubble, .info:focus .info__bubble, .info.open .info__bubble { opacity: 1; visibility: visible; }

/* ---------- BMI scale ---------------------------------------------------- */
.bmi-scale { margin-top: var(--s-4); }
/* stops align with BMI 15–40 scale: 18.5→14%, 25→40%, 30→60%, 35→80% */
.bmi-scale__bar {
  height: 14px; border-radius: var(--r-pill); position: relative;
  background: linear-gradient(90deg,
    #3B82F6 0 14%, #16A34A 14% 40%, #EAB308 40% 60%, #F97316 60% 80%, #DC2626 80% 100%);
}
.bmi-scale__pin {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 6px; height: 26px; background: var(--ink); border-radius: 3px;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3);
  transition: left .4s cubic-bezier(.2,.8,.2,1);
}
.bmi-scale__legend { display: flex; justify-content: space-between; margin-top: 8px; font-size: .72rem; color: var(--ink-subtle); }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--r-pill); font-weight: 600; font-size: .9rem;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge--good { background: var(--good-soft); color: var(--good); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--bad  { background: var(--bad-soft);  color: var(--bad); }
.badge--info { background: var(--info-soft); color: var(--info); }

/* ---------- Donut / pie (loan, salary) ---------------------------------- */
.donut { width: 180px; height: 180px; margin-inline: auto; }
.donut__hole { font-family: var(--font-mono); }
.legend { display: flex; flex-direction: column; gap: 8px; }
.legend__item { display: flex; align-items: center; gap: 10px; font-size: .92rem; }
.legend__swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.legend__val { margin-left: auto; font-family: var(--font-mono); font-weight: 600; }

/* ---------- Data tables (conversion ref, amortization) ------------------ */
.conv-table, .data-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.conv-table th, .data-table th {
  text-align: left; font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-subtle); padding: 10px 12px; border-bottom: 2px solid var(--border-strong);
}
.conv-table td, .data-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.conv-table tr:nth-child(even) td, .data-table tr:nth-child(even) td { background: var(--surface-sunken); }
.data-table td.num, .conv-table td { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); }
.table-scroll { max-height: 360px; overflow-y: auto; }

/* expandable */
details.expand { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; margin-top: var(--s-4); }
details.expand > summary {
  list-style: none; cursor: pointer; padding: 14px var(--s-4); font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  background: var(--surface); min-height: 48px;
}
details.expand > summary::-webkit-details-marker { display: none; }
details.expand > summary .chev { transition: transform .2s ease; width: 20px; height: 20px; stroke: var(--ink-subtle); stroke-width: 2; }
details.expand[open] > summary .chev { transform: rotate(180deg); }

/* ---------- Ad slots ----------------------------------------------------- */
.ad {
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-sunken);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r); color: var(--ink-subtle);
  font-size: .72rem; letter-spacing: .1em; text-transform: uppercase;
  margin-block: var(--s-5); overflow: hidden;
}
.ad::after { content: "Advertisement"; }
.ad--leaderboard { min-height: 90px; }   /* reserve space → no CLS */
.ad--in-content  { min-height: 250px; }
.ad--rail        { min-height: 600px; }
.ad--mobile-anchor { min-height: 50px; margin: 0; }
/* once a real AdSense unit is injected, drop the placeholder chrome */
.ad--live { background: transparent; border: 0; }
.ad--live::after { content: none; }
/* the 300×600 rail is desktop-only; mobile uses the anchor instead */
@media (max-width: 1023px) { .page__rail { display: none; } }

/* sticky dismissible mobile anchor */
.anchor-ad {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 8px; display: none; align-items: center; gap: 8px;
  box-shadow: 0 -4px 16px -8px rgba(0,0,0,.2);
}
.anchor-ad .ad { margin: 0; flex: 1; }
.anchor-ad__close {
  width: 32px; height: 32px; flex: none; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--surface);
  display: grid; place-items: center;
}
.anchor-ad__close svg { width: 18px; height: 18px; stroke: var(--ink-muted); stroke-width: 2; }
@media (max-width: 1023px) { .anchor-ad.show { display: flex; } body.has-anchor { padding-bottom: 56px; } }

/* ---------- Prose / SEO content ----------------------------------------- */
.prose { max-width: var(--measure); margin-inline: auto; }
@media (min-width: 1024px) { .page__main .prose { margin-inline: 0; } }
.prose h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); font-weight: 800; letter-spacing: -.025em; line-height: 1.1; margin-bottom: var(--s-3); }
.prose .lead { font-size: 1.15rem; color: var(--ink-muted); margin-bottom: var(--s-5); }
.prose h2 {
  font-size: 1.5rem; letter-spacing: -.02em; font-weight: 800; line-height: 1.2;
  margin-top: var(--s-7); margin-bottom: var(--s-3);
  scroll-margin-top: calc(var(--nav-h) + 16px);
}
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 1.15rem; font-weight: 700; margin-top: var(--s-5); margin-bottom: var(--s-2); letter-spacing: -.01em; }
.prose p { color: var(--ink-muted); margin-bottom: var(--s-3); }
.prose ul, .prose ol { color: var(--ink-muted); margin: 0 0 var(--s-3); padding-left: 1.3em; }
.prose li { margin-bottom: 6px; }
.prose li::marker { color: var(--accent); }
.prose strong { color: var(--ink); font-weight: 700; }
.prose a { color: var(--accent-ink); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.prose code { font-family: var(--font-mono); font-size: .9em; background: var(--surface-sunken); padding: 2px 6px; border-radius: 5px; color: var(--ink); }

/* callout */
.callout {
  display: flex; gap: 12px; padding: var(--s-4);
  background: var(--info-soft); border: 1px solid #C7D7FB; border-radius: var(--r);
  margin-block: var(--s-4); font-size: .95rem; color: var(--ink-muted);
}
.callout--warn { background: var(--warn-soft); border-color: #F0DCB0; }
.callout svg { width: 22px; height: 22px; flex: none; stroke-width: 2; }
.callout--warn svg { stroke: var(--warn); }
.callout svg { stroke: var(--info); }
.callout strong { color: var(--ink); }

/* formula block */
.formula {
  font-family: var(--font-mono); background: var(--ink); color: #FAF6F0;
  padding: var(--s-4); border-radius: var(--r); overflow-x: auto;
  font-size: .95rem; line-height: 1.7; margin-block: var(--s-3);
}
.formula .op { color: #F59E0B; }
.formula .var { color: #FBBF24; }

/* worked example card */
.example { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--r); padding: var(--s-4); margin-block: var(--s-3); background: var(--surface); }
.example h4 { font-size: .95rem; font-weight: 700; margin-bottom: 6px; }
.example p { font-size: .92rem; margin-bottom: 4px; }

/* ---------- FAQ accordion ------------------------------------------------ */
.faq { border-top: 1px solid var(--border); margin-top: var(--s-4); }
.faq__item { border-bottom: 1px solid var(--border); }
.faq__q {
  width: 100%; text-align: left; background: none; border: 0;
  padding: var(--s-4) 0; font-weight: 600; font-size: 1.05rem; color: var(--ink);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  min-height: 56px;
}
.faq__q .chev { width: 22px; height: 22px; stroke: var(--accent); stroke-width: 2; flex: none; transition: transform .2s ease; }
.faq__q[aria-expanded="true"] .chev { transform: rotate(180deg); }
.faq__a { overflow: hidden; max-height: 0; transition: max-height .25s ease; }
.faq__a-inner { padding-bottom: var(--s-4); color: var(--ink-muted); }
.faq__a-inner p { margin-bottom: var(--s-2); }
.faq__item.open .faq__a { max-height: 600px; }
@media (prefers-reduced-motion: reduce) { .faq__a { transition: none; } }

/* ---------- Related tools ------------------------------------------------ */
.related { margin-top: var(--s-7); }
.related h2 { font-size: 1.25rem; font-weight: 800; margin-bottom: var(--s-3); }
.related__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-3); }
.related__card {
  display: flex; align-items: center; gap: 12px;
  padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); color: var(--ink); text-decoration: none;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.related__card:hover { border-color: var(--accent); box-shadow: var(--shadow-card); text-decoration: none; transform: translateY(-1px); }
.related__icon { width: 38px; height: 38px; flex: none; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; }
.related__icon svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2; }
.related__card b { font-weight: 600; font-size: .95rem; display: block; }
.related__card span { font-size: .8rem; color: var(--ink-subtle); }

/* ---------- Breadcrumb --------------------------------------------------- */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .85rem; color: var(--ink-subtle); margin-bottom: var(--s-4); }
.crumbs a { color: var(--ink-subtle); text-decoration: none; }
.crumbs a:hover { color: var(--accent-ink); text-decoration: underline; }
.crumbs svg { width: 14px; height: 14px; stroke: var(--ink-subtle); stroke-width: 2; }

/* ---------- Homepage ----------------------------------------------------- */
.hero { text-align: center; padding-block: var(--s-8) var(--s-6); }
.hero h1 { font-size: clamp(2.1rem, 6vw, 3.4rem); line-height: 1.08; letter-spacing: -.03em; font-weight: 800; }
.hero h1 b { color: var(--accent); }
.hero p { color: var(--ink-muted); font-size: 1.15rem; max-width: 50ch; margin: var(--s-4) auto 0; }
.hero__search { max-width: 480px; margin: var(--s-5) auto 0; position: relative; }
.hero__search input { padding-left: 46px; height: 56px; box-shadow: var(--shadow-card); }
.hero__search svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; stroke: var(--ink-subtle); stroke-width: 2; pointer-events: none; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-4); margin-block: var(--s-5); }
.tool-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: var(--s-5); border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); color: var(--ink); text-decoration: none;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
  position: relative; overflow: hidden;
}
.tool-card:hover { border-color: var(--accent); box-shadow: var(--shadow-card); transform: translateY(-2px); text-decoration: none; }
.tool-card__icon { width: 48px; height: 48px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; }
.tool-card__icon svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 1.8; }
.tool-card h2, .tool-card h3 { font-size: 1.2rem; font-weight: 700; letter-spacing: -.01em; }
.tool-card p { color: var(--ink-subtle); font-size: .9rem; line-height: 1.5; }
.tool-card__go { margin-top: auto; color: var(--accent-ink); font-weight: 600; font-size: .9rem; display: inline-flex; align-items: center; gap: 4px; }
.tool-card:hover .tool-card__go svg { transform: translateX(3px); }
.tool-card__go svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2.4; transition: transform .18s ease; }
.tool-card__tag { position: absolute; top: 14px; right: 14px; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-ink); background: var(--accent-soft); padding: 3px 8px; border-radius: var(--r-pill); }

.section-label { display: flex; align-items: center; gap: 12px; margin: var(--s-7) 0 var(--s-2); }
.section-label h2 { font-size: 1.1rem; font-weight: 800; letter-spacing: -.01em; }
.section-label span { font-size: .8rem; color: var(--ink-subtle); }

/* ---------- Converter widget -------------------------------------------- */
.conv__row { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--s-3); align-items: end; }
.conv__swap {
  width: 48px; height: 52px; flex: none; align-self: end;
  border: 1.5px solid var(--border-strong); background: var(--surface);
  border-radius: var(--r-sm); display: grid; place-items: center;
  transition: background .15s ease, border-color .15s ease, transform .2s ease;
}
.conv__swap:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.conv__swap:active { transform: rotate(180deg); }
.conv__swap svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2; }
.conv__eq {
  text-align: center; margin-top: var(--s-4); font-size: 1.15rem; color: var(--ink-muted);
  background: var(--accent-softer); border: 1px solid var(--accent-soft);
  border-radius: var(--r-sm); padding: var(--s-3); min-height: 52px;
  display: flex; align-items: center; justify-content: center;
}
.conv__eq b { color: var(--ink); font-family: var(--font-mono); font-weight: 700; }
@media (max-width: 560px) {
  .conv__row { grid-template-columns: 1fr; gap: var(--s-2); }
  .conv__swap { justify-self: center; transform: rotate(90deg); width: 44px; height: 44px; margin-block: 4px; }
  .conv__swap:active { transform: rotate(270deg); }
}

/* ---------- Helpers ------------------------------------------------------ */
.center { text-align: center; }
.muted { color: var(--ink-subtle); }
.hide { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.divider { height: 1px; background: var(--border); border: 0; margin-block: var(--s-6); }
.stack > * + * { margin-top: var(--s-4); }

/* count-up number gets a subtle fade when it changes */
.flash { animation: flash .4s ease; }
@keyframes flash { from { opacity: .35; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .flash { animation: none; }
  .bmi-scale__pin, .tool-card, .related__card { transition: none; }
}

/* page-load stagger for hero elements (respects reduced-motion) */
@media (prefers-reduced-motion: no-preference) {
  .reveal { opacity: 0; transform: translateY(8px); animation: reveal .5s cubic-bezier(.2,.8,.2,1) forwards; }
  .reveal:nth-child(2){ animation-delay: .05s } .reveal:nth-child(3){ animation-delay: .1s }
  @keyframes reveal { to { opacity: 1; transform: none; } }
}
