/* dite —— 手机上用，所以一切按单手拇指操作设计：
   打卡按钮做到 64px 高（拇指盲按也不会点错），底部导航贴着安全区。
   桌面浏览器打开时限宽 520px 居中，纯粹是为了在电脑上调试时不难看。 */

:root {
  --bg: #0f1318;
  --card: #181e26;
  --card2: #1f2731;
  --line: #2a333f;
  --fg: #e8edf3;
  --dim: #8b97a6;
  --dim2: #616d7c;
  --ok: #3ecf8e;          /* 打卡完成 */
  --ok-d: #1d5c41;
  --warn: #e8b64c;
  --accent: #5aa9ff;
  --pro: #c07cf0;         /* 蛋白质专用色，全站统一 */
  --r: 14px;
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--fg);
  font: 15px/1.6 -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
  /* 全屏 PWA 里禁掉橡皮筋回弹，否则整页会跟着手指飘 */
  overscroll-behavior: none;
}

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; }

/* ---------- 顶部：连续达标天数 ---------- */
#hd {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 14px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
  background: rgba(15, 19, 24, .92); backdrop-filter: blur(12px);
}
#streak-n { font-size: 40px; font-weight: 700; line-height: 1; letter-spacing: -1px; }
#streak-t { font-size: 12px; color: var(--dim); margin-top: 4px; }
.hd-side { text-align: right; font-size: 12px; color: var(--dim); line-height: 1.7; }
.sync { color: var(--dim2); font-size: 11px; }
.sync.bad { color: var(--warn); }
.sync.ok { color: var(--ok); }

/* ---------- 主体 ---------- */
#view { padding: 16px 14px 96px; }

.sec { margin-bottom: 22px; }
.sec-t {
  font-size: 12px; color: var(--dim2); letter-spacing: 1.5px;
  margin: 0 4px 9px; text-transform: uppercase;
}

.card { background: var(--card); border-radius: var(--r); padding: 14px; }
.card + .card { margin-top: 10px; }

