/* 刻形颜色与字体：取值以 docs/DESIGN.md 为准；组件只引用用途 token。 */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0020-007E, U+00A0-00FF;
}
:root {
  --font-family: "Inter", "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans SC", sans-serif;
  --light-bg: #FFFFFF;
  --light-card: #F5F5F6;
  --light-track: #E6E6E9;
  --light-text: #131416;
  --light-muted: #6B6E75;
  --day-logged: #C9CBD1;
  --light-protein: #F0643C;
  --light-carbs: #F2A93B;
  --light-fat: #4C8DF0;
  --light-warn: #8F5F00;
  --light-over: #D0312D;
  --bg: var(--light-bg);
  --card: var(--light-card);
  --surface: var(--light-bg);
  --track: var(--light-track);
  --text: var(--light-text);
  --muted: var(--light-muted);
  --accent: var(--text);
  --on-accent: var(--bg);
  --protein: var(--light-protein);
  --carbs: var(--light-carbs);
  --fat: var(--light-fat);
  --warn: var(--light-warn);
  --danger: var(--light-over);
  --overlay: rgba(19, 20, 22, .48);
  --overlay-text: var(--light-bg);
  --chart-area: rgba(19, 20, 22, .06);
  --hairline: rgba(19, 20, 22, .08);

  /* 现有组件的用途别名，继续兼容页面内联的营养素样式。 */
  --bg-deep: var(--bg);
  --card-2: var(--track);
  --subtle: var(--card);
  --hover: var(--track);
  --input-bg: var(--bg);
  --text-2: var(--muted);
  --line: var(--track);
  --line-strong: var(--track);
  --accent-text: var(--text);
  --accent-soft: var(--track);
  --focus: var(--text);
  --ok: var(--text);
  --warn-soft: var(--card);
  --danger-soft: var(--card);
  --train: var(--accent);
  --train-ink: var(--on-accent);
  --train-soft: var(--card);
  --train-line: var(--track);
  --rest: var(--accent);
  --rest-soft: var(--card);
  --rest-line: var(--track);
  --p: var(--protein);
  --c: var(--carbs);
  --f: var(--fat);
  --bar-warn: var(--accent);
  --bar-over: var(--accent);

  /* 导出海报固定浅色，不随系统深色模式改变。 */
  --poster-bg: var(--light-bg);
  --poster-card: var(--light-card);
  --poster-track: var(--light-track);
  --poster-text: var(--light-text);
  --poster-muted: var(--light-muted);
  --poster-protein: var(--light-protein);
  --poster-carbs: var(--light-carbs);
  --poster-fat: var(--light-fat);
  --poster-warn: var(--light-warn);
  --poster-over: var(--light-over);

  --radius: 24px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --shadow: none;
  --shadow-md: none;
  --control-h: 40px;
  --sidebar-w: 232px;
  --nav-h: 64px;
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 320ms;
  --dur-sheet: 380ms;
  --ease-sheet: cubic-bezier(.32, .72, 0, 1);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-in: cubic-bezier(.55, 0, 1, .45);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1012;
    --card: #1B1C1F;
    --surface: #1B1C1F;
    --track: #2E2F33;
    --text: #F4F4F5;
    --muted: #A3A6AC;
    --day-logged: #4A4C52;
    --on-accent: #131416;
    --protein: #F58A6A;
    --carbs: #F5BE66;
    --fat: #7FAEF5;
    --warn: #F5BE66;
    --danger: #FF8A80;
    --overlay: rgba(0, 0, 0, .64);
    --chart-area: rgba(244, 244, 245, .06);
    --hairline: rgba(244, 244, 245, .1);
    color-scheme: dark;
  }
  /* 保留原始图形，深色页面显示反白版本。 */
  .brand img, .onboard-brand img { filter: invert(1); }
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--font-family);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; color: var(--text); letter-spacing: 0; }
h1 { font-size: 26px; font-weight: 600; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
.icon { flex: none; display: block; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid-4 > .wide { grid-column: span 2; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.boot { min-height: 60vh; display: grid; place-items: center; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--track); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 应用外壳：桌面侧栏 / 手机底栏 ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 20;
  background: var(--bg-deep); border: 0;
  display: flex; flex-direction: column; padding: 18px 12px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; font-weight: 600; font-size: 16px; letter-spacing: 0; }
.sidebar .brand img { border-radius: 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); min-height: 44px; font-size: 15px; font-weight: 500; text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a:active { transform: scale(.97); }
.nav a.active { background: var(--card-2); color: var(--text); font-weight: 600; }
.nav a.active .icon { color: var(--accent); }
.sidebar-foot { margin-top: auto; }
.account { display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 10px; border-radius: var(--radius-sm); border: 0; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 600; background: var(--accent); color: var(--on-accent); }
.account-name { flex: 1; font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { padding: 32px 40px 64px; margin-left: var(--sidebar-w); }
.main > * { max-width: 960px; margin-left: auto; margin-right: auto; }
body.auth .main, body.no-nav .main { margin-left: 0; padding: 0; }
body.auth .main > *, body.no-nav .main > * { max-width: none; }
body.no-nav .main { padding: 32px 20px 120px; }
body.no-nav .main > * { max-width: 860px; }
/* 切页：新页面渲染好后整体替换；加载稍久时旧页面略微变淡 */
.main[aria-busy="true"] > .view { opacity: .55; transition: opacity var(--dur-base) var(--ease-out) 150ms; }

@media (max-width: 899px) {
  .sidebar {
    inset: auto 14px calc(16px + env(safe-area-inset-bottom)); width: auto; max-width: none; height: 54px; margin: 0;
    flex-direction: row; padding: 5px; border: 0; border-radius: 999px; box-shadow: var(--floating-shadow);
    background: var(--surface);
  }
  .sidebar .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; align-items: center; }
  .nav a { flex: 1; justify-content: center; padding: 8px; min-width: 44px; min-height: 44px; border-radius: 999px; color: var(--muted); }
  .nav a span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .nav a:hover { background: transparent; }
  .nav a.active { background: var(--card); color: var(--text); }
  .sidebar { transition: right 320ms cubic-bezier(.32,.72,0,1); }
  .sidebar.has-add { right: 78px; transition-delay: 0ms; }
  .sidebar[data-motion="off"] { transition: none; }
  .nav a .icon { width: 22px; height: 22px; }
  .main { margin-left: 0; padding: 18px 14px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }
  h1 { font-size: 22px; }
}

/* ---------- 页面标题 ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title p { margin-top: 6px; color: var(--muted); font-size: 14px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 899px) {
  .page-head { margin-bottom: 16px; align-items: stretch; flex-direction: column; gap: 12px; }
  .page-actions { width: 100%; }
}

/* ---------- 卡片与分区 ---------- */
.card {
  background: var(--card);
  border: 0; border-radius: var(--radius); padding: 22px; box-shadow: none;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2 { font-size: 15px; }
/* 设置式分区：左标题右内容 */
.section { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; }
.section-head h2 { font-size: 15px; }
.section-head p { margin-top: 6px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.section-body > * + * { margin-top: 16px; }
@media (max-width: 899px) {
  .card { padding: 16px; border-radius: var(--radius); }
  .section { grid-template-columns: 1fr; gap: 14px; }
}

/* ---------- 表单控件 ---------- */
.field { display: flex; flex-direction: column; gap: 7px; font-size: 13px; font-weight: 500; color: var(--text-2); }
label.field > span.hint { font-size: 12px; font-weight: 400; color: var(--muted); }
label.field .seg, label.field .chips { align-self: flex-start; }
input, select, textarea {
  font: inherit; font-size: 16px; /* ≥16px 避免 iOS 聚焦时自动放大 */
  color: var(--text); background: var(--input-bg);
  border: 0; border-radius: var(--radius-sm);
  padding: 0 12px; min-height: var(--control-h); min-width: 0; width: 100%;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
textarea { padding: 10px 12px; resize: vertical; min-height: 88px; line-height: 1.5; }
select {
  padding-right: 12px; appearance: auto;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 2px; border-color: var(--accent); box-shadow: none; }
input[type=checkbox] { accent-color: var(--accent); width: auto; min-height: 0; }
input[type=number] { -moz-appearance: textfield; font-variant-numeric: tabular-nums; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.input-unit { position: relative; display: flex; align-items: center; }
.input-unit input { padding-right: 48px; }
.input-unit em { position: absolute; right: 12px; font-style: normal; font-size: 13px; color: var(--muted); pointer-events: none; }
@media (max-width: 899px) { :root { --control-h: 44px; } }

/* ---------- 按钮 ---------- */
button, .btn {
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; color: var(--text);
  background: var(--card); border: 0; box-shadow: none;
  border-radius: var(--radius-sm); padding: 0 14px; min-height: 36px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  white-space: nowrap; text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
button:hover { background: var(--subtle); border-color: var(--muted); }
/* 按下：按钮与可点卡片统一缩到 0.97 */
button:active:not(:disabled), .brand-card:active, .photo-tile:active, .food-id.clickable:active { transform: scale(.97); }
button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; box-shadow: none; }
button.primary {
  color: var(--on-accent); border-color: var(--on-accent);
  background: var(--accent);
  box-shadow: none;
}
button.primary:hover { background: var(--accent); opacity: .88; }
button.lg { min-height: 44px; font-size: 15px; font-weight: 600; border-radius: var(--radius-sm); }
button.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
button.ghost:hover { background: var(--hover); color: var(--text); }
button.danger { color: var(--text-2); }
button.danger:hover { color: var(--text-2); background: var(--danger-soft); }
button.icon { padding: 0; width: 36px; min-width: 36px; }
button:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 899px) { button { min-height: 42px; } button.icon { width: 42px; min-width: 42px; } }

/* 分段控件 */
.seg { position: relative; display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-sm); background: var(--card-2); border: 0; }
.seg button { position: relative; z-index: 1; border: 0; background: transparent; min-height: 30px; padding: 0 14px; border-radius: 8px; color: var(--muted); font-size: 13px; transition: color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
.seg button:hover { color: var(--text); background: transparent; }
.seg button.on, .seg-thumb { background: var(--card); box-shadow: none; }
.seg button.on { color: var(--text); font-weight: 600; }
/* 选中块：切换时从旧选项滑到新选项（ui.js segmented），滑完交回按钮自身 */
.seg-thumb { position: absolute; top: 3px; bottom: 3px; left: 0; border-radius: 8px; transform-origin: left center; opacity: 0; pointer-events: none; }
.seg.moving .seg-thumb { opacity: 1; }
.seg.moving button.on { background: transparent; box-shadow: none; }
/* 选项组（是/否、1–5 分） */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border-radius: 999px; min-height: 34px; padding: 0 14px; min-width: 42px; background: transparent; color: var(--text-2); }
.chips button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

/* ---------- 登录页 ---------- */
.auth-page { min-height: 100vh; min-height: 100dvh; display: grid; align-items: center; padding: 48px 24px; }
.auth-panel { width: 100%; max-width: 380px; margin: 0 auto; min-width: 0; }
.auth-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 40px; font-size: 20px; font-weight: 600; }
.auth-card .brand img { border-radius: 0; }
.auth-card h1 { font-size: 24px; margin-bottom: 24px; }
.auth-form { display: grid; gap: 16px; }
.auth-form input { background: var(--card); min-height: 48px; }
.auth-form button.primary { margin-top: 4px; width: 100%; min-height: 48px; }
.auth-form .field { font-size: 15px; }
.switch { margin-top: 22px; font-size: 15px; color: var(--muted); }
.switch a { display: inline-flex; align-items: center; min-height: 44px; margin-left: 8px; font-weight: 500; }
.error { color: var(--text); font-size: 15px; overflow-wrap: anywhere; }
.error:empty { display: none; }

/* ---------- 指标块 ---------- */
.stat { background: var(--subtle); border: 0; border-radius: var(--radius-md); padding: 12px 14px; }
.stat .k { font-size: 12.5px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.35; letter-spacing: -.03em; margin-top: 2px; }
.stat .v small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.stat.hl .v { color: var(--accent-text); }
.stat.warn { background: var(--warn-soft); border-color: transparent; }
.stat.warn .v { color: var(--warn); }
.stat.bad { background: var(--danger-soft); border-color: transparent; }
.stat.bad .v { color: var(--danger); }
.notice { display: flex; gap: 10px; border-radius: var(--radius-md); padding: 12px 14px; font-size: 14px; line-height: 1.6; background: var(--warn-soft); color: var(--warn); border: 0; }
.notice.ok { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-soft); }
.badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 500; border-radius: 999px; padding: 2px 9px; background: var(--card-2); color: var(--text-2); border: 0; }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-soft); }

