/* =========================================================
   Calcuvi — main stylesheet (mobile first)
   Colours live in the :root tokens below. Change them there.
   ========================================================= */
:root {
  --primary: #0F766E;
  --primary-strong: #115E59;
  --primary-soft: #E3F2EF;
  --on-primary: #FFFFFF;
  --secondary: #1E3A5F;
  --accent: #D97706;
  --accent-soft: #FEF3E2;
  --accent-text: #9A4A05;
  --bg: #F5F8F7;
  --surface: #FFFFFF;
  --surface-2: #EEF3F2;
  --text: #14211F;
  --muted: #5A6B67;
  --border: #DCE4E2;
  --border-strong: #B9C7C4;
  --success: #15803D;
  --error: #B42318;
  --error-soft: #FDECEA;
  --chart-1: #0F766E;
  --chart-2: #E39A2D;
  --chart-3: #1E3A5F;
  --focus: #2563EB;
  --shadow: 0 1px 2px rgba(16, 40, 36, .06), 0 6px 20px rgba(16, 40, 36, .06);
  --shadow-lg: 0 2px 4px rgba(16, 40, 36, .06), 0 14px 40px rgba(16, 40, 36, .10);
  --radius: 14px;
  --radius-sm: 10px;
  --wrap: 1140px;
  --gutter: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #2DD4BF;
    --primary-strong: #5EEAD4;
    --primary-soft: #11302C;
    --on-primary: #04201C;
    --secondary: #C9DBF2;
    --accent: #F5B544;
    --accent-soft: #33260F;
    --accent-text: #F8C66B;
    --bg: #0C1514;
    --surface: #131F1D;
    --surface-2: #1A2826;
    --text: #E6EFED;
    --muted: #A2B4B0;
    --border: #263735;
    --border-strong: #3A4F4C;
    --success: #4ADE80;
    --error: #FF8A80;
    --error-soft: #3A1714;
    --chart-1: #2DD4BF;
    --chart-2: #F5B544;
    --chart-3: #8FB3E0;
    --focus: #93C5FD;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, .35);
  }
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0; font-family: var(--font); font-size: 1rem; line-height: 1.6;
  color: var(--text); background: var(--bg); overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-strong); }
h1, h2, h3, h4 { line-height: 1.25; color: var(--secondary); margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.75rem, 1.3rem + 2vw, 2.5rem); font-weight: 800; }
h2 { font-size: clamp(1.35rem, 1.15rem + .9vw, 1.7rem); font-weight: 750; margin-top: 1.6em; }
h3 { font-size: 1.15rem; font-weight: 700; margin-top: 1.3em; }
p, ul, ol { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 max(var(--gutter), env(safe-area-inset-left)) 0 max(var(--gutter), env(safe-area-inset-right)); }
[hidden] { display: none !important; }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--primary); color: var(--on-primary);
  padding: 12px 16px; border-radius: var(--radius-sm); font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 12px; color: var(--on-primary); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50; 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(--border);
}
@supports not (background: color-mix(in srgb, red, blue)) { .site-header { background: var(--surface); } }
.header-inner { display: flex; align-items: center; gap: 8px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--secondary); font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; min-height: 44px; margin-right: auto; }
.brand:hover { color: var(--secondary); }
.brand img { width: 36px; height: 36px; flex: none; }
.nav-links { display: none; list-style: none; margin: 0; padding: 0; gap: 4px; }
.nav-links a, .menu-panel a {
  display: flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 999px;
  text-decoration: none; color: var(--text); font-weight: 600; font-size: .95rem;
}
.nav-links a:hover, .menu-panel a:hover { background: var(--surface-2); color: var(--primary-strong); }
.nav-links a[aria-current="page"], .menu-panel a[aria-current="page"] { background: var(--primary-soft); color: var(--primary-strong); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px;
  color: var(--secondary); text-decoration: none; background: transparent; border: 1px solid transparent; cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--primary-strong); }
.icon-btn svg { width: 22px; height: 22px; }
.menu { position: static; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu .icon-close { display: none; }
.menu[open] .icon-close { display: block; }
.menu[open] .icon-open { display: none; }
.menu-panel {
  position: absolute; left: 0; right: 0; top: 100%; background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-lg); padding: 8px max(var(--gutter), env(safe-area-inset-left)) 16px;
}
.menu-panel ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.menu-panel a { border-radius: 12px; font-size: 1.05rem; min-height: 52px; }
@media (min-width: 900px) {
  .nav-links { display: flex; }
  .menu { display: none; }
}