/* ---------- 打卡格子 ---------- */
.slots { display: flex; flex-direction: column; gap: 8px; }
.slot {
  display: flex; align-items: center; gap: 12px;
  min-height: 64px; padding: 0 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); cursor: pointer;
  transition: background .15s, border-color .15s;
}
.slot.done { background: var(--ok-d); border-color: var(--ok); }
.slot-tick {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  border: 2px solid var(--dim2);
  display: grid; place-items: center; font-size: 15px; color: transparent;
}
.slot.done .slot-tick { border-color: var(--ok); background: var(--ok); color: #06110b; }
.slot-mid { flex: 1; min-width: 0; }
.slot-l { font-size: 15px; font-weight: 600; }
.slot-l small { font-weight: 400; color: var(--dim); margin-left: 7px; font-size: 12px; }
.slot-d {
  font-size: 13px; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.slot.done .slot-d { color: #a9d9c2; }
.slot-n { flex: none; font-size: 11px; color: var(--dim2); text-align: right; line-height: 1.4; }
.slot-n b { display: block; color: var(--pro); font-size: 13px; font-weight: 600; }

/* 换菜 / 看做法的小按钮，从打卡区域里独立出来，避免手滑把「换菜」按成「打卡」 */
.slot-act {
  flex: none; padding: 8px 10px; margin-right: -6px;
  background: none; border: none; color: var(--dim2); font-size: 18px;
}

/* ---------- 今日总计 ---------- */
.tot { display: flex; gap: 10px; }
.tot > div { flex: 1; background: var(--card); border-radius: var(--r); padding: 12px 14px; }
.tot b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.5px; }
.tot span { font-size: 11px; color: var(--dim2); }
.tot .p b { color: var(--pro); }
.bar { height: 4px; background: var(--card2); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.tot .p .bar > i { background: var(--pro); }

/* ---------- 训练 ---------- */
.ex { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.ex:first-child { border-top: 0; }
.ex-n { font-weight: 600; font-size: 14px; }
.ex-c { font-size: 12px; color: var(--dim); margin-top: 2px; }
.ex-s { flex: none; color: var(--accent); font-size: 13px; font-variant-numeric: tabular-nums; }
.sup { font-size: 10px; color: var(--warn); border: 1px solid var(--warn); border-radius: 4px; padding: 0 4px; margin-left: 6px; vertical-align: 1px; }

/* ---------- 食材 / 采购清单 ---------- */
.ing { display: flex; justify-content: space-between; padding: 8px 0; font-size: 14px; border-top: 1px solid var(--line); }
.ing:first-child { border-top: 0; }
.ing i { color: var(--dim); font-style: normal; font-variant-numeric: tabular-nums; }

.shop-i {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 4px; border-top: 1px solid var(--line); cursor: pointer;
}
.shop-i:first-child { border-top: 0; }
.shop-i .bx {
  width: 21px; height: 21px; flex: none; border: 2px solid var(--dim2); border-radius: 5px;
  display: grid; place-items: center; font-size: 13px; color: transparent;
}
.shop-i.got .bx { background: var(--ok); border-color: var(--ok); color: #06110b; }
.shop-i.got .nm { color: var(--dim2); text-decoration: line-through; }
.shop-i .nm { flex: 1; }
.shop-i .g { color: var(--dim); font-variant-numeric: tabular-nums; font-size: 13px; }

/* ---------- 体重 ---------- */
.wt-in { display: flex; gap: 8px; }
.wt-in input {
  flex: 1; background: var(--card2); border: 1px solid var(--line); color: var(--fg);
  border-radius: 10px; padding: 13px 14px; font-size: 17px; font-variant-numeric: tabular-nums;
}
.wt-in button { flex: none; padding: 0 20px; border-radius: 10px; border: 0; background: var(--accent); color: #04121f; font-size: 15px; font-weight: 600; }
.wt-big { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.wt-big b { font-size: 34px; font-weight: 700; letter-spacing: -1px; }
.wt-big i { font-style: normal; font-size: 13px; color: var(--dim); }
.dn { color: var(--ok); } .up { color: var(--warn); }

/* ---------- 菜谱库 ---------- */
.dish {
  display: flex; align-items: center; gap: 10px; padding: 12px 4px;
  border-top: 1px solid var(--line); cursor: pointer;
}
.dish:first-child { border-top: 0; }
.dish-m { flex: 1; min-width: 0; }
.dish-n { font-size: 14px; font-weight: 600; }
.dish-t { font-size: 11px; color: var(--dim2); margin-top: 3px; }
.dish-k { flex: none; text-align: right; font-size: 11px; color: var(--dim2); line-height: 1.45; }
.dish-k b { display: block; color: var(--pro); font-size: 13px; }
.tag { display: inline-block; background: var(--card2); color: var(--dim); border-radius: 4px; padding: 1px 5px; margin-right: 4px; font-size: 10px; }

/* ---------- 底部导航 ---------- */
#tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6;
  max-width: 520px; margin: 0 auto; display: flex;
  background: rgba(15, 19, 24, .94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs button {
  flex: 1; padding: 13px 0 12px; background: none; border: 0;
  color: var(--dim2); font-size: 12px;
}
#tabs button.on { color: var(--fg); font-weight: 600; }
#tabs button.on::before {
  content: ''; display: block; width: 18px; height: 2px; background: var(--accent);
  border-radius: 1px; margin: 0 auto 6px; margin-top: -8px;
}
#tabs button:not(.on)::before { content: ''; display: block; height: 2px; margin: 0 auto 6px; margin-top: -8px; }

/* ---------- 底部升起的面板 ---------- */
#sheet { position: fixed; inset: 0; z-index: 20; }
#sheet.hide { display: none; }
#sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); }
#sheet-box {
  position: absolute; bottom: 0; left: 0; right: 0;
  max-width: 520px; margin: 0 auto;
  background: var(--bg); border-radius: 18px 18px 0 0;
  max-height: 86vh; display: flex; flex-direction: column;
  border-top: 1px solid var(--line);
}
#sheet-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px 12px; border-bottom: 1px solid var(--line); flex: none;
}
#sheet-title { font-size: 16px; font-weight: 600; }
#sheet-x { background: none; border: 0; color: var(--dim); font-size: 14px; padding: 4px 0 4px 12px; }
#sheet-body {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 18px calc(env(safe-area-inset-bottom) + 26px);
}

/* 做法步骤：序号用悬挂缩进，长句子换行后不会缩到序号底下 */
.steps { counter-reset: s; margin: 0; padding: 0; list-style: none; }
.steps li {
  counter-increment: s; position: relative;
  padding: 0 0 12px 27px; font-size: 14px; line-height: 1.65;
}
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 1px;
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--card2); color: var(--dim); font-size: 11px;
  display: grid; place-items: center; font-weight: 600;
}
.steps b { color: var(--warn); font-weight: 600; }

.pc { font-size: 13px; line-height: 1.65; margin: 3px 0; }
.pc.p::before { content: '优 '; color: var(--ok); font-weight: 600; }
.pc.c::before { content: '劣 '; color: var(--warn); font-weight: 600; }
.note { font-size: 13px; color: var(--dim); line-height: 1.65; }
.hint { font-size: 12px; color: var(--dim2); line-height: 1.6; margin: 8px 4px 0; }
.pick { padding: 13px 4px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; cursor: pointer; }
.pick:first-child { border-top: 0; }
.pick.cur { color: var(--accent); }
.pick .dot { width: 7px; height: 7px; border-radius: 50%; background: transparent; flex: none; }
.pick.cur .dot { background: var(--accent); }
.dbl { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; background: var(--card); border-radius: var(--r); margin-top: 10px; }
.sw { width: 46px; height: 28px; flex: none; border-radius: 14px; background: var(--card2); border: 1px solid var(--line); position: relative; transition: background .18s; }
.sw::after { content: ''; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--dim); transition: transform .18s, background .18s; }
.sw.on { background: var(--ok-d); border-color: var(--ok); }
.sw.on::after { transform: translateX(18px); background: var(--ok); }
