/* 健康工作室 V3.2 — 安静、克制的每日健康工具。系统字体，无外部资源。
   视觉语法：实线 / 实色 = 已测量、主要；虚线 = 待接入、参考、辅助。未知写「未知」，不画成 0。
   色彩：冷雾灰底 + 白色卡片；唯一强调色为深松青；数据色只用于数据本身。
   间距 4 / 8 / 12 / 16 / 20 / 24；圆角 卡片 18、内块 12、标签 8；字号 36 / 26 / 22 / 17 / 15 / 13。 */
:root {
  color-scheme: light dark;
  --bg: #eef1ef;
  --surface: #ffffff;
  --surface-2: #f3f5f4;
  --ink: #121816;
  --ink-2: #47534e;
  --ink-3: #5a6661;
  --line: rgba(18, 24, 22, .08);
  --line-strong: rgba(18, 24, 22, .14);
  --dash: rgba(18, 24, 22, .30);
  --accent: #0a6658;
  --on-accent: #ffffff;
  --accent-soft: rgba(10, 102, 88, .09);
  --warn: #8a5200;
  --warn-soft: #fbefd9;
  --card-shadow: 0 1px 2px rgba(18, 24, 22, .04);
  --tone-intake: #1f7a6b;
  --tone-protein: #4d5fb0;
  --tone-carbs: #b07415;
  --tone-fat: #b0544c;
  --tone-fiber: #4e8040;
  --tone-weight: #3f6e9e;
  --rec-recent: #c63b3b;
  --rec-recovering: #e5862c;
  --rec-near: #d8b235;
  --rec-window_passed: #3f9466;
  --rec-unknown: #dde2e0;
  --rec-hatch: #8f9b97;
  --body-skin: #e8ecea;
  --body-outline: #a8b4b0;
  --body-neutral: #d2d9d6;
  --body-gap: #ffffff;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px;
  --radius: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --tabbar-h: 58px;
  --appbar-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", system-ui, "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f0e;
    --surface: #141a19;
    --surface-2: #1b2321;
    --ink: #e6ecea;
    --ink-2: #a6b2ae;
    --ink-3: #95a29e;
    --line: rgba(230, 236, 234, .09);
    --line-strong: rgba(230, 236, 234, .16);
    --dash: rgba(230, 236, 234, .32);
    --accent: #5ec2ae;
    --on-accent: #08110f;
    --accent-soft: rgba(94, 194, 174, .13);
    --warn: #f2bb62;
    --warn-soft: rgba(242, 187, 98, .14);
    --card-shadow: 0 0 0 1px rgba(230, 236, 234, .05);
    --tone-intake: #4cc2ac;
    --tone-protein: #8f9df0;
    --tone-carbs: #e3a64a;
    --tone-fat: #e88c82;
    --tone-fiber: #8cc27a;
    --tone-weight: #7fb0e3;
    --rec-recent: #e5605b;
    --rec-recovering: #f09a45;
    --rec-near: #e8c552;
    --rec-window_passed: #55b07f;
    --rec-unknown: #34403d;
    --rec-hatch: #66746f;
    --body-skin: #26302e;
    --body-outline: #56645f;
    --body-neutral: #3a4542;
    --body-gap: #141a19;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--appbar-h) + var(--safe-top) + 12px); }
body { margin: 0; background: var(--bg); min-height: 100dvh; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }
button, a, select, summary, label { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; top: calc(var(--safe-top) + 8px); left: 8px; z-index: 100; padding: 12px 16px; background: var(--surface); color: var(--ink); border-radius: var(--radius-sm); transform: translateY(-200%); }
.skip:focus { transform: none; }
[hidden] { display: none !important; }

/* ---------- 顶栏：日期步进器 ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid var(--line);
}
.appbar-inner {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 4px;
  max-width: 640px; margin: 0 auto; height: var(--appbar-h); padding: 0 8px;
  position: relative;
}
.step { width: 44px; height: 44px; border: 0; border-radius: 22px; background: transparent; display: grid; place-items: center; cursor: pointer; }
.step svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.step:active { background: var(--accent-soft); }
.step:disabled { cursor: default; }
.step:disabled svg { stroke: var(--line); }
.date-field { position: relative; display: flex; align-items: baseline; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 4px; border-radius: 12px; cursor: pointer; }
.date-field:active { background: var(--accent-soft); }
.date-main { font-size: 17px; font-weight: 600; white-space: nowrap; }
.date-sub { font-size: 13px; color: var(--accent); font-weight: 600; white-space: nowrap; }
.date-field input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; font-size: 16px; cursor: pointer; }
.date-field:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }
.today { position: absolute; right: 56px; top: 50%; transform: translateY(-50%); min-height: 44px; padding: 0 12px; border: 0; background: transparent; color: var(--accent); font-size: 15px; font-weight: 600; cursor: pointer; }

/* ---------- 底部标签栏（桌面为左侧导航） ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 0 4px var(--safe-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--line);
}
.rail-brand { display: none; }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tabbar-h); color: var(--ink-3); text-decoration: none; font-size: 12px; font-weight: 500;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* ---------- 页面 ---------- */
main { max-width: 640px; margin: 0 auto; padding: 8px calc(16px + var(--safe-right)) calc(var(--tabbar-h) + var(--safe-bottom) + 28px) calc(16px + var(--safe-left)); outline: none; }
.page > h1 { font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; margin: 16px 4px 12px; outline: none; text-wrap: balance; }
.page-body { display: grid; gap: 12px; }
.grid-2 { display: grid; gap: 12px; min-width: 0; }
.grid-2 > * { min-width: 0; }

.card { background: var(--surface); border-radius: var(--radius); padding: var(--s4); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); min-width: 0; box-shadow: var(--card-shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 28px; }
.card-head h2 { font-size: 17px; font-weight: 600; line-height: 1.3; }
.card-link { font-size: 15px; font-weight: 500; text-decoration: none; min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: flex-end; margin: -8px 0; }
.muted { color: var(--ink-2); font-size: 14px; }
.caption { color: var(--ink-2); font-size: 13px; line-height: 1.45; }
.note { font-size: 14px; color: var(--ink-2); background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; }
.meta-line { color: var(--ink-2); font-size: 14px; }
.lead-line { font-size: 16px; }
.title-line { font-size: 20px; font-weight: 600; line-height: 1.3; }
.stack-sm { display: grid; gap: 8px; }
.num { font-variant-numeric: tabular-nums; }

/* 大数字 */
.figure { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 6px; }
.figure-value { font-size: 36px; font-weight: 600; line-height: 1.1; letter-spacing: -.02em; }
.figure.is-range .figure-value { font-size: 32px; }
.figure-approx { font-size: 17px; font-weight: 500; color: var(--ink-2); }
.figure-unit { font-size: 15px; color: var(--ink-2); }
.figure.is-empty .figure-value { font-size: 22px; font-weight: 600; color: var(--ink-2); }
.tag { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; line-height: 1; padding: 4px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; align-self: center; }
.tag-quiet { background: var(--surface-2); color: var(--ink-2); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.pill { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill.is-open { background: var(--warn-soft); color: var(--warn); }

/* 摄入卡里的三项小事实 */
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.facts .fact-wide { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.facts dd.is-unknown { color: var(--ink-2); font-weight: 500; }
.facts dt { font-size: 13px; color: var(--ink-2); }
.facts dd { font-size: 15px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat dd { order: -1; font-size: 26px; font-weight: 650; line-height: 1.15; }
.stat dd.is-unknown { font-size: 17px; color: var(--ink-2); padding-top: 6px; }
.stat dt { font-size: 13px; color: var(--ink-2); line-height: 1.35; }

/* 肌肉状态分组（总览） */
.state-groups { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.state-groups li { display: grid; grid-template-columns: 12px auto minmax(0, 1fr); align-items: baseline; gap: 8px; font-size: 15px; }
.state-name { color: var(--ink-2); white-space: nowrap; }
.state-muscles { font-weight: 500; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; }
.state-groups .swatch { transform: translateY(1px); }
.swatch.status-recent { background: var(--rec-recent); }
.swatch.status-recovering { background: var(--rec-recovering); }
.swatch.status-near { background: var(--rec-near); }
.swatch.status-window_passed { background: var(--rec-window_passed); }
.swatch.status-unknown { background: repeating-linear-gradient(135deg, var(--rec-unknown) 0 3px, var(--rec-hatch) 3px 4px); }
.swatch.tone-intake { background: var(--tone-intake); }
.swatch.tone-protein { background: var(--tone-protein); }
.swatch.tone-carbs { background: var(--tone-carbs); }
.swatch.tone-fat { background: var(--tone-fat); }
.swatch.tone-fiber { background: var(--tone-fiber); }

/* 体重历史参考 */
.historic { border-top: 1px dashed var(--line); padding-top: 10px; display: grid; gap: 6px; }
.historic-title { font-size: 13px; color: var(--ink-2); }
.historic li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 14px; color: var(--ink-2); }

/* 提醒 */
.reminders ul { display: grid; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.reminders li + li { border-top: 1px solid var(--line); }
.reminders a { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 16px; color: var(--ink); text-decoration: none; font-size: 15px; }
.reminders a:active { background: var(--accent-soft); }
.reminders .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }

/* ---------- 折叠区 ---------- */
.disclosure > summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 44px; cursor: pointer; font-size: 15px; font-weight: 500; color: var(--ink-2);
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translate(-2px, -2px); flex: none; margin-right: 4px; }
.disclosure[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.disclosure-body { padding: 4px 0 6px; }
.card .disclosure { border-top: 1px solid var(--line); margin-top: 2px; }
.card .disclosure > summary { margin-bottom: -6px; }
.disclosure.card-like { background: var(--surface); border-radius: var(--radius); padding: 2px 16px; box-shadow: var(--card-shadow); }
.disclosure.card-like.quiet { background: transparent; box-shadow: none; border: 1px solid var(--line-strong); }
.disclosure.card-like[open] { padding-bottom: 12px; }
.disclosure.nested > summary { font-size: 14px; }

.detail-list { display: grid; grid-template-columns: minmax(64px, max-content) minmax(0, 1fr); gap: 6px 14px; font-size: 14px; }
.detail-list dt { color: var(--ink-2); }
.detail-list dd { overflow-wrap: anywhere; }
.detail-list.compact { gap: 4px 12px; }
.detail-list.stacked { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px; }
.detail-list.stacked dt { grid-row: auto; font-size: 13px; }
.detail-list.stacked dd { margin-bottom: 6px; }
.plain-list { display: grid; gap: 6px; font-size: 14px; }
.plain-list li { padding-left: 14px; position: relative; overflow-wrap: anywhere; }
.plain-list li::before { content: ""; position: absolute; left: 2px; top: .65em; width: 5px; height: 5px; border-radius: 50%; background: var(--ink-3); }
.plain-rows li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.plain-rows li:first-child { border-top: 0; }
.daily-values li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.daily-values li:first-child { border-top: 0; }
.mono-id { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.page-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 16px; padding: 4px 4px 0; font-size: 13px; color: var(--ink-2); }
.page-foot a { min-height: 44px; display: inline-flex; align-items: center; font-size: 14px; }

/* ---------- 分段控件 / 按钮 ---------- */
.segmented { display: inline-grid; grid-auto-flow: column; gap: 2px; padding: 2px; border-radius: 10px; background: var(--surface-2); }
.segmented button, .metric-tabs button { border: 0; background: transparent; min-height: 44px; min-width: 56px; padding: 0 12px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.segmented.small button { min-width: 52px; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.metric-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.metric-tabs button { background: var(--surface-2); min-width: 0; }
.metric-tabs button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.text-button { border: 0; background: transparent; color: var(--accent); font-weight: 600; min-height: 44px; padding: 0 4px; cursor: pointer; justify-self: start; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.field { display: grid; gap: 2px; font-size: 13px; color: var(--ink-2); min-width: 0; }
.field select { min-height: 44px; width: 100%; padding: 0 8px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font-size: 15px; }

/* ---------- 图表 ---------- */
.chart-host { min-width: 0; }
.chart { display: block; max-width: 100%; height: auto; touch-action: pan-y; cursor: crosshair; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-base { stroke: var(--ink-3); stroke-opacity: .45; stroke-width: 1; }
.chart-label { fill: var(--ink-2); font-size: 12px; }
.chart-empty { fill: var(--ink-2); font-size: 14px; }
.chart-bar.is-partial { opacity: .45; }
.chart-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tone-intake { fill: var(--tone-intake); stroke: var(--tone-intake); }
.tone-protein { fill: var(--tone-protein); stroke: var(--tone-protein); }
.tone-carbs { fill: var(--tone-carbs); stroke: var(--tone-carbs); }
.tone-fat { fill: var(--tone-fat); stroke: var(--tone-fat); }
.tone-fiber { fill: var(--tone-fiber); stroke: var(--tone-fiber); }
.tone-weight { fill: var(--tone-weight); stroke: var(--tone-weight); }
.chart-line.tone-weight { fill: none; }
.chart-bar { stroke: none; }
/* 当天未记完：虚线空心（虚线 = 还没定下来），与实心的已记完区分 */
.chart-bar.is-open, .chart-dot.is-open { fill-opacity: .18; stroke-width: 1.5; stroke-dasharray: 3 2; }
.chart-bar.is-open.tone-intake { stroke: var(--tone-intake); }
.data-legend .data-key { display: inline-block; width: 10px; height: 14px; border-radius: 3px; background: var(--tone-intake); border: 1.5px solid var(--tone-intake); }
.data-legend .data-key.is-open { background: color-mix(in srgb, var(--tone-intake) 18%, transparent); border-style: dashed; }
.data-legend .data-key.is-partial { opacity: .45; }
.daily-values li.is-unknown > span:last-child { color: var(--ink-2); }
.daily-values li > span:first-child { white-space: nowrap; }
.daily-values li > span:last-child { text-align: right; }
.chart-tooltip { position: fixed; z-index: 50; max-width: 260px; padding: 6px 10px; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: 13px; pointer-events: none; }

/* ---------- 训练：人体图 ---------- */
.recovery-layout { display: grid; gap: 12px; }
.recovery-figure { display: grid; gap: 10px; justify-items: center; }
.body-maps { display: grid; grid-auto-flow: column; justify-content: center; gap: 12px; width: 100%; }
.body-map-panel { text-align: center; }
.body-map-panel figcaption { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.body-map-svg { display: block; width: auto; height: min(420px, 58svh); max-width: 100%; margin: 0 auto; }
/* 素材按 3 倍 viewBox 单位绘制：stroke-width 9 约等于 3 个单位。 */
.body-silhouette path { fill: var(--body-skin); stroke: var(--body-outline); stroke-width: 5; stroke-linejoin: round; }
.body-map-svg .muscle-neutral { fill: var(--body-neutral); stroke: var(--body-gap); stroke-width: 9; stroke-linejoin: round; pointer-events: none; }
.body-map-svg .muscle-hit-area { fill: transparent; stroke: transparent; stroke-linejoin: round; pointer-events: all; cursor: pointer; }
.muscle-target { cursor: pointer; }
.body-map-svg .muscle-fill { stroke: var(--body-gap); stroke-width: 9; stroke-linejoin: round; pointer-events: visiblePainted; }
/* 未知状态的填充来自每个视图的 SVG 斜线图案，这里不设 fill。 */
.muscle-fill.status-recent { fill: var(--rec-recent); }
.muscle-fill.status-recovering { fill: var(--rec-recovering); }
.muscle-fill.status-near { fill: var(--rec-near); }
.muscle-fill.status-window_passed { fill: var(--rec-window_passed); }
.hatch-base { fill: var(--rec-unknown); }
.hatch-line { stroke: var(--rec-hatch); stroke-width: 6; }
.body-map-svg .muscle-target.is-selected .muscle-fill { paint-order: stroke; stroke: var(--ink); stroke-width: 18; }
.body-map-svg .muscle-target:focus-visible { outline: none; }
.body-map-svg .muscle-target:focus-visible .muscle-fill { stroke: var(--accent); stroke-width: 21; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; font-size: 13px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--surface-2); font-weight: 600; }
.muscle-panel { display: grid; gap: 10px; padding: 14px; border-radius: 14px; background: var(--surface-2); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-head h3 { font-size: 20px; font-weight: 600; }
.panel-title { display: inline-flex; align-items: center; gap: 8px; }
.state-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--surface); white-space: nowrap; }
.muscle-panel .note { background: var(--surface); }

/* 本周训练量 */
.bars { display: grid; gap: 6px; max-width: 620px; }
.bars li { display: grid; grid-template-columns: 64px minmax(0, 1fr) 40px; align-items: center; gap: 10px; font-size: 14px; min-height: 22px; }
.bar-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.bar-value { text-align: right; color: var(--ink-2); }

/* 训练记录 */
.session-list { display: grid; }
.session { border-top: 1px solid var(--line); }
.session:first-child { border-top: 0; }
.session > summary { list-style: none; display: grid; grid-template-columns: 48px minmax(0, 1fr) 12px; align-items: center; gap: 12px; min-height: 60px; padding: 8px 0; cursor: pointer; }
.session > summary::-webkit-details-marker { display: none; }
.session > summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(-45deg); }
.session[open] > summary::after { transform: rotate(45deg); }
.session-date { display: grid; justify-items: center; gap: 3px; line-height: 1.25; }
.session-date strong { font-size: 17px; font-weight: 650; }
.session-date small { font-size: 12px; color: var(--ink-2); }
.session-main { display: grid; gap: 2px; min-width: 0; }
.session-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 16px; font-weight: 600; }
.session-meta { font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.session.is-incomplete .session-title > span:first-child, .session.is-incomplete .session-date strong { color: var(--ink-2); font-weight: 500; }
.session-body { display: grid; gap: 10px; padding: 0 0 14px 60px; }
.exercise-list { display: grid; gap: 8px; font-size: 14px; }
.exercise-list .sets { display: block; color: var(--ink-2); font-size: 13px; overflow-wrap: anywhere; }

.map-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.map-table caption { text-align: left; font-size: 14px; font-weight: 600; padding: 6px 0; }
.map-table th, .map-table td { text-align: left; padding: 6px 6px 6px 0; border-top: 1px solid var(--line); vertical-align: top; font-weight: 400; }
.map-table thead th { color: var(--ink-2); }

/* ---------- 饮食 ---------- */
.meal-list { display: grid; }
.meal { border-top: 1px solid var(--line); }
.meal:first-child { border-top: 0; }
.meal > summary { list-style: none; display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: start; gap: 10px; padding: 12px 0; min-height: 56px; cursor: pointer; }
.meal > summary::-webkit-details-marker { display: none; }
.meal-time { font-size: 14px; font-weight: 600; padding-top: 1px; }
.meal-time.is-missing { color: var(--warn); }
.meal-main { display: grid; gap: 2px; min-width: 0; }
.meal-label { font-size: 13px; color: var(--ink-2); }
.meal-foods { font-size: 15px; overflow-wrap: anywhere; }
.meal-kcal { font-size: 14px; font-weight: 600; white-space: nowrap; padding-top: 1px; }
.meal.is-muted .meal-foods, .meal.is-muted .meal-kcal { color: var(--ink-2); }
.meal-body { display: grid; gap: 8px; padding: 0 0 14px 74px; }
.nutrient-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; font-size: 14px; }
.nutrient-grid dt { color: var(--ink-2); font-size: 13px; }
.nutrient-grid dd { font-weight: 600; }
.nutrient-grid dd.is-unknown, .nutrient-row.is-unknown .nutrient-value { color: var(--ink-2); font-weight: 500; }

/* ---------- 营养素 ---------- */
.nutrient-list { display: grid; }
.nutrient-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.nutrient-row:first-child { border-top: 0; }
.nutrient-list.is-secondary .nutrient-row { grid-template-columns: minmax(0, 1fr) auto; padding: 8px 0; }
.nutrient-name { display: grid; font-size: 16px; }
.nutrient-name small { font-size: 13px; color: var(--ink-2); }
.nutrient-value { font-size: 17px; font-weight: 600; text-align: right; }
.nutrient-list.is-secondary .nutrient-value { font-size: 15px; }

/* ---------- V3.2 总览组件 ---------- */
.stack, .trend { grid-template-columns: minmax(0, 1fr); }
.stack { display: grid; gap: var(--s3); }
.slot-label { font-size: 13px; color: var(--ink-2); line-height: 1.35; }
.slot-note { font-size: 13px; color: var(--ink-2); line-height: 1.4; overflow-wrap: anywhere; }
.figure-md .figure-value, .figure-md.is-range .figure-value { font-size: 26px; }
.figure-md .figure-approx { font-size: 15px; }
.figure.figure-md.is-empty .figure-value { font-size: 20px; }
.energy-intake, .protein, .weight-now { display: grid; gap: 2px; }
.slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.slot { display: grid; align-content: start; gap: 2px; min-width: 0; padding: var(--s3); border-radius: var(--radius-md); background: var(--surface-2); border: 1.5px solid transparent; }
.slot-value { font-size: 17px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.slot.is-pending { background: transparent; border-style: dashed; border-color: var(--dash); }
.slot.is-pending .slot-value { color: var(--ink-2); font-size: 15px; }
.data-state { font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.slot-note { text-wrap: balance; }
.reason-list { display: grid; gap: var(--s2); }
.reason-list li { display: grid; }
.reason-list strong { font-weight: 600; }
.reason-list span { color: var(--ink-2); }
.macro-rows li { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); padding: 10px 0; border-top: 1px solid var(--line); }
.macro-rows li:last-child { padding-bottom: 0; }
.macro-name { display: grid; font-size: 15px; min-width: 0; }
.macro-name small { font-size: 12px; color: var(--ink-2); }
.macro-value { font-size: 15px; font-weight: 600; text-align: right; white-space: nowrap; }
.macro-rows li.is-unknown .macro-value { color: var(--ink-2); font-weight: 500; }
.target { display: grid; gap: 4px; margin-top: 6px; }
.target-track { position: relative; height: 8px; border-radius: 4px; background: var(--surface-2); }
.target-band { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: var(--tone-protein); }
.target-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--ink); }
.trend { display: grid; gap: var(--s2); }
.trend-delta { display: flex; justify-content: space-between; gap: var(--s3); font-size: 13px; color: var(--ink-2); }
.trend-empty { font-size: 14px; padding: 10px 12px; border-radius: var(--radius-md); border: 1.5px dashed var(--dash); }
.tag-dashed { background: transparent; color: var(--ink-2); border: 1px dashed var(--dash); padding: 3px 6px; }
.session-link { display: grid; grid-template-columns: minmax(0, 1fr) 12px; align-items: center; gap: var(--s3); min-height: 56px; padding: var(--s3); border-radius: var(--radius-md); background: var(--surface-2); color: var(--ink); text-decoration: none; }
.session-link:active { background: var(--accent-soft); }
.session-link-main { display: grid; gap: 2px; min-width: 0; }
.session-link-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.session-link-title strong { font-size: 17px; font-weight: 600; }
.session-link .meta-line { font-size: 13px; overflow-wrap: anywhere; }
.chevron { width: 8px; height: 8px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(-45deg); justify-self: center; }
.roles { display: grid; gap: var(--s2); }
.role-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.role-chip { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 500; border: 1.5px solid var(--accent); }
.role-chip.is-primary { background: var(--accent); color: var(--on-accent); }
.role-chip.is-secondary { background: transparent; color: var(--accent); border-style: dashed; }
.role-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--ink-2); }
.role-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.role-key { display: inline-block; width: 16px; height: 10px; border-radius: 5px; border: 1.5px solid var(--accent); }
.role-key.is-primary { background: var(--accent); }
.role-key.is-secondary { border-style: dashed; }
.recovery-note { display: grid; gap: var(--s2); padding-top: var(--s3); border-top: 1px solid var(--line); }
.recovery-note .state-groups { padding-top: 0; border-top: 0; }
.sub-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; font-size: 14px; font-weight: 600; }
.sub-head .caption { font-weight: 400; }
.slot-wide { grid-column: 1 / -1; }
.lead-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.lead-value { font-size: 20px; font-weight: 600; }
.row-main { display: grid; gap: 0; min-width: 0; }
.row-date { font-size: 13px; color: var(--ink-2); }
.row-value { font-weight: 600; white-space: nowrap; align-self: center; }
.row-value.is-unknown { color: var(--ink-2); font-weight: 500; }
/* 训练页：只作为辅助参与的肌群按钮用虚线边 */
.chip.is-assist { border-style: dashed; border-color: var(--dash); }
.role-tag { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; line-height: 1; padding: 4px 7px; border-radius: 6px; border: 1.5px solid var(--accent); white-space: nowrap; }
.role-tag.is-primary { background: var(--accent); color: var(--on-accent); }
.role-tag.is-secondary { color: var(--accent); border-style: dashed; }

/* ---------- 加载状态 ---------- */
.data-load-state { max-width: 520px; margin: 30vh auto 0; padding: 20px; text-align: center; color: var(--ink-2); }

/* ---------- 窄屏 ---------- */
@media (max-width: 380px) {
  main { padding-left: 12px; padding-right: 12px; }
  .figure-value { font-size: 30px; }
  .figure.is-range .figure-value { font-size: 26px; }
  .stat dd { font-size: 22px; }
  .facts dd { font-size: 14px; }
  .meal-body, .session-body { padding-left: 0; }
}

/* ---------- 桌面：左侧导航，两栏 ---------- */
@media (min-width: 1024px) {
  .tabbar {
    top: 0; right: auto; width: 220px; bottom: 0;
    display: flex; flex-direction: column; gap: 2px; padding: 20px 12px;
    border-top: 0; border-right: 1px solid var(--line); background: var(--surface);
  }
  .rail-brand { display: block; font-size: 15px; font-weight: 700; padding: 6px 12px 18px; color: var(--ink); }
  .tabbar a { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; font-size: 15px; color: var(--ink-2); }
  .tabbar a[aria-current="page"] { background: var(--accent-soft); }
  .appbar, main { margin-left: 220px; }
  .appbar-inner, main { max-width: 980px; }
  main { padding: 8px 32px 48px; }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .recovery-layout { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; }
  .body-map-svg { height: 440px; }
}

@media (prefers-reduced-motion: no-preference) {
  .step, .chip, .segmented button, .metric-tabs button, .date-field { transition: background-color .15s ease; }
}

/* ---------- V3.4：来源标签、热量参考、逐项估算、预览横幅 ---------- */
.preview-banner { padding: 6px 12px; text-align: center; font-size: 13px; font-weight: 700; line-height: 1.4; background: var(--warn-soft); color: var(--warn); border-bottom: 1px dashed currentColor; }
html.is-preview { scroll-padding-top: calc(var(--appbar-h) + var(--safe-top) + 44px); }
/* 实线 = 记录 / 设备，虚线 = 公式 / 缺失，点线 = 网站试算 */
.src-tag { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; line-height: 1; padding: 3px 6px; border-radius: 6px; border: 1px solid transparent; white-space: nowrap; }
.src-tag.is-record { background: var(--accent-soft); color: var(--accent); }
.src-tag.is-device { border-color: var(--accent); color: var(--accent); }
.src-tag.is-formula { border: 1px dashed var(--warn); color: var(--warn); }
.src-tag.is-estimate { border: 1px dotted var(--warn); background: var(--warn-soft); color: var(--warn); }
.src-tag.is-missing { border: 1px dashed var(--dash); color: var(--ink-2); }
.src-tag.is-note { border: 1px dotted var(--accent); color: var(--accent); }
.label-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
/* 空白指标说明、公式参考标识、训练三项数值 */
.gap-note { overflow-wrap: anywhere; }
p > .gap-note, .card > .gap-note { font-size: 13px; }
.reference-label { font-size: 12px; font-weight: 700; line-height: 1.4; color: var(--warn); overflow-wrap: anywhere; }
.formula-steps { display: grid; gap: 2px; }
.stats.is-pairs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.plain-rows li.session-row .row-main { flex-basis: 100%; }
.row-fields { flex-basis: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 4px 0 0; }
.row-fields dt { font-size: 12px; color: var(--ink-2); }
.row-fields dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.row-fields dd.is-unknown { font-size: 13px; font-weight: 500; color: var(--ink-2); }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.overview-grid > * { min-width: 0; }
.energy-columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); }
.energy-intake { align-content: start; gap: var(--s2); }
.energy-columns .slots { grid-template-columns: minmax(0, 1fr); align-content: start; }
.energy-facts-compact { display: none; }
.energy-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; font-size: 14px; margin: 0; }
.energy-facts dt { color: var(--ink-2); }
.energy-facts dd { overflow-wrap: anywhere; }
.no-likely { font-size: 14px; padding: 8px 10px; border-radius: var(--radius-sm); border: 1.5px dashed var(--dash); }
.wide-note { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; font-weight: 600; color: var(--warn); }
.slot-value.is-big { font-size: 26px; line-height: 1.2; }
.slot.is-partial { background: var(--warn-soft); }
.slot.is-partial .slot-label { color: var(--warn); font-weight: 700; }
.slot.is-partial .slot-note { color: var(--ink); }
.official { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 13px; color: var(--ink-2); padding: 8px 12px; border-radius: var(--radius-sm); border: 1.5px dashed var(--dash); }
.official strong { color: var(--ink); }
.ref-line { display: flex; align-items: baseline; gap: 8px; font-size: 13px; color: var(--ink-2); }
.ref-line > span:last-child { flex: 1; min-width: 0; }
.energy .slot-note { text-wrap: pretty; }
.formula-inputs { display: grid; gap: 4px; margin-top: 4px; padding-top: 6px; border-top: 1px dashed var(--dash); font-size: 13px; }
.formula-inputs li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 12px; }
.formula-inputs small { font-size: 12px; color: var(--ink-2); }
.protein .ref-line { margin-top: 4px; }
.macro-rows li { flex-wrap: wrap; row-gap: 4px; }
.macro-rows .ref-line { flex-basis: 100%; }
.nutrient-row .ref-line { grid-column: 2 / -1; }
.body-missing { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.lead-value.is-big { font-size: 28px; line-height: 1.2; }

.meal-flag { justify-self: start; font-size: 12px; font-weight: 600; color: var(--warn); background: var(--warn-soft); border-radius: 6px; padding: 1px 6px; }
.meal-kcal { display: grid; justify-items: end; align-content: start; }
.meal-kcal small { font-size: 12px; font-weight: 500; color: var(--warn); }
.estimate { display: grid; gap: var(--s2); padding-top: var(--s3); border-top: 1px dashed var(--dash); font-size: 14px; }
.estimate-total { font-weight: 600; }
.item-list li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.item-list small { font-size: 12px; color: var(--ink-2); overflow-wrap: anywhere; }
.item-list li[data-role="hidden"] { padding-left: 12px; }
.item-kcal { display: grid; justify-items: end; align-content: center; font-weight: 600; text-align: right; white-space: nowrap; }
.item-kcal small { font-weight: 500; }
.item-list li.is-unknown .item-kcal { color: var(--ink-2); }
.questions, .wide-box { display: grid; gap: 2px; padding: 8px 10px; border-radius: var(--radius-sm); }
.questions { background: var(--surface-2); }
.wide-box { background: var(--warn-soft); }
.wide-box strong { color: var(--warn); }

.source-rows { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); margin: 0; padding: 0; list-style: none; }
.source-rows li { display: flex; align-items: baseline; gap: 8px; }
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.week-strip li { display: grid; justify-items: center; gap: 2px; padding: 6px 0; border-radius: var(--radius-sm); border: 1.5px solid var(--line-strong); font-size: 14px; color: var(--ink-2); }
.week-strip li.is-trained { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.week-strip li.is-future { border-style: dashed; }
.week-strip small { font-size: 12px; }
.bars li { grid-template-columns: 64px minmax(0, 1fr) 52px 32px; gap: 8px; }

@media (max-width: 380px) { .energy-facts { grid-template-columns: minmax(0, 1fr); } }
/* 窄屏首屏要同时看到摄入、消耗和参考缺口：摄入通栏，消耗与缺口并排，明细更紧凑。 */
@media (max-width: 430px) {
  .energy-columns { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .energy-columns > .slots { display: contents; }
  .energy-intake { grid-column: 1 / -1; }
  .energy-columns [data-slot="burn"] { grid-column: 1; }
  .energy-columns [data-slot="balance"] { grid-column: 2; }
  .energy-intake .energy-facts, .energy-intake .wide-note { display: none; }
  .energy-facts-compact { display: block; margin: 0; font-size: 12px; color: var(--ink-2); }
  .energy .slot-note, .official { font-size: 12px; }
  .slot-value.is-big { font-size: 20px; }
  .card-hero.energy .official { padding: 2px 8px; margin: 0; }
  .card-hero.energy { gap: 8px; }
  .formula-basis { margin-top: 4px; }
}
@media (min-width: 1024px) {
  .overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .overview-grid > [data-card="energy"], .overview-grid > [data-card="training"] { grid-column: 1 / -1; }
  /* 左列摄入，右列消耗 + 参考缺口 */
  .energy-columns { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto 1fr; gap: var(--s3) var(--s5); align-items: start; }
  .energy-columns > .slots { display: contents; }
  .energy-intake { grid-column: 1; grid-row: 1 / span 2; }
  .energy-columns [data-slot="burn"] { grid-column: 2; grid-row: 1; }
  .energy-columns [data-slot="balance"] { grid-column: 2; grid-row: 2; }
  [data-card="training"] { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--s5); align-content: start; }
  [data-card="training"] > * { grid-column: 1; }
  [data-card="training"] > .card-head { grid-column: 1 / -1; }
  [data-card="training"] > .recovery-note { grid-column: 2; grid-row: 2 / span 3; border-top: 0; padding-top: 0; align-content: start; }
}

.ai-entry{margin:0.5rem 1rem;font-size:0.9rem}
noscript .ai-entry{margin:0.75rem 1rem;padding:0.5rem 0}