/* ---------- 进度条与热量环 ---------- */
.bar { height: 6px; border-radius: 999px; background: var(--track); overflow: hidden; }
/* 填充条整条平移露出（transform 由 ui.js barFill 设置） */
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transform: translateX(-100%); }
.bar.warn > i { background: var(--bar-warn); }
.bar.over > i { background: var(--bar-over); }
.macro-line { display: grid; grid-template-columns: 72px 1fr 92px; gap: 12px; align-items: center; font-size: 13.5px; color: var(--text-2); }
.macro-line > span:last-child { text-align: right; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; }
.ring-track { stroke: var(--track); }
.ring-fill { stroke: var(--accent); }
.ring.warn .ring-fill { stroke: var(--bar-warn); }
.ring.over .ring-fill { stroke: var(--bar-over); }

/* ---------- 日期切换 ---------- */
.date-nav { display: flex; align-items: center; gap: 4px; padding: 3px; border-radius: var(--radius-sm); background: var(--card); border: 0; box-shadow: none; }
.date-nav button { border: 0; background: transparent; box-shadow: none; min-height: 32px; }
.date-nav button:hover { background: var(--hover); }
.date-nav button.icon { width: 32px; min-width: 32px; color: var(--text-2); }
.date-label { position: relative; padding: 0 12px; font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; min-width: 128px; }
.date-label .icon { color: var(--muted); }
.date-nav button.date-label.is-today { background: var(--card-2); color: var(--accent-text); }
.date-nav button.date-label.is-today:hover { background: var(--muted); }
.date-label.is-today .icon { color: var(--accent-text); }
.date-native { position: absolute; inset: 0; opacity: 0; pointer-events: none; width: 100%; min-height: 0; border: 0; padding: 0; }
.today-btn { font-size: 13px; color: var(--accent-text) !important; padding: 0 10px; }
.today-btn.is-hidden { visibility: hidden; }
@media (max-width: 899px) {
  .date-nav { width: 100%; }
  .date-nav button { min-height: 38px; }
  .date-nav button.icon { width: 40px; min-width: 40px; }
  .date-label { flex: 1; }
}

/* ---------- 饮食页：今日概览 ---------- */
.overview { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 32px; align-items: center; transition: border-color var(--dur-base) var(--ease-out); }
.overview.day-train { background: var(--card); border-color: var(--train-line); }
.overview.day-rest { background: var(--card); border-color: var(--rest-line); }
.ring-wrap { position: relative; width: 168px; height: 168px; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-center .k { font-size: 12.5px; color: var(--muted); }
.ring-center .v { font-size: 38px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ring-center .v.warn { color: var(--warn); }
.ring-center .v.over { color: var(--danger); }
.ring-center .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ov-body { display: grid; gap: 18px; }
.ov-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ov-top h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 16px; }
.summary-date { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.summary-today { padding: 2px 7px; border-radius: 999px; background: var(--card-2); color: var(--accent-text); font-size: 12px; }
.kv-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 0; border-radius: var(--radius-md); background: var(--surface); }
.kv { padding: 10px 14px; }
.kv + .kv { border: 0; }
.kv .k { font-size: 12px; color: var(--muted); }
.kv .v { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.03em; margin-top: 2px; }
.kv .v small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 3px; }
.kv .v.hl { color: var(--accent-text); }
.macros { display: grid; gap: 10px; }
.log-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-top: 14px; border: 0; }
.log-row .small { color: var(--muted); }
.overview-actions { margin-left: auto; }
.day-pill { font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; letter-spacing: .02em; }
.day-pill.train { background: var(--accent); color: var(--on-accent); }
.day-pill.rest { background: var(--accent); color: var(--on-accent); }
.overview.day-train .seg button.on { color: var(--on-accent); }
.overview.day-rest .seg button.on { color: var(--on-accent); }
.overview.day-train .seg button.on, .overview.day-train .seg-thumb { background: var(--accent); }
.overview.day-rest .seg button.on, .overview.day-rest .seg-thumb { background: var(--accent); }
.overview.day-train .seg.moving button.on, .overview.day-rest .seg.moving button.on { background: transparent; }
@media (max-width: 899px) {
  .overview { grid-template-columns: 1fr; gap: 18px; justify-items: center; }
  .ov-body { width: 100%; }
  .ov-top { order: -1; }
  .kv .v { font-size: 17px; }
  .kv { padding: 9px 10px; }
}

/* 吸顶精简条 */
.sticky-sum {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0; z-index: 15;
  background: var(--surface);
  border: 0; box-shadow: none;
  transform: translateY(-110%); opacity: 0; pointer-events: none;
  transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out);
}
.sticky-sum.day-train { border-bottom-color: var(--train-line); }
.sticky-sum.day-rest { border-bottom-color: var(--rest-line); }
.sticky-sum.show { transform: none; opacity: 1; pointer-events: auto; }
.sticky-inner { max-width: 960px; margin: 0 auto; padding: 10px 40px 12px; display: grid; gap: 7px; }
.sticky-inner > .summary-date { font-size: 14px; }
.sticky-inner b { font-size: 20px; letter-spacing: -.03em; }
.sticky-inner button { min-height: 30px; padding: 0 12px; font-size: 13px; }
.sticky-remain { margin-left: 10px; font-size: 13px; font-weight: 600; color: var(--accent-text); }
.sticky-remain.warn { color: var(--warn); }
.sticky-remain.over { color: var(--danger); }
.sticky-macros { display: flex; gap: 18px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
@media (max-width: 899px) { .sticky-sum { left: 0; } .sticky-inner { padding: 10px 14px 12px; } }

/* 工具条 */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 20px 0 12px; }
.toolbar .save-state { margin-left: auto; }
@media (max-width: 899px) {
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar .primary { grid-column: 1 / -1; }
  .toolbar .save-state { grid-column: 1 / -1; text-align: right; margin: 0; }
}
.save-state { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.save-state::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: .8; }
.save-state:empty::before { display: none; }
.save-state.dirty { color: var(--warn); }
.save-state.dirty::before { background: var(--warn); }

