/* ============================================================
 * 概率勇者 · 考研秘境  —  样式
 * ============================================================ */
:root {
  --bg: #0b1020;
  --bg2: #121a33;
  --panel: rgba(23, 32, 58, 0.82);
  --panel2: #1a2340;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e7ecf8;
  --muted: #93a0bd;
  --gold: #f5c542;
  --gold2: #ffdf7e;
  --primary: #6d8bff;
  --primary2: #4f6ef7;
  --green: #34d399;
  --red: #ff5c7a;
  --purple: #a78bfa;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --font: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(109, 139, 255, 0.18), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(167, 139, 250, 0.16), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

#app { max-width: 880px; margin: 0 auto; padding: 20px 16px 80px; }

.screen { display: none; animation: fadeIn .35s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 11px 20px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--panel2); color: var(--text);
  font-size: 15px; font-weight: 600; cursor: pointer; transition: .18s;
  font-family: var(--font);
}
.btn:hover { transform: translateY(-2px); border-color: rgba(255,255,255,.25); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  border: none; color: #fff;
  box-shadow: 0 8px 24px rgba(79, 110, 247, .4);
}
.btn-primary:hover { box-shadow: 0 10px 30px rgba(79, 110, 247, .55); }
.btn-back { background: transparent; }
.btn-buy { background: linear-gradient(135deg, var(--gold), #e8a523); border: none; color: #3a2a00; }
.btn-disabled { opacity: .45; cursor: not-allowed; }

.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { font-size: 24px; flex: 1; }
.page-coins { font-weight: 800; color: var(--gold); font-size: 18px; }

.empty { color: var(--muted); padding: 30px 0; text-align: center; }

/* ---------- 顶部 HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: none; align-items: center; gap: 16px;
  padding: 10px 18px; background: rgba(11, 16, 32, .92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  font-size: 14px;
}
#hud.show { display: flex; }
.hud-level { font-weight: 700; color: var(--purple); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-hp { letter-spacing: 1px; }
.hud-coins { font-weight: 800; color: var(--gold); margin-left: auto; }
.hud-shield { color: var(--muted); }
.hud-bag { color: var(--muted); }

/* ---------- 首页 ---------- */
.home-hero { text-align: center; padding: 40px 10px 30px; }
.home-badge {
  display: inline-block; padding: 6px 14px; border-radius: 999px;
  background: rgba(109, 139, 255, .15); color: var(--primary);
  font-size: 13px; font-weight: 600; margin-bottom: 18px;
}
.home-title { font-size: 46px; line-height: 1.15; margin-bottom: 14px; }
.home-title span { color: var(--gold); }
.home-sub { color: var(--muted); font-size: 16px; max-width: 560px; margin: 0 auto 26px; line-height: 1.7; }
.home-sub b { color: var(--gold); }
.home-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.home-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 30px 0 18px; }
.home-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 18px; text-align: center; transition: .2s;
}
.home-card:hover { transform: translateY(-4px); border-color: rgba(109,139,255,.4); }
.hc-icon { font-size: 34px; margin-bottom: 10px; }
.hc-title { font-weight: 800; margin-bottom: 6px; font-size: 16px; }
.hc-desc { color: var(--muted); font-size: 13px; line-height: 1.6; }

.home-tip {
  background: rgba(245, 197, 66, .08); border: 1px solid rgba(245, 197, 66, .25);
  color: #e8c96a; border-radius: 12px; padding: 14px 18px; font-size: 14px; line-height: 1.7;
}

/* ---------- 知识点标签 ---------- */
.ktag {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  color: var(--c); font-size: 12px; margin: 3px 4px 3px 0; white-space: nowrap;
}

