/* BMI & Body Fat Calculator — Apple-minimal, self-contained (shares the
   site's token values from app-style.css; tools with their own style.css
   do not get the shared sheet, so the tokens and the classes this page
   uses are duplicated here). */
:root {
  color-scheme: light;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
  --canvas: #f5f5f7;
  --surface: #fff;
  --recessed: #f5f5f7;
  --ink: #1d1d1f;
  --muted: #65656b;
  --line: rgb(0 0 0 / .06);
  --control-line: rgb(0 0 0 / .14);
  --selected: rgb(0 0 0 / .075);
  --accent: #0071e3;
  --accent-hover: #0065cc;
  --accent-ink: #fff;
  --motion: .2s cubic-bezier(.16, 1, .3, 1);
  --under: #5b8def;
  --normal: #1f9d55;
  --over: #d9930d;
  --obese: #d9481c;
  color: var(--ink);
  background: var(--canvas);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #161618;
  --surface: #1e1e20;
  --recessed: #242426;
  --ink: #f5f5f7;
  --muted: #ababaf;
  --line: rgb(255 255 255 / .08);
  --control-line: rgb(255 255 255 / .19);
  --selected: rgb(255 255 255 / .10);
  --accent: #5aaaf9;
  --accent-hover: #7bbaff;
  --accent-ink: #101820;
  --under: #7ba7f5;
  --normal: #4cc38a;
  --over: #e8b23a;
  --obese: #f26d4d;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; transition: background-color var(--motion), color var(--motion); }
main { width: min(560px, calc(100% - 32px)); margin: clamp(32px, 7vw, 80px) auto; }
h1 { font-size: clamp(2.25rem, 5vw, 4rem); font-weight: 600; line-height: 1.12; letter-spacing: -.045em; margin: 16px 0 8px; }
h2 { font-size: 1.25rem; font-weight: 600; margin: 0; }
p { color: var(--muted); margin: 0; }
a { color: var(--ink); text-underline-offset: .2em; }
.subtitle { color: var(--ink); font-size: 1.05rem; font-weight: 500; }
.lede { margin-top: 8px; }
.badges { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; font-size: 14px; }
.badges span { color: var(--muted); }
.panel { display: grid; gap: 24px; margin-block-start: 32px; border: 1px solid var(--line); border-radius: 24px; padding: clamp(16px, 4vw, 32px); background: var(--surface); }
.buttons { display: flex; flex-wrap: wrap; gap: 12px; }
button { display: inline-flex; justify-content: center; align-items: center; background: var(--accent); color: var(--accent-ink); border: 1px solid transparent; border-radius: 8px; min-height: 44px; font: inherit; font-size: 14px; font-weight: 500; padding: 8px 16px; text-decoration: none; cursor: pointer; transition: background-color var(--motion), transform var(--motion); }
button:not(:disabled):hover { background: var(--accent-hover); }
button:not(:disabled):active { transform: scale(.98); }
.secondary { color: var(--ink); background: var(--recessed); }
.secondary:not(:disabled):hover { background: var(--selected); }
.msg { min-height: 1.5em; font-size: 14px; color: var(--obese); }
/* Discreet brand line on every standalone app (Chan, 2026-11-27). */
.brand-line { text-align: center; color: var(--muted); font-size: 12.5px; letter-spacing: .14em; padding: 20px 0 28px; margin: 0; }
.note { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 20px; }

/* ---------- form ---------- */
.form { display: grid; gap: 16px; }
.form > label { display: grid; grid-template-columns: 1fr 140px; align-items: center; gap: 12px; font-size: 15px; color: var(--ink); }
input[type="number"] { font: inherit; font-size: 15px; color: var(--ink); background: var(--recessed); border: 1px solid var(--control-line); border-radius: 8px; padding: 10px 12px; min-height: 44px; width: 100%; text-align: center; }
input[type="number"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
fieldset.sex { border: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 24px; }
fieldset.sex legend { font-size: 15px; color: var(--ink); padding: 0; margin-right: 4px; }
label.radio { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink); cursor: pointer; }
label.radio input[type="radio"] { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }

/* ---------- results ---------- */
.result { gap: 20px; }
.bmi-big { display: flex; align-items: baseline; justify-content: center; gap: 16px; }
.bmi-num { font-size: clamp(3rem, 13vw, 4rem); font-weight: 600; letter-spacing: -.04em; line-height: 1; color: var(--ink); }
.bmi-cat { font-size: 1.25rem; font-weight: 600; padding: 4px 14px; border-radius: 999px; color: #fff; background: var(--muted); }
.bmi-cat[data-cat="under"] { background: var(--under); }
.bmi-cat[data-cat="normal"] { background: var(--normal); }
.bmi-cat[data-cat="over"] { background: var(--over); }
.bmi-cat[data-cat="obese"] { background: var(--obese); }
.scale { position: relative; display: flex; height: 12px; border-radius: 999px; overflow: visible; margin-top: 4px; }
.scale-seg { height: 100%; }
.scale-seg:first-child { border-radius: 999px 0 0 999px; }
.scale-seg:last-child { border-radius: 0 999px 999px 0; }
/* Segment widths = BMI width over the 14-40 display range (total 26). */
.seg-under { flex: 4.5; background: var(--under); }
.seg-normal { flex: 6.5; background: var(--normal); }
.seg-over { flex: 5; background: var(--over); }
.seg-obese { flex: 10; background: var(--obese); }
.scale-marker { position: absolute; top: -5px; width: 4px; height: 22px; margin-left: -2px; background: var(--ink); border-radius: 2px; box-shadow: 0 0 0 2px var(--surface); }
.scale-labels { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 2px; }
.facts { display: grid; gap: 12px; margin: 0; }
.facts > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.facts dt { color: var(--muted); font-size: 15px; }
.facts dd { margin: 0; color: var(--ink); font-size: 15px; }
.facts dd b { font-size: 1.25rem; font-weight: 600; }
.est { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.note-line { font-size: 15px; color: var(--ink); }
@media (max-width: 420px) {
  .form > label { grid-template-columns: 1fr 110px; }
}
