/* ===== 我的增肌助手 · 样式（移动端优先）===== */
:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1f2933;
  --ink-soft: #5b6573;
  --line: #e3e8ef;
  --primary: #16a34a;
  --primary-dark: #15803d;
  --primary-soft: #dcfce7;
  --accent: #0ea5e9;
  --warn: #ef4444;
  --warn-soft: #fee2e2;
  --gold: #f59e0b;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(15, 23, 42, .06);
  --tap: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: calc(72px + var(--safe-b));
  -webkit-text-size-adjust: 100%;
}

/* 顶部 */
.app-header {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #fff;
}
.app-header-inner {
  max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
}
.app-title { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: .5px; }
.save-badge {
  font-size: 12px; background: rgba(255,255,255,.15);
  color: #d1fae5; padding: 4px 10px; border-radius: 999px;
}
.save-badge.err { background: rgba(239,68,68,.25); color: #fecaca; }

/* 顶部常驻警告横幅（存储不可用 / 数据损坏） */
.warn-banner {
  background: #fef2f2; color: #b91c1c; border-bottom: 1px solid #fecaca;
  font-size: 13px; line-height: 1.5; padding: 10px 14px;
}
.warn-banner[hidden] { display: none; }

/* 主区域 */
.main { max-width: 720px; margin: 0 auto; padding: 14px 14px 20px; }
.view { display: block; }
.view[hidden] { display: none; }

/* 卡片 */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 16px; margin: 0 0 10px; }
.card h3 { font-size: 15px; margin: 0 0 8px; color: var(--ink); }

