/* ============================================================
   极速学习 · 主动回忆卡片
   移动端优先 · 柔和配色 · 深浅双主题
   ============================================================ */

:root {
  --bg: #eef2f9;
  --bg-grad-1: #e8eefc;
  --bg-grad-2: #f6f1fb;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --surface-3: #eef3fa;
  --border: #e2e9f3;
  --border-strong: #cfdaea;

  --text: #16233a;
  --text-2: #5b6b85;
  --text-3: #8b99ae;

  --brand: #4f6df5;
  --brand-2: #7b8ffb;
  --brand-soft: #eaefff;

  --hard: #e2685f;
  --hard-soft: #fdeceb;
  --good: #3f8ae8;
  --good-soft: #e9f2fe;
  --easy: #35a97a;
  --easy-soft: #e7f6ef;
  --new: #9aa7bb;
  --new-soft: #eef1f6;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(22, 35, 58, .05);
  --shadow: 0 4px 16px rgba(22, 35, 58, .07);
  --shadow-lg: 0 18px 44px rgba(22, 35, 58, .16);
  --ring: 0 0 0 3px rgba(79, 109, 245, .18);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html[data-theme="dark"] {
  --bg: #0e131c;
  --bg-grad-1: #101724;
  --bg-grad-2: #151020;
  --surface: #171f2c;
  --surface-2: #1c2634;
  --surface-3: #212c3c;
  --border: #26324a;
  --border-strong: #33415c;

  --text: #e8eefb;
  --text-2: #a3b2c9;
  --text-3: #75859d;

  --brand: #7b93ff;
  --brand-2: #9aabff;
  --brand-soft: #1e2a4a;

  --hard: #f08b82;
  --hard-soft: #3a2321;
  --good: #6fb0f5;
  --good-soft: #1b2c44;
  --easy: #5cc79a;
  --easy-soft: #16332a;
  --new: #7b8aa1;
  --new-soft: #212b3a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 4px 18px rgba(0, 0, 0, .38);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, .55);
  --ring: 0 0 0 3px rgba(123, 147, 255, .22);
}

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

html, body {
  margin: 0; padding: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1100px 620px at 12% -10%, var(--bg-grad-1) 0%, transparent 62%),
    radial-gradient(900px 560px at 96% 4%, var(--bg-grad-2) 0%, transparent 58%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}

/* ---------------- 顶部栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 780px; margin: 0 auto;
  padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px; font-size: 19px;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  box-shadow: 0 4px 12px rgba(79, 109, 245, .3);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 16px; letter-spacing: .2px; }
.brand-text small { color: var(--text-3); font-size: 11.5px; }

.topbar-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font-size: 17px; cursor: pointer;
  transition: transform .14s ease, background .18s ease, border-color .18s ease;
}
.icon-btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(.93); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------------- 倒计时 ---------------- */
.countdown {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(135deg, #2b3a6b, #4f6df5);
  color: #fff; border-radius: var(--radius);
  padding: 13px 16px;
  box-shadow: 0 6px 20px rgba(43, 58, 107, .28);
}
html[data-theme="dark"] .countdown {
  background: linear-gradient(135deg, #1b2440, #2f3f7a);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
}
.cd-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cd-days { display: flex; align-items: baseline; gap: 3px; flex: none; }
.cd-days b { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.cd-days span { font-size: 13px; opacity: .85; }
.cd-info { min-width: 0; }
.cd-title { font-size: 13px; font-weight: 600; opacity: .95; }
.cd-sub { font-size: 11.5px; opacity: .72; margin-top: 1px; }
.cd-progress { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.cd-pct b { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cd-pct span { display: block; font-size: 11px; opacity: .72; }
.cd-install {
  border: 1px solid rgba(255, 255, 255, .5);
  background: rgba(255, 255, 255, .18);
  color: #fff; font: inherit; font-size: 11.5px; font-weight: 700;
  padding: 3px 11px; border-radius: 99px; cursor: pointer;
  transition: .16s ease;
}
.cd-install:hover { background: rgba(255, 255, 255, .3); }
.cd-install:active { transform: scale(.95); }

/* 同步状态提示条 */
.net-badge {
  display: flex; align-items: center; justify-content: center;
  gap: 9px; padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 600;
  line-height: 1.6;
  animation: cardIn .25s ease;
}
/* 真断网：中性偏暖，说明数据安全 */
.net-badge.offline {
  background: var(--good-soft); color: var(--good);
  border: 1px solid color-mix(in srgb, var(--good) 30%, transparent);
}
/* 有网但同步失败：用"注意"而非"错误"的观感 */
.net-badge.degraded {
  background: #fef3e6; color: #c47a1e;
  border: 1px solid rgba(196, 122, 30, .3);
}
html[data-theme="dark"] .net-badge.degraded {
  background: #3a2c18; color: #e0a860;
  border-color: rgba(224, 168, 96, .3);
}
.nb-retry {
  flex: none;
  border: 1px solid currentColor; background: transparent; color: inherit;
  font: inherit; font-size: 11.5px; font-weight: 700;
  padding: 3px 11px; border-radius: 99px; cursor: pointer;
  transition: .15s ease;
}
.nb-retry:hover { background: color-mix(in srgb, currentColor 14%, transparent); }
.nb-retry:disabled { opacity: .55; cursor: default; }

/* 倒计时紧急态（考前 3 天） */
.countdown.urgent {
  background: linear-gradient(135deg, #8a3b34, #e2685f);
  box-shadow: 0 6px 20px rgba(226, 104, 95, .35);
}
.countdown.urgent .cd-days b { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .62; } }

/* ---------------- 顶层 Tab ---------------- */
.tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 6px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text-2);
  font: inherit; font-size: 12.5px; font-weight: 650;
  cursor: pointer; transition: .18s ease;
  box-shadow: var(--shadow-sm);
}
.tab:hover { border-color: var(--border-strong); color: var(--text); }
.tab.active {
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  border-color: transparent; color: #fff;
  box-shadow: 0 5px 16px rgba(79, 109, 245, .3);
}
.tab-ico { font-size: 18px; line-height: 1.1; }
.tab-badge {
  position: absolute; top: 5px; right: 8px;
  min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 99px; background: var(--hard); color: #fff;
  font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center;
}
.tab.active .tab-badge { background: rgba(255, 255, 255, .3); }
.tab:focus-visible { outline: none; box-shadow: var(--ring); }

.panel { display: none; flex-direction: column; gap: 13px; }
.panel.active { display: flex; }

/* ---------------- 客观题：开始页 ---------------- */
.qs-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 16px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 12px;
}
.qs-card h2 { margin: 0; font-size: 18px; font-weight: 750; }
.qs-desc { margin: 0; font-size: 13.5px; line-height: 1.75; color: var(--text-2); }
.qs-desc b { color: var(--brand); }
.qs-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.qs-stats > div {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 8px; text-align: center;
}
.qs-stats b { display: block; font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; }
.qs-stats span { font-size: 11.5px; color: var(--text-3); }
.qs-opt { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.qs-history { display: flex; flex-direction: column; gap: 7px; }
.qs-history h3 { margin: 4px 0 0; font-size: 13px; color: var(--text-2); font-weight: 700; }
.hist-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: 12.5px;
}
.hist-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.hist-score.pass { color: var(--easy); }
.hist-score.fail { color: var(--hard); }
.hist-meta { color: var(--text-3); font-size: 11.5px; }

/* ---------------- 客观题：答题页 ---------------- */
.qr-head { display: flex; align-items: center; gap: 10px; }
.qr-progress { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-2); }
.qr-timer {
  margin-left: auto; font-variant-numeric: tabular-nums;
  font-size: 13.5px; font-weight: 700; color: var(--text-2);
  background: var(--surface-3); padding: 4px 11px; border-radius: 99px;
}
.qr-bar { margin: 0; }

.q-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 12px;
}
.q-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.q-type {
  font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 99px;
  background: var(--brand-soft); color: var(--brand);
}
.q-type.judge { background: var(--easy-soft); color: var(--easy); }
.q-type.multi { background: #f3ecfe; color: #7c4ddb; }
html[data-theme="dark"] .q-type.multi { background: #2a2140; color: #b79bf0; }
.q-type.subjective { background: #fef3e6; color: #c47a1e; }
html[data-theme="dark"] .q-type.subjective { background: #3a2c18; color: #e0a860; }

/* 多选提示 */
.multi-hint {
  font-size: 12px; color: #7c4ddb; font-weight: 600;
  background: #f3ecfe; padding: 7px 11px; border-radius: var(--radius-sm);
  margin-bottom: 2px;
}
html[data-theme="dark"] .multi-hint { background: #2a2140; color: #b79bf0; }

/* 主观题 */
.subj-hint {
  font-size: 12.5px; color: var(--text-2); line-height: 1.7;
  background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm);
}
.subj-skeleton {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px;
  animation: cardIn .25s ease;
}
.skel-item { display: flex; gap: 9px; font-size: 13.5px; line-height: 1.65; }
.skel-no {
  flex: none; width: 19px; height: 19px; border-radius: 50%;
  background: var(--brand); color: #fff;
  font-size: 11px; font-weight: 800;
  display: grid; place-items: center; margin-top: 2px;
}
.skel-theories {
  margin-top: 4px; padding-top: 9px; border-top: 1px dashed var(--border-strong);
  font-size: 12px; color: var(--text-3);
}
.subj-score {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 11px 12px;
}
.subj-score-label { font-size: 12.5px; font-weight: 650; color: var(--text-2); }
.subj-score-btns { display: flex; gap: 7px; flex-wrap: wrap; }
.score-btn {
  flex: 1; min-width: 46px; padding: 9px 6px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: .15s ease;
}
.score-btn:hover { border-color: var(--brand); background: var(--brand-soft); }
.score-btn.active {
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  border-color: transparent; color: #fff;
}
.score-btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* 成绩页：分题型明细 */
.rs-breakdown {
  font-size: 13px; color: var(--text-2); line-height: 1.9;
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px;
}
.rs-breakdown b { color: var(--text); font-variant-numeric: tabular-nums; }

/* 卷型选择 */
.qs-paper {
  display: flex; flex-direction: column; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 12px;
}
.qs-paper-title { font-size: 12.5px; font-weight: 700; color: var(--text-2); margin-bottom: 2px; }
.qs-tier-hint { font-size: 11.5px; color: var(--text-3); line-height: 1.7; margin-bottom: 3px; }
.qs-tier {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: 13px; line-height: 1.55; color: var(--text-2); cursor: pointer;
  padding: 7px 9px; border-radius: var(--radius-sm); transition: .15s ease;
}
.qs-tier:hover { background: var(--surface-3); }
.qs-tier input { margin-top: 3px; flex: none; accent-color: var(--brand); }
.qs-tier b { color: var(--text); }
.qs-tier:has(input:checked) { background: var(--brand-soft); }
.qs-tier:has(input:checked) span { color: var(--text); }
.q-no { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.q-stem {
  font-size: clamp(15.5px, 4vw, 18px); font-weight: 650; line-height: 1.6;
  color: var(--text); word-break: break-word;
}
.q-options { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 13px; text-align: left;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 14px; line-height: 1.6; cursor: pointer;
  transition: .15s ease; width: 100%;
}
.opt:hover { border-color: var(--brand); background: var(--brand-soft); }
.opt-key {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-2);
  font-size: 12px; font-weight: 800;
}
.opt.picked { border-color: var(--brand); background: var(--brand-soft); }
.opt.picked .opt-key { background: var(--brand); color: #fff; }
.opt.right { border-color: var(--easy); background: var(--easy-soft); }
.opt.right .opt-key { background: var(--easy); color: #fff; }
.opt.wrong { border-color: var(--hard); background: var(--hard-soft); }
.opt.wrong .opt-key { background: var(--hard); color: #fff; }
.opt-text { flex: 1; min-width: 0; }
.opt:focus-visible { outline: none; box-shadow: var(--ring); }

.qr-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.nav-btn.primary {
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  border-color: transparent; color: #fff;
  box-shadow: 0 4px 14px rgba(79, 109, 245, .3);
}

/* ---------------- 客观题：成绩页 ---------------- */
.rs-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 16px;
  box-shadow: var(--shadow-sm); text-align: center;
  display: flex; flex-direction: column; gap: 12px;
}
.rs-score { display: flex; align-items: baseline; justify-content: center; gap: 5px; }
.rs-score b { font-size: 46px; font-weight: 850; font-variant-numeric: tabular-nums; line-height: 1; }
.rs-score span { font-size: 13px; color: var(--text-3); }
.rs-verdict { font-size: 15px; font-weight: 750; }
.rs-verdict.pass { color: var(--easy); }
.rs-verdict.fail { color: var(--hard); }
.rs-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.rs-grid > div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 9px 5px; }
.rs-grid b { display: block; font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rs-grid span { font-size: 10.5px; color: var(--text-3); }

/* ---------------- 错题本 ---------------- */
.wb-head {
  display: flex; flex-direction: column; gap: 9px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 14px;
  box-shadow: var(--shadow-sm);
}
.wb-title { font-size: 15px; font-weight: 750; }
.wb-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.wb-actions select { flex: 1; min-width: 110px; }
.wb-actions .btn-ghost { padding: 8px 12px; font-size: 13px; }
.wb-list { display: flex; flex-direction: column; gap: 9px; }
.wb-item {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--hard);
  border-radius: var(--radius-sm); padding: 12px 13px;
}
.wb-q { font-size: 14px; font-weight: 650; line-height: 1.6; margin-bottom: 6px; word-break: break-word; }
.wb-ans { font-size: 12.5px; line-height: 1.7; color: var(--text-2); }
.wb-ans .k { color: var(--text-3); }
.wb-ans .right { color: var(--easy); font-weight: 700; }
.wb-ans .mine { color: var(--hard); text-decoration: line-through; }
.wb-meta { display: flex; gap: 8px; align-items: center; margin-top: 7px; flex-wrap: wrap; }
.wb-times {
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px;
  background: var(--hard-soft); color: var(--hard);
}
.wb-ch { font-size: 10.5px; color: var(--text-3); }

/* ---------------- 统计面板 ---------------- */
.stat-head {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 15px; box-shadow: var(--shadow-sm);
}
.stat-title { font-size: 16px; font-weight: 750; }
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; line-height: 1.6; }

.stat-block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 15px; box-shadow: var(--shadow-sm);
}
.stat-block h3 { margin: 0 0 11px; font-size: 13px; font-weight: 700; color: var(--text-2); }

/* 热力图 */
.heatmap { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.hm-cell {
  position: relative; aspect-ratio: 1; border-radius: 6px;
  background: var(--surface-3);
  display: grid; place-items: center;
  transition: transform .12s ease;
}
.hm-cell:hover { transform: scale(1.12); }
.hm-0 { background: var(--surface-3); }
.hm-1 { background: color-mix(in srgb, var(--brand) 22%, var(--surface-3)); }
.hm-2 { background: color-mix(in srgb, var(--brand) 45%, var(--surface-3)); }
.hm-3 { background: color-mix(in srgb, var(--brand) 70%, var(--surface-3)); }
.hm-4 { background: var(--brand); }
.hm-d { font-size: 9px; color: var(--text-3); font-weight: 600; }
.hm-3 .hm-d, .hm-4 .hm-d { color: rgba(255, 255, 255, .9); }
.hm-dot {
  position: absolute; top: 3px; right: 3px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--easy);
  box-shadow: 0 0 0 1.5px var(--surface);
}

/* 章节掌握度 */
.chap-list { display: flex; flex-direction: column; gap: 11px; }
.chap-row { display: flex; flex-direction: column; gap: 5px; }
.chap-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chap-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chap-pct { font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; flex: none; }
.chap-pct.ok { color: var(--easy); }
.chap-pct.mid { color: var(--good); }
.chap-pct.low { color: var(--hard); }
.chap-bar { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.chap-bar > div { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .4s ease; }
.chap-meta { font-size: 11px; color: var(--text-3); }

/* 成绩走势 */
.spark { display: flex; flex-direction: column; gap: 7px; }
.spark-svg { width: 100%; height: 70px; display: block; }
.spark-meta {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: 11.5px; color: var(--text-3); flex-wrap: wrap;
}
.spark-meta b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------------- 布局 ---------------- */
.app {
  max-width: 780px; margin: 0 auto;
  padding: 16px 16px calc(34px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 14px;
}

/* ---------------- 进度卡 ---------------- */
.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
}
.progress-top {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 9px;
}
.progress-label {
  font-weight: 600; font-size: 14.5px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.progress-count { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 13.5px; flex: none; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar-fill {
  height: 100%; width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width .38s cubic-bezier(.4, 0, .2, 1);
}
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 99px;
  font-size: 12.5px; font-weight: 500;
  background: var(--surface-3); color: var(--text-2);
}
.chip i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.chip b { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); }
.chip-hard { background: var(--hard-soft); color: var(--hard); }
.chip-good { background: var(--good-soft); color: var(--good); }
.chip-easy { background: var(--easy-soft); color: var(--easy); }
.chip-new  { background: var(--new-soft);  color: var(--new); }

/* ---------------- 分段控件 ---------------- */
.modebar { display: flex; justify-content: center; }
.seg {
  display: inline-flex; padding: 4px; gap: 3px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; box-shadow: var(--shadow-sm);
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg-btn {
  border: 0; background: transparent; color: var(--text-2);
  font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 7px 15px; border-radius: 99px; cursor: pointer;
  white-space: nowrap; transition: .18s ease;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff; box-shadow: 0 3px 10px rgba(79, 109, 245, .3);
}
.seg-btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------------- 闪卡 ---------------- */
.card-stage { display: flex; flex-direction: column; gap: 12px; }

.flashcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
  display: flex; flex-direction: column;
  gap: 14px;
  min-height: 340px;
  animation: cardIn .3s ease;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px) scale(.99); }
  to   { opacity: 1; transform: none; }
}
.flashcard.flip { animation: flipIn .34s ease; }
@keyframes flipIn {
  0%   { transform: rotateX(-8deg) scale(.985); opacity: .55; }
  100% { transform: none; opacity: 1; }
}

.fc-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.fc-tag {
  font-size: 11.5px; font-weight: 700; letter-spacing: .4px;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 4px 11px; border-radius: 99px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 72%;
}
.fc-index {
  font-size: 12.5px; color: var(--text-3);
  font-variant-numeric: tabular-nums; flex: none;
}

.fc-body { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.fc-label {
  font-size: 11px; font-weight: 700; letter-spacing: 1.3px;
  color: var(--text-3); text-transform: uppercase;
}
.fc-question {
  font-size: clamp(19px, 4.6vw, 25px);
  font-weight: 700; line-height: 1.42;
  color: var(--text); letter-spacing: .2px;
  word-break: break-word;
  margin-bottom: 4px;
}

.fc-answer-wrap {
  border-top: 1px dashed var(--border-strong);
  padding-top: 13px; margin-top: 2px;
  display: flex; flex-direction: column; gap: 7px;
}
.fc-label-answer { color: var(--brand); }

/* 答案模糊遮罩 —— 主动回忆核心 */
.fc-answer, .fc-points {
  transition: filter .28s ease, opacity .28s ease;
}
.fc-answer-wrap.masked .fc-answer,
.fc-answer-wrap.masked .fc-points {
  filter: blur(7px);
  opacity: .5;
  user-select: none;
  pointer-events: none;
}
.fc-answer {
  font-size: 15.5px; line-height: 1.72; color: var(--text);
  word-break: break-word; white-space: pre-wrap;
}
.fc-points { margin: 4px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.fc-points li {
  position: relative; padding-left: 20px;
  font-size: 14.5px; line-height: 1.65; color: var(--text-2);
}
.fc-points li::before {
  content: ""; position: absolute; left: 5px; top: .62em;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--brand); opacity: .7;
}
.fc-points:empty { display: none; }

.recall-hint {
  margin-top: auto; text-align: center;
  font-size: 12.5px; color: var(--text-3);
  padding: 9px; border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.fc-answer-wrap:not(.masked) ~ .recall-hint { display: none; }

.fc-foot { display: flex; }
.btn-reveal {
  width: 100%;
  border: 1px solid var(--brand);
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff; font: inherit; font-weight: 650; font-size: 15px;
  padding: 13px; border-radius: 14px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  box-shadow: 0 5px 16px rgba(79, 109, 245, .28);
  transition: transform .14s ease, box-shadow .2s ease, opacity .2s ease;
}
.btn-reveal:hover { box-shadow: 0 8px 22px rgba(79, 109, 245, .38); }
.btn-reveal:active { transform: translateY(1px) scale(.995); }
.btn-reveal:focus-visible { outline: none; box-shadow: var(--ring); }

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px; font-weight: 600;
  padding: 2px 6px; border-radius: 6px;
  background: rgba(255, 255, 255, .22);
  border: 1px solid rgba(255, 255, 255, .3);
  color: #fff;
}

/* ---------------- 反馈按钮 ---------------- */
.feedback { animation: cardIn .26s ease; }
.feedback-title {
  text-align: center; font-size: 12.5px; color: var(--text-3); margin-bottom: 9px;
}
.feedback-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.fb {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px; padding: 11px 6px;
  cursor: pointer; font: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  transition: transform .14s ease, box-shadow .2s ease, background .18s ease, border-color .18s ease;
  box-shadow: var(--shadow-sm);
}
.fb b { font-size: 15px; font-weight: 700; }
.fb small { font-size: 11px; color: var(--text-3); }
.fb:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.fb:active { transform: translateY(0) scale(.98); }
.fb:focus-visible { outline: none; box-shadow: var(--ring); }
.fb-hard { color: var(--hard); border-color: color-mix(in srgb, var(--hard) 35%, var(--border)); }
.fb-hard:hover { background: var(--hard-soft); }
.fb-good { color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, var(--border)); }
.fb-good:hover { background: var(--good-soft); }
.fb-easy { color: var(--easy); border-color: color-mix(in srgb, var(--easy) 35%, var(--border)); }
.fb-easy:hover { background: var(--easy-soft); }

/* ---------------- 导航 ---------------- */
.navrow { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 9px; }
.nav-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 11px 6px; border-radius: 13px; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: .16s ease;
}
.nav-btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.nav-btn:active { transform: scale(.97); }
.nav-btn:focus-visible { outline: none; box-shadow: var(--ring); }

.kb-hint {
  text-align: center; font-size: 11.5px; color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  gap: 5px; flex-wrap: wrap;
}
.kb-hint kbd {
  background: var(--surface-3); border: 1px solid var(--border);
  color: var(--text-2);
}

/* ---------------- 抽屉面板 ---------------- */
.sheet { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-mask {
  position: absolute; inset: 0;
  background: rgba(12, 20, 34, .5);
  backdrop-filter: blur(3px);
  animation: fadeIn .22s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet-panel {
  position: relative;
  width: 100%; max-width: 780px;
  max-height: 88vh;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: slideUp .3s cubic-bezier(.32, .72, 0, 1);
  padding-bottom: var(--safe-bottom);
}
.sheet-tall { max-height: 92vh; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }

.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 15px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.sheet-head h3 { margin: 0; font-size: 16.5px; font-weight: 700; }
.sheet-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.sheet-foot {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 13px 16px; border-top: 1px solid var(--border);
  flex: none;
}

/* 拖放区 */
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 28px 18px; text-align: center; cursor: pointer;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  transition: .2s ease;
}
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop-icon { font-size: 32px; line-height: 1; }
.drop-title { font-weight: 650; font-size: 15px; }
.drop-sub { font-size: 12.5px; color: var(--text-3); }

.gen-opts {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.opt-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.opt-row label { color: var(--text-2); font-weight: 600; flex: none; }
.opt-row select, .opt-row input[type="range"] { flex: 1; min-width: 0; }
.opt-row.opt-inline label {
  display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer;
}
select, input[type="search"], input[type="text"], textarea {
  font: inherit; font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  width: 100%;
  transition: border-color .18s ease, box-shadow .18s ease;
}
select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--ring);
}
input[type="range"] { accent-color: var(--brand); }
input[type="checkbox"] { accent-color: var(--brand); width: 17px; height: 17px; }

.parse-log {
  font-size: 12.5px; line-height: 1.7;
  background: var(--surface-3); border-radius: var(--radius-sm);
  padding: 11px 13px; color: var(--text-2);
  max-height: 170px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
}

.btn-primary, .btn-ghost {
  font: inherit; font-size: 14px; font-weight: 650;
  padding: 11px 15px; border-radius: 13px; cursor: pointer;
  transition: .16s ease; border: 1px solid transparent;
}
.btn-primary {
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff; box-shadow: 0 4px 14px rgba(79, 109, 245, .3);
}
.btn-primary:hover { box-shadow: 0 7px 20px rgba(79, 109, 245, .4); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost {
  background: var(--surface); border-color: var(--border-strong); color: var(--text);
}
.btn-ghost:hover { background: var(--surface-3); }
.btn-ghost.danger { color: var(--hard); border-color: color-mix(in srgb, var(--hard) 38%, var(--border)); }
.btn-ghost.danger:hover { background: var(--hard-soft); }
.btn-block { width: 100%; }
.btn-primary:focus-visible, .btn-ghost:focus-visible { outline: none; box-shadow: var(--ring); }
.fineprint { font-size: 11.5px; color: var(--text-3); text-align: center; margin: 0; }

/* ---------------- 卡片库 ---------------- */
.lib-tools { display: flex; gap: 9px; padding: 13px 16px; border-bottom: 1px solid var(--border); flex: none; }
.lib-tools input { flex: 2; min-width: 0; }
.lib-tools select { flex: 1; min-width: 0; }
.lib-list { overflow-y: auto; flex: 1; padding: 11px 16px; display: flex; flex-direction: column; gap: 9px; }
.lib-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 13px; background: var(--surface-2);
  cursor: pointer; transition: .16s ease;
}
.lib-item:hover { border-color: var(--brand); background: var(--brand-soft); }
.lib-q { font-weight: 650; font-size: 14px; margin-bottom: 3px; word-break: break-word; }
.lib-a { font-size: 12.5px; color: var(--text-2); line-height: 1.6; word-break: break-word; }
.lib-meta { display: flex; gap: 7px; align-items: center; margin-top: 7px; flex-wrap: wrap; }
.lv {
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px;
  background: var(--surface-3); color: var(--text-3);
}
.lv.hard { background: var(--hard-soft); color: var(--hard); }
.lv.good { background: var(--good-soft); color: var(--good); }
.lv.easy { background: var(--easy-soft); color: var(--easy); }
.lib-ch { font-size: 10.5px; color: var(--text-3); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.field > span { font-weight: 600; color: var(--text-2); }

/* ---------------- 统计 ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-box {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 14px;
}
.stat-box .k { font-size: 12px; color: var(--text-3); font-weight: 600; }
.stat-box .v { font-size: 25px; font-weight: 750; font-variant-numeric: tabular-nums; margin-top: 2px; }
.dist { display: flex; flex-direction: column; gap: 10px; }
.dist-row { display: flex; flex-direction: column; gap: 5px; }
.dist-top { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); }
.dist-top b { color: var(--text); font-variant-numeric: tabular-nums; }
.dist-bar { height: 9px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.dist-bar > div { height: 100%; border-radius: 99px; transition: width .4s ease; }
.stat-section-title { font-size: 13px; font-weight: 700; color: var(--text-2); margin: 4px 0 0; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + var(--safe-bottom));
  transform: translateX(-50%) translateY(14px);
  background: var(--text); color: var(--surface);
  padding: 10px 20px; border-radius: 99px;
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 200; opacity: 0;
  transition: opacity .24s ease, transform .24s ease;
  pointer-events: none; max-width: 88vw; text-align: center;
}
.toast[hidden] { display: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.muted { color: var(--text-3); font-weight: 500; font-size: 13px; }
.empty { text-align: center; color: var(--text-3); padding: 44px 20px; font-size: 14px; }

/* ---------------- 移动端 ---------------- */
@media (max-width: 560px) {
  .app { padding: 13px 12px calc(28px + var(--safe-bottom)); gap: 12px; }
  .flashcard { padding: 16px 15px 14px; min-height: 300px; border-radius: 19px; }
  .navrow { grid-template-columns: 1fr 1fr 1fr; gap: 7px; }
  .nav-btn { font-size: 12.5px; padding: 10px 4px; }
  .fb b { font-size: 14px; }
  .fb small { display: none; }
  .feedback-btns { gap: 7px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-box .v { font-size: 22px; }
  .kb-hint { display: none; }
  .sheet-foot { padding: 12px; }
  .lib-tools { padding: 11px 12px; }
  .lib-list { padding: 10px 12px; }
}

@media (min-width: 861px) {
  .sheet { align-items: center; }
  .sheet-panel { border-radius: 22px; max-height: 86vh; margin: 0 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
