:root {
  --primary: #4F46E5;
  --primary-dark: #3730A3;
  --primary-50: #EEEDFF;
  --primary-100: #DCDAFE;
  --primary-light: #A5A0FF;
  --hl: #FFC94D;
  --hl-50: #FFF6DD;
  --hl-dark: #F7B91F;
  --hl-line: #F6DFA0;
  --hl-ink: #B7791F;
  --ink: #1E1B3A;
  --muted: #64607D;
  --surface: #F5F4FF;
  --white: #FFFFFF;
  --line: #E6E4F2;
  --line-strong: #CFCBE6;

  --c-under: #38BDF8;
  --c-healthy: #22C55E;
  --c-over: #FACC15;
  --c-ob1: #FB923C;
  --c-ob2: #EF4444;
  --c-ob3: #B91C1C;

  --font-head: "Lexend", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(30, 27, 58, .06), 0 8px 24px rgba(30, 27, 58, .06);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 700; }
h2 { font-size: clamp(1.4rem, 3vw, 1.75rem); font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { margin: 0 0 1em; }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-dark); }
mark { background: var(--hl); color: var(--ink); padding: 0 .3em; border-radius: 4px; font-weight: 600; }
img { max-width: 100%; }
.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 16px; }

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--hl); outline-offset: 2px; border-radius: 6px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  font: 600 .95rem/1 var(--font-body);
  padding: .8em 1.1em; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-ghost { background: var(--white); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-hl { background: var(--hl); color: var(--ink); }
.btn-hl:hover { background: var(--hl-dark); color: var(--ink); }
.btn-block { width: 100%; padding: 1em; font-size: 1.05rem; }
.text-link { font-weight: 600; text-decoration: none; }
.text-link:hover { text-decoration: underline; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); background: var(--white); position: sticky; top: 0; z-index: 50; }
.header-inner { display: flex; align-items: center; gap: 24px; min-height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 36px; height: 36px; flex: none; }
.brand-name { font-family: var(--font-head); font-weight: 500; font-size: 1.15rem; letter-spacing: -.01em; }
.brand-name b, .brand-footer b { color: var(--primary); font-weight: 700; }
.brand-tld { color: var(--muted); font-weight: 400; }
.site-nav { margin-left: auto; }
.site-nav ul { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; }
.site-nav a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 500; font-size: .95rem; }
.site-nav a:hover { background: var(--primary-50); color: var(--primary-dark); }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line-strong); border-radius: 10px; width: 44px; height: 44px; font-size: 1.3rem; color: var(--ink); cursor: pointer; }

@media (max-width: 991.98px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .site-nav { display: none; position: absolute; left: 0; right: 0; top: 100%; background: var(--white); border-bottom: 1px solid var(--line); padding: 8px 12px 16px; }
  .site-nav.open { display: block; }
  .site-nav ul { flex-direction: column; }
  .site-nav a { padding: 12px; }
}

/* Ad placeholders: fixed sizes so nothing shifts when ads load */
.ad-slot {
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: repeating-linear-gradient(45deg, #FAFAFC, #FAFAFC 10px, #F2F1F8 10px, #F2F1F8 20px);
  border: 1px dashed var(--line-strong); border-radius: 8px;
  color: #9A96B3; font: 500 .8rem/1.4 var(--font-body); letter-spacing: .02em;
  margin-left: auto; margin-right: auto;
}
.ad-leader { width: 728px; max-width: 100%; height: 90px; margin-top: 16px; margin-bottom: 4px; }
.ad-rect { width: 336px; max-width: 100%; height: 280px; margin-top: 8px; margin-bottom: 48px; }
.ad-rect-sm { width: 300px; height: 250px; }
.ad-sky { width: 300px; height: 600px; }
.ad-mobile { width: 320px; height: 50px; border-radius: 0; }
/* Live ads: same reserved space, no placeholder styling; responsive ads may grow taller */
.ad-live { display: flex; align-items: center; justify-content: center; margin-left: auto; margin-right: auto; overflow: hidden; }
.ad-live.ad-leader { height: auto; min-height: 90px; }
.ad-live.ad-rect { height: auto; min-height: 280px; }
.ad-live.ad-rect-sm { min-height: 250px; }
.ad-live.ad-sky { height: auto; min-height: 600px; }
.ad-live.ad-mobile { height: 50px; }

/* Sticky footer ad: phones (320×50) and tablets (728×90), only where that viewport has an ad */
.ad-anchor { display: none; justify-content: center; position: fixed; left: 0; right: 0; bottom: 0; background: var(--white); border-top: 1px solid var(--line); padding: 4px 0; z-index: 60; }
.ad-anchor.closed { display: none !important; }
.ad-close { position: absolute; right: 4px; top: -28px; width: 28px; height: 28px; border-radius: 8px 8px 0 0; border: 1px solid var(--line); border-bottom: 0; background: var(--white); color: var(--muted); cursor: pointer; }
@media (min-width: 768px) and (max-width: 1199.98px) {
  body.has-anchor-tablet .ad-anchor { display: flex; }
  body.has-anchor-tablet { padding-bottom: 100px; }
}
@media (max-width: 767.98px) {
  body.has-anchor-mobile .ad-anchor { display: flex; }
  body.has-anchor-mobile { padding-bottom: 60px; }
}

.ad-anchor .ad-v { margin: 0; }

/* Ad zones: each size shows only on its viewports (same breakpoints as AD_VIEWPORTS in app/lib/ads.php) */
@media (min-width: 1200px) { .ad-v:not(.ad-v--desktop) { display: none !important; } }
@media (min-width: 768px) and (max-width: 1199.98px) { .ad-v:not(.ad-v--tablet) { display: none !important; } }
@media (max-width: 767.98px) { .ad-v:not(.ad-v--mobile) { display: none !important; } }

/* Hero */
.hero { padding: 32px 0 48px; background: linear-gradient(180deg, var(--white) 0%, var(--surface) 100%); border-bottom: 1px solid var(--line); }
.hero-grid {
  display: grid; gap: 24px 48px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "intro" "calc" "formulas";
}
.hero-intro { grid-area: intro; }
.hero-formulas { grid-area: formulas; }
.hero-calc { grid-area: calc; }
@media (min-width: 992px) {
  .hero { padding: 48px 0 64px; }
  .hero-grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    grid-template-areas: "intro calc" "formulas calc";
    grid-template-rows: auto 1fr;
    align-items: start;
  }
}
.eyebrow { display: inline-flex; align-items: center; gap: 6px; background: var(--primary-50); color: var(--primary-dark); font-weight: 600; font-size: .85rem; padding: 4px 12px; border-radius: 999px; margin-bottom: 14px; }
.byline { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .9rem; color: var(--muted); margin-bottom: 18px; }
.byline i { color: var(--primary); }
.answer { font-size: 1.12rem; background: var(--white); border: 1px solid var(--line); border-left: 4px solid var(--hl); border-radius: 0; padding: 16px 20px; }
.answer strong { font-weight: 600; }

