*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #10b981;
  --green-dark: #059669;
  --green-light: #d1fae5;
  --bg: #f0fdf4;
  --card: #ffffff;
  --border: #d1fae5;
  --text: #064e3b;
  --muted: #6b7280;
  --radius: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

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

/* ── NAV ── */
nav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(16,185,129,0.08);
}

.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 52px; }
.nav-logo { font-weight: 800; font-size: 1rem; color: var(--green-dark); text-decoration: none; letter-spacing: -0.3px; }
.nav-links { display: flex; gap: 4px; }
.nav-links a { text-decoration: none; color: var(--muted); font-size: 0.875rem; font-weight: 500; padding: 6px 12px; border-radius: 8px; transition: background 0.15s, color 0.15s; }
.nav-links a:hover { background: var(--green-light); color: var(--green-dark); }
.nav-links a.active { background: var(--green-light); color: var(--green-dark); font-weight: 600; }

/* ── HEADER ── */
header {
  background: linear-gradient(135deg, #064e3b 0%, #059669 55%, #34d399 100%);
  color: white;
  padding: 48px 0 40px;
}

.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.header-text h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 800; letter-spacing: -0.5px; }
.tagline { margin-top: 10px; font-size: 1rem; opacity: 0.85; max-width: 500px; }

.header-badge { flex-shrink: 0; }
.badge-ring {
  width: 96px; height: 96px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.12);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.badge-label { font-size: 1.4rem; font-weight: 900; color: #fff; line-height: 1; }
.badge-sub { font-size: 0.65rem; color: rgba(255,255,255,0.75); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 2px; }

/* ── LAYOUT ── */
.layout { display: grid; grid-template-columns: 1fr 300px; gap: 24px; padding-top: 28px; padding-bottom: 48px; align-items: start; }
.calc-section { display: flex; flex-direction: column; gap: 20px; }

/* ── CARDS ── */
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: 0 2px 8px rgba(16,185,129,0.06); transition: box-shadow 0.2s; }
.card:hover { box-shadow: 0 4px 16px rgba(16,185,129,0.1); }
.card h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 20px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.card h2::before { content: ''; display: inline-block; width: 4px; height: 1.1em; background: var(--green); border-radius: 2px; flex-shrink: 0; }

.sidebar-tip h3 { font-size: 0.95rem; font-weight: 700; color: var(--green-dark); margin-bottom: 8px; }
.sidebar-tip p { font-size: 0.85rem; color: var(--muted); line-height: 1.6; }

