:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #111827;
  --sub: #6b7280;
  --line: #e5e7eb;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --warm: #f59e0b;
  --good: #059669;
  --bad: #dc2626;
  --radius: 16px;
  --tap: 46px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --card: #151a2e;
    --text: #e5e7eb;
    --sub: #94a3b8;
    --line: #232a44;
    --accent: #818cf8;
    --accent-soft: #1e2440;
    --warm: #fbbf24;
    --good: #34d399;
    --bad: #f87171;
  }
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  overscroll-behavior-y: none;
}

body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

#app { max-width: 680px; margin: 0 auto; padding: 0 14px; }

/* ---------- 头部 ---------- */
.head { padding: calc(14px + env(safe-area-inset-top)) 0 10px; }
.head-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.head-title { font-size: 19px; font-weight: 700; letter-spacing: .2px; }
.head-sub { color: var(--sub); font-size: 13px; margin-top: 2px; }
.streak { text-align: center; background: var(--accent-soft); border-radius: 14px; padding: 6px 12px; min-width: 66px; }
.streak-num { font-size: 22px; font-weight: 800; color: var(--warm); line-height: 1.1; }
.streak-label { font-size: 11px; color: var(--sub); }
.countdown {
  margin-top: 10px; display: flex; align-items: baseline; gap: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px;
}
.cd-label { font-size: 13px; color: var(--sub); flex: 1; }
.cd-num { font-size: 26px; font-weight: 800; color: var(--accent); }
.cd-unit { font-size: 13px; color: var(--sub); }

