/* FreshTrack 登录后应用 · 外壳与页面布局 */

.ft-app {
  display: grid;
  grid-template-columns: var(--ft-sidebar-w) minmax(0, 1fr);
  min-height: 100svh;
  background: linear-gradient(168deg, #f3f9ef 0%, #f8fbf6 34%, #eef6ea 78%, #eaf4e5 100%);
  color: var(--ft-ink);
}
:root[data-theme="dark"] .ft-app { background: var(--ft-bg); }

/* ── 侧边栏 ───────────────────────────────────────────────── */
.ft-side {
  position: sticky; top: 0; height: 100svh; z-index: 30;
  display: flex; flex-direction: column; gap: var(--ft-s3);
  padding: var(--ft-s4) var(--ft-s3);
  background: var(--ft-surface); border-right: 1px solid var(--ft-border);
}
.ft-side-head { padding: var(--ft-s2) var(--ft-s2) var(--ft-s1); }
.ft-brand { display: flex; align-items: center; gap: var(--ft-s2); text-decoration: none; color: var(--ft-ink); font-weight: 700; font-size: var(--ft-fs-heading); letter-spacing: -.01em; }
.ft-brand img { border-radius: 8px; }
.ft-nav { display: flex; flex-direction: column; gap: 2px; }
.ft-nav-item {
  display: flex; align-items: center; gap: var(--ft-s3);
  min-height: 44px; padding: 0 var(--ft-s3); border-radius: var(--ft-r-control);
  color: var(--ft-ink-2); text-decoration: none; font-size: var(--ft-fs-body); font-weight: 500;
  transition: background var(--ft-dur-hover), color var(--ft-dur-hover);
}
.ft-nav-item:hover { background: var(--ft-surface-2); color: var(--ft-ink); }
.ft-nav-item.is-active { background: var(--ft-brand-tint); color: var(--ft-brand-strong); font-weight: 600; }
.ft-nav-item--pro { color: var(--ft-brand-strong); }
.ft-nav-item--pro svg { color: var(--ft-brand-strong); }
.ft-side-foot { margin-top: auto; padding-top: var(--ft-s3); border-top: 1px solid var(--ft-border); }
.ft-user {
  display: flex; align-items: center; gap: var(--ft-s2);
  padding: var(--ft-s2); border-radius: var(--ft-r-control); text-decoration: none; color: inherit;
  transition: background var(--ft-dur-hover);
}
.ft-user:hover { background: var(--ft-surface-2); }
.ft-user-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ft-user-main strong { font-size: var(--ft-fs-label); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-user-main i { font-style: normal; font-size: var(--ft-fs-micro); color: var(--ft-ink-3); }

/* ── 主区域 ───────────────────────────────────────────────── */
.ft-body { display: flex; flex-direction: column; min-width: 0; }
.ft-main {
  flex: 1; width: 100%; max-width: var(--ft-content-max);
  margin: 0 auto; padding: var(--ft-s5) var(--ft-page-pad) var(--ft-s10);
  outline: none;
}
.ft-main:focus-visible { outline: none; }

.ft-top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--ft-s4);
  padding: var(--ft-s5) var(--ft-page-pad) var(--ft-s3);
  background: var(--ft-bg);
  background: color-mix(in srgb, var(--ft-bg) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ft-border);
}
.ft-top-titles { min-width: 0; }
.ft-top-title { margin: 0; font-size: var(--ft-fs-display); line-height: var(--ft-lh-display); font-weight: 700; letter-spacing: -.01em; }
.ft-top-context { margin: var(--ft-s1) 0 0; font-size: var(--ft-fs-label); color: var(--ft-ink-2); }
.ft-top-actions { display: flex; align-items: center; gap: var(--ft-s2); flex: none; }
.ft-lang { display: inline-flex; padding: 2px; gap: 2px; background: var(--ft-surface-2); border-radius: var(--ft-r-control); }
.ft-lang button {
  min-width: 40px; min-height: 32px; border: none; border-radius: 8px; background: none;
  font: inherit; font-size: var(--ft-fs-micro); font-weight: 600; color: var(--ft-ink-2); cursor: pointer;
}
.ft-lang button.is-active { background: var(--ft-surface); color: var(--ft-ink); box-shadow: var(--ft-shadow-1); }
.ft-top-user { display: inline-flex; border-radius: 50%; }

.ft-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--ft-s4);
  padding: var(--ft-s5) var(--ft-page-pad) var(--ft-s8);
  border-top: 1px solid var(--ft-border); color: var(--ft-ink-3); font-size: var(--ft-fs-micro);
}

.ft-offline {
  display: flex; align-items: center; gap: var(--ft-s2);
  padding: var(--ft-s2) var(--ft-page-pad);
  background: var(--ft-warn-tint); color: var(--ft-warn); font-size: var(--ft-fs-label);
}

/* ── 底部 Tab（手机）──────────────────────────────────────── */
.ft-tabbar { display: none; }

/* ── 栅格与工具 ───────────────────────────────────────────── */
.ft-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--ft-s5); }
.ft-col-4 { grid-column: span 4; }
.ft-col-5 { grid-column: span 5; }
.ft-col-6 { grid-column: span 6; }
.ft-col-7 { grid-column: span 7; }
.ft-col-8 { grid-column: span 8; }
.ft-col-12 { grid-column: span 12; }
.ft-stack { display: flex; flex-direction: column; gap: var(--ft-s4); }
.ft-stack--sm { gap: var(--ft-s2); }
.ft-stack--lg { gap: var(--ft-s6); }
.ft-row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--ft-s4); }
.ft-side-col { display: flex; flex-direction: column; gap: var(--ft-s4); }
.ft-page-section { margin-bottom: var(--ft-s8); }
.ft-page-section:last-child { margin-bottom: 0; }
.ft-inline { display: flex; align-items: center; gap: var(--ft-s3); flex-wrap: wrap; }
.ft-spread { display: flex; align-items: center; justify-content: space-between; gap: var(--ft-s3); }
.ft-loading-row { padding: var(--ft-s8); text-align: center; color: var(--ft-ink-3); font-size: var(--ft-fs-label); }

/* ── 今日主卡 ─────────────────────────────────────────────── */
.ft-hero { display: flex; gap: var(--ft-s6); align-items: center; flex-wrap: wrap; }
.ft-hero-ring { display: flex; flex-direction: column; align-items: center; gap: var(--ft-s2); }
.ft-hero-copy { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: var(--ft-s2); }
.ft-hero-value { display: flex; align-items: baseline; gap: var(--ft-s2); }
.ft-hero-value strong { font-size: 30px; line-height: 36px; font-weight: 700; letter-spacing: -.02em; }
.ft-hero-value span { font-size: var(--ft-fs-label); color: var(--ft-ink-2); }
.ft-hero-note { font-size: var(--ft-fs-body); color: var(--ft-ink-2); margin: 0; }
/* 目标值只作为副信息：首屏唯一的大数字留给环形里的"已摄入"，避免两个大数字抢焦点 */
.ft-hero-goal { margin: 0; font-size: var(--ft-fs-label); color: var(--ft-ink-3); }
.ft-bars { display: flex; flex-direction: column; gap: var(--ft-s3); margin-top: var(--ft-s2); }

/* ── 记录页两栏布局（左：概览+月历 / 右：当日明细）───────────────
   log.js 的 .ft-log 依次有 4 个子节点：
     1) 搜索面板（通栏） 2) 月度概览三块（通栏） 3) 月历卡（左栏） 4) Tab 明细区（右栏）
   宽屏时并排，避免月历被全宽拉伸成巨块、右侧留大片空白。 */
