/* ================= 养生大师 · 宣纸黛青 ================= */
:root {
  --paper: #f7f5f0;
  --paper-2: #fdfcfa;
  --surface: #ffffff;
  --ink: #2c2925;
  --ink-2: #5c564e;
  --ink-3: #8d8579;
  --line: #e6e1d8;
  --line-2: #f0ece4;

  --dai: #3c6b5c;         /* 黛青主色 */
  --dai-2: #2c5245;
  --dai-soft: #e8f0ec;
  --dai-mid: #6f9c8a;

  --cinnabar: #b5523c;    /* 朱砂 */
  --cinnabar-soft: #fbeeea;
  --gold: #b8893c;
  --gold-soft: #faf3e4;

  --good: #4a7c59;
  --warn: #b8893c;
  --bad: #b5523c;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --sh-1: 0 1px 2px rgba(44,41,37,.05);
  --sh-2: 0 4px 16px rgba(44,41,37,.07);
  --sh-3: 0 12px 32px rgba(44,41,37,.13);

  --sb-w: 232px;
  --tb-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  overscroll-behavior-y: none;
}

/* 宣纸质感：极淡的横向纹理 */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.012) 0 1px, transparent 1px 4px),
    radial-gradient(ellipse 80% 50% at 15% 0%, rgba(60,107,92,.045), transparent 60%),
    radial-gradient(ellipse 70% 50% at 100% 100%, rgba(181,82,60,.035), transparent 60%);
}

#app { position: relative; z-index: 1; display: flex; min-height: 100vh; }

/* ============ 侧边栏（桌面） ============ */
.sidebar {
  width: var(--sb-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 22px 18px 20px; }
.brand-mark {
  width: 40px; height: 40px; flex-shrink: 0;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--dai), var(--dai-2));
  color: #fff; border-radius: 11px;
  font-size: 20px; font-weight: 600;
  box-shadow: 0 3px 10px rgba(60,107,92,.28);
  font-family: "STKaiti", "KaiTi", "PingFang SC", serif;
}
.brand-text h1 { font-size: 16px; font-weight: 600; letter-spacing: .5px; }
.brand-text p { font-size: 11px; color: var(--ink-3); margin-top: 1px; }

.nav { flex: 1; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border: 0; border-radius: var(--r);
  background: transparent; color: var(--ink-2);
  font-size: 14.5px; font-family: inherit; cursor: pointer;
  transition: background .16s, color .16s;
  text-align: left; width: 100%;
}
.nav-item:hover { background: var(--line-2); }
.nav-item.active { background: var(--dai-soft); color: var(--dai-2); font-weight: 600; }
.nav-ico { font-size: 16px; width: 20px; text-align: center; opacity: .85; }

.sidebar-foot { padding: 12px 16px calc(14px + var(--safe-b)); border-top: 1px solid var(--line-2); }
.ai-status { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-3); }
.ai-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex-shrink: 0; }
.ai-status.on .dot { background: var(--good); box-shadow: 0 0 0 3px rgba(74,124,89,.14); }
.ai-status.off .dot { background: var(--warn); box-shadow: 0 0 0 3px rgba(184,137,60,.14); }

