/* iOS-inspired design tokens. Series colors are validated for colour-blind separation
   (lean / fat / bone; light vs white surface, dark vs #1C1C1E). */
:root {
  color-scheme: light;
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --card-2: #F2F2F7;
  --ink: #000000;
  --ink-2: #6C6C70;
  --ink-3: #8E8E93;
  --sep: #E5E5EA;
  --grid: #EEEEF2;
  --track: #E9E9EE;
  --band: rgba(120, 120, 128, .10);
  --band-2: rgba(120, 120, 128, .18);
  --accent: #007AFF;

  --lean: #007AFF;
  --fat: #C25E00;
  --bone: #C93A8C;

  --good: #248A3D;
  --good-bg: rgba(52, 199, 89, .14);
  --warn: #9A6700;
  --warn-bg: rgba(255, 204, 0, .20);
  --bad: #D70015;
  --bad-bg: rgba(255, 59, 48, .12);

  /* category glyph colors, as in the Health app */
  --c-body: #AF52DE;
  --c-heart: #FF2D55;
  --c-sleep: #5856D6;
  --c-activity: #FF9500;
  --c-cycle: #FF375F;
  --c-meds: #30B0C7;
  --c-labs: #007AFF;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000; --card: #1C1C1E; --card-2: #2C2C2E;
    --ink: #FFFFFF; --ink-2: #AEAEB2; --ink-3: #8E8E93;
    --sep: #38383A; --grid: #2A2A2D; --track: #3A3A3C;
    --band: rgba(235, 235, 245, .07); --band-2: rgba(235, 235, 245, .13);
    --accent: #0A84FF;
    --lean: #0A84FF; --fat: #D9730A; --bone: #E05FA8;
    --good: #30D158; --good-bg: rgba(48, 209, 88, .16);
    --warn: #FFD60A; --warn-bg: rgba(255, 214, 10, .16);
    --bad: #FF453A; --bad-bg: rgba(255, 69, 58, .18);
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000; --card: #1C1C1E; --card-2: #2C2C2E;
  --ink: #FFFFFF; --ink-2: #AEAEB2; --ink-3: #8E8E93;
  --sep: #38383A; --grid: #2A2A2D; --track: #3A3A3C;
  --band: rgba(235, 235, 245, .07); --band-2: rgba(235, 235, 245, .13);
  --accent: #0A84FF;
  --lean: #0A84FF; --fat: #D9730A; --bone: #E05FA8;
  --good: #30D158; --good-bg: rgba(48, 209, 88, .16);
  --warn: #FFD60A; --warn-bg: rgba(255, 214, 10, .16);
  --bad: #FF453A; --bad-bg: rgba(255, 69, 58, .18);
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }

/* ---------- header */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  padding: max(14px, env(safe-area-inset-top)) 16px 10px;
  border-bottom: .5px solid transparent;
}
.top.scrolled { border-bottom-color: var(--sep); }
.top-row, .seg, main { max-width: 1120px; margin-left: auto; margin-right: auto; }
.top-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .02em; }
h1 { font-size: 34px; font-weight: 700; letter-spacing: -.02em; margin: 0; line-height: 1.15; }
.top-actions { display: flex; align-items: center; gap: 10px; padding-bottom: 4px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--card);
  display: grid; place-items: center; color: var(--accent); cursor: pointer; box-shadow: var(--shadow);
}
.live { border: 0; background: none; cursor: pointer; padding: 4px 0; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.live.on i { background: var(--good); box-shadow: 0 0 0 0 var(--good); animation: pulse 2.4s infinite; }
.live.flash i { animation: pulse .6s 3; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); } 100% { box-shadow: 0 0 0 8px transparent; } }

.seg {
  margin-top: 12px; display: flex; gap: 2px; padding: 2px; border-radius: 9px;
  background: rgba(118, 118, 128, .12); overflow-x: auto; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: 1 0 auto; border: 0; background: transparent; padding: 6px 12px; border-radius: 7px;
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.seg button.on { background: var(--card); font-weight: 600; box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); }
:root[data-theme="dark"] .seg button.on { background: #636366; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg button.on { background: #636366; } }
.seg.small { margin: 0; display: inline-flex; }
.seg.small button { padding: 4px 10px; font-size: 12px; flex: 0 0 auto; }

/* ---------- layout */
main { padding: 8px 16px calc(40px + env(safe-area-inset-bottom)); }
.section { margin-top: 26px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 4px 10px; }
.section-head h2 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.section-head .aside { font-size: 13px; color: var(--ink-2); }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }

.card {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px 16px; box-shadow: var(--shadow);
  min-width: 0; position: relative;
}
.card.tap { cursor: pointer; transition: transform .12s ease; }
.card.tap:active { transform: scale(.985); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.cat { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.cat svg { width: 16px; height: 16px; flex: none; }
.when { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.chev::after { content: "›"; margin-left: 6px; font-size: 18px; line-height: 0; color: var(--ink-3); }

.big { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.big .v { font-size: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.big .u { font-size: 15px; font-weight: 600; color: var(--ink-2); }
.big.xl .v { font-size: 44px; }
.sub { font-size: 13px; color: var(--ink-2); }
.muted { color: var(--ink-3); }
.delta { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.good { color: var(--good); } .delta.bad { color: var(--bad); } .delta.flat { color: var(--ink-2); }

.title { font-size: 17px; font-weight: 600; margin: 0 0 2px; }
.desc { font-size: 13px; color: var(--ink-2); margin: 0 0 10px; }

/* ---------- pills */
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill.good { color: var(--good); background: var(--good-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }
.pill.neutral { color: var(--ink-2); background: var(--band-2); }

/* ---------- insight cards */
.insight { display: flex; gap: 12px; align-items: flex-start; }
.insight .dot { width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center; }
.insight .dot svg { width: 18px; height: 18px; }
.insight p { margin: 2px 0 0; font-size: 14px; color: var(--ink-2); }
.insight b { color: var(--ink); font-weight: 600; }

/* ---------- inset grouped list (Blood work) */
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.row {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(90px, 1fr) auto; gap: 14px; align-items: center;
  padding: 11px 16px; cursor: pointer; position: relative;
}
.row + .row::before, .row + .detail::before, .detail + .row::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--sep);
}
.row:hover { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.row .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.row .name small { display: block; color: var(--ink-3); font-weight: 400; font-size: 12px; }
.row .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.row .val small { font-weight: 400; color: var(--ink-3); font-size: 12px; margin-left: 2px; }
.row .val .pill { margin-left: 6px; }
.detail { padding: 4px 16px 16px; position: relative; }
@media (max-width: 560px) {
  .row { grid-template-columns: minmax(0, 1fr) auto; }
  .row .rb { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- range bar */
.rb { position: relative; height: 22px; }
.rb .track { position: absolute; left: 0; right: 0; top: 9px; height: 4px; border-radius: 2px; background: var(--track); }
.rb .ref { position: absolute; top: 9px; height: 4px; background: color-mix(in srgb, var(--good) 35%, var(--track)); }
.rb .opt { position: absolute; top: 9px; height: 4px; background: var(--good); }
.rb .mk {
  position: absolute; top: 4px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%;
  background: var(--ink); border: 3px solid var(--card); box-shadow: 0 0 0 .5px var(--sep);
}
.rb .mk.good { background: var(--good); } .rb .mk.warn { background: var(--warn); } .rb .mk.bad { background: var(--bad); }
.rb.lg { height: 34px; }
.rb.lg .track, .rb.lg .ref, .rb.lg .opt { top: 12px; height: 8px; border-radius: 4px; }
.rb.lg .mk { top: 6px; width: 20px; height: 20px; margin-left: -10px; }
.rb-labels { position: relative; height: 16px; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rb-labels span { position: absolute; transform: translateX(-50%); white-space: nowrap; }

/* ---------- composition bars (DEXA) */
.comp { display: grid; grid-template-columns: 74px 1fr auto; gap: 10px; align-items: center; margin: 8px 0; }
.comp .lbl { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.comp .bar { display: flex; gap: 2px; height: 26px; }
.comp .bar span {
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: #fff;
  min-width: 0; overflow: hidden; white-space: nowrap;
}
.comp .bar span:first-child { border-radius: 6px 0 0 6px; } .comp .bar span:last-child { border-radius: 0 6px 6px 0; }
.comp .tot { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* regional small multiples */
.regions { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); }
.region { background: var(--card-2); border-radius: 12px; padding: 12px; }
.region h4 { margin: 0; font-size: 14px; font-weight: 600; }
.vbars { display: flex; align-items: flex-end; gap: 6px; height: 92px; margin: 10px 0 4px; }
.vbars .b { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.vbars .b i { display: block; width: 100%; max-width: 30px; border-radius: 4px 4px 0 0; background: var(--lean); }
.vbars .b em { font-style: normal; font-size: 11px; font-weight: 600; margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.vbars-x { display: flex; gap: 6px; font-size: 10.5px; color: var(--ink-3); text-align: center; }
.vbars-x span { flex: 1; }

/* balance */
.bal { display: grid; grid-template-columns: 1fr 60px 1fr; gap: 6px; align-items: center; margin: 10px 0; font-variant-numeric: tabular-nums; }
.bal .l { display: flex; justify-content: flex-end; } .bal .r { display: flex; }
.bal .l i, .bal .r i { display: block; height: 18px; background: var(--lean); }
.bal .l i { border-radius: 4px 0 0 4px; } .bal .r i { border-radius: 0 4px 4px 0; }
.bal .mid { text-align: center; font-size: 12px; color: var(--ink-2); }
.bal-h { display: grid; grid-template-columns: 1fr 60px 1fr; font-size: 12px; color: var(--ink-3); }
.bal-h span:first-child { text-align: right; } .bal-h span:nth-child(2) { text-align: center; }

/* ---------- charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-size: 11px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .base-line { stroke: var(--sep); stroke-width: 1; }
.chart .band-label { fill: var(--ink-3); font-size: 10.5px; }
.chart .dlabel { font-size: 12px; font-weight: 600; fill: var(--ink); }
.chart .xhair { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .marker-line { stroke: var(--c-meds); stroke-width: 1.5; opacity: .7; }
.chart-empty {
  height: 140px; display: grid; place-items: center; text-align: center; color: var(--ink-3); font-size: 13px;
  border: 1px dashed var(--sep); border-radius: 10px; padding: 12px;
}
.tip {
  position: fixed; z-index: 50; pointer-events: none; opacity: 0; transition: opacity .08s;
  background: var(--card); color: var(--ink); border-radius: 10px; padding: 8px 10px; font-size: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.18), 0 0 0 .5px var(--sep); min-width: 120px; max-width: 260px;
}
.tip.show { opacity: 1; }
.tip .t { color: var(--ink-2); margin-bottom: 4px; font-weight: 500; }
.tip .r { display: flex; align-items: center; gap: 6px; justify-content: space-between; font-variant-numeric: tabular-nums; }
.tip .r i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 4px; }
.tip .r b { font-weight: 600; }

/* ---------- cycle */
.ring-wrap { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; }
@media (max-width: 560px) { .ring-wrap { grid-template-columns: 1fr; justify-items: center; text-align: center; } }
.strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(8px, 1fr); gap: 2px; margin: 12px 0 4px; }
.strip i { height: 26px; border-radius: 3px; background: var(--track); position: relative; }
.strip i.p { background: var(--c-cycle); }
.strip i.pp { background: transparent; box-shadow: inset 0 0 0 1.5px var(--c-cycle); }
.strip i.f { background: color-mix(in srgb, var(--accent) 35%, var(--track)); }
.strip i.o { background: var(--accent); }
.strip i.today::after { content: ""; position: absolute; left: 50%; bottom: -7px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--ink); }
.strip-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); margin-top: 8px; }

/* ---------- lists / forms */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: .5px solid var(--sep); font-size: 14px; }
.tl li:first-child { border-top: 0; }
.tl .x { border: 0; background: none; color: var(--bad); cursor: pointer; font-size: 13px; padding: 0 0 0 8px; }
.btn {
  border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 600; font-size: 14px; cursor: pointer;
  background: var(--accent); color: #fff;
}
.btn.ghost { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.text-btn { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 16px; cursor: pointer; }
.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); }
.form input, .form select {
  font: inherit; color: var(--ink); background: var(--card-2); border: 0; border-radius: 10px; padding: 10px 12px; min-width: 0;
}
.form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.sheet {
  border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: 86vh;
  background: var(--bg); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.sheet::backdrop { background: rgba(0,0,0,.35); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px; position: sticky; top: 0; background: var(--bg); }
.sheet-head h2 { margin: 0; font-size: 20px; }
#sheet-body { padding: 4px 16px 20px; }
#sheet-body .card { margin-top: 12px; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; word-break: break-all; }
.copy { display: flex; gap: 8px; align-items: center; background: var(--card-2); border-radius: 8px; padding: 8px 10px; margin: 6px 0; }
.copy code { flex: 1; }
ol.steps { padding-left: 18px; margin: 6px 0 0; font-size: 14px; } ol.steps li { margin: 4px 0; }
.src { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.empty { text-align: center; padding: 26px 12px; color: var(--ink-2); font-size: 14px; }
.empty .btn { margin-top: 10px; }
.foot { margin-top: 30px; text-align: center; font-size: 12px; color: var(--ink-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.live.stale span { color: var(--warn); font-weight: 600; }
.live.stale i { background: var(--warn); }

/* ＋ Log floating button */
.fab {
  position: fixed; z-index: 20; right: max(16px, env(safe-area-inset-right)); bottom: max(18px, calc(env(safe-area-inset-bottom) + 8px));
  border: 0; border-radius: 999px; padding: 13px 20px 13px 16px; font-size: 17px; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #fff; box-shadow: 0 8px 24px rgba(0, 122, 255, .35), 0 2px 6px rgba(0,0,0,.15);
  display: inline-flex; align-items: center; gap: 6px;
}
.fab span { font-size: 20px; line-height: 1; }
.fab:active { transform: scale(.96); }
main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.form input[type=number] { -moz-appearance: textfield; }
@media (max-width: 560px) { .sheet { width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 16px 16px 0 0; } }

/* ---------- Today */
.today-hello { font-size: 15px; color: var(--ink-2); margin: 14px 4px 10px; font-weight: 500; }
.today { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); align-items: start; }
.rings { display: flex; align-items: center; gap: 14px; margin: 6px 0 4px; flex-wrap: wrap; }
.ring-score { text-align: center; }
.ring-label { font-size: 12px; font-weight: 600; color: var(--ink-2); margin-top: 2px; }
.ring-note { flex: 1; min-width: 120px; }
.btn.small, .text-btn.small { font-size: 13px; }
.btn.small { padding: 6px 12px; margin-top: 6px; }
.minis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; padding-top: 12px; border-top: .5px solid var(--sep); }
@media (max-width: 420px) { .minis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mini-v { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mini-v .u { font-size: 12px; color: var(--ink-2); font-weight: 600; margin-left: 2px; }
.weigh { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; margin: 6px 0 8px; }
.weigh input { font: inherit; font-size: 26px; font-weight: 700; color: var(--ink); background: var(--card-2); border: 0; border-radius: 12px; padding: 10px 12px; min-width: 0; width: 100%; font-variant-numeric: tabular-nums; }
.weigh .btn { padding: 12px 16px; font-size: 16px; }
.vit-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.streak { font-size: 14px; font-weight: 600; }
.checks { list-style: none; margin: 8px 0 0; padding: 0; }
.checks li + li { border-top: .5px solid var(--sep); }
.check { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 2px; border: 0; background: none; text-align: left; cursor: pointer; min-height: 52px; -webkit-tap-highlight-color: transparent; }
.check .box { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--ink-3); flex: none; display: grid; place-items: center; transition: background .12s, border-color .12s; }
.check.on .box { background: var(--good); border-color: var(--good); }
.check.on .box::after { content: ""; width: 8px; height: 14px; border: solid #fff; border-width: 0 3px 3px 0; transform: translateY(-2px) rotate(45deg); }
.check .nm { font-size: 16px; font-weight: 500; }
.check.on .nm { color: var(--ink-2); }
.check .nm small { display: block; font-size: 12.5px; color: var(--ink-3); font-weight: 400; }
.vhist, .hgrid { display: grid; grid-template-columns: repeat(14, 1fr); gap: 3px; margin-top: 12px; }
.hgrid { grid-template-columns: repeat(30, 1fr); gap: 2px; margin-top: 4px; }
.vhist i, .hgrid i { height: 14px; border-radius: 3px; background: var(--track); }
.hgrid i { height: 12px; }
.vhist i.part { background: color-mix(in srgb, var(--good) 40%, var(--track)); }
.vhist i.full, .hgrid i.full { background: var(--good); }
.vhist i.now { outline: 2px solid var(--ink-3); outline-offset: 1px; }
.vhist-x { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--ink-3); margin-top: 6px; }
.hrow { margin-top: 12px; } .hrow .nm { font-size: 14px; font-weight: 500; } .hrow small { color: var(--ink-3); margin-left: 6px; }
.btn.period { width: 100%; padding: 13px; font-size: 16px; background: var(--c-cycle); }
.vrow { display: grid; grid-template-columns: 1.4fr 1fr auto auto; gap: 6px; margin-top: 8px; align-items: center; }
.vrow input, .vrow select { font: inherit; font-size: 15px; color: var(--ink); background: var(--card-2); border: 0; border-radius: 10px; padding: 10px; min-width: 0; }
.vrow .x { border: 0; background: none; color: var(--bad); cursor: pointer; font-size: 13px; }
@media (max-width: 520px) { .vrow { grid-template-columns: 1fr 1fr; } }
#toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; z-index: 60;
  background: var(--ink); color: var(--card); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; transition: all .2s; pointer-events: none; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- consistency calendars */
.ex-btn { width: 100%; padding: 13px; font-size: 16px; margin: 6px 0 12px; background: var(--c-activity); }
.ex-btn.done { background: var(--good-bg); color: var(--good); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-head .text-btn { font-size: 24px; line-height: 1; padding: 2px 10px; }
.cal-head .text-btn:disabled { color: var(--ink-3); opacity: .4; cursor: default; }
.cal-month { font-weight: 600; font-size: 15px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid .wd { text-align: center; font-size: 11px; color: var(--ink-3); font-weight: 600; padding-bottom: 2px; }
.cd {
  aspect-ratio: 1; border: 0; border-radius: 10px; background: var(--card-2); position: relative; padding: 0; cursor: pointer;
  display: grid; place-items: center; min-width: 0; -webkit-tap-highlight-color: transparent;
}
.cd.blank { background: none; }
.cd .n { position: absolute; top: 3px; left: 5px; font-size: 10px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.cd .e { font-size: clamp(16px, 5vw, 24px); line-height: 1; margin-top: 6px; }
.cd.on { background: color-mix(in srgb, var(--good) 14%, var(--card-2)); }
.cd.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cd:disabled { opacity: .35; cursor: default; }
.cd:not(:disabled):active { transform: scale(.94); }
.cal-foot { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); margin-top: 10px; }
.cal-foot b { color: var(--ink); }

/* ---------- vitamin manager */
.vit-btn { margin: 0; }
.vcard { background: var(--card); border-radius: var(--radius); padding: 12px; margin-top: 12px; box-shadow: var(--shadow); }
.vline { display: flex; gap: 8px; align-items: center; }
.vline .vn { flex: 1; font: inherit; font-size: 17px; font-weight: 600; color: var(--ink); background: var(--card-2); border: 0; border-radius: 10px; padding: 10px 12px; min-width: 0; }
.vline .x { border: 0; background: none; color: var(--bad); font-size: 13px; cursor: pointer; }
.vfields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.vfields label { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); font-weight: 500; }
.vfields input, .vfields select { font: inherit; font-size: 16px; color: var(--ink); background: var(--card-2); border: 0; border-radius: 10px; padding: 9px 10px; min-width: 0; width: 100%; }
.stepper { display: grid; grid-template-columns: 38px 1fr 38px; background: var(--card-2); border-radius: 10px; overflow: hidden; }
.stepper button { border: 0; background: none; font-size: 20px; color: var(--accent); cursor: pointer; }
.stepper input { text-align: center; padding: 9px 0 !important; border-radius: 0 !important; font-weight: 600; }
.vtotal { margin-top: 8px; font-size: 14px; color: var(--ink-2); min-height: 18px; }
.vtotal b { color: var(--ink); }

/* ---------- classes & week */
.cls-list { list-style: none; margin: 4px 0 0; padding: 0; }
.cls { display: grid; grid-template-columns: 72px 1fr auto; gap: 10px; align-items: start; padding: 9px 0; }
.cls + .cls { border-top: .5px solid var(--sep); }
.cls-time { font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.cls-time small { display: block; color: var(--ink-3); font-weight: 400; font-size: 12px; }
.cls-title { font-weight: 600; font-size: 15px; }
.cls-oura { display: flex; gap: 5px; align-items: center; font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }
.cls-oura svg { width: 13px; height: 13px; color: var(--c-heart); flex: none; }
.cls-badge .pill { font-size: 11px; }
.cls-yest { margin-top: 10px; padding-top: 8px; border-top: .5px solid var(--sep); }
.cal-status { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); margin-top: 10px; }
.week-card { grid-column: 1 / -1; }
.week-card .card-head .when { display: inline-flex; align-items: center; gap: 4px; }
.week-card .card-head .text-btn { font-size: 20px; padding: 0 6px; line-height: 1; }
.week-card .text-btn:disabled { opacity: .3; }
.wk-day { display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding: 10px 0; border-top: .5px solid var(--sep); }
.wk-day.today { background: color-mix(in srgb, var(--accent) 7%, transparent); border-radius: 10px; padding-left: 6px; padding-right: 6px; }
.wk-day.future { opacity: .75; }
.wk-date { display: flex; flex-direction: column; align-items: center; font-size: 12px; color: var(--ink-2); }
.wk-date span { font-size: 20px; font-weight: 700; color: var(--ink); }
.wk-ex { font-size: 16px !important; }
.wk-scores { display: flex; gap: 6px; }
.score { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.score.hi { color: var(--good); background: var(--good-bg); } .score.mid { color: var(--warn); background: var(--warn-bg); } .score.lo { color: var(--bad); background: var(--bad-bg); }
.wk-main .cls { grid-template-columns: 70px 1fr auto; padding: 6px 0; }
@media (max-width: 420px) { .cls, .wk-main .cls { grid-template-columns: 66px 1fr; } .cls-badge { grid-column: 2; } }

/* ---------- Today layout: two even stacks on wide screens, one ordered column on a phone */
.today-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.tcol { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.today-grid > .week-card { grid-column: 1 / -1; }
.today-grid .card { margin: 0; }
@media (max-width: 820px) {
  .today-grid { display: flex; flex-direction: column; align-items: stretch; }
  .tcol { display: contents; }
  .o1 { order: 1; } .o2 { order: 2; } .o3 { order: 3; } .o4 { order: 4; } .o5 { order: 5; } .o6 { order: 6; } .o7 { order: 7; }
}
/* consistent card rhythm on Today */
.today-grid .card-head { min-height: 26px; margin-bottom: 8px; }

/* weight chart */
.wchart-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 12px 0 6px; padding-top: 12px; border-top: .5px solid var(--sep); flex-wrap: wrap; }

/* consistency: compact month calendars */
.cal-nav { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.cal-nav .text-btn { font-size: 20px; line-height: 1; padding: 0 6px; }
.cal-nav .text-btn:disabled { opacity: .3; cursor: default; }
.ex-btn { margin: 0 0 12px; padding: 11px; font-size: 15px; }
.cals { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mcal-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.mc-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.mc-grid .wd { text-align: center; font-size: 9.5px; color: var(--ink-3); font-weight: 600; }
.mc {
  height: 24px; border: 0; border-radius: 6px; background: transparent; padding: 0; cursor: pointer; min-width: 0;
  font-size: 10.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; display: grid; place-items: center; line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.mc.blank { pointer-events: none; }
.mc.on { font-size: 14px; background: color-mix(in srgb, var(--good) 14%, transparent); }
.mc.today { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--ink); font-weight: 700; }
.mc:disabled { opacity: .35; cursor: default; }
.mc:not(:disabled):hover { background: var(--card-2); }
.mc.on:not(:disabled):hover { background: color-mix(in srgb, var(--good) 22%, transparent); }
.mcal-foot { font-size: 12px; color: var(--ink-2); margin-top: 6px; }
.mcal-foot b { color: var(--ink); }
@media (max-width: 360px) { .cals { grid-template-columns: 1fr; } }

/* week: a 7-column calendar on wide screens, compact rows on a phone */
.wk-day { padding: 8px 0; }
@media (min-width: 821px) {
  .wk-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: .5px solid var(--sep); border-radius: 12px; overflow: hidden; }
  .wk-day { display: flex; flex-direction: column; gap: 6px; padding: 10px 8px 12px; border-top: 0; border-left: .5px solid var(--sep); min-height: 150px; }
  .wk-day:first-child { border-left: 0; }
  .wk-day.today { border-radius: 0; padding-left: 8px; padding-right: 8px; }
  .wk-date { flex-direction: row; align-items: baseline; gap: 6px; }
  .wk-date span { font-size: 18px; }
  .wk-main .cls { grid-template-columns: 1fr; gap: 2px; padding: 6px 0; }
  .wk-main .cls-time { font-size: 12px; }
  .wk-main .cls-time small { display: none; }
  .wk-main .cls-title { font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
  .wk-main .cls-oura { font-size: 11px; }
  .wk-main .cls-badge .pill { font-size: 10px; padding: 1px 6px; }
  .wk-none { font-size: 12px; }
}
.cls-sec { font-weight: 600; margin-bottom: 2px; }
.cls-day + .cls-day { margin-top: 6px; }
.cls-daylabel { font-size: 13px; font-weight: 600; color: var(--ink); margin-top: 4px; }
.cls-daylabel span { font-weight: 400; color: var(--ink-3); margin-left: 4px; }