.ft-log { display: grid; gap: var(--ft-s5); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1080px) {
  .ft-log {
    grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
    align-items: start;
  }
  .ft-log > :nth-child(1),
  .ft-log > :nth-child(2) { grid-column: 1 / -1; }
  .ft-log > :nth-child(3) { grid-column: 1; }
  .ft-log > :nth-child(4) { grid-column: 2; }
}

/* ── 图表：柱状 ───────────────────────────────────────────── */
.ft-chart { position: relative; padding-top: var(--ft-s4); }
/* 参考线画在柱子上层；数值改放在图上方（.ft-chart-meta），避免右端高柱把标签压住 */
.ft-chart-lines { position: absolute; left: 0; right: 0; top: calc(var(--ft-s4) + 26px); bottom: 26px; pointer-events: none; z-index: 2; }
.ft-chart-cols { position: relative; z-index: 1; }
.ft-chart-meta { display: flex; flex-wrap: wrap; gap: var(--ft-s2) var(--ft-s5); margin-bottom: var(--ft-s3); font-size: var(--ft-fs-micro); color: var(--ft-ink-2); }
.ft-chart-meta span { display: inline-flex; align-items: center; gap: 6px; }
.ft-chart-meta b { font-weight: 600; color: var(--ft-ink); }
.ft-chart-line { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--ft-brand-strong); opacity: .7; }
.ft-chart-line i { position: absolute; right: 0; top: -16px; font-style: normal; font-size: 11px; color: var(--ft-ink-3); background: var(--ft-surface); padding: 0 4px; }
.ft-chart-line--avg { border-top-style: dotted; border-color: var(--ft-ink-3); }
.ft-chart-cols { display: flex; align-items: flex-end; gap: 3px; height: 190px; }
.ft-col {
  position: relative; flex: 1 1 0; min-width: 6px; height: 100%;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px;
  border-radius: 6px 6px 0 0; cursor: default;
}
.ft-col-bar { width: 100%; max-width: 16px; border-radius: 3px; background: var(--ft-nutri-kcal); transition: height var(--ft-dur-data) var(--ft-ease-out), filter var(--ft-dur-hover); }
.ft-col.is-empty .ft-col-bar { background: var(--ft-border-strong); }
.ft-col.is-over .ft-col-bar { background: var(--ft-warn); }
.ft-col.is-today .ft-col-bar { background: var(--ft-brand-strong); }
.ft-col:hover .ft-col-bar, .ft-col:focus-visible .ft-col-bar { filter: brightness(1.08); }
.ft-col-label { font-size: 11px; color: var(--ft-ink-3); white-space: nowrap; }
.ft-chart-legend { display: flex; gap: var(--ft-s4); margin-top: var(--ft-s3); font-size: var(--ft-fs-micro); color: var(--ft-ink-2); }
.ft-chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ft-dot { width: 10px; height: 2px; border-radius: 1px; display: inline-block; }
.ft-dot--goal { background: var(--ft-brand-strong); }
.ft-dot--avg { background: var(--ft-ink-3); }
.ft-dot--empty { background: var(--ft-border-strong); height: 6px; width: 6px; border-radius: 2px; }

.ft-spark { color: var(--ft-brand); }
.ft-spark--protein { color: var(--ft-nutri-protein); }
.ft-spark--sleep { color: var(--ft-nutri-protein); }
.ft-spark--weight { color: var(--ft-nutri-protein); }
.ft-line { display: block; }
.ft-line-note { font-size: 11px; fill: var(--ft-ink-3); }

/* ── 月历热力 ─────────────────────────────────────────────── */
/* 注意：格子用 aspect-ratio 1/1，所以必须限制月历本身的最大宽度，
   否则在 1200px 宽的容器里会被拉成 200px 的巨块（记录页曾出现此问题）。 */
.ft-month { display: flex; flex-direction: column; gap: var(--ft-s2); max-width: 460px; }
.ft-month-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; font-size: var(--ft-fs-micro); color: var(--ft-ink-3); text-align: center; }
.ft-month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.ft-day {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 9px; background: var(--ft-surface-2);
  font: inherit; font-size: var(--ft-fs-micro); color: var(--ft-ink-2); cursor: pointer;
  transition: transform var(--ft-dur-hover), box-shadow var(--ft-dur-hover);
}
.ft-day:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--ft-shadow-1); }
.ft-day.lv-0 { background: var(--ft-surface-2); color: var(--ft-ink-3); }
.ft-day.lv-1 { background: rgba(58,174,115,.16); color: var(--ft-ink); }
.ft-day.lv-2 { background: rgba(58,174,115,.34); color: var(--ft-ink); }
.ft-day.lv-3 { background: color-mix(in srgb, var(--ft-brand) 58%, var(--ft-surface)); color: var(--ft-brand-contrast); }
.ft-day.lv-4 { background: var(--ft-warn); color: #fff; }
.ft-day.is-today { border-color: var(--ft-brand-strong); font-weight: 700; }
.ft-day.is-selected { outline: 2px solid var(--ft-focus); outline-offset: 1px; }
.ft-day.is-blank { background: none; cursor: default; }
.ft-day.is-future { opacity: .4; cursor: not-allowed; }
.ft-month-legend { display: flex; align-items: center; gap: 6px; font-size: var(--ft-fs-micro); color: var(--ft-ink-3); justify-content: flex-end; }
.ft-month-legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.ft-month-legend .lv-0 { background: var(--ft-surface-2); }
.ft-month-legend .lv-1 { background: rgba(58,174,115,.16); }
.ft-month-legend .lv-2 { background: rgba(58,174,115,.34); }
.ft-month-legend .lv-3 { background: rgba(58,174,115,.58); }
.ft-month-legend .lv-4 { background: var(--ft-warn); }

/* ── 拍照流程 ─────────────────────────────────────────────── */
.ft-scan { display: flex; flex-direction: column; gap: var(--ft-s5); }
.ft-scan-drop {
  display: flex; flex-direction: column; align-items: center; gap: var(--ft-s3);
  padding: var(--ft-s14) var(--ft-s5); text-align: center;
  border: 2px dashed var(--ft-border-strong); border-radius: var(--ft-r-card); background: var(--ft-surface);
}
.ft-scan-icon { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 50%; background: var(--ft-brand-tint); color: var(--ft-brand-strong); }
.ft-scan-preview { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: var(--ft-s6); align-items: start; }
.ft-scan-img { width: 100%; border-radius: var(--ft-r-card); border: 1px solid var(--ft-border); background: var(--ft-surface-2); }
.ft-scan-steps { display: flex; flex-direction: column; gap: var(--ft-s3); }
.ft-scan-progress { height: 6px; border-radius: 3px; background: var(--ft-surface-2); overflow: hidden; }
.ft-scan-progress i { display: block; height: 100%; width: 40%; border-radius: 3px; background: var(--ft-brand); animation: ft-indeterminate 1.4s ease-in-out infinite; }
@keyframes ft-indeterminate { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

/* ── AI 助手 ─────────────────────────────────────────────── */
.ft-chat { display: flex; flex-direction: column; gap: var(--ft-s3); }
.ft-chat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--ft-s4); }
.ft-chat-stream {
  min-height: 40vh; display: flex; flex-direction: column; gap: var(--ft-s4);
  padding: var(--ft-s4) 0;
}
.ft-msg { display: flex; gap: var(--ft-s2); max-width: 76ch; }
/* 空态欢迎块在消息区里垂直居中，避免"顶部一段字 + 中间一大片空白" */
.ft-coach-messages { min-height: 100%; }
.ft-coach-welcome { margin: auto 0; }
.ft-msg--user { align-self: flex-end; flex-direction: row-reverse; }
.ft-msg-bubble {
  padding: var(--ft-s3) var(--ft-s4); border-radius: 12px; font-size: var(--ft-fs-body);
  white-space: pre-wrap; word-break: break-word; line-height: 1.7;
}
.ft-msg--user .ft-msg-bubble { background: var(--ft-brand-tint); color: var(--ft-ink); }
.ft-msg--assistant .ft-msg-bubble { background: var(--ft-surface); border: 1px solid var(--ft-border); }
.ft-msg-actions { display: flex; gap: 2px; opacity: 0; transition: opacity var(--ft-dur-hover); align-self: flex-end; }
.ft-msg:hover .ft-msg-actions, .ft-msg:focus-within .ft-msg-actions { opacity: 1; }
.ft-typing { display: inline-flex; gap: 4px; align-items: center; }
.ft-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ft-ink-3); animation: ft-blink 1.2s infinite; }
.ft-typing i:nth-child(2) { animation-delay: .2s; }
.ft-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes ft-blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
.ft-composer { border: 1px solid var(--ft-border-strong); border-radius: var(--ft-r-card); background: var(--ft-surface); padding: var(--ft-s2) var(--ft-s2) var(--ft-s2) var(--ft-s4); }
.ft-composer-row { display: flex; align-items: flex-end; gap: var(--ft-s2); }
.ft-composer textarea {
  flex: 1; border: none; outline: none; resize: none; background: none; color: var(--ft-ink);
  font: inherit; font-size: var(--ft-fs-body); line-height: 1.6; padding: var(--ft-s2) 0; max-height: 132px;
}
.ft-composer-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--ft-s3); padding: 2px 0 0; }
.ft-suggestions { display: flex; gap: var(--ft-s2); flex-wrap: wrap; }
.ft-suggestion {
  border: 1px solid var(--ft-border-strong); background: var(--ft-surface); color: var(--ft-ink-2);
  border-radius: var(--ft-r-pill); padding: 8px 14px; font: inherit; font-size: var(--ft-fs-label); cursor: pointer;
}
.ft-suggestion:hover { background: var(--ft-surface-2); color: var(--ft-ink); }
.ft-jump-latest {
  position: sticky; bottom: var(--ft-s4); align-self: center;
  border: 1px solid var(--ft-border); background: var(--ft-surface); color: var(--ft-ink);
  border-radius: var(--ft-r-pill); padding: 8px 14px; font: inherit; font-size: var(--ft-fs-label);
  box-shadow: var(--ft-shadow-2); cursor: pointer;
}