/* ---------- 关卡选择 ---------- */
.level-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.level-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; position: relative; display: flex; flex-direction: column; gap: 8px;
  transition: .2s; overflow: hidden;
}
.level-card:hover { transform: translateY(-3px); border-color: rgba(109,139,255,.4); }
.level-card.locked { opacity: .55; filter: grayscale(.4); }
.level-boss { border-color: rgba(245, 197, 66, .5); background: linear-gradient(135deg, rgba(245,197,66,.08), var(--panel)); }
.level-num { font-size: 13px; color: var(--gold); font-weight: 700; }
.level-name { font-size: 19px; font-weight: 800; }
.level-desc { color: var(--muted); font-size: 13px; line-height: 1.6; }
.level-enemy { font-size: 13px; color: #c3a6ff; }
.level-tags { margin-top: 4px; }
.level-lock { color: var(--muted); font-size: 14px; padding: 8px 0; }
.btn-enter { margin-top: auto; justify-content: center; }

/* ---------- 图鉴 ---------- */
.dex-hint { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.dex-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.dex-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px;
  border-left: 4px solid var(--c);
}
.dex-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.dex-icon { font-size: 22px; }
.dex-name { font-weight: 800; font-size: 16px; }
.dex-stars { margin-left: auto; color: var(--gold); font-size: 13px; letter-spacing: 1px; }
.dex-desc { color: var(--muted); font-size: 13px; line-height: 1.6; margin-bottom: 10px; }
.dex-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.dex-tag { color: var(--c); font-weight: 700; }
.dex-acc { color: var(--muted); }

/* ---------- 历史战绩 ---------- */
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px;
  display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center;
}
.hi-level { font-weight: 800; }
.hi-mvp, .hi-assist { color: var(--muted); font-size: 14px; }
.hi-time { margin-left: auto; color: var(--muted); font-size: 12px; }

/* ---------- 地图 ---------- */
.map-head { display: flex; align-items: center; gap: 14px; margin: 10px 0 14px; }
.map-head h2 { font-size: 22px; }
.map-progress { color: var(--muted); font-size: 14px; margin-left: auto; }
.map-hp { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.map-path { display: flex; flex-direction: column; gap: 14px; }
.map-row { display: flex; gap: 12px; justify-content: center; }
.map-row.passed { opacity: .35; }
.map-row:not(.current) { pointer-events: none; }
.map-node {
  flex: 1; max-width: 180px; display: flex; align-items: center; gap: 8px;
  padding: 14px 12px; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--line); cursor: pointer; transition: .18s; font-size: 14px;
}
.map-node.current-row { }
.map-row.current .map-node { border-color: rgba(109,139,255,.6); box-shadow: 0 0 0 3px rgba(109,139,255,.18); }
.map-node:hover { transform: translateY(-3px); }
.map-node.resolved { opacity: .45; }
.map-node.elite { border-color: rgba(255,92,122,.5); }
.map-node.shop { border-color: rgba(245,197,66,.5); }
.map-node.treasure { border-color: rgba(52,211,153,.5); }
.map-node.rest { border-color: rgba(255,159,67,.5); }
.map-node.miniboss { border-color: rgba(167,139,250,.6); }
.map-node.boss { border-color: rgba(245,197,66,.8); }
.mn-icon { font-size: 20px; }
.mn-name { font-weight: 700; }

