:root {
  --bg: #ffffff;
  --bg-soft: #f6f8fa;
  --ink: #1a1a1a;
  --ink-soft: #383d44;
  --brand: #0a7c5a;
  --brand-dark: #075c43;
  --brand-tint: #e8f5ef;
  --border: #e2e6ea;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 6px 24px rgba(0, 0, 0, .04);
  --chart-grid: #e2e6ea;
}
:root[data-theme="dark"] {
  --bg: #0f1418;
  --bg-soft: #161c22;
  --ink: #f3f5f7;
  --ink-soft: #c2c9d1;
  --brand: #2bd693;
  --brand-dark: #4fe0a4;
  --brand-tint: #102a22;
  --border: #2c3742;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --chart-grid: #232c34;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
:root[data-theme="dark"] .site-header { background: rgba(15, 20, 24, .92); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; }
.logo { font-weight: 700; font-size: 20px; color: var(--ink); letter-spacing: -.01em; }
.logo span { color: var(--brand); }
.header-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.nav-toggle { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; color: var(--ink); cursor: pointer; }
.currency-switch select {
  font-size: 14px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: #1a1a1a; cursor: pointer; max-width: 150px;
}
:root[data-theme="dark"] .currency-switch select,
:root[data-theme="dark"] .currency-switch select option { background: #161c22; color: #f3f5f7; }
.currency-switch select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
@media (max-width: 600px) {
  .currency-switch select { max-width: 110px; font-size: 13px; }
}

.hero { padding: 48px 0 24px; text-align: center; }
.hero h1 { font-size: clamp(28px, 5vw, 44px); margin: 0 0 .4em; letter-spacing: -.02em; }
.lead { font-size: clamp(16px, 2.4vw, 20px); color: var(--ink-soft); max-width: 720px; margin: 0 auto; }

.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  padding: 24px 0 8px;
}
.card {
  display: block; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--brand); text-decoration: none; }
.card h2 { font-size: 19px; margin: 0 0 8px; color: var(--ink); }
.card p { margin: 0 0 14px; color: var(--ink-soft); font-size: 15px; }
.card-link { color: var(--brand-dark); font-weight: 600; font-size: 14px; }

.content { padding: 32px 0 24px; max-width: 760px; }
.content h2 { font-size: 26px; margin-top: 1.6em; }
.content h3 { font-size: 19px; margin-top: 1.6em; margin-bottom: .3em; }
.content p { color: var(--ink-soft); }

/* Calculator page */
.calc-page { padding: 28px 0 40px; }
.calc { max-width: 720px; margin: 0 auto; }
.calc h1 { font-size: clamp(24px, 4vw, 34px); margin: 0 0 6px; letter-spacing: -.01em; }
.calc .desc { color: var(--ink-soft); margin: 0 0 22px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 12px 14px; font-size: 16px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; color: #1a1a1a;
}
:root[data-theme="dark"] .field input, :root[data-theme="dark"] .field select { background: #161c22; color: #f3f5f7; }
.field input::placeholder { color: #8a929b; }
.field input:focus, .field select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }

.btn {
  display: inline-block; background: var(--brand); color: #fff; border: none;
  padding: 13px 22px; font-size: 16px; font-weight: 600; border-radius: 10px; cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: translateY(1px); }

.result {
  margin-top: 24px; padding: 20px; background: var(--brand-tint);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.result h2 { margin: 0 0 8px; font-size: 18px; color: var(--brand-dark); }
.result .big { font-size: 30px; font-weight: 700; color: var(--ink); }
.result .big .unit, .result .sub .unit { font-size: 16px; font-weight: 600; color: var(--ink-soft); }
.result .sub { font-size: 18px; font-weight: 600; color: var(--brand-dark); margin-top: 2px; }
.result table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.result td, .result th { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); font-size: 15px; }
.result th { color: var(--ink-soft); font-weight: 600; }
.result td:last-child, .result th:last-child { text-align: right; font-variant-numeric: tabular-nums; }

.schedule { margin-top: 18px; max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
.schedule table { width: 100%; border-collapse: collapse; }
.schedule th, .schedule td { padding: 8px 12px; font-size: 14px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.schedule th { background: var(--bg-soft); position: sticky; top: 0; text-align: left; }
.schedule td:last-child, .schedule th:last-child { text-align: right; }

.back { display: inline-block; margin-bottom: 16px; font-size: 14px; }

.site-footer { margin-top: 40px; border-top: 1px solid var(--border); padding: 24px 0; color: var(--ink-soft); font-size: 14px; }

@media (max-width: 600px) {
  .hero { padding: 32px 0 16px; }
  .calc-page { padding: 16px 0 32px; }
}

/* ---- theme toggle ---- */
.theme-toggle { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; cursor: pointer; color: var(--ink); font-size: 14px; line-height: 1; display: inline-flex; align-items: center; gap: 6px; }
.theme-toggle:hover { border-color: var(--brand); }

/* ---- nav drawer ---- */
.nav-drawer { position: fixed; inset: 0 0 0 auto; width: min(80vw, 320px); background: var(--bg); border-left: 1px solid var(--border); transform: translateX(100%); transition: transform .22s ease; z-index: 50; padding: 60px 22px 22px; overflow-y: auto; box-shadow: -10px 0 40px rgba(0,0,0,.08); }
body.nav-open .nav-drawer { transform: none; }
.nav-drawer a { display: block; padding: 11px 6px; color: var(--ink); border-bottom: 1px solid var(--border); font-size: 16px; }
.nav-drawer a:hover { color: var(--brand); }
.nav-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .22s; z-index: 40; }
body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
.nav-close { position: absolute; top: 14px; right: 16px; background: none; border: none; font-size: 22px; color: var(--ink-soft); cursor: pointer; }

/* ---- breadcrumbs ---- */
.breadcrumbs { font-size: 13px; color: var(--ink-soft); padding: 14px 0 0; }
.breadcrumbs a { color: var(--ink-soft); }
.breadcrumbs span { margin: 0 7px; opacity: .5; }

/* ---- chart blocks ---- */
.chart-block { margin-top: 20px; padding: 14px 14px 6px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); }
.chart-title { font-size: 14px; font-weight: 600; color: var(--ink-soft); margin: 0 0 8px; }
.chart-mount { width: 100%; }
.chart-mount svg { max-width: 100%; height: auto; display: block; }
.muted { color: var(--ink-soft); font-size: 13px; }

/* ---- result sub-label / caption / note ---- */
.result .sub-label { display: block; font-size: 13px; font-weight: 400; color: var(--ink-soft); margin-top: 2px; }
.result .caption { margin: 4px 0 12px; color: var(--ink-soft); font-size: 15px; }
.result .note { background: #fff8e1; border: 1px solid #ffe69b; color: #7a5b00; padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-top: 8px; }
:root[data-theme="dark"] .result .note { background: #2a2400; border-color: #4a3d00; color: #ffd970; }
:root[data-theme="dark"] .result { background: var(--brand-tint); border-color: var(--border); }

/* ---- form actions / buttons ---- */
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--border); padding: 11px 16px; font-size: 15px; font-weight: 600; border-radius: 10px; cursor: pointer; }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand-dark); }