/* ── 响应式 ───────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .ft-grid { gap: var(--ft-s4); }
  .ft-col-4, .ft-col-5, .ft-col-6, .ft-col-7, .ft-col-8 { grid-column: span 12; }
}

@media (max-width: 1023px) {
  .ft-app { grid-template-columns: var(--ft-rail-w) minmax(0, 1fr); }
  .ft-side { padding: var(--ft-s3) var(--ft-s2); align-items: center; }
  .ft-side-head { padding: 0; }
  .ft-brand span { display: none; }
  .ft-nav-item { justify-content: center; padding: 0; width: 48px; }
  .ft-nav-item span { display: none; }
  .ft-btn--block span { display: none; }
  .ft-btn--block { width: 48px; padding: 0; }
  .ft-user-main, .ft-user > .ft-i { display: none; }
  .ft-user { justify-content: center; }
  .ft-top-title { font-size: 24px; line-height: 32px; }
}

@media (max-width: 767px) {
  .ft-app { grid-template-columns: minmax(0, 1fr); padding-bottom: calc(var(--ft-tabbar-h) + env(safe-area-inset-bottom)); }
  .ft-side { display: none; }
  .ft-main { padding: var(--ft-s4) var(--ft-s4) var(--ft-s8); }
  .ft-top { padding: var(--ft-s4) var(--ft-s4) var(--ft-s3); align-items: center; }
  .ft-top-title { font-size: 22px; line-height: 28px; }
  .ft-top-context { font-size: var(--ft-fs-micro); }
  .ft-foot { padding: var(--ft-s4) var(--ft-s4) var(--ft-s6); }

  .ft-tabbar {
    display: grid; grid-template-columns: repeat(7, 1fr); align-items: center;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--ft-tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--ft-surface); border-top: 1px solid var(--ft-border);
  }
  .ft-tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    height: 100%; text-decoration: none; color: var(--ft-ink-2); font-size: 11px; background: none; border: none;
  }
  .ft-tab.is-active { color: var(--ft-brand-strong); font-weight: 600; }
  .ft-tab--scan {
    justify-self: center; width: 56px; height: 56px; margin-top: -18px;
    border-radius: 50%; background: var(--ft-brand); color: var(--ft-brand-contrast);
    border: 3px solid var(--ft-bg); box-shadow: var(--ft-shadow-2); cursor: pointer;
  }
  .ft-tab--scan:hover { background: var(--ft-brand-strong); }

  .ft-hero { gap: var(--ft-s4); }
  .ft-hero-ring { width: 100%; align-items: center; }
  .ft-scan-preview { grid-template-columns: 1fr; }
  .ft-chart-cols { height: 150px; }
  .ft-col-label { display: none; }
  .ft-msg { max-width: 100%; }
}

/* ── 行内菜单（今日/记录的行操作）──────────────────────────── */
.ft-row { position: relative; }
.ft-row-actions { position: relative; }
.ft-menu--row { right: 0; top: calc(100% + 4px); min-width: 168px; }
.ft-menu--row button { align-items: center; }

/* ── 今日页细节 ───────────────────────────────────────────── */
.ft-meal-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9px; background: var(--ft-brand-tint);
  color: var(--ft-brand-strong); font-size: var(--ft-fs-label); font-weight: 600;
}
/* 行元信息拆两段：窄屏只留"餐次 · 时间"，避免营养串被挤成两行断字 */
.ft-row-meta-main, .ft-row-meta-macros { display: inline; }
.ft-row-meta-macros::before { content: " · "; }
@media (max-width: 560px) {
  .ft-row-meta-macros { display: none; }
}
.ft-unit { font-style: normal; font-weight: 400; font-size: var(--ft-fs-micro); color: var(--ft-ink-3); }
.ft-summary-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: var(--ft-fs-label); color: var(--ft-ink-2); }
.ft-summary-list li::marker { color: var(--ft-brand); }
.ft-water { display: flex; flex-direction: column; }

/* ── 快记面板 ─────────────────────────────────────────────── */
.ft-quick { display: flex; flex-direction: column; gap: var(--ft-s3); }
.ft-quick-chips { display: flex; flex-wrap: wrap; gap: var(--ft-s2); }

/* ── 同意项 ───────────────────────────────────────────────── */
.ft-consent {
  display: flex; align-items: flex-start; gap: var(--ft-s2);
  font-size: var(--ft-fs-label); color: var(--ft-ink-2);
  padding: var(--ft-s3); border-radius: var(--ft-r-control); background: var(--ft-surface-2);
}
.ft-consent input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--ft-brand); flex: none; }
.ft-consent > span { flex: 1; }

