/* Body composition card on the Labs tab (static/body-comp.js). Page tokens only (--ink, --line, --surface, --accent...),
   so it follows whatever theme the dashboard sets. Mobile first; wide rows wrap as whole items, nothing scrolls the page. */
#bodycomp-card[hidden] { display: none; }
.bc-head { flex-wrap: wrap; row-gap: 6px; }
.bc-titles { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; flex: 1 1 200px; min-width: 0; }
.bc-titles h2 { margin: 0; }
.bc-head .pill { flex: none; }
.bc-demo { background: var(--warn-soft); color: var(--warn); font-weight: 600; }

.bc-scans { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.bc-scan { flex: none; white-space: nowrap; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 6px 12px; min-height: 36px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.bc-scan:hover { border-color: var(--rapha-accent-line); }
.bc-scan[aria-pressed=true] { background: var(--accent-soft); border-color: var(--rapha-accent-line); color: var(--accent); }
.bc-scan:focus-visible, .bc-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.bc-note { margin: 0 0 12px; font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }
.bc-h { margin: 18px 0 8px; font-size: 13px; font-weight: 700; color: var(--ink); }
.bc-sub { margin: 8px 0 0; line-height: 1.5; }
.bc-sub a { color: var(--accent); font-weight: 600; }

/* Headline tiles */
.bc-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.bc-tile { position: relative; display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--ink); }
.bc-tile.has-btn { cursor: pointer; }
.bc-tile.has-btn:hover { border-color: var(--rapha-accent-line); background: var(--accent-soft); }
.bc-tile:has(.bc-tile-btn:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.bc-tile-name { font-size: 12px; color: var(--ink-3); line-height: 1.3; }
.bc-tile-btn { all: unset; font-size: 12px; color: var(--ink-3); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.bc-tile-btn::after { content: ""; position: absolute; inset: 0; border-radius: 12px; }
.bc-tile-val { font-size: 20px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.bc-tile-ch { font-size: 12px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.bc-tile-flag { font-size: 11.5px; font-weight: 600; color: var(--high); }

/* Trend small multiples */
.bc-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.bc-chart { display: flex; flex-direction: column; margin: 0; min-width: 0; padding: 10px 10px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.bc-chart figcaption { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 2px 8px; margin-bottom: 4px; }
.bc-chart-name { font-size: 13px; font-weight: 600; flex: 1 1 auto; min-width: 0; }
.bc-more { white-space: nowrap; margin-left: auto; }
.bc-chart svg { display: block; width: 100%; height: auto; margin-top: auto; }
.bc-one { margin-top: 2px; text-align: center; }
.bc-grid { stroke: var(--line); stroke-width: 1; }
.bc-axis { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.bc-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.bc-pt { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.bc-pt.on { fill: var(--accent); stroke: var(--rapha-accent-line); stroke-width: 3; }
.bc-nc { fill: var(--surface); stroke: var(--ink-2); stroke-width: 1.6; stroke-dasharray: 2.5 1.5; }
.bc-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 8px 0 0; font-size: 12px; color: var(--ink-2); }
.bc-lg { display: inline-flex; align-items: center; gap: 6px; }
.bc-lg svg { flex: none; overflow: visible; }
.bc-guard { margin: 6px 0 0; line-height: 1.5; }

/* Regional / segmental bars */
.bc-bars { display: grid; gap: 10px; margin-top: 8px; }
.bc-row { display: grid; gap: 3px; min-width: 0; }
.bc-row-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; font-size: 13px; }
.bc-row-top span { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.bc-bar { display: flex; height: 14px; border-radius: 4px; background: var(--surface-2); }
.bc-bar span { display: block; height: 100%; min-width: 2px; }
.bc-bar span:first-child { border-radius: 4px 0 0 4px; }
.bc-bar span:last-child { border-radius: 0 4px 4px 0; }
.bc-bar span:only-child { border-radius: 4px; }
.bc-fat { background: repeating-linear-gradient(135deg, var(--rapha-accent-line) 0 4px, var(--accent-soft) 4px 7px); }
.bc-lean { background: var(--accent); }
.bc-sw { display: inline-block; width: 14px; height: 10px; border-radius: 3px; }
.bc-row-kg { font-variant-numeric: tabular-nums; }

/* Bone density: WHO T-score gauge */
.bc-sites { display: grid; gap: 16px; }
.bc-site { min-width: 0; }
.bc-site-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; font-size: 13px; margin-bottom: 26px; }
.bc-band { flex: none; white-space: nowrap; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.bc-band.normal { background: var(--ok-soft); color: var(--ok); }
.bc-band.osteopenia { background: var(--warn-soft); color: var(--warn); }
.bc-band.osteoporosis { background: var(--high-soft); color: var(--high); }
.bc-gauge { position: relative; }
.bc-zones { display: flex; height: 24px; border-radius: 6px; overflow: hidden; }
.bc-z { display: flex; align-items: center; justify-content: center; min-width: 0; padding: 0 4px; font-size: 11px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .75; }
.bc-z + .bc-z { border-left: 2px solid var(--surface); }
.bc-z.on { opacity: 1; }
.bc-z.normal { background: var(--ok-soft); color: var(--ok); }
.bc-z.osteopenia { background: var(--warn-soft); color: var(--warn); }
.bc-z.osteoporosis { background: var(--high-soft); color: var(--high); }
.bc-mark { position: absolute; top: -6px; bottom: -6px; width: 0; border-left: 3px solid var(--ink); margin-left: -1.5px; }
.bc-mark b { position: absolute; bottom: 100%; margin-bottom: 2px; font-size: 12px; white-space: nowrap; color: var(--ink); transform: translateX(-50%); }
.bc-mark.left b { transform: none; left: -2px; }
.bc-mark.right b { transform: translateX(-100%); left: 2px; }
.bc-ticks { position: relative; height: 18px; margin-top: 4px; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.bc-ticks span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.bc-ticks span.l { transform: none; }
.bc-ticks span.r { transform: translateX(-100%); }
.bc-site-vals { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.bc-site-vals b { color: var(--ink); }

.bc-foot { display: grid; gap: 2px; margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--line); line-height: 1.5; }
.bc-foot b { color: var(--ink-2); }

/* Tablet and up: bars go on one line (name, bar, kg) */
@media (min-width: 641px) {
  .bc-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bc-row { grid-template-columns: minmax(130px, 170px) minmax(0, 1fr) minmax(150px, auto); align-items: center; column-gap: 14px; }
  .bc-row-kg { text-align: right; }
  .bc-sites { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); column-gap: 24px; }
}
@media (max-width: 640px) {
  .bc-scan { min-height: 44px; font-size: 13.5px; }
  .bc-tile-val { font-size: 19px; }
  .bc-more { min-height: 44px; display: inline-flex; align-items: center; }
  .bc-z { font-size: 10.5px; padding: 0 2px; }
}