/* ---------- Breadcrumbs ---------- */
.breadcrumbs { font-size: .9rem; color: var(--muted); padding-top: 14px; }
.breadcrumbs ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.breadcrumbs li { display: inline-flex; align-items: center; gap: 4px; }
.breadcrumbs li + li::before { content: "›"; color: var(--border-strong); margin-right: 2px; }
.breadcrumbs a { color: var(--muted); text-decoration: none; padding: 10px 2px; display: inline-block; }
.breadcrumbs a:hover { color: var(--primary); text-decoration: underline; }
.breadcrumbs [aria-current] { color: var(--text); font-weight: 600; }

/* ---------- Page heading ---------- */
.page-head { padding: 12px 0 8px; }
.page-head h1 { margin-bottom: .3em; }
.page-head .lead { font-size: 1.08rem; color: var(--muted); max-width: 70ch; margin-bottom: 0; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--primary-strong); background: var(--primary-soft); padding: 4px 10px; border-radius: 999px; margin-bottom: 10px; }

/* ---------- Hero (home) ---------- */
.hero { padding: 36px 0 20px; text-align: center; }
.hero h1 { font-size: clamp(2rem, 1.4rem + 3vw, 3.1rem); max-width: 18ch; margin: 0 auto .35em; }
.hero h1 .hl { color: var(--primary); }
.hero p { font-size: 1.12rem; color: var(--muted); max-width: 56ch; margin: 0 auto 1.2em; }
.search-box { position: relative; max-width: 620px; margin: 0 auto; }
.search-box svg { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; color: var(--muted); pointer-events: none; }
.search-box input {
  width: 100%; min-height: 58px; padding: 0 18px 0 52px; font-size: 1.05rem; border-radius: 999px;
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.search-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.search-status { min-height: 1.6em; margin: 10px 0 0; color: var(--muted); font-size: .95rem; }
.trust-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin-top: 16px; color: var(--muted); font-size: .92rem; list-style: none; padding: 0; }
.trust-row li { display: inline-flex; align-items: center; gap: 6px; }
.trust-row svg { width: 18px; height: 18px; color: var(--success); }

/* ---------- Sections & cards ---------- */
.section { padding: 18px 0 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head h2 { margin-top: .6em; }
.section-head a { font-weight: 600; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.card-grid { display: grid; gap: 12px; grid-template-columns: 1fr; list-style: none; padding: 0; margin: 0; }
@media (min-width: 560px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .card-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 1100px) { .card-grid.cols-4 { grid-template-columns: repeat(4, 1fr); } }
.tool-card {
  display: flex; gap: 14px; align-items: flex-start; height: 100%; padding: 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text);
  box-shadow: var(--shadow); transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.tool-card:hover { transform: translateY(-2px); border-color: var(--primary); box-shadow: var(--shadow-lg); color: var(--text); }
.tool-card .ti { flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-strong); }
.tool-card .ti svg { width: 24px; height: 24px; }
.tool-card[data-cat="health"] .ti { background: #FDECEC; color: #B4232C; }
.tool-card[data-cat="math"] .ti { background: #EAF0FB; color: #1E4FA8; }
.tool-card[data-cat="date-time"] .ti { background: #F3ECFB; color: #6B32A8; }
.tool-card[data-cat="converters"] .ti { background: var(--accent-soft); color: var(--accent-text); }
@media (prefers-color-scheme: dark) {
  .tool-card[data-cat="health"] .ti { background: #3A1A1C; color: #FCA5A5; }
  .tool-card[data-cat="math"] .ti { background: #18243A; color: #93C5FD; }
  .tool-card[data-cat="date-time"] .ti { background: #2A1D3A; color: #D8B4FE; }
}
.tool-card strong { display: block; font-size: 1.04rem; color: var(--secondary); margin-bottom: 2px; }
.tool-card span.d { display: block; color: var(--muted); font-size: .92rem; line-height: 1.45; }
.cat-card { flex-direction: column; }
.cat-card .count { font-size: .85rem; color: var(--primary-strong); font-weight: 700; }

/* ---------- Calculator layout ---------- */
.calc { display: grid; gap: 16px; margin: 18px 0 8px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) {
  .calc { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 20px; align-items: start; }
  .calc-results { position: sticky; top: 84px; }
}
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
@media (min-width: 480px) { .panel { padding: 22px; } }
.panel-title { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 14px; font-weight: 700; }

.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.field label, .field .label { font-weight: 650; font-size: .98rem; color: var(--text); }
.field .hint { font-size: .85rem; color: var(--muted); }
.input-group {
  display: flex; align-items: stretch; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); overflow: hidden; transition: border-color .15s, box-shadow .15s; min-height: 52px;
}
.input-group:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input-group .affix { display: flex; align-items: center; padding: 0 14px; color: var(--muted); background: var(--surface-2); font-weight: 600; font-size: .95rem; white-space: nowrap; }
.input-group input, .input-group select {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 1.1rem;
  font-weight: 600; padding: 0 14px; min-height: 50px; font-variant-numeric: tabular-nums;
}
.input-group input:focus, .input-group select:focus { outline: none; }
.input-group input[type="date"] { min-width: 0; width: 100%; }
select { font: inherit; }
.select-plain {
  width: 100%; min-height: 52px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); padding: 0 40px 0 14px; font-size: 1.05rem; font-weight: 600;
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat;
}
.select-plain:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.field.invalid .input-group, .field.invalid .select-plain { border-color: var(--error); }
.field.invalid .input-group:focus-within { box-shadow: 0 0 0 4px var(--error-soft); }
.error-msg { display: flex; gap: 6px; align-items: flex-start; color: var(--error); font-size: .9rem; font-weight: 600; margin-top: 6px; }
.error-msg:empty { display: none; }

/* range slider */
.range { width: 100%; margin: 12px 0 0; height: 28px; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; --pct: 50%; }
.range::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: linear-gradient(to right, var(--primary) var(--pct), var(--border) var(--pct)); }
.range::-moz-range-track { height: 6px; border-radius: 6px; background: var(--border); }
.range::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--primary); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); box-shadow: var(--shadow); }
.range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); }
.range:focus-visible { outline-offset: 4px; }
.range-scale { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin-top: 2px; }