/* ---------- 餐次 ---------- */
.meals { display: grid; gap: 14px; }
.meal { min-width: 0; padding: 0; overflow: visible; }
.meal-head { background: var(--card); border-radius: var(--radius); scroll-margin-top: calc(var(--meal-sticky-top, 0px) + 12px); }
.meal.open > .meal-head { position: sticky; top: var(--meal-sticky-top, 0px); z-index: 10; border: 0; border-radius: var(--radius) var(--radius) 0 0; }
.meal-toggle { display: block; width: 100%; padding: 14px 18px; border: 0; border-radius: inherit; text-align: left; white-space: normal; }
.meal-heading { display: flex; align-items: center; gap: 10px; width: 100%; }
.meal-title { min-width: 0; overflow-wrap: anywhere; font-size: 16px; font-weight: 600; }
.meal-clock { flex: none; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.meal-chevron { flex: none; color: var(--muted); transform: rotate(90deg); }
.meal.open .meal-chevron { transform: rotate(-90deg); }
.meal-preview { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 400; color: var(--muted); }
.meal-edit { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 10px 18px 4px; }
.meal-edit input.meal-name {
  border: 0; background: transparent; font-weight: 600; font-size: 16px; padding: 0 8px; margin-left: -8px; min-height: 32px;
  width: 7em; letter-spacing: 0;
}
.meal-edit input.meal-name:hover { background: var(--hover); }
.meal-edit input.meal-name:focus { background: var(--input-bg); border-color: var(--accent); }
.tpl-edit-head { flex-wrap: wrap; }
.meal-order { display: flex; flex: none; gap: 2px; }
.meal-order button { min-height: 32px; width: 32px; padding: 0; }
.meal-time { flex: none; min-height: 32px; padding: 0 6px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meal-defaults { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.meal-default { display: flex; align-items: center; gap: 6px; }
.meal-default input { min-width: 0; }
.meal-default input[type="time"] { flex: none; width: 136px; }
.brand-tag { font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--card-2); color: var(--text-2); border: 0; white-space: nowrap; }
.meal-sum { flex: none; margin-left: auto; text-align: right; font-size: 12px; color: var(--muted); line-height: 1.45; }
.meal-sum b { color: var(--text); font-size: 16px; font-weight: 600; letter-spacing: 0; }
.meal-macros { display: block; font-weight: 400; }
.meal-body { position: relative; z-index: 0; }
.meal .picker-input { scroll-margin-top: calc(var(--meal-sticky-top, 0px) + 100px); }
.items { padding: 4px 10px; }
.supplement-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; }
.supplement-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 34px; padding: 4px 8px; border-radius: 8px; font-size: 13px; }
.supplement-chip > span:first-of-type { overflow-wrap: anywhere; }
.supplement-chip .thumb { flex: none; width: 24px; height: 24px; border-radius: 5px; }
.supplement-chip .num { flex: none; color: var(--muted); }
/* 食物行：行内编辑，未聚焦时弱化边框 */
.item {
  position: relative; display: grid; gap: 4px 10px; align-items: center; padding: 8px; border-radius: var(--radius-sm);
  grid-template-columns: minmax(0, 1fr) 120px 84px 140px;
  grid-template-areas: "food qty kcal del" "nut srv srv srv";
  transition: background-color var(--dur-fast) var(--ease-out);
}
.item + .item { margin-top: 2px; }
.item:hover { background: var(--hover); }
.item > .food-cell { grid-area: food; position: relative; min-width: 0; }
.item .brand-flag { position: absolute; inset: 0; padding: 0 8px; display: flex; align-items: flex-start; overflow: hidden; pointer-events: none; font: inherit; font-weight: 500; }
.item .brand-flag .mirror { visibility: hidden; white-space: pre; flex: 0 1 auto; min-width: 0; overflow: hidden; font-size: 16px; }
.item .brand-tag.item-brand { flex: none; margin: 3px 0 0 2px; font-size: 10px; line-height: 14px; padding: 0 6px; background: var(--card-2); }
.item > .input-unit { grid-area: qty; }
.item > .kcal { grid-area: kcal; }
.item-actions { grid-area: del; display: flex; align-items: center; justify-content: end; gap: 4px; }
.item-actions button { min-height: 32px; color: var(--muted); }
.item-actions .swap-food, .item-actions .move-food { padding: 0 6px; font-size: 12px; white-space: nowrap; }
.item-actions .delete-item { display: inline-flex; align-items: center; justify-content: center; width: 32px; min-width: 32px; opacity: 0; }
.item:hover .delete-item, .item:focus-within .delete-item { opacity: 1; }
.item-actions .delete-item:hover { color: var(--text-2); background: var(--danger-soft); }
.item > .nut { grid-area: nut; }
.item > .srv { grid-area: srv; justify-self: start; font-size: 12px; color: var(--text-2); }
.item .picker-input { border-color: transparent; background: transparent; box-shadow: none; font-weight: 500; padding: 0 8px; }
.item .picker-input:hover { border-color: transparent; background: var(--hover); }
.item .picker-input:focus { background: var(--input-bg); border-color: var(--accent); }
.item .input-unit input { background: var(--input-bg); border-color: var(--line); text-align: right; padding-right: 36px; }
.item .input-unit em { right: 11px; }
.item .nut { font-size: 12px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; padding-left: 8px; }
.item .kcal { text-align: right; font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item .kcal:not(:empty)::after { content: ' kcal'; font-size: 11px; font-weight: 500; color: var(--muted); }
.item .missing { color: var(--warn); }
.meal-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 10px 12px; align-items: center; }
.add-item { border: 0; background: transparent; color: var(--accent-text); font-weight: 500; padding: 0 10px; }
.add-item:hover { background: var(--accent-soft); }
.add-meal { width: 100%; margin-top: 14px; border: 0; background: transparent; color: var(--text-2); min-height: 46px; border-radius: var(--radius-md); }
.add-meal:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.empty-meal { padding: 14px 8px 4px; font-size: 13px; color: var(--muted); }
@media (max-width: 899px) {
  .meal-toggle { padding: 12px 14px; }
  .meal-edit { padding: 8px 14px 2px; }
  .meal-heading { flex-wrap: wrap; gap: 6px 8px; }
  .meal-title { font-size: 15px; }
  .meal.open .meal-macros { max-width: 14em; white-space: normal; }
  .items { padding: 2px 6px; }
  .item {
    grid-template-columns: 104px minmax(0, 1fr) 140px;
    grid-template-areas: "food food del" "qty nut kcal" "srv srv srv";
    gap: 6px 8px; padding: 10px 8px; border: 0; border-radius: 0;
  }
  .item:last-child { border: 0; }
  .item:hover { background: transparent; }
  .item-actions .delete-item { opacity: .7; }
  .item .picker-input { background: var(--subtle); }
  .item .nut { padding-left: 0; gap: 2px 8px; }
  .item > .srv { padding: 2px 8px; border-radius: 6px; background: var(--subtle); }
  .meal-edit input.meal-name { width: 4.6em; font-size: 15px; }
  .meal-sum { white-space: nowrap; font-size: 11px; }
  .meal-sum b { font-size: 15px; }
}

/* 食物选择器 */
.picker { position: relative; }
.picker-search-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.picker-search-row > input { flex: 1; width: 0; min-width: 0; }
.picker-search-row > .picker-create { display: inline-flex; align-items: center; gap: 4px; flex: none; min-height: 44px; white-space: nowrap; }
.picker-list {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0; min-width: 300px;
  background: var(--surface); border: 0; border-radius: var(--radius-sm); box-shadow: none;
  max-height: 340px; overflow: auto; padding: 5px;
}
.picker-list .opt { padding: 9px 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; }
.picker-list .opt.on, .picker-list .opt:hover { background: var(--accent-soft); }
.picker-list .opt .meta { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; line-height: 1.4; }
.picker-list .empty { padding: 12px; font-size: 14px; color: var(--muted); }
.food-swap-picker .picker-list { position: static; min-width: 0; margin-top: 6px; }
.food-swap-picker select { margin-bottom: 8px; }
.swap-comparison { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 13px; }
.swap-comparison th, .swap-comparison td { padding: 10px 4px; border: 0; text-align: right; white-space: normal; overflow-wrap: anywhere; }
.swap-comparison th { position: static; }
.swap-comparison tbody th { color: var(--text-2); background: transparent; }
.swap-comparison th:first-child { text-align: left; }
.swap-comparison thead th { color: var(--muted); font-weight: 500; }
@media (max-width: 899px) { .picker-list { max-height: 50vh; min-width: 0; } }