/* ---------- 战斗 ---------- */
.battle-enemy { display: flex; align-items: center; gap: 14px; margin: 6px 0 10px; }
.be-icon { font-size: 40px; filter: drop-shadow(0 4px 10px rgba(0,0,0,.4)); }
.be-name { font-size: 20px; font-weight: 800; }
.be-diff { color: var(--gold); font-size: 13px; margin-top: 2px; }
.be-source {
  margin-left: auto; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: rgba(245,197,66,.15); color: var(--gold2); border: 1px solid rgba(245,197,66,.4);
}
.battle-hp { margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.battle-question { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 16px; }
.bq-stem { font-size: 18px; line-height: 1.75; font-weight: 500; }
.bq-tags { margin-top: 12px; }

.battle-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.option {
  display: flex; align-items: flex-start; gap: 12px; text-align: left;
  padding: 16px; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--line); color: var(--text); cursor: pointer;
  font-size: 15px; line-height: 1.6; transition: .15s; font-family: var(--font);
}
.option:hover:not(:disabled) { border-color: var(--primary); transform: translateY(-2px); }
.option:disabled { cursor: default; }
.option.hidden { opacity: .15; pointer-events: none; }
.opt-letter {
  flex: none; width: 26px; height: 26px; border-radius: 8px; display: inline-flex;
  align-items: center; justify-content: center; background: rgba(109,139,255,.2);
  color: var(--primary); font-weight: 800; font-size: 14px;
}
.option.is-correct { border-color: var(--green); background: rgba(52,211,153,.12); }
.option.is-correct .opt-letter { background: var(--green); color: #052; }
.option.is-wrong { border-color: var(--red); background: rgba(255,92,122,.12); }
.option.is-wrong .opt-letter { background: var(--red); color: #fff; }
.option.reveal-correct { border-color: var(--green); box-shadow: 0 0 0 3px rgba(52,211,153,.25); }

.battle-items { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.bi-title { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.bi-row { display: flex; flex-wrap: wrap; gap: 8px; }
.bi-empty { color: var(--muted); font-size: 13px; }
.bi-item {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
  border-radius: 999px; background: var(--panel2); border: 1px solid var(--line);
  color: var(--text); cursor: pointer; font-size: 13px; transition: .15s; font-family: var(--font);
}
.bi-item:hover { border-color: var(--gold); transform: translateY(-2px); }
.bi-icon { font-size: 16px; }
.bi-count { color: var(--gold); font-weight: 700; }

.battle-feedback { margin-top: 16px; }
.feedback { border-radius: 14px; padding: 18px; line-height: 1.7; }
.feedback.correct { background: rgba(52,211,153,.1); border: 1px solid rgba(52,211,153,.4); }
.feedback.wrong { background: rgba(255,92,122,.1); border: 1px solid rgba(255,92,122,.4); }
.feedback.hint { background: rgba(109,139,255,.1); border: 1px solid rgba(109,139,255,.4); }
.fb-head { font-size: 17px; font-weight: 800; margin-bottom: 8px; }
.fb-answer { color: var(--green); font-weight: 700; margin-bottom: 8px; }
.fb-explain { color: var(--text); font-size: 14px; }
.fb-kb { margin-top: 12px; }
.fb-next { margin-top: 14px; }

/* ---------- 商店 ---------- */
.shop-hint { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.shop-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.shop-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px;
  display: flex; flex-direction: column; gap: 8px; position: relative;
}
.shop-card.rare { border-color: rgba(109,139,255,.5); }
.shop-card.epic { border-color: rgba(167,139,250,.55); }
.shop-card.legendary { border-color: rgba(245,197,66,.6); background: linear-gradient(135deg, rgba(245,197,66,.08), var(--panel)); }
.sc-icon { font-size: 32px; }
.sc-name { font-size: 17px; font-weight: 800; }
.sc-rarity { font-size: 12px; color: var(--muted); }
.sc-desc { color: var(--muted); font-size: 13px; line-height: 1.6; }
.sc-kb { font-size: 12px; color: var(--purple); }
.shop-card .btn { margin-top: auto; justify-content: center; }

/* ---------- 结果 ---------- */
.result-box { text-align: center; padding: 60px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.result-icon { font-size: 40px; margin-bottom: 16px; font-weight: 700; }
.result-desc { color: var(--muted); margin-bottom: 24px; }

/* ---------- Boss 开场 ---------- */
.boss-intro-box { text-align: center; padding: 50px 24px; background: var(--panel); border: 1px solid rgba(245,197,66,.4); border-radius: var(--radius); }
.boss-icon { font-size: 64px; margin-bottom: 12px; }
.boss-intro-box h2 { font-size: 28px; margin-bottom: 16px; color: var(--gold); }
.boss-intro-box p { color: var(--muted); line-height: 1.8; margin-bottom: 8px; }
.boss-rules { color: #ffb4c2 !important; font-size: 14px; }
#btn-boss-go { margin-top: 20px; font-size: 17px; }

/* ---------- MVP 结算 ---------- */
.mvp-head { text-align: center; padding: 26px 20px; border-radius: var(--radius); margin-bottom: 18px; }
.mvp-head.win { background: linear-gradient(135deg, rgba(52,211,153,.15), rgba(109,139,255,.15)); border: 1px solid rgba(52,211,153,.4); }
.mvp-head.lose { background: linear-gradient(135deg, rgba(255,92,122,.15), rgba(167,139,250,.12)); border: 1px solid rgba(255,92,122,.4); }
.mvp-banner { font-size: 26px; font-weight: 900; margin-bottom: 6px; }
.mvp-level { color: var(--muted); }

.mvp-medals { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.medal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; text-align: center; }
.medal-mvp { border-color: rgba(245,197,66,.6); background: linear-gradient(135deg, rgba(245,197,66,.12), var(--panel)); }
.medal-assist { border-color: rgba(192,205,224,.5); }
.medal-icon { font-size: 40px; margin-bottom: 8px; }
.medal-label { font-weight: 800; font-size: 14px; color: var(--muted); }
.medal-name { font-size: 20px; font-weight: 900; margin: 6px 0; }
.medal-note { font-size: 12px; color: var(--muted); }

.mvp-ranking { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 16px; }
.mvp-ranking-title { font-weight: 800; margin-bottom: 14px; }
.mvp-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 8px;
  border-bottom: 1px solid var(--line); border-left: 4px solid var(--c); padding-left: 14px;
}
.mvp-row:last-child { border-bottom: none; }
.mvp-rank { font-size: 16px; width: 28px; text-align: center; }
.mvp-icon { font-size: 20px; }
.mvp-name { font-weight: 700; }
.mvp-stars { color: var(--gold); font-size: 12px; letter-spacing: 1px; }
.mvp-score { margin-left: auto; color: var(--muted); font-size: 13px; }

.mvp-reward { text-align: center; color: var(--gold); font-weight: 700; margin-bottom: 18px; }
.mvp-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel2); border: 1px solid rgba(245,197,66,.5); color: var(--gold2);
  padding: 12px 22px; border-radius: 999px; font-weight: 700; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 100; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .home-title { font-size: 34px; }
  .home-cards, .level-grid, .dex-grid, .shop-grid { grid-template-columns: 1fr; }
  .battle-options { grid-template-columns: 1fr; }
  .mvp-medals { grid-template-columns: 1fr; }
  #hud { gap: 10px; font-size: 12px; }
}

/* ============================================================
 * 新增：数学公式渲染样式
 * ============================================================ */
.m { font-style: normal; letter-spacing: 0; }
.m-sup { font-size: 0.72em; vertical-align: 0.5em; line-height: 1; }
.m-sub { font-size: 0.72em; vertical-align: -0.18em; line-height: 1; }
.m-frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 2px; line-height: 1; }
.m-frac .m-num { display: block; padding: 0 4px 2px; border-bottom: 1px solid currentColor; font-size: 0.82em; }
.m-frac .m-den { display: block; padding: 2px 4px 0; font-size: 0.82em; }
.m-sqrt { display: inline-flex; align-items: stretch; line-height: 1; }
.m-sqrt::before { content: '√'; font-size: 1.05em; margin-right: 1px; }
.m-sqrt .m-radic { border-top: 1px solid currentColor; padding: 1px 2px 0; }
.m-big { font-size: 1.4em; vertical-align: -0.18em; margin: 0 1px; line-height: 1; }
.m-binom { white-space: nowrap; }
.m-binom sub, .m-binom sup { font-size: 0.72em; line-height: 1; }
.m-overline { border-top: 1px solid currentColor; padding-top: 1px; }
.m-underline { border-bottom: 1px solid currentColor; }
.m-fn { font-style: normal; font-family: inherit; }
.m-text { font-family: var(--font); font-style: normal; }
.m-hat { position: relative; display: inline-block; }
.m-hat::before { content: '^'; position: absolute; top: -0.72em; left: 50%; transform: translateX(-50%); font-size: 0.7em; line-height: 1; }
.m-space { display: inline-block; width: 0.18em; }
.m-space.wide { width: 0.9em; }
.m-space.wider { width: 1.8em; }
.m-xarrow { display: inline-flex; align-items: center; gap: 2px; }
.m-xarrow .m-arr { font-size: 1.05em; }
.m-xarrow .m-arrlabel { font-size: 0.68em; vertical-align: 0.4em; line-height: 1; }

/* 题目/选项中的公式与文字对齐 */
.bq-stem .m, .option .m, .fb-explain .m, .fb-answer .m, .dd-math .m, .dd-q .m, .hint-formula .m { line-height: 1.6; }

/* ============================================================
 * 新增：首页收集进度 & 通用进度条
 * ============================================================ */
.hc-progress { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.hc-progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--gold), #f59e0b); transition: width .4s ease; }

.home-collect {
  max-width: 560px; margin: 26px auto 0; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px;
}
.hc-progress-label { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.hc-progress-label b { color: var(--gold); }
.hc-progress-sub { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.6; }

/* ============================================================
 * 新增：冒险手册（收集 + 局外养成）
 * ============================================================ */
.dex-progress-box { margin-bottom: 12px; }
.dex-progress-label { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.dex-progress-label b { color: var(--gold); }

.dex-milestones { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.dex-ms { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; opacity: .5; transition: .2s; }
.dex-ms.done { opacity: 1; border-color: rgba(245, 197, 66, .5); background: linear-gradient(135deg, rgba(245, 197, 66, .1), var(--panel)); }
.ms-icon { font-size: 20px; display: block; margin-bottom: 4px; }
.ms-name { font-size: 13px; font-weight: 700; }
.ms-n { font-size: 11px; color: var(--muted); display: block; margin-top: 2px; }

.dex-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.dex-tab {
  padding: 7px 15px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line);
  color: var(--muted); cursor: pointer; font-size: 13px; font-family: var(--font); transition: .15s;
}
.dex-tab:hover { border-color: rgba(255, 255, 255, .25); }
.dex-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.dex-card.locked { opacity: .5; filter: grayscale(.5); border-left-color: var(--line) !important; }
.dex-card.collected { cursor: pointer; transition: .18s; }
.dex-card.collected:hover { transform: translateY(-3px); border-color: var(--c); }
.dex-lv { color: var(--gold); font-weight: 700; }

.dex-detail { display: none; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.dex-detail.open { display: block; }
.dd-row { margin-bottom: 12px; }
.dd-row > b { display: block; font-size: 12px; color: var(--purple); margin-bottom: 6px; }
.dd-math { font-size: 16px; text-align: center; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.dd-text { font-size: 13px; line-height: 1.7; color: var(--text); }
.dd-q { font-size: 13px; line-height: 1.7; color: var(--muted); }
.dd-a { font-size: 13px; color: var(--green); font-weight: 700; margin-top: 4px; }
.dd-toggle { font-size: 12px; color: var(--muted); text-align: center; margin-top: 4px; }

/* ============================================================
 * 新增：hint 提示反馈 & MVP 新收集
 * ============================================================ */
.hint-head { font-weight: 800; font-size: 15px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hint-badge { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.hint-badge.hit { background: rgba(52, 211, 153, .18); color: var(--green); border: 1px solid rgba(52, 211, 153, .5); }
.hint-badge.fallback { background: rgba(245, 197, 66, .18); color: var(--gold2); border: 1px solid rgba(245, 197, 66, .5); }
.hint-formula { background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; font-size: 16px; text-align: center; }
.hint-tip { color: var(--text); font-size: 14px; line-height: 1.7; }

.mvp-newly { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 16px; line-height: 1.8; }
.mvp-newly-note { color: var(--purple); }

@media (max-width: 640px) {
  .dex-milestones { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
 * 新增：AI 助教（答题后提问 + 结构化回答 + 设置页）
 * ============================================================ */
.fb-actions { display: flex; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.fb-actions .fb-next { margin-top: 0; }

.btn-ai {
  background: rgba(167, 139, 250, .14);
  border: 1px solid rgba(167, 139, 250, .45);
  color: #d9c9ff;
}
.btn-ai:hover { background: rgba(167, 139, 250, .26); border-color: rgba(167, 139, 250, .7); }

/* ---------- 对话面板 ---------- */
.ai-panel {
  margin-top: 16px; border-radius: 14px; overflow: hidden;
  background: rgba(15, 21, 42, .9); border: 1px solid rgba(167, 139, 250, .4);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .4);
  animation: fadeIn .25s ease;
}
.ai-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(167, 139, 250, .22), rgba(109, 139, 255, .16));
  border-bottom: 1px solid rgba(167, 139, 250, .3);
}
.ai-title { font-weight: 800; font-size: 16px; }
.ai-sub { color: var(--muted); font-size: 12px; flex: 1; }
.ai-head-actions { display: flex; gap: 6px; }
.ai-head-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--muted); cursor: pointer; font-size: 14px;
  transition: .15s; font-family: var(--font);
}
.ai-head-btn:hover { color: var(--text); border-color: rgba(255, 255, 255, .3); }
.ai-history-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: rgba(245, 197, 66, .14); color: var(--gold);
  border: 1px solid rgba(245, 197, 66, .4); white-space: nowrap;
}
.ai-head-btn.ai-clear-history:hover { color: #ff8a8a; border-color: rgba(255, 120, 120, .55); }

.ai-quick { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px 4px; }
.ai-chip {
  padding: 7px 13px; border-radius: 999px; cursor: pointer; font-size: 13px;
  background: rgba(109, 139, 255, .12); border: 1px solid rgba(109, 139, 255, .35);
  color: #c7d4ff; transition: .15s; font-family: var(--font);
}
.ai-chip:hover { background: rgba(109, 139, 255, .24); transform: translateY(-2px); }

.ai-conv {
  padding: 12px 16px; max-height: 420px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}
.ai-empty { color: var(--muted); font-size: 13px; padding: 12px 0; text-align: center; }

.ai-msg { display: flex; margin: 6px 0; }
.ai-msg.user { justify-content: flex-end; }
.ai-msg.user .ai-bubble {
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  color: #fff; border-radius: 14px 14px 4px 14px; max-width: 82%;
}
.ai-msg.ai { justify-content: flex-start; gap: 8px; }
.ai-msg.ai .ai-bubble {
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 4px 14px 14px 14px; max-width: 88%;
}
.ai-avatar { font-size: 22px; flex: none; margin-top: 2px; }
.ai-bubble { padding: 10px 14px; font-size: 14px; line-height: 1.65; word-break: break-word; }

/* 加载动画 */
.ai-loading { display: flex; align-items: center; gap: 6px; padding: 14px 16px; }
.ai-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--purple);
  animation: aiBounce 1.2s infinite ease-in-out;
}
.ai-dot:nth-child(2) { animation-delay: .15s; }
.ai-dot:nth-child(3) { animation-delay: .3s; }
.ai-loading-text { color: var(--muted); font-size: 13px; margin-left: 6px; }
@keyframes aiBounce {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}

.ai-input-row { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }
.ai-input {
  flex: 1; padding: 11px 14px; border-radius: 10px; background: #0c1226;
  border: 1px solid var(--line); color: var(--text); font-size: 14px; font-family: var(--font);
}
.ai-input:focus { outline: none; border-color: var(--primary); }
.ai-send {
  padding: 11px 20px; border-radius: 10px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary2)); color: #fff;
  font-weight: 700; font-size: 14px; font-family: var(--font); transition: .15s;
}
.ai-send:hover { box-shadow: 0 6px 18px rgba(79, 110, 247, .5); }

/* ---------- 回答的 Markdown 结构 ---------- */
.ai-bubble .m { line-height: 1.6; }
.ai-bubble .ai-h { margin: 12px 0 6px; font-size: 16px; line-height: 1.4; }
.ai-bubble .ai-h:first-child { margin-top: 0; }
.ai-bubble h1.ai-h { font-size: 18px; color: var(--gold); padding-bottom: 6px; border-bottom: 1px dashed rgba(245, 197, 66, .35); }
.ai-bubble h2.ai-h { font-size: 17px; color: var(--gold); padding-bottom: 5px; border-bottom: 1px dashed rgba(245, 197, 66, .35); }
.ai-bubble h3.ai-h { font-size: 15px; color: #d9c9ff; }
.ai-bubble h4.ai-h { font-size: 14px; color: var(--purple); }
.ai-bubble .ai-p { margin: 6px 0; }
.ai-bubble .ai-ul, .ai-bubble .ai-ol { margin: 6px 0; padding-left: 20px; }
.ai-bubble .ai-ul li, .ai-bubble .ai-ol li { margin: 4px 0; }
.ai-bubble strong { color: var(--gold2); }
.ai-bubble .ai-quote {
  margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--primary);
  background: rgba(109, 139, 255, .08); color: #c7d4ff; border-radius: 0 8px 8px 0; font-size: 13px;
}
.ai-bubble .ai-code {
  background: #0a0f1f; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; overflow-x: auto; margin: 8px 0;
  font-family: "SFMono-Regular", Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.6;
}
.ai-bubble .ai-ic {
  background: rgba(255, 255, 255, .08); padding: 1px 6px; border-radius: 5px;
  font-family: Consolas, monospace; font-size: .9em;
}
.ai-bubble .ai-hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }

/* ---------- AI 设置页 ---------- */
.ai-settings-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; max-width: 640px;
}
.ai-notice {
  background: rgba(245, 197, 66, .12); border: 1px solid rgba(245, 197, 66, .4);
  color: var(--gold2); border-radius: 10px; padding: 12px 16px; font-size: 14px; margin-bottom: 16px;
}
.ai-settings-tip { color: var(--muted); font-size: 13px; line-height: 1.7; margin-bottom: 18px; }
.ai-settings-tip code {
  background: rgba(255, 255, 255, .08); padding: 1px 6px; border-radius: 5px;
  font-family: Consolas, monospace; font-size: 12px; color: #c7d4ff;
}
.ai-field { display: block; margin-bottom: 16px; }
.ai-field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.ai-field input, .ai-field textarea {
  width: 100%; padding: 12px 14px; border-radius: 10px; background: #0c1226;
  border: 1px solid var(--line); color: var(--text); font-size: 14px; font-family: var(--font);
  resize: vertical;
}
.ai-field input:focus, .ai-field textarea:focus { outline: none; border-color: var(--primary); }
.ai-settings-actions { display: flex; gap: 12px; margin-top: 4px; }
.ai-test-result { margin-top: 16px; font-size: 14px; }
.ai-testing { color: var(--muted); }
.ai-test-ok { color: var(--green); }
.ai-test-ok span { color: var(--text); }
.ai-test-fail { color: var(--red); }

