/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f5f8f7;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --text: #12211d;
  --text-muted: #52655f;
  --border: #dfe8e4;
  --accent: #0f8a6c;
  --accent-dark: #0a6b53;
  --accent-soft: #e3f4ee;

  --cat-under: #3b82f6;
  --cat-normal: #16a34a;
  --cat-over: #f59e0b;
  --cat-obese: #dc2626;

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Sora", var(--sans);

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 1px 2px rgba(18, 33, 29, 0.04), 0 8px 24px -12px rgba(18, 33, 29, 0.14);
  --shadow-lg: 0 4px 8px rgba(18, 33, 29, 0.05), 0 20px 45px -18px rgba(18, 33, 29, 0.22);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1613;
    --surface: #16211d;
    --surface-2: #1c2925;
    --text: #eef4f1;
    --text-muted: #9db1aa;
    --border: #26332e;
    --accent: #2bcf9f;
    --accent-dark: #1fa980;
    --accent-soft: rgba(43, 207, 159, 0.14);
  }
}
:root[data-theme="dark"] {
  --bg: #0e1613;
  --surface: #16211d;
  --surface-2: #1c2925;
  --text: #eef4f1;
  --text-muted: #9db1aa;
  --border: #26332e;
  --accent: #2bcf9f;
  --accent-dark: #1fa980;
  --accent-soft: rgba(43, 207, 159, 0.14);
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.12; letter-spacing: -0.01em; font-family: var(--display); }
::selection { background: var(--accent); color: #fff; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: 780px; margin-inline: auto; padding-inline: 1.25rem; }

.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--accent); color: #fff;
  z-index: 9999; border-radius: 8px; font-weight: 600;
  transition: top .2s var(--ease-out);
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   4. Header
   ============================================================= */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding-block: .9rem;
  gap: 1rem;
}
.brand {
  display: flex; align-items: center; gap: .5rem;
  font-family: var(--display); font-weight: 700; font-size: 1.05rem;
  color: var(--text);
}
.brand-mark { color: var(--accent); flex-shrink: 0; }
.header-nav { display: none; gap: 1.5rem; font-size: .92rem; font-weight: 500; color: var(--text-muted); }
.header-nav a:hover { color: var(--accent); }
@media (min-width: 720px) {
  .header-nav { display: flex; }
}

/* =============================================================
   5. Hero + tool card
   ============================================================= */
.hero { padding-block: 2.75rem 1.5rem; text-align: center; }
.hero h1 {
  font-size: clamp(1.7rem, 4.4vw, 2.5rem);
  max-width: 20ch;
  margin-inline: auto;
}
.hero-sub {
  color: var(--text-muted);
  max-width: 46ch;
  margin: .85rem auto 0;
  font-size: 1.02rem;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.6rem;
  margin: 1.75rem auto 0;
  max-width: 620px;
  text-align: left;
}

.imc-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.field label {
  display: block;
  font-size: .88rem;
  font-weight: 600;
  margin-bottom: .4rem;
  color: var(--text);
}
.input-unit {
  display: flex; align-items: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  overflow: hidden;
  transition: border-color .15s var(--ease-out);
}
.input-unit:focus-within { border-color: var(--accent); }
.input-unit input {
  flex: 1; min-width: 0;
  border: 0; background: transparent; color: var(--text);
  font-size: 1.15rem; font-weight: 600;
  padding: .75rem .85rem;
  font-family: var(--sans);
  -moz-appearance: textfield;
}
.input-unit input::-webkit-outer-spin-button,
.input-unit input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-unit .unit {
  padding: 0 .9rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: .92rem;
  border-left: 1px solid var(--border);
  align-self: stretch;
  display: flex; align-items: center;
}
.hint { font-size: .78rem; color: var(--text-muted); margin-top: .35rem; }

.result { margin-top: 1.5rem; }
.result-placeholder {
  color: var(--text-muted);
  font-size: .95rem;
  text-align: center;
  padding: 1.25rem 0;
}