/* ---------- 对话框 ---------- */
dialog.modal {
  border: 0; border-radius: var(--radius); padding: 0; width: min(540px, calc(100% - 32px));
  background: var(--surface); color: var(--text); box-shadow: none;
}
dialog.modal::backdrop { background: var(--overlay);  }
/* 进场：弹窗轻微上浮放大，遮罩渐显；退场（.closing，ui.js modal）更快地反向 */
dialog.modal[open] { animation: modal-in var(--dur-slow) var(--ease-out); }
dialog.modal[open]::backdrop { animation: fade-in var(--dur-slow) var(--ease-out); }
dialog.modal.closing { animation: modal-out var(--dur-base) var(--ease-in) forwards; pointer-events: none; }
dialog.modal.closing::backdrop { animation: fade-out var(--dur-base) var(--ease-in) forwards; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes modal-out { to { opacity: 0; transform: translateY(4px) scale(.98); } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 0; }
.modal-head h2 { font-size: 18px; font-weight: 600; }
.modal-body { padding: 14px 22px 22px; display: grid; gap: 16px; max-height: 78vh; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 6px; }
@media (max-width: 899px) {
  dialog.modal { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: var(--radius) var(--radius) 0 0; padding-bottom: env(safe-area-inset-bottom); }
  /* 手机端是底部面板：从底部滑入、滑出 */
  dialog.modal[open] { animation-name: sheet-in; }
  dialog.modal.closing { animation-name: sheet-out; }
  .modal-actions button { flex: 1; min-height: 46px; }
}

/* ---------- 待页面接入的基础组件（CTF-60） ---------- */
dialog.bottom-sheet { max-height: calc(100dvh - 24px); overflow: hidden; }
dialog.bottom-sheet[open], dialog.bottom-sheet[open]::backdrop { animation-duration: var(--dur-sheet); animation-timing-function: var(--ease-sheet); }
dialog.bottom-sheet.closing, dialog.bottom-sheet.closing::backdrop { animation-duration: var(--dur-base); }
dialog.bottom-sheet.sheet-interacted:not(.closing) { animation: none; }
.bottom-sheet .modal-head { position: relative; }
.bottom-sheet .modal-head button { min-width: 44px; min-height: 44px; }
.bottom-sheet .modal-body { max-height: calc(100dvh - 120px); max-height: min(78dvh, calc(100dvh - 120px)); overscroll-behavior: contain; }
.bottom-sheet .modal-body button { min-height: 44px; }
@media (max-width: 899px) {
  .bottom-sheet .modal-head { padding-top: 24px; touch-action: pan-x pinch-zoom; user-select: none; }
  .bottom-sheet .modal-head::before { content: ''; position: absolute; top: 10px; left: calc(50% - 18px); width: 36px; height: 4px; border-radius: 999px; background: var(--track); }
  .bottom-sheet .modal-body { max-height: min(78dvh, calc(100dvh - 144px - env(safe-area-inset-bottom))); }
}
@media (min-width: 900px) {
  dialog.bottom-sheet { margin: auto; }
}
.undo-stack { position: fixed; z-index: 100; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); left: 14px; right: 14px; display: grid; gap: 8px; pointer-events: none; }
.undo-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: min(100%, 480px); margin: 0 auto; padding: 4px 6px 4px 16px; border-radius: var(--radius-sm); background: var(--accent); color: var(--on-accent); pointer-events: auto; }
.undo-bar > span { min-width: 0; overflow-wrap: anywhere; }
.undo-bar button { min-height: 44px; color: inherit; background: transparent; font-size: 15px; font-weight: 600; }
.undo-bar button:focus-visible { outline-color: var(--on-accent); }
.bottom-sheet .undo-stack { bottom: calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) {
  .undo-stack { bottom: 24px; }
}
.stepper { display: grid; grid-template-columns: 52px minmax(0, 1fr) 52px; align-items: center; gap: 6px; }
.stepper .stepper-adjust { width: 52px; height: 52px; padding: 0; border-radius: 999px; background: var(--card); font-size: 24px; font-weight: 400; transition: none; }
.stepper-center { display: grid; justify-items: center; min-width: 0; text-align: center; }
.stepper .stepper-value { min-width: 44px; max-width: 100%; min-height: 52px; padding: 0 8px; background: transparent; font-size: 46px; line-height: 1.1; font-weight: 500; white-space: normal; overflow-wrap: anywhere; transition: none; }
.stepper-input { width: 100%; min-height: 52px; font-size: 16px; text-align: center; background: var(--card); }
.stepper-center small { color: var(--muted); font-size: 13px; }
.serving-shortcuts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.serving-shortcuts button { min-height: 44px; font-size: 15px; border-radius: 999px; background: var(--card); transition: none; }
.serving-shortcuts button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.swipe-delete { display: flex; align-items: center; gap: 8px; overflow: hidden; }
.swipe-content { flex: 1; min-width: 0; touch-action: pan-y pinch-zoom; }
.swipe-delete-button { flex: none; min-width: 44px; min-height: 44px; color: var(--muted); font-size: 15px; }
@media (prefers-reduced-motion: reduce) {
  dialog.bottom-sheet[open], dialog.bottom-sheet[open]::backdrop { animation-name: fade-in; animation-duration: var(--dur-base); }
  dialog.bottom-sheet.closing, dialog.bottom-sheet.closing::backdrop { animation-name: fade-out; animation-duration: var(--dur-base); }
}
.brand-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 520px) { .brand-grid { grid-template-columns: 1fr; } }
.brand-card {
  position: relative; display: flex; flex-direction: column; gap: 3px; padding: 14px; cursor: pointer;
  border: 0; border-radius: var(--radius-sm); background: var(--card);
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.brand-card.disabled:active { transform: none; }
.brand-card:hover { border-color: var(--muted); }
.brand-card input { position: absolute; opacity: 0; pointer-events: none; }
.brand-card .brand-name { font-weight: 600; font-size: 15px; }
.brand-card .brand-hint { font-size: 12px; color: var(--muted); padding-right: 20px; line-height: 1.5; }
.brand-card::after { content: ''; position: absolute; top: 14px; right: 14px; width: 18px; height: 18px; border-radius: 6px; border: 0; }
.brand-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: none; }
.brand-card:has(input:checked)::after { content: '✓'; background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-size: 12px; line-height: 17px; text-align: center; font-weight: 600; }
.brand-card:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.plan-preview { border: 0; border-radius: var(--radius-sm); overflow: hidden; background: var(--subtle); }
.plan-row { display: flex; justify-content: space-between; padding: 9px 14px; font-size: 14px; color: var(--text-2); }
.plan-row + .plan-row { border: 0; }
.plan-row b { color: var(--text); font-weight: 600; }
.tpl-list { display: grid; gap: 8px; }
.tpl-item { display: flex; align-items: center; gap: 8px; padding: 14px; border: 0; border-radius: var(--radius-sm); background: var(--subtle); }
.tpl-name { font-weight: 600; }
.tpl-item .small { margin-top: 2px; color: var(--muted); }
@media (max-width: 899px) { .tpl-item { flex-wrap: wrap; } .tpl-item .grow { flex-basis: 100%; } .tpl-item button { flex: 1; } }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 0; border-radius: var(--radius-md); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 11px 14px; text-align: left; border: 0; white-space: nowrap; }
tbody tr:last-child td { border: 0; }
th { font-weight: 500; color: var(--muted); font-size: 12px; background: var(--subtle); position: sticky; top: 0; letter-spacing: .02em; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tbody td { transition: background-color var(--dur-fast) var(--ease-out); }
tbody tr:hover td { background: var(--hover); }
tr.clickable { cursor: pointer; }
tr.sel td { background: var(--accent-soft); }

/* ---------- 趋势 ---------- */
.trend-verdict { padding: 0 2px; }
.trend-conclusion { font-size: 24px; font-weight: 600; line-height: 1.4; margin: 0 0 6px; }
.trend-verdict > .muted { margin: 0; }
.trend-numbers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.trend-numbers .stat { padding: 0; background: transparent; }
.trend-numbers .stat .v { font-size: 24px; }
.trend-detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.trend-details summary, .trend-week-list summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 500; }
.trend-details summary::after, .trend-week-list summary::after { content: '+'; color: var(--muted); margin-left: auto; }
.trend-details[open] summary::after, .trend-week-list[open] summary::after { content: '−'; }
.trend-week-list { display: none; }
.trend-week-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; color: var(--text); }
.trend-week-link small { display: block; margin-top: 4px; }
.trend-week-link[aria-current] { font-weight: 600; }
.trend-logs > .card-head { margin-bottom: 0; }
.trend-logs .sheet-wrap { overflow-x: auto; }
.log-toggle { display: block; margin-inline: auto; color: var(--text-2); }
.trend-logs .sheet { min-width: 1100px; }
.trend-log-day { background: var(--card); border-radius: var(--radius-md); padding: 4px 16px 12px; margin-top: 10px; }
.trend-log-day summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; cursor: pointer; }
.trend-log-day summary::-webkit-details-marker, .trend-details summary::-webkit-details-marker, .trend-week-list summary::-webkit-details-marker { display: none; }
.trend-log-day summary .sheet-day { display: block; flex-shrink: 0; }
.trend-log-day .sheet-day small { display: block; font-size: 15px; margin-top: 2px; }
.trend-log-day .corner-tag { margin-left: 6px; }
.trend-log-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.trend-log-values > div { min-width: 0; }
.trend-log-values dt { color: var(--muted); }
.trend-log-values dd { margin: 4px 0 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; white-space: pre-wrap; }
.trend-log-values > div:last-child { grid-column: 1 / -1; }
.trend-log-day button, .trend-chart .seg button { min-height: 44px; }
.chart { width: 100%; height: auto; display: block; }
.chart .line { fill: none; stroke: var(--text); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart .pt { fill: var(--muted); opacity: .6; }
.chart .trend-average { fill: var(--text); }
.chart text { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.trend-chart-key { margin: 0; }
@media (max-width: 899px) {
  .trend-conclusion { font-size: 21px; }
  .trend-page { font-size: 15px; }
  .trend-numbers .stat .k, .trend-numbers .stat .v small, .trend-details .stat .k, .trend-details .stat .v small { font-size: 15px; }
  .trend-numbers .stat .v { font-size: 22px; }
  .trend-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trend-week-table { display: none; }
  .trend-week-list { display: block; }
  .trend-chart .card-head { flex-wrap: wrap; }
  .trend-chart .seg button { font-size: 15px; }
}

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; }

/* 表单操作条：手机端吸附在底部导航上方 */
.form-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.form-actions .small { color: var(--muted); margin-right: auto; }
@media (max-width: 899px) {
  .form-actions {
    position: sticky; bottom: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom)); z-index: 5;
    background: var(--surface);
    border: 0; border-radius: var(--radius-sm); padding: 10px; box-shadow: none;
  }
  body.no-nav .form-actions { bottom: calc(12px + env(safe-area-inset-bottom)); }
  .form-actions button.primary { flex: 1; min-height: 44px; }
  .form-actions .small { display: none; }
}

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(12px) scale(.96);
  background: var(--text); color: var(--on-accent); border: 0;
  padding: 10px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; z-index: 50; max-width: calc(100% - 32px); text-align: center;
  box-shadow: none;
  transition: opacity var(--dur-base) var(--ease-in), transform var(--dur-base) var(--ease-in);
}
/* 进场带一点回弹，退场直接下沉淡出 */
.toast.show {
  opacity: 1; transform: translateX(-50%);
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-slow) var(--ease-spring);
}
.toast.err { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
@media (min-width: 900px) { .toast { left: calc(50% + var(--sidebar-w) / 2); } body.auth .toast { left: 50%; } }
@media (max-width: 899px) { .toast { bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); } }

/* 档案页 */
#app form.stack > * + * { margin-top: 14px; }
.result-card { background: var(--card); border-color: var(--accent-soft); }
.result-card .card-head h2 { gap: 8px; }
.result-card .card-head .icon { color: var(--accent); }
.onboard-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 28px; }
.onboard-brand img { border-radius: 8px; }
.view > .section, .view > .card { margin-top: 14px; }

/* 搜索框、周选择 */
.search { position: relative; display: flex; align-items: center; }
.search .icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 36px; width: 240px; }
.week-picker { width: auto; min-width: 220px; }
@media (max-width: 899px) {
  .search { flex: 1; }
  .search input { width: 100%; }
  .week-picker { width: 100%; }
}
.notice .icon { margin-top: 2px; }

.view > .sticky-sum { max-width: none; margin: 0; }

/* 品牌选择：全部品牌，可滚动；不能配餐的置灰 */
.brand-grid { max-height: 46vh; overflow: auto; padding: 2px; }
.brand-card .brand-count { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.brand-card.disabled { opacity: .5; cursor: not-allowed; background: var(--subtle); }
.brand-card.disabled:hover { border-color: var(--line-strong); }

/* 品牌字标：中文 + 英文 */
.brand em, .onboard-brand em { font-style: normal; font-weight: 600; color: var(--muted); letter-spacing: .04em; font-size: .82em; margin-left: 2px; }
.sidebar .brand img, .auth-card .brand img, .onboard-brand img { border-radius: 0; }

/* 拍照识别 */
.photo-section { border: 0; border-radius: var(--radius-md); padding: 12px 14px; background: var(--subtle); display: grid; gap: 10px; }
.photo-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.photo-head h3 { gap: 6px; font-size: 15px; }
.photo-head h3 .icon { color: var(--accent); }
.photo-head p { margin-top: 4px; }
.photo-grid { display: grid; grid-template-columns: repeat(2, 120px); gap: 12px; }
.photo-tile {
  position: relative; display: grid; place-items: center; aspect-ratio: 1 / 1; width: 120px; border-radius: var(--radius-sm); overflow: hidden; cursor: pointer;
  border: 0; background: var(--card);
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.photo-tile:hover { border-color: var(--accent); background: var(--accent-soft); }
.photo-tile.has-photo { border-style: solid; }
.photo-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--subtle); } /* 铺满方框并等比缩小，完整显示不裁切 */
.photo-empty { display: grid; justify-items: center; gap: 2px; text-align: center; color: var(--muted); font-size: 11.5px; line-height: 1.35; padding: 6px; }
.photo-empty .icon { color: var(--accent); margin-bottom: 2px; }
.photo-empty b { color: var(--text); font-size: 13px; }
.photo-retake, .photo-label { position: absolute; font-size: 12px; font-weight: 600; color: var(--overlay-text); background: var(--overlay); border-radius: 999px; padding: 3px 9px; display: inline-flex; align-items: center; gap: 4px; }
.photo-retake { right: 5px; bottom: 5px; font-size: 11px; padding: 2px 7px; }
.photo-label { left: 5px; top: 5px; font-size: 11px; padding: 2px 7px; }
.spinner.sm { width: 12px; height: 12px; border-width: 2px; margin-right: 6px; }
@media (max-width: 520px) { .photo-head { flex-direction: column; } }
/* 识别后自动填入的字段：灰底提示核对；用户修改后取消高亮 */
input.filled, .filled input { border-color: var(--accent); background: var(--accent-soft); }
.photo-view { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.photo-view figure { margin: 0; }
.photo-view img { width: 100%; border-radius: var(--radius-sm); border: 0; display: block; }
.photo-view figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; text-align: center; }
@media (max-width: 520px) { .photo-view { grid-template-columns: 1fr; } }

