/* 谭成义减脂法 · 手机网页版 */
:root {
  --bg: #f3f5f2;
  --card: #ffffff;
  --ink: #14201c;
  --muted: #7c867f;
  --line: #e7ebe6;
  --accent: #0e6b5c;
  --accent-2: #14836f;
  --soft: #e6f2ee;
  --carb: #b8863b;
  --pro: #2f7d6e;
  --fat: #a85a4e;
  --warn: #b4543f;
  --shadow: 0 1px 2px rgba(20, 32, 28, .04), 0 8px 24px rgba(20, 32, 28, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; min-width: 0; }
input { -webkit-appearance: none; appearance: none; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
button { cursor: pointer; border: none; background: none; padding: 0; }
input { border: none; background: none; outline: none; }

.wrap { max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; }

/* ---------- 通用 ---------- */
.card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 0 14px 12px;
}
.card-tight { padding: 14px 16px; }
.row { display: flex; align-items: center; }
.row > * { min-width: 0; }
html, body { overflow-x: hidden; }
.between { justify-content: space-between; }
.gap8 { gap: 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 22px 20px 10px;
}
.section-title h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: .2px; }
.section-title span { font-size: 12px; color: var(--muted); }

/* ---------- 顶部 ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  padding: calc(10px + env(safe-area-inset-top)) 14px 8px;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(243, 245, 242, .75));
  backdrop-filter: blur(8px);
}
.top-row { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--soft); }
.brand b { font-size: 14px; letter-spacing: .3px; }
.date-nav { display: flex; align-items: center; gap: 2px; }
.date-nav button { width: 30px; height: 30px; border-radius: 10px; color: var(--muted); font-size: 16px; }
.date-nav button:active { background: var(--soft); }
.date-nav .date-label { min-width: 78px; text-align: center; font-size: 13px; font-weight: 600; }

/* ---------- 主圆环 ---------- */
.ring-card { padding: 18px 16px 16px; }
.ring-wrap { position: relative; width: 190px; height: 190px; margin: 2px auto 6px; }
.ring-wrap svg { transform: rotate(-90deg); display: block; }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px;
}
.ring-center .left { font-size: 34px; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.ring-center .unit { font-size: 11px; color: var(--muted); letter-spacing: 1px; }
.ring-center .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.badge-type {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: var(--soft); color: var(--accent); font-size: 12px; font-weight: 600;
}
.badge-type.mid { background: #eef1e6; color: #6b7a3a; }
.badge-type.rest { background: #eef0f4; color: #5b6b82; }

/* ---------- 三大营养素 ---------- */
.macros { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 12px; }
.macro { background: #fafbf9; border-radius: 12px; padding: 10px 10px 9px; }
.macro .k { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }
.macro .v { font-size: 17px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }
.macro .v i { font-style: normal; font-size: 11px; font-weight: 500; color: var(--muted); }
.macro .bar { height: 4px; border-radius: 4px; background: #eceeeb; margin-top: 7px; overflow: hidden; }
.macro .bar i { display: block; height: 100%; border-radius: 4px; transition: width .35s ease; }
.macro.c .v { color: var(--carb); } .macro.c .bar i { background: var(--carb); }
.macro.p .v { color: var(--pro); } .macro.p .bar i { background: var(--pro); }
.macro.f .v { color: var(--fat); } .macro.f .bar i { background: var(--fat); }
.macro.over .v { color: var(--warn); } .macro.over .bar i { background: var(--warn); }

/* ---------- 餐次 ---------- */
.meal { padding: 14px 16px; }
.meal-head { display: flex; align-items: center; justify-content: space-between; }
.meal-head .name { font-weight: 650; font-size: 14px; }
.meal-head .kcal { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meal-list { margin: 8px 0 0; }
.food-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0; border-bottom: 1px dashed var(--line);
}
.food-item:last-child { border-bottom: none; }
.food-item .fn { flex: 1; min-width: 0; }
.food-item .fn b { font-weight: 550; font-size: 13.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.food-item .fn span { font-size: 11px; color: var(--muted); }
.food-item .fk { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.del { width: 26px; height: 26px; border-radius: 8px; color: #b9c0ba; font-size: 15px; line-height: 1; }
.del:active { background: #fbeeeb; color: var(--warn); }
.add-line {
  display: flex; align-items: center; gap: 6px; margin-top: 8px;
  color: var(--accent); font-size: 13px; font-weight: 550;
}
.add-line span.plus {
  width: 20px; height: 20px; border-radius: 7px; background: var(--soft);
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; padding: 0 18px; border-radius: 13px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 14.5px;
  width: 100%;
}
.btn:active { transform: scale(.99); background: var(--accent-2); }
.btn.ghost { background: var(--soft); color: var(--accent); }
.btn.line { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.sm { height: 36px; font-size: 13px; padding: 0 14px; width: auto; border-radius: 10px; }
.btn.danger { background: #fbeeeb; color: var(--warn); }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 480px; margin: 0 auto;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: #9aa49d; font-size: 10.5px;
}
.tabbar button svg { width: 21px; height: 21px; }
.tabbar button.on { color: var(--accent); }
.tabbar button.on svg { stroke-width: 2.1; }

main { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

/* ---------- 弹层 ---------- */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(12, 20, 17, .38); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
.sheet {
  width: 100%; max-width: 480px; background: #fff;
  border-radius: 22px 22px 0 0; padding: 8px 0 calc(10px + env(safe-area-inset-bottom));
  max-height: 88vh; display: flex; flex-direction: column;
  animation: up .24s cubic-bezier(.2, .8, .3, 1);
}
.sheet-grip { width: 38px; height: 4px; border-radius: 3px; background: #e3e7e2; margin: 6px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 0 18px 10px; }
.sheet-head h3 { margin: 0; font-size: 16px; }
.sheet-body { overflow-y: auto; padding: 0 18px; -webkit-overflow-scrolling: touch; }
.sheet-body::-webkit-scrollbar { width: 0; }

@keyframes up { from { transform: translateY(28px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.search {
  display: flex; align-items: center; gap: 8px; background: #f5f7f4;
  border-radius: 12px; padding: 10px 12px; margin-bottom: 12px;
}
.search input { flex: 1; font-size: 14px; }
.search svg { width: 17px; height: 17px; color: #a6b0a9; }

.cats { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 10px; }
.cats::-webkit-scrollbar { display: none; }
.cat {
  flex: 0 0 auto; padding: 6px 12px; border-radius: 999px; background: #f4f6f3;
  color: #6d7770; font-size: 12.5px; border: 1px solid transparent;
}
.cat.on { background: var(--soft); color: var(--accent); border-color: #cfe5de; font-weight: 600; }

.food-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.food-row .fn { flex: 1; min-width: 0; }
.food-row .fn b { font-weight: 550; font-size: 14px; display: block; }
.food-row .fn span { font-size: 11.5px; color: var(--muted); }
.food-row .fk { font-size: 12.5px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 26px 0; }

/* 添加食物面板 */
.pick { padding: 4px 0 10px; }
.pick-name { font-size: 17px; font-weight: 650; }
.pick-macro { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.grams-row { display: flex; align-items: center; gap: 12px; margin: 16px 0 10px; }
.stepper { display: flex; align-items: center; background: #f5f7f4; border-radius: 12px; }
.stepper button { width: 42px; height: 42px; font-size: 19px; color: var(--accent); }
.stepper input { width: 74px; text-align: center; font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stepper .u { font-size: 12px; color: var(--muted); padding-right: 12px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { padding: 7px 12px; border-radius: 10px; background: #f5f7f4; font-size: 12.5px; color: #55605a; }
.chip.on { background: var(--soft); color: var(--accent); font-weight: 650; box-shadow: inset 0 0 0 1.5px #9dcdbe; }
.meal-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.meal-pick button { height: 38px; border-radius: 11px; background: #f5f7f4; font-size: 13px; color: #55605a; }
.meal-pick button.on { background: var(--accent); color: #fff; font-weight: 600; }
.computed { background: #fafbf9; border-radius: 12px; padding: 12px; display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; margin-bottom: 14px; }
.computed div b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.computed div span { font-size: 10.5px; color: var(--muted); }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; min-width: 0; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%; height: 46px; border-radius: 12px; background: #eef1ec;
  padding: 0 14px; font-size: 15px; border: 1px solid #e4e8e2;
}
.input:focus { border-color: #bfe0d6; background: #fff; }
.seg { display: grid; grid-auto-flow: column; gap: 8px; }
.seg button {
  height: 44px; border-radius: 12px; background: #f5f7f4; font-size: 14px; color: #55605a;
}
.seg button.on { background: var(--soft); color: var(--accent); font-weight: 650; box-shadow: inset 0 0 0 1px #cfe5de; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week button { height: 40px; border-radius: 10px; background: #f5f7f4; font-size: 13px; color: #55605a; }
.week button.on { background: var(--accent); color: #fff; font-weight: 600; }

/* ---------- 计划页 ---------- */
.plan-hero { background: linear-gradient(150deg, #0e6b5c, #14786a 55%, #1a8474); color: #fff; }
.plan-hero .k { font-size: 12px; opacity: .82; }
.plan-hero h3 { margin: 6px 0 2px; font-size: 20px; letter-spacing: .3px; }
.plan-hero .meta { font-size: 12px; opacity: .8; }
.progress-line { height: 5px; border-radius: 4px; background: rgba(255, 255, 255, .22); margin-top: 14px; overflow: hidden; }
.progress-line i { display: block; height: 100%; background: #fff; border-radius: 4px; }
.plan-hero .foot { display: flex; justify-content: space-between; font-size: 11.5px; opacity: .82; margin-top: 7px; }

.day-list { margin-top: 4px; }
.day-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.day-row:last-child { border-bottom: none; }
.day-row .d { width: 62px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.day-row .t { flex: 1; font-size: 12.5px; }
.day-row .m { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.day-row.today { background: #f7fbf9; border-radius: 10px; padding-left: 8px; margin-left: -8px; }
.tag { font-size: 10.5px; padding: 2px 7px; border-radius: 6px; background: #eef1ee; color: #6a756e; }
.tag.high { background: #fbeee0; color: #a46a25; }
.tag.mid { background: #f0f2e4; color: #6f7a3c; }
.tag.rest { background: #eceff3; color: #5d6b7e; }
.dotmark { width: 6px; height: 6px; border-radius: 50%; background: #d9ded9; }
.dotmark.done { background: var(--accent); }

/* ---------- 复盘 ---------- */
.big-num { font-size: 30px; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.delta { font-size: 12.5px; padding: 3px 9px; border-radius: 8px; font-weight: 600; }
.delta.down { background: #e6f2ee; color: var(--accent); }
.delta.up { background: #fbeeeb; color: var(--warn); }
.delta.flat { background: #f0f2f0; color: #6a756e; }
.advice { border-radius: 14px; padding: 13px 14px; background: #f7fbf9; border: 1px solid #e3efe9; }
.advice b { display: block; font-size: 13.5px; margin-bottom: 3px; }
.advice p { margin: 0; font-size: 12.5px; color: #55605a; line-height: 1.55; }
.chart-wrap { margin: 6px 0 2px; }
.chart-wrap svg { width: 100%; height: 120px; display: block; }

.wlist .wrow { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.wlist .wrow:last-child { border: none; }

/* ---------- 设置 / 引导 ---------- */
.setup { padding: 26px 22px calc(30px + env(safe-area-inset-bottom)); max-width: 480px; margin: 0 auto; }
.setup h1 { font-size: 26px; margin: 6px 0 6px; letter-spacing: -.3px; }
.setup .lead { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; line-height: 1.6; }
.setup .kicker { font-size: 11.5px; letter-spacing: 2px; color: var(--accent); font-weight: 700; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.result-box { background: #f7fbf9; border: 1px solid #e3efe9; border-radius: 14px; padding: 14px; margin-top: 4px; }
.result-line { display: flex; justify-content: space-between; font-size: 13.5px; padding: 4px 0; }
.result-line b { font-variant-numeric: tabular-nums; }
.footnote { font-size: 11px; color: #9aa49d; line-height: 1.6; margin: 18px 20px 4px; }
.linkish { color: var(--accent); font-weight: 600; }
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(20, 32, 28, .92); color: #fff; font-size: 13px; padding: 10px 16px;
  border-radius: 12px; z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s ease;
  max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; }
.sep { height: 1px; background: var(--line); margin: 14px 0; }
.list-btn { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 14px; text-align: left; }
.list-btn:last-child { border-bottom: none; }
.list-btn .chev { color: #c3cac4; }
