:root {
  --primary: #D85A30;
  --bg: #FBFAF7;
  --card: #FFFFFF;
  --text: #2C2C2A;
  --muted: #8A8983;
  --border: rgba(44,44,42,.10);
  --border-strong: rgba(44,44,42,.18);
  --teal: #0F6E56;
  --teal-soft: #E1F5EE;
  --amber: #854F0B;
  --amber-soft: #FAEEDA;
  --accent-soft: #FAECE7;
  --blue: #185FA5;
  --blue-soft: #E6F1FB;
  --line: rgba(44,44,42,.10);
  --r: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: -.2px; }
.user-box { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.user-box span { color: var(--muted); max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 三栏标签 ---------- */
.tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  max-width: 680px; margin: 12px auto 0; padding: 4px;
  background: var(--card); border: 1px solid var(--border); border-radius: 11px;
  position: sticky; top: 55px; z-index: 20;
}
.tab {
  font-family: inherit; font-size: 14px; font-weight: 500; color: var(--muted);
  background: transparent; border: none; border-radius: 8px; padding: 9px 4px; cursor: pointer;
  transition: background .15s, color .15s;
}
.tab.on { background: var(--primary); color: #fff; }
.pane { display: none; }
.pane.on { display: block; }

/* ---------- 卡片 ---------- */
main { padding: 0 12px 60px; }
.card {
  max-width: 680px; margin: 12px auto 0; padding: 16px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--r);
}
.card h2 {
  font-size: 14px; margin: 0 0 12px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.card h2 .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); flex: none; }
.card h2 .sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- 表单 ---------- */
label { display: block; margin: 12px 0 0; font-size: 13px; font-weight: 500; }
input[type=email], input[type=password], input[type=number], input[type=date], textarea, select {
  width: 100%; margin-top: 6px; padding: 10px 11px; border: 1px solid var(--border-strong);
  border-radius: 9px; font-size: 15px; font-family: inherit; background: var(--bg);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); background: var(--card); }