/* segmented radio control */
.seg { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px; background: var(--surface-2); border-radius: 12px; border: 1px solid var(--border); margin: 0; }
.seg legend { padding: 0; margin-bottom: 6px; font-weight: 650; float: left; width: 100%; }
.seg-wrap { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.seg-wrap > legend { font-weight: 650; margin-bottom: 6px; padding: 0; }
.seg label { flex: 1 1 auto; position: relative; display: flex; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span {
  flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; min-height: 44px; padding: 6px 12px;
  border-radius: 9px; font-weight: 650; font-size: .95rem; color: var(--muted); transition: background .15s, color .15s; white-space: nowrap;
}
.seg input:checked + span { background: var(--surface); color: var(--primary-strong); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
.row-2 { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.row-2 .field { margin-bottom: 18px; }
.inline-actions { display: flex; justify-content: center; margin: -4px 0 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border-radius: 12px; border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 650; font-size: .98rem; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--primary); color: var(--primary-strong); background: var(--primary-soft); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); color: var(--on-primary); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 44px; padding: 0 14px; font-size: .92rem; }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
@media (min-width: 420px) { .actions { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.actions .btn { padding: 0 10px; }
.reset-row { display: flex; justify-content: flex-end; margin-top: 4px; }

/* ---------- Results ---------- */
.result-hero { border-radius: 12px; padding: 18px; background: linear-gradient(135deg, var(--primary-soft), color-mix(in srgb, var(--primary-soft) 40%, var(--surface))); border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent); }
@supports not (background: color-mix(in srgb, red, blue)) { .result-hero { background: var(--primary-soft); } }
.result-label { font-size: .92rem; font-weight: 650; color: var(--muted); margin: 0 0 4px; }
.result-value { font-size: clamp(1.9rem, 1.4rem + 2.6vw, 2.6rem); font-weight: 800; color: var(--primary-strong); line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; margin: 0; }
.result-sub { margin: 6px 0 0; color: var(--muted); font-size: .95rem; }
.result-sub strong { color: var(--text); }
.stats { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; margin: 14px 0 0; padding: 0; list-style: none; }
.stats li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 2px; border-bottom: 1px dashed var(--border); align-items: baseline; }
.stats li:last-child { border-bottom: 0; }
.stats .k { color: var(--muted); font-size: .97rem; display: inline-flex; align-items: center; gap: 8px; }
.stats .v { font-weight: 750; font-size: 1.08rem; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.dot-1 { background: var(--chart-1); } .dot-2 { background: var(--chart-2); } .dot-3 { background: var(--chart-3); }
.result-error { padding: 16px; border-radius: 12px; background: var(--error-soft); color: var(--error); font-weight: 650; margin: 0; }
.words-out { font-size: 1.2rem; font-weight: 650; line-height: 1.5; color: var(--text); overflow-wrap: anywhere; margin: 0; }
.compare { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.compare > div { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface); min-width: 0; }
.compare .result-value { font-size: clamp(1.25rem, 1rem + 1.6vw, 1.7rem); }
.compare .result-sub { font-size: .88rem; }
.compare .win { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; z-index: 90;
  background: var(--secondary); color: var(--surface); padding: 12px 18px; border-radius: 12px; font-weight: 650; box-shadow: var(--shadow-lg);
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
@media (prefers-color-scheme: dark) { .toast { background: #E6EFED; color: #0C1514; } }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Charts & tables ---------- */
.chart-card { margin-top: 16px; }
.chart-card h2, .chart-card h3 { margin-top: 0; }
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid line { stroke: var(--border); }
.chart .axis line { stroke: var(--border-strong); }
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.donut-wrap .chart { width: 170px; flex: none; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; list-style: none; padding: 0; margin: 10px 0 0; font-size: .9rem; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.tabs-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 12px; max-width: 100%; }
.table-wrap:focus-visible { outline: 3px solid var(--focus); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: .93rem; }
th, td { padding: 10px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
thead th { position: sticky; top: 0; background: var(--surface-2); color: var(--secondary); font-weight: 700; z-index: 1; }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
.table-foot { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; align-items: center; margin-top: 12px; }
.table-foot .note { color: var(--muted); font-size: .9rem; margin: 0; }

/* BMI scale */
.bmi-scale { margin-top: 18px; }
.bmi-bar { position: relative; display: flex; height: 16px; border-radius: 999px; overflow: visible; }
.bmi-bar span { height: 100%; }
.bmi-bar span:first-child { border-radius: 999px 0 0 999px; }
.bmi-bar span:last-of-type { border-radius: 0 999px 999px 0; }
.bmi-u { background: #60A5FA; } .bmi-n { background: #22C55E; } .bmi-o { background: #F59E0B; } .bmi-ob { background: #EF4444; }
.bmi-marker { position: absolute; top: -8px; width: 4px; height: 32px; background: var(--text); border-radius: 4px; transform: translateX(-50%); box-shadow: 0 0 0 3px var(--surface); transition: left .35s ease; }
.bmi-labels { position: relative; height: 18px; font-size: .78rem; color: var(--muted); margin-top: 8px; }
.bmi-labels span { position: absolute; transform: translateX(-50%); }
.bmi-key { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; list-style: none; padding: 0; margin: 14px 0 0; font-size: .88rem; color: var(--muted); }
.bmi-key li { display: flex; gap: 8px; align-items: center; }
.bmi-key li.active { color: var(--text); font-weight: 700; }

/* ---------- Content ---------- */
.content { max-width: 78ch; }
.content-layout { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr); margin-top: 8px; }
.content h2:first-child { margin-top: .4em; }
.content li { margin-bottom: .35em; }
.formula { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 10px; padding: 14px 16px; margin: 0 0 1em; font-family: var(--mono); font-size: .95rem; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.example { background: var(--accent-soft); border-radius: 12px; padding: 16px 18px; margin: 0 0 1em; }
.example h3 { margin-top: 0; color: var(--accent-text); }
.example p:last-child, .example ul:last-child { margin-bottom: 0; }
.tip-list { padding-left: 1.2em; }
.faq { margin-top: 8px; }
.faq details { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-bottom: 10px; }
.faq summary {
  cursor: pointer; padding: 14px 48px 14px 16px; font-weight: 700; color: var(--secondary); min-height: 52px; display: flex; align-items: center;
  list-style: none; position: relative; border-radius: 12px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 18px; top: 50%; transform: translateY(-50%); font-size: 1.4rem; color: var(--primary); font-weight: 500; }
.faq details[open] summary::after { content: "–"; }
.faq .answer { padding: 0 16px 14px; }
.faq .answer p:last-child { margin-bottom: 0; }
.disclaimer { font-size: .9rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: 14px; margin-top: 28px; }
.noscript { background: var(--accent-soft); color: var(--accent-text); padding: 14px 16px; border-radius: 12px; font-weight: 600; margin: 12px 0; }
.prose-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.legal { max-width: 78ch; }
.legal h2 { font-size: 1.3rem; }
.updated { color: var(--muted); font-size: .92rem; }

/* ---------- Monetisation ---------- */
.ad-slot { margin: 24px auto; text-align: center; min-height: 280px; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; }
.ad-slot .ad-label { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.ad-slot ins { display: block; width: 100%; min-height: 250px; }
@media (min-width: 768px) { .ad-slot { min-height: 120px; } .ad-slot ins { min-height: 90px; } }
.affiliate { margin: 24px 0; padding: 18px; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border)); background: var(--accent-soft); display: grid; gap: 10px; }
.affiliate .aff-tag { font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); }
.affiliate h2 { font-size: 1.15rem; margin: 0; }
.affiliate p { margin: 0; color: var(--text); }
.affiliate .aff-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.affiliate .aff-note { font-size: .85rem; color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer { margin-top: 48px; background: var(--secondary); color: #D5E0EE; padding: 36px 0 calc(24px + env(safe-area-inset-bottom)); }
@media (prefers-color-scheme: dark) { .site-footer { background: #0A1211; color: var(--muted); border-top: 1px solid var(--border); } }
.site-footer a { color: #FFFFFF; text-decoration: none; display: inline-flex; min-height: 44px; align-items: center; }
@media (prefers-color-scheme: dark) { .site-footer a { color: var(--text); } }
.site-footer a:hover { text-decoration: underline; }
.footer-grid { display: grid; gap: 24px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.footer-grid .about { grid-column: 1 / -1; }
@media (min-width: 900px) { .footer-grid { grid-template-columns: 1.4fr 1fr 1fr 1fr; } .footer-grid .about { grid-column: auto; } }
.site-footer h2 { color: #FFFFFF; font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 6px; }
@media (prefers-color-scheme: dark) { .site-footer h2 { color: var(--text); } }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer .brand { color: #FFFFFF; margin: 0 0 8px; }
.site-footer p { font-size: .93rem; }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, .15); margin-top: 24px; padding-top: 16px; font-size: .88rem; display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; }

/* ---------- Consent banner ---------- */
.consent {
  position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 80; max-width: 560px; margin: 0 auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 16px;
}
.consent p { margin: 0 0 12px; font-size: .95rem; }
.consent .row { display: flex; gap: 8px; flex-wrap: wrap; }
.consent .btn { flex: 1 1 140px; }

/* ---------- Misc ---------- */
.notice { padding: 14px 16px; border-radius: 12px; background: var(--primary-soft); color: var(--text); margin: 0 0 1em; }
.big-404 { font-size: clamp(4rem, 3rem + 6vw, 7rem); font-weight: 900; color: var(--primary); line-height: 1; margin: 0; }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.muted { color: var(--muted); }
.test-pass { color: var(--success); } .test-fail { color: var(--error); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* chart colour classes (set by charts.js) */
.s1 { fill: var(--chart-1); } .s2 { fill: var(--chart-2); } .s3 { fill: var(--chart-3); }
.st1 { stroke: var(--chart-1); } .st2 { stroke: var(--chart-2); } .st3 { stroke: var(--chart-3); }
.a1 { fill: var(--chart-1); opacity: .14; } .a2 { fill: var(--chart-2); opacity: .16; } .a3 { fill: var(--chart-3); opacity: .12; }
.chart .track { stroke: var(--surface-2); }
.chart text.donut-big { font-size: 16px; font-weight: 800; fill: var(--text); }
.compare { margin-top: 14px; }
.copy-words { margin: 12px 0 0; justify-content: flex-start; }
.donut-wrap .stats { flex: 1 1 220px; margin: 0; min-width: 0; }
.seg-btns { display: flex; gap: 8px; }
.bmi-badge-u { background: #DBEAFE; color: #1E40AF; } .bmi-badge-n { background: #DCFCE7; color: #166534; }
.bmi-badge-o { background: #FEF3C7; color: #92400E; } .bmi-badge-ob { background: #FEE2E2; color: #991B1B; }
.bmi-key .dot { width: 12px; height: 12px; }
.related { margin-top: 8px; }
p, li { overflow-wrap: break-word; }
.legal a, .content a { overflow-wrap: anywhere; }

/* ad space preview (local only) */
.ad-slot.is-preview { border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); padding: 12px; }
.ad-preview { margin: 0; color: var(--muted); font-size: .9rem; font-weight: 600; text-align: center; }

/* back-to-top button */
.to-top {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); z-index: 70;
  width: 48px; height: 48px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(12px); transition: opacity .2s, transform .2s, visibility .2s;
}
.to-top svg { width: 22px; height: 22px; }
.to-top:hover { background: var(--primary-strong); }
.to-top.show { opacity: 1; visibility: visible; transform: none; }