/* ============ 主区 ============ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 15;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 15px 26px;
  background: rgba(247,245,240,.9);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line-2);
}
.topbar-left h2 { font-size: 19px; font-weight: 600; letter-spacing: .3px; }
.topbar-left p { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.term-chip {
  padding: 6px 13px; border-radius: 999px;
  background: var(--gold-soft); color: #8a6428;
  font-size: 12.5px; font-weight: 500; white-space: nowrap;
  border: 1px solid rgba(184,137,60,.2);
}

.views { padding: 20px 26px 40px; max-width: 1180px; width: 100%; }
.view { display: none; animation: fade .28s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

/* ============ 卡片 ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--sh-1);
  margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h3 { font-size: 15.5px; font-weight: 600; }
.head-actions { display: flex; gap: 12px; }
.muted { font-size: 12.5px; color: var(--ink-3); }
.empty { color: var(--ink-3); font-size: 13.5px; text-align: center; padding: 22px 10px; }

.hero-grid { display: grid; grid-template-columns: minmax(0,320px) minmax(0,1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }

/* ============ 热量环 ============ */
.ring-card { display: flex; flex-direction: column; align-items: center; }
.ring-wrap { position: relative; width: 200px; height: 200px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line-2); stroke-width: 13; }
.ring-fg {
  fill: none; stroke: url(#g) ; stroke: var(--dai); stroke-width: 13;
  stroke-linecap: round;
  stroke-dasharray: 515; stroke-dashoffset: 515;
  transition: stroke-dashoffset .85s cubic-bezier(.4,0,.2,1);
}
.ring-center {
  position: absolute; inset: 0; display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 1px;
}
.ring-num { font-size: 40px; font-weight: 600; letter-spacing: -1px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ring-unit { font-size: 12px; color: var(--ink-3); margin-top: -2px; }
.ring-sub { font-size: 12px; color: var(--ink-3); margin-top: 5px; }
.ring-meta {
  margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap;
  justify-content: center; width: 100%;
}
.pill {
  padding: 4px 11px; border-radius: 999px; font-size: 12px;
  background: var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.pill.good { background: #e9f3ec; color: var(--good); }
.pill.warn { background: var(--gold-soft); color: #8a6428; }
.pill.bad  { background: var(--cinnabar-soft); color: var(--cinnabar); }

/* ============ 营养素条 ============ */
.macro-list { display: flex; flex-direction: column; gap: 15px; }
.macro-row .macro-top {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px; font-size: 13.5px;
}
.macro-name { font-weight: 500; }
.macro-val { color: var(--ink-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.bar { height: 7px; background: var(--line-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; transition: width .7s cubic-bezier(.4,0,.2,1); }
.bar-fill.protein { background: linear-gradient(90deg, #5c8d7b, var(--dai)); }
.bar-fill.carb    { background: linear-gradient(90deg, #d4a95f, var(--gold)); }
.bar-fill.fat     { background: linear-gradient(90deg, #d08672, var(--cinnabar)); }
.bar-fill.fiber   { background: linear-gradient(90deg, #8fb08f, #5d8a5d); }

/* ============ 通用控件 ============ */
button { font-family: inherit; }
.btn-primary {
  padding: 10px 18px; border: 0; border-radius: var(--r);
  background: var(--dai); color: #fff; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background .16s, transform .1s, box-shadow .16s;
  box-shadow: 0 2px 6px rgba(60,107,92,.2);
}
.btn-primary:hover { background: var(--dai-2); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary.lg, .btn-secondary.lg { flex: 1; padding: 14px 18px; font-size: 15px; }
.btn-secondary {
  padding: 10px 18px; border: 1px solid var(--dai); border-radius: var(--r);
  background: var(--surface); color: var(--dai); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background .16s;
}
.btn-secondary:hover { background: var(--dai-soft); }
.btn-ghost {
  padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--paper-2); color: var(--ink-2); font-size: 13px; cursor: pointer;
}
.btn-link {
  border: 0; background: none; color: var(--dai); font-size: 13px;
  cursor: pointer; padding: 4px; font-family: inherit; font-weight: 500;
}
.btn-link:hover { text-decoration: underline; }
.block { width: 100%; }

input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--paper-2); color: var(--ink); font-size: 14px;
  font-family: inherit; transition: border-color .16s, box-shadow .16s;
}
input:focus, select:focus, textarea:focus {
  outline: 0; border-color: var(--dai-mid);
  box-shadow: 0 0 0 3px rgba(60,107,92,.1);
}
select { cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath fill='%238d8579' d='M5.5 7L0 0h11z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 32px; }

/* ============ 饮水 ============ */
.water-bar {
  height: 24px; background: linear-gradient(180deg, #eef5f7, #e4eef1);
  border-radius: 999px; overflow: hidden; margin-bottom: 12px;
  border: 1px solid #dfeaee;
}
.water-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #7fb8c9, #5a9cb5);
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.water-actions { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.btn-water {
  flex: 1; min-width: 84px; padding: 9px 10px;
  border: 1px solid #cfe3e9; border-radius: var(--r);
  background: #f2f8fa; color: #3f7f96; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background .15s;
}
.btn-water:hover { background: #e4f1f5; }
.mini-row { display: flex; gap: 12px; margin-bottom: 13px; }
.mini-row label { flex: 1; font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 7px; }
.mini-row input { width: 76px; padding: 8px 10px; }

/* ============ 体重 ============ */
.weight-row { display: flex; gap: 10px; margin-bottom: 12px; }
.weight-row input { flex: 1; }
.stat-line { font-size: 13px; color: var(--ink-2); margin-bottom: 12px; display: flex; gap: 14px; flex-wrap: wrap; }
.stat-line b { font-weight: 600; }
.trend { display: flex; align-items: flex-end; gap: 4px; height: 60px; }
.trend-bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 4px; }
.trend-fill { background: linear-gradient(180deg, var(--dai-mid), var(--dai)); border-radius: 3px 3px 0 0; min-height: 3px; }
.trend-lbl { font-size: 9.5px; color: var(--ink-3); text-align: center; }

/* ============ 柱状趋势图 ============ */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 10px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.chart-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; position: relative; }
.chart-target {
  position: absolute; left: -20%; right: -20%; height: 2px;
  background: repeating-linear-gradient(90deg, var(--cinnabar) 0 5px, transparent 5px 10px);
  opacity: .55;
}
.chart-bar {
  width: 68%; max-width: 40px; border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, var(--dai-mid), var(--dai));
  transition: height .7s cubic-bezier(.4,0,.2,1); min-height: 3px;
}
.chart-bar.over { background: linear-gradient(180deg, #d08672, var(--cinnabar)); }
.chart-lbl { font-size: 10.5px; color: var(--ink-3); }
.chart-val { font-size: 10.5px; color: var(--ink-2); font-weight: 500; font-variant-numeric: tabular-nums; }

/* ============ 节气卡 ============ */
.term-badge {
  padding: 4px 12px; border-radius: 999px; font-size: 12px;
  background: var(--dai-soft); color: var(--dai-2); font-weight: 500;
}
.term-advice { font-size: 14px; color: var(--ink-2); line-height: 1.75; margin-bottom: 12px; }
.foods-hint { display: flex; gap: 7px; flex-wrap: wrap; }
.food-tag {
  padding: 5px 12px; border-radius: 999px; font-size: 12.5px;
  background: var(--dai-soft); color: var(--dai-2); border: 1px solid rgba(60,107,92,.13);
}

/* ============ 饮食记录 ============ */
.log-list { display: flex; flex-direction: column; gap: 10px; }
.log-item {
  display: flex; align-items: center; gap: 13px;
  padding: 12px 14px; background: var(--paper-2);
  border: 1px solid var(--line-2); border-radius: var(--r);
  cursor: pointer; transition: border-color .16s, background .16s;
}
.log-item:hover { border-color: var(--dai-mid); background: var(--surface); }
.log-icon {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px;
  display: grid; place-items: center; font-size: 17px;
  background: var(--dai-soft); color: var(--dai-2);
}
.log-main { flex: 1; min-width: 0; }
.log-title {
  font-size: 14px; font-weight: 500; margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.log-sub { font-size: 12px; color: var(--ink-3); }
.log-kcal { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.log-kcal small { font-size: 11px; color: var(--ink-3); font-weight: 400; }
.score-badge {
  padding: 3px 9px; border-radius: 6px; font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.score-badge.good { background: #e9f3ec; color: var(--good); }
.score-badge.warn { background: var(--gold-soft); color: #8a6428; }
.score-badge.bad  { background: var(--cinnabar-soft); color: var(--cinnabar); }

/* ============ 拍照区 ============ */
.scan-card { padding: 20px; }
.scan-zone {
  border: 2px dashed var(--line); border-radius: var(--r-lg);
  background: var(--paper-2); min-height: 260px;
  display: grid; place-items: center; overflow: hidden;
  position: relative; transition: border-color .2s, background .2s;
  margin-bottom: 16px;
}
.scan-zone.drag { border-color: var(--dai); background: var(--dai-soft); }
.scan-zone img { max-width: 100%; max-height: 380px; display: block; object-fit: contain; }
.scan-zone img[hidden] { display: none; }
.scan-placeholder { text-align: center; padding: 36px 20px; }
.scan-ico { font-size: 40px; color: var(--dai-mid); margin-bottom: 12px; opacity: .65; }
.scan-title { font-size: 15.5px; font-weight: 500; margin-bottom: 5px; }
.scan-tip { font-size: 13px; color: var(--ink-3); }
.scan-actions { display: flex; gap: 12px; margin-bottom: 14px; }
.scan-actions .ico { font-size: 15px; margin-right: 4px; }
.text-entry { display: flex; gap: 10px; }
.text-entry input { flex: 1; }
.scan-status { margin-top: 14px; font-size: 13.5px; color: var(--ink-2); }
.scan-status.err { color: var(--cinnabar); }
.scan-status.ok { color: var(--good); }

/* 识别中遮罩 */
.loading-mask {
  position: absolute; inset: 0; background: rgba(255,255,255,.9);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; z-index: 5; backdrop-filter: blur(2px);
}
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--dai-soft); border-top-color: var(--dai);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-txt { font-size: 13.5px; color: var(--ink-2); }

/* ============ 识别结果 ============ */
.result-head {
  display: flex; align-items: center; gap: 14px; margin-bottom: 16px;
}
.score-ring {
  width: 74px; height: 74px; flex-shrink: 0; position: relative;
  display: grid; place-items: center;
}
.score-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.score-ring .sr-bg { fill: none; stroke: var(--line-2); stroke-width: 6; }
.score-ring .sr-fg { fill: none; stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset .8s; }
.score-ring .sr-num { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; z-index: 1; }
.result-title { font-size: 16.5px; font-weight: 600; margin-bottom: 3px; }
.result-sub { font-size: 12.5px; color: var(--ink-3); }

.kcal-hero {
  display: flex; align-items: baseline; gap: 8px;
  padding: 14px 16px; background: linear-gradient(135deg, var(--dai-soft), #f2f7f4);
  border-radius: var(--r); margin-bottom: 16px;
}
.kcal-hero .k-num { font-size: 30px; font-weight: 600; color: var(--dai-2); font-variant-numeric: tabular-nums; }
.kcal-hero .k-unit { font-size: 13px; color: var(--ink-2); }
.kcal-hero .k-note { margin-left: auto; font-size: 12.5px; color: var(--ink-3); }

.food-table { display: flex; flex-direction: column; gap: 1px; background: var(--line-2); border-radius: var(--r); overflow: hidden; margin-bottom: 16px; }
.food-row {
  display: grid; grid-template-columns: 1fr auto auto auto;
  gap: 11px; align-items: center; padding: 11px 14px; background: var(--surface);
  font-size: 13.5px;
}
.food-row.head { background: var(--paper-2); font-size: 12px; color: var(--ink-3); font-weight: 500; }
.food-name { font-weight: 500; display: flex; align-items: center; gap: 7px; min-width: 0; }
.food-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.food-grams { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.food-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.tag-src {
  font-size: 10px; padding: 1px 6px; border-radius: 4px; flex-shrink: 0;
  background: var(--line-2); color: var(--ink-3);
}
.tag-src.db { background: var(--dai-soft); color: var(--dai-2); }

.dims { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px,1fr)); gap: 11px; margin-bottom: 16px; }
.dim-item { padding: 12px; background: var(--paper-2); border-radius: var(--r); border: 1px solid var(--line-2); }
.dim-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.dim-name { font-size: 12.5px; color: var(--ink-2); }
.dim-score { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dim-detail { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; }

.advice-box {
  padding: 14px 16px; background: var(--gold-soft);
  border-radius: var(--r); border: 1px solid rgba(184,137,60,.18); margin-bottom: 16px;
}
.advice-box h4 { font-size: 13.5px; color: #8a6428; margin-bottom: 9px; font-weight: 600; }
.advice-box ul { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.advice-box li { font-size: 13.5px; color: var(--ink-2); padding-left: 17px; position: relative; line-height: 1.6; }
.advice-box li::before { content: "•"; position: absolute; left: 5px; color: var(--gold); font-weight: 700; }

.pairing-box {
  padding: 14px 16px; background: var(--dai-soft);
  border-radius: var(--r); margin-bottom: 16px;
}
.pairing-box h4 { font-size: 13.5px; color: var(--dai-2); margin-bottom: 9px; font-weight: 600; }
.pairing-box ul { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.pairing-box li { font-size: 13.5px; color: var(--ink-2); padding-left: 17px; position: relative; }
.pairing-box li::before { content: "→"; position: absolute; left: 3px; color: var(--dai); }

.notice-box {
  padding: 13px 16px; background: var(--cinnabar-soft);
  border: 1px solid rgba(181,82,60,.16); border-radius: var(--r);
  font-size: 13.5px; color: #8f422f; line-height: 1.65;
}
.notice-box code {
  background: rgba(255,255,255,.7); padding: 2px 6px; border-radius: 4px;
  font-size: 12px; font-family: ui-monospace, Consolas, monospace;
}

.result-actions { display: flex; gap: 11px; margin-top: 4px; }
.result-actions button { flex: 1; }

/* ============ 菜谱 ============ */
.gen-row { display: flex; gap: 12px; margin-bottom: 12px; }
.gen-field { flex: 1; }
.gen-field label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 5px; }
#recipePantry { margin-bottom: 12px; }
.gen-status { margin-top: 12px; font-size: 13px; color: var(--ink-3); min-height: 20px; }

.filter-row { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  padding: 5px 13px; border-radius: 999px; font-size: 12.5px;
  border: 1px solid var(--line); background: var(--paper-2);
  color: var(--ink-2); cursor: pointer; transition: all .16s;
}
.chip:hover { border-color: var(--dai-mid); }
.chip.active { background: var(--dai); color: #fff; border-color: var(--dai); }

.recipe-list { display: flex; flex-direction: column; gap: 11px; }
.recipe-item {
  padding: 14px 16px; background: var(--paper-2);
  border: 1px solid var(--line-2); border-radius: var(--r);
  cursor: pointer; transition: border-color .16s, box-shadow .16s;
}
.recipe-item:hover { border-color: var(--dai-mid); box-shadow: var(--sh-2); }
.recipe-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.recipe-name { font-size: 15px; font-weight: 600; }
.recipe-meta { font-size: 12px; color: var(--ink-3); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 3px; }
.recipe-nutri { display: flex; gap: 12px; font-size: 12px; color: var(--ink-2); margin-top: 8px; flex-wrap: wrap; }
.recipe-nutri b { font-weight: 600; }

/* 菜谱详情 */
.detail-head { margin-bottom: 16px; }
.detail-title { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.detail-meta { display: flex; gap: 9px; flex-wrap: wrap; }
.detail-section { margin-bottom: 18px; }
.detail-section h4 {
  font-size: 14px; font-weight: 600; margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px; color: var(--dai-2);
}
.detail-section h4::before { content: ""; width: 3px; height: 14px; background: var(--dai); border-radius: 2px; }
.ing-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ing-list li {
  padding: 9px 13px; background: var(--paper-2);
  border-radius: var(--r-sm); font-size: 13.5px;
  border-left: 2px solid var(--dai-mid);
}
.step-list { list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 11px; }
.step-list li {
  counter-increment: s; position: relative; padding-left: 36px;
  font-size: 13.5px; line-height: 1.7; color: var(--ink-2);
}
.step-list li::before {
  content: counter(s); position: absolute; left: 0; top: 0;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--dai-soft); color: var(--dai-2);
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
}
.tip-box {
  padding: 13px 15px; background: var(--gold-soft);
  border-radius: var(--r); font-size: 13.5px; color: var(--ink-2); line-height: 1.7;
  border: 1px solid rgba(184,137,60,.16);
}

/* ============ 计划 ============ */
.plan-day { margin-bottom: 16px; }
.plan-day-head {
  display: flex; align-items: center; gap: 11px; margin-bottom: 12px;
}
.plan-day-badge {
  width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0;
  background: var(--dai-soft); color: var(--dai-2);
  display: grid; place-items: center; font-size: 15px; font-weight: 600;
}
.plan-day-title { font-size: 15px; font-weight: 600; }
.plan-day-sub { font-size: 12px; color: var(--ink-3); }
.meal-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  background: var(--paper-2); border-radius: var(--r); margin-bottom: 8px;
  border: 1px solid var(--line-2);
}
.meal-slot {
  padding: 4px 10px; border-radius: 6px; font-size: 12px;
  background: var(--dai-soft); color: var(--dai-2); flex-shrink: 0; font-weight: 500;
}
.meal-main { flex: 1; min-width: 0; }
.meal-name { font-size: 14px; font-weight: 500; }
.meal-note { font-size: 11.5px; color: var(--ink-3); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meal-kcal { font-size: 13.5px; font-weight: 600; color: var(--dai-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.shop-hint {
  padding: 12px 15px; background: var(--paper-2); border-radius: var(--r);
  font-size: 13px; color: var(--ink-2); line-height: 1.7;
  border: 1px dashed var(--line);
}
.shop-hint b { color: var(--ink); }

/* ============ 采购清单 ============ */
.shopping-add { display: flex; gap: 10px; margin-bottom: 14px; }
.shopping-add input { flex: 1; }
.shopping-list { display: flex; flex-direction: column; gap: 7px; }
.shop-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 13px;
  background: var(--paper-2); border-radius: var(--r); border: 1px solid var(--line-2);
}
.shop-check {
  width: 20px; height: 20px; border-radius: 6px; flex-shrink: 0;
  border: 1.5px solid var(--line); cursor: pointer;
  display: grid; place-items: center; transition: all .16s;
}
.shop-item.done .shop-check { background: var(--dai); border-color: var(--dai); }
.shop-item.done .shop-check::after { content: "✓"; color: #fff; font-size: 12px; }
.shop-item.done .shop-name { text-decoration: line-through; color: var(--ink-3); }
.shop-name { flex: 1; font-size: 14px; }
.shop-del { border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 16px; padding: 2px 6px; }
.shop-del:hover { color: var(--cinnabar); }

/* ================================================================
   登录 / 账号
   ================================================================ */
.account-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 11px 7px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; transition: all .16s; width: 100%;
  font-family: inherit; text-align: left;
}
.account-chip:hover { border-color: var(--dai-mid); background: var(--dai-soft); }
.account-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: #fff;
  font-size: 13px; font-weight: 500;
}
.account-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.account-name {
  font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-state {
  font-size: 11px; color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-chip.logged .account-state { color: var(--good); }

/* 弹层内表单 */
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--line-2); border-radius: var(--r); margin-bottom: 4px;
}
.auth-tab {
  flex: 1; padding: 9px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-2);
  font-size: 14px; cursor: pointer; transition: all .16s;
  font-family: inherit;
}
.auth-tab.active { background: var(--surface); color: var(--dai-2); font-weight: 600;
  box-shadow: var(--sh-1); }
.auth-field label {
  display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px;
}
.auth-field { position: relative; }
.auth-field .pw-toggle {
  position: absolute; right: 10px; bottom: 9px;
  border: 0; background: none; cursor: pointer;
  color: var(--ink-3); font-size: 12px; padding: 2px 4px;
}
.auth-field .pw-toggle:hover { color: var(--dai); }
.auth-err {
  font-size: 12.5px; color: var(--cinnabar);
  background: var(--cinnabar-soft); padding: 9px 12px;
  border-radius: var(--r-sm); border: 1px solid rgba(181,82,60,.14);
}
.auth-hint {
  font-size: 11.5px; color: var(--ink-3); line-height: 1.6;
  padding: 10px 12px; background: var(--paper-2);
  border-radius: var(--r-sm); border: 1px solid var(--line-2);
}
.auth-hint b { color: var(--ink-2); }

.user-box {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; background: var(--paper-2);
  border-radius: var(--r); border: 1px solid var(--line-2);
  margin-bottom: 16px;
}
.user-box .ub-avatar {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-size: 19px; font-weight: 500;
}
.user-box .ub-info { flex: 1; min-width: 0; }
.user-box .ub-name { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.user-box .ub-sub { font-size: 12px; color: var(--ink-3); }
.guest-badge {
  padding: 3px 9px; border-radius: 999px; font-size: 11px;
  background: var(--gold-soft); color: #8a6428; border: 1px solid rgba(184,137,60,.2);
}

/* 数据存储说明 */
.storage-note {
  padding: 14px 16px; border-radius: var(--r);
  background: var(--dai-soft); border: 1px solid rgba(60,107,92,.14);
  font-size: 13px; color: var(--ink-2); line-height: 1.7;
}
.storage-note.guest {
  background: var(--gold-soft); border-color: rgba(184,137,60,.18);
}
.storage-note b { color: var(--ink); }

/* 会话历史里的登录入口 */
.login-prompt {
  margin: 0 14px 12px; padding: 11px 13px;
  border-radius: var(--r); background: var(--gold-soft);
  border: 1px solid rgba(184,137,60,.18);
  font-size: 12px; color: #8a6428; line-height: 1.6;
}
.login-prompt button {
  display: block; width: 100%; margin-top: 7px;
  padding: 6px; border-radius: var(--r-sm);
  border: 1px solid rgba(184,137,60,.3); background: rgba(255,255,255,.6);
  color: #8a6428; font-size: 12px; cursor: pointer; font-family: inherit;
}
.login-prompt button:hover { background: #fff; }

/* ================================================================
   对话（首页问答）
   ================================================================ */
.chat-wrap {
  display: flex;
  gap: 16px;
  height: calc(100vh - var(--tb-h) - 58px);
  min-height: 460px;
}

/* 会话侧栏 */
.chat-side {
  width: 232px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.chat-side-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--line-2); }
.chat-side-head .ico { font-size: 14px; margin-right: 3px; }
.chat-session-list { flex: 1; overflow-y: auto; padding: 8px; }

.session-item {
  padding: 10px 12px; border-radius: var(--r);
  cursor: pointer; transition: background .16s;
  margin-bottom: 2px; position: relative;
}
.session-item:hover { background: var(--line-2); }
.session-item.active { background: var(--dai-soft); }
.session-item.active .si-title { color: var(--dai-2); font-weight: 600; }
.si-title {
  font-size: 13.5px; margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.si-meta { font-size: 11px; color: var(--ink-3); display: flex; gap: 8px; }
.si-del {
  position: absolute; right: 8px; top: 8px;
  width: 22px; height: 22px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink-3); cursor: pointer;
  font-size: 13px; opacity: 0; transition: opacity .15s, background .15s;
  line-height: 1; display: grid; place-items: center;
}
.session-item:hover .si-del { opacity: 1; }
.si-del:hover { background: var(--cinnabar-soft); color: var(--cinnabar); }

/* 对话主区 */
.chat-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.chat-scroll {
  flex: 1; overflow-y: auto;
  padding: 22px 24px 12px;
  scroll-behavior: smooth;
}

/* 开场引导 */
.chat-welcome {
  max-width: 560px; margin: 0 auto;
  padding: 26px 0 20px; text-align: center;
}
.chat-welcome.hidden { display: none; }
.welcome-mark {
  width: 58px; height: 58px; margin: 0 auto 16px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--dai), var(--dai-2));
  color: #fff; border-radius: 17px;
  font-size: 28px; font-family: "STKaiti", "KaiTi", "PingFang SC", serif;
  box-shadow: 0 5px 16px rgba(60,107,92,.24);
}
.chat-welcome h2 { font-size: 21px; font-weight: 600; margin-bottom: 9px; }
.welcome-sub { font-size: 14px; color: var(--ink-2); line-height: 1.8; margin-bottom: 18px; }
.welcome-profile {
  display: inline-flex; gap: 7px; flex-wrap: wrap;
  justify-content: center; margin-bottom: 20px;
}
.welcome-chips {
  display: flex; gap: 9px; flex-wrap: wrap;
  justify-content: center; margin-bottom: 24px;
}
.chip-btn {
  padding: 8px 15px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--paper-2);
  color: var(--ink-2); font-size: 13px; cursor: pointer;
  transition: all .16s; font-family: inherit;
}
.chip-btn:hover {
  border-color: var(--dai-mid); background: var(--dai-soft); color: var(--dai-2);
}
.welcome-tips {
  text-align: left; padding: 15px 18px;
  background: var(--paper-2); border-radius: var(--r);
  border: 1px solid var(--line-2);
}
.welcome-tips span { font-size: 12px; color: var(--ink-3); }
.welcome-tips ul { list-style: none; margin-top: 9px; display: flex; flex-direction: column; gap: 7px; }
.welcome-tips li {
  font-size: 13px; color: var(--ink-2);
  padding-left: 15px; position: relative; line-height: 1.6;
}
.welcome-tips li::before {
  content: ""; position: absolute; left: 3px; top: 8px;
  width: 4px; height: 4px; border-radius: 50%; background: var(--dai-mid);
}

/* 消息 */
.chat-msgs { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; gap: 12px; align-items: flex-start; }
.msg-user { flex-direction: row-reverse; }
.msg-avatar {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 9px;
  display: grid; place-items: center; font-size: 14px; font-weight: 500;
}
.msg-assistant .msg-avatar {
  background: linear-gradient(145deg, var(--dai), var(--dai-2));
  color: #fff; font-family: "STKaiti", "KaiTi", "PingFang SC", serif; font-size: 17px;
}
.msg-user .msg-avatar { background: var(--line-2); color: var(--ink-2); }
.msg-body { min-width: 0; max-width: 82%; }
.msg-user .msg-body { display: flex; flex-direction: column; align-items: flex-end; }

.bubble {
  padding: 12px 16px; border-radius: 14px;
  font-size: 14.5px; line-height: 1.75;
  white-space: pre-wrap; word-break: break-word;
}
.msg-assistant .bubble {
  background: var(--paper-2); color: var(--ink);
  border: 1px solid var(--line-2);
  border-top-left-radius: 4px;
}
.msg-user .bubble {
  background: var(--dai); color: #fff;
  border-top-right-radius: 4px;
}
.bubble img.chat-thumb {
  display: block; width: 100%; max-width: 260px;
  border-radius: 9px; margin-bottom: 8px;
}
.bubble strong { font-weight: 600; }

/* 打字指示 */
.typing { display: flex; gap: 4px; padding: 4px 0; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--dai-mid);
  animation: bounce 1.3s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .16s; }
.typing span:nth-child(3) { animation-delay: .32s; }
@keyframes bounce {
  0%, 62%, 100% { transform: translateY(0); opacity: .5; }
  31% { transform: translateY(-6px); opacity: 1; }
}

/* 结构化数据卡 */
.msg-card {
  margin-top: 10px; border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; background: var(--surface);
}
.msg-card-head {
  padding: 9px 13px; background: var(--paper-2);
  border-bottom: 1px solid var(--line-2);
  font-size: 12.5px; color: var(--ink-2); font-weight: 500;
  display: flex; justify-content: space-between; align-items: center;
}
.msg-card-body { padding: 12px 14px; }
.msg-kcal {
  display: flex; align-items: baseline; gap: 7px;
  padding: 11px 14px; background: linear-gradient(135deg, var(--dai-soft), #f2f7f4);
  margin-bottom: 11px;
}
.msg-kcal .k-num { font-size: 24px; font-weight: 600; color: var(--dai-2); }
.msg-kcal .k-unit { font-size: 12.5px; color: var(--ink-2); }
.msg-kcal .k-note { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.mini-food { display: flex; flex-direction: column; gap: 7px; }
.mini-food-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px; background: var(--paper-2);
  border-radius: var(--r-sm); font-size: 13px;
}
.mini-food-row .mf-name { flex: 1; font-weight: 500; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-food-row .mf-g { font-size: 11.5px; color: var(--ink-3); }
.mini-food-row .mf-k { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* 消息操作按钮 */
.msg-actions {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px;
}
.msg-act {
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-size: 12.5px; cursor: pointer;
  transition: all .16s; font-family: inherit;
}
.msg-act:hover { border-color: var(--dai); color: var(--dai); background: var(--dai-soft); }

.msg-time { font-size: 11px; color: var(--ink-3); margin-top: 6px; }

/* 输入区 */
.chat-input-bar {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 12px 18px 8px;
  border-top: 1px solid var(--line-2);
  background: var(--paper-2);
}
.chat-attach {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer;
  display: grid; place-items: center;
  color: var(--ink-2); font-size: 17px;
  transition: all .16s;
}
.chat-attach:hover { border-color: var(--dai); color: var(--dai); }
.chat-input-box {
  flex: 1; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 13px; transition: border-color .16s, box-shadow .16s;
  display: flex; align-items: center;
}
.chat-input-box:focus-within {
  border-color: var(--dai-mid); box-shadow: 0 0 0 3px rgba(60,107,92,.09);
}
.chat-input-box textarea {
  width: 100%; border: 0; outline: 0; resize: none;
  background: transparent; font-family: inherit;
  font-size: 14.5px; line-height: 1.6; color: var(--ink);
  max-height: 132px; padding: 4px 0;
}
.chat-input-box textarea::placeholder { color: var(--ink-3); }
.chat-send {
  width: 38px; height: 38px; flex-shrink: 0;
  border: 0; border-radius: 10px;
  background: var(--dai); color: #fff; cursor: pointer;
  display: grid; place-items: center; font-size: 17px;
  transition: background .16s, opacity .16s, transform .1s;
}
.chat-send:hover { background: var(--dai-2); }
.chat-send:disabled { opacity: .38; cursor: not-allowed; }
.chat-send:not(:disabled):active { transform: scale(.94); }
.chat-disclaimer {
  text-align: center; font-size: 11px; color: var(--ink-3);
  padding: 0 18px 10px; background: var(--paper-2);
}

/* 会话切换按钮（手机端顶部） */
.chat-mobile-bar { display: none; }

@media (max-width: 1024px) {
  .chat-wrap { height: calc(100vh - var(--tb-h) - 54px); }
}

@media (max-width: 720px) {
  .chat-wrap {
    height: calc(100vh - var(--tb-h) - 66px - var(--safe-b));
    min-height: 0; gap: 0;
  }
  /* 侧栏改为抽屉 */
  .chat-side {
    position: fixed; inset: 0 auto 0 0; width: 78vw; max-width: 300px;
    z-index: 60; border-radius: 0; border: 0;
    transform: translateX(-100%); transition: transform .26s cubic-bezier(.4,0,.2,1);
    box-shadow: var(--sh-3);
  }
  .chat-side.open { transform: none; }
  .chat-main { border-radius: 0; border: 0; box-shadow: none; }
  .chat-scroll { padding: 16px 14px 8px; }
  .chat-welcome { padding: 14px 0 12px; }
  .chat-welcome h2 { font-size: 19px; }
  .welcome-mark { width: 50px; height: 50px; font-size: 24px; margin-bottom: 13px; }
  .welcome-sub { font-size: 13px; }
  .welcome-chips { gap: 7px; margin-bottom: 18px; }
  .chip-btn { font-size: 12.5px; padding: 7px 13px; }
  .welcome-tips { padding: 13px 15px; }
  .msg { gap: 9px; }
  .msg-avatar { width: 28px; height: 28px; font-size: 13px; }
  .msg-assistant .msg-avatar { font-size: 15px; }
  .msg-body { max-width: 86%; }
  .bubble { padding: 10px 13px; font-size: 14px; border-radius: 12px; }
  .msg-assistant .bubble { border-top-left-radius: 3px; }
  .msg-user .bubble { border-top-right-radius: 3px; }
  .chat-input-bar { padding: 10px 12px 6px; gap: 8px; }
  .chat-disclaimer { padding: 0 12px 8px; font-size: 10.5px; }
  .bubble img.chat-thumb { max-width: 190px; }
}

@media (max-width: 380px) {
  .chat-input-box textarea { font-size: 14px; }
  .chat-attach, .chat-send { width: 34px; height: 34px; }
}
.constitution-hero {
  padding: 24px; border-radius: var(--r-lg); margin-bottom: 16px;
  background: linear-gradient(135deg, var(--dai) 0%, var(--dai-2) 100%);
  color: #fff; text-align: center;
}
.constitution-type {
  font-size: 30px; font-weight: 600; margin-bottom: 9px; letter-spacing: 2px;
  font-family: "STKaiti", "KaiTi", "PingFang SC", serif;
}
.constitution-desc { font-size: 13.5px; opacity: .92; line-height: 1.75; max-width: 480px; margin: 0 auto; }

.q-list { display: flex; flex-direction: column; gap: 11px; }
.q-item {
  padding: 14px 16px; background: var(--paper-2);
  border-radius: var(--r); border: 1px solid var(--line-2);
}
.q-text { font-size: 14.5px; margin-bottom: 11px; }
.q-btns { display: flex; gap: 9px; }
.q-btn {
  flex: 1; padding: 9px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-size: 13.5px;
  cursor: pointer; transition: all .16s;
}
.q-btn.on-yes { background: var(--dai); color: #fff; border-color: var(--dai); }
.q-btn.on-no  { background: var(--cinnabar); color: #fff; border-color: var(--cinnabar); }

.con-type-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 10px; margin-bottom: 16px; }
.con-type {
  padding: 11px 13px; background: var(--paper-2); border-radius: var(--r);
  border: 1px solid var(--line-2);
}
.con-type-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.con-type-name { font-size: 13.5px; font-weight: 500; }
.con-type-pct { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.advice-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(230px,1fr)); gap: 14px; }
.advice-col { padding: 15px 17px; border-radius: var(--r); border: 1px solid var(--line-2); }
.advice-good { background: #f2f8f4; border-color: #dcebe1; }
.advice-avoid { background: var(--cinnabar-soft); border-color: rgba(181,82,60,.14); }
.advice-ex { background: var(--paper-2); }
.advice-col h5 { font-size: 13px; font-weight: 600; margin-bottom: 9px; }
.advice-good h5 { color: var(--good); }
.advice-avoid h5 { color: var(--cinnabar); }
.advice-ex h5 { color: var(--dai-2); }
.advice-col p { font-size: 13px; color: var(--ink-2); line-height: 1.7; margin-bottom: 9px; }

/* ============ 我的 ============ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 13px; margin-bottom: 16px; }
.form-field label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 5px; }
.form-field.full { grid-column: 1 / -1; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(128px,1fr)); gap: 12px; }
.stat-box {
  padding: 14px; background: var(--paper-2); border-radius: var(--r);
  border: 1px solid var(--line-2); text-align: center;
}
.stat-box .s-val { font-size: 22px; font-weight: 600; color: var(--dai-2); font-variant-numeric: tabular-nums; }
.stat-box .s-val small { font-size: 12px; color: var(--ink-3); font-weight: 400; margin-left: 2px; }
.stat-box .s-lbl { font-size: 12px; color: var(--ink-3); margin-top: 3px; }

.sys-info { font-size: 13px; color: var(--ink-2); line-height: 2; }
.sys-info code {
  background: var(--line-2); padding: 2px 7px; border-radius: 4px;
  font-size: 12px; font-family: ui-monospace, Consolas, monospace;
}

/* ============ 弹层 ============ */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(44,41,37,.42); backdrop-filter: blur(3px); }
.modal-body {
  position: relative; background: var(--surface); border-radius: var(--r-lg);
  padding: 24px; max-width: 560px; width: 100%; max-height: 86vh; overflow-y: auto;
  box-shadow: var(--sh-3); animation: pop .24s cubic-bezier(.3,1.2,.5,1);
}
@keyframes pop { from { opacity: 0; transform: scale(.95) translateY(10px); } to { opacity: 1; transform: none; } }
.modal-close {
  position: absolute; top: 14px; right: 16px; width: 30px; height: 30px;
  border: 0; background: var(--line-2); border-radius: 50%;
  cursor: pointer; font-size: 16px; color: var(--ink-2); line-height: 1;
}
.modal-close:hover { background: var(--line); }

/* ============ Toast ============ */
.toast-wrap {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 9px; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 11px 20px; border-radius: 999px; font-size: 13.5px;
  background: rgba(44,41,37,.93); color: #fff; box-shadow: var(--sh-3);
  animation: toastIn .26s cubic-bezier(.3,1.2,.5,1);
  max-width: 88vw; text-align: center;
}
.toast.ok { background: rgba(60,107,92,.95); }
.toast.err { background: rgba(181,82,60,.95); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ================================================================
   响应式：平板 → 手机
   ================================================================ */
@media (max-width: 1024px) {
  .hero-grid, .grid-2 { grid-template-columns: 1fr; }
  .views { padding: 18px 18px 36px; }
  .topbar { padding: 13px 18px; }
}

@media (max-width: 720px) {
  body { font-size: 14.5px; }
  /* 侧边栏 → 底部导航 */
  #app { flex-direction: column; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    width: 100%; height: auto; flex-direction: row;
    border-right: 0; border-top: 1px solid var(--line);
    box-shadow: 0 -2px 14px rgba(44,41,37,.07);
    padding-bottom: var(--safe-b);
    z-index: 30;
  }
  .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; padding: 5px 4px; gap: 0; width: 100%; }
  .nav-item {
    flex: 1; flex-direction: column; gap: 2px; padding: 7px 2px;
    font-size: 10.5px; border-radius: var(--r-sm); min-width: 0;
  }
  .nav-ico { font-size: 17px; }
  .nav-label { font-size: 10.5px; }

  .main { padding-bottom: calc(66px + var(--safe-b)); }
  .topbar { padding: 12px 15px; }
  .topbar-left h2 { font-size: 17px; }
  .topbar-left p { font-size: 11.5px; }
  .term-chip { font-size: 11.5px; padding: 5px 10px; }
  .views { padding: 14px 13px 26px; }

  .card { padding: 15px 15px; border-radius: var(--r); margin-bottom: 12px; }
  .card-head h3 { font-size: 14.5px; }
  .ring-wrap { width: 176px; height: 176px; }
  .ring-num { font-size: 35px; }

  .scan-zone { min-height: 210px; }
  .scan-actions { flex-direction: column; }
  .text-entry { flex-direction: column; }
  .gen-row { flex-direction: column; gap: 11px; }

  .food-row { grid-template-columns: 1fr auto; gap: 6px 11px; padding: 11px 13px; }
  .food-row.head { display: none; }
  .food-row .f-grams { grid-column: 1 / -1; font-size: 11.5px; }
  .food-row .f-pro { display: none; }
  .food-row .f-car { display: none; }

  .dims { grid-template-columns: repeat(2,1fr); }
  .result-actions { flex-direction: column; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-body { max-width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92vh; padding: 20px 17px calc(20px + var(--safe-b)); }
  .toast-wrap { bottom: calc(78px + var(--safe-b)); }
}

@media (max-width: 380px) {
  .nav-label { font-size: 9.5px; }
  .nav-item { padding: 6px 1px; }
}

/* 桌面端悬停才有手势感；触摸设备去掉 */
@media (hover: none) {
  .btn-primary:active { transform: scale(.98); }
  .log-item:active, .recipe-item:active { background: var(--line-2); }
}

/* 打印（导出报告） */
@media print {
  .sidebar, .topbar, .scan-actions, .result-actions, .btn-primary, .btn-secondary { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}