/* 热量账本 自定义样式（在 Pico.css 之上）
   结构：设计变量 → 页面骨架（侧边栏 / 内容区）→ 通用组件 → 各页面。
   以电脑宽屏为主；窄屏只保证能用。 */

:root:not([data-theme=dark]) {
  --pico-font-size: 100%;          /* 取消 Pico 在大屏上的字号放大 */
  --pico-font-family: "Inter", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --pico-spacing: 0.9rem;
  --pico-form-element-spacing-vertical: 0.5rem;
  --pico-form-element-spacing-horizontal: 0.75rem;
  --pico-border-radius: 10px;
  --pico-background-color: #f4f6f9;
  --pico-color: #1c2430;
  --pico-h1-color: #111823;
  --pico-h2-color: #111823;
  --pico-h3-color: #1c2430;
  --pico-muted-color: #6b7686;
  --pico-muted-border-color: #e6e9ef;
  --pico-primary: #1f63d6;
  --pico-primary-background: #2468de;
  --pico-primary-border: #2468de;
  --pico-primary-underline: rgba(36, 104, 222, 0.35);
  --pico-primary-hover: #174fb0;
  --pico-primary-hover-background: #1b58c4;
  --pico-primary-hover-border: #1b58c4;
  --pico-primary-focus: rgba(36, 104, 222, 0.14);
  --pico-primary-inverse: #fff;
  --pico-secondary: #556070;
  --pico-secondary-border: #cfd5df;
  --pico-secondary-hover: #1c2430;
  --pico-card-background-color: #ffffff;
  --pico-card-border-color: #e6e9ef;
  --pico-card-box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.05);
  --pico-form-element-background-color: #ffffff;
  --pico-form-element-border-color: #d5dae3;
  --pico-form-element-active-background-color: #ffffff;
  --pico-table-border-color: #edf0f4;
  --pico-progress-background-color: #e9edf3;
  --pico-progress-color: var(--pico-primary-background);
  --ok-bg: #e6f6ec;
  --ok-fg: #17603a;
  --err-bg: #fdecec;
  --err-fg: #9a1f1f;
  --warn-bg: #fff4d6;
  --warn-fg: #7a5200;
  --danger: #d03b3b;
  --bar-bg: #ffffff;
  --hover-bg: #f1f4f9;
  --sidebar-width: 15rem;
  --tabbar-height: 3.4rem;
  --folder-bg: #fafbfd;          /* 文件夹标签页：选中标签和内容面板（同一张纸） */
  --folder-tab-bg: #e4e8ef;      /* 未选中的标签（后面的纸） */
  --folder-tab-hover: #edf0f5;
  --folder-border: #d9dee7;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --pico-font-size: 100%;
    --pico-font-family: "Inter", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
    --pico-spacing: 0.9rem;
    --pico-form-element-spacing-vertical: 0.5rem;
    --pico-form-element-spacing-horizontal: 0.75rem;
    --pico-border-radius: 10px;
    --pico-background-color: #0f1319;
    --pico-color: #e4e8ee;
    --pico-h1-color: #f3f5f8;
    --pico-h2-color: #f3f5f8;
    --pico-h3-color: #e4e8ee;
    --pico-muted-color: #97a1b0;
    --pico-muted-border-color: #262d38;
    --pico-primary: #7aa9f5;
    --pico-primary-background: #2e74e6;
    --pico-primary-border: #2e74e6;
    --pico-primary-underline: rgba(122, 169, 245, 0.4);
    --pico-primary-hover: #a3c4f9;
    --pico-primary-hover-background: #3f82ee;
    --pico-primary-hover-border: #3f82ee;
    --pico-primary-focus: rgba(84, 141, 235, 0.22);
    --pico-primary-inverse: #fff;
    --pico-card-background-color: #171c24;
    --pico-card-border-color: #262d38;
    --pico-card-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --pico-form-element-background-color: #12161d;
    --pico-form-element-border-color: #303846;
    --pico-table-border-color: #232a34;
    --pico-progress-background-color: #262d38;
    --pico-progress-color: var(--pico-primary-background);
    --ok-bg: #173a25;
    --ok-fg: #b6e8c6;
    --err-bg: #4a1c1c;
    --err-fg: #f6c1c1;
    --warn-bg: #4a3a10;
    --warn-fg: #f3dfa0;
    --danger: #e66767;
    --bar-bg: #131820;
    --hover-bg: #1d232d;
    --sidebar-width: 15rem;
    --tabbar-height: 3.4rem;
    --folder-bg: #131820;
    --folder-tab-bg: #1b212a;
    --folder-tab-hover: #222934;
    --folder-border: #2a323e;
  }
}

body { min-height: 100vh; }
h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 1rem; }
h2 { font-size: 1.05rem; font-weight: 650; margin-bottom: 0.6rem; }
.muted { color: var(--pico-muted-color); font-size: 0.9rem; }
h1 small.muted, h2 small.muted { font-weight: 400; font-size: 0.9rem; margin-left: 0.4rem; letter-spacing: 0; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- 页面骨架：左侧导航 + 内容区 ---------- */
main.container { max-width: 1320px; padding: 1.6rem 2rem 3rem; margin: 0; }
body.no-nav main.container { margin: 0 auto; }
body.has-nav { padding-left: var(--sidebar-width); }
body.has-nav main.container { margin: 0 auto; }

.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 20; width: var(--sidebar-width);
  display: flex; flex-direction: column; gap: 0.4rem; padding: 1.1rem 0.8rem 1rem;
  background: var(--bar-bg); border-right: 1px solid var(--pico-muted-border-color);
}
.brand {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.3rem 0.6rem 1rem;
  font-size: 1.1rem; font-weight: 700; text-decoration: none; color: var(--pico-h1-color);
}
.brand-mark {
  display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 9px;
  background: linear-gradient(135deg, #ff8a3d, #f0532d); color: #fff; flex: none;
}
.sidenav { display: flex; flex-direction: column; justify-content: flex-start; gap: 0.15rem; flex: 1; }
.sidenav a {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.7rem;
  border-radius: 9px; text-decoration: none; font-size: 0.95rem;
  color: var(--pico-muted-color); white-space: nowrap;
}
.sidenav a:hover { background: var(--hover-bg); color: var(--pico-color); }
.sidenav a[aria-current="page"] { color: var(--pico-primary); background: var(--pico-primary-focus); font-weight: 600; }
.sidenav .icon { flex: none; }
.logout-form { margin: 0; padding: 0.6rem 0.3rem 0; border-top: 1px solid var(--pico-muted-border-color); }
.link-button {
  width: auto; margin: 0; padding: 0.3rem 0.5rem; border: 0; background: none;
  color: var(--pico-muted-color); font-size: 0.9rem; box-shadow: none;
}
.link-button:hover { color: var(--pico-primary); background: none; }

/* 卡片：页面里的 <article> 一律是白底圆角卡片 */
article, .card {
  margin: 0 0 1.1rem; padding: 1.1rem 1.25rem; scroll-margin-top: 1rem;
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-card-border-color); border-radius: 14px;
  box-shadow: var(--pico-card-box-shadow);
}
a.card { display: block; text-decoration: none; color: var(--pico-color); transition: border-color .12s, box-shadow .12s; }
a.card:hover { border-color: var(--pico-primary-border); box-shadow: 0 0 0 3px var(--pico-primary-focus); }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1rem; margin-bottom: 1.1rem; }
.page-head h1 { margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.page-actions [role="button"] { padding: 0.45rem 0.95rem; font-size: 0.92rem; margin: 0; }

/* 中等宽度：侧边栏变成顶部一行 */
.tabbar { display: none; }
@media (max-width: 1000px) {
  body.has-nav { padding-left: 0; }
  main.container { padding: 1rem 1rem 2rem; }
  .sidebar {
    position: sticky; bottom: auto; width: auto; flex-direction: row; align-items: center;
    padding: 0.4rem 0.8rem; border-right: 0; border-bottom: 1px solid var(--pico-muted-border-color);
  }
  .brand { padding: 0.2rem 0.4rem; }
  .sidenav { flex-direction: row; overflow-x: auto; }
  .sidenav .icon { display: none; }
  .sidenav a { padding: 0.4rem 0.7rem; }
  .logout-form { padding: 0; border: 0; }
}
/* 手机：底部标签栏 */
@media (max-width: 640px) {
  .sidenav { display: none; }
  .sidebar { justify-content: space-between; }
  body.has-nav { padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: flex; height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bar-bg);
    border-top: 1px solid var(--pico-muted-border-color);
  }
  .tabbar a {
    flex: 1; display: flex; align-items: center; justify-content: center;
    text-decoration: none; font-size: 0.85rem; color: var(--pico-muted-color);
  }
  .tabbar a[aria-current="page"] { color: var(--pico-primary); font-weight: 600; }
}

