/* 每日健身打卡小程序 —— 样式 */
:root {
  --bg: #FBF6F2;
  --bg-soft: #F4EDE7;
  --surface: #FFFFFF;
  --surface-2: #FDFAF8;
  --ink: #2A2522;
  --ink-2: #554C46;
  --muted: #8C8177;
  --line: #EEE4DC;
  --primary: #E4664B;
  --primary-soft: #FDEDE7;
  --sage: #5F9E80;
  --sage-soft: #E8F2EC;
  --sage-2: #C8E2D4;
  --sage-3: #97C9AF;
  --amber: #DDA02F;
  --amber-soft: #FBF1DC;
  --blue: #4E7FA8;
  --blue-soft: #E9F1F7;
  --danger: #C0503E;
  --shadow: 0 2px 4px rgba(66,44,32,.04), 0 10px 28px -14px rgba(66,44,32,.18);
  --radius: 18px;
  --tab-h: 62px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17140F;
    --bg-soft: #201C17;
    --surface: #221E19;
    --surface-2: #2A251F;
    --ink: #F2EBE4;
    --ink-2: #D5CBC2;
    --muted: #9C9086;
    --line: #362F28;
    --primary: #F0805F;
    --primary-soft: #3A261E;
    --sage: #7CBE9C;
    --sage-soft: #22301F;
    --sage-2: #2E4033;
    --sage-3: #3F6B52;
    --amber: #E5B45C;
    --amber-soft: #33291A;
    --blue: #7FAFD6;
    --blue-soft: #1E2A33;
    --danger: #E08472;
    --shadow: 0 2px 4px rgba(0,0,0,.2), 0 12px 30px -16px rgba(0,0,0,.7);
  }
}

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

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Noto Sans SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.app {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 16px calc(var(--tab-h) + 30px);
  min-height: 100vh;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 2px 10px;
  background: linear-gradient(var(--bg) 72%, rgba(0,0,0,0));
  backdrop-filter: saturate(1.4) blur(6px);
}
.topbar h1 {
  font-size: 19px;
  margin: 0;
  font-weight: 600;
  letter-spacing: -.2px;
}
.topbar .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}
.topbar .grow { flex: 1; }
.streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
  padding: 6px 11px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.card.tight { padding: 13px 14px; }
.card.flat { box-shadow: none; background: var(--surface-2); }

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.card-head h2 {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
  flex: 1;
}
.card-head .hint { font-size: 12px; color: var(--muted); font-weight: 400; }

.section-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 22px 4px 9px;
  text-transform: uppercase;
}