/* ---------- 卡片 ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; padding-bottom: 18px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.card-title { font-size: 15px; font-weight: 700; }
.small-title { font-size: 14px; }
.card-sub { font-size: 13px; color: var(--sub); }
.hint { font-size: 12.5px; color: var(--sub); background: var(--accent-soft); border-radius: 10px; padding: 8px 10px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.alert { border-color: var(--warm); }
.stop { border-color: var(--bad); }

/* ---------- 回合 ---------- */
.round.done { opacity: .72; }
.round-head { display: flex; gap: 12px; align-items: flex-start; }
.tick {
  width: var(--tap); height: var(--tap); min-width: var(--tap); border-radius: 50%;
  border: 2px solid var(--line); background: transparent; color: var(--accent);
  font-size: 22px; font-weight: 800; line-height: 1;
}
.round.done .tick { background: var(--accent); border-color: var(--accent); color: #fff; }
.round-label { font-size: 16px; font-weight: 700; }
.round-hint { font-size: 13px; color: var(--sub); }
.round-meta { font-size: 12px; color: var(--sub); margin-top: 2px; }
.round-actions { display: flex; gap: 8px; }

/* ---------- 按钮 ---------- */
.btn {
  min-height: var(--tap); padding: 10px 16px; border-radius: 12px; border: 1px solid transparent;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn.small { min-height: 40px; padding: 8px 14px; font-size: 14px; }
.btn.tiny { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn:active { transform: scale(.985); }

/* ---------- 进度条 ---------- */
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar.small { height: 7px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--warm)); border-radius: 999px; transition: width .25s; }

/* ---------- 阶段 ---------- */
.stage-head { display: flex; gap: 12px; align-items: center; width: 100%; background: transparent; border: 0; color: inherit; text-align: left; padding: 0; }
.stage-no { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 800; display: flex; align-items: center; justify-content: center; }
.stage-main { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.stage-name { font-size: 15px; font-weight: 700; }
.chev { color: var(--sub); }
.stage-body { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; padding: 6px 0; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
.check input:checked + span { color: var(--sub); text-decoration: line-through; }
.mini-block { display: flex; flex-direction: column; gap: 6px; }
.mini-title { font-size: 12.5px; font-weight: 700; color: var(--accent); }
.mini-text { font-size: 13px; color: var(--sub); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: transparent; color: var(--sub); border-radius: 999px; padding: 6px 10px; font-size: 12.5px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- 复盘 ---------- */
.seg { display: flex; gap: 8px; }
.seg-btn { flex: 1; min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--sub); font-size: 14px; }
.seg-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.review-row { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.review-head { display: flex; justify-content: space-between; align-items: center; }
.tag { font-size: 12px; border-radius: 999px; padding: 3px 9px; }
.tag.good { background: rgba(5, 150, 105, .14); color: var(--good); }
.tag.mid { background: rgba(245, 158, 11, .16); color: var(--warm); }
.tag.bad { background: rgba(220, 38, 38, .14); color: var(--bad); }

/* ---------- 投递 ---------- */
.ms { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 9px 0; }
.ms:first-of-type { border-top: 0; }
.ms-left { display: flex; flex-direction: column; }
.ms-days { font-weight: 800; color: var(--accent); white-space: nowrap; }
.ms.hard .ms-days { color: var(--warm); }
.ms.stop .ms-days { color: var(--bad); }
.app { gap: 8px; }
.field { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.field > span { width: 76px; color: var(--sub); font-size: 13.5px; }
.field input, .field select, textarea {
  flex: 1; min-height: 40px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 15px; font-family: inherit;
}
textarea { width: 100%; resize: vertical; }

/* ---------- 开关 ---------- */
.switch { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--sub); white-space: nowrap; flex: 0 0 auto; }
.switch input { width: 22px; height: 22px; accent-color: var(--warm); }
.row-between > div:first-child { flex: 1; min-width: 0; }

/* ---------- 底部标签栏 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; min-height: 58px; background: transparent; border: 0; color: var(--sub);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11.5px;
}
.tab .tab-icon { font-size: 17px; }
.tab.on { color: var(--accent); font-weight: 700; }

/* ---------- 知识点行 ---------- */
.kp { display: flex; align-items: center; gap: 10px; width: 100%; background: transparent; border: 0; border-top: 1px solid var(--line); padding: 10px 0; color: inherit; text-align: left; }
.kp:first-child { border-top: 0; }
.kp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.kp-title { font-size: 14.5px; font-weight: 700; }
.kp-sub { font-size: 12px; color: var(--sub); }
.kp-dots { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.kp-pct { margin-left: auto; font-size: 13px; font-weight: 800; color: var(--accent); }
.dot { font-size: 11.5px; color: var(--sub); border: 1px solid var(--line); border-radius: 999px; padding: 2px 7px; }
.dot.half { color: var(--warm); border-color: var(--warm); }
.dot.full { color: var(--good); border-color: var(--good); }
.bar.tiny { height: 6px; }
.card.next { border-color: var(--accent); }

/* ---------- 知识点详情 ---------- */
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--accent); height: 34px; }
.slider-val { width: 46px; text-align: right; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.quiz { display: flex; flex-direction: column; gap: 12px; }
.q { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.q:first-child { border-top: 0; }
.q-title { font-size: 14px; font-weight: 600; }
.opt { display: flex; gap: 9px; align-items: flex-start; font-size: 13.5px; color: var(--sub); padding: 5px 0; }
.opt input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.q.right .q-title::after { content: ' ✓'; color: var(--good); }
.q.wrong .q-title::after { content: ' ✗'; color: var(--bad); }
.why { font-size: 12.5px; color: var(--sub); background: var(--accent-soft); border-radius: 10px; padding: 8px 10px; }
iframe.bili { width: 100%; height: 240px; border: 1px solid var(--line); border-radius: 12px; background: #000; }

/* ---------- 资源小节 ---------- */
.res { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 7px; }
.res:first-of-type { border-top: 0; padding-top: 0; }
.res-head { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.res-head b { font-weight: 700; }
.tag.must { background: rgba(79, 70, 229, .16); color: var(--accent); }
.tag.ref { background: rgba(148, 163, 184, .18); color: var(--sub); }
.tag.skip { background: rgba(120, 120, 130, .14); color: var(--sub); text-decoration: line-through; }
.tag.drill { background: rgba(5, 150, 105, .16); color: var(--good); }

/* ---------- 题库 ---------- */
.bank-opts { display: flex; flex-direction: column; gap: 8px; }
.bank-opts .opt { border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--text); padding: 11px 12px; text-align: left; font-size: 14px; width: 100%; }
.bank-opts .opt.on-right { border-color: var(--good); background: rgba(5, 150, 105, .12); }
.bank-opts .opt.on-wrong { border-color: var(--bad); background: rgba(220, 38, 38, .10); }

/* ---------- 计时条 ---------- */
.timerbar {
  display: none; position: fixed; left: 0; right: 0; bottom: calc(58px + env(safe-area-inset-bottom)); z-index: 19;
  align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--accent); color: #fff;
}
.timerbar.show { display: flex; }
.tb-label { flex: 1; font-size: 13px; }
.tb-time { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.timerbar .btn.tiny { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .35); color: #fff; }

/* ---------- 弹层 / 提示 ---------- */
.sheet-mask { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; }
.sheet {
  width: 100%; max-height: 88vh; overflow: auto; background: var(--card);
  border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-body { display: flex; flex-direction: column; gap: 12px; }
.sheet-foot { display: flex; gap: 10px; }
.sheet-foot .btn { flex: 1; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px); bottom: calc(96px + env(safe-area-inset-bottom));
  background: rgba(17, 24, 39, .94); color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 13.5px; opacity: 0; pointer-events: none; transition: all .22s; z-index: 60; max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