/* ---------- 提示 ---------- */
.notice {
  display: block; padding: 0.5rem 0.75rem; margin-bottom: 0.8rem;
  border-radius: var(--pico-border-radius); font-size: 0.92rem;
}
.notice.ok { background: var(--ok-bg); color: var(--ok-fg); }
.notice.err { background: var(--err-bg); color: var(--err-fg); }
span.notice { display: inline-block; margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-height) + 1.2rem);
  transform: translateX(-50%); z-index: 50; max-width: min(90vw, 28rem);
  padding: 0.6rem 0.9rem; border-radius: var(--pico-border-radius);
  background: var(--err-bg); color: var(--err-fg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2); font-size: 0.92rem;
}

/* ---------- 表单 ---------- */
form { margin-bottom: 0; }
form button[type="submit"], .button-row button { width: auto; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.button-row button { margin-bottom: 0; }
.test-result { margin: 0.8rem 0 0; min-height: 1.2rem; }
.test-result:empty { display: none; }
fieldset.recommend {
  padding: 0.8rem; margin-bottom: 1rem;
  border: 1px dashed var(--pico-muted-border-color); border-radius: var(--pico-border-radius);
}
fieldset.recommend legend { padding: 0 0.4rem; font-size: 0.9rem; color: var(--pico-muted-color); }
fieldset.recommend button { width: auto; margin-bottom: 0; }

/* 设置 → 目标 → 减重计划 */
fieldset.goal-plan {
  padding: 0.8rem; margin-bottom: 1rem;
  border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius);
  background: transparent;
}
fieldset.goal-plan legend { padding: 0 0.4rem; font-size: 0.9rem; font-weight: 600; }
fieldset.goal-plan .notice { margin: 0.4rem 0; }
fieldset.goal-plan > p.muted { margin: 0.4rem 0; }
.plan-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.6rem;
  margin: 0.2rem 0 0.6rem;
}
.plan-cell {
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 0.6rem 0.75rem; background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color); border-radius: 8px;
}
.plan-cell .muted { font-size: 0.8rem; line-height: 1.35; }
.plan-label { font-size: 0.8rem; color: var(--pico-muted-color); }
.plan-value { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.plan-value small { font-size: 0.8rem; font-weight: 400; color: var(--pico-muted-color); }
.plan-suggest { border-color: var(--pico-primary-border); background: var(--pico-primary-focus); }
.plan-suggest button { width: auto; margin: 0.25rem 0 0; padding: 0.2rem 0.7rem; font-size: 0.85rem; }
label.inline-check { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }
.htmx-request button[type="submit"], button.htmx-request { opacity: 0.6; pointer-events: none; }
.htmx-indicator { font-size: 0.9rem; color: var(--pico-muted-color); }

.notice.warn { background: var(--warn-bg); color: var(--warn-fg); }
small.block { display: block; margin: -0.3rem 0 0.8rem; }
.back { margin-bottom: 0.4rem; font-size: 0.92rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1rem; }
.toolbar [role="button"] { padding: 0.45rem 0.9rem; }
button.small, [role="button"].small { padding: 0.3rem 0.7rem; font-size: 0.9rem; width: auto; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.danger-text { color: var(--danger); }
.icon-button {
  width: 2.2rem; height: 2.2rem; padding: 0; margin: 0; flex: none; line-height: 1;
  border: 1px solid var(--pico-muted-border-color); background: none; color: var(--pico-muted-color);
}
.inline-form { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-start; }
.inline-form .food-picker { flex: 1 1 14rem; }
.inline-form button { margin-bottom: 0; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block; padding: 0.05rem 0.4rem; margin-left: 0.2rem; vertical-align: middle;
  border-radius: 999px; font-size: 0.72rem; font-weight: 500; line-height: 1.5;
  background: var(--pico-muted-border-color); color: var(--pico-color);
}
.tag.ai { background: var(--warn-bg); color: var(--warn-fg); }
.tag.recipe { background: var(--ok-bg); color: var(--ok-fg); }

/* ---------- 食物选择器 ---------- */
.food-picker { position: relative; min-width: 0; }
.food-picker input[type="search"] { margin-bottom: 0; }
.picker-results {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 30;
  max-height: 18rem; overflow-y: auto;
  background: var(--pico-card-background-color); color: var(--pico-color);
  border-radius: var(--pico-border-radius);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.picker-results:empty { display: none; }
.picker-results .pick {
  display: flex; justify-content: space-between; align-items: center; gap: 0.6rem;
  width: 100%; margin: 0; padding: 0.55rem 0.75rem; text-align: left;
  border: 0; border-bottom: 1px solid var(--pico-muted-border-color); border-radius: 0;
  /* Pico 在 button 上把 --pico-color 改成了白色（主按钮的反色）：这里改回外层的文字色，里面的标签也跟着正常 */
  --pico-color: inherit; background: none; color: inherit; box-shadow: none;
}
.picker-results .pick:last-child { border-bottom: 0; }
.picker-results .pick:hover, .picker-results .pick:focus { background: var(--pico-primary-focus); }
.picker-results .pick small { color: var(--pico-muted-color); white-space: nowrap; }
.picker-empty { margin: 0; padding: 0.6rem 0.75rem; font-size: 0.9rem; color: var(--pico-muted-color); }

.grams-field { display: inline-flex; align-items: center; gap: 0.3rem; flex: none; }
.grams-field input { width: 6rem; margin-bottom: 0; text-align: right; }
.grams-field .unit { color: var(--pico-muted-color); }

/* ---------- 食物库 ---------- */
.empty { padding: 1rem 0.2rem; }
.nutri-grid { grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); }

/* ---------- 菜谱 ---------- */
.recipe-rows { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.6rem; }
.recipe-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.recipe-row .food-picker { flex: 1 1 10rem; }
.row-note { flex-basis: 100%; }
.cooked-weight { margin-top: 1rem; }
.recipe-preview { margin: 0.5rem 0 1rem; overflow-x: auto; }
.recipe-preview:empty { display: none; }
.preview-table { margin-bottom: 0.5rem; font-size: 0.9rem; }
.preview-table th, .preview-table td { padding: 0.35rem 0.5rem; white-space: nowrap; }
.preview-table tr.result th, .preview-table tr.result td { font-weight: 600; color: var(--pico-primary); }

/* ---------- 每日饮食 ---------- */
.day-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 0.8rem; }
.day-nav h1 { margin: 0; font-size: 1.3rem; }
.day-title { flex: 1; min-width: 9rem; text-align: center; }
.day-nav [role="button"] { margin: 0; font-size: 1.1rem; line-height: 1; }
.day-input { width: auto; margin: 0; padding: 0.3rem 0.5rem; height: auto; font-size: 0.9rem; }
.today-link { font-size: 0.9rem; }

.summary-kcal { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.3rem 1rem; }
.summary .big { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.summary progress { margin: 0.4rem 0 0.2rem; height: 0.5rem; }
progress.over { --pico-progress-color: var(--danger); }
.over { color: var(--danger); }
.macro-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.9rem; margin-top: 0.9rem; }
.macro-head { display: flex; justify-content: space-between; gap: 0.3rem; font-size: 0.92rem; }
.macro-foot { font-size: 0.8rem; }
@media (max-width: 520px) {
  .macro-grid { grid-template-columns: 1fr; gap: 0.6rem; }
}

/* ---------- 图表 ----------
   配色取自经过色觉障碍校验的参考调色板：浅色 / 深色各一套，按固定顺序使用。 */
.viz-root {
  --viz-surface: #ffffff;
  --viz-text: #111823;
  --viz-text-secondary: #556070;
  --viz-muted: #8a94a3;
  --viz-grid: #edf0f4;
  --viz-axis: #d5dae3;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .viz-root {
    --viz-surface: #171c24;
    --viz-text: #f3f5f8;
    --viz-text-secondary: #c2c9d4;
    --viz-muted: #8a94a3;
    --viz-grid: #232a34;
    --viz-axis: #303846;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #0ca30c;
    --series-7: #9085e9;
    --series-8: #e66767;
  }
}
.chart-box { position: relative; height: 290px; }
.chart-note { margin: 0.6rem 0 0; font-size: 0.82rem; }
@media (max-width: 520px) { .chart-box { height: 240px; } }