/* 照片识别状态：每张照片下方单独显示 */
.photo-col { display: grid; gap: 8px; align-content: start; }
.photo-status { display: flex; align-items: center; gap: 6px; font-size: 12.5px; flex-wrap: wrap; }
.photo-status.busy { color: var(--accent-text); }
.photo-status.done { color: var(--text-2); font-weight: 600; }
.photo-status.error { color: var(--text-2); }
.photo-status .retry { min-height: 30px; padding: 0 10px; font-size: 12.5px; color: var(--accent-text); border-color: var(--accent); }
.photo-status .spinner.sm { margin-right: 0; }

.tpl-edit-meal { border: 0; border-radius: var(--radius-sm); padding: 10px; background: var(--subtle); display: grid; gap: 6px; }
.tpl-edit-head { display: flex; align-items: center; gap: 8px; }
.tpl-edit-head input { flex: 1; min-width: 0; font-weight: 600; }
.tpl-edit-item { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.tpl-edit-item .input-unit { width: 120px; flex: none; }
.tpl-edit-item .input-unit input { text-align: right; padding-right: 32px; }

/* ---------- 档案：紧凑展示 ---------- */
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; }
.grid-stats .stat { padding: 10px 12px; min-width: 0; }
.grid-stats .stat .v { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.ratio .k { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
label.field > span.hint > button { align-self: flex-start; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 18px; }
.info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.info .k { font-size: 12px; color: var(--muted); }
.info .v { font-size: 14.5px; font-weight: 500; overflow-wrap: anywhere; }

/* ---------- 食材：缩略图、分类、过敏原、筛选 ---------- */
.thumb { width: 36px; height: 36px; flex: none; border-radius: 8px; object-fit: cover; background: var(--subtle); border: 0; }
.thumb.empty { display: inline-block; }
.food-id { display: flex; align-items: center; gap: 10px; }
.food-name-cell { white-space: normal; min-width: 180px; }
.cat-tag { display: inline-block; margin-left: 6px; font-size: 11px; line-height: 16px; padding: 0 6px; border-radius: 999px; background: var(--card-2); color: var(--text-2); border: 0; vertical-align: 1px; }
.cat-tag.carbs { color: var(--text-2); }
.cat-tag.carbs::before { background: var(--c); }
.cat-tag.protein { color: var(--text-2); }
.cat-tag.protein::before { background: var(--p); }
.cat-tag.fat { color: var(--text-2); }
.cat-tag.fat::before { background: var(--f); }
.cat-tag:is(.carbs, .protein, .fat)::before { content: ""; display: inline-block; width: 5px; height: 5px; margin-right: 4px; border-radius: 50%; vertical-align: 2px; }
.cat-tag.supplement { color: var(--accent-text); border-color: currentColor; }
.allergen { color: var(--warn); }
.effect { color: var(--text-2); }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters .brand-filter { width: auto; min-width: 140px; margin-left: auto; }
@media (max-width: 899px) { .filters .brand-filter { margin-left: 0; flex: 1; } }
.picker-list .opt-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.picker-list .opt .thumb { width: 32px; height: 32px; }
.picker-list .opt .allergen { display: block; font-size: 11.5px; }
.picker-list .opt.create { color: var(--accent-text); font-weight: 500; border: 0; border-radius: 0 0 8px 8px; }
.item .item-thumb { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); z-index: 1; pointer-events: none; display: flex; }
.item .item-thumb:empty { display: none; }
.item .item-thumb .thumb { width: 30px; height: 30px; border-radius: 7px; }
.item .food-cell.has-thumb .picker-input { padding-left: 42px; }
.item .food-cell.has-thumb .brand-flag { padding-left: 42px; }
dialog.modal.wide { width: min(760px, calc(100% - 32px)); }
.share-posters { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 16px; }
.share-poster { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 12px; margin: 0; min-width: 0; }
.share-frame { align-self: start; max-height: min(62vh, 620px); overflow: auto; overscroll-behavior: contain; border-radius: var(--radius-sm); }
.share-frame img { display: block; width: 100%; height: auto; }
@media (min-width: 900px) {
  dialog.modal.share-dialog { width: min(820px, calc(100% - 32px)); }
}
@media (max-width: 899px) {
  .share-posters { grid-auto-columns: 80%; overflow-x: auto; scroll-snap-type: x mandatory; }
  .share-poster { scroll-snap-align: center; }
  .share-posters:has(> :only-child) { grid-auto-columns: 100%; }
}
.modal-body .card { border: 0; box-shadow: none; padding: 0; background: transparent; margin: 0 !important; }

/* ---------- 饮食：当天标签 ---------- */
.ring-col { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.day-tag { min-height: 28px; padding: 0 12px; border-radius: 999px; font-size: 12.5px; border: 0; background: transparent; color: var(--muted); gap: 4px; }
.day-tag.on { border: 0; background: var(--card-2); color: var(--text-2); font-weight: 600; }

/* 日期角标（当天标签） */
.corner-tag { display: inline-block; margin-left: 3px; transform: translateY(-7px); font-size: 10px; line-height: 15px; padding: 0 5px; border-radius: 999px; background: var(--card-2); color: var(--text-2); font-weight: 600; white-space: nowrap; }
.date-cell { white-space: nowrap; }

/* ---------- 日志：表格视图（按页面宽度铺满，不横向滚动） ---------- */
.sheet-wrap { border: 0; border-radius: var(--radius-md); overflow: hidden; }
.sheet { table-layout: fixed; width: 100%; font-size: 12.5px; }
.sheet th { padding: 7px 2px; text-align: center; white-space: normal; line-height: 1.3; font-size: 11.5px; }
.sheet td { padding: 0; white-space: normal; }
.sheet td.sheet-date { padding: 4px 6px; }
.sheet tr.sel td.sheet-date { background: var(--accent-soft); }
.sheet-day { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 4px; line-height: 1.25; }
.sheet-day b { font-weight: 600; font-variant-numeric: tabular-nums; }
.sheet-day small { color: var(--muted); font-size: 11px; }
.sheet-day .corner-tag { transform: none; margin-left: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.sheet .sheet-cell input, .sheet .sheet-cell select {
  display: block; width: 100%; min-width: 0; height: 34px; min-height: 34px; border: 0; border-radius: 0; background: transparent; box-shadow: none;
  padding: 0 4px; font-size: 12.5px; text-overflow: ellipsis;
}
.sheet .sheet-cell select { -webkit-appearance: none; appearance: none; background-image: none; text-align: center; text-align-last: center; cursor: pointer; }
.sheet .sheet-cell.num input { text-align: right; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.sheet .sheet-cell.num input::placeholder { color: var(--muted); opacity: .7; }
.sheet .sheet-cell.num input::-webkit-inner-spin-button, .sheet .sheet-cell.num input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.sheet .sheet-cell input:focus, .sheet .sheet-cell select:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--input-bg); }
.sheet tbody tr:hover td { background: var(--hover); }
.sheet tr.incomplete td.sheet-date { color: var(--text-2); }
.sheet tr.incomplete td.sheet-cell:nth-child(2) { background: var(--danger-soft); }
button.link { border: 0; background: transparent; padding: 0; min-height: 0; color: inherit; font: inherit; cursor: pointer; }
button.link:hover { color: var(--accent-text); background: transparent; }

/* 食材表单：分类默认显示，点「修改」展开 */
.cat-tag.lg { margin-left: 0; font-size: 13px; line-height: 24px; padding: 0 12px; }
button.sm { min-height: 28px; padding: 0 10px; font-size: 13px; }

/* ---------- 食材：详情与紧凑表单 ---------- */
.food-id.clickable { cursor: pointer; }
.food-id.clickable:hover .food-link { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }
.food-detail { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: 18px; align-items: start; }
.food-detail:not(:has(.detail-photos)) { grid-template-columns: 1fr; }
.detail-photos { display: grid; gap: 10px; }
.detail-photos img { width: 100%; max-height: 220px; object-fit: contain; border-radius: var(--radius-sm); border: 0; background: var(--subtle); display: block; }
.detail-body { display: grid; gap: 12px; align-content: start; }
.detail-price { font-weight: 600; font-variant-numeric: tabular-nums; }
.detail-table { font-size: 14px; }
.detail-table th, .detail-table td { padding: 8px 10px; }
.detail-table tbody th { font-weight: 500; color: var(--text-2); background: transparent; position: static; font-size: 13px; }
@media (max-width: 620px) { .food-detail { grid-template-columns: 1fr; } .detail-photos { grid-template-columns: 1fr 1fr; } }

.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 620px) { .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.form-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.form-meta .meta-label { color: var(--text-2); font-weight: 500; }
.form-meta .allergen { margin-left: auto; }
.food-form.compact { gap: 12px; }
.similar-foods { display: grid; gap: 6px; min-width: 0; }
.similar-foods h3 { margin: 0; font-size: 14px; font-weight: 500; }
.similar-food { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; min-height: 44px; padding: 8px; text-align: left; }
.similar-food-info { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.similar-food-info > span, .similar-food-info > small { display: block; }
.similar-food-info > small { margin-top: 3px; color: var(--muted); font-size: 12px; font-weight: 400; }
.similar-food-info .badge { margin-left: 6px; }
.food-form.compact label.field { gap: 5px; font-size: 12.5px; }
.food-form.compact .photo-section { grid-template-columns: auto 1fr; align-items: center; padding: 8px 12px; gap: 14px; }
.food-form.compact .photo-grid { grid-template-columns: repeat(2, 84px); gap: 10px; }
.food-form.compact .photo-grid .photo-col { grid-template-columns: 84px auto; grid-auto-flow: column; align-items: center; }
.food-form.compact .photo-tile { width: 84px; height: 84px; aspect-ratio: auto; }
.food-form.compact .photo-empty span { display: none; }
.food-form.compact .photo-empty b { font-size: 11.5px; }
@media (min-width: 621px) { .food-form.compact .photo-grid { grid-template-columns: repeat(2, auto); } }

/* ---------- 体型：插画主视图 + 随身体数据变化的 SVG 剪影 ---------- */
.body-comparison .card-head { margin-bottom: 18px; }
.body-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; max-width: 640px; margin: auto; }
.body-figure { min-width: 0; text-align: center; }
.body-caption { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 2px 10px; font-size: 13px; }
.body-caption .row { gap: 5px; }
.body-value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.body-goal .body-value { color: var(--accent-text); }
.body-stage { position: relative; aspect-ratio: 3 / 4; overflow: hidden; border-radius: var(--radius-md); background: var(--card); isolation: isolate; }
.body-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transform: scale(var(--body-height, 1)); transform-origin: center bottom; transition: transform var(--dur-slow) var(--ease-out); }
.body-silhouette { position: absolute; z-index: 1; right: 8px; bottom: 8px; width: 20%; height: 30%; padding: 4px; border-radius: 8px; color: var(--text-2); background: var(--surface); fill: currentColor; }
.body-goal .body-silhouette { color: var(--accent-text); }
.body-form { transform-origin: 50px 190px; transition: transform var(--dur-slow) var(--ease-out); }
.body-figure > .small { display: block; margin-top: 8px; }
.body-projection { text-align: center; margin-top: 16px; }
.body-stage.asset-error .body-silhouette { inset: 10% 25%; width: 50%; height: 80%; background: none; }
.body-compact .body-pair { max-width: 320px; gap: 16px; }
.body-compact .body-stage { max-height: 180px; }
.body-compact .body-value { font-size: 16px; }
@media (max-width: 480px) {
  .body-pair { gap: 12px; }
  .body-caption { align-items: flex-start; flex-direction: column; gap: 2px; }
  .body-value { font-size: 18px; }
  .body-comparison .card-head { gap: 12px; }
  .body-comparison .card-head > .row:last-child { gap: 4px; }
  .body-comparison .seg button { padding: 0 10px; }
}

/* ---------- 减少动态效果：去掉位移、缩放和绘制，只保留淡入淡出（JS 数字滚动同样直接到位） ---------- */
@media (prefers-reduced-motion: reduce) {
  button:active:not(:disabled), .brand-card:active, .photo-tile:active, .food-id.clickable:active, .nav a:active { transform: none; }
  .sticky-sum { transform: none; }
  .toast, .toast.show { transform: translateX(-50%); }
  dialog.modal[open] { animation-name: fade-in; }
  dialog.modal.closing { animation-name: fade-out; }
  .body-form, .body-stage img { transition: none; }
}

/* Private body photos share the comparison card. */
.body-photos { border: 0; margin-top: 20px; padding-top: 16px; }
.body-photo-pair { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; }
.body-photo-pair > * { width: min(200px, calc(50% - 8px)); min-width: 0; }
.body-photo-pair figure { margin: 0; }
.body-photo-pair img { display: block; width: 100%; max-height: 280px; object-fit: contain; border-radius: var(--radius-md); background: var(--subtle); }
.body-photo-pair figcaption { margin-top: 6px; font-size: 12px; text-align: center; color: var(--muted); }

/* 保存反馈始终留在操作附近，失败可直接重试。 */
.save-state[hidden], .save-state button[hidden] { display: none; }
.save-state { flex-wrap: wrap; }
.save-state button { font-size: inherit; }
.save-state:has([aria-live]:empty)::before { display: none; }

/* ---------- 今天：手机单列、桌面概览与饮食两栏 ---------- */
:root { --floating-shadow: 0 8px 24px var(--chart-area); }
.today-page { font-size: 15px; }
.today-page button { min-height: 44px; }
.today-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.today-header h1 { flex: none; font-size: 21px; font-weight: 600; }
.today-header-actions { flex-wrap: nowrap; justify-content: flex-end; gap: 6px; min-width: 0; }
.today-header-actions > button { flex: none; padding-inline: 10px; }
.today-header-actions > .ghost { width: 44px; padding: 0; }
.today-header button { border-radius: 999px; }
.today-header .today-day-type { gap: 6px; background: var(--card); font-size: 13px; }
.today-header .today-day-type.is-train { background: var(--train); color: var(--train-ink); }
.today-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); margin: 12px 0 18px; padding-bottom: 8px; overflow: visible; }
.today-week button { display: grid; justify-items: center; gap: 5px; padding: 4px 0; background: transparent; color: var(--muted); }
.today-week small { font-size: 11.5px; }
.today-week button > span { position: relative; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 999px; color: var(--muted); }
.today-week .logged > span { background: var(--day-logged); color: var(--text); }
.today-week .future { opacity: .5; }
.today-week .future > span { background: transparent; color: var(--muted); }
.today-week .sealed > span { outline: 1.5px solid var(--text); outline-offset: -1.5px; }
.today-week .is-today > span { background: var(--accent); color: var(--on-accent); }
.today-week .selected > span::after { content: ''; position: absolute; bottom: -8px; width: 4px; height: 4px; border-radius: 999px; background: var(--text); }
.today-layout { display: grid; gap: 18px; align-items: start; }
.today-overview { min-width: 0; }
.today-overview > .save-state { margin: 8px 4px 0; }
.today-summary { display: grid; gap: 8px; }
.today-hero { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px; background: var(--card); border-radius: 24px; }
.today-hero-content { flex: 1 1 160px; min-width: 0; }
.today-hero-actions { display: flex; align-items: center; gap: 6px; margin-top: 10px; min-width: 0; }
.today-hero-actions > button { min-height: 28px; padding: 0 6px; border-radius: 999px; background: var(--card-2); font-size: 11px; }
.today-hero-actions > .day-tag { display: block; flex: 0 1 auto; min-width: 0; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-hero-actions > .day-ratio { flex: none; white-space: nowrap; }
.day-ratio-options { display: grid; gap: 8px; }
.day-ratio-options > button { display: flex; justify-content: flex-start; gap: 12px; padding: 12px; background: var(--card); text-align: left; }
.day-ratio-options > button.on { background: var(--accent); color: var(--on-accent); }
.day-ratio-options b { flex: none; font-weight: 600; }
.day-ratio-options small { margin-left: auto; color: inherit; }
.today-hero small { display: block; color: var(--muted); font-size: 12px; }
.today-big { display: flex; align-items: baseline; gap: 6px; font-size: 50px; line-height: 1.1; margin: 3px 0 6px; font-weight: 600; letter-spacing: -.03em; }
.today-big > .today-kcal, .today-sticky .today-kcal { display: inline; color: var(--muted); font-size: 16px; font-weight: 400; letter-spacing: 0; }
@media (max-width: 359px) {
  .today-hero { padding: 16px; gap: 8px; }
}
.today-big.warn, .today-sticky .warn { color: var(--warn); }
.today-big.over, .today-sticky .over { color: var(--danger); }
.today-ring { position: relative; flex: none; width: 92px; height: 92px; }
.today-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.today-ring > span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 14px; font-weight: 600; }
.today-macros { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.today-macro { display: grid; justify-items: start; gap: 2px; padding: 13px 12px; border-radius: 20px; background: var(--card); }
.today-macro small { color: var(--muted); font-size: 12px; font-weight: 400; }
.today-macro > b { font-size: 18px; font-weight: 600; letter-spacing: -.03em; }
.today-macro-ring { margin-top: 5px; display: block; width: 26px; height: 26px; }
.today-macro-ring svg { display: block; width: 100%; height: 100%; }
.today-macro-ring .ring-fill { stroke: currentColor; }
.today-quiet { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.today-quiet button { display: flex; justify-content: space-between; gap: 6px; min-height: 44px; padding: 0 13px; border-radius: 14px; background: var(--card); font-size: 13px; color: var(--muted); }
.today-quiet b { font-weight: 600; color: var(--text); }
.today-meals { min-width: 0; }
.today-meals > h2 { font-size: 15.5px; margin: 0 2px 10px; }
.today-meals .meals { gap: 8px; }
.today-meals .meal { border-radius: 20px; }
.today-meals .meal-head { position: relative; }
.today-meals .meal-menu-button { position: absolute; right: 4px; top: 4px; width: 44px; min-height: 44px; padding: 0; }
.today-meals .meal-toggle { display: flex; align-items: center; gap: 10px; padding: 14px 52px 14px 14px; border-radius: 20px; }
.today-meals .meal-heading { display: grid; grid-template-columns: 1fr auto; gap: 2px 6px; flex: 1; min-width: 0; }
.meal-label { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.meal-menu input { font-size: 16px; }
.meal-menu > button { width: 100%; justify-content: flex-start; }
.today-meals .meal-title { font-size: 15px; overflow-wrap: anywhere; }
.today-meals .meal-clock { font-size: 12px; }
.today-meals .meal-chevron { display: none; }
.today-meals .meal-sum { display: flex; align-items: center; flex-wrap: wrap; grid-column: 1 / -1; gap: 4px 8px; margin: 0; text-align: left; }
.today-meals .meal-sum b { font-size: 12px; font-weight: 400; color: var(--muted); }
.today-macro-text { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 7px; color: var(--muted); font-size: 11.5px; font-weight: 400; }
.today-macro-text > span { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.today-macro-text i { width: 5px; height: 5px; border-radius: 999px; }
.today-food-placeholder { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 999px; background: var(--track); color: var(--muted); font-size: 12px; object-fit: cover; }
.today-meals .items { padding: 4px 10px; }
.today-food-row { display: flex; align-items: center; gap: 9px; min-height: 64px; padding: 6px 4px; background: var(--card); cursor: pointer; }
.today-food-row > .thumb { flex: none; width: 30px; height: 30px; border-radius: 999px; object-fit: cover; }
.today-food-info { flex: 1; min-width: 0; display: grid; gap: 1px; }
.today-food-info > .today-food-name { display: block; min-height: 44px; max-width: 100%; padding: 0; text-align: left; font-size: 15px; font-weight: 400; white-space: normal; overflow-wrap: anywhere; }
.today-food-amount { display: grid; flex: none; text-align: right; gap: 2px; }
.today-food-amount b { font-size: 13px; font-weight: 500; }
.today-food-amount small { color: var(--muted); font-size: 11.5px; }
.today-meals .swipe-delete { gap: 2px; }
.today-meals .swipe-delete-button { padding: 0 4px; font-size: 12px; }
.today-meals .meal-foot { flex-wrap: wrap; }
.today-meals .meal-order button { width: 44px; min-width: 44px; }
.today-item-detail { display: grid; justify-items: center; gap: 8px; margin: 16px 0; }
.today-checkin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.today-checkin-grid input[type=checkbox] { width: 20px; height: 20px; min-height: 20px; margin: 0; }
.today-menu > button { width: 100%; justify-content: flex-start; }
.today-add-preview { display: grid; gap: 8px; padding: 16px; border-radius: 20px; background: var(--card); }
.today-add-preview > b { font-size: 28px; font-weight: 600; }
.today-add-preview small { color: var(--muted); }
.today-add-food { display: grid; gap: 10px; min-width: 0; }
.today-add-food > .primary { width: 100%; }
.today-add-quantity { display: grid; gap: 8px; min-width: 0; }
.today-add-selection { display: flex; align-items: center; gap: 10px; min-width: 0; }
.today-add-selection > .thumb { width: 44px; height: 44px; border-radius: 999px; flex: none; }
.today-add-selection > div { min-width: 0; }
.today-add-selection b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.food-entry-selected .today-add-preview { padding: 10px 14px; gap: 4px; }
.food-entry-selected .today-add-preview > b { font-size: 24px; }
.food-entry-selected .modal-body { max-height: calc(100dvh - 100px - env(safe-area-inset-bottom)); padding: 10px 16px 16px; }
.food-entry-selected .today-add-food, .food-entry-selected .today-add-quantity { gap: 6px; }
.food-entry-selected .serving-shortcuts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 6px; gap: 6px; }
.food-entry-selected .serving-shortcuts button { min-width: 0; padding-inline: 6px; white-space: normal; overflow-wrap: anywhere; }

@media (max-height: 650px) {
  .food-entry-selected .today-add-preview { grid-template-columns: minmax(0, 1fr) auto; padding: 8px 12px; }
  .food-entry-selected .intake-preview-track { grid-column: 1 / -1; }
  .food-entry-selected .today-add-selection b { -webkit-line-clamp: 1; }
  .food-entry-selected .serving-shortcuts button { font-size: 13px; }
}

.today-add { position: fixed; opacity: 0; visibility: hidden; pointer-events: none; transform: scale(.4); right: 24px; bottom: 24px; z-index: 21; width: 54px; height: 54px; min-height: 54px; padding: 0; border-radius: 999px; box-shadow: var(--floating-shadow); }
.today-sticky .sticky-inner { grid-template-columns: 1fr 100px; align-items: center; }
.today-add.is-visible { opacity: 1; visibility: visible; pointer-events: auto; transform: scale(1); transition-delay: 0s; }
.today-add.is-entering, .today-add.is-exiting { will-change: transform, opacity; }
.today-add.is-exiting { visibility: visible; animation: shell-add-out 260ms cubic-bezier(.4,0,.6,1) both; }
.today-add.is-entering { animation: shell-add-in 420ms cubic-bezier(.32,.72,0,1) 120ms both; }
.today-add[data-motion="off"] { animation: none; transition: none; }
body.auth .today-add, body.no-nav .today-add { opacity: 0; visibility: hidden; pointer-events: none; }
@keyframes shell-add-out {
  from { opacity: 1; transform: scale(1); }
  50% { opacity: 1; }
  to { opacity: 0; transform: scale(.4); }
}
@keyframes shell-add-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes shell-add-in {
  from { opacity: 0; transform: scale(.6); }
  70% { opacity: 1; transform: scale(1.06); }
  to { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
  .today-add, .today-add.is-entering, .today-add.is-exiting { transform: none; animation: none; transition: opacity 200ms ease, visibility 0s 200ms; }
  .today-add.is-visible { transform: none; transition-delay: 0s; }
  .today-add.is-exiting { animation: shell-add-fade-out 200ms ease both; }
}

@media (min-width: 900px) {
  .today-layout { grid-template-columns: minmax(290px, 1fr) minmax(0, 1.4fr); gap: 24px; }
  .today-overview { position: sticky; top: 24px; }
  .today-sticky { display: none; }
}
@media (max-width: 899px) {
  .today-add { right: 14px; bottom: calc(16px + env(safe-area-inset-bottom)); }
}

/* 记一笔与打卡（CTF-62） */
.weight-form > * + * { margin-top: 12px; }
.weight-body-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.weight-body-fields input { font-size: 16px; }
.weight-actions { display: flex; gap: 8px; }
.weight-actions .primary { flex: 1; }
.picker-details { display: block; margin-top: 4px; }
.today-add-food, .checkin-form { font-size: 15px; }
.today-add-food input, .checkin-form input, .checkin-form textarea { font-size: 16px; }
.today-add-food .picker-list { position: static; min-width: 0; max-height: 36dvh; margin-top: 6px; background: var(--card); border-radius: 20px; box-shadow: none; }
.today-add-food .picker-list .opt { min-height: 60px; }
.today-add-preview { position: sticky; top: 0; z-index: 1; }
.today-add-preview > b.warn { color: var(--warn); }
.today-add-preview > b.over { color: var(--danger); }
.intake-preview-track { position: relative; height: 6px; overflow: hidden; border-radius: 999px; background: var(--track); }
.intake-preview-track i { position: absolute; inset-block: 0; background: var(--text); border-radius: 999px; }
.intake-preview-ghost { opacity: .34; }
.today-recent-foods { display: grid; gap: 6px; }
.today-recent-food { display: flex; width: 100%; gap: 10px; padding: 12px; text-align: left; background: var(--card); border-radius: 20px; }
.today-recent-food .thumb { flex: none; width: 32px; height: 32px; border-radius: 999px; object-fit: cover; }
.today-recent-info { flex: 1; display: grid; gap: 4px; min-width: 0; }
.today-recent-amount { display: grid; flex: none; gap: 4px; font-size: 13px; text-align: right; }
.today-recent-amount small { font-size: 12px; color: var(--muted); }
.today-add-selection b { font-size: 15px; font-weight: 500; }
.today-photo-entry { justify-content: flex-start; }
.today-add-quantity:empty { display: none; }
.checkin-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.checkin-tile { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 2px; min-height: 92px; padding: 14px 12px; border-radius: 20px; background: var(--card); font-size: 15px; transition: none; }
.checkin-tile b { font-size: 23px; font-weight: 500; letter-spacing: -.03em; }
.checkin-tile small { color: var(--muted); font-size: 12px; }
.checkin-tile[aria-pressed=true] { background: var(--text); color: var(--on-accent); }
.checkin-tile[aria-pressed=true] small { color: inherit; }
.checkin-editors { display: grid; gap: 8px; }
.checkin-editor { display: flex; align-items: end; gap: 8px; padding: 12px; border-radius: 20px; background: var(--card); }
.checkin-editor .field { flex: 1; min-width: 0; }
.checkin-form .chips button { flex: 1; min-width: 44px; font-size: 15px; transition: none; }
.checkin-form .scale-chips { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); width: 100%; }
.checkin-form .scale-chips button { min-width: 0; padding: 0 4px; font-size: 13px; white-space: nowrap; }
.checkin-more summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; }
.checkin-more-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 12px 0; }
.checkin-conflict { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; background: var(--card); border-radius: 20px; }
.checkin-conflict span { font-size: 13px; }
.checkin-form > .primary, .today-add-food > .primary { width: 100%; }

/* ---------- 桌面布局（CTF-73） ---------- */
@media (min-width: 900px) {
  body:not(.auth):not(.no-nav) .main > * { max-width: 1440px; }
  .sticky-inner { max-width: 1440px; }

  .today-layout { grid-template-columns: minmax(240px, .9fr) minmax(0, 1.4fr); }
  .today-overview .today-week { max-width: 336px; margin: 0 0 20px; }
  .today-hero { flex-wrap: wrap; padding: 24px; }
  .today-meals .meals { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .today-meals .meal { padding: 24px; }
  .today-meals .meal-toggle { padding: 0 44px 0 0; border-radius: 0; }
  .today-meals .meal-menu-button { top: 0; right: 0; }
  .today-meals .meal-head { border-radius: 0; }
  .today-meals .meal-heading { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .today-meals .meal-label { display: flex; align-items: baseline; flex-wrap: nowrap; gap: 8px; min-width: 0; }
  .today-meals .meal-clock { font-size: 14px; }
  .today-meals .meal-sum { display: grid; grid-column: 2; justify-items: end; gap: 4px; max-width: 150px; text-align: right; }
  .today-meals .meal-sum b, .today-meals .today-macro-text { font-size: 13px; }
  .today-meals .items { padding: 16px 0; }
  .today-meals .meal-foot { padding: 0; justify-content: space-between; }
  .today-meals .today-food-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 48px 48px; gap: 6px; min-height: 56px; padding: 6px 0; }
  .today-meals .today-food-row > .thumb, .today-meals .today-food-row > .today-food-placeholder { grid-column: 1; grid-row: 1; width: 44px; height: 44px; border-radius: 14px; }
  .today-meals .today-food-info { grid-column: 2; grid-row: 1; }
  .today-meals .today-food-amount { display: contents; }
  .today-meals .today-food-quantity, .today-meals .today-food-kcal { min-width: 0; grid-row: 1; font-size: 13px; font-weight: 400; text-align: right; overflow-wrap: anywhere; }
  .today-meals .today-food-quantity { grid-column: 3; }
  .today-meals .today-food-kcal { grid-column: 4; }
  .today-meals .today-food-info > small { font-size: 13px; }
  .today-meals .swipe-delete-button { font-size: 13px; }

  .trend-page, .foods-page, .profile-page { font-size: 14px; }
  .trend-page .card, .foods-page .card, .profile-page .card, .profile-overview .stat { padding: 24px; }
  .trend-page .small, .foods-page .small, .profile-page .small,
  .trend-page .stat .k, .trend-page .stat .v small, .trend-page .sheet-day small,
  .profile-page .stat .k, .profile-page .stat .v small, .profile-page .info .k,
  .profile-page .field, .profile-page .hint, .profile-page .section-head p { font-size: 14px; }
  .trend-page table, .foods-page table, .trend-page th, .foods-page th,
  .trend-page .sheet .sheet-cell input, .trend-page .sheet .sheet-cell select,
  .foods-page .cat-tag, .foods-page .badge, .foods-page .chips button { font-size: 14px; }
  .profile-page .profile-overview { gap: 16px; }
  .profile-page .profile-settings { padding: 24px; }
  .trend-page .trend-numbers, .profile-page .grid-stats { gap: 16px; }

  /* 搜索和筛选共用吸顶容器，窄桌面允许筛选组内换行。 */
  .food-library-controls { grid-template-columns: minmax(0, 1fr) minmax(160px, 240px); align-items: start; }
  .foods-page .search { grid-column: 2; grid-row: 1; }
  .foods-page .search input { width: 100%; min-width: 0; }
  .food-library-controls > .filters { grid-column: 1; grid-row: 1; }
  .foods-page .filters > * { min-width: 0; max-width: 100%; }
  .foods-page .brand-filter { width: auto; min-width: 0; flex: 1 1 140px; }

  .trend-page > * { min-width: 0; }
  .trend-logs .sheet { min-width: 1000px; }
  .trend-week-table th, .trend-week-table td { padding: 10px 8px; }
  .trend-week-table th, .trend-week-table td:nth-child(2), .trend-week-table td:last-child { white-space: normal; }
  .trend-week-table th:last-child, .trend-week-table td:last-child { width: 24%; overflow-wrap: anywhere; }
}

@media (min-width: 1200px) {
  .today-layout { grid-template-columns: 380px minmax(0, 1fr); }
  .today-overview .today-big { font-size: 64px; }
  .today-overview .today-ring { width: 120px; height: 120px; }
  .today-meals { --meal-columns: 44px minmax(0, 1fr) minmax(48px, .5fr) minmax(48px, .5fr) repeat(3, minmax(42px, .45fr)); }
  .today-meals .meal-heading, .today-meals .today-food-row { grid-template-columns: var(--meal-columns); column-gap: 8px; }
  /* 右侧菜单预留与食物行删除按钮相同的 44px + 2px，保持合计列对齐。 */
  .today-meals .meal-toggle { padding-right: 46px; }
  .today-meals .meal-label { grid-column: 1 / 4; grid-row: 1; }
  .today-meals .meal-sum, .today-meals .meal-sum > .today-macro-text,
  .today-meals .today-food-info, .today-meals .today-food-info > .today-macro-text { display: contents; }
  .today-meals .meal-sum > b { grid-column: 4; grid-row: 1; text-align: right; }
  .today-meals .today-food-name { grid-column: 2; grid-row: 1; }
  .today-meals .today-food-info > small { grid-column: 2; grid-row: 2; }
  .today-meals .today-nutrient-protein { grid-column: 5; }
  .today-meals .today-nutrient-carbs { grid-column: 6; }
  .today-meals .today-nutrient-fat { grid-column: 7; }
  .today-meals .today-macro-text > span { grid-row: 1; justify-content: flex-end; min-width: 0; white-space: normal; overflow-wrap: anywhere; font-size: 13px; text-align: right; }

  .trend-page { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; align-items: start; }
  .trend-page > * { grid-column: 1 / -1; margin-top: 0; }
  .trend-page > .trend-chart { grid-column: 1; grid-row: 1 / 4; }
  .trend-page > .trend-verdict { grid-column: 2; grid-row: 1; }
  .trend-page > .trend-numbers { grid-column: 2; grid-row: 2; }
  .trend-page > .trend-details { grid-column: 2; grid-row: 3; }
  .trend-details .trend-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .profile-page:has(> .profile-overview) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 320px); gap: 24px; align-items: start; }
  .profile-page:has(> .profile-overview) > .page-head { grid-column: 1 / -1; margin-bottom: 0; }
  .profile-page > .profile-overview { margin-bottom: 0; }
  .profile-page > form .section-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
  .profile-page > form .section-body > * { min-width: 0; margin-top: 0; }
  .profile-page > form .section-body > .grid-4 { display: contents; }
  .profile-page > form .section-body .field { min-width: 0; max-width: 360px; }
  .profile-page > form .section-body > .field:has(> .meal-defaults) { grid-column: 1 / -1; max-width: none; }
  .profile-page > form .meal-defaults { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .profile-page > form .meal-default input { max-width: 360px; }
}

/* 食材、我的（CTF-64） */
.foods-page, .profile-page { min-width: 0; }
.foods-page .page-actions .search { min-width: 0; }
.food-library-unit { font-size: 15px; }
.food-library-open { width: 100%; min-height: 44px; padding: 0; background: transparent; text-align: left; justify-content: flex-start; white-space: normal; }
.food-library-open:hover { background: transparent; }
.food-library-open > div { min-width: 0; overflow-wrap: anywhere; }
.food-library-list { display: none; }
.profile-overview { display: grid; gap: 20px; margin-bottom: 24px; min-width: 0; }
.profile-group { min-width: 0; padding: 12px 8px; border-radius: 20px; background: var(--card); }
.profile-group h2 { color: var(--muted); font-size: 12px; font-weight: 400; margin-bottom: 12px; }
.profile-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 4px; }
.profile-body .profile-metrics, .profile-daily .profile-metrics { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.profile-metric { min-width: 0; text-align: left; }
.profile-value { display: flex; align-items: baseline; gap: 0; white-space: nowrap; font-size: 20px; font-weight: 600; }
.profile-value small { font-size: 10px; font-weight: 400; letter-spacing: 0; }
.profile-label { margin-top: 4px; color: var(--muted); font-size: 12px; }
@media (min-width: 900px) {
  .profile-group { padding: 24px; }
  .profile-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 8px; }
}
.profile-settings { display: grid; gap: 6px; padding: 8px 16px; border-radius: var(--radius); background: var(--card); }
.profile-setting { min-width: 0; min-height: 56px; padding: 10px 0; justify-content: space-between; gap: 12px; font-size: 15px; text-align: left; background: transparent; white-space: normal; }
.profile-setting:hover { background: transparent; color: var(--muted); }
@media (max-width: 899px) {
  .food-library-table, .food-library-unit { display: none; }
  .food-library-list { display: grid; gap: 8px; list-style: none; padding: 0; margin: 0; }
  .food-library-item { min-width: 0; padding: 14px; background: var(--card); border-radius: 20px; }
  .food-library-open { display: flex; align-items: center; gap: 10px; font-size: 15px; }
  .food-library-open > .thumb { width: 44px; height: 44px; border-radius: 999px; }
  .food-library-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
  .food-library-name > span { font-size: 15px; font-weight: 500; }
  .food-library-name > span, .food-library-name > small { display: block; }
  .food-library-name small { color: var(--muted); font-size: 12px; font-weight: 400; }
  .food-library-energy { flex: none; display: grid; text-align: right; font-size: 20px; }
  .food-library-energy small { font-size: 15px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
  .food-library-macros { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 8px 0 0; font-size: 11.5px; color: var(--muted); }
  .food-library-macros > span::before { content: ''; display: inline-block; width: 5px; height: 5px; margin-right: 4px; border-radius: 999px; vertical-align: 2px; }
  .food-library-macros .protein::before { background: var(--protein); }
  .food-library-macros .carbs::before { background: var(--carbs); }
  .food-library-macros .fat::before { background: var(--fat); }
  .food-library-item .small { font-size: 15px; overflow-wrap: anywhere; }
  .foods-page button, .foods-page select, .foods-page .chips button { min-height: 44px; font-size: 15px; }
  .foods-page .filters > *, .foods-page .brand-filter { min-width: 0; max-width: 100%; }
  .profile-page .field, .profile-page .section-head p, .profile-page .small, .profile-page .stat .k,
  .profile-page .stat .v small, .profile-page .form-actions > span, .profile-page .hint { font-size: 15px; }
  .profile-page button, .profile-page select, .profile-page input { min-height: 44px; }
  .profile-page .seg button { font-size: 15px; }
  .profile-page .grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); }
  .profile-page .meal-defaults { grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); }
  .food-form.compact .field, .food-form.compact .small, .food-form.compact label.field { font-size: 15px; }
  .food-form button, .food-form input, .food-form select { min-height: 44px; }
  .food-form.compact .photo-section { grid-template-columns: 1fr; }
  .food-form .grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); }
  .food-form .grid-4 > .wide { grid-column: 1 / -1; }
  .food-detail .small, .food-detail .detail-table, .food-detail .detail-table th, .profile-password .field { font-size: 15px; }
  .modal:has(.food-detail) button, .profile-password button, .profile-password input { min-height: 44px; }
  .food-detail { min-width: 0; overflow-wrap: anywhere; }
  .food-detail .detail-table { table-layout: fixed; }
  .food-detail .detail-table th, .food-detail .detail-table td { white-space: normal; }
  .food-form.compact .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .food-form.compact .photo-grid .photo-col { grid-template-columns: minmax(0, 1fr); grid-auto-flow: row; }
  .food-form.compact .photo-tile { width: 100%; }
}