/* ── UNIT TOGGLE ── */
.unit-toggle { display: flex; gap: 0; margin-bottom: 20px; border: 1.5px solid var(--border); border-radius: 10px; overflow: hidden; }
.unit-btn { flex: 1; padding: 10px; border: none; background: #fff; color: var(--muted); font-size: 0.875rem; font-weight: 600; cursor: pointer; transition: background 0.15s, color 0.15s; }
.unit-btn.active { background: var(--green); color: #fff; }
.unit-btn:not(.active):hover { background: var(--green-light); }

/* ── FORM ── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }

input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  color: var(--text);
  background: #f0fdf4;
  transition: border-color 0.15s, box-shadow 0.15s;
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
input:focus { outline: none; border-color: var(--green); background: #fff; box-shadow: 0 0 0 3px rgba(16,185,129,0.12); }

select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  color: var(--text);
  background: #f0fdf4;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}
select:focus { outline: none; border-color: var(--green); background-color: #fff; box-shadow: 0 0 0 3px rgba(16,185,129,0.12); }

button#calcBtn {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
  box-shadow: 0 4px 14px rgba(16,185,129,0.35);
  transition: box-shadow 0.15s, transform 0.1s;
}
button#calcBtn:hover { box-shadow: 0 6px 20px rgba(16,185,129,0.45); }
button#calcBtn:active { transform: scale(0.98); }

/* ── RESULT ── */
.result { margin-top: 20px; padding: 24px; border-radius: 14px; text-align: center; animation: fadeIn 0.25s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.result.underweight { background: #eff6ff; border: 1.5px solid #93c5fd; color: #1d4ed8; }
.result.normal      { background: #f0fdf4; border: 1.5px solid #6ee7b7; color: #065f46; }
.result.overweight  { background: #fff7ed; border: 1.5px solid #fdba74; color: #c2410c; }
.result.obese       { background: #fef2f2; border: 1.5px solid #fca5a5; color: #b91c1c; }
.result.error       { background: #fef2f2; border: 1.5px solid #fca5a5; color: #b91c1c; }

.result .bmi-score { font-size: 4rem; font-weight: 900; display: block; line-height: 1; letter-spacing: -2px; }
.result .bmi-category { font-size: 1.2rem; font-weight: 700; display: block; margin-top: 4px; }
.result .bmi-detail { font-size: 0.9rem; margin-top: 8px; opacity: 0.85; display: block; }
.result .bmi-ideal { font-size: 0.875rem; margin-top: 10px; padding-top: 10px; border-top: 1px solid currentColor; opacity: 0.7; display: block; }
.result .label { font-size: 0.95rem; }

/* ── BMI SCALE ── */
.scale-bar { display: flex; border-radius: 10px; overflow: hidden; height: 56px; }
.scale-seg { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 600; padding: 4px; text-align: center; }
.scale-seg span { font-size: 0.8rem; font-weight: 700; }
.scale-seg small { font-size: 0.7rem; opacity: 0.85; }
.scale-seg.underweight { background: #bfdbfe; color: #1e40af; }
.scale-seg.normal      { background: #6ee7b7; color: #065f46; }
.scale-seg.overweight  { background: #fcd34d; color: #92400e; }
.scale-seg.obese       { background: #fca5a5; color: #991b1b; }

/* ── FORMULA ── */
.formula { background: #f0fdf4; border-left: 4px solid var(--green); border-radius: 6px; padding: 12px 16px; font-family: 'Courier New', monospace; font-size: 0.875rem; margin: 10px 0; color: var(--text); }
.explainer p { font-size: 0.93rem; color: var(--muted); margin-bottom: 8px; }

/* ── TABLE ── */
.grade-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.grade-table th { background: #f0fdf4; padding: 9px 12px; text-align: left; font-weight: 600; border-bottom: 1px solid var(--border); color: var(--text); }
.grade-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--muted); }
.grade-table tr:last-child td { border-bottom: none; }
.grade-table tr:hover td { background: #f0fdf4; }

/* ── INTRO BLURB ── */
.intro-blurb { border-left: 4px solid var(--green); background: var(--green-light); }
.intro-blurb p { font-size: 0.95rem; color: #065f46; line-height: 1.7; }
.intro-blurb p strong { color: var(--green-dark); }

/* ── FAQ ── */
.faq details { border-bottom: 1px solid var(--border); padding: 13px 0; }
.faq details:last-child { border-bottom: none; }
.faq summary { font-weight: 600; cursor: pointer; font-size: 0.93rem; list-style: none; display: flex; justify-content: space-between; align-items: center; color: var(--text); user-select: none; }
.faq summary::after { content: '+'; font-size: 1.3rem; color: var(--green); flex-shrink: 0; margin-left: 12px; }
.faq details[open] summary::after { content: '−'; }
.faq details p { margin-top: 10px; font-size: 0.88rem; color: var(--muted); line-height: 1.65; }

/* ── ADS ── */
.ad-banner { width: 100%; text-align: center; }
.ad-placeholder { background: #d1fae5; color: #6b7280; font-size: 0.7rem; display: flex; align-items: center; justify-content: center; border-radius: 8px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 500; }
.ad-top .ad-placeholder    { height: 90px; }
.ad-bottom .ad-placeholder { height: 90px; }
.ad-inline .ad-placeholder { height: 100px; margin-top: 20px; }
.ad-sidebar .ad-placeholder { height: 250px; }
.ad-top    { padding: 8px 0; background: #fff; border-bottom: 1px solid var(--border); }
.ad-bottom { padding: 8px 0; background: #fff; border-top: 1px solid var(--border); }
.sticky-ad { position: sticky; top: 20px; }

/* ── SIDEBAR ── */
.sidebar { display: flex; flex-direction: column; gap: 20px; }

/* ── FOOTER ── */
footer { background: #064e3b; color: #6ee7b7; text-align: center; padding: 24px 0; font-size: 0.83rem; }
footer a { color: #a7f3d0; text-decoration: none; }
footer a:hover { color: #fff; }
.disclaimer { margin-top: 6px; font-size: 0.75rem; opacity: 0.6; }

/* ── HIDDEN ── */
.hidden { display: none !important; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .card { padding: 20px; }
  .header-badge { display: none; }
  .form-row { grid-template-columns: 1fr; }
}