.result-body {
  border-top: 1px dashed var(--border);
  padding-top: 1.4rem;
  animation: fadeUp .35s var(--ease-out);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.result-top { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.result-number { display: flex; align-items: baseline; gap: .4rem; }
.result-value { font-family: var(--display); font-size: 2.6rem; font-weight: 800; line-height: 1; }
.result-unit { color: var(--text-muted); font-size: .95rem; font-weight: 600; }
.result-badge {
  padding: .4rem .85rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: .88rem;
  color: #fff;
  background: var(--text-muted);
  white-space: nowrap;
}
.result-badge[data-cat="under"] { background: var(--cat-under); }
.result-badge[data-cat="normal"] { background: var(--cat-normal); }
.result-badge[data-cat="over"] { background: var(--cat-over); }
.result-badge[data-cat="obese"] { background: var(--cat-obese); }

/* Gauge */
.gauge { margin-top: 1.5rem; }
.gauge-track {
  position: relative;
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: visible;
}
.gauge-seg { height: 100%; }
.gauge-seg:first-child { border-top-left-radius: 999px; border-bottom-left-radius: 999px; }
.gauge-seg:last-child { border-top-right-radius: 999px; border-bottom-right-radius: 999px; }
.gauge-under { flex-basis: 14%; background: var(--cat-under); }
.gauge-normal { flex-basis: 26%; background: var(--cat-normal); }
.gauge-over { flex-basis: 20%; background: var(--cat-over); }
.gauge-obese { flex-basis: 40%; background: var(--cat-obese); }

.gauge-marker {
  position: absolute;
  top: -9px;
  left: 0%;
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 10px solid var(--text);
  transform: translateX(-50%);
  transition: left .3s var(--ease-out);
}

.gauge-scale {
  position: relative;
  height: 1rem;
  margin-top: .3rem;
  font-size: .72rem;
  color: var(--text-muted);
}
.gauge-scale span {
  position: absolute;
  transform: translateX(-50%);
}
.gauge-scale span:first-child { transform: translateX(0); }
.gauge-scale span:last-child { transform: translateX(-100%); }

.gauge-legend {
  display: flex; flex-wrap: wrap; gap: .9rem;
  margin-top: .85rem;
  font-size: .78rem;
  color: var(--text-muted);
}
.gauge-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; }
.dot-under { background: var(--cat-under); }
.dot-normal { background: var(--cat-normal); }
.dot-over { background: var(--cat-over); }
.dot-obese { background: var(--cat-obese); }

.result-recommendation {
  margin-top: 1.25rem;
  font-size: .95rem;
  line-height: 1.55;
}
.result-ideal {
  margin-top: .6rem;
  font-size: .85rem;
  color: var(--text-muted);
}

.privacy-badge {
  margin-top: 1.1rem;
  font-size: .82rem;
  color: var(--text-muted);
}
.noscript-note {
  margin-top: 1rem;
  padding: .85rem 1rem;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .9rem;
}

@media (max-width: 539px) {
  .imc-form { grid-template-columns: 1fr; }
  .tool-card { padding: 1.25rem; }
}

/* =============================================================
   6. Ad slots
   ============================================================= */
.ad-slot {
  min-height: 90px;
  margin-block: 2rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: .78rem;
}
.ad-label { text-transform: uppercase; letter-spacing: .08em; }

/* =============================================================
   7. How it works
   ============================================================= */
.how { padding-block: 1.5rem; }
.how h2 { text-align: center; font-size: 1.5rem; margin-bottom: 1.75rem; }
.how-steps {
  list-style: none;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(3, 1fr);
}
.how-steps li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.25rem;
}
.how-steps svg { color: var(--accent); margin-bottom: .75rem; }
.how-steps h3 { font-size: 1.02rem; margin-bottom: .4rem; }
.how-steps p { font-size: .88rem; color: var(--text-muted); }
@media (max-width: 719px) {
  .how-steps { grid-template-columns: 1fr; }
}

/* =============================================================
   8. SEO text
   ============================================================= */
.seo-text { padding-block: 1.5rem; }
.seo-text h2 { font-size: 1.5rem; margin-bottom: 1rem; }
.seo-text h3 { font-size: 1.12rem; margin-top: 1.6rem; margin-bottom: .55rem; }
.seo-text p { margin-bottom: .9rem; color: var(--text-muted); }
.seo-text p:last-child { margin-bottom: 0; }
.formula {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: .8rem 1rem;
  display: inline-block;
}

/* =============================================================
   9. Table
   ============================================================= */
.table-section { padding-block: 1.5rem; }
.table-section h2 { font-size: 1.5rem; margin-bottom: 1.25rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
thead th {
  text-align: left;
  background: var(--surface-2);
  padding: .75rem 1rem;
  font-weight: 700;
}
tbody td { padding: .7rem 1rem; border-top: 1px solid var(--border); color: var(--text-muted); }
tbody tr.row-normal td { color: var(--text); font-weight: 700; background: var(--accent-soft); }
.table-note { margin-top: .9rem; font-size: .82rem; color: var(--text-muted); }
.table-source { margin-top: .4rem; font-size: .82rem; color: var(--text-muted); }

/* Inline citation links inside prose (SEO text, table sources, FAQ) */
.seo-text a,
.table-source a,
.faq a {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
}
.seo-text a:hover,
.table-source a:hover,
.faq a:hover { color: var(--accent); }

/* =============================================================
   10. FAQ
   ============================================================= */
.faq { padding-block: 1.5rem; }
.faq h2 { font-size: 1.5rem; margin-bottom: 1.25rem; }
.faq details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0;
  margin-bottom: .7rem;
  background: var(--surface);
  overflow: hidden;
}
.faq summary {
  cursor: pointer;
  list-style: none;
  padding: .95rem 1.1rem;
  font-weight: 600;
  font-size: .96rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  font-size: 1.3rem;
  color: var(--accent);
  flex-shrink: 0;
  transition: transform .2s var(--ease-out);
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p {
  padding: 0 1.1rem 1.05rem;
  color: var(--text-muted);
  font-size: .92rem;
  line-height: 1.6;
}

/* =============================================================
   11. Disclaimer & footer
   ============================================================= */
.medical-disclaimer {
  padding-block: .5rem 2rem;
  font-size: .78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 1rem;
}
.footer-inner {
  padding-block: 1.5rem;
  display: flex; flex-wrap: wrap; gap: 1rem;
  align-items: center; justify-content: space-between;
  font-size: .82rem;
  color: var(--text-muted);
}
.footer-nav { display: flex; gap: 1.1rem; }
.footer-nav a:hover { color: var(--accent); }

/* =============================================================
   12. Responsive
   ============================================================= */
@media (min-width: 720px) {
  .container { max-width: 860px; }
}
@media (min-width: 960px) {
  .container { max-width: 920px; }
}
