/* VitalCalc — "health dashboard": warm paper + sage/green accent, gauge & bar
   visuals for ranges. Light default; dark via prefers-color-scheme. RTL aware. */

:root {
  /* light (warm paper) */
  --bg: #f7f5ef;
  --bg-2: #ece9df;
  --panel: #ffffff;
  --panel-2: #f2efe6;
  --line: #ddd6c4;
  --line-strong: #bdb39c;
  --ink: #1f2a23;
  --ink-soft: #56635a;
  --ink-faint: #8a948b;
  --accent: #2f9e6f;          /* sage/health green */
  --accent-deep: #1f7a55;
  --accent-soft: rgba(47, 158, 111, 0.13);
  --accent-glow: rgba(47, 158, 111, 0.26);
  /* range band colors (BMI / risk) */
  --band-low: #5b9bd5;        /* underweight / low risk */
  --band-ok: #2f9e6f;         /* normal / healthy */
  --band-warn: #d8a13a;       /* over / moderate */
  --band-high: #d96650;       /* obese / high */
  --band-extreme: #b0413e;    /* severe */
  --err: #c0392b;
  --radius: 14px;
  --radius-sm: 10px;
  --mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
  --display: "Inter", "Apple SD Gothic Neo", sans-serif;
}
/* ===== 3-way theme (Light/Dark/System) — base :root above = native LIGHT. Opposite (dark) WCAG-aware auto-generated (contrast-solving ink/accent vs worst-case surface). ===== */
:root[data-theme="dark"]{
  --bg: #1e1c15;
  --bg-2: #090806;
  --panel: #303030;
  --panel-2: #0f0e0b;
  --line: rgba(255,255,255,0.12);
  --line-strong: rgba(255,255,255,0.12);
  --ink: #afc4b7;
  --ink-soft: #8f9d93;
  --ink-faint: #757f76;
  --accent: #2e996c;
  --accent-deep: #279a6b;
  --accent-soft: #2e996c;
  --accent-glow: rgba(0,0,0,0.40);
  --band-low: #438ccf;
  --band-ok: #2e996c;
  --band-warn: #b07f23;
  --band-high: #d9644e;
  --band-extreme: #ca6c6a;
  --err: #d96357;
}












@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1714;
    --bg-2: #131e1a;
    --panel: #18241f;
    --panel-2: #1d2c26;
    --line: #2b3a32;
    --line-strong: #3c4f44;
    --ink: #e6f0ea;
    --ink-soft: #9fb2a7;
    --ink-faint: #6c7c72;
    --accent: #4fd193;          /* lighter sage for dark */
    --accent-deep: #6fe0a8;
    --accent-soft: rgba(79, 209, 147, 0.15);
    --accent-glow: rgba(79, 209, 147, 0.34);
    --band-low: #6fb3e8;
    --band-ok: #4fd193;
    --band-warn: #e8b65a;
    --band-high: #e87a64;
    --band-extreme: #d65651;
    --err: #f47067;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; } /* 명시적 display가 [hidden]을 무력화하지 않도록 */

html, body {
  background:
    radial-gradient(900px 520px at 88% -8%, var(--accent-soft), transparent 60%),
    radial-gradient(700px 460px at -4% 108%, var(--accent-soft), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
b, h1, h2, h3 { font-weight: 700; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-soft); }

/* i18n switcher theming */
.i18n-switch {
  --i18n-switch-bg: var(--panel-2);
  --i18n-switch-border: var(--line);
  --i18n-switch-fg: var(--ink);
  --i18n-switch-active-bg: var(--accent-soft);
  --i18n-switch-active-fg: var(--accent);
  --i18n-switch-menu-bg: var(--panel);
  --i18n-switch-menu-border: var(--line);
}

/* ── topbar ─────────────────────────────────────────────── */
.topbar {
  max-width: 880px;
  margin: 0 auto;
  padding: 22px clamp(16px, 5vw, 32px) 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 13px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--accent), var(--accent-deep));
  color: #ffffff;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 8px 22px -10px var(--accent-glow);
}
.brand h1 {
  font-family: var(--display);
  font-size: 20px;
  letter-spacing: -.015em;
  line-height: 1.1;
}
.brand p { font-size: 12.5px; color: var(--ink-soft); }
.brand .accent { color: var(--accent); }

.switchers { display: flex; align-items: center; gap: 8px; }

