/* FitLoop · 设计系统
 * 深色、手机优先、无外部字体与图标库（图标全部内联 SVG）
 */
:root {
  --bg: #090b0d;
  --bg-soft: #0e1216;
  --card: #12171c;
  --card-2: #171e25;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #e9eff3;
  --dim: #8b99a6;
  --dim-2: #5d6b77;
  --lime: #b8f24a;
  --lime-dark: #7ba52b;
  --teal: #3fd6c0;
  --amber: #ffb454;
  --red: #ff6b6b;
  --violet: #a78bfa;
  --radius: 18px;
  --radius-s: 12px;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

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

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

body {
  background: radial-gradient(1200px 600px at 50% -200px, #16211a 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font-family: inherit; font-size: 16px; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--teal); }

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  background: linear-gradient(180deg, rgba(9, 11, 13, 0.96) 60%, rgba(9, 11, 13, 0.72));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(140deg, var(--lime), #6fcf52);
  display: grid; place-items: center; color: #10170c; font-weight: 800; font-size: 15px;
  flex: none; box-shadow: 0 4px 14px rgba(184, 242, 74, 0.25);
}
.brand-name { font-weight: 700; letter-spacing: 0.2px; font-size: 16px; white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--dim-2); letter-spacing: 0.4px; white-space: nowrap; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--line); color: var(--dim);
  transition: transform 0.15s ease, color 0.15s;
}
.icon-btn:active { transform: scale(0.94); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- 布局 ---------- */
.view { padding: 6px 16px 24px; animation: fade 0.26s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: linear-gradient(180deg, var(--card) 0%, #10151a 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
}
.card.tight { padding: 13px; }
.card.flat { background: var(--card-2); }
.card.accent { border-color: rgba(184, 242, 74, 0.28); background: linear-gradient(160deg, rgba(184, 242, 74, 0.09), rgba(18, 23, 28, 0.9)); }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-title { font-size: 13px; font-weight: 650; letter-spacing: 0.5px; color: var(--dim); text-transform: uppercase; }
.card-title b { color: var(--text); font-weight: 650; text-transform: none; letter-spacing: 0; font-size: 15px; }

.section-label { font-size: 12px; letter-spacing: 0.8px; color: var(--dim-2); margin: 20px 2px 8px; text-transform: uppercase; }
.section-label:first-child { margin-top: 8px; }

/* ---------- 文字 ---------- */
.h1 { font-size: 26px; font-weight: 750; letter-spacing: -0.4px; margin: 4px 0 2px; }
.h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.2px; margin: 0 0 6px; }
.muted { color: var(--dim); }
.tiny { font-size: 12px; color: var(--dim-2); }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* ---------- 指标 ---------- */
.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.metric-grid.three { grid-template-columns: repeat(3, 1fr); }
.metric {
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 11px 12px;
}
.metric .k { font-size: 11.5px; color: var(--dim-2); letter-spacing: 0.3px; }
.metric .v { font-size: 21px; font-weight: 700; letter-spacing: -0.3px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.metric .u { font-size: 12px; color: var(--dim); font-weight: 500; margin-left: 2px; }
.metric .s { font-size: 11.5px; color: var(--dim-2); margin-top: 1px; }

.hero-stat { display: flex; align-items: flex-end; gap: 10px; }
.hero-stat .big { font-size: 44px; font-weight: 800; letter-spacing: -1.5px; line-height: 1; font-variant-numeric: tabular-nums; }
.hero-stat .unit { font-size: 15px; color: var(--dim); margin-bottom: 6px; }

/* ---------- 徽章 / 标签 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--dim);
}
.badge.good { color: var(--lime); border-color: rgba(184, 242, 74, 0.35); background: rgba(184, 242, 74, 0.08); }
.badge.warn { color: var(--amber); border-color: rgba(255, 180, 84, 0.35); background: rgba(255, 180, 84, 0.08); }
.badge.bad { color: var(--red); border-color: rgba(255, 107, 107, 0.35); background: rgba(255, 107, 107, 0.08); }
.badge.info { color: var(--teal); border-color: rgba(63, 214, 192, 0.32); background: rgba(63, 214, 192, 0.08); }
.badge.neutral { color: var(--dim); }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  font-size: 12.5px; padding: 5px 11px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line); color: var(--dim);
}
.chip.on { color: #10170c; background: var(--lime); border-color: var(--lime); font-weight: 650; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 12px 16px; border-radius: 13px; font-size: 15px; font-weight: 650;
  background: var(--card-2); color: var(--text); border: 1px solid var(--line-strong);
  transition: transform 0.12s ease, filter 0.15s;
}
.btn:active { transform: scale(0.975); }
.btn.primary { background: linear-gradient(140deg, var(--lime), #9adb35); color: #10170c; border-color: transparent; box-shadow: 0 6px 18px rgba(184, 242, 74, 0.18); }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--dim); }
.btn.danger { color: var(--red); border-color: rgba(255, 107, 107, 0.3); background: rgba(255, 107, 107, 0.06); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13.5px; border-radius: 10px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn-row { display: flex; gap: 9px; }
.btn-row .btn { flex: 1; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 12.5px; color: var(--dim); margin-bottom: 6px; letter-spacing: 0.2px; }
.field .hint { font-size: 11.5px; color: var(--dim-2); margin-top: 5px; line-height: 1.45; }
input[type="text"], input[type="number"], input[type="password"], input[type="date"], select, textarea {
  width: 100%; padding: 12px 13px; border-radius: 12px;
  background: #0c1014; border: 1px solid var(--line-strong); color: var(--text);
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: rgba(184, 242, 74, 0.5); box-shadow: 0 0 0 3px rgba(184, 242, 74, 0.1); }
textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--dim-2); }
select { appearance: none; background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b99a6' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.seg { display: flex; background: #0c1014; border: 1px solid var(--line-strong); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; padding: 9px 6px; border-radius: 9px; font-size: 13.5px; color: var(--dim); font-weight: 550;
}
.seg button.on { background: var(--card-2); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.3); }

.check { display: flex; align-items: center; gap: 10px; padding: 10px 2px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--lime); }

/* ---------- 列表 ---------- */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-size: 14.5px; font-weight: 550; }
.row .sub { font-size: 12px; color: var(--dim-2); margin-top: 1px; }
.row .num { font-variant-numeric: tabular-nums; font-weight: 650; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 14px; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--dim); }
.kv .v { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- 进度条 ---------- */
.bar { height: 7px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--lime), #d8ff7a); transition: width .4s ease; }
.bar.teal > i { background: linear-gradient(90deg, var(--teal), #8ff0e2); }
.bar.amber > i { background: linear-gradient(90deg, var(--amber), #ffd08a); }
.macro-row { margin-bottom: 11px; }
.macro-row .top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.macro-row .top b { font-variant-numeric: tabular-nums; }

/* ---------- 训练卡 ---------- */
.day-card { border: 1px solid var(--line); border-radius: 15px; margin-bottom: 10px; overflow: hidden; background: var(--card); }
.day-head { display: flex; align-items: center; gap: 10px; padding: 13px 14px; width: 100%; text-align: left; }
.day-head .wd { font-size: 11.5px; color: var(--lime); font-weight: 700; letter-spacing: .5px; width: 34px; flex: none; }
.day-head .nm { font-weight: 650; font-size: 15px; }
.day-head .fc { font-size: 12px; color: var(--dim-2); }
.day-head .arw { margin-left: auto; color: var(--dim-2); transition: transform .2s; }
.day-card.open .arw { transform: rotate(180deg); }
.day-body { display: none; padding: 0 14px 14px; }
.day-card.open .day-body { display: block; }

.ex-row { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.ex-row .idx { font-size: 11px; color: var(--dim-2); width: 16px; padding-top: 3px; flex: none; font-variant-numeric: tabular-nums; }
.ex-row .ex-name { font-size: 14px; font-weight: 550; }
.ex-row .ex-meta { font-size: 12px; color: var(--dim); margin-top: 1px; font-variant-numeric: tabular-nums; }
.ex-row .ex-note { font-size: 11.5px; color: var(--lime); margin-top: 2px; opacity: .85; }
.ex-row .last { margin-left: auto; font-size: 11px; color: var(--dim-2); text-align: right; flex: none; }

/* ---------- 餐单 ---------- */
.meal { border: 1px solid var(--line); border-radius: 14px; padding: 13px; margin-bottom: 10px; background: var(--card); }
.meal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.meal-head .mn { font-weight: 650; font-size: 15px; }
.meal-head .mk { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.meal-item { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; padding: 4px 0; color: var(--text); }
.meal-item .g { color: var(--dim); font-variant-numeric: tabular-nums; }
.meal-note { font-size: 11.5px; color: var(--dim-2); margin-top: 8px; line-height: 1.45; }

/* ---------- 图表 ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: rgba(255,255,255,.06); stroke-width: 1; }
.chart .zero { stroke: rgba(255,255,255,.18); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .axis { fill: var(--dim-2); font-size: 8.5px; font-family: var(--font); }
.chart .endlabel { font-size: 9px; font-weight: 700; font-family: var(--font); }
.chart-empty { padding: 26px 0; text-align: center; color: var(--dim-2); font-size: 13px; }
.legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--dim); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 9px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

/* ---------- 体脂视觉选择 ---------- */
.sil-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sil {
  border: 1px solid var(--line); border-radius: 13px; padding: 7px 4px 8px;
  background: var(--card-2); text-align: center; transition: border-color .15s, background .15s;
}
.sil.on { border-color: var(--lime); background: rgba(184, 242, 74, 0.09); }
.sil svg { width: 100%; height: 74px; display: block; }
.sil .sv { font-size: 13px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.sil .sl { font-size: 10.5px; color: var(--dim-2); }

/* ---------- 照片 ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.photo-cell { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 3/4; background: var(--card-2); border: 1px solid var(--line); }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-cell .pd { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px; font-size: 10px; background: linear-gradient(0deg, rgba(0,0,0,.8), transparent); color: #dfe7ec; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.compare figure { margin: 0; }
.compare img { width: 100%; border-radius: 12px; border: 1px solid var(--line); display: block; }
.compare figcaption { font-size: 11.5px; color: var(--dim); text-align: center; margin-top: 4px; }

/* ---------- 底部导航 ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  max-width: 560px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(10, 13, 16, 0.92);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.nav button {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 5px 0; border-radius: 12px; color: var(--dim-2); font-size: 10.5px; font-weight: 550;
  transition: color .15s;
}
.nav button svg { width: 21px; height: 21px; }
.nav button.on { color: var(--lime); }
.nav button.on svg { filter: drop-shadow(0 0 8px rgba(184, 242, 74, .35)); }

/* ---------- 弹层 ---------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.62);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease; backdrop-filter: blur(3px);
}
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: #0f1418; border: 1px solid var(--line-strong);
  border-bottom: none; border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(22px + env(safe-area-inset-bottom));
  animation: slideUp .26s cubic-bezier(.2,.8,.3,1);
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 38px; height: 4px; border-radius: 999px; background: var(--line-strong); margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 12px; font-size: 17px; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: 96px; z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: #1b232b; border: 1px solid var(--line-strong); color: var(--text);
  padding: 10px 16px; border-radius: 12px; font-size: 13.5px; box-shadow: var(--shadow);
  animation: toastIn .22s ease; max-width: 88%; text-align: center;
}
.toast.err { border-color: rgba(255,107,107,.5); color: #ffd7d7; }
.toast.ok { border-color: rgba(184,242,74,.45); color: #e6ffc0; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 引导页 ---------- */
.onboard { padding: 26px 20px 40px; max-width: 560px; margin: 0 auto; }
.onboard .logo { width: 54px; height: 54px; border-radius: 16px; background: linear-gradient(140deg, var(--lime), #6fcf52); display: grid; place-items: center; color: #10170c; font-weight: 800; font-size: 24px; box-shadow: 0 10px 30px rgba(184,242,74,.25); }
.step-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--dim); background: var(--card); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; }

/* ---------- 忙状态 ---------- */
#busy {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 70; display: none; align-items: center; gap: 8px;
  background: #1b232b; border: 1px solid rgba(184, 242, 74, 0.3);
  color: #e6ffc0; font-size: 12.5px; padding: 8px 14px; border-radius: 999px;
  box-shadow: var(--shadow); max-width: 90vw; white-space: nowrap;
}

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 26px 12px; color: var(--dim-2); font-size: 13.5px; line-height: 1.6; }

/* ---------- 开关 ---------- */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch input { appearance: none; width: 44px; height: 26px; border-radius: 999px; background: #232c34; position: relative; transition: background .18s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #8b99a6; transition: transform .18s, background .18s; }
.switch input:checked { background: rgba(184,242,74,.28); }
.switch input:checked::after { transform: translateX(18px); background: var(--lime); }

/* ---------- 训练记录编辑 ---------- */
.set-row { display: grid; grid-template-columns: 28px 1fr 1fr 30px; gap: 7px; align-items: center; margin-bottom: 6px; }
.set-row .sn { font-size: 11.5px; color: var(--dim-2); text-align: center; font-variant-numeric: tabular-nums; }
.set-row input { padding: 9px 10px; font-size: 15px; text-align: center; }
.set-row .del { color: var(--dim-2); font-size: 18px; line-height: 1; padding: 4px; }
.ex-block { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; background: var(--card); }
.ex-block-head { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.ex-block-head .nm { font-weight: 600; font-size: 14.5px; flex: 1; }
.ex-block-head input { flex: 1; padding: 8px 10px; font-size: 14.5px; font-weight: 600; }

/* ---------- 对话 ---------- */
.chat-scroll { max-height: 55vh; overflow-y: auto; padding-right: 2px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 15px; font-size: 14px; margin-bottom: 9px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.msg.me { margin-left: auto; background: rgba(184,242,74,.14); border: 1px solid rgba(184,242,74,.25); border-bottom-right-radius: 5px; }
.msg.ai { background: var(--card-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.sys { margin: 0 auto; background: transparent; color: var(--dim-2); font-size: 12px; text-align: center; max-width: 100%; }
.typing { display: inline-flex; gap: 3px; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--dim); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* ---------- 桌面端 ---------- */
@media (min-width: 700px) {
  body { display: flex; justify-content: center; }
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: rgba(9,11,13,.5); }
  .nav { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* ---------- 打印（导出计划给教练） ---------- */
@media print {
  body { background: #fff; color: #000; }
  .nav, .topbar-actions, .btn, .nav { display: none !important; }
  .card, .day-card { border-color: #ccc; background: #fff; }
  .metric, .day-card, .meal { background: #f7f7f7; }
  .muted, .tiny, .metric .k { color: #555; }
}
