/* RehabGo 视觉：深海军蓝（品牌）+ 湖蓝（强调）+ 暖白底。手机竖屏优先，支持深色模式。 */
:root {
  --bg: #f7f5f1;
  --bg-2: #efede8;
  --card: #ffffff;
  --text: #13233a;
  --muted: #5d6878;
  --line: #e6e2db;
  --brand: #0b2545;
  --brand-2: #13406b;
  --accent: #0e9fb4;
  --accent-soft: #e2f5f8;
  --primary: #0b2545;
  --primary-ink: #ffffff;
  --danger: #d64545;
  --warn-bg: #fff4e5;
  --warn-line: #f0b25a;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(11, 37, 69, 0.05), 0 6px 20px rgba(11, 37, 69, 0.06);
  --green: #179a5a;
  --yellow: #c48a0c;
  --red: #d64545;
  --green-bg: #e7f6ee;
  --yellow-bg: #fcf2da;
  --red-bg: #fdecec;
  --tabbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1220;
    --bg-2: #0f1a2c;
    --card: #121d30;
    --text: #e8eef6;
    --muted: #9aa8ba;
    --line: #23314a;
    --accent: #2cc1d6;
    --accent-soft: #10303a;
    --primary: #2cc1d6;
    --primary-ink: #04141c;
    --warn-bg: #2b2214;
    --warn-line: #a8782f;
    --green-bg: #11301f;
    --yellow-bg: #33280f;
    --red-bg: #3a1a1a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }

main { max-width: 1040px; margin: 0 auto; padding: 12px 16px 16px; }

h1 { font-size: 24px; line-height: 1.3; margin: 10px 0 6px; letter-spacing: 0.01em; }
h2 { font-size: 18px; margin: 0 0 8px; }

/* ---------- 顶栏与导航 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand .logo { width: 32px; height: 32px; flex: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-size: 18px; letter-spacing: 0.02em; }
.brand small { font-size: 12px; color: var(--muted); }

.topnav { display: none; }
.topnav a { margin-left: 22px; color: var(--muted); text-decoration: none; font-weight: 600; padding: 6px 2px; border-bottom: 2px solid transparent; }
.topnav a.active { color: var(--text); border-bottom-color: var(--accent); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600;
}
.tabbar svg { width: 24px; height: 24px; fill: currentColor; }
.tabbar a.active { color: var(--accent); }

@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .topnav { display: block; }
  .tabbar { display: none; }
}

/* ---------- 通用 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 14px 0; box-shadow: var(--shadow);
}
.card.warn { background: var(--warn-bg); border-color: var(--warn-line); box-shadow: none; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.card-head h2 { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.caution { color: var(--danger); font-size: 14px; }
.error, .status-line.error { color: var(--danger); font-weight: 600; }
.status-line { margin: 8px 0 0; min-height: 1em; }

.pill { font-size: 13px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 2px 10px; border-radius: 999px; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 18px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font-size: 16px; font-weight: 600; text-decoration: none; cursor: pointer;
  width: 100%; margin-top: 10px; font-family: inherit;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible, .chip:focus-visible, .tabbar a:focus-visible, .topnav a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.big { min-height: 54px; font-size: 17px; }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.danger-outline { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.5; cursor: default; }

.grid { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 768px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .grid > .card { margin: 8px 0; }
}

/* ---------- 首页 ---------- */
.hero {
  position: relative; overflow: hidden;
  margin: 6px 0 14px; padding: 26px 20px 22px; border-radius: 24px;
  color: #fff;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(34, 184, 207, 0.55) 0%, rgba(34, 184, 207, 0) 55%),
    linear-gradient(150deg, #0b2545 0%, #13406b 62%, #1b6ca8 100%);
}
.hero::after {
  content: ""; position: absolute; right: -40px; bottom: -60px; width: 220px; height: 220px;
  border: 26px solid rgba(255, 255, 255, 0.07); border-radius: 50%;
}
.eyebrow { margin: 0 0 6px; font-size: 13px; font-weight: 700; letter-spacing: 0.08em; color: #9fe6f0; }
.hero h1 { font-size: 28px; margin: 0 0 8px; position: relative; z-index: 1; }
.hero-sub { margin: 0 0 6px; color: rgba(255, 255, 255, 0.86); position: relative; z-index: 1; }
.hero-actions { position: relative; z-index: 1; }
.hero .btn.primary { background: #ffffff; color: #0b2545; border-color: #ffffff; }
.hero .btn.ghost { color: #ffffff; border-color: rgba(255, 255, 255, 0.4); }
.hero-points { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 14px 0 0; position: relative; z-index: 1; }
.hero-points li { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.18); }
.hero-points li::before { content: "✓ "; color: #9fe6f0; font-weight: 700; }
@media (min-width: 768px) {
  .hero { padding: 40px 36px 34px; }
  .hero h1 { font-size: 36px; }
  .hero-actions { display: flex; gap: 12px; max-width: 520px; }
}

.plan-list { list-style: none; padding: 0; margin: 8px 0 4px; }
.plan-list li { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plan-list li:last-child { border-bottom: 0; }
.plan-list .mark { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; }
.plan-list li.done .mark { background: var(--accent); border-color: var(--accent); color: #fff; }
.plan-list li.done .name { color: var(--muted); }
.plan-list .name { font-weight: 600; }
.plan-list .meta { font-size: 13px; color: var(--muted); white-space: nowrap; }

.week-chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 150px; margin-top: 10px; }
.bar-col { display: flex; flex-direction: column; align-items: center; height: 100%; gap: 4px; }
.bar-val { font-size: 12px; font-weight: 700; color: var(--accent); min-height: 1.2em; }
.bar-track { flex: 1; width: 100%; max-width: 30px; display: flex; align-items: flex-end; background: var(--bg-2); border-radius: 8px; overflow: hidden; }
.bar { width: 100%; background: linear-gradient(180deg, var(--accent), var(--brand-2)); border-radius: 8px; min-height: 0; transition: height 0.4s ease; }
.bar.zero { height: 0 !important; }
.bar-label { font-size: 12px; color: var(--muted); }
.bar-label.today { color: var(--text); font-weight: 700; }
.bar-dot { width: 6px; height: 6px; border-radius: 50%; }
.bar-dot.red { background: var(--red); }
.bar-dot.yellow { background: var(--yellow); }

.card.pro { background: linear-gradient(180deg, var(--accent-soft), var(--card) 70%); }
.report {
  white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 14px; line-height: 1.6;
  background: var(--bg); border: 1px dashed var(--line); border-radius: 12px; padding: 12px; margin: 10px 0 0;
  user-select: text; -webkit-user-select: text;
}
.checks { list-style: none; padding: 0; margin: 6px 0 0; }
.checks li { position: relative; padding: 6px 0 6px 26px; }
.checks li::before { content: ""; position: absolute; left: 0; top: 10px; width: 16px; height: 16px; border-radius: 50%; background: var(--accent-soft); box-shadow: inset 0 0 0 5px var(--accent); }

/* ---------- 训练前确认 ---------- */
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.field { margin: 18px 0; border: 0; padding: 0; }
.field legend, .field > label { font-weight: 600; margin-bottom: 6px; display: block; }
.pain-row { display: flex; align-items: center; gap: 12px; }
.pain-row input { flex: 1; accent-color: var(--accent); }
.pain-row output { min-width: 2ch; font-size: 24px; font-weight: 800; text-align: right; }
#symptoms label { display: flex; gap: 10px; align-items: center; padding: 7px 0; }
#symptoms input { width: 20px; height: 20px; accent-color: var(--accent); }
.privacy-line { text-align: center; margin: 10px 0 0; }

.banner {
  background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 12px;
  padding: 10px 12px; margin: 8px 0; font-size: 14px;
}

/* ---------- 训练 ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 8px 14px; font-size: 15px; cursor: pointer; font-family: inherit;
}
.chip[aria-selected="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

.info ol { padding-left: 20px; margin: 8px 0; }
.row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.row .btn { margin-top: 0; }
.row select { flex: 1; min-height: 44px; font-size: 15px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 0 8px; font-family: inherit; }

.video-slot {
  margin-top: 10px; border: 1px dashed var(--line); border-radius: 12px;
  min-height: 110px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); overflow: hidden; background: var(--bg);
}
.video-slot video { width: 100%; display: block; }

.stage-wrap { margin-top: 12px; }
.stage {
  position: relative; width: 100%; aspect-ratio: 4 / 3; background: #000;
  border-radius: var(--radius); overflow: hidden;
}
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.stage video { transform: scaleX(-1); }

.hud {
  position: absolute; top: 10px; left: 10px; right: 10px;
  display: flex; justify-content: space-between; align-items: flex-start;
  color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); pointer-events: none;
}
.hud-count { font-size: 46px; font-weight: 800; line-height: 1; }
.hud-count small { font-size: 22px; font-weight: 600; }
.hud-angle { font-size: 18px; font-weight: 700; background: rgba(11, 37, 69, 0.55); padding: 4px 10px; border-radius: 10px; }

.hold { position: absolute; left: 10px; right: 10px; bottom: 56px; height: 8px; background: rgba(255, 255, 255, 0.25); border-radius: 4px; }
.hold-bar { height: 100%; width: 0; background: #22b8cf; border-radius: 4px; transition: width 0.1s linear; }

.prompt {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  background: rgba(11, 37, 69, 0.72); color: #fff; border-radius: 12px;
  padding: 8px 12px; font-size: 17px; font-weight: 600; text-align: center;
}

.plan { margin-bottom: 4px; }
.plan-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.plan-head h2 { margin: 4px 0; }
.plan-progress { color: var(--accent); font-weight: 700; white-space: nowrap; }
.plan .small { margin: 2px 0 8px; }
.plan .chips { flex-wrap: wrap; overflow: visible; }
.chip.done:not([aria-selected="true"]) { color: var(--accent); border-color: var(--accent); }

/* 训练后疼痛红绿灯 */
.pain-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pain-options .btn { margin-top: 0; font-weight: 700; }
.btn.light.green { border-color: var(--green); color: var(--green); background: var(--green-bg); }
.btn.light.yellow { border-color: var(--yellow); color: var(--yellow); background: var(--yellow-bg); }
.btn.light.red { border-color: var(--red); color: var(--red); background: var(--red-bg); }
.light-result { border-left: 5px solid var(--line); padding: 4px 0 4px 12px; margin-top: 8px; }
.light-result.green { border-left-color: var(--green); }
.light-result.yellow { border-left-color: var(--yellow); }
.light-result.red { border-left-color: var(--red); }

/* ---------- 记录 ---------- */
.progress-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.progress-item:last-child { border-bottom: 0; }
.progress-head { font-weight: 600; }
.progress-nums { font-size: 24px; font-weight: 800; color: var(--text); }
.progress-item.up .progress-nums { color: var(--accent); }
.progress-msg { margin: 2px 0 0; }

.streak { text-align: center; }
.streak-num { font-size: 52px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.streak-week { margin: 10px 0 0; color: var(--text); }

.records { list-style: none; padding: 0; margin: 0; }
.records li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.records li:last-child { border-bottom: 0; }
.records .meta { color: var(--muted); font-size: 13px; }
.records .empty { padding: 8px 0; }
.rec-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-weight: 600; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--warn-bg); border: 1px solid var(--warn-line); white-space: nowrap; }
.tag.light.green { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.tag.light.yellow { background: var(--yellow-bg); border-color: var(--yellow); color: var(--yellow); }
.tag.light.red { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.tips { padding-left: 20px; margin: 0; }
.tips li { margin: 6px 0; }
.confirm { margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--red-bg); }
.confirm p { margin: 0; }

.disclaimer {
  max-width: 1040px; margin: 0 auto; padding: 8px 16px 20px;
  color: var(--muted); font-size: 12px; text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .btn, .bar, .hold-bar { transition: none; }
}

/* 横屏：说明和画面左右排列 */
@media (orientation: landscape) and (min-width: 700px) {
  .train-layout { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 16px; align-items: start; }
  .train-layout .card.info { margin-top: 12px; }
}

/* ---------- 我的情况 → 生成计划（v0.5） ---------- */
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg-opt { position: relative; flex: 1 1 calc(50% - 8px); min-width: 120px; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt span {
  display: flex; align-items: center; justify-content: center; min-height: 46px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-weight: 600; text-align: center;
}
.seg-opt input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.seg-opt input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.input {
  width: 100%; min-height: 46px; font-size: 16px; font-family: inherit; padding: 0 12px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.reasons { list-style: none; padding: 0; margin: 8px 0 0; }
.reasons li { position: relative; padding: 3px 0 3px 18px; font-size: 14px; color: var(--muted); }
.reasons li::before { content: ""; position: absolute; left: 4px; top: 12px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.plan-list li.skipped .name, .plan-list li.skipped .meta { color: var(--muted); }
.plan-list li.skipped .name { text-decoration: line-through; font-weight: 500; }
.btn.primary-outline { border-color: var(--accent); color: var(--accent); }
.link { color: var(--accent); font-weight: 600; text-decoration: none; display: inline-block; margin-top: 4px; }
.perf-note { margin: 8px 0 0; padding: 8px 12px; border-radius: 12px; background: var(--warn-bg); border: 1px solid var(--warn-line); }
.disclaimer-box { margin: 14px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