/* ---------- 通用元素 ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.bold { font-weight: 600; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .06s ease, background .15s ease;
}
.btn:active { transform: scale(.975); }
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn.soft { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.btn.sage { background: var(--sage-soft); border-color: transparent; color: var(--sage); }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 10px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-2);
  white-space: nowrap;
}
.chip.primary { background: var(--primary-soft); color: var(--primary); }
.chip.sage { background: var(--sage-soft); color: var(--sage); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }

.divider { height: 1px; background: var(--line); margin: 13px -16px; }
.divider.in { margin: 13px 0; }

/* ---------- 进度环 ---------- */
.hero {
  display: flex;
  align-items: center;
  gap: 18px;
}
.ring { position: relative; width: 92px; height: 92px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .val {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ring .val b { font-size: 22px; font-weight: 600; line-height: 1.1; }
.ring .val span { font-size: 10.5px; color: var(--muted); }

.hero-info h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.hero-info .meta { font-size: 13px; color: var(--muted); }

/* ---------- 训练条目 ---------- */
.ex {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.ex:last-child { border-bottom: 0; padding-bottom: 2px; }
.ex .box {
  flex: none;
  width: 23px;
  height: 23px;
  border-radius: 8px;
  border: 1.8px solid var(--line);
  background: var(--surface);
  margin-top: 1px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 13px;
}
.ex.done .box {
  background: var(--sage);
  border-color: var(--sage);
  color: #fff;
}
.ex.done .name { text-decoration: line-through; color: var(--muted); }
.ex .name { font-weight: 500; }
.ex .desc { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.ex .gear-link {
  border: 0;
  background: none;
  color: var(--blue);
  font-size: 12px;
  font-family: inherit;
  padding: 0 0 0 2px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.block-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--sage);
  background: var(--sage-soft);
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  margin: 14px 0 2px;
}
.day-title { font-size: 15px; font-weight: 600; }
.rest-note {
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 13px;
  color: var(--ink-2);
}

/* ---------- 器械库 ---------- */
.gear-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.gear-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  border: 0;
  font-family: inherit;
  color: inherit;
  transition: transform .08s ease;
}
.gear-card:active { transform: scale(.98); }
.gear-card .thumb {
  background: var(--surface-2);
  border-radius: 11px;
  padding: 4px;
  margin-bottom: 8px;
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
}
.thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 11px;
}
.gear-card .gn { font-weight: 600; font-size: 14px; }
.gear-card .gd { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.eq { width: 100%; height: auto; display: block; }
.eq .m { stroke: var(--muted); stroke-width: 3.4; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.eq .m2 { stroke: var(--muted); stroke-width: 2; fill: none; stroke-linecap: round; opacity: .55; }
.eq .b { stroke: var(--ink); stroke-width: 3.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.eq .f { fill: var(--ink); stroke: none; }
.eq .a { stroke: var(--primary); stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-dasharray: 5 5; }
.eq .hl { fill: var(--primary); opacity: .18; }
.eq .pad { fill: var(--muted); opacity: .14; }

/* ---------- 居家：体态专项 / 动作库 ---------- */
.pos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.pos-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 12px;
  text-align: left;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}
.pos-card:active { transform: scale(.985); }
.pos-card .pi { font-size: 20px; line-height: 1; }
.pos-card .pn { font-weight: 600; margin-top: 7px; font-size: 14px; }
.pos-card .pb { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }

.creator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}
.creator:last-of-type { border-bottom: 0; }
.creator .ct { font-weight: 600; font-size: 13.5px; }
.creator .cd { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.45; }

.mv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.mv-item:last-child { border-bottom: 0; padding-bottom: 2px; }
.mv-item .mtitle { font-weight: 500; font-size: 13.5px; }
.mv-item .mdesc { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.45; }

/* ---------- 视频讲解 ---------- */
.vblock {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 12px;
  margin-top: 14px;
}
.vhead {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}
.vhint { font-size: 11px; color: var(--muted); font-weight: 400; }
.vitem {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--surface);
  border-radius: 11px;
  padding: 7px;
  margin-bottom: 7px;
  text-decoration: none;
  color: inherit;
}
.vitem:active { transform: scale(.99); }
.vthumb {
  width: 78px;
  height: 50px;
  flex: none;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-soft);
}
.vtxt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.vtxt b { font-size: 13px; font-weight: 500; line-height: 1.45; }
.vtxt i { font-style: normal; font-size: 11px; color: var(--blue); }
.vmore {
  display: block;
  font-size: 12px;
  color: var(--blue);
  text-decoration: none;
  padding: 2px 2px 0;
}
.vtip { font-size: 11px; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.vbadge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 2px 8px;
  margin-top: 7px;
}

/* ---------- 弹层 ---------- */
.sheet-bg {
  position: fixed;
  inset: 0;
  background: rgba(28,20,14,.42);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes up { from { transform: translateY(26px); opacity: .4 } to { transform: none; opacity: 1 } }
.sheet {
  background: var(--surface);
  width: 100%;
  max-width: 700px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(24px + env(safe-area-inset-bottom));
  animation: up .22s ease;
}
@media (min-width: 640px) {
  .sheet-bg { align-items: center; }
  .sheet { border-radius: 22px; max-height: 84vh; margin: 0 16px; }
}
.sheet-grip {
  width: 38px; height: 4px; border-radius: 999px;
  background: var(--line); margin: 4px auto 14px;
}
.sheet h2 { font-size: 18px; margin: 0 0 4px; font-weight: 600; }
.sheet h3 { font-size: 14px; margin: 18px 0 6px; font-weight: 600; }

.steps { margin: 0; padding-left: 20px; }
.steps li { margin-bottom: 6px; font-size: 13.5px; }
.warn {
  background: var(--amber-soft);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 13px;
  margin-top: 14px;
}
.warn b { color: var(--amber); }

/* ---------- 饮食 ---------- */
.macro-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
}
.macro {
  background: var(--surface-2);
  border-radius: 13px;
  padding: 10px 4px;
}
.macro .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.macro .k { font-size: 11px; color: var(--muted); }