@media (max-width: 640px) {
  .ai-msg.user .ai-bubble, .ai-msg.ai .ai-bubble { max-width: 92%; }
  .ai-conv { max-height: 340px; }
}

/* ============================================================
 * 教学关（Lesson）
 * ============================================================ */
.lesson-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px;
}
.lesson-badge {
  padding: 5px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap;
  background: linear-gradient(135deg, rgba(245,197,66,.2), rgba(255,223,126,.12));
  color: var(--gold2); border: 1px solid rgba(245,197,66,.45);
}
.lesson-level { color: var(--muted); font-size: 14px; font-weight: 600; }
.lesson-progress-bar {
  flex: 1; min-width: 100px; height: 10px; border-radius: 999px;
  background: rgba(255,255,255,.08); overflow: hidden;
}
.lesson-progress-fill {
  height: 100%; border-radius: 999px; transition: width .4s ease;
  background: linear-gradient(90deg, var(--primary), var(--purple));
}
.lesson-count { color: var(--muted); font-size: 13px; white-space: nowrap; }

.lesson-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 26px; box-shadow: var(--shadow);
  border-top: 3px solid var(--c, var(--primary));
  animation: lessonIn .45s ease;
}
@keyframes lessonIn { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }

.lc-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.lc-icon { font-size: 42px; line-height: 1; animation: floatY 2.4s ease-in-out infinite; }
@keyframes floatY { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.lc-titles { flex: 1; }
.lc-title { font-size: 20px; font-weight: 800; line-height: 1.3; }
.lc-kname { font-size: 13px; color: var(--c, var(--gold)); font-weight: 700; margin-top: 3px; }
.lc-stars { font-size: 15px; color: var(--gold); letter-spacing: 1px; white-space: nowrap; }

.lc-story {
  background: rgba(255,255,255,.04); border-left: 3px solid var(--c, var(--primary));
  padding: 14px 16px; border-radius: 0 12px 12px 0; margin-bottom: 18px;
  font-size: 15px; line-height: 1.85; color: var(--text);
}
.lc-story .m { color: #fff; }

.lc-chart {
  background: rgba(10,15,31,.6); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px; margin-bottom: 18px; overflow: hidden;
}
.lc-chart svg { display: block; width: 100%; height: auto; }

.lc-formula-label { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: 1px; margin-bottom: 6px; }
.lc-formula {
  background: linear-gradient(135deg, rgba(109,139,255,.12), rgba(167,139,250,.12));
  border: 1px dashed rgba(109,139,255,.4); border-radius: 14px;
  padding: 18px; text-align: center; font-size: 20px; margin-bottom: 18px;
}
.lc-formula .m { color: #fff; }

.lc-steps { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.lc-step { display: flex; align-items: flex-start; gap: 12px; }
.ls-num {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--c, var(--primary)); color: #0b1020; font-weight: 800;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.ls-text { font-size: 15px; line-height: 1.7; color: var(--text); flex: 1; padding-top: 2px; }
.ls-text .m { color: #fff; }

.lc-mnemonic {
  display: flex; align-items: center; gap: 8px;
  background: rgba(245,197,66,.1); border: 1px solid rgba(245,197,66,.35);
  color: var(--gold2); border-radius: 12px; padding: 12px 16px; font-size: 15px; font-weight: 600;
}
.lm-icon { font-size: 18px; }

.lesson-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; gap: 12px; }
.lesson-actions .btn { font-size: 16px; padding: 13px 26px; }

/* 关卡卡片按钮组 */
.level-actions { display: flex; gap: 10px; margin-top: 6px; }
.level-actions .btn { flex: 1; justify-content: center; }
.btn-review { border-color: rgba(167,139,250,.4); color: #c7b5ff; }
.btn-review:hover { border-color: rgba(167,139,250,.75); color: #e3d9ff; }

/* ---------- 图表动画 ---------- */
.chart-dot { transform-box: fill-box; transform-origin: center; animation: dotPop .5s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes dotPop { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } }
.chart-bell-line { stroke-dasharray: 1200; stroke-dashoffset: 1200; animation: draw 1.6s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.chart-bar { transform-box: fill-box; transform-origin: bottom; animation: growUp .7s ease both; }
@keyframes growUp { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.chart-node { transform-box: fill-box; transform-origin: center; animation: nodeIn .5s ease both; }
@keyframes nodeIn { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: scale(1); } }
.chart-edge { stroke-dasharray: 200; stroke-dashoffset: 200; animation: draw 1s ease forwards; }
.chart-venn-a, .chart-venn-b { transform-box: fill-box; transform-origin: center; animation: vennIn .8s ease both; }
@keyframes vennIn { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }

@media (max-width: 640px) {
  .lesson-card { padding: 18px; }
  .lc-title { font-size: 17px; }
  .lc-formula { font-size: 17px; }
}
