:root{
  --bg:#f6f7f5; --card:#fff; --text:#16181a; --muted:#6f7680; --faint:#9aa1ab;
  --line:#e6e8e6; --green:#15a34a; --green-bg:#e7f7ed; --green-deep:#0d7a36;
  --amber:#e08c1a; --red:#d93b3b; --blue:#3b7fd9;
  --r:14px;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
/* display:flex 等规则会盖掉 hidden 的 UA 样式，这里统一压回来 */
[hidden]{display:none!important}
html,body{margin:0;padding:0}
body{
  font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Helvetica Neue",Arial,sans-serif;
  background:var(--bg); color:var(--text); font-size:15px; line-height:1.5;
  -webkit-font-smoothing:antialiased;
}
button{font-family:inherit;font-size:inherit;cursor:pointer;border:0;background:none;color:inherit}
input,select,textarea{font-family:inherit;font-size:16px}
#app{max-width:520px;margin:0 auto;padding:0 16px 110px;min-height:100vh}

/* 切标签页时内容淡入上浮一点，比硬切看着顺 */
@keyframes viewIn{from{opacity:.55;transform:translateY(7px)}to{opacity:1;transform:none}}
#view.view-in{animation:viewIn .19s cubic-bezier(.22,.61,.36,1) both}
@media(prefers-reduced-motion:reduce){#view.view-in{animation:none}}

.topbar{display:flex;align-items:center;justify-content:space-between;padding:20px 0 14px}
.greet{font-size:22px;font-weight:600;letter-spacing:-.3px}
.date{font-size:13px;color:var(--muted);margin-top:2px}
.avatar{width:38px;height:38px;border-radius:50%;background:var(--green-bg);color:var(--green-deep);
  font-weight:600;font-size:14px}

.card{background:var(--card);border-radius:var(--r);padding:16px;margin-bottom:12px;
  box-shadow:0 1px 2px rgba(16,24,40,.04)}
.card-t{font-size:13px;color:var(--muted);font-weight:500;margin-bottom:10px}

/* 热量环 */
.ring-wrap{display:flex;align-items:center;gap:20px}
.ring{position:relative;width:158px;height:158px;flex:0 0 auto}
.ring svg{transform:rotate(-90deg)}
.ring-mid{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center}
.ring-num{font-size:34px;font-weight:600;letter-spacing:-1px;line-height:1}
.ring-lbl{font-size:12px;color:var(--muted);margin-top:4px}
.ring-side{flex:1;display:flex;flex-direction:column;gap:12px}
.kv{display:flex;justify-content:space-between;align-items:baseline;font-size:14px}
.kv b{font-size:17px;font-weight:600}
.kv span{color:var(--muted)}

.bar{height:7px;background:#eef0ee;border-radius:4px;overflow:hidden}
.bar>i{display:block;height:100%;border-radius:4px;background:var(--green);transition:width .35s}

/* 餐次 */
.meal{display:flex;gap:12px;padding:12px 0;border-bottom:1px solid var(--line)}
.meal:last-child{border-bottom:0;padding-bottom:0}
.meal-thumb{width:52px;height:52px;border-radius:10px;object-fit:cover;background:#eef0ee;flex:0 0 auto}
.meal-thumb.empty{display:flex;align-items:center;justify-content:center;font-size:20px;color:var(--faint)}
.meal-body{flex:1;min-width:0}
.meal-row{display:flex;justify-content:space-between;align-items:baseline}
.meal-name{font-weight:500;font-size:14px}
.meal-kcal{font-weight:600;font-size:15px}
.meal-items{font-size:12.5px;color:var(--muted);margin-top:3px;overflow:hidden;text-overflow:ellipsis;
  white-space:nowrap}
.empty-hint{text-align:center;color:var(--faint);font-size:13.5px;padding:22px 0}

/* tabbar */
.tabbar{position:fixed;bottom:0;left:0;right:0;max-width:520px;margin:0 auto;
  display:flex;background:rgba(255,255,255,.94);backdrop-filter:blur(12px);
  border-top:1px solid var(--line);padding:6px 0 calc(6px + env(safe-area-inset-bottom));z-index:30}
.tabbar button{flex:1;padding:7px 0;font-size:12px;color:var(--faint);font-weight:500;
  transition:color .18s ease,transform .12s ease}
.tabbar button.on{color:var(--green-deep)}
/* 点按有即时反馈，手指落下就觉得「已经切了」 */
.tabbar button:active{transform:scale(.9)}

.fab{position:fixed;right:calc(50% - 260px + 18px);bottom:calc(74px + env(safe-area-inset-bottom));
  width:54px;height:54px;border-radius:50%;background:var(--green);color:#fff;font-size:28px;
  font-weight:300;line-height:1;box-shadow:0 6px 18px rgba(21,163,74,.32);z-index:31;
  display:flex;align-items:center;justify-content:center;padding-bottom:2px}
@media(max-width:560px){.fab{right:18px}}

/* sheet */
.sheet-backdrop{position:fixed;inset:0;background:rgba(18,22,20,.38);z-index:50;
  display:flex;align-items:flex-end;justify-content:center}
.sheet{background:#fff;width:100%;max-width:520px;border-radius:18px 18px 0 0;
  max-height:88vh;overflow-y:auto;padding:18px 18px calc(24px + env(safe-area-inset-bottom))}
.sheet-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px}
.sheet-head b{font-size:17px}

.btn-primary{width:100%;background:var(--green);color:#fff;border-radius:12px;padding:13px;
  font-weight:600;font-size:15.5px;margin-top:6px}
.btn-primary:disabled{opacity:.5}
.btn-text{color:var(--muted);font-size:13.5px}
.btn-ghost{background:var(--green-bg);color:var(--green-deep);border-radius:10px;padding:10px 12px;
  font-weight:500;font-size:14px}

.field{width:100%;background:#f4f5f3;border:1px solid transparent;border-radius:11px;
  padding:12px 13px;margin-bottom:10px;outline:none}
.field:focus{background:#fff;border-color:var(--green)}
.row2{display:flex;gap:10px}
.row2>*{flex:1}
.seg{display:flex;gap:6px;margin-bottom:12px}
.seg button{flex:1;padding:9px;border-radius:10px;background:#f4f5f3;font-size:14px;color:var(--muted)}
.seg button.on{background:var(--green-bg);color:var(--green-deep);font-weight:600}

.gate{position:fixed;inset:0;background:var(--bg);display:flex;align-items:center;justify-content:center;
  padding:24px;z-index:80}
.gate-card{width:100%;max-width:340px;text-align:center}
.logo{font-size:30px;font-weight:700;letter-spacing:-1px;color:var(--green-deep)}
.gate-sub{color:var(--muted);font-size:14px;margin:6px 0 26px}
.gate-card input{width:100%;background:#fff;border:1px solid var(--line);border-radius:12px;
  padding:13px;margin-bottom:10px;outline:none}
.gate-card input:focus{border-color:var(--green)}
.err{color:var(--red);font-size:13px;min-height:18px;margin:8px 0 0}

/* 记录弹层内 */
.dish{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:11px 0;
  border-bottom:1px solid var(--line)}
.dish input{width:66px;text-align:right;background:#f4f5f3;border:1px solid transparent;
  border-radius:8px;padding:6px 8px;font-size:14px;outline:none}
.dish input:focus{background:#fff;border-color:var(--green)}
.dish-name{font-size:14px;font-weight:500}
.dish-sub{font-size:12px;color:var(--muted);margin-top:1px}
.conf{display:inline-block;font-size:10.5px;padding:1px 6px;border-radius:5px;margin-left:5px;
  vertical-align:1px}
.conf.high{background:var(--green-bg);color:var(--green-deep)}
.conf.mid{background:#fef3e2;color:var(--amber)}
.conf.low{background:#fdeaea;color:var(--red)}
.tot{display:flex;justify-content:space-between;padding:13px 0 4px;font-size:14px}
.tot b{font-size:18px}

.photo-box{border:1px dashed var(--line);border-radius:12px;padding:22px;text-align:center;
  color:var(--muted);font-size:13.5px;margin-bottom:12px}
.photo-box img{max-width:100%;border-radius:10px}

.stat3{display:flex;gap:10px;margin-bottom:12px}
.stat3>div{flex:1;background:#f6f7f5;border-radius:11px;padding:11px 12px}
.stat3 span{font-size:12px;color:var(--muted);display:block}
.stat3 b{font-size:19px;font-weight:600;letter-spacing:-.4px}
.stat3 em{font-size:11.5px;color:var(--faint);font-style:normal}

.chart-box{height:210px;margin:2px -4px 0}
.note{font-size:12.5px;color:var(--faint);line-height:1.55;margin-top:8px}
.toast{position:fixed;left:50%;bottom:96px;transform:translateX(-50%);background:#16181a;
  color:#fff;padding:10px 16px;border-radius:10px;font-size:13.5px;z-index:99;opacity:0;
  transition:opacity .25s;pointer-events:none}
.toast.show{opacity:.94}

/* 记餐草稿：名字与热量可编辑 */
.dish-name-edit{width:100%;background:transparent;border:none;
  border-bottom:1px dashed var(--line);font-size:14px;font-weight:500;
  padding:2px 0;outline:none;font-family:inherit;color:inherit}
.dish-name-edit:focus{border-bottom-color:var(--green)}
.kcal-edit{width:52px;text-align:right;background:#f4f5f3;border:1px solid transparent;
  border-radius:6px;padding:2px 4px;font-size:12px;outline:none;font-family:inherit;color:inherit}
.kcal-edit:focus{background:#fff;border-color:var(--green)}

/* 每日目标悬停提示 */
.kv.tip{cursor:help}
.kv.tip b{border-bottom:1px dotted var(--muted)}
.tipbox{position:absolute;left:16px;right:16px;background:#20301f;color:#fff;
  border-radius:10px;padding:10px 12px;font-size:12.5px;line-height:1.65;
  z-index:6;box-shadow:0 6px 18px rgba(0,0,0,.18)}

/* 今天还差多少 · 该吃啥 */
.sug-list{margin-top:4px}
.sug{display:flex;gap:10px;padding:10px 0;border-bottom:1px solid var(--line)}
.sug:last-child{border-bottom:none;padding-bottom:0}
.sug-n{width:20px;height:20px;flex:none;border-radius:50%;background:#e8f4ea;color:var(--green);
  font-size:12px;font-weight:600;display:flex;align-items:center;justify-content:center;margin-top:2px}
.sug-t{font-size:14px;font-weight:500;line-height:1.4}
.sug-s{font-size:12.5px;color:var(--muted);line-height:1.6;margin-top:3px}

.sug-tag{display:inline-block;margin-left:8px;padding:1px 7px;border-radius:6px;
  background:#e8f4ea;color:var(--green);font-size:11px;font-weight:500;vertical-align:1px}

/* 找菜谱 */
.sug-link{margin-left:8px;padding:2px 8px;border:1px solid var(--line);border-radius:999px;
  background:#fff;color:var(--green);font-size:11.5px;font-family:inherit;cursor:pointer}
.sug-link:active{background:#eef7ef}
.rcp{display:flex;gap:10px;align-items:flex-start;padding:11px 0;border-bottom:1px solid var(--line);
  text-decoration:none;color:inherit}
.rcp:last-of-type{border-bottom:none}
.rcp-e{font-size:15px;line-height:1.3;flex:none;width:72px;word-break:break-all;opacity:.9}
.rcp-n{font-size:14.5px;font-weight:500;color:var(--green)}
.rcp-m{font-size:12px;color:var(--muted);margin-top:3px}
.rcp-cap{font-size:12px;color:var(--muted);padding:0 0 8px;border-bottom:1px solid var(--line);margin-bottom:2px}
