/* 减脂搭子 —— 全局样式（手机优先） */
:root{
  --bg:#f4f6f2;
  --surface:#ffffff;
  --surface-2:#f0f3ee;
  --ink:#18261f;
  --ink-2:#3c4f45;
  --muted:#7d8f85;
  --line:#e3e8e1;
  --green:#1f7a55;
  --green-dark:#14603f;
  --green-soft:#e6f3ec;
  --carb:#e0a92e;
  --carb-soft:#fdf3dd;
  --protein:#e0674a;
  --protein-soft:#fdeae4;
  --fiber:#4f9a63;
  --fiber-soft:#e7f4e9;
  --warn:#c9741b;
  --warn-soft:#fdf1e2;
  --radius:16px;
  --radius-sm:10px;
  --shadow:0 1px 2px rgba(24,38,31,.04),0 6px 18px rgba(24,38,31,.06);
  --tabbar-h:64px;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0}
body{
  background:var(--bg);
  color:var(--ink);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  font-size:15px;
  line-height:1.55;
  overscroll-behavior-y:none;
}
button{font-family:inherit;font-size:inherit;color:inherit;border:0;background:none;padding:0;cursor:pointer}
input,select{font-family:inherit;font-size:inherit;color:inherit}
h1,h2,h3,h4,p{margin:0}
img{display:block;max-width:100%}

/* ---------- 布局 ---------- */
#app{
  display:flex;
  flex-direction:column;
  min-height:100vh;
  min-height:100dvh;
  max-width:520px;
  margin:0 auto;
  background:var(--bg);
  position:relative;
}
.top-wrap{
  position:sticky;top:0;z-index:20;
  background:linear-gradient(180deg,var(--bg) 76%,rgba(244,246,242,.92));
  backdrop-filter:blur(6px);
}
.topbar{
  display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:14px 16px 8px;
}
/* 常驻励志短句条 */
.quote-bar{
  display:flex;align-items:center;gap:6px;
  margin:0 16px 9px;padding:6px 12px;border-radius:999px;
  background:var(--green-soft);color:var(--green-dark);
  font-size:12.5px;font-weight:600;min-height:30px;
  border:1px solid #d3e8dc;
}
.quote-bar[hidden]{display:none}
.topbar .tb-title{font-size:19px;font-weight:700;letter-spacing:.5px}
.topbar .tb-sub{font-size:12px;color:var(--muted);margin-top:1px}
.topbar .tb-actions{display:flex;gap:8px;align-items:center}
main#view{
  flex:1;
  padding:2px 16px calc(var(--tabbar-h) + 26px);
  overflow-x:hidden;
}
/* 底部页签 */
.tabbar{
  position:fixed;bottom:0;left:0;right:0;z-index:30;
  max-width:520px;margin:0 auto;
  height:calc(var(--tabbar-h) + env(safe-area-inset-bottom,0px));
  padding-bottom:env(safe-area-inset-bottom,0px);
  display:grid;grid-template-columns:repeat(4,1fr);
  background:rgba(255,255,255,.94);
  backdrop-filter:blur(12px);
  border-top:1px solid var(--line);
}
.tabbar button{
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;
  min-height:44px;color:var(--muted);font-size:11px;font-weight:600;
  transition:color .15s;
}
.tabbar button .tb-ico{font-size:20px;line-height:1;filter:grayscale(.65);opacity:.75;transition:.15s}
.tabbar button.active{color:var(--green)}
.tabbar button.active .tb-ico{filter:none;opacity:1;transform:translateY(-1px)}

/* ---------- 通用文字 ---------- */
.muted{color:var(--muted)}
.small{font-size:12.5px}
.tiny{font-size:11.5px}
.strong{font-weight:700}
.center{text-align:center}
.big{font-size:26px;font-weight:800;letter-spacing:-.3px}
.warn-text{color:var(--warn)}
.good-text{color:var(--green)}