textarea { resize: vertical; line-height: 1.6; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 label { margin-top: 0; }

/* ---------- 按钮 ---------- */
.btn {
  padding: 10px 16px; border: 1px solid var(--border-strong); background: var(--card);
  border-radius: 9px; font-size: 14px; font-weight: 500; cursor: pointer; font-family: inherit;
  transition: opacity .15s;
}
.btn:active { opacity: .7; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-ghost { border: none; color: var(--muted); background: transparent; }
.btn-block { width: 100%; margin-top: 10px; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* ---------- 登录弹层 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(44,44,42,.42); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: 100%; max-width: 360px; background: var(--card); border-radius: 16px; padding: 22px;
  max-height: 90vh; overflow-y: auto;
}
.modal h2 { font-size: 17px; margin: 0 0 6px; font-weight: 600; }
.modal .muted { margin: 0 0 6px; }
.modal .row { display: flex; gap: 10px; margin-top: 16px; }
.modal .row .btn { flex: 1; }
.msg { min-height: 18px; font-size: 13px; color: #B3261E; margin: 10px 0 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 34px;
  background: var(--text); color: #fff; font-size: 14px; padding: 11px 18px;
  border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 200;
  max-width: 88vw; text-align: center;
}
.toast.show { opacity: .95; }

.hidden { display: none !important; }

/* ---------- 今日状态条 ---------- */
.todaybar { padding: 15px 16px; }
.tb { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tb-l .k, .tb-r .k { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.tb-l .v { font-size: 20px; font-weight: 600; letter-spacing: -.4px; font-variant-numeric: tabular-nums; }
.tb-l .v small, .tb-r .v small { font-size: 13px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.tb-r { text-align: right; }
.tb-r .v { font-size: 20px; font-weight: 600; color: var(--primary); letter-spacing: -.4px; font-variant-numeric: tabular-nums; }
.tb-tip {
  font-size: 12px; color: var(--muted); margin-top: 11px; padding-top: 11px;
  border-top: 1px solid var(--line); line-height: 1.65;
}
.tb-tip b { color: var(--text); font-weight: 600; }

/* ---------- 步骤 ---------- */
.steps { list-style: none; margin: 0; padding: 0; }
.step { display: flex; align-items: flex-start; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.step:last-of-type { border-bottom: none; }
.step .sbox {
  flex: none; width: 22px; height: 22px; border: 1.5px solid var(--border-strong); border-radius: 7px;
  margin-top: 1px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.step.done .sbox { background: var(--teal); border-color: var(--teal); }
.step.done .sbox::after {
  content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 1.8px 1.8px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.step .sbody { flex: 1; min-width: 0; }
.step .st { font-size: 14px; font-weight: 500; display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.step .st em { font-style: normal; font-size: 11px; color: var(--muted); font-weight: 400; }
.step .sd { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.55; }
.step .sd b { color: var(--text); font-weight: 500; }
.step.done .st { color: var(--muted); text-decoration: line-through; }
.stime { flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
.stotal {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.stotal b { font-size: 15px; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.sopt {
  font-size: 12px; color: var(--muted); margin-top: 10px; padding: 10px 12px;
  background: var(--bg); border-radius: 9px; line-height: 1.65;
}
.sopt b { color: var(--text); font-weight: 500; }

/* ---------- 计划 vs 实际 ---------- */
.vsrow {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  background: var(--bg); border-radius: 11px; padding: 11px 13px; margin-bottom: 8px;
}
.vsside { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.vsside .vs-k { font-size: 11px; color: var(--muted); }
.vsside .vs-v { font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -.2px; }
.vsside.now { text-align: right; }
.vsarrow { color: var(--muted); font-size: 15px; }
.vsfill { position: relative; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 10px; }
.vsfill i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--teal); }
.vsfill i.low { background: var(--primary); }
.vsfill i.over { background: var(--blue); }
.vslabel { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 5px; }
.vsnote {
  font-size: 12px; line-height: 1.65; padding: 10px 12px; border-radius: 9px;
  background: var(--bg); color: var(--muted); margin-bottom: 10px;
}
.vsnote.ok { background: var(--teal-soft); color: var(--teal); }
.vsnote.warn { background: var(--accent-soft); color: var(--primary); }
.vsnote b { font-weight: 600; }

/* ---------- 周期 ---------- */
.restbox { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.rest-opt {
  border: 1px solid var(--border-strong); border-radius: 9px; padding: 9px 4px;
  text-align: center; cursor: pointer; background: var(--bg);
}
.rest-opt .rn { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.rest-opt .rl { font-size: 11px; color: var(--muted); margin-top: 1px; }
.rest-opt.on { border-color: var(--teal); background: var(--teal-soft); }
.rest-opt.on .rl { color: var(--teal); }
.rest-warn {
  font-size: 12px; color: var(--primary); background: var(--accent-soft);
  border-radius: 8px; padding: 9px 11px; margin-top: 10px; line-height: 1.65; display: none;
}
.rest-warn.show { display: block; }
.rest-warn b { font-weight: 600; }
.loadbox { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.loadbox > div { background: var(--bg); border-radius: 10px; padding: 11px 12px; }
.loadbox span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.loadbox b { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.4px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.65; }

/* ---------- 历史列表 ---------- */
.log-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.log-item:last-child { border-bottom: none; }
.log-date {
  flex: none; width: 46px; font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums; text-align: left;
}
.log-main { flex: 1; min-width: 0; font-size: 13.5px; }
.log-main .l2 { color: var(--text); }
.log-main .l3 { font-size: 11px; color: var(--muted); margin-top: 2px; }
.log-rep {
  flex: none; font-size: 15px; font-weight: 500; color: var(--text);
  font-variant-numeric: tabular-nums; text-align: right;
}
.log-rep small { display: block; font-size: 10px; color: var(--muted); font-weight: 400; }
.log-edit {
  flex: none; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--muted); cursor: pointer; font-size: 13px; padding: 0;
}
.log-edit:active { background: var(--bg); }

/* ---------- 方案折叠 ---------- */
.fold:not(.open) .fold-body { display: none; }
.fold-toggle {
  width: 100%; font-family: inherit; font-size: 13px; color: var(--muted);
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
  padding: 8px; cursor: pointer; margin-top: 4px;
}
.plan { border-color: rgba(216,90,48,.22); }
.plan ol { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.75; color: var(--muted); }
.plan ol li { margin-bottom: 8px; }
.plan ol li b { color: var(--text); font-weight: 600; }
.plan .warn {
  font-size: 12px; color: var(--primary); margin-top: 12px; padding-top: 12px;
  border-top: 1px solid rgba(216,90,48,.18); line-height: 1.65;
}
.plan .warn b { font-weight: 600; }
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.diff-col { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; }
.diff-col.on { background: var(--teal-soft); border-color: rgba(15,110,86,.25); }
.diff-t { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.diff-col.on .diff-t { color: var(--teal); }
.diff-l { font-size: 12px; line-height: 1.55; color: var(--muted); }
.bw { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.bw input { width: 104px; background: var(--bg); }

/* ---------- AI 教练 ---------- */
.coach-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.coach-q {
  font-family: inherit; font-size: 12.5px; text-align: left; padding: 9px 11px;
  background: var(--amber-soft); color: var(--amber); border: 1px solid rgba(133,79,11,.18);
  border-radius: 9px; cursor: pointer; line-height: 1.4;
}
.coach-q:active { opacity: .7; }
.coach-input { display: flex; gap: 8px; align-items: flex-end; }
.coach-input textarea { flex: 1; margin-top: 0; }
.coach-input .btn { flex: none; }
.coach-log { margin-top: 12px; }
.coach-msg { margin-bottom: 10px; font-size: 13.5px; line-height: 1.7; }
.coach-msg .who { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.coach-msg .body {
  padding: 10px 12px; border-radius: 10px; white-space: pre-wrap;
  background: var(--bg); color: var(--text);
}
.coach-msg.me .body { background: var(--accent-soft); color: var(--text); }
.coach-badge {
  display: inline-block; margin-bottom: 6px; padding: 2px 8px; font-size: 11px;
  border-radius: 999px; background: var(--amber-soft); color: var(--amber);
}
.coach-quota { font-size: 11px; color: var(--muted); margin-top: 8px; text-align: right; }

/* ---------- 图表 ---------- */
.chart-wrap { position: relative; }
.chart-wrap canvas { width: 100%; display: block; }
.chart-x { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 6px; }

/* ---------- 编辑横幅 ---------- */
.edit-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--amber-soft); color: var(--amber); border-radius: 9px;
  padding: 10px 12px; margin-bottom: 12px; font-size: 13px;
}
.edit-banner button {
  font-family: inherit; font-size: 12px; background: transparent; border: none;
  color: var(--amber); text-decoration: underline; cursor: pointer; padding: 0;
}

/* ---------- 未同步提示 ---------- */
.unsync-bar {
  background: var(--amber-soft); color: var(--amber); border-radius: 9px;
  padding: 10px 12px; margin-bottom: 12px; font-size: 13px; line-height: 1.6;
}
.unsync-bar b { font-weight: 600; }

@media (max-width: 480px) {
  .diff { grid-template-columns: 1fr; }
  .coach-quick { grid-template-columns: 1fr; }
}