.swatch { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 2px; margin: 0 0.2rem 0 0.3rem; vertical-align: -0.05rem; }
.swatch.s1 { background: var(--series-1); }
.swatch.s2 { background: var(--series-2); }
.swatch.s3 { background: var(--series-3); }
.data-table.summary-table th, .data-table.summary-table td { white-space: normal; }
.data-table.summary-table tbody th { font-weight: 500; text-align: left; }
/* Pico 的 nav 默认两端对齐，这里的几组链接都改成靠左排列 */
.range-row, .section-links { justify-content: flex-start; }
.range-row .day-input { margin-left: auto; }
[role="button"][aria-disabled="true"] { opacity: 0.35; pointer-events: none; }

.range-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; margin-bottom: 0.8rem; }
.range-row a {
  padding: 0.25rem 0.8rem; border-radius: 999px; text-decoration: none; font-size: 0.88rem;
  color: var(--pico-muted-color); border: 1px solid var(--pico-muted-border-color);
  background: var(--pico-card-background-color);
}
.range-row a:hover { color: var(--pico-color); border-color: var(--pico-secondary-border); }
.range-row a[aria-current="true"] {
  color: var(--pico-primary-inverse); background: var(--pico-primary-background); border-color: var(--pico-primary-background);
}

/* ---------- 数字卡片 ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1rem; margin-bottom: 1.1rem; }
.stat {
  padding: 0.85rem 1rem; border-radius: 14px;
  background: var(--pico-card-background-color); border: 1px solid var(--pico-card-border-color);
  box-shadow: var(--pico-card-box-shadow);
}
.stat-label { font-size: 0.8rem; color: var(--pico-muted-color); }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.25; }
.stat-value.small { font-size: 1.15rem; padding-top: 0.3rem; }
.stat-value small { font-size: 0.85rem; font-weight: 400; color: var(--pico-muted-color); }

.stat-foot { font-size: 0.8rem; margin-top: 0.15rem; }
.stat progress { margin: 0.35rem 0 0.1rem; height: 0.4rem; }
a.stat-link { display: block; text-decoration: none; color: var(--pico-color); }
a.stat-link:hover { outline: 2px solid var(--pico-primary-focus); }
.section-title { margin: 1.4rem 0 0.6rem; }
.plain-list { padding-left: 1.1rem; margin-bottom: 0; }
.plain-list li { margin-bottom: 0.5rem; }
.plain-list .notice { display: inline-block; margin: 0.3rem 0 0; }

/* 迷你趋势图 */
.spark svg { display: block; width: 100%; height: 2.6rem; margin: 0.4rem 0 0.2rem; overflow: visible; }
.spark-bar { fill: var(--series-1); opacity: 0.55; }
.spark-bar.last { opacity: 1; }
.spark-target { stroke: var(--viz-text-secondary); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.spark-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark-dot { fill: var(--series-1); stroke: var(--pico-card-background-color); stroke-width: 2; }

/* AI 生成的内容 */
.ai-box .markdown h2 { font-size: 1rem; margin: 1rem 0 0.3rem; }
.ai-box .markdown h3 { font-size: 0.95rem; margin: 0.8rem 0 0.3rem; }
.ai-box .markdown p, .ai-box .markdown li { font-size: 0.95rem; }
.ai-box .markdown ul, .ai-box .markdown ol { padding-left: 1.2rem; }
.ai-box .markdown table { font-size: 0.9rem; }
.ai-box .button-row { margin-top: 0.6rem; }

/* ---------- 数据表 ---------- */
.table-wrap { overflow-x: auto; }
.data-table { margin: 0; font-size: 0.92rem; }
.data-table th, .data-table td { padding: 0.5rem 0.7rem; white-space: nowrap; }
.data-table thead th { font-size: 0.82rem; font-weight: 600; color: var(--pico-muted-color); }
.data-table tbody tr:hover td, .data-table tbody tr:hover th { background: var(--hover-bg); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .link-button { font-size: 0.85rem; padding: 0; }

.data-table td.wrap { white-space: normal; min-width: 12rem; }

/* ---------- 运动 ---------- */
.exercise-kcal { white-space: nowrap; }
details.calc { margin: 0.4rem 0 0; padding: 0; border: 0; font-size: 0.85rem; }
details.calc summary { color: var(--pico-muted-color); cursor: pointer; }
details.calc ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }
details.calc li { margin-bottom: 0.2rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.4rem; }

/* ---------- 体重 ---------- */
.weight-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.7rem; }
.weight-form label { flex: 1 1 9rem; margin: 0; }
.weight-form input { margin-bottom: 0; }
.weight-form button { width: auto; margin: 0; }
.weight-form + small { display: block; margin-top: 0.5rem; }

/* ---------- 快速录入 ---------- */
.quick textarea { margin-bottom: 0.5rem; resize: vertical; min-height: 3.4rem; }
.quick-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.quick-row select { width: auto; margin: 0; }
.quick-row button { width: auto; margin: 0; }
.quick-row label.quick-meal { display: flex; align-items: center; gap: 0.4rem; margin: 0; white-space: nowrap; }
.quick small { display: block; margin-top: 0.5rem; }
.quick-confirm { border: 2px solid var(--pico-primary); }
.quick-item {
  padding: 0.7rem 0.8rem; margin-bottom: 0.7rem;
  border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius);
}
.quick-item.has-error { border-color: var(--danger); }
.quick-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; }
.quick-include { flex: 1; min-width: 8rem; margin: 0; font-size: 1rem; }
.quick-head .grams-field input { width: 5.5rem; padding: 0.3rem 0.5rem; height: auto; }
.quick-item .notice { margin: 0.5rem 0 0; }
.quick-match { margin: 0.4rem 0 0; font-size: 0.92rem; }
.quick-choices { margin: 0.5rem 0 0; padding: 0; border: 0; }
.quick-choices legend { font-size: 0.9rem; color: var(--pico-muted-color); margin-bottom: 0.3rem; }
.quick-choices label { display: block; margin-bottom: 0.25rem; }
.quick-new { margin-top: 0.5rem; }
.quick-new > .muted { margin-bottom: 0.5rem; }

.meal-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.2rem 1rem; }
.meal-head h2 { margin-bottom: 0.4rem; }
.meal-head .muted { font-size: 0.85rem; }
.entries { padding: 0; margin: 0 0 0.8rem; }
.entry { list-style: none; padding: 0.5rem 0; border-bottom: 1px solid var(--pico-muted-border-color); }
.entry-main { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; }
.entry-name { min-width: 0; overflow-wrap: anywhere; }
.entry-name a { text-decoration: none; }
.entry .grams-field input { width: 5.2rem; padding: 0.3rem 0.5rem; height: auto; }
.entry-sub { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 0.2rem 1rem; margin-top: 0.2rem; font-size: 0.85rem; }
.entry-actions { display: flex; align-items: flex-start; gap: 0.6rem; margin-left: auto; }
.entry-actions .link-button { font-size: 0.85rem; padding: 0; }
details.swap { margin: 0; padding: 0; border: 0; }
details.swap summary { font-size: 0.85rem; color: var(--pico-muted-color); list-style: none; cursor: pointer; }
details.swap summary::after { display: none; }
details.swap summary::-webkit-details-marker { display: none; }
details.swap[open] { flex-basis: 100%; }
details.swap[open] .food-picker { margin-top: 0.4rem; min-width: 14rem; }
/* 拖动记录到另一餐 */
.drag-handle { flex: none; cursor: grab; color: var(--pico-muted-color); font-size: 1.05rem; line-height: 1; padding: 0.15rem 0.1rem; margin-right: -0.2rem; user-select: none; opacity: 0.55; }
.entry:hover .drag-handle { opacity: 1; }
.drag-handle:active { cursor: grabbing; }
.entry-main .entry-name { flex: 1; }
.entry.dragging { opacity: 0.45; }
article.meal { transition: box-shadow 0.12s, background-color 0.12s; }
article.meal.drop-target { box-shadow: 0 0 0 2px var(--pico-primary); background-color: color-mix(in srgb, var(--pico-primary) 6%, var(--pico-card-background-color)); }
details.swap.move[open] { flex-basis: auto; }
.move-choices { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.35rem; }
.move-choices .chip { font-size: 0.8rem; }
.add-entry { display: flex; align-items: flex-start; gap: 0.5rem; }
.add-entry .food-picker { flex: 1; }
.add-entry button { width: auto; margin: 0; padding-left: 0.9rem; padding-right: 0.9rem; white-space: nowrap; }
.copy-button { margin-top: 0.6rem; padding: 0; font-size: 0.88rem; color: var(--pico-primary); }
@media (max-width: 420px) {
  .add-entry { flex-wrap: wrap; }
  .add-entry .food-picker { flex-basis: 100%; }
  .add-entry .grams-field { flex: 1; }
  .add-entry .grams-field input { width: 100%; }
}