/* ---------- 卡片 ---------- */
.card{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:14px;
  box-shadow:var(--shadow);
  margin-bottom:12px;
}
.card.flush{padding:0;overflow:hidden}
.card-h{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}
.card-title{font-size:15.5px;font-weight:700}
.card-sub{font-size:12px;color:var(--muted);margin-top:2px}
.card-hero{
  background:linear-gradient(145deg,#1f7a55,#2f9a6c 55%,#48b07f);
  color:#fff;border:0;
}
.card-hero .muted,.card-hero .card-sub{color:rgba(255,255,255,.8)}

.row{display:flex;align-items:center;gap:10px}
.row-between{display:flex;align-items:center;justify-content:space-between;gap:10px}
.col{display:flex;flex-direction:column;gap:8px}
.grid2{display:grid;grid-template-columns:repeat(2,1fr);gap:10px}
.grid3{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.spacer{flex:1}
.divider{height:1px;background:var(--line);margin:12px 0}

/* ---------- 按钮 / 标签 ---------- */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:6px;
  min-height:44px;padding:0 16px;border-radius:12px;
  background:var(--surface-2);color:var(--ink-2);font-weight:600;font-size:14px;
  transition:transform .08s,background .15s;
}
.btn:active{transform:scale(.97)}
.btn.primary{background:var(--green);color:#fff}
.btn.primary:active{background:var(--green-dark)}
.btn.ghost{background:transparent;border:1px solid var(--line)}
.btn.small{min-height:40px;padding:0 13px;font-size:13px;border-radius:10px}
.btn.block{display:flex;width:100%}
.btn.danger{color:#b3341f;background:#fdeeea}
.btn[disabled]{opacity:.5}
.btn-hero{background:rgba(255,255,255,.18);color:#fff}

.chips{display:flex;flex-wrap:wrap;gap:8px}
.chip{
  min-height:36px;padding:0 13px;border-radius:999px;
  background:var(--surface);border:1px solid var(--line);
  display:inline-flex;align-items:center;gap:5px;
  font-size:13px;font-weight:600;color:var(--ink-2);
}
.chip.active{background:var(--green);border-color:var(--green);color:#fff}
.chip.carb{background:var(--carb-soft);border-color:#f2e3bd;color:#8a6410}
.chip.protein{background:var(--protein-soft);border-color:#f6d9d0;color:#a2402a}
.chip.fiber{background:var(--fiber-soft);border-color:#d6e9da;color:#2f6b41}

/* ---------- 热量环 ---------- */
.ring-wrap{position:relative;width:150px;height:150px;flex:0 0 auto}
.ring{width:100%;height:100%;transform:rotate(-90deg)}
.ring circle{fill:none;stroke-linecap:round}
.ring .track{stroke:rgba(255,255,255,.22);stroke-width:11}
.ring .bar{stroke:#fff;stroke-width:11;transition:stroke-dashoffset .6s ease}
.ring-txt{
  position:absolute;inset:0;display:flex;flex-direction:column;
  align-items:center;justify-content:center;gap:0;
}
.ring-txt .rv{font-size:26px;font-weight:800;line-height:1.1}
.ring-txt .rl{font-size:11.5px;color:rgba(255,255,255,.82)}

/* ---------- 三大营养素 ---------- */
.macros{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.macro{
  background:rgba(255,255,255,.14);border-radius:12px;padding:8px 10px;
}
.macro .mv{font-size:16px;font-weight:800}
.macro .ml{font-size:11px;color:rgba(255,255,255,.8)}
.macro.carb-m{background:rgba(255,241,214,.9);color:#7a590d}
.macro.carb-m .ml{color:#a07f2d}
.macro.protein-m{background:rgba(253,232,226,.9);color:#8f3a25}
.macro.protein-m .ml{color:#b0664f}
.macro.fiber-m{background:rgba(230,244,232,.9);color:#2c6340}
.macro.fiber-m .ml{color:#5b8a6b}

/* ---------- 今日页：餐卡 ---------- */
.meal-card{padding:0;overflow:hidden}
.meal-head{
  display:flex;align-items:center;gap:10px;
  padding:12px 14px;border-bottom:1px solid var(--line);
  background:var(--surface-2);
}
.meal-emoji{font-size:20px;line-height:1}
.meal-name{font-size:15px;font-weight:700}
.meal-time{font-size:11.5px;color:var(--muted)}
.meal-kcal{font-size:13px;font-weight:700;color:var(--green);white-space:nowrap}
.meal-body{padding:6px 14px 12px}
.food-line{
  display:flex;align-items:center;gap:10px;
  padding:10px 0;border-bottom:1px dashed #eef1ec;
  width:100%;text-align:left;min-height:44px;
}
.food-line:last-child{border-bottom:0}
.food-line .fi{font-size:18px;width:24px;text-align:center;flex:0 0 auto}
.food-line .fn{flex:1;min-width:0;font-size:14px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.food-line .fg{font-size:12px;color:var(--muted);white-space:nowrap}
.food-line .fk{font-size:12.5px;font-weight:700;white-space:nowrap;color:var(--ink-2);min-width:52px;text-align:right}
.food-line .chev{color:#c3cdc5;font-size:12px}
.dot{width:6px;height:6px;border-radius:50%;flex:0 0 auto}

/* ---------- 食材格 ---------- */
.food-tile{
  display:flex;flex-direction:column;align-items:center;gap:2px;
  background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-sm);
  padding:11px 4px 9px;min-height:88px;position:relative;
  transition:transform .08s,border-color .15s;
}
.food-tile:active{transform:scale(.96)}
.food-tile .ico{font-size:24px;line-height:1.15}
.food-tile .nm{font-size:12.5px;font-weight:600;text-align:center;line-height:1.25}
.food-tile .kc{font-size:10.5px;color:var(--muted)}
.food-tile .badge{
  position:absolute;top:5px;right:5px;font-size:9.5px;font-weight:700;
  padding:0 5px;border-radius:999px;line-height:15px;
}
.badge.carb{background:var(--carb-soft);color:#8a6410}
.badge.protein{background:var(--protein-soft);color:#a2402a}
.badge.fiber{background:var(--fiber-soft);color:#2f6b41}
.sec-title{display:flex;align-items:center;gap:7px;font-size:13.5px;font-weight:700;margin:16px 0 8px}
.sec-title .bar{width:4px;height:14px;border-radius:2px;background:var(--green)}
.sec-title .cnt{font-size:11.5px;font-weight:500;color:var(--muted)}

/* ---------- 表单 ---------- */
.field{margin-bottom:14px}
.field>label{display:block;font-size:13px;font-weight:600;color:var(--ink-2);margin-bottom:6px}
.field .hint{font-size:11.5px;color:var(--muted);margin-top:5px}
.input{
  width:100%;min-height:46px;padding:10px 13px;
  background:var(--surface);border:1px solid var(--line);border-radius:12px;
  font-size:16px;font-weight:600;outline:none;
  transition:border-color .15s,box-shadow .15s;
}
.input:focus{border-color:var(--green);box-shadow:0 0 0 3px var(--green-soft)}
.input-wrap{position:relative;display:flex;align-items:center}
.input-wrap .unit{position:absolute;right:13px;font-size:13px;color:var(--muted);pointer-events:none}
.seg{display:grid;grid-auto-flow:column;gap:6px;background:var(--surface-2);border-radius:12px;padding:4px}
.seg button{
  min-height:38px;border-radius:9px;font-size:13px;font-weight:600;color:var(--ink-2);
  display:flex;align-items:center;justify-content:center;
}
.seg button.active{background:var(--surface);box-shadow:0 1px 3px rgba(24,38,31,.12);color:var(--green)}

/* ---------- 列表 ---------- */
.list{display:flex;flex-direction:column}
.list-item{
  display:flex;align-items:center;gap:12px;padding:13px 0;
  border-bottom:1px solid var(--line);width:100%;text-align:left;min-height:52px;
}
.list-item:last-child{border-bottom:0}
.list-item .li-ico{font-size:18px;width:26px;text-align:center}
.list-item .li-main{flex:1;min-width:0}
.list-item .li-t{font-size:14px;font-weight:600}
.list-item .li-s{font-size:11.5px;color:var(--muted)}
.list-item .del-btn{
  width:40px;height:40px;flex:0 0 auto;border-radius:10px;
  display:flex;align-items:center;justify-content:center;
  background:var(--surface-2);color:#b7c2ba;font-size:13px;
}
.list-item .del-btn:active{background:#fdeeea;color:#b3341f}

/* ---------- 统计块 ---------- */
.stats{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.stat{background:var(--surface-2);border-radius:12px;padding:10px 8px;text-align:center}
.stat .sv{font-size:17px;font-weight:800;line-height:1.25}
.stat .sl{font-size:11px;color:var(--muted);margin-top:1px}

/* ---------- 图表 ---------- */
.chart-wrap{margin-top:6px;position:relative}
canvas.jz-chart{width:100%;height:170px;display:block}
.chart-legend{display:flex;gap:14px;font-size:11.5px;color:var(--muted);margin-top:6px}

/* ---------- 弹层 / 全屏页 ---------- */
.sheet-mask{
  position:fixed;inset:0;z-index:60;background:rgba(16,26,21,.42);
  display:flex;align-items:flex-end;justify-content:center;
  opacity:0;pointer-events:none;transition:opacity .2s;
}
.sheet-mask.show{opacity:1;pointer-events:auto}
.sheet{
  width:100%;max-width:520px;max-height:86vh;
  background:var(--surface);border-radius:20px 20px 0 0;
  transform:translateY(18px);transition:transform .22s ease;
  display:flex;flex-direction:column;overflow:hidden;
  padding-bottom:env(safe-area-inset-bottom,0px);
}
.sheet-mask.show .sheet{transform:translateY(0)}
.sheet-h{
  display:flex;align-items:center;gap:10px;padding:14px 16px 12px;
  border-bottom:1px solid var(--line);flex:0 0 auto;
}
.sheet-body{padding:14px 16px 22px;overflow-y:auto;-webkit-overflow-scrolling:touch}
.sheet .close{
  width:40px;height:40px;border-radius:50%;background:var(--surface-2);
  display:flex;align-items:center;justify-content:center;font-size:15px;color:var(--muted);flex:0 0 auto;
}
.fullpage{
  position:fixed;inset:0;z-index:70;background:var(--bg);
  max-width:520px;margin:0 auto;display:flex;flex-direction:column;
  transform:translateX(100%);transition:transform .22s ease;visibility:hidden;
}
.fullpage.show{transform:translateX(0);visibility:visible}
.fullpage-h{
  position:sticky;top:0;z-index:5;display:flex;align-items:center;gap:10px;
  padding:12px 14px;background:var(--surface);border-bottom:1px solid var(--line);
}
.fullpage-h .fp-title{font-size:16px;font-weight:700;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.fullpage-body{flex:1;overflow-y:auto;padding:14px 16px calc(28px + env(safe-area-inset-bottom,0px))}
.back-btn{width:38px;height:38px;border-radius:50%;background:var(--surface-2);display:flex;align-items:center;justify-content:center;font-size:17px;flex:0 0 auto}

/* 做法行 */
.recipe-row{
  display:flex;align-items:center;gap:12px;padding:12px 0;width:100%;text-align:left;
  border-bottom:1px solid var(--line);min-height:56px;
}
.recipe-row:last-child{border-bottom:0}
.recipe-row .rr-thumb{
  width:46px;height:46px;border-radius:12px;flex:0 0 auto;
  display:flex;align-items:center;justify-content:center;font-size:22px;background:var(--green-soft);
}
.recipe-row .rr-main{flex:1;min-width:0}
.recipe-row .rr-t{font-size:14.5px;font-weight:700}
.recipe-row .rr-s{font-size:11.5px;color:var(--muted);display:flex;gap:8px;flex-wrap:wrap;margin-top:1px}

/* 步骤 */
.step{display:flex;gap:12px;padding:12px 0;border-bottom:1px dashed #eef1ec}
.step:last-child{border-bottom:0}
.step-no{
  width:26px;height:26px;border-radius:50%;background:var(--green);color:#fff;
  display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:700;flex:0 0 auto;
}
.step-tx{flex:1;font-size:14px;line-height:1.6;padding-top:2px}
.ing-table{display:grid;grid-template-columns:1fr auto;gap:8px 12px;font-size:14px}
.ing-table .ig-n{color:var(--ink-2)}
.ing-table .ig-q{color:var(--muted);font-variant-numeric:tabular-nums}
.tip-box{background:var(--warn-soft);border-radius:12px;padding:11px 13px;font-size:13px;color:#7d5211;line-height:1.6}

/* ---------- 饮水 / 睡眠 ---------- */
.cups{display:grid;grid-template-columns:repeat(auto-fill,minmax(30px,1fr));gap:6px;margin-top:4px}
.cup{
width:100%;height:36px;border-radius:11px;border:1px dashed #cfd8d1;
  display:flex;align-items:center;justify-content:center;font-size:15px;color:#c8d2ca;
  background:var(--surface);
}
.cup.on{background:#e6f2fb;border:1px solid #b6d8ef;color:#2b7bb9}
.cup:active{transform:scale(.94)}
.bar-track{height:8px;border-radius:999px;background:var(--surface-2);overflow:hidden;margin:10px 0 6px}
.bar-track>i{display:block;height:100%;border-radius:999px;background:var(--green);transition:width .3s}
.bar-track.blue>i{background:#3d8fc4}

/* 开关 */
.switch{
  width:46px;height:28px;border-radius:999px;background:#d8e0d9;position:relative;flex:0 0 auto;
  transition:background .18s;
}
.switch>i{
  position:absolute;top:3px;left:3px;width:22px;height:22px;border-radius:50%;
  background:#fff;box-shadow:0 1px 3px rgba(24,38,31,.25);transition:transform .18s;
}
.switch.on{background:var(--green)}
.switch.on>i{transform:translateX(18px)}

/* 空状态 */
.empty{text-align:center;padding:34px 16px;color:var(--muted)}
.empty .eico{font-size:34px;opacity:.55}
.empty .etx{font-size:13.5px;margin-top:8px;line-height:1.6}

/* toast */
#toast{
  position:fixed;left:50%;bottom:96px;transform:translate(-50%,10px);
  background:rgba(24,38,31,.92);color:#fff;font-size:13.5px;font-weight:600;
  padding:10px 18px;border-radius:999px;z-index:99;
  opacity:0;pointer-events:none;transition:.22s;max-width:86vw;text-align:center;
}
#toast.show{opacity:1;transform:translate(-50%,0)}

/* 徽标 */
.tag{
  display:inline-flex;align-items:center;gap:4px;font-size:11px;font-weight:700;
  padding:2px 8px;border-radius:999px;background:var(--surface-2);color:var(--ink-2);
}
.tag.green{background:var(--green-soft);color:var(--green-dark)}
.tag.warn{background:var(--warn-soft);color:var(--warn)}
.tag.carb{background:var(--carb-soft);color:#8a6410}
.tag.protein{background:var(--protein-soft);color:#a2402a}
.tag.fiber{background:var(--fiber-soft);color:#2f6b41}

@media (min-width:521px){
  body{background:#e8ece6}
  #app{box-shadow:0 0 40px rgba(24,38,31,.08);min-height:100vh}
}