.meal { display: flex; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.meal:last-child { border-bottom: 0; }
.meal .ico {
  flex: none; width: 34px; height: 34px; border-radius: 11px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.meal .mt { font-weight: 600; font-size: 13.5px; display: flex; gap: 8px; align-items: baseline; }
.meal .mt em { font-style: normal; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.meal .md { font-size: 13px; color: var(--ink-2); margin-top: 2px; }

.food-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.food-col { background: var(--surface-2); border-radius: 13px; padding: 12px; }
.food-col h4 { margin: 0 0 7px; font-size: 13px; }
.food-col ul { margin: 0; padding-left: 17px; font-size: 12.5px; color: var(--ink-2); }
.food-col li { margin-bottom: 3px; }

/* ---------- 数据页 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 12px 10px; }
.stat .v { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.stat .k { font-size: 11.5px; color: var(--muted); }

.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.heat .cell {
  aspect-ratio: 1;
  border-radius: 6px;
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--muted);
}
.heat .cell.wk { background: transparent; font-size: 10px; color: var(--muted); }
.heat .cell.lv1 { background: var(--sage-soft); color: var(--sage); }
.heat .cell.lv2 { background: var(--sage-2); color: var(--ink); }
.heat .cell.lv3 { background: var(--sage-3); color: #fff; }
.heat .cell.lv4 { background: var(--sage); color: #fff; }
.heat .cell.today { outline: 2px solid var(--primary); outline-offset: 1px; }
.heat .cell.future { opacity: .35; }

.chart-wrap { margin-top: 6px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.chart .area { fill: var(--primary); opacity: .08; }
.chart .dot { fill: var(--surface); stroke: var(--primary); stroke-width: 2.4; }
.chart .goal { stroke: var(--sage); stroke-width: 1.6; stroke-dasharray: 5 4; }
.chart .goal-t { fill: var(--sage); font-size: 10px; }

/* ---------- 表格 ---------- */
table.tb { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tb th, table.tb td { text-align: left; padding: 9px 8px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tb th { font-size: 11.5px; color: var(--muted); font-weight: 600; }
table.tb tr:last-child td { border-bottom: 0; }
table.tb td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  -webkit-appearance: none;
  appearance: none;
}
textarea { min-height: 74px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.inline-fields { display: flex; gap: 10px; }
.inline-fields .field { flex: 1; margin-bottom: 0; }

.quick { display: flex; gap: 7px; flex-wrap: wrap; }
.quick button {
  flex: 1;
  min-width: 62px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 11px;
  padding: 9px 4px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.quick button.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px) saturate(1.6);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.tabbar .inner { display: flex; width: 100%; max-width: 700px; }
.tabs {
  flex: 1;
  border: 0;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 10.5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  padding: 6px 0;
}
.tabs .ic { font-size: 18px; line-height: 1; }
.tabs.on { color: var(--primary); font-weight: 600; }

/* ---------- 计时器 ---------- */
.timer-face {
  font-size: 56px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  margin: 10px 0 4px;
}
.timer-face.run { color: var(--primary); }

.fab {
  position: fixed;
  right: max(16px, calc(50vw - 350px + 16px));
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  z-index: 35;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 0;
  background: var(--primary);
  color: #fff;
  font-size: 21px;
  box-shadow: 0 8px 22px -6px rgba(228,102,75,.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + 78px);
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 22px 10px;
}
.bar-track { height: 7px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--sage); transition: width .3s ease; }