.hero-formulas { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.formula-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.formula-label { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.formula { font-family: var(--font-head); font-size: 1.15rem; font-weight: 500; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.frac { display: inline-flex; flex-direction: column; text-align: center; font-size: .95rem; }
.frac span:first-child { border-bottom: 2px solid var(--ink); padding: 0 6px 2px; }
.frac span:last-child { padding: 2px 6px 0; }
.formula-eg { font-size: .95rem; color: var(--muted); }
.formula-link { margin-top: auto; font-weight: 600; font-size: .92rem; text-decoration: none; }
.formula-link:hover { text-decoration: underline; }

/* Calculator */
.calc-card { background: var(--white); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 22px; }
@media (min-width: 576px) { .calc-card { padding: 28px; } }
.calc-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 16px; }
.calc-head h2 { font-size: 1.3rem; margin: 0; }
.privacy { font-size: .8rem; color: #15803D; background: #ECFDF3; padding: 4px 10px; border-radius: 999px; font-weight: 500; white-space: nowrap; }

.unit-toggle, .mode-toggle { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.unit-toggle { margin-bottom: 18px; }
.unit-toggle button, .mode-toggle button {
  flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 9px 8px;
  font: 600 .9rem/1.2 var(--font-body); color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.unit-toggle button[aria-checked="true"], .mode-toggle button[aria-checked="true"] { background: var(--white); color: var(--primary-dark); box-shadow: 0 1px 3px rgba(30,27,58,.12); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 420px) { .field-row { grid-template-columns: 1fr; } }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field .opt { color: var(--muted); font-weight: 400; }
.field-age { max-width: 50%; }
@media (max-width: 420px) { .field-age { max-width: none; } }
.input-unit { position: relative; flex: 1; }
.input-unit input {
  width: 100%; height: 50px; border: 1.5px solid var(--line-strong); border-radius: 12px;
  padding: 0 44px 0 14px; font: 600 1.15rem var(--font-body); color: var(--ink); background: var(--white);
  font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.input-unit input::-webkit-outer-spin-button, .input-unit input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-unit input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }
.input-unit input::placeholder { color: #BDB9D2; font-weight: 500; }
.input-unit span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .9rem; pointer-events: none; }
.input-pair { display: flex; gap: 8px; }

[data-unit-mode="metric"] .f-ftin, [data-unit-mode="metric"] .f-lb, [data-unit-mode="metric"] .f-st,
[data-unit-mode="imperial"] .f-metric, [data-unit-mode="imperial"] .f-st,
[data-unit-mode="stones"] .f-metric, [data-unit-mode="stones"] .f-lb { display: none; }

.free-text { margin: 2px 0 16px; font-size: .9rem; }
.free-text summary { cursor: pointer; color: var(--primary); font-weight: 500; list-style: none; }
.free-text summary::-webkit-details-marker { display: none; }
.free-text em { font-style: normal; background: var(--surface); padding: 1px 6px; border-radius: 4px; color: var(--ink); }
.free-row { display: flex; gap: 8px; margin-top: 10px; }
.free-row input { flex: 1; height: 44px; border: 1.5px solid var(--line-strong); border-radius: 10px; padding: 0 12px; font: 500 1rem var(--font-body); }
.free-row input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }
.free-msg { margin: 6px 0 0; min-height: 1.2em; font-size: .85rem; color: var(--muted); }
.free-msg.err { color: #B91C1C; }
.free-msg.ok { color: #15803D; }

/* Result */
.result { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 20px; }
.result-empty { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: .95rem; }
.result-empty i { font-size: 1.8rem; color: var(--primary-100); }
.result-empty p { margin: 0; }
.example-flag { font-size: .82rem; color: #92400E; background: var(--hl-50); border-radius: 8px; padding: 6px 10px; display: flex; gap: 6px; align-items: center; }
.result-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.result-label { font-size: .85rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.result-value { font: 700 3.4rem/1 var(--font-head); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.cat-pill { display: inline-block; font-weight: 600; font-size: .88rem; padding: 6px 12px; border-radius: 999px; white-space: nowrap; background: var(--surface); color: var(--ink); }
.c-under { background: #E0F2FE; color: #075985; }
.c-healthy { background: #DCFCE7; color: #166534; }
.c-over { background: #FEF9C3; color: #854D0E; }
.c-ob1 { background: #FFEDD5; color: #9A3412; }
.c-ob2 { background: #FEE2E2; color: #991B1B; }
.c-ob3 { background: #B91C1C; color: #FFFFFF; }
.cat-text { font-weight: 600; padding: 2px 8px; border-radius: 6px; }

.scale { position: relative; margin: 8px 0 34px; }
.scale-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; }
.scale-bar span { display: block; }
.s-under { background: var(--c-under); flex: 3.5; }
.s-healthy { background: var(--c-healthy); flex: 6.5; }
.s-over { background: var(--c-over); flex: 5; }
.s-ob1 { background: var(--c-ob1); flex: 5; }
.s-ob2 { background: var(--c-ob2); flex: 5; }
.s-ob3 { background: var(--c-ob3); flex: 5; }
.scale-marker { position: absolute; top: -6px; left: 0; transform: translateX(-50%); transition: left .5s cubic-bezier(.2,.8,.2,1); }
.scale-marker span { display: block; width: 24px; height: 24px; border-radius: 50%; background: var(--white); border: 5px solid var(--ink); box-shadow: 0 2px 6px rgba(30,27,58,.25); }
.scale-ticks { position: relative; height: 16px; margin-top: 6px; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.scale-ticks span { position: absolute; transform: translateX(-50%); }

.child-note { background: var(--primary-50); border-radius: 10px; padding: 10px 12px; font-size: .9rem; display: flex; gap: 8px; }
.child-note i { color: var(--primary); font-size: 1.1rem; }

.result-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0 0 18px; }
.result-facts div { background: var(--surface); border-radius: 12px; padding: 10px 12px; }
.result-facts dt { font-size: .78rem; font-weight: 500; color: var(--muted); display: flex; gap: 4px; align-items: center; }
.result-facts dd { margin: 2px 0 0; font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; }
.info { color: var(--muted); text-decoration: none; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.result-actions .btn-hl { flex: 1 1 100%; }
.result-actions .btn-ghost { flex: 1 1 0; font-size: .88rem; }

/* Content layout with right rail */
.page-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 48px; padding-top: 48px; padding-bottom: 32px; }
.content { max-width: 780px; width: 100%; margin: 0 auto; }
.rail { display: none; }
@media (min-width: 1200px) {
  .page-grid { grid-template-columns: minmax(0, 1fr) 300px; }
  .content { margin: 0; max-width: none; }
  .rail { display: block; }
  .rail-sticky { position: sticky; top: 92px; }
}

.section { margin-bottom: 56px; scroll-margin-top: 84px; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.section-head h2 { margin: 0; }
.lead { color: var(--muted); font-size: 1.05rem; }
.more { margin-top: 12px; font-size: .95rem; }
.note { font-size: .92rem; color: var(--muted); margin-top: 12px; }

/* Solver */
.mode-toggle button { padding: 8px 12px; font-size: .85rem; white-space: nowrap; }
.solver { list-style: none; padding: 0; margin: 18px 0 0; counter-reset: step; }
.solver li {
  position: relative; padding: 16px 18px 16px 64px; margin-bottom: 12px;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  counter-increment: step;
}
.solver li::before {
  content: counter(step); position: absolute; left: 16px; top: 16px; width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-50); color: var(--primary-dark); font: 700 .95rem/32px var(--font-head); text-align: center;
}
.solver .s-title { font-weight: 600; margin-bottom: 6px; }
.solver .s-expr { font: 500 1.25rem/1.5 var(--font-head); font-variant-numeric: tabular-nums; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.solver .s-expr mark { padding: 2px 10px; }
.solver .s-why { font-size: .9rem; color: var(--muted); margin: 6px 0 0; }
.solver li.final { border-color: var(--primary-100); background: linear-gradient(180deg, var(--white), var(--primary-50)); }
.solver li.final::before { content: "✓"; background: var(--primary); color: #fff; }

.anim .solver li { opacity: 0; transform: translateY(8px); }
.anim .solver li.shown { opacity: 1; transform: none; transition: opacity .35s, transform .35s; }
.anim .solver li.shown mark { animation: hl .7s ease .25s both; }
@keyframes hl { from { background-size: 0 100%; } to { background-size: 100% 100%; } }
.solver mark { background: linear-gradient(var(--hl), var(--hl)) no-repeat; background-size: 100% 100%; }

.hand-input { width: 120px; height: 42px; border: 1.5px dashed var(--primary); border-radius: 10px; padding: 0 10px; font: 600 1.1rem var(--font-head); font-variant-numeric: tabular-nums; color: var(--ink); background: var(--primary-50); }
.hand-input:focus { outline: none; border-style: solid; box-shadow: 0 0 0 4px var(--primary-50); background: var(--white); }
.hand-input.ok { border: 1.5px solid #16A34A; background: #ECFDF3; }
.hand-input.bad { border: 1.5px solid #DC2626; background: #FEF2F2; }
.hand-check { font-size: .85rem; padding: .6em .9em; }
.hand-fb { font-size: .9rem; margin: 6px 0 0; }
.hand-fb.ok { color: #15803D; }
.hand-fb.bad { color: #B91C1C; }
.solver-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.solver-empty { color: var(--muted); background: var(--surface); border-radius: var(--radius); padding: 18px; }

/* Chart */
.chart-wrap { position: relative; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; touch-action: none; }
#bmi-chart { display: block; width: 100%; cursor: crosshair; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: .8rem; padding: 4px 8px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, -130%); }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0; margin: 12px 0 0; font-size: .85rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend .sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; flex: none; }

/* Way cards */
.way-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-top: 16px; }
.way-card { display: flex; flex-direction: column; gap: 4px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s, box-shadow .15s; }
.way-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); color: var(--ink); }
.way-card i { font-size: 1.5rem; color: var(--primary); margin-bottom: 4px; }
.way-card strong { font-family: var(--font-head); font-weight: 600; }
.way-card span { font-size: .85rem; color: var(--muted); line-height: 1.45; }

/* Examples */
.examples { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 16px; }
.example { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; }
.example header { margin-bottom: 8px; }
.example h3 { margin: 6px 0 0; }
.tag { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--primary-dark); background: var(--primary-50); padding: 3px 8px; border-radius: 6px; }
.example ol { padding-left: 1.2em; margin: 0 0 12px; font-size: .93rem; font-variant-numeric: tabular-nums; }
.example li { margin-bottom: 4px; }
.ex-result { margin: auto 0 0; padding-top: 10px; border-top: 1px dashed var(--line-strong); font-weight: 600; }

.callout { display: flex; gap: 12px; background: var(--hl-50); border-radius: var(--radius); padding: 14px 16px; }
.callout i { font-size: 1.4rem; color: #B45309; }
.callout p { margin: 0; }

/* Categories table */
.table-wrap { overflow-x: auto; }
.cat-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cat-table th, .cat-table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.cat-table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cat-table tr.you { background: var(--hl-50); }
.cat-table tr.you td:first-child::after { content: "  ← you"; font-weight: 700; color: #92400E; }

.mistakes { list-style: none; padding: 0; margin: 0; }
.mistakes li { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.mistakes i { color: #DC2626; font-size: 1.3rem; line-height: 1.4; }

.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.pros, .cons { border-radius: var(--radius); padding: 16px 18px; }
.pros { background: #F0FDF4; }
.cons { background: #FFF7ED; }
.pros h3 i { color: #16A34A; }
.cons h3 i { color: #EA580C; }
.pros ul, .cons ul { margin: 0; padding-left: 1.2em; }

.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 16px 32px 16px 0; font-weight: 600; position: relative; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 4px; top: 12px; font: 400 1.5rem var(--font-head); color: var(--primary); }
.faq details[open] summary::after { content: "−"; }
.faq details p { color: var(--muted); }

.trust { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; background: var(--surface); border-radius: var(--radius); padding: 18px; }
.trust-item { display: flex; gap: 10px; font-size: .88rem; }
.trust-item i { font-size: 1.4rem; color: var(--primary); }
.trust-item strong { display: block; }
.trust-item span { color: var(--muted); }
.disclaimer { font-size: .82rem; color: var(--muted); margin-top: 14px; }

/* Footer */
.site-footer { background: var(--ink); color: #C9C6DF; padding: 48px 0 24px; margin-top: 24px; font-size: .92rem; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 24px; }
/* The brand needs more room than a link column: its own row on smaller screens, a wider first column on large ones */
.footer-grid > :first-child { grid-column: 1 / -1; max-width: 420px; }
@media (min-width: 1200px) {
  .footer-grid { grid-template-columns: minmax(250px, 1.3fr) repeat(auto-fit, minmax(140px, 1fr)); }
  .footer-grid > :first-child { grid-column: auto; }
}
.site-footer h3 { color: #fff; font-size: .95rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 6px; }
.site-footer a { color: #C9C6DF; text-decoration: none; }
.site-footer a:hover { color: #fff; }
.brand-footer { font-family: var(--font-head); font-size: 1.15rem; color: #fff !important; display: inline-block; margin-bottom: 8px; }
.brand-footer b { color: var(--primary-light); }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.1); margin-top: 32px; padding-top: 16px; font-size: .82rem; }

/* Print = "Save as PDF" result report */
@media print {
  .site-header, .ad-slot, .ad-anchor, .rail, .site-footer, .free-text, .unit-toggle, .btn, .mode-toggle, .solver-foot,
  .ad-close { display: none !important; }
  .hero { background: none; border: 0; padding: 0; }
  .calc-card { box-shadow: none; }
  body { font-size: 12pt; }
}

/* Phones: get the calculator into the first screen */
@media (max-width: 575.98px) {
  body { font-size: 16px; }
  .hero { padding: 18px 0 32px; }
  .hero-grid { gap: 18px; }
  .eyebrow { display: none; }
  h1 { margin-bottom: .3em; }
  .byline { font-size: .8rem; gap: 2px 12px; margin-bottom: 12px; }
  .answer { font-size: .98rem; padding: 12px 14px; line-height: 1.55; }
  .calc-head h2 { font-size: 1.15rem; }
  .privacy { font-size: .72rem; padding: 3px 8px; }
  .brand-name { font-size: 1rem; }
  .brand-mark { width: 32px; height: 32px; }
  .result-value { font-size: 2.8rem; }
}

/* ===== Shared additions for spoke pages ===== */
.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; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 12px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--primary); text-decoration: underline; }
.site-nav a[aria-current="page"] { background: var(--primary-50); color: var(--primary-dark); }

.field-label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.label-row label { margin: 0; }
.link-btn { background: none; border: 0; padding: 2px 4px; color: var(--primary); font: 500 .85rem var(--font-body); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; border-radius: 6px; }
.link-btn:hover { text-decoration: underline; }
.field-hint { font-size: .8rem; color: var(--muted); margin: 6px 0 0; }
.input-unit.date input { padding-right: 10px; font-size: 1rem; }
[data-age-mode="years"] .age-mode-dob, [data-age-mode="dob"] .age-mode-years { display: none !important; }
.sex-toggle { margin-bottom: 0; }

/* ===== Kids page ===== */
.kid-steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kid-steps li { display: flex; gap: 12px; align-items: flex-start; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.ks-num { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--hl); font: 700 .95rem/30px var(--font-head); text-align: center; }
.kid-steps strong { display: block; font-family: var(--font-head); font-weight: 600; }
.kid-steps span:not(.ks-num) { font-size: .88rem; color: var(--muted); line-height: 1.4; display: block; }

.result-value sup { font-size: .4em; vertical-align: super; margin-left: 2px; letter-spacing: 0; }
.result-sub { font-size: .9rem; color: var(--muted); margin-top: 6px; }
.result-sub b { color: var(--ink); }
.pct-scale .s-under, .pct-scale .s-healthy, .pct-scale .s-over, .pct-scale .s-ob1 { flex: none; }

.dots-wrap { display: flex; gap: 16px; align-items: center; background: var(--surface); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.dots { display: grid; grid-template-columns: repeat(20, 7px); gap: 3px; flex: none; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #D9D6EE; }
.dot.low { background: var(--primary); }
.dot.you { background: var(--hl); box-shadow: 0 0 0 2px var(--ink); }
.dots-wrap p { margin: 0; font-size: .9rem; line-height: 1.45; }
@media (max-width: 420px) { .dots-wrap { flex-direction: column; align-items: flex-start; } }

#r-severe { margin-bottom: 14px; }

.lms-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 4px 0; }
.lms-cards div { background: var(--hl-50); border-radius: 10px; padding: 8px 10px; }
.lms-cards span { display: block; font-size: .75rem; color: #92400E; font-weight: 600; }
.lms-cards b { font: 600 1.15rem var(--font-head); font-variant-numeric: tabular-nums; }
.formula-box { font: 500 1.15rem var(--font-head); display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; }
.formula-box sup, .s-expr sup { font-size: .65em; }
.solver .s-sub { display: block; font-size: 1.05rem; margin-bottom: 2px; }
.solver .s-sub b { font-weight: 600; }

.history { margin-top: 20px; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.history-head h3 { margin: 0; }
.history-table td, .history-table th { padding: 8px 10px; font-size: .92rem; }
.history-empty { color: var(--muted); font-size: .92rem; margin: 6px 0 0; }
#history-clear { margin-top: 10px; font-size: .85rem; }

.same-bmi { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-top: 16px; }
.same-bmi-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; font-weight: 600; }
.sb-input { flex: none; width: 110px; }
.sb-input input { height: 44px; padding-right: 12px; }
.same-bmi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.sb-card { background: var(--surface); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.sb-age { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.sb-card b { font: 600 1.05rem var(--font-head); }
.sb-card .cat-pill { font-size: .75rem; padding: 3px 8px; white-space: normal; }

.parent-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (min-width: 576px) { .parent-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .parent-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; } }
.parent-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.parent-card i { font-size: 1.5rem; color: var(--primary); }
.parent-card h3 { margin: 6px 0 6px; }
.parent-card p { font-size: .93rem; margin: 0; color: var(--muted); }

/* Byline author (pen name from the admin panel) */
.byline-author { display: inline-flex; align-items: center; gap: 6px; }
.byline-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }


/* ===== Real site: pieces that come from Markdown and the layout ===== */
.hero-grid--plain { grid-template-areas: "intro" "formulas"; }
@media (min-width: 992px) {
  .hero-grid--plain { grid-template-columns: minmax(0, 1fr); grid-template-areas: "intro" "formulas"; max-width: 860px; }
}
.section-tools { display: flex; justify-content: flex-end; margin: -4px 0 8px; }

/* "Read more" links: [Text](/path/){.text-link} */
.text-link::after { content: " →"; }

/* Blockquote marked {.callout} */
blockquote.callout { margin: 0 0 1em; background: var(--hl-50); border-radius: var(--radius); padding: 14px 16px 14px 48px; position: relative; }
blockquote.callout::before { content: "💡"; position: absolute; left: 16px; top: 13px; font-size: 1.2rem; }
blockquote.callout p:last-child { margin-bottom: 0; }

/* List marked {.mistakes} */
ul.mistakes { list-style: none; padding: 0; margin: 0; }
ul.mistakes li { display: block; position: relative; padding: 14px 0 14px 36px; border-bottom: 1px solid var(--line); }
ul.mistakes li::before { content: "✕"; position: absolute; left: 0; top: 14px; width: 22px; height: 22px; border-radius: 50%; background: #FEE2E2; color: #DC2626; font-size: .75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }

/* Tables written in Markdown */
.content table:not(.cat-table):not(.bmi-grid) { width: 100%; border-collapse: collapse; margin: 0 0 1em; font-variant-numeric: tabular-nums; }
.content table:not(.cat-table):not(.bmi-grid) th, .content table:not(.cat-table):not(.bmi-grid) td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.content table:not(.cat-table):not(.bmi-grid) th { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.pros ul, .cons ul { margin: 0; }
.pros h3::before { content: "✓ "; color: #16A34A; }
.cons h3::before { content: "! "; color: #EA580C; }

.draft-banner { background: #FFF6DD; color: #92400E; text-align: center; font-size: .9rem; font-weight: 500; padding: 8px 16px; border-bottom: 1px solid #FBD38D; }
.dev-warning { background: #FEF2F2; color: #991B1B; border: 1px dashed #F87171; border-radius: 8px; padding: 8px 12px; font-size: .9rem; }
.not-found ul { padding-left: 1.2em; }

/* Links to pages that aren't published yet (see unlink_pending_pages) */
a.link-pending { text-decoration-style: dotted; opacity: .75; }
a.link-pending:hover { cursor: help; }

/* ===== Tools (assets/js/tools.js) ===== */
.tool { border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin: 16px 0 20px; background: var(--white); }
@media (min-width: 576px) { .tool { padding: 22px; } }
.tool[data-unit="metric"] [data-show-unit="imperial"], .tool[data-unit="imperial"] [data-show-unit="metric"] { display: none !important; }
.hero-calc > .tool { margin-top: 0; box-shadow: var(--shadow); border-radius: 20px; }
.tool-toggles { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.seg-toggle { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.tool > .seg-toggle { margin-bottom: 16px; }
.seg-toggle button { border: 0; background: transparent; border-radius: 9px; padding: 8px 12px; font: 600 .88rem/1.2 var(--font-body); color: var(--muted); cursor: pointer; }
.seg-toggle button[aria-checked="true"] { background: var(--white); color: var(--primary-dark); box-shadow: 0 1px 3px rgba(30,27,58,.12); }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 14px; }
.tool-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.tool fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; align-content: start; }
.tool legend { font-weight: 600; font-size: .9rem; margin-bottom: 8px; }
.tool .select { width: 100%; height: 50px; border: 1.5px solid var(--line-strong); border-radius: 12px; padding: 0 12px; font: 500 1rem var(--font-body); background: var(--white); color: var(--ink); }
.field-narrow { max-width: 200px; }
.check-row { display: flex; gap: 8px; align-items: center; font-weight: 500; margin: 4px 0 12px; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--primary); }
.tool-out { margin-top: 6px; border-top: 1px dashed var(--line-strong); padding-top: 14px; }
.tool-out:empty { display: none; }
.tool-big { font-size: 1.1rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tool-big b { font: 700 1.8rem var(--font-head); }
.tool-hint { font-size: .88rem; color: var(--muted); margin: 8px 0 0; }
.tool-note { font-size: .92rem; border-radius: 10px; padding: 10px 12px; margin: 10px 0 0; }
.tool-note.ok { background: #F0FDF4; color: #166534; }
.tool-note.flag { background: #FFF7ED; color: #9A3412; }
.tool-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.tool-stats > div { background: var(--surface); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.tool-stats span { font-size: .78rem; font-weight: 600; color: var(--muted); }
.tool-stats b { font: 700 1.25rem var(--font-head); font-variant-numeric: tabular-nums; }
.tool-stats em { font-style: normal; font-size: .8rem; color: var(--muted); }
.tool-stats em.flag { color: #C2410C; font-weight: 600; }
.tool-stats em.ok { color: #15803D; font-weight: 600; }
.compare-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.compare-cards > div { background: var(--surface); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.compare-cards span { font-size: .8rem; font-weight: 600; color: var(--muted); }
.compare-cards em { font-style: normal; font-size: .82rem; color: var(--muted); }
.slider-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px 12px; margin-bottom: 14px; }
@media (min-width: 576px) { .slider-row { grid-template-columns: 200px minmax(0, 1fr) 140px; align-items: center; } }
.slider-row label { font-weight: 600; font-size: .9rem; }
.slider-row input[type="range"] { width: 100%; accent-color: var(--primary); }
.slider-row output { font-weight: 600; font-variant-numeric: tabular-nums; }
.preset-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-sm { font-size: .82rem; padding: .55em .85em; }
.err-table td, .err-table th { text-align: center; }
.err-table th[scope="row"] { text-align: left; }

/* Spreadsheet formulas */
.formula-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.formula-row > div, .formula-copy { min-width: 0; }
.formula-label { font-weight: 600; }
.formula-copy { display: flex; gap: 8px; align-items: flex-start; }
.formula-copy code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; }
.download-csv { margin-top: 14px; }

/* Code (Markdown fenced blocks and inline) */
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
pre { background: #1E1B3A; color: #E4E2F3; border-radius: 12px; padding: 14px 16px; overflow-x: auto; margin: 0 0 1em; }
pre code { background: none; border: 0; padding: 0; color: inherit; font-size: .86rem; line-height: 1.6; }

/* Printable BMI table */
.bmi-grid { border-collapse: collapse; font-size: .74rem; font-variant-numeric: tabular-nums; width: 100%; }
.bmi-grid caption { text-align: left; font-weight: 600; font-size: .85rem; color: var(--muted); padding-bottom: 8px; }
.bmi-grid th, .bmi-grid td { padding: 5px 4px; text-align: center; border: 1px solid #fff; white-space: nowrap; }
.bmi-grid thead th { background: var(--surface); font-weight: 600; }
.bmi-grid tbody th { background: var(--surface); text-align: left; padding-left: 8px; }
.g-under { background: #E0F2FE; } .g-healthy { background: #DCFCE7; } .g-over { background: #FEF9C3; }
.g-ob1 { background: #FFEDD5; } .g-ob2 { background: #FEE2E2; } .g-ob3 { background: #FECACA; }
@media print {
  body.printing-table * { visibility: hidden; }
  body.printing-table .bmi-table-tool, body.printing-table .bmi-table-tool * { visibility: visible; }
  body.printing-table .bmi-table-tool { position: absolute; left: 0; top: 0; width: 100%; border: 0; }
  body.printing-table .tool-toggles { display: none; }
  .bmi-grid td, .bmi-grid th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
/* Long inline formulas in running text wrap instead of overflowing */
p code, li code, td code { overflow-wrap: anywhere; }

/* ===== Phase 2–3 tools ===== */
.measures-table .formula-cell { font-size: .8rem; color: var(--muted); }
.measures-table th[scope="row"] { font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--ink); font-size: .92rem; }
.tool-hint.err, .track-msg.err { color: #B91C1C; }
.track-chart { width: 100%; display: block; margin: 12px 0; }
.track-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.track-add { margin-top: 4px; }
.ws-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.worksheet { margin-top: 12px; }
.ws-page { border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 14px; background: #fff; }
.ws-head { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: baseline; justify-content: space-between; border-bottom: 2px solid var(--ink); padding-bottom: 8px; margin-bottom: 10px; }
.ws-head h3 { margin: 0; }
.ws-seed { color: var(--muted); font-size: .85rem; }
.ws-instructions { font-size: .9rem; }
.ws-list { padding-left: 1.4em; margin: 0; }
.ws-list li { padding: 10px 0; border-bottom: 1px dashed var(--line); display: flex; flex-direction: column; gap: 6px; }
.ws-blank { color: var(--muted); font-size: .9rem; }
.ws-answers .ws-list li span:last-child { font-size: .88rem; color: var(--muted); }
.pr-streak { font-weight: 600; color: #15803D; }
.pr-step { margin-bottom: 12px; }
.pr-step label { font-weight: 600; font-size: .9rem; display: block; margin-bottom: 6px; }
.pr-row { display: flex; gap: 8px; align-items: center; }
.batch-input { width: 100%; border: 1.5px solid var(--line-strong); border-radius: 12px; padding: 10px 12px; font: 500 .9rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.batch-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }
.batch-download { margin-top: 12px; }
.print-card { border: 2px solid var(--ink); border-radius: 16px; padding: 20px; max-width: 640px; margin: 16px 0; background: #fff; }
.print-card h3 { margin-top: 0; }
.pc-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.pc-cols p { margin: 4px 0; }
.pc-cats { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: .85rem; text-align: center; }
.pc-cats td { padding: 8px 4px; border: 2px solid #fff; }
@media print {
  body.printing-worksheet * , body.printing-card * { visibility: hidden; }
  body.printing-worksheet .worksheet, body.printing-worksheet .worksheet *,
  body.printing-card .print-card, body.printing-card .print-card * { visibility: visible; }
  body.printing-worksheet .worksheet, body.printing-card .print-card { position: absolute; left: 0; top: 0; width: 100%; }
  body.printing-worksheet .ws-page { border: 0; page-break-after: always; }
  body.printing-card .print-card button { display: none; }
  .pc-cats td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Gear pages */
.affiliate-note { font-size: .82rem; color: var(--muted); background: var(--surface); border-radius: 8px; padding: 8px 12px; display: flex; gap: 6px; align-items: flex-start; }
.product-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 16px 0; }
.product-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.product-card h3 { margin: 4px 0 0; }
.product-card p { font-size: .92rem; color: var(--muted); margin: 0; }
.product-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 8px; }
.product-price { font-weight: 600; }
.pc-cats { table-layout: fixed; }
.pc-cats td { overflow-wrap: anywhere; }
@media (max-width: 420px) { .pc-cats { font-size: .72rem; } .print-card { padding: 14px; } }

/* ===== Article UX: progress, checks, contents, takeaways, sources, author, related ===== */
.read-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1000; pointer-events: none; }
.read-progress span { display: block; height: 100%; background: var(--primary); transform: scaleX(0); transform-origin: 0 50%; }

.page-checks { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -6px 0 18px; }
.check-badge { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 500; color: #166534; background: #ECFDF3; border: 1px solid #BBF7D0; border-radius: 999px; padding: 4px 10px; text-decoration: none; }
.check-badge:hover { background: #DCFCE7; }
.check-badge i { font-size: .95rem; }
.page-tools { display: inline-flex; gap: 4px; margin-left: auto; }
.page-tool { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--white); color: var(--ink); border-radius: 999px; padding: 4px 11px; font: 500 .82rem var(--font-body); cursor: pointer; }
.page-tool:hover { border-color: var(--primary); color: var(--primary); }
.page-tool:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (max-width: 575.98px) {
  .page-checks { margin: -4px 0 12px; gap: 6px; }
  .check-badge, .page-tool { font-size: .76rem; padding: 3px 9px; }
  .page-tools { margin-left: 0; }
}

/* On this page */
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a { display: block; text-decoration: none; color: var(--muted); font-size: .88rem; line-height: 1.35; padding: 6px 10px 6px 12px; border-left: 2px solid var(--line); }
.toc a:hover { color: var(--primary); }
.toc a.active { color: var(--primary-dark); border-left-color: var(--primary); font-weight: 600; background: var(--primary-50); }
.toc-title { font: 600 .78rem var(--font-head); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.toc-rail { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 12px; margin-bottom: 20px; max-height: calc(100vh - 92px - 640px); min-height: 160px; overflow-y: auto; }
.toc-inline { border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); margin: 0 0 32px; }
.toc-inline summary { cursor: pointer; padding: 12px 16px; font: 600 .95rem var(--font-head); list-style: none; display: flex; align-items: center; gap: 8px; }
.toc-inline summary::-webkit-details-marker { display: none; }
.toc-inline summary::after { content: "\ea4e"; font-family: remixicon; margin-left: auto; transition: transform .2s; }
.toc-inline[open] summary::after { transform: rotate(180deg); }
.toc-inline nav { padding: 0 12px 12px; }
@media (min-width: 1200px) { .toc-inline { display: none; } }
/* Short screens: the contents list scrolls away and only the ad stays pinned */
@media (min-width: 1200px) and (max-height: 900px) {
  .rail-sticky { display: contents; }
  .toc-rail { max-height: none; }
  .rail-ad { position: sticky; top: 92px; }
}
/* No sidebar ad (ads off or no code): the contents list gets the full height and stays pinned */
.rail-sticky:not(:has(.rail-ad)) .toc-rail { max-height: calc(100vh - 120px); }
@media (min-width: 1200px) and (max-height: 900px) {
  .rail-sticky:not(:has(.rail-ad)) { display: block; }
  .rail-sticky:not(:has(.rail-ad)) .toc-rail { max-height: calc(100vh - 120px); }
}

/* Key takeaways */
.takeaways { background: var(--hl-50); border: 1px solid var(--hl-line); border-radius: var(--radius); padding: 18px 20px 8px; margin: 0 0 28px; }
.takeaways-title { font: 600 1rem var(--font-head); margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.takeaways-title i { color: var(--hl-ink); font-size: 1.15rem; }
.takeaways ul { margin: 0 0 10px; padding-left: 0; list-style: none; }
.takeaways li { position: relative; padding-left: 26px; margin-bottom: 8px; }
.takeaways li::before { content: "\eb7b"; font-family: remixicon; position: absolute; left: 0; top: 0; color: var(--hl-ink); }

/* Citations and sources */
.footnote-ref { text-decoration: none; font-weight: 600; font-size: .78em; padding: 0 2px; }
.footnote-ref::before { content: "["; } .footnote-ref::after { content: "]"; }
sup[id^="fnref"] { scroll-margin-top: 100px; }
.sources-list { font-size: .9rem; color: var(--muted); padding-left: 1.4em; }
.sources-list li { margin-bottom: 8px; scroll-margin-top: 100px; }
.sources-list li:target { background: var(--hl-50); border-radius: 6px; }
.sources-list p { margin: 0; display: inline; }
.sources-further { list-style: disc; }
.footnote-backref { text-decoration: none; margin-left: 2px; }
.section-sources h3 { font-size: 1rem; margin-top: 16px; }

/* "What it shows / doesn't show" tables: {.compare} before a two-column table */
table.compare th:first-child, table.compare th:last-child { width: 50%; }
table.compare td { vertical-align: top; }
table.compare td:first-child::before, table.compare td:last-child::before { font-family: remixicon; margin-right: 6px; }
table.compare td:first-child::before { content: "\eb7b"; color: #16A34A; }
table.compare td:last-child::before { content: "\eb99"; color: #DC2626; }

/* Talk to a doctor: {.doctor} before a blockquote */
blockquote.doctor { margin: 0 0 1.2em; background: #F0F9FF; border: 1px solid #BAE6FD; border-left: 4px solid #0284C7; border-radius: var(--radius); padding: 14px 16px 14px 52px; position: relative; }
blockquote.doctor::before { content: "\f197"; font-family: remixicon; position: absolute; left: 16px; top: 12px; font-size: 1.35rem; color: #0284C7; }
blockquote.doctor p:last-child { margin-bottom: 0; }

/* Checklists */
ul.checklist { list-style: none; padding-left: 0; }
.check-item label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; padding: 6px 0; }
.check-item input { width: 20px; height: 20px; flex: none; margin-top: 2px; accent-color: var(--primary); cursor: pointer; }
.check-item.done label { color: var(--muted); }
.checklist-note { font-size: .82rem; color: var(--muted); margin-top: -4px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; text-decoration: underline; cursor: pointer; }

/* Self-check */
.self-check { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 0 0 1.2em; box-shadow: var(--shadow); }
.self-check fieldset { border: 0; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .self-check fieldset { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.self-check legend { font: 600 1rem var(--font-head); margin-bottom: 10px; padding: 0; }
.sc-option { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer; font-size: .93rem; }
.sc-option:has(input:checked) { border-color: var(--primary); background: var(--primary-50); }
.sc-option input { width: 18px; height: 18px; flex: none; margin-top: 2px; accent-color: var(--primary); }
.sc-result > div { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.sc-result > div:first-child { border-top: 0; margin-top: 0; }
.sc-result p { margin: 0 0 6px; font-size: .93rem; }
.sc-head { font-weight: 600; display: flex; gap: 6px; align-items: flex-start; }
.sc-head i { color: var(--primary); margin-top: 1px; }
.sc-links { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.sc-links a { font-weight: 500; }
.sc-links a::after { content: " →"; }

/* Author box */
.author-box { display: flex; gap: 16px; align-items: flex-start; background: var(--surface); border-radius: var(--radius); padding: 20px; margin: 8px 0 32px; }
.author-avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; }
.author-avatar--icon { display: grid; place-items: center; background: var(--primary-100); color: var(--primary-dark); font-size: 1.6rem; }
.author-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0; }
.author-name { font: 600 1.1rem var(--font-head); margin: 0 0 6px; }
.author-bio { margin: 0 0 6px; font-size: .95rem; }
.author-links { margin: 0; font-size: .88rem; }
@media (max-width: 420px) { .author-box { padding: 16px; gap: 12px; } .author-avatar { width: 48px; height: 48px; } }

/* Related pages */
.related { margin: 40px 0 16px; }
.related h2 { font-size: 1.35rem; }
.related-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .related-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.related-card { display: flex; flex-direction: column; gap: 6px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s; }
.related-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.related-card strong { font-family: var(--font-head); font-weight: 600; line-height: 1.3; }
.related-card span { font-size: .88rem; color: var(--muted); }
.related-card .related-more { margin-top: auto; color: var(--primary); font-weight: 500; }

/* Back to top: sits above the sticky footer ad when there is one */
.back-to-top { position: fixed; right: 16px; bottom: 24px; z-index: 900; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--white); color: var(--primary); box-shadow: var(--shadow); font-size: 1.3rem; cursor: pointer; display: grid; place-items: center; }
.back-to-top[hidden] { display: none; }
.back-to-top:hover { background: var(--primary); color: #fff; }
@media (max-width: 767.98px) { body.has-anchor-mobile .back-to-top { bottom: 96px; } }
@media (min-width: 768px) and (max-width: 1199.98px) { body.has-anchor-tablet .back-to-top { bottom: 140px; } }
body.ad-anchor-closed .back-to-top { bottom: 24px !important; }

@media print {
  .read-progress, .page-tools, .toc, .back-to-top, .related, .self-check fieldset, .checklist-note, .skip-link { display: none !important; }
  .page-grid { display: block; padding-top: 16px; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .8em; color: #555; word-break: break-all; }
  .related-card, .check-badge { border: 0; }
}

/* Credit line on printables (the terms ask that it stays on copies) */
.ws-credit { font-size: .75rem; color: var(--muted); margin: 10px 0 0; text-align: right; }
