/* ============ 看吃 App 样式 ============ */
:root {
  --bg: #F3F6F2;
  --card: #FFFFFF;
  --ink: #1B2733;
  --muted: #8A94A3;
  --line: #EDF0EC;
  --primary: #2F9E63;
  --primary-dark: #237A4C;
  --primary-soft: #E6F4EC;
  --kcal: #FF7A45;
  --carb: #E9A23B;
  --protein: #4C8DFF;
  --fat: #9B6BFF;
  --kcal-soft: #FFF0E8;
  --carb-soft: #FFF6E3;
  --protein-soft: #EBF2FF;
  --fat-soft: #F2ECFF;
  --danger: #E5484D;
  --radius: 20px;
  --shadow: 0 6px 24px rgba(31, 55, 43, 0.06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 72px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, #EAF3EC 0%, var(--bg) 220px);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img { max-width: 100%; display: block; }

.app { max-width: 520px; margin: 0 auto; padding: 0 16px calc(var(--tabbar-h) + var(--safe-bottom) + 16px); min-height: 100dvh; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 4px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-dot { width: 42px; height: 42px; object-fit: contain; flex: none; border-radius: 10px; -webkit-user-drag: none; }
.brand h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: 1px; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.mode-badge {
  font-size: 11px; color: var(--primary-dark); background: var(--primary-soft);
  padding: 4px 10px; border-radius: 999px; font-weight: 600;
  font-family: inherit; white-space: nowrap; max-width: 168px;
  overflow: hidden; text-overflow: ellipsis; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 14px;
}
h2 { margin: 0; font-size: 17px; }
.block-title { margin-bottom: 12px; }
.tip { font-size: 11px; color: var(--muted); text-align: center; margin: 12px 0 0; line-height: 1.5; }
#resultPanel { scroll-margin-top: 10px; }

/* ---------- 视图切换 ---------- */
.view { display: none; animation: fade .22s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 拍照区 ---------- */
.photo-card { padding: 22px 18px; }
.empty-state { width: 100%; text-align: center; padding: 26px 0 18px; }
#view-camera.idle .empty-state { display: flex; flex-direction: column; align-items: center; padding: 0; }
#view-camera.idle .photo-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: auto;
  padding: 10px 18px;
}
/* —— 快门按钮：相机快门质感 —— */
.shutter {
  position: relative;
  width: 156px;
  height: 156px;
  border-radius: 50%;
  margin: 0 auto;
  background:
    radial-gradient(circle at 32% 26%, rgba(168, 243, 197, .75) 0%, rgba(98, 226, 145, .75) 38%, rgba(50, 185, 107, .75) 78%, rgba(23, 118, 63, .75) 100%);
  box-shadow:
    0 0 0 12px rgba(255, 255, 255, .94),       /* 白色快门环 */
    0 0 0 13px rgba(17, 107, 255, .32),        /* 环外细描边 */
    0 16px 34px rgba(7, 62, 166, .40),         /* 投影 */
    inset 0 -8px 14px rgba(0, 0, 0, .20),      /* 底部内阴影：立体 */
    inset 0 5px 10px rgba(255, 255, 255, .40); /* 顶部高光 */
  transition: transform .15s ease, box-shadow .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.shutter:hover { transform: scale(1.03); }
.shutter:focus-visible { outline: none; box-shadow: 0 0 0 5px rgba(255,255,255,.94), 0 0 0 9px rgba(17,107,255,.48), 0 0 0 16px rgba(17,107,255,.22); }
.shutter:active {
  transform: scale(.92);
  box-shadow:
    0 0 0 12px rgba(255,255,255,.94),
    0 0 0 13px rgba(17,107,255,.22),
    0 8px 18px rgba(7, 62, 166, .32),
    inset 0 2px 8px rgba(0, 0, 0, .25);
}
/* 内圈：光圈环 + 高光 */
.shutter-ring {
  position: absolute;
  inset: 17px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .85);
  background:
    radial-gradient(circle at 32% 26%, rgba(255,255,255,.35) 0%, rgba(255,255,255,0) 58%),
    radial-gradient(circle at 68% 80%, rgba(0,0,0,.12) 0%, rgba(0,0,0,0) 60%);
}
/* 中心取景圆点 */
.shutter-ring::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 42px; height: 42px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, #FFFFFF 0%, #EAF1FF 42%, #C8DBFF 78%, #A6C4FF 100%);
  box-shadow:
    0 3px 8px rgba(7, 62, 166, .35),
    inset 0 -3px 6px rgba(7, 62, 166, .18);
}
.empty-title {
  margin: 0 0 40px;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--ink);
}
.empty-sub {
  margin: 0;
  font-size: 16px;
  color: var(--muted);
  line-height: 1.7;
}

#preview { width: 100%; border-radius: 14px; margin-bottom: 14px; background: #fff; }

.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.flex1 { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 14px; font-size: 15px; font-weight: 700;
  padding: 13px 16px; transition: transform .1s ease, opacity .15s ease;
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn.primary { background: linear-gradient(145deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: 0 8px 18px rgba(47,158,99,.28); }
.btn.ghost { background: #F1F4F0; color: var(--ink); }
.btn.secondary { background: var(--primary-soft); color: var(--primary-dark); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.big { width: 100%; padding: 15px; font-size: 16px; }
.btn.small { padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.btn.primary.small { box-shadow: none; }

/* ---------- 识别结果 ---------- */
.res-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.res-summary { margin: 6px 0 0; font-size: 13px; color: var(--muted); line-height: 1.6; }
.demo-badge {
  flex: none; font-size: 11px; color: #B45309; background: #FEF3C7;
  padding: 4px 9px; border-radius: 999px; font-weight: 700; white-space: nowrap;
}

/* ---------- 四大营养指标 ---------- */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.metric {
  border-radius: 14px; padding: 12px 6px 11px; text-align: center;
  background: var(--mc-soft, #F3F6F2);
}
.metric .m-ico { font-size: 18px; }
.metric .m-value { font-size: 20px; font-weight: 800; color: var(--mc, var(--ink)); margin-top: 2px; letter-spacing: -0.5px; }
.metric .m-value small { font-size: 11px; font-weight: 600; color: var(--muted); margin-left: 1px; }
.metric .m-label { font-size: 11px; color: var(--muted); margin-top: 3px; }
.metric[data-k="kcal"]   { --mc: var(--kcal);   --mc-soft: var(--kcal-soft); }
.metric[data-k="carbs"]  { --mc: var(--carb);   --mc-soft: var(--carb-soft); }
.metric[data-k="protein"]{ --mc: var(--protein);--mc-soft: var(--protein-soft); }
.metric[data-k="fat"]    { --mc: var(--fat);    --mc-soft: var(--fat-soft); }

/* ---------- 用餐类型 ---------- */
.meal-control { margin: 14px 0; padding: 13px; border-radius: 14px; background: #F7F9F6; }
.meal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.meal-head span { font-size: 13px; font-weight: 700; }
.meal-head small { color: var(--muted); font-size: 11px; }
.meal-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.meal-options button { padding: 8px 2px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.meal-options button.active { color: #0D4DB8; background: #E8F0FF; border-color: #116BFF; box-shadow: 0 0 0 2px rgba(17, 107, 255, .10); }

/* ---------- 实际食用份量：各项克重自动汇总 ---------- */
.result-total {
  min-height: 52px; padding: 9px 10px; display: flex; flex-direction: column; justify-content: center;
  border: 1px solid #DCE8DF; border-radius: 14px; background: #FBFCFA;
}
.result-total > span { color: var(--muted); font-size: 11px; font-weight: 600; }
.result-total strong { margin-top: 2px; color: var(--ink); font-size: 15px; }
.result-total small { margin-top: 2px; color: var(--muted); font-size: 10px; }

/* ---------- 结果页折叠抽屉 ---------- */
.result-folds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: 8px; margin: 14px 0; }
.result-fold {
  overflow: hidden; border: 1px solid var(--line); border-radius: 14px;
  background: #F7F9F6; transition: background .16s ease, border-color .16s ease;
}
.result-fold.open { background: #FBFCFA; border-color: #DCE8DF; }
.result-fold-head {
  width: 100%; min-height: 52px; padding: 9px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  text-align: left;
}
.result-fold-head:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.result-fold-title { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.result-fold-title > span { flex: none; color: var(--muted); font-size: 11px; font-weight: 600; }
.result-fold-title strong { max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--ink); }
.result-fold-chevron { flex: none; color: var(--muted); font-size: 17px; line-height: 1; transition: transform .16s ease; }
.result-fold.open .result-fold-chevron { transform: rotate(180deg); }
.result-fold-body { padding: 0 9px 10px; border-top: 1px solid var(--line); }
.result-fold-body .meal-options { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 9px; }

/* ---------- 识别结果修改意见 ---------- */
.revision-control { margin: 14px 0; padding: 13px; border-radius: 14px; background: #F7F9F6; }
.revision-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.revision-head label { font-size: 13px; font-weight: 700; }
.revision-head small { color: var(--muted); font-size: 11px; text-align: right; }
.revision-control textarea {
  width: 100%; min-height: 76px; box-sizing: border-box; resize: vertical;
  padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 11px;
  background: #fff; color: var(--ink); font: inherit; font-size: 14px; line-height: 1.5;
}
.revision-control textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 158, 99, .10); }
.revision-control .btn { margin-top: 9px; }
.revision-example { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.revision-notice {
  margin: 12px 0; padding: 10px 12px; border-radius: 11px;
  color: #8A4B08; background: #FFF4DD; border: 1px solid #F4D49A;
  font-size: 12px; line-height: 1.5; font-weight: 600;
}

/* ---------- 明细条目 ---------- */
.items-list, .entry-list { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.entry {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  background: #F7F9F6; border-radius: 14px; padding: 11px 12px;
}
.entry .e-main { flex: 1; min-width: 0; }
.entry .e-name { display: flex; align-items: baseline; min-width: 0; font-size: 14px; font-weight: 700; }
.entry .e-food { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .e-meal { flex: none; margin-left: 4px; color: var(--primary-dark); font-size: 12px; font-weight: 600; }
.entry .e-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.result-weight-row { display: flex; align-items: center; gap: 6px; margin-top: 7px; }
.result-weight-row > span { color: var(--muted); font-size: 11px; }
.weight-adjust { display: inline-flex; align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.weight-adjust button { width: 30px; height: 32px; color: var(--primary-dark); font-size: 17px; font-weight: 800; background: var(--primary-soft); }
.weight-adjust input {
  width: 52px; height: 32px; padding: 0 2px; border: 0; outline: none; background: #fff;
  color: var(--ink); font-size: 14px; font-weight: 800; text-align: center; font-family: inherit;
  -moz-appearance: textfield;
}
.weight-adjust input::-webkit-outer-spin-button,
.weight-adjust input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }
.weight-adjust input:focus { background: #F8FCF9; box-shadow: inset 0 0 0 2px rgba(47, 158, 99, .16); }
.weight-adjust > span { padding-right: 8px; color: var(--muted); font-size: 11px; }
.entry .e-nums { flex: none; text-align: right; font-size: 12px; color: var(--muted); line-height: 1.2; }
.entry .e-macros { flex: 0 0 100%; display: flex; flex-wrap: wrap; gap: 7px; padding-left: 62px; }
.entry .e-macro { --macro-color: var(--muted); --macro-soft: #F1F4F0; display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 5px 10px; border-radius: 999px; color: var(--macro-color); background: var(--macro-soft); font-size: 11px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.entry .e-macro b { color: var(--macro-color); font-size: 14px; }
.entry .e-macro[data-k="carbs"] { --macro-color: var(--carb); --macro-soft: var(--carb-soft); }
.entry .e-macro[data-k="protein"] { --macro-color: var(--protein); --macro-soft: var(--protein-soft); }
.entry .e-macro[data-k="fat"] { --macro-color: var(--fat); --macro-soft: var(--fat-soft); }
.entry .e-nums b { color: var(--kcal); font-size: 14px; }
.entry .del-btn {
  flex: none; width: 28px; height: 28px; border-radius: 9px; background: #FFF0EF;
  color: var(--danger); font-size: 15px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.entry-actions { flex: none; display: flex; gap: 5px; }
.entry .edit-btn {
  flex: none; width: 28px; height: 28px; border-radius: 9px; background: #EBF2FF;
  color: #356FD1; font-size: 15px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- 空状态 ---------- */
.list-empty { text-align: center; color: var(--muted); padding: 22px 0 10px; }
.list-empty p { margin: 0 0 6px; font-size: 14px; }
.list-empty .empty-sub { font-size: 12px; }

/* ---------- 记录 ---------- */
.day-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.record-date-btn {
  flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto; column-gap: 6px; text-align: left;
  padding: 9px 12px; border: 1px solid #F0D38A; border-radius: 14px;
  background: linear-gradient(135deg, #FFF8E5, #FFF1C7);
  box-shadow: 0 5px 16px rgba(174, 121, 0, .12);
}
.record-date-btn > span { grid-column: 1; grid-row: 1; color: #A16B00; font-size: 11px; font-weight: 700; }
.record-date-btn strong { grid-column: 1; grid-row: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #835500; font-size: 20px; }
.record-date-btn em { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: #B27A00; font-size: 17px; font-style: normal; }
.record-home-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.record-home-head h2 { margin: 0; font-size: 18px; }
.record-home-head p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.record-past-entry {
  width: 100%; margin-top: 14px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center; gap: 9px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 14px;
  background: #F7F9F6; text-align: left;
}
.record-past-entry > span { color: var(--muted); font-size: 12px; font-weight: 700; }
.record-past-entry strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: 14px; }
.record-past-entry em { color: #AAB2AB; font-size: 18px; font-style: normal; }
.record-today-highlight {
  padding: 14px; border: 1px solid #F0D38A; border-radius: 16px;
  background: linear-gradient(135deg, #FFF8E5, #FFF1C7);
  box-shadow: 0 5px 16px rgba(174, 121, 0, .12);
}
.record-home-card .record-today-highlight .today-overview { margin-top: 12px; }
.record-home-section-title { margin: 0; color: #835500; font-size: 16px; }
.record-home-divider { height: 1px; margin: 16px 0 12px; background: var(--line); }
.record-home-list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.record-home-list-head h3 { margin: 0; font-size: 16px; }
.record-home-list-head span { color: var(--muted); font-size: 11px; }
.record-home-card .entry-list { margin: 0; }
.record-launch-btn { width: 100%; }
.record-shoot-btn { flex: none; margin: 0; padding: 8px 12px; }
.record-delete-day { margin-top: 12px; color: var(--danger); background: #FFF0EF; }

.ai-chat-panel.record-detail-panel { top: 7dvh; }
.record-detail-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px calc(18px + var(--safe-bottom)); }
.record-detail-date { width: 100%; }
.record-detail-overview { margin: 14px 0 18px; }
.record-detail-list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 2px 0 10px; }
.record-detail-list-head h3 { margin: 0; font-size: 17px; }
.record-detail-list-head span { color: var(--muted); font-size: 11px; }
.record-detail-loading { padding: 30px 0 20px; }
.date-picker-mark {
  flex: none; width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 13px; background: #FFF3D6; font-size: 20px;
}
.record-calendar-mask {
  position: absolute; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center;
  padding: 18px; background: rgba(20, 28, 24, .34); animation: fadeIn .16s ease;
}
.record-calendar-card {
  width: min(100%, 360px); padding: 18px 16px 14px; border-radius: 24px; background: #fff;
  box-shadow: 0 20px 50px rgba(18, 31, 23, .24); animation: popIn .18s ease;
}
.record-calendar-head { display: grid; grid-template-columns: 38px 1fr 38px; align-items: center; gap: 8px; margin-bottom: 14px; }
.record-calendar-head strong { text-align: center; color: var(--ink); font-size: 17px; }
.record-calendar-head button {
  width: 38px; height: 38px; border-radius: 13px; background: #F3F6F2;
  color: var(--primary-dark); font-size: 21px; font-weight: 800;
}
.record-calendar-head button:disabled { color: #C8D0C9; background: #F7F8F6; }
.record-calendar-week, .record-calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.record-calendar-week { margin-bottom: 6px; }
.record-calendar-week span { color: var(--muted); font-size: 11px; font-weight: 700; text-align: center; }
.record-calendar-cell {
  width: 100%; aspect-ratio: 1; display: grid; place-items: center; border-radius: 12px;
  color: var(--ink); background: #F7F9F6; font-size: 13px; font-weight: 700;
}
.record-calendar-cell.today { box-shadow: inset 0 0 0 1.5px var(--primary); color: var(--primary-dark); }
.record-calendar-cell.selected { color: #fff; background: linear-gradient(145deg, var(--primary), var(--primary-dark)); box-shadow: 0 5px 13px rgba(47, 158, 99, .24); }
.record-calendar-cell:disabled { color: #C7CEC8; background: #FAFBF9; }
.record-calendar-cell.blank { background: transparent; }
.record-calendar-close { margin-top: 12px; padding: 10px; }

/* ---------- 底部标签栏 ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: 520px;
  display: flex; background: rgba(255, 255, 255, .92); backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 10px calc(6px + var(--safe-bottom));
  z-index: 40;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 0; font-size: 11px; color: var(--muted); border-radius: 12px;
  transition: color .15s ease;
}
.tab .tab-ico { font-size: 21px; filter: grayscale(1) opacity(.55); transition: filter .15s ease, transform .12s ease; }
.tab.active { color: var(--primary-dark); font-weight: 700; }
.tab.active .tab-ico { filter: none; transform: translateY(-1px); }

/* ---------- 弹出层 ---------- */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(20, 28, 24, .42);
  display: flex; align-items: flex-end; justify-content: center; z-index: 60;
  animation: fadeIn .18s ease;
}
.sheet-mask.hidden { display: none; }
.sheet {
  width: 100%; max-width: 520px; max-height: 82dvh; overflow-y: auto;
  background: #fff; border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(18px + var(--safe-bottom));
  animation: slideUp .22s ease;
}
.modal {
  width: 86%; max-width: 340px; background: #fff; border-radius: 18px;
  padding: 22px 18px 18px; margin: 0 auto auto;
  animation: popIn .18s ease;
}
.sheet-mask.modal-mask { align-items: center; }
.modal-text { margin: 0 0 18px; font-size: 15px; line-height: 1.7; text-align: center; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-close { width: 32px; height: 32px; border-radius: 50%; background: #F1F4F0; color: var(--muted); font-size: 14px; }
.sheet .metric-grid { margin-bottom: 14px; }
.sheet .entry { background: #fff; border: 1px solid var(--line); }
@keyframes slideUp { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 加载状态 ---------- */
.spinner-wrap { text-align: center; padding: 18px 0 8px; }
.spinner {
  width: 40px; height: 40px; border-radius: 50%; margin: 0 auto 12px;
  border: 4px solid var(--primary-soft); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 14px; color: var(--muted); text-align: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translate(-50%, 8px); bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 18px);
  background: rgba(27, 39, 51, .94); color: #fff; font-size: 13px;
  padding: 10px 18px; border-radius: 999px; z-index: 90; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; max-width: 86%; text-align: center;
  box-shadow: 0 8px 20px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: rgba(47, 158, 99, .96); }
.toast.err { background: rgba(229, 72, 77, .96); }

.hidden { display: none !important; }

@media (min-width: 560px) {
  body { background: #EDF2EC; }
  .tabbar, .sheet { border-radius: 18px 18px 0 0; }
}

/* ---------- 登录 / 注册 ---------- */
.auth-screen {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 28px) 16px calc(env(safe-area-inset-bottom, 0px) + 30px);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 18px 22px;
}
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand img { width: 62px; height: 62px; object-fit: contain; margin: 0 auto 8px; }
.auth-brand h1 { margin: 0; font-size: 28px; font-weight: 800; color: var(--ink); }
.auth-brand p { margin: 8px 0 0; font-size: 13px; color: var(--muted); line-height: 1.6; }
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #F0F4F0;
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 16px;
}
.auth-tab {
  padding: 10px 8px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}
.auth-tab.active { background: #fff; color: var(--primary-dark); box-shadow: 0 2px 8px rgba(30, 62, 45, .08); }
.auth-switch {
  margin: 14px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.auth-switch button { color: var(--primary-dark); font-weight: 700; padding: 2px; }
.auth-assist { margin: -2px 0 13px; text-align: right; }
.auth-assist button { color: var(--primary-dark); font-size: 12px; font-weight: 700; padding: 3px 2px; }
.auth-reset-lead {
  margin: 0 0 16px;
  padding: 11px 12px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 13px;
  line-height: 1.65;
}
.auth-reset-help { margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; text-align: center; }
.req { color: var(--danger); font-style: normal; font-weight: 700; }
.api-key-box {
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid #F2CBCA;
  background: #FFF9F8;
  border-radius: 12px;
}
.api-key-box .field { margin-bottom: 8px; }
.reg-key-help { margin: 0 0 8px; font-size: 12px; line-height: 1.5; color: var(--danger); }
.key-guide-btn {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #F5C6C5;
  border-radius: 10px;
  background: #FFF0EF;
  font-size: 13px;
  font-weight: 700;
  color: var(--danger);
  text-align: center;
}
.register-limit {
  margin: 12px 0 10px;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  color: var(--muted);
  background: #FFF8E8;
  border: 1px solid #F4E3B6;
  border-radius: 10px;
  padding: 8px 10px;
}
.auth-msg { margin-top: 12px; font-size: 13px; line-height: 1.6; min-height: 18px; text-align: center; }
.auth-msg.err { color: var(--danger); }
.auth-msg.ok { color: var(--primary-dark); }

/* ---------- API Key 获取引导 ---------- */
.key-guide-lead { margin: 0 0 14px; font-size: 14px; color: var(--muted); line-height: 1.7; }
.key-guide-steps {
  margin: 0 0 16px;
  padding-left: 22px;
  font-size: 14px;
  line-height: 1.9;
  color: var(--ink);
}
.key-guide-steps li { margin-bottom: 12px; }
.key-guide-steps b { color: var(--primary-dark); }
.key-guide-step-title {
  display: inline-block;
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.5;
}
.key-guide-figure {
  margin: 8px 0 14px;
  padding: 8px;
  background: #EDF1ED;
  border: 1px solid #DCE3DC;
  border-radius: 10px;
}
.key-guide-step-image {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  border-radius: 6px;
  background: #fff;
  object-fit: contain;
}
.key-guide-warning {
  margin: 0 0 14px;
  padding: 11px 12px;
  background: #FFF0EF;
  border: 1px solid #F5C6C5;
  border-radius: 12px;
  color: var(--danger);
}
.key-guide-warning strong { display: block; font-size: 13px; margin-bottom: 5px; }
.key-guide-warning .key-guide-emphasis {
  margin: 8px 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.6;
}
.key-guide-warning ul { margin: 0; padding-left: 18px; font-size: 12px; line-height: 1.7; }
.key-guide-link { text-decoration: none; margin-bottom: 10px; }

/* ---------- 账号信息 ---------- */
.account-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.account-head > div { flex: 1; min-width: 0; }
.account-info { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.account-info b { color: var(--ink); font-size: 14px; }
.account-actions { margin-top: 10px; align-items: center; }
.account-actions .account-hint { flex: 1; }

/* ---------- 设置页 ---------- */
.form-tip { margin: 0 0 14px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.form-tip b { color: var(--primary-dark); }
.field { display: block; margin-bottom: 12px; text-align: left; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input {
  width: 100%; padding: 11px 12px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #FBFCFA;
  font-size: 14px; color: var(--ink); font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--primary); background: #fff; }
.keyrow { display: flex; gap: 8px; }
.keyrow input { flex: 1; min-width: 0; }
.mini-btn {
  flex: none; padding: 0 12px; border-radius: 12px; font-size: 13px;
  background: #F1F4F0; color: var(--ink); font-weight: 600;
}
.cfg-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; min-height: 20px; }
.cfg-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 6px 12px; border-radius: 999px; font-weight: 600;
}
.cfg-chip.on { background: var(--primary-soft); color: var(--primary-dark); }
.cfg-chip.off { background: #FFF0E8; color: #C2410C; }
.cfg-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
#cfgMsg { margin-top: 10px; font-size: 13px; line-height: 1.7; word-break: break-all; }
#cfgMsg.ok { color: var(--primary-dark); }
#cfgMsg.err { color: var(--danger); }
.cfg-loading { color: var(--muted); }

/* ---------- 记录照片缩略图 / 查看器 ---------- */
.entry .thumb { flex: none; width: 52px; height: 52px; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; }
.entry-photo { width: 52px; height: 52px; border-radius: 11px; object-fit: cover; background: #EDF0EC; display: block; }
.viewer { position: relative; max-width: 94%; display: flex; align-items: center; justify-content: center; }
.viewer img { display: block; max-width: 100%; max-height: 82dvh; border-radius: 16px; background: #111; }
.viewer-close {
  position: absolute; top: -16px; right: -16px; width: 38px; height: 38px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; font-size: 15px; backdrop-filter: blur(4px);
}

/* —— 自定义快门图片：把图片命名为 shutter.png 放到 public/ 根目录即可生效 ——
   未提供图片时 img 保持隐藏，自动回退到上方默认设计 */
.shutter-art {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 50%;
  height: 50%;
  transform: translate(-50%, -50%);
  /* 取消圆形遮罩与裁切，保留图片完整 */
  object-fit: contain;
  -webkit-user-drag: none;
}
.shutter-art.show { display: block; }
.shutter.has-art .shutter-ring { display: none; }
.shutter.has-art { box-shadow: 0 0 0 12px rgba(255,255,255,.94), 0 18px 38px rgba(7,62,166,.38); }

/* —— 环外虚线细描边（缓慢转动）—— */
.shutter-dash {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 180px;
  height: 180px;
  margin-left: -90px;
  margin-top: -90px;
  border-radius: 50%;
  border: 1px dashed rgba(17, 107, 255, .78); /* 与按钮背景同色系（蓝色） */
  pointer-events: none;
  animation: shutterDashSpin 56s linear infinite; /* 转速为原速的 25% */
}
.shutter.has-art .shutter-dash { display: block; }
@keyframes shutterDashSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* —— 左上角“看吃”入口 / 返回链接 —— */
.brand-link {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 4px 8px;
  margin: -4px -8px;
  cursor: pointer;
  border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
}
.brand-link:active { opacity: .6; }
.back-link {
  display: inline-block;
  font: inherit;
  font-size: 14px;
  color: var(--primary-dark);
  background: none;
  border: none;
  padding: 2px 0 10px;
  cursor: pointer;
}
.back-link:active { opacity: .6; }

/* —— 相册选择按钮 —— */
.album-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  padding: 9px 20px;
  border-radius: 999px;
  background: #F0F3EF;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid #E3E8E2;
  -webkit-tap-highlight-color: transparent;
  transition: transform .1s ease, background .15s ease;
}
.album-btn:active { transform: scale(.96); background: #E5EAE4; }



.plan-personal-card { padding: 0; overflow: hidden; }
.plan-personal-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px; text-align: left; }
.plan-personal-copy { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.plan-personal-title { color: var(--ink); font-size: 17px; font-weight: 800; line-height: 1.2; }
.plan-personal-summary { overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.plan-personal-action { flex: none; color: var(--primary-dark); font-size: 12px; font-weight: 700; white-space: nowrap; }
.plan-personal-chevron { display: inline-block; transition: transform .2s ease; }
.plan-personal-toggle[aria-expanded="true"] .plan-personal-chevron { transform: rotate(180deg); }
.plan-personal-body { padding: 16px 18px 18px; border-top: 1px solid var(--line); }
.plan-seg { display: flex; gap: 10px; }
.plan-seg-btn {
  flex: 1; padding: 13px 0; border-radius: 14px; font-size: 15px; font-weight: 700;
  background: #F1F4F0; color: var(--muted); border: 1.5px solid transparent;
  transition: all .15s ease; -webkit-tap-highlight-color: transparent;
}
.plan-seg-btn.active {
  background: var(--primary-soft); color: var(--primary-dark); border-color: var(--primary);
}
.plan-seg-btn:active { transform: scale(.97); }







.plan-note { font-size: 11px; color: var(--muted); margin: 10px 0 0; text-align: center; }
.metric-grid.plan-grid { grid-template-columns: repeat(3, 1fr); }

/* ---------- 计划页（紧凑版） ---------- */
.plan-seg { display: flex; gap: 8px; margin-bottom: 14px; }
.plan-row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.plan-cell { display: flex; flex-direction: column; gap: 6px; min-width: 0; text-align: left; }
.plan-cell-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.plan-cell input, .plan-hrs-trigger {
  width: 100%; padding: 10px 6px; border-radius: 11px; border: 1.5px solid var(--line);
  background: #FBFCFA; font-size: 14px; text-align: center; color: var(--ink);
  font-family: inherit; box-sizing: border-box; -webkit-tap-highlight-color: transparent;
}
.plan-cell input:focus { outline: none; border-color: var(--primary); background: #fff; }
.plan-hrs-trigger { cursor: pointer; }
.plan-hrs-trigger.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; }
.plan-hrs-panel { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.plan-hrs-panel button {
  text-align: left; padding: 11px 13px; border-radius: 11px; font-size: 14px; color: var(--ink);
  background: #FBFCFA; border: 1.5px solid var(--line); font-family: inherit; -webkit-tap-highlight-color: transparent;
}
.plan-hrs-panel button.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; }

/* 计划可视化 */
.plan-vis { margin-top: 16px; }
.plan-bar { display: flex; height: 16px; border-radius: 999px; overflow: hidden; background: #F0F3EF; margin-bottom: 10px; }
.plan-bar .seg { display: block; height: 100%; min-width: 0; transition: width .6s ease; }
.plan-bar .seg.carb { background: var(--carb, #E9A23B); }
.plan-bar .seg.protein { background: var(--protein, #4C8DFF); }
.plan-bar .seg.fat { background: var(--fat, #9B6BFF); }
.plan-legend { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.plan-legend b { color: var(--ink); font-weight: 700; }


/* ---------- 早中晚饮食推荐 ---------- */
.meal-recommend-card { position: relative; overflow: hidden; border: 1px solid rgba(47, 158, 99, .14); }
.meal-recommend-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%); }
.meal-plan-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.meal-plan-head .block-title { margin-bottom: 4px; color: var(--primary-dark); }
.meal-plan-subtitle { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.meal-plan-badge { flex: none; margin-top: 2px; padding: 4px 9px; border-radius: 999px; color: var(--primary-dark); background: var(--primary-soft); font-size: 11px; font-weight: 700; }
.meal-plan-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; margin: 14px 0; border-radius: 15px; background: #F1F4F0; }
.meal-plan-tabs button { min-width: 0; padding: 9px 4px; border-radius: 11px; color: var(--muted); font-size: 13px; font-weight: 700; white-space: nowrap; transition: background .15s ease, color .15s ease, box-shadow .15s ease; }
.meal-plan-tabs button small { font-size: 10px; font-weight: 600; opacity: .75; }
.meal-plan-tabs button.active { color: var(--primary-dark); background: #fff; box-shadow: 0 2px 8px rgba(31, 55, 43, .08); }
.meal-recommend-detail { padding: 14px; border: 1.5px solid #DCEFE1; border-radius: 17px; background: linear-gradient(150deg, #FBFDFB 0%, #EDF8F0 100%); }
.meal-reco-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.meal-reco-eyebrow { margin: 0 0 4px; color: var(--primary-dark); font-size: 11px; font-weight: 800; }
.meal-reco-top h3 { margin: 0; font-size: 17px; line-height: 1.3; }
.meal-reco-refresh { flex: none; padding: 7px 10px; border: 1px solid #D9E8DE; border-radius: 10px; color: var(--primary-dark); background: #fff; font-size: 12px; font-weight: 700; }
.meal-reco-refresh:active { transform: scale(.97); }
.meal-target-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 13px 0 11px; }
.meal-target { padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.meal-target b { margin-left: 2px; font-size: 12px; }
.meal-target.carbs { color: var(--carb); background: var(--carb-soft); }
.meal-target.protein { color: var(--protein); background: var(--protein-soft); }
.meal-target.fat { color: var(--fat); background: var(--fat-soft); }
.meal-food-list { display: flex; flex-direction: column; gap: 7px; padding: 3px; overflow: visible; border-radius: 19px; background: rgba(226, 241, 231, .72); }
.meal-food-item:focus-within { z-index: 20; }
.meal-food-item { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid #E1F0E5; border-radius: 15px; background: rgba(255, 255, 255, .94); font-size: 13px; }
.meal-food-item span { display: flex; align-items: center; gap: 8px; color: #526059; }
.meal-food-item span::before { content: ""; width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px rgba(47, 158, 99, .10); }
.meal-food-item b { color: var(--ink); font-size: 13px; white-space: nowrap; }
.meal-reco-foot { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin-top: 11px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.meal-reco-foot strong { color: var(--primary-dark); font-size: 15px; }
.meal-macro-row { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 5px 12px; margin-top: 2px; }
.meal-macro { font-weight: 700; }
.meal-macro[data-k="carbs"], .meal-gap-item[data-k="carbs"], .meal-food-name small[data-category="carb"] { color: var(--carb); }
.meal-macro[data-k="protein"], .meal-gap-item[data-k="protein"], .meal-food-name small[data-category="protein"] { color: var(--protein); }
.meal-macro[data-k="fat"], .meal-gap-item[data-k="fat"], .meal-food-name small[data-category="fat"] { color: var(--fat); }
.meal-macro b, .meal-gap-item b { color: inherit; font-weight: 800; }
.meal-food-name { min-width: 0; align-items: flex-start !important; flex-direction: column; gap: 2px !important; }
.meal-food-name::before { margin-top: 5px; }
.meal-food-name b { white-space: normal; }
.meal-food-picker { position: relative; min-width: 0; max-width: 220px; }
.meal-food-select { display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 126px; max-width: 220px; padding: 6px 10px; border: 1px solid #CFE5D7; border-radius: 12px; background: #fff; color: var(--ink); font: 700 13px/1.3 inherit; cursor: pointer; }
.meal-food-select span { display: block; min-width: 0; overflow: hidden; color: inherit !important; text-overflow: ellipsis; white-space: nowrap; }
.meal-food-select span::before { display: none; }
.meal-food-select i { flex: none; color: var(--primary-dark); font-style: normal; }
.meal-food-select[aria-expanded="true"] { border-color: var(--primary); background: var(--primary-soft); }
.meal-food-menu { position: absolute; z-index: 40; top: calc(100% + 7px); left: 50%; width: max-content; min-width: 170px; max-width: 240px; max-height: 270px; padding: 6px; overflow: auto; transform: translateX(-50%); border: 1px solid #D9E8DE; border-radius: 17px; background: #fff; box-shadow: 0 14px 34px rgba(31, 55, 43, .18); }
.meal-food-option { display: block; width: 100%; padding: 9px 13px; border-radius: 11px; background: transparent; color: var(--ink); text-align: center; white-space: nowrap; font: 600 13px/1.3 inherit; cursor: pointer; }
.meal-food-option:hover, .meal-food-option.active { color: var(--primary-dark); background: var(--primary-soft); font-weight: 800; }
.meal-food-select:focus-visible { outline: 2px solid rgba(47,158,99,.18); outline-offset: 1px; border-color: var(--primary); }
.meal-food-name small { color: var(--muted); font-size: 10px; }
.meal-food-amount { flex: none; display: inline-flex; align-items: center; gap: 3px; padding: 4px 7px; border-radius: 9px; background: #F1F7F3; color: var(--muted); font-size: 11px; }
.meal-food-amount input { width: 52px; padding: 3px 2px; border: 0; border-bottom: 1px solid #97C9A8; outline: none; background: transparent; color: var(--ink); text-align: right; font: 700 13px/1.2 inherit; }
.meal-food-amount span::before { display: none; }
.meal-plan-gap { display: flex; flex-wrap: wrap; gap: 3px 10px; margin-top: 7px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.meal-reco-loading, .meal-reco-empty { display: flex; min-height: 86px; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 13px; text-align: center; }
.meal-reco-loading { flex-direction: column; }
.meal-reco-empty { margin: 0; }
.goal-rows { display: flex; flex-direction: column; gap: 14px; }
.goal-row { --macro-soft: #F7F9F6; padding: 11px 12px; border-radius: 14px; background: var(--macro-soft); }
.goal-row[data-k="carbs"] { --macro-soft: var(--carb-soft); }
.goal-row[data-k="protein"] { --macro-soft: var(--protein-soft); }
.goal-row[data-k="fat"] { --macro-soft: var(--fat-soft); }
.goal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 13px; }








/* 今日精简版 */
.today-overview { }
.today-kcal-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.today-kcal { display: inline-flex; align-items: baseline; gap: 2px; }
.today-kcal b { font-size: 38px; font-weight: 800; color: var(--kcal, #FF7A45); letter-spacing: -1px; line-height: 1; }
.today-kcal em { font-style: normal; font-size: 13px; color: var(--muted); margin-left: 4px; }
.goal-set-btn {
  padding: 7px 14px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #F1F4F0; color: var(--ink); -webkit-tap-highlight-color: transparent;
}
.goal-set-btn:active { transform: scale(.96); }
.macro-inline { font-size: 13px; color: var(--muted); line-height: 1.8; padding: 4px 0 2px; }
.macro-inline b { color: var(--ink); }

.goal-rows { display: flex; flex-direction: column; gap: 12px; }
.goal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; font-size: 13px; }
.goal-name { font-weight: 700; color: var(--ink); }
.goal-right { display: flex; align-items: center; gap: 8px; }


.goal-over { font-size: 11px; color: #fff; padding: 2px 9px; border-radius: 999px; font-weight: 700; }
.goal-track { height: 13px; border-radius: 999px; background: #F0F3EF; overflow: hidden; }
.goal-fill { height: 100%; border-radius: 999px; transition: width .5s ease; }

/* 今日指标：清晰放大 + 主题色 */
.goal-rows { gap: 15px; }
.goal-head { margin-bottom: 7px; }
.goal-name { font-size: 16px; font-weight: 800; }
.goal-right { display: flex; align-items: baseline; gap: 8px; }
.goal-cur { font-size: 26px; font-weight: 800; line-height: 1; letter-spacing: -0.5px; }
.goal-unit { font-size: 13px; color: var(--muted); margin-left: 1px; font-weight: 600; }
.goal-tgt { font-size: 14px; color: var(--muted); font-weight: 600; }
.goal-tgt b { font-weight: 800; color: var(--ink); }
.goal-over { font-size: 12px; padding: 3px 10px; }
.goal-track { height: 15px; }
.macro-inline { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; font-size: 15px; font-weight: 600; padding: 4px 0 2px; }
.macro-inline b { font-size: 21px; font-weight: 800; }
.macro-inline .macro-pill { padding: 5px 9px; border-radius: 999px; line-height: 1.2; }
.macro-inline .macro-pill[data-k="carbs"] { background: var(--carb-soft); }
.macro-inline .macro-pill[data-k="protein"] { background: var(--protein-soft); }
.macro-inline .macro-pill[data-k="fat"] { background: var(--fat-soft); }
.macro-inline .mi-sep { color: var(--line); font-size: 14px; }
/* 拍照页顶部横向照片展示区 */
.photo-showcase {
  display: flex;
  gap: 10px;
  padding: 10px;
  height: 128px;
  box-sizing: border-box;
  background: rgba(255, 255, 255, .6);
  border: 1.5px dashed rgba(47, 158, 99, .25);
  border-radius: 18px;
  overflow-x: auto;
  margin-bottom: 14px;
  scrollbar-width: none;
}
.photo-showcase::-webkit-scrollbar { display: none; }


/* 单个照片展示位：加高 + 占满宽度 */
.photo-showcase { height: 210px; }


/* 照片展示位：直接放图片 */
.photo-showcase { padding: 0; background: none; border: none; overflow: hidden; }
.ps-img { width: 100%; height: 100%; object-fit: cover; object-position: 15% center; border-radius: 18px; display: block; }

/* 图片在展示框内上移 100px（像素位移方式） */
.photo-showcase { position: relative; overflow: hidden; }
.ps-img {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: auto;           /* 保持原图比例，超高部分被框裁掉 */
  object-fit: initial;
  object-position: initial;
  transform: translateY(-100px);  /* 默认图显示窗口下移（想看的内容更靠下） */
  border-radius: 18px;
  display: block;
}
/* 展示图裁切编辑器 */
.photo-editor { width: min(94vw, 560px); background: #fff; border-radius: 18px; padding: 18px; }
.photo-editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.photo-editor-head h3 { margin: 0; font-size: 17px; }
.crop-stage {
  position: relative; width: 100%; aspect-ratio: 16 / 11; border-radius: 14px;
  overflow: hidden; background: #E8ECE8; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
}
.crop-stage.dragging { cursor: grabbing; }
.crop-stage img { position: absolute; left: 0; top: 0; max-width: none; user-select: none; pointer-events: none; }
.crop-controls { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; }
.crop-controls input[type=range] { flex: 1; min-width: 0; }
.crop-hint { font-size: 12px; color: var(--muted); line-height: 1.6; margin: 8px 0 14px; }

/* 自定义展示图：与编辑框完全一致地铺满 */
.photo-showcase.custom .ps-img {
  position: absolute; left: 0; top: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center;
  transform: none;
  border-radius: 18px; display: block;
}

/* 统一比例 16:7：主页展示框与编辑框一致 */
.photo-showcase { height: auto; aspect-ratio: 16 / 11; }
.crop-stage { aspect-ratio: 16 / 11; }

/* 扫描/分析时隐藏顶部展示图，保持分析框架 */
#view-camera:not(.idle) .photo-showcase { display: none; }


/* 贴住内容列边缘 + 彻底去圆角（含自定义图） */
.photo-showcase {
  width: 100%;
  margin-left: 0;
  margin-right: 0;
}
.photo-showcase,
.photo-showcase .ps-img,
.photo-showcase.custom .ps-img {
  border-radius: 0 !important;
}

/* 顶部展示图：宽度铺满屏幕（圆角保持 0） */
.photo-showcase {
  width: auto;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

/* 顶部展示图：只贴住内容列边缘（圆角 0 保留） */
.photo-showcase {
  width: 100%;
  margin-left: 0;
  margin-right: 0;
}

.account-hint { font-size: 12px; color: var(--muted); }
#passwordMask { align-items: center; justify-content: center; padding: 20px; }
#passwordMask .modal { margin: 0; width: min(92vw, 380px); }
.password-modal h3 { margin: 0; font-size: 18px; text-align: center; }
.password-modal-tip { margin: 7px 0 16px; color: var(--muted); font-size: 12px; line-height: 1.6; text-align: center; }
.password-modal .field { margin-bottom: 11px; }
.modal-msg { min-height: 17px; margin: 3px 0 10px; color: var(--muted); font-size: 12px; line-height: 1.5; text-align: center; }
.modal-msg.err { color: var(--danger); }
.input-modal-field {
  width: 100%; padding: 12px 13px; border-radius: 12px; margin-bottom: 16px;
  border: 1.5px solid var(--line); background: #FBFCFA; font-size: 16px; color: var(--ink);
  font-family: inherit; box-sizing: border-box;
}
.input-modal-field:focus { outline: none; border-color: var(--primary); background: #fff; }

/* 输入弹窗：全局垂直+水平居中 */
#inputModalMask {
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#inputModalMask .modal {
  margin: 0;
  width: min(86vw, 340px);
}
/* 删除确认弹窗：全局居中 */
#modalMask { align-items: center; justify-content: center; padding: 20px; }
#modalMask .modal { margin: 0; }

/* 营养数据修改弹窗：全局居中 */
#editNutrientsMask { align-items: center; justify-content: center; padding: 20px; }
#editNutrientsMask .modal { margin: 0; width: min(92vw, 390px); }
.nutrients-modal h3 { margin: 0; font-size: 18px; text-align: center; }
.modal-food-name { margin: 7px 0 15px; text-align: center; color: var(--muted); font-size: 13px; }
.nutrients-edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.nutrients-edit-grid label { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.nutrients-edit-grid span { font-size: 12px; color: var(--muted); }
.nutrients-edit-grid input {
  width: 100%; min-width: 0; padding: 11px 10px; border-radius: 11px; border: 1.5px solid var(--line);
  background: #FBFCFA; color: var(--ink); font-size: 16px; font-family: inherit; box-sizing: border-box;
}
.nutrients-edit-grid input:focus { outline: none; border-color: var(--primary); background: #fff; }

/* 默认展示图（GIF）：完整铺满、取消旧位移 */
.photo-showcase:not(.custom) .ps-img {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center;
  transform: none;
}

/* ============ AI 键盘输入与对话面板 ============ */
.camera-input-dock {
  width: 100%;
  min-height: 66px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(157, 105, 0, .13);
  border-radius: 20px;
  background: #F3BE4E;
  box-shadow: 0 10px 24px rgba(166, 107, 0, .22);
}
.keyboard-input-icon {
  width: 25px;
  height: 25px;
  display: block;
  color: #111;
}
.camera-input-dock:active { transform: scale(.992); }
.keyboard-input-btn {
  position: relative;
  z-index: 2;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #F6DDA5;
  color: #3D2B00;
  box-shadow: inset 0 0 0 1px rgba(157, 105, 0, .08);
  font-size: 24px;
  line-height: 1;
  transition: transform .14s ease, background .14s ease, box-shadow .14s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.keyboard-input-btn:active {
  transform: scale(.95);
  background: #E8AE32;
}
.keyboard-input-btn:focus-visible,
.ai-chat-history-btn:focus-visible,
.ai-chat-new-btn:focus-visible,
.ai-chat-history-open:focus-visible,
.ai-chat-history-del:focus-visible,
.ai-chat-close:focus-visible,
.ai-chat-send:focus-visible {
  outline: 3px solid rgba(47, 158, 99, .32);
  outline-offset: 2px;
}
.ai-chat-mask {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  z-index: 60;
  background: rgba(8, 13, 10, .46);
  animation: fadeIn .18s ease;
}
.ai-chat-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  top: 42dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 -18px 48px rgba(7, 25, 15, .22);
  animation: aiPanelIn .24s cubic-bezier(.22, .8, .32, 1);
}
@keyframes aiPanelIn {
  from { transform: translateY(38px); opacity: .75; }
  to { transform: translateY(0); opacity: 1; }
}
.ai-chat-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.ai-chat-titlewrap { display: flex; align-items: center; gap: 11px; min-width: 0; }
.ai-chat-mark {
  flex: none;
  width: 40px;
  height: 40px;
  display: block;
  object-fit: contain;
  background: transparent;
}
.ai-chat-head h3 { margin: 0; font-size: 17px; line-height: 1.2; }
.ai-chat-head p { margin: 3px 0 0; font-size: 11px; color: var(--muted); }
.ai-chat-close {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: #F2F4F1;
  color: #667064;
  font-size: 15px;
}
.ai-chat-actions { flex: none; display: flex; align-items: center; gap: 8px; }
.ai-chat-history-btn {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: #FFF3D6;
  color: #775400;
  font-size: 17px;
  font-weight: 800;
}
.ai-chat-history-backdrop {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: rgba(20, 28, 24, .28);
  animation: fadeIn .16s ease;
}
.ai-chat-history-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  width: min(84%, 320px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 24px 0 0 24px;
  box-shadow: 14px 0 34px rgba(18, 31, 23, .16);
  transform: translateX(-102%);
  transition: transform .22s cubic-bezier(.22, .8, .32, 1);
}
.ai-chat-history-panel.open { transform: translateX(0); }
.ai-chat-history-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--line);
}
.ai-chat-history-head h3 { margin: 0; font-size: 16px; }
.ai-chat-history-head p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.ai-chat-new-btn {
  flex: none;
  padding: 8px 10px;
  border-radius: 11px;
  background: #F3BE4E;
  color: #3D2B00;
  font-size: 12px;
  font-weight: 800;
}
.ai-chat-history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-chat-history-empty {
  margin: auto;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  line-height: 1.7;
}
.ai-chat-history-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 14px;
  background: #F7F9F6;
}
.ai-chat-history-open {
  flex: 1;
  min-width: 0;
  padding: 8px 9px;
  border-radius: 10px;
  text-align: left;
}
.ai-chat-history-open b {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-chat-history-open span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.ai-chat-history-del {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #FFF0EF;
  color: var(--danger);
  font-size: 14px;
}
.ai-delete-mask {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(14, 21, 17, .42);
}
.ai-delete-modal {
  width: min(86%, 320px);
  padding: 20px 18px 16px;
  border-radius: 18px;
  background: #fff;
  text-align: center;
  box-shadow: 0 18px 44px rgba(7, 20, 12, .24);
  animation: popIn .18s ease;
}
.ai-delete-modal h3 { margin: 0 0 8px; font-size: 18px; }
.ai-delete-modal p { margin: 0 0 17px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.ai-delete-actions { display: flex; gap: 10px; }
.ai-chat-notice {
  flex: none;
  margin: 10px 16px 0;
  padding: 9px 11px;
  border-radius: 12px;
  background: #FFF6DD;
  color: #775400;
  font-size: 12px;
  line-height: 1.55;
}
.ai-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}
.ai-chat-welcome {
  margin: auto 0;
  padding: 18px 16px;
  border-radius: 18px;
  background: #F7F9F6;
  color: #5C665C;
  text-align: center;
  font-size: 13px;
  line-height: 1.7;
}
.ai-chat-welcome b { color: var(--ink); }
.ai-msg.row { display: flex; }
.ai-msg.row.user { justify-content: flex-end; }
.ai-msg.row.assistant { justify-content: flex-start; }
.ai-msg-bubble {
  max-width: min(86%, 420px);
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-msg.row.user .ai-msg-bubble {
  background: #F3BE4E;
  color: #3D2B00;
  border-bottom-right-radius: 6px;
}
.ai-msg.row.assistant .ai-msg-bubble {
  background: #F3F6F2;
  color: var(--ink);
  border-bottom-left-radius: 6px;
}
.ai-msg.row.error .ai-msg-bubble {
  background: #FFF0EF;
  color: #B72D34;
}
.ai-msg.loading .ai-msg-bubble {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.ai-typing-dots { display: inline-flex; gap: 3px; }
.ai-typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: aiDot 1s ease-in-out infinite;
}
.ai-typing-dots i:nth-child(2) { animation-delay: .16s; }
.ai-typing-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes aiDot { 0%, 70%, 100% { transform: translateY(0); opacity: .45; } 35% { transform: translateY(-3px); opacity: 1; } }
.ai-chat-form {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.ai-chat-form textarea {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  max-height: 120px;
  resize: none;
  padding: 12px 14px;
  border: 1.5px solid #E4E8E2;
  border-radius: 15px;
  background: #FBFCFA;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
  outline: none;
}
.ai-chat-form textarea:focus { border-color: #D99E22; background: #fff; }
.ai-chat-send {
  flex: none;
  min-width: 68px;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 15px;
  background: #F3BE4E;
  color: #3D2B00;
  font-size: 14px;
  font-weight: 800;
}
.ai-chat-send:disabled { opacity: .55; cursor: default; }
body.ai-chat-open { overflow: hidden; }