/* ── 食谱详情 ─────────────────────────────────────────────── */
.ft-recipe { display: flex; flex-direction: column; gap: var(--ft-s4); }
/* 照片与占位卡：占位卡必须绝对定位垫在下面，否则会排到照片下方变成一个大灰块 */
.ft-recipe { position: relative; }
.ft-recipe-media { position: relative; height: 180px; border-radius: var(--ft-r-card); overflow: hidden; background: var(--ft-surface-2); }
.ft-recipe-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
}
.ft-recipe-ph {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--ft-ink-3); background: var(--ft-surface-2);
}
.ft-recipe-img + .ft-recipe-ph { z-index: 0; }
.ft-recipe-img { z-index: 1; }
@media (max-width: 640px) {
  .ft-recipe-media { height: 200px; }   /* 手机上照片给高一点，看着更像成品图 */
}
.ft-recipe-head h3 { margin: var(--ft-s2) 0 4px; font-size: var(--ft-fs-title); }
.ft-recipe-name { margin: 0 0 4px; font-size: var(--ft-fs-title); line-height: var(--ft-lh-title); font-weight: 600; }
.ft-recipe-macros { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--ft-s2); }
.ft-recipe-macro {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: var(--ft-s3); border-radius: var(--ft-r-control); background: var(--ft-surface-2);
}
.ft-recipe-macro strong { font-size: var(--ft-fs-heading); }
.ft-recipe-macro span { font-size: var(--ft-fs-micro); color: var(--ft-ink-3); }
.ft-recipe-macro.ft-bar--kcal strong { color: var(--ft-nutri-kcal); }
.ft-recipe-macro.ft-bar--protein strong { color: var(--ft-nutri-protein); }
.ft-recipe-macro.ft-bar--carbs strong { color: var(--ft-nutri-carbs); }
.ft-recipe-macro.ft-bar--fat strong { color: var(--ft-nutri-fat); }
.ft-recipe-block h4 { margin: 0 0 var(--ft-s2); font-size: var(--ft-fs-body); }
.ft-recipe-ul, .ft-recipe-ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: var(--ft-fs-label); color: var(--ft-ink-2); }

/* 电脑端摄像头拍照弹窗 */
.ft-webcam { display: grid; gap: 10px; }
.ft-webcam video { width: 100%; max-height: 46vh; border-radius: 14px; background: #101613; object-fit: cover; transform: scaleX(-1); }
.ft-webcam-tip { text-align: center; color: var(--ft-muted, var(--ft-ink-3)); font-size: 12px; }

/* 侧栏品牌：中文名 + 英文名 */
.ft-brand-name { display: flex; flex-direction: column; line-height: 1.15; font-size: 15px; font-weight: 700; }
.ft-brand-name small { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ft-muted, var(--ft-ink-3)); }

/* ── 常用餐快捷条（Pro）────────────────────────────────────── */
.ft-favs { margin-bottom: var(--ft-s4, 16px); }
.ft-favs-label { display: block; font-size: 12px; color: var(--ft-ink-3); margin-bottom: 8px; }
.ft-favs-row { display: flex; flex-wrap: wrap; gap: 8px; }
.ft-favs-item { display: inline-flex; align-items: center; background: var(--ft-surface-2); border: 1px solid var(--ft-border); border-radius: var(--ft-r-pill, 999px); overflow: hidden; }
.ft-favs-add {
  display: inline-flex; align-items: baseline; gap: 6px; border: none; background: none; cursor: pointer;
  font: inherit; font-size: 13px; color: var(--ft-ink); padding: 7px 6px 7px 13px; max-width: 260px;
}
.ft-favs-add i { font-style: normal; font-size: 11px; color: var(--ft-ink-3); }
.ft-favs-add:hover { color: var(--ft-brand-strong); }
.ft-favs-x { border: none; background: none; cursor: pointer; color: var(--ft-ink-3); font-size: 15px; padding: 0 10px 0 4px; line-height: 1; }
.ft-favs-x:hover { color: var(--ft-danger); }

/* ── 食物库搜索（添加一餐表单内）──────────────────────────── */
.ft-food-search { margin-bottom: var(--ft-s4, 16px); }
.ft-food-search input {
  width: 100%; min-height: 44px; padding: 0 var(--ft-s3); margin-top: 6px;
  font: inherit; font-size: var(--ft-fs-body, 14px); color: var(--ft-ink);
  background: var(--ft-surface); border: 1px solid var(--ft-border-strong);
  border-radius: var(--ft-r-control, 12px);
}
.ft-food-search input:focus { outline: none; border-color: var(--ft-focus); box-shadow: 0 0 0 3px rgba(74,163,106,.18); }
.ft-food-results {
  margin-top: 8px; max-height: 260px; overflow-y: auto;
  border: 1px solid var(--ft-border); border-radius: var(--ft-r-control, 12px); background: var(--ft-surface-2);
}
.ft-food-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%;
  padding: 10px 13px; border: none; border-bottom: 1px solid var(--ft-border);
  background: none; font: inherit; text-align: left; cursor: pointer; color: var(--ft-ink);
}
.ft-food-item:last-of-type { border-bottom: none; }
.ft-food-item:hover { background: var(--ft-brand-tint); }
.ft-food-name { font-size: 13.5px; font-weight: 600; }
.ft-food-macros { font-size: 11.5px; color: var(--ft-ink-3); }
.ft-food-macros i { font-style: normal; opacity: .8; }
.ft-food-empty { margin: 0; padding: 12px 13px; font-size: 12.5px; color: var(--ft-ink-3); }
.ft-food-src { margin: 0; padding: 8px 13px; font-size: 11px; color: var(--ft-ink-3); border-top: 1px solid var(--ft-border); }

/* 可点击的餐行（用 div 承载，避免按钮嵌套导致行内菜单失效） */
.ft-row[data-ft-meal-open] { cursor: pointer; }
.ft-row[data-ft-meal-open]:hover { background: var(--ft-surface-2); }
.ft-row[data-ft-meal-open]:focus-visible { outline: 2px solid var(--ft-focus); outline-offset: -2px; }

/* ── 记录行排版保险：长菜名不挤掉热量/按钮 ────────────────── */
.ft-row-main { min-width: 0; }
.ft-row-title { overflow-wrap: anywhere; line-height: 1.45; }
.ft-row-meta { display: block; line-height: 1.5; }
.ft-row { gap: var(--ft-s3, 12px); }
.ft-row-value { white-space: nowrap; }
.ft-row-meta-macros { color: var(--ft-ink-3); }
@media (min-width: 900px) {
  /* 桌面端：菜名一行、营养一行，信息不挤在一起 */
  .ft-row { padding-top: 12px; padding-bottom: 12px; }
}