/* ---------- 登录 / 首次设置 ---------- */
.auth-card { max-width: 24rem; margin: 12vh auto 0; padding: 1.6rem; }
.auth-card button[type="submit"] { width: 100%; }

/* ---------- 设置页 ---------- */
.section-links { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin-bottom: 1rem; font-size: 0.92rem; }
.version { text-align: center; }

/* ---------- 首页清单 ---------- */
.checklist { padding-left: 0; }
.checklist li { list-style: none; display: flex; gap: 0.5rem; align-items: baseline; }
.checklist .check { width: 1.2rem; text-align: center; }
.checklist .done { color: var(--pico-muted-color); }
.checklist .done .check { color: var(--ok-fg); }

/* 围度 */
.measure-form label { flex: 1 1 6.5rem; }
.measure-stats { margin-top: 1.1rem; }
.stat-sub { font-size: 0.8rem; }

/* ====================== 仪表盘 ====================== */

/* 今日四个数 */
.kpi-row { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.kpi-row .card { margin: 0; }
.kpi-label { font-size: 0.85rem; color: var(--pico-muted-color); }
.kpi-value { color: var(--pico-h1-color); font-size: 2rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.02em; margin-top: 0.15rem; }
.kpi-value small { font-size: 0.9rem; font-weight: 400; letter-spacing: 0; color: var(--pico-muted-color); }
.kpi-foot { font-size: 0.85rem; margin-top: 0.2rem; }
a.kpi-hero { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.kpi-hero .kpi-value { font-size: 2.6rem; }

.ring { flex: none; }
.ring circle { fill: none; stroke-width: 8; }
.ring-track { stroke: var(--pico-progress-background-color); }
.ring-fill { stroke: var(--pico-primary-background); stroke-linecap: round; }
.ring.over .ring-fill { stroke: var(--danger); }
.ring text { font-size: 15px; font-weight: 700; fill: var(--pico-h1-color); }

/* 今日：营养素 / 饮水 / 钠 */
.tile-row { display: grid; grid-template-columns: minmax(0, 3fr) minmax(15rem, 1fr); gap: 1rem; margin-bottom: 1.4rem; }
.tile-row .card { margin: 0; }
.tile-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.5rem; }
.tile-head h2 { margin: 0; }
.tile-head .muted, .more { font-size: 0.85rem; }
.more { text-decoration: none; white-space: nowrap; }
.tile-value { font-size: 1.7rem; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
.tile-value small { font-size: 0.9rem; font-weight: 400; color: var(--pico-muted-color); }
.tile-foot { font-size: 0.85rem; margin-top: 0.35rem; }
.tile-note { font-size: 0.8rem; margin: 0.5rem 0 0; }
.tile .notice { margin: 0 0 0.5rem; }

/* 进度条：填充是数据色，轨道是同一色的浅色 */
.meter { height: 8px; border-radius: 999px; overflow: hidden; margin-top: 0.45rem; background: var(--pico-progress-background-color); }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--pico-primary-background); }
.meter.m-protein > span, .meter.water > span { background: #2a78d6; }
.meter.m-fat > span { background: #eb6834; }
.meter.m-carbs > span { background: #1baf7a; }
.meter.sodium > span { background: #6250d6; }
.meter.over > span { background: var(--danger); }

.chip-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.8rem; }
button.chip {
  width: auto; margin: 0; padding: 0.3rem 0.7rem; font-size: 0.85rem; border-radius: 999px;
  background: var(--pico-primary-focus); color: var(--pico-primary); border: 1px solid transparent; box-shadow: none;
}
button.chip:hover { border-color: var(--pico-primary-border); }
button.chip.ghost { background: none; color: var(--pico-muted-color); border-color: var(--pico-muted-border-color); }

/* 趋势区 */
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin-bottom: 0.8rem; }
.section-head .section-title { margin: 0; font-size: 1.2rem; }
.section-head .range-row { margin: 0; }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.1rem; }
.chart-grid .card { margin: 0; min-width: 0; }
.chart-grid .span-2 { grid-column: 1 / -1; }
.chart-sub { margin: 0 0 0.7rem; font-size: 0.86rem; }
.chart-projection { margin: -0.4rem 0 0.7rem; font-size: 0.86rem; font-weight: 500; }

.mini-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1.4rem; margin-top: 0.4rem; }
.mini-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.mini-label { font-size: 0.9rem; color: var(--pico-muted-color); }
.mini-value { font-size: 1.35rem; font-weight: 700; }
.mini-value small { font-size: 0.8rem; font-weight: 400; color: var(--pico-muted-color); }
.mini-sub { font-size: 0.8rem; }
.chart-box.mini-box { height: 120px; margin-top: 0.4rem; }

@media (max-width: 1180px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .tile-row { grid-template-columns: 1fr; }
  .side-tiles { flex-direction: row; }
}
@media (max-width: 760px) {
  .chart-grid, .kpi-row, .tile-row { grid-template-columns: 1fr; }
}

