/* ===== 减脂驾驶舱 · 浅色精修 · 手机优先 ===== */
:root {
  --green: #16a34a;
  --green-dark: #147e3c;
  --green-soft: #e2f6e9;
  --red: #dc2626;
  --red-soft: #fdeaea;
  --amber: #d97706;
  --amber-soft: #fdf2dc;
  --blue: #2563eb;
  --blue-soft: #e3edfc;
  --gold: #b45309;
  --gold-soft: #fef3c7;
  --bg: #f2f4f1;
  --card: #ffffff;
  --text: #1c2430;
  --text-2: #5f6b7a;
  --text-3: #97a1ae;
  --line: #e6e9e4;
  --line-soft: #eff1ed;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(28, 36, 48, .04), 0 6px 18px rgba(28, 36, 48, .05);
  --shadow-pop: 0 12px 40px rgba(28, 36, 48, .18);
}

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

html { font-size: 16px; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  padding-bottom: calc(74px + env(safe-area-inset-bottom));
}
.hidden { display: none !important; }
button { font-family: inherit; touch-action: manipulation; }

/* ---------- 认证层 ---------- */
#auth-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(165deg, #053f2c 0%, #0d7a43 55%, #34c96e 100%);
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: #fff; border-radius: 24px;
  padding: 38px 28px; text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .3);
  animation: popIn .35s cubic-bezier(.2, .9, .3, 1.2);
}
.auth-logo { font-size: 46px; }
.auth-card h1 { font-size: 22px; margin: 8px 0 4px; letter-spacing: 1px; }
.auth-sub { color: var(--text-3); font-size: 13px; margin-bottom: 22px; }
.auth-form { text-align: left; }
.auth-form label { display: block; font-size: 13px; color: var(--text-2); margin: 12px 0 6px; }
.auth-form input[type=password] {
  width: 100%; padding: 13px 14px; font-size: 16px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.auth-form input[type=password]:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.remember-row { display: flex !important; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.auth-form .btn { margin-top: 18px; }
.auth-error { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; text-align: center; }

/* ---------- 顶栏 ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(242, 244, 241, .88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-inner {
  max-width: 860px; margin: 0 auto; padding: 11px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.brand { font-weight: 800; font-size: 16px; letter-spacing: .5px; }
.stage-banner {
  font-size: 12px; font-weight: 600; color: var(--green-dark);
  background: var(--green-soft); padding: 5px 12px; border-radius: 999px;
  white-space: nowrap;
}

/* ---------- 主区域 ---------- */
main { max-width: 860px; margin: 0 auto; padding: 14px 14px 24px; }
.page-title { font-size: 20px; font-weight: 800; margin: 6px 2px 12px; letter-spacing: .3px; }
.page-title-sub { font-size: 14px; font-weight: 500; color: var(--text-3); }
.section-title {
  font-size: 14px; font-weight: 700; color: var(--text-2);
  margin: 20px 4px 8px; display: flex; align-items: center; gap: 6px;
}

/* 卡片进出场（前几个子元素依次淡入） */
.page > * { animation: riseIn .3s ease both; }
.page > *:nth-child(2) { animation-delay: .04s; }
.page > *:nth-child(3) { animation-delay: .08s; }
.page > *:nth-child(4) { animation-delay: .12s; }
.page > *:nth-child(5) { animation-delay: .16s; }
.page > *:nth-child(n+6) { animation-delay: .2s; }
@keyframes riseIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.card-title { font-weight: 700; font-size: 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.card-sub { font-size: 12.5px; color: var(--text-3); margin-bottom: 10px; line-height: 1.5; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.grid-2 > .card { margin-bottom: 0; }
@media (max-width: 560px) { .grid-2.stack-mobile { grid-template-columns: 1fr; } }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 14px; font-weight: 600; padding: 11px 16px; min-height: 42px;
  background: #eceee9; color: var(--text);
  transition: transform .08s ease, opacity .15s, background .15s, box-shadow .15s;
  user-select: none;
}
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--green); color: #fff; box-shadow: 0 3px 10px rgba(22, 163, 74, .28); }
.btn-primary:hover { background: var(--green-dark); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-sm { padding: 7px 13px; min-height: 34px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 4px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; font-size: 16px;   /* 16px 防 iOS 自动缩放 */
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); outline: none;
  background: #fff; color: var(--text); font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft);
}
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; margin-bottom: 14px; }
.meal-field { border-top: 1px dashed var(--line); padding-top: 12px; }

/* 日期导航 */
.date-nav { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.date-nav input[type=date] {
  flex: 1; min-width: 0; padding: 9px 10px; font-size: 15px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--text);
}
.save-status { color: var(--text-3); transition: color .2s; }
.save-status.on { color: var(--green-dark); font-weight: 600; }

/* 分段选择（大按钮单选） */
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 64px; min-height: 44px; padding: 10px 6px; font-size: 14px; font-weight: 600;
  border: 1.5px solid var(--line); background: #fff; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-2);
  transition: all .15s;
}
.seg button:active { transform: scale(.96); }
.seg button.on { border-color: var(--green); background: var(--green-soft); color: var(--green-dark); }
/* "未记录/没喝"等中性选项选中态：灰色，不误报为"合规" */
.seg button.on[data-v=""] { border-color: var(--line); background: #f0f1ef; color: var(--text-2); }
/* danger 组：最后一个选项是违规态（喝了/今天疼/晚了/没做） */
.seg.seg-danger button.on:last-child:not([data-v=""]) { border-color: var(--red); background: var(--red-soft); color: var(--red); }
/* 按取值定调：酒精/防线三档 */
.seg button.on[data-v="lte2"], .seg button.on[data-v="ok"] { border-color: var(--amber); background: var(--amber-soft); color: var(--amber); }
.seg button.on[data-v="over"], .seg button.on[data-v="loss"] { border-color: var(--red); background: var(--red-soft); color: var(--red); }

/* ---------- 今日页快速打卡 ---------- */
.quick-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 2px; border-bottom: 1px solid var(--line-soft);
}
.quick-row:last-child { border-bottom: none; }
.q-label { flex: 1; font-size: 14.5px; font-weight: 600; }
.q-state { font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.q-state.good { color: var(--green-dark); font-weight: 700; }

.mini-seg { display: flex; gap: 6px; }
.mini-seg button {
  min-height: 38px; padding: 6px 12px; font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--line); background: #fff; border-radius: 10px;
  color: var(--text-3); cursor: pointer; transition: all .15s; white-space: nowrap;
}
.mini-seg button:active { transform: scale(.94); }
.mini-seg button.on { border-color: var(--green); background: var(--green-soft); color: var(--green-dark); }
.mini-seg.mini-danger button.on:last-child,
.mini-seg.mini-urge button.on[data-v="loss"] { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.mini-seg.mini-urge button.on[data-v="ok"] { border-color: var(--amber); background: var(--amber-soft); color: var(--amber); }

.meal-dots { display: flex; gap: 6px; }
.meal-dot {
  width: 46px; min-height: 40px; border: 1.5px solid var(--line); border-radius: 10px;
  background: #fff; cursor: pointer; font-size: 12px; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1.2; transition: all .15s;
}
.meal-dot i { font-style: normal; font-size: 13px; }
.meal-dot:active { transform: scale(.94); }
.meal-dot.good { border-color: var(--green); background: var(--green-soft); color: var(--green-dark); }
.meal-dot.bad { border-color: var(--red); background: var(--red-soft); color: var(--red); }

/* 锚定时刻表 */
.anchor-row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 9px 2px; border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}
.anchor-row:last-child { border-bottom: none; }
.anchor-t { width: 58px; flex-shrink: 0; color: var(--text-3); font-weight: 600; font-size: 12.5px; }
.anchor-text { flex: 1; color: var(--text-2); }
.anchor-row.past { opacity: .55; }
.anchor-row.now { background: var(--green-soft); margin: 0 -8px; padding: 9px 8px; border-radius: 10px; border-bottom-color: transparent; }
.anchor-row.now .anchor-text { color: var(--green-dark); font-weight: 600; }