/* ── 扫条码（扫描页，Pro）──────────────────────────────────── */
.ft-barcode { display: grid; gap: 8px; }
.ft-barcode input { width: 100%; min-height: 44px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--ft-ink); background: var(--ft-surface); border: 1px solid var(--ft-border-strong); border-radius: var(--ft-r-control, 12px); }
.ft-barcode video { width: 100%; max-height: 180px; border-radius: 12px; background: #101613; object-fit: cover; }

/* ── 今日页快捷记录栏 ─────────────────────────────────────── */
.ft-quick-bar {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;
  margin-bottom: var(--ft-s5, 20px);
}
.ft-quick-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 6px; font: inherit; font-size: 12px; font-weight: 600; color: var(--ft-ink-2);
  background: var(--ft-surface); border: 1px solid var(--ft-border); border-radius: 16px;
  box-shadow: var(--ft-shadow-1); cursor: pointer;
  transition: transform var(--ft-dur-hover) var(--ft-ease-out), box-shadow var(--ft-dur-hover), color var(--ft-dur-hover), border-color var(--ft-dur-hover);
}
.ft-quick-btn:hover { color: var(--ft-brand-strong); border-color: var(--ft-brand); box-shadow: var(--ft-shadow-2); transform: translateY(-1px); }
.ft-quick-btn:active { transform: translateY(0) scale(.985); }
.ft-quick-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--ft-brand-tint); color: var(--ft-brand-strong);
}
.ft-quick-btn:nth-child(3) .ft-quick-ico { background: rgba(60,123,224,.12); color: #3C7BE0; }
.ft-quick-btn:nth-child(4) .ft-quick-ico { background: rgba(60,150,224,.12); color: #2F7FC8; }
@media (max-width: 480px) { .ft-quick-bar { gap: 8px; } .ft-quick-btn { padding: 10px 4px; font-size: 11px; } }

/* hero 状态徽章 */
.ft-hero-chip {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .01em;
  background: var(--ft-surface-2); color: var(--ft-ink-2);
}
.ft-hero-chip.is-ok { background: var(--ft-brand-tint); color: var(--ft-brand-strong); }
.ft-hero-chip.is-near { background: var(--ft-warn-tint); color: var(--ft-warn); }
.ft-hero-chip.is-over { background: var(--ft-danger-tint); color: var(--ft-danger); }

/* 扫码取景框 */
/* 取景框：必须给容器和 video 明确高度，否则画面高度塌成 0，用户看不到自己在扫什么 */
.ft-barcode-reader { position: relative; min-height: 208px; height: 208px; border-radius: 14px; overflow: hidden; background: #0d120f; }
.ft-barcode-reader video { width: 100% !important; height: 208px !important; object-fit: cover; border-radius: 14px; display: block; }
.ft-barcode-reader canvas { display: none !important; }
.ft-barcode-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ft-barcode-reader img[alt="Info icon"] { display: none; }

/* ── 每日小结（记录页）────────────────────────────────────── */
.ft-daybrief {
  display: grid; gap: 8px; margin: 4px 0 14px; padding: 14px 16px;
  border-radius: 14px; background: var(--ft-surface-2); border: 1px solid var(--ft-border);
}
.ft-daybrief.good { background: var(--ft-brand-tint); border-color: transparent; }
.ft-daybrief.warn { background: var(--ft-warn-tint); border-color: transparent; }
.ft-daybrief-top { display: flex; align-items: baseline; gap: 6px; }
.ft-daybrief-top strong { font-size: 24px; font-weight: 800; color: var(--ft-ink); }
.ft-daybrief-pct { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--ft-ink-2); }
.ft-daybrief-bar { height: 6px; border-radius: 999px; background: rgba(0,0,0,.07); overflow: hidden; }
.ft-daybrief-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--ft-grad-brand); transition: width var(--ft-dur-data) var(--ft-ease-out); }
.ft-daybrief.warn .ft-daybrief-bar > span { background: linear-gradient(90deg, #D9911F, #C4623F); }
.ft-daybrief-tip { margin: 0; font-size: 13px; line-height: 1.5; color: var(--ft-ink-2); }


/* ═══════════════════════════════════════════════════════════
   今日主视觉 v2：品牌渐变大卡（渐变环 + 白字大数字 + 彩条 + 迷你走势）
   ═══════════════════════════════════════════════════════════ */
.ft-hero2 {
  position: relative; overflow: hidden;
  margin-bottom: var(--ft-s5, 20px);
  padding: clamp(18px, 2.4vw, 26px);
  border-radius: 22px;
  background: linear-gradient(135deg, #1F8A55 0%, #15704A 55%, #0E5C3C 100%);
  color: #fff;
  box-shadow: 0 18px 40px -20px rgba(14, 92, 60, .55), 0 2px 8px -4px rgba(14, 92, 60, .3);
}
:root[data-theme="dark"] .ft-hero2 {
  background: linear-gradient(135deg, #1B7A4C 0%, #145C39 55%, #0C4029 100%);
  box-shadow: 0 18px 40px -22px rgba(0, 0, 0, .8);
}
.ft-hero2.is-near { background: linear-gradient(135deg, #C58A1E 0%, #A96F14 55%, #7E5310 100%); box-shadow: 0 18px 40px -20px rgba(126, 83, 16, .5); }
.ft-hero2.is-over { background: linear-gradient(135deg, #B4453A 0%, #94352C 55%, #6E271F 100%); box-shadow: 0 18px 40px -20px rgba(110, 39, 31, .5); }

/* 右上角柔光，制造"玻璃质感" */
.ft-hero2-glow {
  position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.28) 0%, rgba(255,255,255,0) 70%);
  pointer-events: none;
}
.ft-hero2-main { position: relative; display: flex; align-items: center; gap: clamp(14px, 2vw, 24px); flex-wrap: wrap; }
.ft-hero2-ring { position: relative; flex: none; display: grid; place-items: center; }
.ft-hero2-ring-in { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.ft-hero2-ring-in strong { font-size: clamp(24px, 3vw, 30px); font-weight: 800; letter-spacing: -.02em; color: #fff; line-height: 1.05; }
.ft-hero2-ring-in i { font-style: normal; font-size: 11.5px; color: rgba(255,255,255,.82); }
.ft-hero2-ring-in em { font-style: normal; font-size: 11px; font-weight: 700; color: rgba(255,255,255,.9); background: rgba(255,255,255,.16); border-radius: 999px; padding: 1px 7px; margin-top: 2px; }

.ft-hero2-copy { flex: 1; min-width: 190px; }
.ft-hero2-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ft-hero2-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  background: rgba(255,255,255,.94); color: #0E5C3C;
}
.ft-hero2.is-near .ft-hero2-chip { color: #7E5310; }
.ft-hero2.is-over .ft-hero2-chip { color: #8C2F26; }
.ft-hero2-chip--ghost { background: rgba(255,255,255,.18); color: #fff; }
.ft-hero2-chip--ghost svg { width: 13px; height: 13px; }
.ft-hero2-title { margin: 0 0 4px; font-size: 15px; font-weight: 700; color: rgba(255,255,255,.9); letter-spacing: .01em; }
.ft-hero2-note { margin: 0; font-size: 14px; line-height: 1.5; color: rgba(255,255,255,.95); }

.ft-hero2-bars { position: relative; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 18px; margin-top: 18px; }
.ft-hero2-bar-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 12.5px; color: rgba(255,255,255,.86); margin-bottom: 6px; }
.ft-hero2-bar-head b { font-size: 13.5px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.ft-hero2-bar-head b i { font-style: normal; font-weight: 400; font-size: 11.5px; color: rgba(255,255,255,.72); }
.ft-hero2-bar-track { display: block; height: 6px; border-radius: 999px; background: rgba(255,255,255,.22); overflow: hidden; }
.ft-hero2-bar-track > span { display: block; height: 100%; border-radius: 999px; background: #fff; transition: width var(--ft-dur-data) var(--ft-ease-out); }
.ft-hero2-bar[data-key="protein"] .ft-hero2-bar-track > span { background: linear-gradient(90deg, #BDF7D6, #7BE7AE); }
.ft-hero2-bar[data-key="carbs"] .ft-hero2-bar-track > span { background: linear-gradient(90deg, #FFE2A8, #FFC46B); }
.ft-hero2-bar[data-key="fat"] .ft-hero2-bar-track > span { background: linear-gradient(90deg, #FFD2C2, #FFA98A); }

.ft-hero2-spark { position: relative; margin-top: 16px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.18); }
.ft-hero2-spark svg { display: block; width: 100%; }
.ft-hero2-spark-label { display: block; margin-top: 2px; font-size: 11.5px; color: rgba(255,255,255,.72); }

@media (max-width: 520px) {
  .ft-hero2 { border-radius: 20px; padding: 16px; }
  .ft-hero2-main { gap: 12px; }
  .ft-hero2-ring { --s: 108px; }
}

/* ── 趋势图 v2：平滑渐变面积图 ─────────────────────────────── */
.ft-chart2 { display: grid; gap: 6px; }
.ft-chart2-svg { display: block; width: 100%; height: clamp(170px, 26vw, 230px); overflow: visible; }
.ft-chart2-x { display: flex; align-items: center; gap: 0; padding: 0 2px; }
.ft-chart2-x span { flex: 1 1 0; text-align: center; font-size: 11px; color: var(--ft-ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ft-chart2-x span.is-today { color: var(--ft-brand-strong); font-weight: 700; }
.ft-trends-chart { overflow: visible !important; }

/* ═══════════════════════════════════════════════════════════
   餐别配色体系：早=琥珀 · 午=品牌绿 · 晚=靛蓝 · 加=玫红
   （同一色系贯穿徽章、行强调，扫一眼就知道是哪一餐）
   ═══════════════════════════════════════════════════════════ */
.ft-meal-badge[data-cat="Breakfast"] { background: #FDF2E3; color: #9A6412; }
.ft-meal-badge[data-cat="Lunch"]     { background: #E7F4EC; color: #14663F; }
.ft-meal-badge[data-cat="Dinner"]    { background: #E9EEF8; color: #35559C; }
.ft-meal-badge[data-cat="Snack"]     { background: #FCEEF1; color: #A83E5B; }
.ft-meal-badge { transition: background var(--ft-dur-hover), color var(--ft-dur-hover); }

/* 深色模式：改成低饱和底 + 亮字，避免亮块刺眼 */
:root[data-theme="dark"] .ft-meal-badge[data-cat="Breakfast"] { background: rgba(217,145,31,.20); color: #EFC078; }
:root[data-theme="dark"] .ft-meal-badge[data-cat="Lunch"]     { background: rgba(31,138,85,.22);  color: #8FD8B2; }
:root[data-theme="dark"] .ft-meal-badge[data-cat="Dinner"]    { background: rgba(90,124,204,.20); color: #A9C0F0; }
:root[data-theme="dark"] .ft-meal-badge[data-cat="Snack"]     { background: rgba(200,90,130,.20); color: #F0A9C0; }

/* ═══════════════════════════════════════════════════════════
   食谱库页面（分类筛选 + 搜索 + 卡片网格）
   ═══════════════════════════════════════════════════════════ */
.ft-lib { display: flex; flex-direction: column; gap: var(--ft-s4); }
.ft-lib-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--ft-s3); }
.ft-lib-title { margin: 0; font-size: var(--ft-fs-title); font-weight: 700; letter-spacing: -.02em; }
.ft-lib-count {
  flex: none; font: 700 13px/1 var(--ft-font); font-variant-numeric: tabular-nums;
  color: var(--ft-brand-strong); background: var(--ft-brand-tint);
  padding: 7px 11px; border-radius: 999px;
}
.ft-lib-search { position: relative; display: flex; align-items: center; gap: 8px; }
.ft-lib-search > svg { position: absolute; left: 13px; color: var(--ft-ink-3); pointer-events: none; }
.ft-lib-search input {
  width: 100%; min-height: 46px; padding: 0 84px 0 40px;
  border: 1px solid var(--ft-line); border-radius: var(--ft-r-pill);
  background: var(--ft-surface); color: var(--ft-ink); font-size: var(--ft-fs-body);
}
.ft-lib-search input:focus { outline: none; border-color: var(--ft-brand); box-shadow: 0 0 0 3px var(--ft-brand-tint); }
.ft-lib-clear {
  position: absolute; right: 8px; border: none; background: var(--ft-surface-2); color: var(--ft-ink-2);
  border-radius: var(--ft-r-pill); padding: 7px 12px; font-size: var(--ft-fs-label); cursor: pointer;
}
.ft-lib-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.ft-lib-chips::-webkit-scrollbar { display: none; }
.ft-lib-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--ft-line); background: var(--ft-surface); color: var(--ft-ink-2);
  border-radius: var(--ft-r-pill); padding: 8px 13px; font-size: var(--ft-fs-label); cursor: pointer;
  transition: background var(--ft-dur-hover), color var(--ft-dur-hover), border-color var(--ft-dur-hover);
}
.ft-lib-chip i { font-style: normal; font-size: var(--ft-fs-micro); opacity: .6; font-variant-numeric: tabular-nums; }
.ft-lib-chip:hover { border-color: var(--ft-brand); color: var(--ft-brand-strong); }
.ft-lib-chip.is-on { background: var(--ft-brand); border-color: var(--ft-brand); color: #fff; }
.ft-lib-chip.is-on i { opacity: .85; }
.ft-lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: var(--ft-s3); }
@media (max-width: 560px) { .ft-lib-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.ft-lib-card {
  display: flex; flex-direction: column; padding: 0; overflow: hidden; text-align: left; cursor: pointer;
  background: var(--ft-surface); border: 1px solid var(--ft-line); border-radius: var(--ft-r-card);
  transition: transform var(--ft-dur-hover), box-shadow var(--ft-dur-hover), border-color var(--ft-dur-hover);
}
.ft-lib-card:hover { transform: translateY(-2px); border-color: var(--ft-brand); box-shadow: 0 16px 32px -22px rgba(14,60,38,.4); }
.ft-lib-thumb { display: block; position: relative; aspect-ratio: 4 / 3; background: var(--ft-surface-2); }
.ft-lib-img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* 无成品图：按分类着色的占位卡（不假装有照片） */
.ft-lib-ph {
  width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: #fff; background: linear-gradient(150deg, #1d7a4c, #0e4f31);
}
.ft-lib-ph[data-tone="1"] { background: linear-gradient(150deg, #4f9d69, #2f7a4c); }
.ft-lib-ph[data-tone="2"] { background: linear-gradient(150deg, #b98a3e, #8a6224); }
.ft-lib-ph[data-tone="3"] { background: linear-gradient(150deg, #4a7fa8, #2f5b80); }
.ft-lib-ph[data-tone="4"] { background: linear-gradient(150deg, #c98b4b, #9a6430); }
.ft-lib-ph[data-tone="5"] { background: linear-gradient(150deg, #3f8f9c, #2b6a75); }
.ft-lib-ph[data-tone="6"] { background: linear-gradient(150deg, #b56a8a, #8c4a67); }
.ft-lib-ph[data-tone="7"] { background: linear-gradient(150deg, #5c86b8, #3d5f8c); }
.ft-lib-ph[data-tone="8"] { background: linear-gradient(150deg, #7d7f86, #55575c); }
.ft-lib-ph[data-tone="9"] { background: linear-gradient(150deg, #8a7f5c, #635a3d); }
.ft-lib-ph svg { opacity: .55; }
.ft-lib-ph-name { font-size: var(--ft-fs-label); font-weight: 700; letter-spacing: .02em; text-shadow: 0 1px 6px rgba(0,0,0,.28); }
.ft-lib-body { display: flex; flex-direction: column; gap: 5px; padding: 10px 11px 12px; }
.ft-lib-name { font-size: var(--ft-fs-label); font-weight: 600; line-height: 1.35; color: var(--ft-ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ft-lib-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.ft-lib-cat { font-size: var(--ft-fs-micro); color: var(--ft-ink-3); }
.ft-lib-kcal { font-size: var(--ft-fs-micro); font-weight: 600; color: var(--ft-ink-2); font-variant-numeric: tabular-nums; }
.ft-lib-more { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ft-lib-note { margin: 0; text-align: center; }
.ft-lib-card.is-skel { border: none; background: transparent; min-height: 168px; }

/* 食谱库缩略图：占位卡垫底，图片加载成功才盖上去（境外图床挂起时不会留空白框） */
.ft-lib-thumb { position: relative; display: block; overflow: hidden; }
/* 直接出图：不做 opacity 淡入，避免"先占位卡、后出图"的观感。
   （图片若加载失败/超时，JS 会把它移除，此时下面的占位卡才露出来） */
.ft-lib-thumb .ft-lib-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  background: var(--ft-surface-2); }

/* 有配图的菜：垫一层淡骨架（不是彩色占位卡），图片解码完成直接盖上去。
   加载中看起来是正常加载态，加载完就是照片，避免"先占位后出图"的跳变与空白框。 */
.ft-lib-thumb .ft-lib-skel {
  position: absolute; inset: 0; display: block;
  background: linear-gradient(100deg, var(--ft-surface-2) 30%, rgba(255,255,255,.55) 50%, var(--ft-surface-2) 70%);
  background-size: 220% 100%;
  animation: ft-lib-shimmer 1.4s ease-in-out infinite;
}
@keyframes ft-lib-shimmer { 0% { background-position: 130% 0; } 100% { background-position: -30% 0; } }
@media (prefers-reduced-motion: reduce) { .ft-lib-thumb .ft-lib-skel { animation: none; } }

/* 首页「近 7 天摄入」柱状图（views.css 是 index.html 真正加载的样式）。
   注意：SVG 的默认填充是黑色，所以颜色同时写在 rect 的 fill 属性上，避免样式没加载时变黑块。 */

.ft-hero2-spark .ft-spark-bar:hover rect { filter: brightness(1.08); }
.ft-hero2-spark svg text { fill: #fff; }
.ft-hero2-spark .ft-hero2-spark-label { display: block; margin-top: 2px; }

/* 食谱库卡片：等高 + 元信息贴底。长菜名（两行）会把卡片撑高，导致同一行卡片参差不齐 */
.ft-lib-card { height: 100%; }
.ft-lib-body { flex: 1; }
.ft-lib-meta { margin-top: auto; }
.ft-lib-kcal .ft-unit { margin-left: 3px; }
/* 分类与热量换行时不互相挤压（窄屏下 620千卡 会粘在一起） */
.ft-lib-cat { white-space: nowrap; }
.ft-lib-kcal { white-space: nowrap; }

/* 趋势图 x 轴：标签不再互相挤压 */
.ft-chart2-x { gap: 2px; }
.ft-chart2-x span { font-size: 11px; white-space: nowrap; overflow: hidden; }
@media (max-width: 520px) { .ft-chart2-x span { font-size: 10px; } }

/* 趋势图交互层：股票软件式的十字光标 + 浮动数据卡 */
.ft-chart2 { position: relative; }
.ft-chart2[tabindex]:focus-visible { outline: 2px solid var(--ft-brand); outline-offset: 4px; border-radius: 10px; }
.ft-chart-cursor { pointer-events: none; }
.ft-chart-tip {
  position: absolute; top: 4px; z-index: 3; pointer-events: none;
  min-width: 118px; padding: 8px 11px; border-radius: 10px;
  background: color-mix(in oklab, var(--ft-ink) 92%, transparent);
  color: #fff; font-size: 12px; line-height: 1.55; white-space: nowrap;
  box-shadow: 0 10px 26px -14px rgba(0,0,0,.6);
  transform: translateX(0); transition: opacity .12s ease;
}
.ft-chart-tip[hidden] { display: none; }
.ft-chart-tip b { display: block; font-size: 11px; font-weight: 600; opacity: .78; margin-bottom: 2px; }
.ft-chart-tip-v strong { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ft-chart-tip-goal { display: block; opacity: .72; font-size: 11px; }
.ft-chart-tip em { display: block; font-style: normal; margin-top: 2px; color: #9be8bd; }
.ft-chart-tip em.is-over { color: #ffd66b; }
.ft-chart2-x span.is-active { color: var(--ft-brand); font-weight: 700; }

/* ── 留白补丁（2026-10-16 布局体检）─────────────────────────────
   体检发现的问题：副标题/标签离主标题只有 4px，统计卡里三行文字只有 2px，
   卡片内的提示块上下没有外边距。统一放宽到 6–12px。 */
.ft-top-context { margin-top: var(--ft-s2); }
.ft-card-sub { margin-top: 6px; }
.ft-card-titles { row-gap: 2px; }
.ft-tile { gap: 6px; }
.ft-tile-hint { margin-top: 2px; }
.ft-inline-note { margin: var(--ft-s3) 0; }
.ft-inline-note:first-child { margin-top: 0; }
.ft-inline-note:last-child { margin-bottom: 0; }
.ft-card > .ft-inline-note + * { margin-top: var(--ft-s3); }
.ft-form-grid + .ft-form-actions { margin-top: var(--ft-s5); }
.ft-seg { gap: 4px; }
.ft-lang { gap: 4px; }
@media (max-width: 767px) {
  /* 移动端内容区底部再加一档留白，避免最后一项贴着标签栏 */
  .ft-main { padding-bottom: calc(var(--ft-s8) + 8px); }
  .ft-page-section { margin-bottom: var(--ft-s6); }
}

/* ── 手机端密度优化 ────────────────────────────────────────────
   记录页原来三张统计卡竖排占掉一整屏；餐次行里菜名被截成"清蒸鲈鱼 + …"。 */
@media (max-width: 640px) {
  /* ① 统计卡横排三列，省一屏高度 */
  .ft-row2 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .ft-tile { padding: 10px 11px; gap: 4px; border-radius: 12px; }
  .ft-tile-label { font-size: 11px; line-height: 1.3; }
  .ft-tile-value { font-size: 17px; line-height: 22px; }
  .ft-tile-value i { font-size: 10px; }
  .ft-tile-hint { font-size: 10.5px; line-height: 1.3; }

  /* ② 餐次行：菜名允许两行并占满宽度，热量列收窄 */
  .ft-log-meal .ft-row { align-items: flex-start; }
  .ft-log-meal .ft-row-main { min-width: 0; }
  .ft-log-meal .ft-row-title {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; white-space: normal; line-height: 1.35;
  }
  .ft-log-meal .ft-row-value { font-size: var(--ft-fs-label); white-space: nowrap; padding-top: 2px; }
  .ft-log-meal .ft-row-actions { gap: 2px; }
}

/* ── 手机端布局修复（用户实测截图反馈，2026-10-16 晚）─────────────
   ① 底栏压住最后一条记录 → 内容底部留白加大（含安全区）
   ② 标签栏 7 项在 390px 下要放得下 → 图标与文字缩小、隐藏未读角标
   ③ 「我的」分组导航文字被折成"账/号" → 不允许换行
   ④ 提醒行的时间选择框被开关挤扁 → 允许换行并给时间框弹性宽度
   ⑤ 趋势页习惯卡的「记一笔」被右边缘切掉 → 头部允许换行、按钮不可压缩 */
@media (max-width: 767px) {
  .ft-main { padding-bottom: calc(var(--ft-tabbar-h) + env(safe-area-inset-bottom) + 28px); }
  .ft-tab { gap: 1px; padding: 4px 0; }
  .ft-tab svg { width: 19px; height: 19px; }
  .ft-tab span { font-size: 10px; line-height: 1.15; }
  .ft-tabbar { padding-left: 4px; padding-right: 4px; }
  .ft-tab--scan { width: 42px; height: 42px; }

  /* 用户反馈：横向滚动导致「隐私与数据」被切在屏幕外，看着像坏了 → 改成两行换行，6 个都能看到 */
  .ft-me-nav { flex-wrap: wrap; gap: 8px; padding-bottom: 0; overflow: visible; }
  .ft-me-nav-link { flex: 0 1 auto; white-space: nowrap; min-height: 34px; padding: 0 12px; font-size: 13px; }
}

@media (max-width: 560px) {
  .ft-remind-row { flex-wrap: wrap; row-gap: 8px; }
  .ft-remind-main { flex: 1 1 100%; }           /* 标题说明独占一行 */
  .ft-remind-row .ft-remind-time { flex: 1 1 auto; min-width: 96px; }
  .ft-remind-row .ft-switch { flex: none; }

  .ft-habit-head { flex-wrap: wrap; row-gap: 6px; }
  .ft-habit-head > .ft-btn, .ft-habit-head > button { flex: none; margin-left: auto; }
}

/* 趋势页顶部统计行：手机上 4 段信息会挤成两行且贴边 */
@media (max-width: 560px) {
  .ft-top-context { font-size: 12.5px; line-height: 1.5; }
  .ft-top-title { font-size: 26px; }
}

/* 手机端顶部「装到桌面」小胶囊（未安装时显示，点了就能装） */
.ft-install-pill {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  height: 32px; padding: 0 10px; margin-right: 4px;
  border-radius: 999px; border: 1px solid color-mix(in oklab, var(--ft-brand) 45%, transparent);
  background: var(--ft-brand-tint); color: var(--ft-brand-strong);
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.ft-install-pill[hidden] { display: none; }
.ft-install-pill:hover { border-color: var(--ft-brand); }
@media (max-width: 400px) { .ft-install-pill span { display: none; } .ft-install-pill { padding: 0 8px; } }

/* ── 顶栏打磨（用户：左上角太乱、中英切换不居中）──────────────────
   原来标题与副信息挤在左列、语言/主题/头像在右列，副信息会换行把整块顶栏撑乱。
   现在：第一行 标题 + 右侧操作（垂直居中），第二行 副信息独占整行。 */
/* 关键：必须允许换行，否则"副信息整行"会被挤成一列，标题变竖排 */
.ft-top { flex-wrap: wrap; align-items: center; row-gap: 4px; column-gap: var(--ft-s3); }
.ft-top-titles { min-width: 0; flex: 1 1 auto; }
.ft-top-title { font-size: 24px; line-height: 1.2; letter-spacing: -.02em; }
.ft-top-actions { display: flex; align-items: center; gap: 6px; flex: none; margin-left: auto; }
.ft-lang { display: inline-flex; align-items: center; height: 34px; padding: 2px; border-radius: 999px;
  background: var(--ft-surface-2); border: 1px solid var(--ft-border); }
.ft-lang button {
  min-width: 44px; height: 28px; padding: 0 10px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ft-ink-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.ft-lang button.is-active { background: var(--ft-surface); color: var(--ft-ink); box-shadow: var(--ft-shadow-sm, 0 1px 2px rgba(0,0,0,.06)); }
.ft-top-context--full { flex: 1 1 100%; margin: 0; font-size: var(--ft-fs-micro); color: var(--ft-ink-3); line-height: 1.5; }
@media (max-width: 480px) {
  .ft-top-title { font-size: 22px; }
  .ft-lang button { min-width: 38px; padding: 0 8px; font-size: 12.5px; }
}

/* ── 底部导航打磨（用户：排版不好看、拍照要在最中间）──────────────
   7 项等宽，第 4 项正好是正中；摄像头做成略大的圆形主按钮，左右各 3 项。 */
.ft-tabbar { box-shadow: 0 -1px 0 var(--ft-border), 0 -8px 24px -18px rgba(20,32,26,.28); }
.ft-tab { color: var(--ft-ink-3); text-decoration: none; border-radius: 12px; }
.ft-tab.is-active { color: var(--ft-brand); }
.ft-tab.is-active span { font-weight: 600; }
.ft-tab--scan {
  width: 46px; height: 46px; margin: 0 auto; border-radius: 50%;
  background: var(--ft-brand); color: #fff; border: 0; cursor: pointer;
  display: grid; place-items: center; transform: translateY(-8px);
  box-shadow: 0 8px 18px -8px color-mix(in oklab, var(--ft-brand) 70%, transparent);
}
.ft-tab--scan svg { width: 22px; height: 22px; }

/* ── 习惯卡（睡眠/体重）间距：用户反馈"挨着太近" ───────────── */
@media (max-width: 860px) {
  .ft-trends-habits { grid-template-columns: 1fr; gap: var(--ft-s4); }
  .ft-habit { padding: var(--ft-s4); }
}

/* ── 提醒卡片底部两个按钮：手机上位置偏移，改为等高并排 ─────── */
@media (max-width: 560px) {
  .ft-form-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: stretch; }
  .ft-form-actions > * { width: 100%; justify-content: center; }
}

/* ── 拍照页重排（用户：排版重新改）─────────────────────────────
   原来是一个大虚线框里塞三个按钮 + 说明 + 勾选 + 免责声明，重心散。
   现在：正中一个大圆快门，下面三个等宽快捷入口，其余信息弱化。 */
.ft-scan { display: flex; flex-direction: column; gap: var(--ft-s5); }
.ft-scan-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: var(--ft-s5) 0 var(--ft-s3); }
.ft-scan-shutter {
  width: 104px; height: 104px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--ft-brand); color: #fff; display: grid; place-items: center;
  box-shadow: 0 14px 30px -14px color-mix(in oklab, var(--ft-brand) 75%, transparent);
  transition: transform .15s ease;
}
.ft-scan-shutter:active { transform: scale(.96); }
.ft-scan-shutter-ring {
  width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid rgba(255,255,255,.5);
}
.ft-scan-hero-title { margin: 4px 0 0; font-size: 19px; font-weight: 650; color: var(--ft-ink); }
.ft-scan-hero-hint { margin: 0; max-width: 300px; font-size: var(--ft-fs-label); line-height: 1.6; color: var(--ft-ink-3); }
.ft-scan-quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ft-scan-quick-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px;
  border: 1px solid var(--ft-border); border-radius: var(--ft-r-card); background: var(--ft-surface);
  color: var(--ft-ink-2); font: inherit; font-size: var(--ft-fs-micro); cursor: pointer;
}
.ft-scan-quick-item:active { background: var(--ft-surface-2); }
.ft-scan-quick-item svg { color: var(--ft-brand); }

/* 页脚版本号：小号灰色，方便用户/客服确认版本 */
.ft-build { margin-left: auto; font-size: 11px; color: var(--ft-ink-3); opacity: .75; font-variant-numeric: tabular-nums; }

/* ── 无照片的占位卡统一（用户："为啥还有没照片的" + 之前颜色花花绿绿）──
   统一成中性灰底 + 淡图标 + "暂无照片"，看起来是"还没配图"，
   而不是"图片加载失败"。 */
.ft-lib-ph, .ft-recipe-ph, .ft-lib-img-ph {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(180deg, var(--ft-surface-2), color-mix(in oklab, var(--ft-surface-2) 70%, var(--ft-bg)));
  color: var(--ft-ink-3);
}
.ft-lib-ph svg, .ft-recipe-ph svg, .ft-lib-img-ph svg { opacity: .5; }
.ft-lib-ph::after, .ft-recipe-ph::after, .ft-lib-img-ph::after {
  content: "暂无照片"; font-size: 11px; color: var(--ft-ink-3); opacity: .8;
}
[lang="en"] .ft-lib-ph::after, [lang="en"] .ft-recipe-ph::after, [lang="en"] .ft-lib-img-ph::after { content: "No photo yet"; }
/* 卡片上不给占位块乱上色 */
.ft-lib-card [data-tone] { background: inherit; }

/* 扫码取景区：必须给足尺寸，否则 html5-qrcode 的解码区域是 0×0（iOS 上表现为"扫不出来"） */
.ft-barcode-reader { width: 100%; min-height: 240px; border-radius: var(--ft-r-card); overflow: hidden; background: #000; }
.ft-barcode-reader video { width: 100% !important; height: auto !important; object-fit: cover; }

/* 扫码提示框：只做视觉引导，不限制解码区域（解码扫全画面，命中率更高） */
.ft-barcode-reader { position: relative; }
.ft-barcode-reader::after {
  content: ""; position: absolute; left: 8%; right: 8%; top: 50%; height: 92px;
  transform: translateY(-50%); border: 2px solid rgba(255,255,255,.85); border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.18); pointer-events: none;
}

/* 补录商品的小表单 */
.ft-bc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 10px; }
.ft-bc-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--ft-ink-3); }
.ft-barcode-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