/* 首页统计网格 */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.stat .label { font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.stat .value { font-size: 22px; font-weight: 700; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--ink-soft); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 16px; font-weight: 600; cursor: pointer; width: 100%;
  transition: transform .05s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: #fff; border-color: var(--warn); color: var(--warn); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-sm { min-height: 40px; font-size: 14px; padding: 0 12px; width: auto; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* 标签 */
.badge {
  display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-dark); margin-left: 6px;
}
.badge-opt { background: #fef3c7; color: #b45309; }
.badge-done { background: var(--primary-soft); color: var(--primary-dark); }
.badge-wait { background: #e5e7eb; color: #6b7280; }
.badge-active { background: #dbeafe; color: #1d4ed8; }

/* 动作卡片（训练列表） */
.ex-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  margin-bottom: 10px; background: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.ex-card:active { background: #f8fafc; }
.ex-card .ex-name { font-size: 16px; font-weight: 600; }
.ex-card .ex-meta { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.ex-card .ex-right { text-align: right; font-size: 13px; color: var(--ink-soft); }

/* 输入 */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.input, .select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; font-size: 16px;
  background: #fff; color: var(--ink); font-family: inherit;
}
textarea { min-height: 72px; resize: vertical; }
.input:focus, .select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

/* 每组录入行 */
.set-row {
  display: grid; grid-template-columns: 28px 1fr 1fr auto auto; gap: 8px;
  align-items: center; margin-bottom: 10px;
}
.set-row .set-idx { font-size: 14px; color: var(--ink-soft); text-align: center; }
.set-row .input { min-height: 44px; text-align: center; }
.set-done-btn {
  min-height: 44px; width: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-soft); font-size: 18px; cursor: pointer;
}
.set-done-btn.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.set-del-btn {
  min-height: 44px; width: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--warn); font-size: 18px; cursor: pointer;
}
.set-row { grid-template-columns: 24px 1fr 1fr auto auto; }
.set-cell { position: relative; display: flex; align-items: center; }
.set-cell .input { width: 100%; padding-right: 30px; }
.set-unit { position: absolute; right: 10px; font-size: 12px; color: var(--ink-soft); pointer-events: none; }
.set-head { display: grid; grid-template-columns: 24px 1fr 1fr auto auto; gap: 8px; font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; }
.set-head span:nth-child(1) { text-align: center; }
.set-status { font-size: 13px; color: var(--primary-dark); background: var(--primary-soft); border-radius: 8px; padding: 6px 10px; margin-bottom: 10px; font-weight: 600; }

/* 首页计划选择器 */
.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.plan-chip { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; text-align: left; }
.plan-chip:active { background: #f8fafc; }
.plan-chip-name { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.plan-chip-sub { font-size: 12px; color: var(--ink-soft); }

/* 自由训练构建器 */
.free-ex { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: #fff; }
.free-ex-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.free-ex-head .ex-name { font-size: 16px; font-weight: 600; }
.free-ex-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.free-ex-fields label.muted { margin-bottom: 4px; }

/* 底部导航 */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); box-shadow: 0 -2px 10px rgba(15,23,42,.06);
}
.nav-btn {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 8px 0 6px; color: var(--ink-soft); font-size: 12px;
}
.nav-btn .nav-ico { font-size: 20px; line-height: 1; }
.nav-btn.active { color: var(--primary); }
.nav-btn.active .nav-ico { transform: translateY(-1px); }

/* 浮层（动作编辑） */
.overlay {
  position: fixed; inset: 0; z-index: 40; background: var(--bg);
  display: flex; flex-direction: column;
}
.overlay[hidden] { display: none; }
.overlay-inner { flex: 1; overflow-y: auto; padding: 14px 14px 90px; max-width: 720px; margin: 0 auto; width: 100%; }
.overlay-head {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
}
.overlay-head h2 { font-size: 18px; margin: 0; flex: 1; }
.overlay-foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  background: #fff; border-top: 1px solid var(--line); padding: 10px 14px calc(10px + var(--safe-b));
  display: flex; gap: 10px; max-width: 720px; margin: 0 auto;
}

/* 上次成绩明细 */
.last-rec { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; }
.last-rec-h { font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.last-rec-set { display: inline-block; font-size: 12px; color: var(--ink-soft); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; margin: 0 6px 6px 0; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-mask[hidden] { display: none; }
.modal {
  background: #fff; border-radius: var(--radius); width: 100%; max-width: 420px;
  padding: 18px; box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.modal h3 { margin: 0 0 10px; font-size: 17px; }
.modal p { margin: 0 0 14px; color: var(--ink-soft); font-size: 14px; }
.modal .btn-row { margin-top: 6px; }

/* 轻提示 */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  z-index: 60; background: #0f172a; color: #fff; padding: 10px 18px;
  border-radius: 999px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.3);
  max-width: 90vw; text-align: center;
}
.toast[hidden] { display: none; }
.toast.err { background: var(--warn); }

/* 历史/列表 */
.row-item {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  margin-bottom: 10px; background: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.row-item:active { background: #f8fafc; }
.row-item .ri-title { font-weight: 600; }
.row-item .ri-sub { font-size: 13px; color: var(--ink-soft); margin-top: 3px; }

/* 进度条 */
.progress {
  height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; margin-top: 8px;
}
.progress > span { display: block; height: 100%; background: var(--primary); }

/* 表格（分析/历史） */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: right; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl th { color: var(--ink-soft); font-weight: 600; }
.tbl tr.up td { background: #f0fdf4; }

/* 体重曲线 */
.chart-wrap { width: 100%; overflow-x: auto; }
.chart-wrap svg { display: block; width: 100%; height: 220px; }

/* 小工具 */
.muted { color: var(--ink-soft); font-size: 13px; }
.hr { height: 1px; background: var(--line); margin: 12px 0; border: none; }
.section-title { font-size: 15px; font-weight: 700; margin: 4px 0 10px; }
.note-box { background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 10px 12px; font-size: 13px; color: #92400e; }
.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 14px; cursor: pointer; }
.pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 电脑端略放宽 */
@media (min-width: 760px) {
  .main { padding-top: 22px; }
  .btn { width: auto; }
  .btn-block { width: 100%; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