/* small segmented control (unit / sex / formula) */
.seg-sm { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.us-btn {
  border: 0; background: transparent; color: var(--ink-soft);
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  transition: all .12s ease;
}
@media (pointer: coarse) { .us-btn { min-height: 44px; display: inline-flex; align-items: center; } }
.us-btn:hover { color: var(--ink); }
.us-btn.is-on { background: var(--accent); color: #fff; box-shadow: 0 3px 10px -5px var(--accent-glow); }
.us-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── tabs ───────────────────────────────────────────────── */
.tabs {
  position: sticky; top: 0; z-index: 5;
  max-width: 880px; margin: 0 auto; padding: 10px clamp(16px, 5vw, 32px);
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin;
  background: linear-gradient(var(--bg), var(--bg) 70%, transparent);
}
.tabs::-webkit-scrollbar { height: 6px; }
.tabs::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.tab {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink-soft); font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 15px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  transition: all .15s ease;
}
.tab:hover { color: var(--ink); border-color: var(--line-strong); }
.tab.is-active {
  background: var(--accent); color: #ffffff; border-color: var(--accent);
  box-shadow: 0 4px 14px -6px var(--accent-glow);
}
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── wrap / cards ───────────────────────────────────────── */
.wrap { max-width: 880px; margin: 0 auto; padding: 4px clamp(16px, 5vw, 32px) 40px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}

/* ── shared profile ─────────────────────────────────────── */
.profile { padding: 14px 18px; margin-bottom: 14px; }
.profile-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > span { font-size: 13px; color: var(--ink-soft); }
.field em { font-style: normal; color: var(--accent); font-size: 11px; margin-left: 4px; }
.inp {
  display: flex; align-items: center; background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.inp:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inp input {
  width: 100%; min-width: 0; background: transparent; border: 0; color: var(--ink);
  font-family: var(--mono); font-size: 16.5px; font-weight: 600;
  padding: 11px 12px; text-align: right; outline: none; letter-spacing: -.01em;
}
.inp input::-webkit-outer-spin-button,
.inp input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.inp input[type=number] { -moz-appearance: textfield; }
.inp b { color: var(--ink-soft); font-size: 13px; font-weight: 500; margin-right: 10px; white-space: nowrap; }

.check {
  flex-direction: row; align-items: center; gap: 8px; cursor: pointer;
}
.check input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.check span { color: var(--ink-soft); font-size: 13.5px; }

/* inputs card (per-calc extra) */
.inputs { padding: 16px 18px; margin-bottom: 14px; display: grid; gap: 14px; }
.inputs.grid-3 { grid-template-columns: repeat(3, 1fr); }
.checks { display: flex; gap: 16px; flex-wrap: wrap; }

/* big segmented control (activity / goal) — wraps, labelled */
.seg {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.seg-btn {
  flex: 1 1 0; min-width: 92px; display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: var(--bg); border: 1px solid var(--line); color: var(--ink-soft);
  font-family: inherit; font-size: 13.5px; font-weight: 600; padding: 9px 8px; border-radius: 11px; cursor: pointer;
  transition: all .15s ease;
}
.seg-btn small { font-weight: 400; font-size: 10.5px; opacity: .82; }
.seg-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.seg-btn.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap-seg .us-btn { flex: 0 0 auto; }

/* ── output ─────────────────────────────────────────────── */
.output { display: grid; gap: 14px; }
.hero-result {
  background: linear-gradient(150deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 22px;
  display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden;
}
.hero-result::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 170px; height: 170px;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
  pointer-events: none;
}
.hr-label { font-size: 13px; color: var(--ink-soft); }
.hr-value {
  font-family: var(--mono); font-size: clamp(28px, 7vw, 42px); font-weight: 700;
  color: var(--accent); letter-spacing: -.02em; line-height: 1.1;
}
.hr-value .u { font-size: .45em; color: var(--ink-soft); font-weight: 500; margin-left: 6px; }
.hr-sub { font-size: 13px; color: var(--ink-soft); }
.hr-sub .pill {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-weight: 700; font-size: 12.5px; color: #fff; margin-left: 6px;
  background: var(--accent);
}
.hr-sub .pill.is-low { background: var(--band-low); }
.hr-sub .pill.is-ok { background: var(--band-ok); }
.hr-sub .pill.is-warn { background: var(--band-warn); }
.hr-sub .pill.is-high { background: var(--band-high); }
.hr-sub .pill.is-extreme { background: var(--band-extreme); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 3px;
}
.s-label { font-size: 12.5px; color: var(--ink-soft); }
.s-value { font-family: var(--mono); font-size: 18px; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
.s-value .u { font-size: .6em; color: var(--ink-soft); font-weight: 500; margin-left: 4px; }
.s-sub { font-size: 11.5px; color: var(--ink-faint); }

/* breakdown card */
.bd { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.bd-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 13px 18px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.bd-head h3 { font-family: var(--display); font-size: 15px; }
.bd-head .foot { font-size: 11.5px; color: var(--ink-faint); text-align: right; }
.bd-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 18px; font-size: 13.5px;
}
.bd-row + .bd-row { border-top: 1px solid var(--line); }
.bd-row > span:first-child { color: var(--ink-soft); }
.bd-row > span:last-child { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.bd-row.total { background: var(--panel-2); }
.bd-row.total > span:first-child { color: var(--ink); font-weight: 600; }
.bd-row.total > span:last-child { color: var(--accent); }

/* ── BMI / range gauge ──────────────────────────────────── */
.gauge { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.gauge-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.gauge-head .lab { font-size: 12px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .08em; }
.gauge-track {
  position: relative; height: 14px; border-radius: 999px; overflow: hidden;
  display: flex; box-shadow: inset 0 0 0 1px var(--line);
}
.gauge-seg { height: 100%; }
.gauge-seg.s-under { background: var(--band-low); }
.gauge-seg.s-normal { background: var(--band-ok); }
.gauge-seg.s-over { background: var(--band-warn); }
.gauge-seg.s-obese { background: var(--band-high); }
.gauge-seg.s-extreme { background: var(--band-extreme); }
.gauge-needle {
  position: absolute; top: -5px; bottom: -5px; width: 3px; background: var(--ink);
  border-radius: 2px; box-shadow: 0 0 0 3px var(--panel); transform: translateX(-50%);
  transition: left .35s cubic-bezier(.2,.8,.2,1);
}
.gauge-ticks {
  display: flex; justify-content: space-between; margin-top: 6px;
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint);
}
.gauge-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; }
.gauge-legend .li { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); }
.gauge-legend .sw { width: 11px; height: 11px; border-radius: 3px; }

/* macro bar */
.macro-bar { display: flex; height: 22px; border-radius: 8px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.macro-bar .mb-p { background: var(--band-high); }
.macro-bar .mb-c { background: var(--band-warn); }
.macro-bar .mb-f { background: var(--band-low); }

.hint { font-size: 12px; color: var(--ink-soft); margin-top: -4px; line-height: 1.5; }

/* ── ad slots (money-lab pattern) ───────────────────────── */
.ad-slot { display: none; margin: 24px 0; }
.ad-slot.is-live, .ad-slot.is-preview { display: block; }
.ad-label {
  display: block; font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint); opacity: .8; margin-bottom: 5px; text-align: center;
}
.ad-ph {
  display: none; align-items: center; justify-content: center;
  min-height: 90px; padding: 18px; border: 1px dashed var(--line); border-radius: var(--radius-sm);
  background: var(--panel-2); color: var(--ink-faint); font-size: 12px; text-align: center;
}
.ad-slot.is-preview .ad-ph { display: flex; }
.ad-slot.is-preview .adsbygoogle { display: none !important; }
.ad-slot.is-live .ad-ph { display: none; }

/* ── info / FAQ ─────────────────────────────────────────── */
.info { margin-top: 28px; color: var(--ink-soft); font-size: 14px; line-height: 1.7; }
.info h2 { font-size: 15px; color: var(--ink); margin: 22px 0 8px; }
.info > h2:first-child { margin-top: 0; }
.info p { margin-bottom: 8px; }
.info b { color: var(--ink); }
.faq { margin: 4px 0 8px; }
.faq dt { color: var(--ink); font-weight: 600; margin-top: 12px; }
.faq dd { margin: 4px 0 0; }

.disclaimer {
  margin-top: 22px; font-size: 12.5px; color: var(--ink-soft); line-height: 1.65;
  text-align: center; padding: 0 8px;
}
.disclaimer b { color: var(--ink); }

.foot { max-width: 880px; margin: 0 auto; padding: 8px clamp(16px, 5vw, 32px) 80px; text-align: center; }
.foot a { color: var(--ink-faint); font-size: 12px; }
.foot a:hover { color: var(--accent); }

/* ── toast ──────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 500;
  padding: 10px 18px; border-radius: 999px;
  box-shadow: 0 10px 30px -8px rgba(0,0,0,.35);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-err { background: var(--err); color: #fff; }

/* ── RTL ────────────────────────────────────────────────── */
[dir="rtl"] .inp input { text-align: left; }
[dir="rtl"] .inp b { margin-right: 0; margin-left: 10px; }
[dir="rtl"] .hr-value .u { margin-left: 0; margin-right: 6px; }
[dir="rtl"] .field em { margin-left: 0; margin-right: 4px; }

/* ── responsive ─────────────────────────────────────────── */
@media (max-width: 720px) {
  .profile-row { grid-template-columns: repeat(2, 1fr); }
  .inputs.grid-3 { grid-template-columns: 1fr; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .profile-row { grid-template-columns: 1fr; }
  .brand h1 { font-size: 18px; }
  .topbar { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