/* 手机保留独立卡片；吸顶层低于导航，弹窗由原生 dialog 顶层承载。 */
.foods-page > .page-head { flex-direction: row; align-items: center; }
.foods-page .page-actions { width: auto; }
.food-library-controls { position: sticky; top: 0; z-index: 12; display: grid; gap: 12px 16px; padding: 12px 0 14px; background: var(--bg); }
.food-library-controls > .filters { min-width: 0; margin: 0; }
.food-library-controls .search { min-width: 0; }
.foods-page .food-library-container { padding: 0; background: transparent; }
.food-library-open > .thumb { width: 44px; height: 44px; border-radius: 999px; }
.food-library-placeholder { display: inline-flex; align-items: center; justify-content: center; background: var(--track); color: var(--muted); font-size: 18px; }
@media (min-width: 900px) {
  /* 不建立 overflow 滚动祖先，表头随页面吸顶；宽表仍可随页面横向滚动。 */
  .food-library-table { overflow: visible; border-radius: 20px; }
  .food-library-table table { border-collapse: separate; border-spacing: 0; background: var(--card); border-radius: 20px; }
  .food-library-table th, .food-library-table td { padding: 12px 20px; }
  .foods-page .food-library-table th { top: var(--food-controls-height, 0px); z-index: 11; background: var(--card); font-size: 12px; }
  .food-library-table th:first-child { border-radius: 20px 0 0 0; }
  .food-library-table th:last-child { border-radius: 0 20px 0 0; }
  .food-library-table tbody td { height: 64px; background: transparent; border: 0; }
  .food-library-table tbody tr + tr td { border-top: 1px solid var(--hairline); }
  .food-library-table tbody tr:first-child td:first-child { border-top-left-radius: 20px; }
  .food-library-table tbody tr:first-child td:last-child { border-top-right-radius: 20px; }
  .food-library-table tbody tr:last-child td:first-child { border-bottom-left-radius: 20px; }
  .food-library-table tbody tr:last-child td:last-child { border-bottom-right-radius: 20px; }
  .food-library-table tbody tr:hover td { background: var(--hover); }
  .food-library-table .food-note-cell { white-space: normal; min-width: 160px; overflow-wrap: anywhere; }
  .food-library-table .food-library-placeholder { background: var(--bg); }
}

/* 内容多的灰卡：行之间用极细线，分组仍靠卡片和留白。 */
.today-meals .items { border-top: 1px solid var(--hairline); }
.today-meals .items > .swipe-delete + .swipe-delete { border-top: 1px solid var(--hairline); }
.sheet tbody tr + tr td, .trend-week-table tbody tr + tr td { border-top: 1px solid var(--hairline); }
.trend-week-link + .trend-week-link { border-top: 1px solid var(--hairline); }
.profile-settings { gap: 0; }
.profile-setting + .profile-setting { border-top: 1px solid var(--hairline); }
.detail-table tbody tr + tr th, .detail-table tbody tr + tr td { border-top: 1px solid var(--hairline); }
@media (max-width: 899px) {
  .today-meals .items { margin: 0 14px; padding: 4px 0; }
}