/* ---- segmented / frequency toggle ---- */
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented label { padding: 10px 16px; font-size: 15px; cursor: pointer; color: var(--ink-soft); }
.segmented input:checked + label { background: var(--brand); color: #fff; }

/* ---- toast ---- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); opacity: 0; transition: opacity .25s, transform .25s; z-index: 100; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- radio rows (BMI/calorie units, sex) ---- */
.radio-row { display: flex; gap: 16px; }
.radio-row label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; font-size: 15px; cursor: pointer; }

/* ---- live indicator ---- */
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); margin-right: 6px; box-shadow: 0 0 0 0 rgba(43,214,147,.5); animation: pulse 1.6s infinite; vertical-align: middle; }
@keyframes pulse { 0%{ box-shadow:0 0 0 0 rgba(43,214,147,.4);} 70%{ box-shadow:0 0 0 8px rgba(43,214,147,0);} 100%{ box-shadow:0 0 0 0 rgba(43,214,147,0);} }

/* ---- print ---- */
@media print {
  .site-header, .nav-drawer, .nav-backdrop, .nav-toggle, .back, .currency-switch, .theme-toggle, .form-actions, .content { display: none !important; }
  .result { border-color: #ccc; }
}

@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* ---- affiliate disclosure + ad slots ---- */
.affil-disclosure {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; color: var(--ink-soft); padding: 9px 12px; margin: 14px 0;
}
.affil-disclosure::before { content: "Affiliate disclosure — "; font-weight: 600; color: var(--ink); }

.ad-slot {
  margin: 18px 0; min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-soft); border: 1px dashed var(--border); border-radius: 10px;
  color: var(--ink-soft); font-size: 13px;
}
.ad-slot::before { content: "Ad"; font-weight: 600; opacity: .4; }
.ad-slot[data-filled="true"] { background: transparent; border: 0; min-height: 0; }
.ad-slot[data-filled="true"]::before { content: ""; }

/* ---- footer links ---- */
.footer-links { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; }
.footer-links a { color: var(--ink-soft); font-size: 14px; }
.footer-links a:hover { color: var(--brand-dark); text-decoration: underline; }

/* ---- legal/info pages ---- */
.legal { max-width: 760px; }
.legal h1 { font-size: 28px; margin-bottom: 8px; }
.legal h2 { font-size: 20px; margin-top: 1.6em; margin-bottom: 8px; color: var(--ink); }
.legal p, .legal ul { color: var(--ink-soft); }
.legal ul { padding-left: 1.2em; }
.legal ul li { margin-bottom: 6px; }
.legal code { background: var(--bg-soft); padding: 2px 6px; border-radius: 4px; font-size: 14px; }
.legal-muted { font-size: 13px; font-style: italic; opacity: .75; margin-top: 1.6em; }
.affil-link-line { font-size: 15px; color: var(--ink-soft); margin-top: 14px; padding: 12px 14px; background: var(--brand-tint); border-radius: 10px; }
.affil-link-line a { color: var(--brand-dark); font-weight: 600; }

/* ---- article pages ---- */
.article { max-width: 720px; }
.article h1 { font-size: clamp(26px, 4vw, 34px); margin-bottom: 8px; line-height: 1.25; }
.article-lead { font-size: 18px; color: var(--ink-soft); margin-top: 6px; }
.article-byline { font-size: 13px; color: var(--ink-soft); opacity: .8; margin-bottom: 16px; }
.article h2 { font-size: 22px; margin-top: 1.8em; margin-bottom: 10px; }
.article h3 { font-size: 18px; margin-top: 1.4em; margin-bottom: 6px; }
.article p { color: var(--ink-soft); }
.article .example { background: var(--brand-tint); border-radius: 10px; padding: 14px 16px; }
.article .btn { margin: 8px 0; }