/* 首页：三大营养素（主）+ 右侧饮水 / 钠（次） */
.macro-card { padding: 1.3rem 1.5rem 1.4rem; }
.macro-big { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2.2rem; margin-top: 0.6rem; }
.macro-name { display: flex; align-items: center; gap: 0.45rem; font-size: 0.95rem; color: var(--pico-muted-color); }
.dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; flex: none; }
.dot.m-protein { background: #2a78d6; }
.dot.m-fat { background: #eb6834; }
.dot.m-carbs { background: #1baf7a; }
.macro-num { font-size: 2.5rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; color: var(--pico-h1-color); margin-top: 0.2rem; }
.macro-num small { font-size: 1rem; font-weight: 400; letter-spacing: 0; color: var(--pico-muted-color); }
.meter.thick { height: 12px; margin-top: 0.6rem; }
.macro-meta { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 0.5rem; font-size: 0.92rem; font-weight: 600; }
.macro-meta .muted { font-weight: 400; }
.macro-share { font-size: 0.82rem; margin-top: 0.15rem; }
.side-tiles { display: flex; flex-direction: column; gap: 1rem; }
.side-tiles .card { margin: 0; flex: 1; padding: 0.9rem 1.1rem; }
.side-tiles .tile-value { font-size: 1.4rem; }
@media (max-width: 760px) {
  .macro-big { grid-template-columns: 1fr; gap: 1.2rem; }
  .side-tiles { flex-direction: column; }
}

/* 饮食页的饮水条 */
.water-bar-main { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1.2rem; }
.water-bar-info { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.9rem; }
.water-bar-info h2 { margin: 0; }
.water-bar-value strong { font-size: 1.3rem; }
.water-bar .chip-row { margin: 0; align-items: center; }
.water-total { display: flex; align-items: center; gap: 0.4rem; margin: 0 0 0 0.4rem; }
.water-total input { width: 8rem; margin: 0; padding: 0.3rem 0.6rem; height: auto; font-size: 0.85rem; }
.macro-card { display: flex; flex-direction: column; }
.macro-big { flex: 1; align-content: center; }

/* ---------- 运动页：汇总、按天分组 ---------- */
.exercise-top { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.exercise-top article { margin-bottom: 1rem; }
.summary-figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 0.3rem 0 0.9rem; }
.summary-figures .stat-value { font-size: 1.45rem; }
.share-table { margin: 0; font-size: 0.9rem; }
.share-table th, .share-table td { padding: 0.28rem 0.5rem; border: 0; background: none; white-space: nowrap; }
.share-table th { width: 3.2rem; padding-left: 0; font-weight: 500; color: var(--pico-muted-color); }
.share-table .num { width: 1%; text-align: right; font-variant-numeric: tabular-nums; }
.share-table .share-bar { width: auto; }
.share-bar span { display: block; height: 8px; border-radius: 999px; background: var(--series-3); }
.chart-box.short { height: 220px; }
.exercise-day + .exercise-day { margin-top: 0.9rem; }
.exercise-day-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.2rem 1rem;
  padding: 0.45rem 0.8rem; border-radius: 10px; background: var(--hover-bg); font-size: 0.92rem;
}
.exercise-day-head .day-kcal { color: var(--pico-color); font-size: 1.02rem; }
.exercise-day .entries { margin: 0; padding: 0 0.8rem; }
.exercise-day .entry:last-child { border-bottom: 0; }
.load-more { display: block; width: auto; margin: 1rem auto 0; }
@media (max-width: 900px) { .exercise-top { grid-template-columns: 1fr; } }
.exercise-day .entry-main { gap: 0.4rem 1rem; }
.exercise-day .entry-name { flex: none; }
.exercise-meta { flex: 1; min-width: 0; font-size: 0.85rem; }
.exercise-day .entry-main .link-button { font-size: 0.85rem; padding: 0; }
.exercise-day details.calc { margin-top: 0.15rem; }
.exercise-day details.calc summary { display: inline-block; }
.exercise-day details.calc summary::after { display: none; }

/* ---------- 月历：每天一格（运动页、体重页） ---------- */
.month-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem 1rem; margin-bottom: 0.8rem; }
.month-nav { display: flex; align-items: center; gap: 0.6rem; }
.month-nav h2 { margin: 0; min-width: 8.2rem; text-align: center; }
.month-nav [role="button"] { margin: 0; font-size: 1.1rem; line-height: 1; }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.month-weekday { padding: 0.1rem 0.5rem 0.2rem; font-size: 0.78rem; color: var(--pico-muted-color); }
.month-cell {
  display: flex; flex-direction: column; gap: 0.1rem; min-height: 6.6rem; padding: 0.4rem 0.55rem 0.5rem;
  border: 1px solid var(--pico-muted-border-color); border-radius: 10px;
  /* Pico 把链接的 --pico-color 改成了主色，这里改回正文颜色 */
  --pico-color: inherit; background: var(--pico-card-background-color); color: inherit; text-decoration: none; overflow: hidden;
}
.month-cell.out { border-color: transparent; background: none; }
.month-cell.future { opacity: 0.4; }
a.month-cell:hover { border-color: var(--pico-primary-border); }
.month-cell.has { background: var(--cell-tint); border-color: var(--cell-tint-border); }
.month-cell.selected { border-color: var(--pico-primary-background); box-shadow: 0 0 0 2px var(--pico-primary-focus); }
.cell-num { font-size: 0.8rem; color: var(--pico-muted-color); }
.month-cell.today .cell-num { color: var(--pico-primary); font-weight: 700; }
.cell-main { font-size: 1.12rem; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.cell-main small { font-size: 0.72rem; font-weight: 400; color: var(--pico-muted-color); }
.cell-line, .cell-sub { font-size: 0.78rem; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-sub { color: var(--pico-muted-color); margin-top: auto; }
.month-grid.exercise-cells { --cell-tint: rgba(27, 175, 122, 0.09); --cell-tint-border: rgba(27, 175, 122, 0.35); }
.month-grid.weight-cells { --cell-tint: rgba(98, 80, 214, 0.08); --cell-tint-border: rgba(98, 80, 214, 0.32); }
.month-grid.weight-cells .month-cell { min-height: 5.4rem; }
.day-detail { margin-top: 1rem; }
.day-detail .entries { margin: 0; padding: 0 0.8rem; }
.day-detail .entry:last-child { border-bottom: 0; }
.day-line { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.3rem 1rem; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--pico-muted-border-color); }
.day-line:last-child { border-bottom: 0; }
.day-line .link-button { font-size: 0.85rem; padding: 0; }
@media (max-width: 760px) {
  .month-cell, .month-grid.weight-cells .month-cell { min-height: 4.2rem; padding: 0.3rem; }
  .cell-line { display: none; }
  .cell-main { font-size: 0.9rem; }
}
/* 手机上一格只有约 45px：数字不折行，单位省掉（"81.3" 不再被拆成两行） */
@media (max-width: 520px) {
  .month-grid { gap: 3px; }
  .month-cell, .month-grid.weight-cells .month-cell { padding: 0.25rem 0.15rem; }
  .cell-main { font-size: 0.8rem; white-space: nowrap; letter-spacing: -0.02em; }
  .cell-main small, .cell-num small { display: none; }
}
.girth-item { margin-left: 0.9rem; white-space: nowrap; }

/* ---------- 日期月历弹层（static/js/datepicker.js） ---------- */
input.date-input {
  cursor: pointer; font-variant-numeric: tabular-nums; padding-right: 2.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a94a3' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='5' width='17' height='15' rx='2.5'/%3E%3Cpath d='M3.5 10h17M8 3v4M16 3v4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.7rem center; background-size: 1.1rem;
}
input.date-input.day-input { width: 9.2rem; padding-right: 2rem; background-position: right 0.5rem center; background-size: 1rem; }
.date-pop {
  position: absolute; z-index: 60; width: 19.5rem; padding: 0.8rem;
  border-radius: 14px; border: 1px solid var(--pico-muted-border-color);
  background: var(--pico-card-background-color); color: var(--pico-color);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.date-pop button { --pico-color: inherit; width: auto; margin: 0; padding: 0; border: 0; background: none; color: inherit; box-shadow: none; }
.date-pop-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.date-pop-head strong { font-size: 0.98rem; }
.date-pop .date-pop-nav { width: 2rem; height: 2rem; border-radius: 8px; font-size: 1.15rem; line-height: 1; color: var(--pico-muted-color); }
.date-pop .date-pop-nav:hover:not(:disabled) { background: var(--hover-bg); color: var(--pico-color); }
.date-pop-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.date-pop-weekday { padding: 0.2rem 0; text-align: center; font-size: 0.74rem; color: var(--pico-muted-color); }
.date-pop .date-pop-day {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 2.5rem; border-radius: 9px; font-size: 0.9rem; font-variant-numeric: tabular-nums;
}
.date-pop .date-pop-day:hover:not(:disabled) { background: var(--hover-bg); }
.date-pop .date-pop-day:focus-visible { outline: 2px solid var(--pico-primary-background); outline-offset: -2px; }
.date-pop .date-pop-day.today { font-weight: 700; color: var(--pico-primary); }
.date-pop .date-pop-day.selected { background: var(--pico-primary-background); color: #fff; }
.date-pop button:disabled { opacity: 0.3; cursor: default; }
.date-pop-marks { display: flex; align-items: center; justify-content: center; gap: 3px; height: 6px; }
.mark-food, .mark-exercise { display: inline-block; box-sizing: border-box; flex: none; }
.mark-food { width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid #2a78d6; }
.mark-food.complete { background: #2a78d6; }
.mark-exercise { width: 9px; height: 3px; border-radius: 2px; background: #1baf7a; }
.date-pop-day.selected .mark-food { border-color: #fff; }
.date-pop-day.selected .mark-food.complete, .date-pop-day.selected .mark-exercise { background: #fff; }
.date-pop-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px solid var(--pico-muted-border-color); }
.date-pop-legend { display: flex; align-items: center; font-size: 0.74rem; color: var(--pico-muted-color); white-space: nowrap; }
.date-pop-legend i { margin: 0 0.25rem 0 0.6rem; }
.date-pop-legend i:first-child { margin-left: 0; }
.date-pop .date-pop-today { padding: 0.2rem 0.7rem; border-radius: 999px; font-size: 0.82rem; color: var(--pico-primary); background: var(--pico-primary-focus); }

/* ---------- 周期回顾 ---------- */
.notice.info { background: var(--pico-primary-focus); color: var(--pico-color); }
.adherence-row .stat-value small { font-size: 0.9rem; }
.adherence-row .meter { margin: 0.35rem 0 0.4rem; }
.review-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.review-grid article { margin-bottom: 1rem; }
.summary-table td small { margin-left: 0.25rem; }
.ai-link { margin: 0.9rem 0 0; font-size: 0.92rem; }
@media (max-width: 1100px) { .review-grid { grid-template-columns: 1fr; } }

/* ---------- AI 总结页 ---------- */
.home-ai-line { margin: 0.4rem 0 0; font-size: 0.9rem; text-align: right; }
.ai-targets { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.ai-targets form { margin: 0; }
button.ai-target {
  --pico-color: inherit; display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem;
  width: auto; margin: 0; padding: 0.55rem 0.9rem; text-align: left; border-radius: 12px; box-shadow: none;
  background: var(--pico-card-background-color); color: var(--pico-color); border: 1px solid var(--pico-muted-border-color);
}
button.ai-target:hover:not(:disabled) { border-color: var(--pico-primary-border); background: var(--pico-primary-focus); }
button.ai-target.asked { border-color: var(--pico-primary-background); }
button.ai-target strong { font-size: 0.95rem; }
button.ai-target small { font-size: 0.78rem; color: var(--pico-muted-color); }
.ai-layout { display: grid; grid-template-columns: 22rem minmax(0, 1fr); gap: 1rem; align-items: start; }
.ai-layout .ai-list, .ai-layout .ai-detail { margin: 0; }
.ai-list { padding: 0.9rem 0.7rem; max-height: calc(100vh - 3rem); overflow-y: auto; position: sticky; top: 1rem; }
.ai-list .range-row { padding: 0 0.3rem; }
.ai-items { margin: 0; padding: 0; }
.ai-items li { list-style: none; margin: 0 0 2px; }
a.ai-item {
  --pico-color: inherit; display: flex; flex-direction: column; gap: 0.2rem; padding: 0.6rem 0.7rem;
  border-radius: 10px; border: 1px solid transparent; color: var(--pico-color); text-decoration: none;
}
a.ai-item:hover { background: var(--hover-bg); }
a.ai-item.selected { background: var(--pico-primary-focus); border-color: var(--pico-primary-border); }
.ai-item-head { display: flex; align-items: center; gap: 0.4rem; font-size: 0.92rem; }
.ai-item-head .tag { margin-left: 0; }
.ai-item-preview {
  font-size: 0.82rem; line-height: 1.45; color: var(--pico-muted-color);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ai-item-meta { font-size: 0.74rem; color: var(--pico-muted-color); }
.tag.kind-weekly { background: var(--ok-bg); color: var(--ok-fg); }
.tag.kind-monthly { background: var(--warn-bg); color: var(--warn-fg); }
.ai-detail .tile-head h2 small { font-size: 0.85rem; font-weight: 400; }
.ai-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-top: 0.8rem; }
.ai-actions form { margin: 0; }
.ai-actions a { margin-left: auto; font-size: 0.9rem; }
button.danger-outline { color: var(--danger); border-color: var(--danger); }
.ai-input { max-height: 22rem; overflow: auto; margin: 0.5rem 0 0; padding: 0.7rem; font-size: 0.78rem; border-radius: 10px; background: var(--hover-bg); }
@media (max-width: 900px) {
  .ai-layout { grid-template-columns: 1fr; }
  .ai-list { position: static; max-height: 18rem; }
}

/* ---------- 食物库表格 ---------- */
.food-filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 0.8rem;
  padding: 0.8rem 1rem; margin-bottom: 1rem;
}
.food-filters input[type=search] { flex: 1 1 16rem; margin: 0; }
.food-filters select { width: auto; margin: 0; }
.food-filters .inline-check { margin: 0; white-space: nowrap; }
.food-table-card { padding: 0; margin-bottom: 1rem; overflow: hidden; }
.table-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem;
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--pico-muted-border-color); font-size: 0.88rem;
}
.bulk-bar { display: flex; gap: 0.4rem; align-items: center; }
.bulk-bar select { width: auto; margin: 0; padding-top: 0.3rem; padding-bottom: 0.3rem; font-size: 0.85rem; }
.bulk-bar button { width: auto; margin: 0; padding: 0.3rem 0.8rem; font-size: 0.85rem; }
.food-table { margin: 0; font-size: 0.9rem; }
.food-table th, .food-table td { padding: 0.5rem 0.7rem; vertical-align: middle; }
.food-table thead th { font-size: 0.8rem; font-weight: 600; color: var(--pico-muted-color); white-space: nowrap; }
.food-table th a { --pico-color: inherit; color: inherit; text-decoration: none; }
.food-table th.sorted a { color: var(--pico-primary); }
.food-table .sort-mark { margin-left: 0.2rem; }
.food-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.food-table td.name a { --pico-color: inherit; color: inherit; font-weight: 500; text-decoration: none; }
.food-table td.name a:hover { color: var(--pico-primary); }
.food-table td.name small { display: block; }
.food-table tbody tr:hover { background: var(--hover-bg); }
.food-table .check { width: 2.2rem; }
.food-table .check input { margin: 0; }
.food-table .star-col { width: 2rem; padding-left: 0; padding-right: 0; text-align: center; }
.food-table .empty { text-align: center; padding: 2rem 1rem; }
button.star {
  --pico-color: inherit; width: auto; margin: 0; padding: 0 0.2rem; border: 0; background: none; box-shadow: none;
  color: var(--pico-muted-color); font-size: 1.05rem; line-height: 1; cursor: pointer;
}
button.star.on { color: #e0a100; }
button.star:hover, button.star:focus { background: none; color: #e0a100; }
h1 button.star { font-size: 1.4rem; vertical-align: 0.1em; }
.picker-results .fav { color: #e0a100; margin-right: 0.2rem; }
.tag.shikaka { background: #e8eefc; color: #2c4a8a; }
.tag.off { background: var(--err-bg); color: var(--err-fg); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tag.shikaka { background: #22304d; color: #a9c1f2; }
}
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; padding: 0.7rem 1rem;
  border-top: 1px solid var(--pico-muted-border-color); font-size: 0.88rem; }
.pager a { --pico-color: inherit; color: inherit; padding: 0.15rem 0.55rem; border-radius: 6px; text-decoration: none; }
.pager a:hover { background: var(--hover-bg); }
.pager a[aria-current] { background: var(--pico-primary-background); color: #fff; }
.pager .muted { margin-left: auto; }

/* 食物编辑页：常用份量 */
fieldset.portions {
  padding: 0.8rem; margin: 0.5rem 0 1rem;
  border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius);
}
fieldset.portions legend { padding: 0 0.4rem; font-size: 0.9rem; font-weight: 600; }
fieldset.portions > p { margin: 0 0 0.6rem; font-size: 0.85rem; }
.portion-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; max-width: 28rem; }
.portion-row input { margin: 0; }
.portion-row input[name=portion_label] { flex: 1.4; }
.portion-row input[name=portion_grams] { flex: 1; }
.portion-row .eq, .portion-row .unit { color: var(--pico-muted-color); }

/* 饮食页逐条添加：常用份量按钮 */
.portion-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; flex-basis: 100%; }
.portion-chips:empty { display: none; }
.portion-chips .chip {
  --pico-color: inherit; width: auto; margin: 0; padding: 0.15rem 0.6rem; font-size: 0.82rem;
  border: 1px solid var(--pico-primary-border); border-radius: 999px;
  background: var(--pico-primary-focus); color: var(--pico-primary);
}
.portion-chips .chip:hover { background: var(--pico-primary-background); color: #fff; }
.add-entry { flex-wrap: wrap; }
.add-entry .food-picker { flex: 1 1 12rem; }
/* AI 总结页：生成中的提示平时完全隐藏（htmx 默认只把它设成透明，仍会占位把后面的文字挤开） */
#ai-busy:not(.htmx-request) { display: none; }
#ai-busy.htmx-request { display: block; }
.ai-generate .tile-head h2 { white-space: nowrap; }

/* 周期回顾：减重计划进度 */
.review-side { min-width: 0; }
.plan-progress .good { color: var(--ok-fg); font-weight: 600; }
.plan-progress .warn-text { color: var(--warn-fg); font-weight: 600; }
.plan-progress h2 small { font-size: 0.8rem; font-weight: 400; }
/* 本期对上期 与 右侧一列（体重与围度变化、减重计划进度）上下对齐：两列等高，右列最后一张卡片拉伸填满 */
.review-grid { align-items: stretch; margin-bottom: 1rem; }
.review-grid > article, .review-side > article { margin: 0; }
.review-side { display: flex; flex-direction: column; gap: 1rem; }
.review-side > article:last-child { flex: 1; }

/* ---------- 动作库 ---------- */
.ai-new { display: flex; gap: 0.5rem; align-items: center; margin: 0; }
.ai-new input[type="text"] { width: 16rem; margin: 0; padding: 0.45rem 0.7rem; font-size: 0.92rem; height: auto; }
.ai-new button { margin: 0; padding: 0.45rem 0.95rem; font-size: 0.92rem; width: auto; }
article > .ai-new { margin-bottom: 1rem; }
article > .ai-new input[type="text"] { flex: 1 1 16rem; width: auto; }
.food-table td.name small.name-en { font-size: 0.8rem; }
.hint-list { font-size: 0.85rem; margin: -0.4rem 0 1rem; padding-left: 1.1rem; }
.hint-list li { list-style: disc; margin: 0.1rem 0; }
.empty .link-button { color: var(--pico-primary); text-decoration: underline; }

/* ---------- 记录训练 ---------- */
.workout-entry { padding: 1rem 1.2rem; margin-bottom: 1rem; }
.workout-entry .entry-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 0.5rem; }
.workout-entry .entry-head small { margin-left: 0.4rem; }
.workout-entry .entry-head .last-time { display: block; margin: 0.2rem 0 0; }
.workout-entry .entry-side { display: flex; gap: 0.8rem; align-items: center; white-space: nowrap; }
.set-table { width: 100%; margin: 0 0 0.6rem; }
.set-table th, .set-table td { padding: 0.25rem 0.4rem; font-size: 0.88rem; }
.set-table td input, .set-table td select { margin: 0; padding: 0.35rem 0.55rem; height: auto; font-size: 0.92rem; }
.set-table .set-no { width: 2.5rem; color: var(--pico-muted-color); }
.set-table .row-actions { width: 3rem; text-align: right; }
.workout-entry .entry-foot { display: flex; gap: 0.8rem; align-items: center; }
.workout-entry .entry-foot .entry-note { flex: 1; margin: 0; padding: 0.4rem 0.6rem; height: auto; }
.small-button { margin: 0; padding: 0.35rem 0.8rem; font-size: 0.88rem; width: auto; }
.movement-picker { position: relative; }
.movement-picker input[type="search"] { margin-bottom: 0.4rem; }
.pick-results .pick { display: block; width: 100%; text-align: left; margin: 0 0 0.3rem; padding: 0.45rem 0.7rem;
  background: var(--pico-card-background-color); color: var(--pico-color); border: 1px solid var(--pico-muted-border-color); }
.pick-results .pick:hover { border-color: var(--pico-primary); }
.pick-results .pick .star { margin-right: 0.3rem; }
/* Pico 在按钮内部把 --pico-color 改成了白色；这里用根元素上的文字颜色 */
:root { --page-text: var(--pico-color); }
.movement-picker .pick-results button.pick { color: var(--page-text); background: var(--pico-card-background-color); }
.workout-summary .summary-line { margin-bottom: 0.3rem; }
.workout-total .form-actions { display: flex; gap: 0.6rem; align-items: center; }
.workout-total .form-actions > * { margin: 0; width: auto; }
.workout-detail { width: 100%; margin: 0.3rem 0 0.4rem; }
.workout-detail td { padding: 0.2rem 0.5rem; font-size: 0.86rem; border-bottom: 1px solid var(--pico-muted-border-color); }
.workout-detail td.name { white-space: nowrap; }
.workout-detail td.sets { width: 60%; }
a.tag-link { text-decoration: none; cursor: pointer; }
a.tag-link:hover { color: var(--pico-primary); }
button.tag-link { margin: 0; padding: 0.05rem 0.45rem; width: auto; border: 0; font: inherit; font-size: 0.75rem; cursor: pointer; }
button.tag-link:hover { color: var(--pico-primary); }
form.inline-tag { display: inline; margin: 0; }

/* ---------- 训练日 ---------- */
.page-intro { margin: -0.4rem 0 1.2rem; font-size: 0.9rem; }
.day-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 1rem; align-items: stretch; }
.day-card { margin: 0; display: flex; flex-direction: column; }
.day-card > header { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; margin: 0 0 0.6rem; padding: 0; background: none; border: 0; }
.day-card > header h2 { margin: 0; font-size: 1.15rem; }
.day-card > header .muted { font-size: 0.85rem; white-space: nowrap; }
.day-movements { flex: 1; margin: 0 0 0.6rem; padding-left: 1.4rem; font-size: 0.92rem; }
.day-movements li { margin: 0.15rem 0; list-style: decimal; }
.day-movements li small { font-size: 0.78rem; }
.day-movements li.inactive { color: var(--pico-muted-color); text-decoration: line-through; }
.day-note { font-size: 0.85rem; margin: 0 0 0.6rem; }
.day-card > footer { display: flex; gap: 0.5rem; align-items: center; margin: 0; padding: 0.7rem 0 0; background: none; border-top: 1px solid var(--pico-muted-border-color); }
.day-card > footer { flex-wrap: wrap; row-gap: 0.4rem; }
.day-card > footer > a, .day-card > footer .link-button { white-space: nowrap; flex-shrink: 0; }
.day-card > footer .day-order { margin-left: auto; display: flex; gap: 0.3rem; }
.order-arrow { width: 1.9rem; height: 1.9rem; margin: 0; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem; line-height: 1; color: var(--pico-muted-color); background: none; border: 1px solid var(--pico-muted-border-color); border-radius: 6px; }
.order-arrow:hover { color: var(--pico-primary); border-color: var(--pico-primary-border); background: none; }
.day-card > footer form { margin: 0; }
.day-card > footer .link-button { font-size: 0.85rem; }
.day-items { margin: 0 0 0.8rem; padding: 0; counter-reset: dayitem; }
.day-items:has(li) + .day-items-empty { display: none; }
.day-item { list-style: none; counter-increment: dayitem; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--pico-muted-border-color); }
.day-item::before { content: counter(dayitem); color: var(--pico-muted-color); width: 1.6rem; font-size: 0.85rem; }
.day-item .day-item-name { flex: 1; }
.day-item .day-item-actions { display: flex; gap: 0.8rem; }
#day-form .form-actions { display: flex; gap: 0.6rem; align-items: center; }
#day-form .form-actions > * { margin: 0; width: auto; }
#day-form .form-actions .danger-outline { margin-left: auto; color: var(--err-fg); border-color: var(--err-fg); }
.template-picker { padding: 0.9rem 1.2rem; }
.template-picker .template-head { display: flex; gap: 0.8rem; align-items: baseline; flex-wrap: wrap; }
.template-picker .template-head .manage-link { margin-left: auto; font-size: 0.88rem; }
.template-picker .chip-row { margin-top: 0.6rem; }
.template-picker .chip small { opacity: 0.75; margin-left: 0.2rem; }
.template-notice { margin: 0.7rem 0 0; }
.template-empty { font-size: 0.88rem; margin: 0 0 1rem; }

/* ---------- 训练评估 ---------- */
.head-sub { font-size: 0.9rem; font-weight: 400; margin-left: 0.4rem; }
.segmented { display: flex; gap: 0.35rem; flex: none; width: auto; }
.segmented .small-button { min-width: 3.6rem; text-align: center; }
.good { color: var(--ok-fg); }
.bad { color: var(--err-fg); }
.eval-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.eval-kpis .kpi { margin: 0; padding: 0.9rem 1.1rem; }
.kpi-sub { font-size: 0.8rem; margin-top: 0.15rem; }
.status-mix { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.35rem; }
@media (max-width: 1100px) { .eval-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .eval-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.eval-two { align-items: stretch; margin-bottom: 1rem; }
.eval-two > article { margin: 0; }
.small-note { font-size: 0.82rem; margin: 0.6rem 0 0; }
/* 状态标签 */
.st { display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.78rem; white-space: nowrap;
  background: var(--hover-bg); color: var(--pico-muted-color); }
.st-progress, .st-m-ok { background: var(--ok-bg); color: var(--ok-fg); }
.st-plateau, .st-m-low { background: var(--warn-bg); color: var(--warn-fg); }
.st-regress, .st-m-high { background: var(--err-bg); color: var(--err-fg); }
.st-steady { background: var(--pico-primary-focus); color: var(--pico-primary); }
/* 风险提示 */
.flag-list { margin: 0; padding: 0; }
.flag { list-style: none; display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.55rem 0; border-bottom: 1px solid var(--pico-muted-border-color); font-size: 0.9rem; }
.flag:last-child { border-bottom: 0; }
.flag .tag { font-size: 0.72rem; }
.flag-level { flex: none; width: 2.6rem; text-align: center; border-radius: 6px; font-size: 0.75rem; padding: 0.1rem 0; font-weight: 600; }
.flag-high .flag-level { background: var(--err-bg); color: var(--err-fg); }
.flag-medium .flag-level { background: var(--warn-bg); color: var(--warn-fg); }
.flag-info .flag-level { background: var(--hover-bg); color: var(--pico-muted-color); }
/* 恢复 */
.recovery-list { margin: 0; }
.recovery-list > div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.5rem 0; border-bottom: 1px solid var(--pico-muted-border-color); }
.recovery-list dt { font-weight: 400; color: var(--pico-muted-color); margin: 0; }
.recovery-list dd { margin: 0; text-align: right; font-weight: 600; }
.recovery-list dd small { display: block; font-weight: 400; font-size: 0.75rem; }
/* 动作表 + 趋势图 */
.eval-split { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
@media (max-width: 1000px) { .eval-split { grid-template-columns: 1fr; } }
.table-wrap { overflow-x: auto; }
.eval-table { width: 100%; margin: 0; }
.eval-table th, .eval-table td { font-size: 0.86rem; padding: 0.35rem 0.5rem; white-space: nowrap; }
.eval-table td.name { font-weight: 600; }
.eval-table tr.clickable { cursor: pointer; }
.eval-table tr.clickable:hover td { background: var(--hover-bg); }
.eval-table tr.selected td { background: var(--pico-primary-focus); }
.spark { display: block; }
.spark polyline { fill: none; stroke: var(--series-1); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.spark.spark-regress polyline { stroke: var(--err-fg); }
.spark.spark-plateau polyline { stroke: var(--warn-fg); }
.e1rm-chart { position: sticky; top: 1rem; border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius); padding: 0.8rem 1rem; }
.e1rm-chart .chart-title { margin-bottom: 0.4rem; font-size: 0.92rem; }
/* 肌群热力表 */
.heat-table { width: 100%; margin: 0; }
.heat-table th, .heat-table td { font-size: 0.84rem; padding: 0.3rem 0.45rem; white-space: nowrap; }
.heat-table thead th small { font-weight: 400; color: var(--pico-muted-color); }
.heat-table td.heat { border-left: 2px solid var(--pico-card-background-color); }
.heat.h1 { background: color-mix(in srgb, var(--warn-bg) 60%, transparent); }
.heat.h2 { background: var(--warn-bg); }
.heat.h3 { background: var(--ok-bg); color: var(--ok-fg); font-weight: 600; }
.heat.h4 { background: var(--err-bg); color: var(--err-fg); font-weight: 600; }
/* 平衡 */
.ratio-row { margin-bottom: 1.1rem; }
.ratio-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.35rem; }
.ratio-head span { font-size: 1.3rem; font-weight: 700; }
.ratio-bar { display: flex; height: 0.7rem; border-radius: 999px; overflow: hidden; background: var(--hover-bg); }
.ratio-bar .pull { background: var(--series-1); }
.ratio-bar .push { background: var(--series-2); }
.ratio-legend { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.78rem; margin: 0.3rem 0 0.2rem; }
/* AI 评估与修改建议 */
.eval-ai { margin-top: 1rem; }
.eval-ai .inline-form { margin: 0; }
.eval-ai-meta { font-size: 0.82rem; margin-bottom: 0.8rem; }
.eval-ai-meta a[aria-current] { font-weight: 700; text-decoration: none; }
.proposals { margin: 0 0 1.2rem; }
.proposals h3 { font-size: 1rem; margin: 0 0 0.5rem; }
.proposal { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: 0.7rem 0.9rem; margin-bottom: 0.5rem;
  border: 1px solid var(--pico-muted-border-color); border-left: 4px solid var(--pico-primary); border-radius: 8px; }
.proposal.is-applied { border-left-color: var(--ok-fg); }
.proposal.is-dismissed { border-left-color: var(--pico-muted-border-color); opacity: 0.7; }
.proposal.is-invalid { border-left-color: var(--warn-fg); }
.proposal-change { margin: 0.2rem 0; font-size: 0.92rem; }
.proposal-reason { font-size: 0.85rem; }
.proposal-error { font-size: 0.82rem; color: var(--warn-fg); margin-top: 0.2rem; }
.proposal-actions { display: flex; gap: 0.4rem; flex: none; }
.proposal-actions form { margin: 0; }
/* 动作表单：肌群多选 */
.muscle-pick { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0 0 0.9rem; }
.muscle-pick legend { width: 100%; font-size: 0.92rem; margin-bottom: 0.3rem; }
.muscle-pick legend small { font-size: 0.8rem; }
.muscle-chip { display: inline-flex; align-items: center; gap: 0.3rem; margin: 0; padding: 0.2rem 0.6rem; font-size: 0.85rem;
  border: 1px solid var(--pico-muted-border-color); border-radius: 999px; cursor: pointer; }
.muscle-chip input { margin: 0; width: 0.9rem; height: 0.9rem; }
.muscle-chip:has(input:checked) { border-color: var(--pico-primary); background: var(--pico-primary-focus); color: var(--pico-primary); }
.threshold-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 1rem; }
@media (max-width: 900px) { .threshold-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- 训练总时长 ---------- */
.workout-meta .duration-field input { font-size: 1.15rem; font-weight: 600; border-color: var(--pico-primary-border); }
.workout-meta .duration-field .tag { font-size: 0.72rem; vertical-align: 1px; }
.duration-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.6rem; margin: 0 0 0.5rem; font-size: 0.92rem; }
.duration-hint .chip { margin: 0; }
.exercise-meta small { font-size: 0.78rem; }
details.swap.duration-edit { position: relative; }
details.swap.duration-edit[open] { flex-basis: auto; }
details.duration-edit[open] summary { color: var(--pico-primary); }
.duration-panel { position: absolute; right: 0; top: 1.5rem; z-index: 30; width: max-content; max-width: min(24rem, 90vw);
  padding: 0.7rem 0.9rem; border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius);
  background: var(--pico-card-background-color); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); white-space: normal; }
.duration-form { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.3rem; }
.duration-form input { width: 6rem; margin: 0; padding: 0.3rem 0.5rem; height: auto; }
.duration-form button { margin: 0; }
.calibrate-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.8rem; margin: 0 0 0.8rem; }
.calibrate-row button { margin: 0; }
.calibration { padding: 0.8rem 1rem; margin: 0 0 1rem; border-radius: var(--pico-border-radius); background: var(--pico-card-sectioning-background-color); }
.calibration p { margin-bottom: 0.5rem; }
.calibration-table { width: auto; min-width: 18rem; margin: 0 0 0.6rem; font-size: 0.92rem; }
.calibration-table th, .calibration-table td { padding: 0.3rem 0.8rem; }
.calibration-table .num { text-align: right; }

/* ---------- 文件夹标签页（运动、周期回顾、设置） ----------
   选中的标签和下方面板是同一张纸：同背景、无分隔线；标签向下盖住面板上边框 1px。
   未选中的标签颜色稍深、底部有边框，像压在后面的纸。 */
.folder-tabs { display: flex; justify-content: flex-start; align-items: flex-end; gap: 0.25rem; padding: 0 0.9rem; margin: 0 0 -1px;
  position: relative; z-index: 1; overflow-x: auto; scrollbar-width: none; }
.folder-tabs::-webkit-scrollbar { display: none; }
.folder-tab { position: relative; flex: none; display: block; padding: 0.5rem 1.15rem 0.45rem; white-space: nowrap;
  font-size: 0.93rem; color: var(--pico-muted-color); text-decoration: none;
  background: var(--folder-tab-bg); border: 1px solid var(--folder-border); border-radius: 8px 8px 0 0;
  transition: background-color 150ms ease, color 150ms ease, padding 150ms ease; }
.folder-tab:hover { background: var(--folder-tab-hover); color: var(--pico-h3-color); text-decoration: none; }
.folder-tab:focus-visible { outline: 2px solid var(--pico-primary); outline-offset: -3px; }
.folder-tab[aria-current] { z-index: 2; padding-top: 0.65rem; color: var(--pico-h1-color); font-weight: 650;
  background: var(--folder-bg); border-bottom-color: var(--folder-bg); }
.folder-tab[aria-current]:hover { background: var(--folder-bg); }
.folder-panel { position: relative; background: var(--folder-bg); border: 1px solid var(--folder-border);
  border-radius: var(--pico-border-radius); padding: 1.5rem 1.6rem 1.2rem; }
.folder-panel > :last-child { margin-bottom: 0; }
.folder-panel > .page-head:first-child, .folder-panel > h1:first-child, .folder-panel > .day-nav:first-child { margin-top: 0; }
@media (max-width: 720px) {
  .folder-tabs { padding: 0 0.4rem; }
  .folder-tab { padding: 0.45rem 0.8rem 0.4rem; font-size: 0.88rem; }
  .folder-panel { padding: 1rem 0.8rem; }
}

/* ---------- 运动页快速添加：单项运动 | 训练日 ---------- */
.quick-add-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.5rem; }
.quick-add-head h2 { margin: 0; }
.seg-switch { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--folder-tab-bg); }
.seg-switch button { margin: 0; width: auto; padding: 0.32rem 0.95rem; font-size: 0.88rem; border: 0; border-radius: 7px;
  background: none; color: var(--pico-muted-color); transition: background-color 150ms ease, color 150ms ease; }
.seg-switch button:hover { color: var(--pico-color); }
.seg-switch button[aria-selected="true"] { background: var(--pico-card-background-color); color: var(--pico-h1-color); font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12); }
.quick-add-intro { margin: 0 0 0.8rem; font-size: 0.86rem; }
.quick-day-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.5rem; min-height: 1.6rem; }
.quick-day-hint .chip { margin: 0; }

/* 图表卡片标题旁的切换（每天 | 每周） */
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.6rem; }
.chart-head h2 { margin: 0; }