/* 里程碑庆祝卡 */
.celebrate {
  display: flex; gap: 12px; align-items: center;
  border: 1.5px solid #f0c96a;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  box-shadow: 0 4px 16px rgba(180, 83, 9, .12);
}
.celebrate-ico { font-size: 30px; animation: bounce 1.2s ease infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-5px); } }
.celebrate-body { font-size: 14px; color: #7c4a03; }

.startup-card { border: 1.5px solid var(--green); background: linear-gradient(180deg, #f2fcf5, #fff); }
.tappable { cursor: pointer; transition: transform .1s; }
.tappable:active { transform: scale(.97); }
.num-unit { font-size: 15px; font-weight: 600; color: var(--text-3); margin-left: 3px; }

/* ---------- 清单勾选项 ---------- */
.check-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 4px; border-bottom: 1px solid var(--line-soft); cursor: pointer;
  min-height: 48px;
}
.check-item:last-child { border-bottom: none; }
.check-box {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  border: 2px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #fff; transition: all .18s;
}
.check-item.done .check-box { background: var(--green); border-color: var(--green); }
.check-item.bad .check-box { background: var(--red); border-color: var(--red); }
.check-item .check-label { flex: 1; font-size: 15px; }
.check-item.done .check-label { color: var(--text-3); }
.check-hint { font-size: 11px; color: var(--text-3); }

/* ---------- 状态条 / 徽章 ---------- */
.streak-card { text-align: center; padding: 18px 14px; }
.streak-num {
  font-size: 40px; font-weight: 800; color: var(--green); line-height: 1.1;
  font-variant-numeric: tabular-nums; letter-spacing: -.5px;
}
.streak-card.warn .streak-num { color: var(--red); }
.streak-label { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}
.badge-green { background: var(--green-soft); color: var(--green-dark); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-gray { background: #f0f1ef; color: var(--text-2); }
.good { color: var(--green-dark); font-weight: 700; }
.bad { color: var(--red); font-weight: 700; }

/* ---------- 提示条 ---------- */
.notice {
  border-radius: var(--radius-sm); padding: 11px 13px; font-size: 13.5px;
  margin-bottom: 10px; line-height: 1.55;
  border: 1px solid transparent;
}
.notice-green { background: var(--green-soft); color: var(--green-dark); border-color: #c4e9d2; }
.notice-red { background: var(--red-soft); color: #b91c1c; border-color: #f3caca; }
.notice-amber { background: var(--amber-soft); color: #a16207; border-color: #f0dcae; }
.notice-blue { background: var(--blue-soft); color: #1d4ed8; border-color: #c3d6f5; }
.notice-link { cursor: pointer; }
.notice-link:active { opacity: .8; }

/* ---------- 表格 ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; color: var(--text-3); font-weight: 600; font-size: 12px; padding: 6px 8px; }
.tbl td { padding: 10px 8px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tr.today-row td { background: #f0fdf4; }

/* 周均值表 */
.wk-row {
  display: grid; grid-template-columns: 1.15fr 1fr .9fr .9fr .9fr .8fr .8fr;
  gap: 4px; padding: 10px 2px; font-size: 13px; align-items: center;
  border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums;
}
.wk-row:last-of-type { border-bottom: none; }
.wk-head { color: var(--text-3); font-size: 11.5px; font-weight: 600; padding: 6px 2px; }
.wk-now { background: var(--green-soft); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 10px; border-bottom-color: transparent; }

/* ---------- 里程碑 / 解锁树 ---------- */
.milestone-list { display: grid; gap: 8px; }
.milestone {
  display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 11px 12px;
  transition: all .2s;
}
.milestone.achieved { border-color: #e8c96e; background: linear-gradient(135deg, #fffdf2, #fdf6dd); }
.milestone .m-ico { font-size: 20px; }
.milestone .m-body { flex: 1; min-width: 0; }
.milestone .m-title { font-size: 14px; font-weight: 600; }
.milestone .m-date { font-size: 12px; color: var(--text-3); }

.tree-node {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 2px;
  border: 1.5px solid var(--line); background: #fff; position: relative;
}
.tree-node.current { border-color: var(--green); background: var(--green-soft); }
.tree-node.passed { border-color: var(--green); background: #fff; }
.tree-node.locked { opacity: .5; }
.tree-connector { width: 2px; height: 10px; background: var(--line); margin: 0 0 0 26px; }
.tree-level { font-weight: 600; font-size: 14px; flex: 1; }

/* ---------- 方案页手风琴 ---------- */
.acc {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--line-soft); box-shadow: var(--shadow);
  margin-bottom: 10px; overflow: hidden;
}
.acc summary {
  list-style: none; cursor: pointer; user-select: none;
  padding: 15px 16px; font-size: 15px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  transition: background .15s; min-height: 52px;
}
.acc summary::-webkit-details-marker { display: none; }
.acc summary::after {
  content: '›'; margin-left: auto; color: var(--text-3);
  font-size: 20px; transform: rotate(90deg); transition: transform .2s;
}
.acc:not([open]) summary::after { transform: rotate(0deg); }
.acc summary:active { background: var(--line-soft); }
.acc-body {
  padding: 2px 16px 16px; font-size: 14px; color: var(--text-2);
  border-top: 1px solid var(--line-soft);
}
.plan-h { font-weight: 700; color: var(--text); font-size: 13.5px; margin: 14px 0 6px; }
.plan-list { padding-left: 20px; display: grid; gap: 6px; margin: 6px 0; }
.plan-list li { line-height: 1.6; }
.plan-list b { color: var(--text); }

/* 器械清单 */
.gear-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--line-soft);
  cursor: pointer; min-height: 52px;
}
.gear-row:last-of-type { border-bottom: none; }
.gear-row .check-box { width: 24px; height: 24px; }
.gear-row.has .check-box { background: var(--green); border-color: var(--green); }
.gear-body { flex: 1; min-width: 0; }
.gear-name { font-size: 14px; font-weight: 600; }
.gear-row.has .gear-name { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--green); }
.gear-meta { font-size: 12px; color: var(--text-3); }

/* ---------- 图表 ---------- */
.chart-box { width: 100%; height: 240px; }
.chart-box.tall { height: 300px; }

/* ---------- 照片对比 ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 10px; }
.photo-item { position: relative; border-radius: var(--radius-sm); overflow: hidden; background: var(--line); }
.photo-item img { width: 100%; height: 140px; object-fit: cover; display: block; }
.photo-item .p-meta {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; padding: 3px 6px;
}
.photo-item .p-del {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px;
  border-radius: 50%; background: rgba(0, 0, 0, .5); color: #fff; border: none; font-size: 12px;
}
.photo-item.selected { outline: 3px solid var(--green); }

/* ---------- 底部导航（6 项） ---------- */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line-soft);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: none; border: none; padding: 7px 0 6px; cursor: pointer;
  font-size: 10.5px; color: var(--text-3); position: relative; min-height: 52px;
  transition: color .15s;
}
.tab .tab-ico { font-size: 20px; transition: transform .18s; }
.tab::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%) scaleX(0);
  width: 26px; height: 3px; border-radius: 0 0 3px 3px; background: var(--green);
  transition: transform .2s;
}
.tab.active { color: var(--green-dark); font-weight: 700; }
.tab.active::before { transform: translateX(-50%) scaleX(1); }
.tab.active .tab-ico { transform: translateY(-1px) scale(1.08); }

/* ---------- Toast / Modal ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 60;
  background: rgba(24, 32, 44, .92); color: #fff;
  padding: 11px 20px; border-radius: 999px; font-size: 14px;
  max-width: 85vw; text-align: center;
  box-shadow: var(--shadow-pop);
  animation: toastIn .25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
#modal-mask {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 26, 34, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 560px) { #modal-mask { align-items: center; padding: 20px; } }
#modal-box {
  background: #fff; border-radius: 20px 20px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%; max-width: 460px; max-height: 85vh; overflow-y: auto;
  animation: sheetUp .28s cubic-bezier(.2, .9, .3, 1);
}
@media (min-width: 560px) {
  #modal-box { border-radius: 20px; padding: 22px; animation: popIn .25s ease; }
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.modal-title { font-size: 16px; font-weight: 800; margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---------- 桌面端微调 ---------- */
@media (min-width: 700px) {
  #tabbar { justify-content: center; }
  .tab { flex: 0 1 130px; }
  .grid-desktop-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .grid-desktop-2 > .card { margin-bottom: 0; }
  .grid-desktop-2 .section-title { margin-top: 20px; }
  .chart-box { height: 280px; }
}

.empty-tip { text-align: center; color: var(--text-3); font-size: 13px; padding: 24px 0; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.text-center { text-align: center; }
.small { font-size: 12px; color: var(--text-2); }

/* 数字统一等宽 */
.streak-num, .q-state, .wk-row { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
