/* ============================================================
   千羽宗期权学堂 · 设计系统
   克制高级：深蓝黑底 + 单一品牌蓝 + 红/绿仅用于盈亏 + 高对比中性灰阶
============================================================ */
:root {
  --bg: #0a0e15;
  --bg2: #0e1320;
  --panel: #131a28;
  --panel2: #19212f;
  --card: #121826;
  --card-hi: #161e2d;
  --border: #283041;
  --border-hi: #3a4459;
  --text: #eef2f8;
  --text2: #b3bfd0;
  --text3: #8593a6;
  --brand: #4f8ef7;
  --brand-d: #3a72d8;
  --brand-soft: rgba(79,142,247,.12);
  --green: #14c98a;
  --red: #f6465d;
  --amber: #e0a93a;
  --shadow: rgba(0,0,0,.4);
  --ease: cubic-bezier(.22,.61,.36,1);
  --r: 16px;
}
body.light {
  --bg: #f4f6fb;
  --bg2: #ffffff;
  --panel: #ffffff;
  --panel2: #f3f6fb;
  --card: #ffffff;
  --card-hi: #ffffff;
  --border: #e2e8f2;
  --border-hi: #ccd6e6;
  --text: #161f2e;
  --text2: #4d5b72;
  --text3: #74829a;
  --brand: #2f6fe0;
  --brand-d: #2459c2;
  --brand-soft: rgba(47,111,224,.09);
  --green: #0a9f6a;
  --red: #e0344b;
  --amber: #c08418;
  --shadow: rgba(25,40,70,.10);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px; line-height: 1.75; min-height: 100vh;
  transition: background .3s, color .3s; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.hidden { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }
::selection { background: rgba(79,142,247,.28); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { 0% { transform: scale(.92); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes bounce { 0% { transform: scale(.4); } 55% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* ============ 顶栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px 12px; padding: 12px 24px;
  background: color-mix(in srgb, var(--bg2) 88%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.back-site { flex-shrink: 0; display: inline-flex; align-items: center; background: var(--panel); border: 1px solid var(--border); color: var(--text2); padding: 6px 13px; border-radius: 9px; font-size: 13px; text-decoration: none; white-space: nowrap; transition: all .18s var(--ease); }
.back-site:hover { border-color: var(--brand); color: var(--brand); }
.brand { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.brand:active { opacity: .7; }
.brand-icon { width: 32px; height: 32px; border-radius: 9px; font-size: 16px; display: flex; align-items: center; justify-content: center; background: var(--brand-soft); border: 1px solid rgba(79,142,247,.32); }
.brand-name { font-size: 16.5px; font-weight: 700; letter-spacing: .3px; white-space: nowrap; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.xp-box { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--border); padding: 4px 11px 4px 4px; border-radius: 20px; }
.level-badge { background: var(--brand); color: #fff; font-weight: 700; font-size: 11.5px; padding: 3px 11px; border-radius: 13px; }
.xp-bar { width: 90px; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
body.light .xp-bar { background: #e4eaf4; }
.xp-fill { height: 100%; width: 0; background: var(--brand); transition: width .7s var(--ease); border-radius: 3px; }
.xp-text { font-size: 11.5px; color: var(--text2); font-variant-numeric: tabular-nums; }
.icon-btn { background: var(--panel); border: 1px solid var(--border); color: var(--text); width: 34px; height: 34px; border-radius: 9px; font-size: 15px; transition: all .18s var(--ease); }
.icon-btn:hover { border-color: var(--border-hi); }
.icon-btn:active { transform: scale(.92); }

#main { max-width: 1000px; margin: 0 auto; padding: 0 20px 72px; }
#homeView, #lessonView { animation: fadeIn .25s ease both; }

/* ============ Hero ============ */
.hero { position: relative; margin: 28px 0 10px; padding: 40px 32px 34px; text-align: center; overflow: hidden; border: 1px solid var(--border); border-radius: 22px; background: linear-gradient(180deg, var(--panel) 0%, var(--card) 100%); }
#heroCv { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hero-in { position: relative; z-index: 1; }
.hero-pill { display: inline-block; font-size: 12.5px; color: var(--text2); background: var(--bg2); border: 1px solid var(--border); border-radius: 20px; padding: 5px 16px; margin-bottom: 20px; animation: fadeUp .45s var(--ease) both; }
.hero h1 { font-size: clamp(28px, 4.8vw, 42px); line-height: 1.28; font-weight: 800; letter-spacing: .5px; margin-bottom: 16px; animation: fadeUp .45s .05s var(--ease) both; }
.hero h1 .hl { color: var(--brand); }
.hero p { color: var(--text2); max-width: 480px; margin: 0 auto; font-size: 15px; animation: fadeUp .45s .1s var(--ease) both; }
.hero-cta { margin-top: 26px; display: inline-flex; flex-direction: column; gap: 2px; align-items: center; padding: 13px 40px; background: var(--brand); color: #fff; border: none; border-radius: 13px; font-size: 16px; font-weight: 700; box-shadow: 0 8px 26px rgba(79,142,247,.32); animation: fadeUp .45s .15s var(--ease) both; transition: all .18s var(--ease); }
.hero-cta:hover { background: var(--brand-d); transform: translateY(-2px); box-shadow: 0 12px 30px rgba(79,142,247,.4); }
.hero-cta:active { transform: scale(.97); }
.hero-cta .sub { font-size: 11.5px; font-weight: 400; opacity: .9; }
.hero-cta:disabled { background: var(--panel2); color: var(--text2); box-shadow: none; }
.hstats { display: flex; justify-content: center; gap: 12px; margin-top: 30px; flex-wrap: wrap; animation: fadeUp .45s .2s var(--ease) both; }
.hstat { min-width: 116px; padding: 14px 20px; border-radius: 14px; text-align: center; background: var(--bg2); border: 1px solid var(--border); }
.hstat .n { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text); }
.hstat .n .dim { font-size: 15px; color: var(--text3); font-weight: 600; }
.hstat .l { font-size: 11.5px; color: var(--text2); margin-top: 3px; }

/* ============ 徽章 ============ */
.bwall { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 22px 24px; margin: 24px 0 32px; }
.bwall h3 { font-size: 14.5px; margin-bottom: 16px; color: var(--text); }
.badges { display: flex; gap: 16px; flex-wrap: wrap; }
.bitem { text-align: center; width: 78px; }
.bi { width: 52px; height: 52px; margin: 0 auto 7px; border-radius: 14px; background: var(--panel2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 24px; filter: grayscale(1); opacity: .4; transition: all .25s var(--ease); }
.bitem.earned .bi { filter: none; opacity: 1; border-color: var(--brand); background: var(--brand-soft); }
.bn { font-size: 11px; color: var(--text3); line-height: 1.35; }
.bitem.earned .bn { color: var(--text2); }

/* ============ 章节 ============ */
.chapter { margin-bottom: 34px; animation: fadeUp .4s var(--ease) both; }
.chead { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.cicon { width: 44px; height: 44px; border-radius: 12px; font-size: 21px; display: flex; align-items: center; justify-content: center; background: var(--panel); border: 1px solid var(--border); flex-shrink: 0; }
.ctitle { font-size: 17.5px; font-weight: 700; color: var(--text); }
.cdesc { font-size: 12.5px; color: var(--text2); margin-top: 1px; }
.cprog { margin-left: auto; font-size: 12.5px; color: var(--text2); white-space: nowrap; display: flex; align-items: center; gap: 9px; font-variant-numeric: tabular-nums; }
.cbar { width: 72px; height: 5px; background: var(--panel2); border-radius: 3px; overflow: hidden; }
.cfill { height: 100%; background: var(--brand); border-radius: 3px; transition: width .6s var(--ease); }

.lgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 13px; }
.lcard { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 16px 17px 15px; cursor: pointer; position: relative; transition: all .2s var(--ease); min-height: 104px; display: flex; flex-direction: column; gap: 9px; overflow: hidden; animation: fadeUp .4s var(--ease) both; }
.lcard:hover { border-color: var(--brand); transform: translateY(-3px); box-shadow: 0 12px 26px var(--shadow); }
.lcard:active { transform: translateY(-1px); }
.lcard.locked { opacity: .5; cursor: not-allowed; }
.lcard.locked:hover { transform: none; border-color: var(--border); box-shadow: none; }
.lcard.next { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand-soft); }
.ltop { display: flex; align-items: center; gap: 8px; }
.lchip { font-size: 11px; font-weight: 700; color: var(--text2); background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 8px; font-variant-numeric: tabular-nums; }
.lcard.done .lchip { color: var(--green); border-color: rgba(20,201,138,.35); }
.lcard.next .lchip { color: var(--brand); border-color: rgba(79,142,247,.4); }
.lstate { margin-left: auto; font-size: 13px; color: var(--text3); }
.lcard.done .lstate, .lcard.next .lstate { color: var(--brand); }
.lcard .ltitle { font-weight: 650; font-size: 15px; line-height: 1.5; color: var(--text); }
.ltags { display: flex; gap: 6px; margin-top: auto; }
.ltag { font-size: 11px; padding: 2px 9px 2px 7px; border-radius: 8px; background: var(--panel2); color: var(--text2); border: 1px solid var(--border); display: inline-flex; align-items: center; gap: 5px; }
.ltag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--text3); }
.ltag.quiz::before { background: var(--brand); }
.ltag.tool::before { background: var(--green); }
.ltag.game::before { background: var(--amber); }
.lline { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--panel2); }
.lline::after { content: ''; position: absolute; inset: 0; width: 0; background: var(--green); transition: width .5s var(--ease); }
.lline.full::after { width: 100%; }

/* ============ 课程页 ============ */
.ltop2 { display: flex; align-items: center; gap: 14px; margin: 24px 0 20px; flex-wrap: wrap; animation: fadeUp .35s var(--ease) both; }
.back { background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 8px 16px; border-radius: 10px; font-size: 14px; transition: all .18s var(--ease); }
.back:hover { border-color: var(--brand); color: var(--brand); }
.lh1 { font-size: 21px; font-weight: 700; color: var(--text); }
.lmeta { font-size: 12.5px; color: var(--text2); margin-top: 1px; }
.block { margin-bottom: 16px; animation: fadeUp .4s var(--ease) both; }
.txt, .quiz, .wbox { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 24px 28px; }
.txt h3 { font-size: 16.5px; margin-bottom: 13px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 10px; }
.txt h3::before { content: ''; width: 3px; height: 16px; border-radius: 2px; background: var(--brand); flex-shrink: 0; }
.txt h4 { font-size: 14.5px; margin: 18px 0 8px; color: var(--text); font-weight: 700; }
.txt p { margin-bottom: 11px; color: var(--text); }
.txt p:last-child { margin-bottom: 0; }
.txt ul, .txt ol { padding-left: 22px; margin-bottom: 11px; }
.txt li { margin-bottom: 7px; color: var(--text); }
.txt li::marker { color: var(--text3); }
.txt strong { color: var(--text); font-weight: 700; }
.txt em { color: var(--brand); font-style: normal; font-weight: 600; }
.txt .tip { background: var(--brand-soft); border: 1px solid rgba(79,142,247,.22); border-left: 3px solid var(--brand); padding: 13px 16px; border-radius: 10px; margin: 14px 0; font-size: 13.5px; color: var(--text); }
.txt .warn { background: rgba(246,70,93,.07); border: 1px solid rgba(246,70,93,.2); border-left: 3px solid var(--red); padding: 13px 16px; border-radius: 10px; margin: 14px 0; font-size: 13.5px; color: var(--text); }
.txt .warn strong { color: var(--red); }
.txt table { width: 100%; border-collapse: separate; border-spacing: 0; margin: 14px 0; font-size: 13.5px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.txt th, .txt td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 10px 14px; text-align: left; color: var(--text); }
.txt th:last-child, .txt td:last-child { border-right: none; }
.txt tr:last-child td { border-bottom: none; }
.txt th { background: var(--panel2); font-weight: 700; font-size: 12.5px; color: var(--text2); }
.txt tbody tr:hover td, .txt tr:hover td { background: var(--brand-soft); }
.txt code { background: var(--panel2); padding: 1.5px 7px; border-radius: 5px; font-family: "SF Mono", Menlo, monospace; font-size: 12.5px; border: 1px solid var(--border); color: var(--brand); }

/* quiz */
.q { font-weight: 650; font-size: 15px; margin-bottom: 15px; color: var(--text); }
.qb { display: inline-block; background: var(--brand-soft); color: var(--brand); font-size: 11px; padding: 2px 9px; border-radius: 8px; margin-right: 8px; vertical-align: 2px; border: 1px solid rgba(79,142,247,.3); font-weight: 700; }
.opts { display: flex; flex-direction: column; gap: 9px; }
.opt { text-align: left; background: var(--panel2); border: 1px solid var(--border); color: var(--text); padding: 13px 16px; border-radius: 10px; font-size: 14.5px; transition: all .18s var(--ease); line-height: 1.55; }
.opt:hover:not(:disabled) { border-color: var(--brand); }
.opt:active:not(:disabled) { transform: scale(.99); }
.opt:disabled { cursor: default; }
.opt.correct { border-color: var(--green); background: rgba(20,201,138,.1); }
.opt.wrong { border-color: var(--red); background: rgba(246,70,93,.08); animation: shake .35s ease; opacity: .75; }
.exp { margin-top: 13px; padding: 13px 16px; border-radius: 10px; font-size: 13.5px; background: var(--panel2); border: 1px solid var(--border); display: none; color: var(--text); }
.exp.show { display: block; animation: fadeUp .3s var(--ease); }
.exp .ok { color: var(--green); font-weight: 700; }
.exp .no { color: var(--red); font-weight: 700; }

/* ============ Widget 通用 ============ */
.wbox h3 { font-size: 15.5px; margin-bottom: 12px; font-weight: 700; color: var(--text); }
.wb { display: inline-block; background: rgba(20,201,138,.12); color: var(--green); font-size: 11px; padding: 2px 9px; border-radius: 8px; margin-right: 8px; vertical-align: 2px; border: 1px solid rgba(20,201,138,.3); font-weight: 700; }
.whint { color: var(--text2); font-size: 13px; margin-bottom: 14px; }
.werr { color: var(--text2); font-size: 14px; }
.ctrl { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.ctrl label { font-size: 13px; color: var(--text2); min-width: 76px; }
.ctrl input[type=range] { flex: 1; min-width: 130px; accent-color: var(--brand); height: 5px; cursor: pointer; }
.ctrl .val { font-weight: 700; min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.chart-wrap { position: relative; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin: 6px 0 12px; }
body.light .chart-wrap { background: #fafcff; }
.chart-wrap canvas { display: block; width: 100%; }
.rgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; margin-top: 6px; }
.rc { background: var(--panel2); border: 1px solid var(--border); border-radius: 11px; padding: 12px 14px; text-align: center; }
.rl { font-size: 11.5px; color: var(--text2); }
.rv { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text); margin-top: 2px; }
.rv.up { color: var(--green); }
.rv.down { color: var(--red); }
.rv.warn-c { color: var(--brand); }
.tip { background: var(--brand-soft); border: 1px solid rgba(79,142,247,.22); border-left: 3px solid var(--brand); padding: 13px 16px; border-radius: 10px; margin-top: 12px; font-size: 13px; color: var(--text); }

/* 头寸切换 */
.seg4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 11px; padding: 4px; margin-bottom: 8px; }
body.light .seg4 { background: #eaf0f8; }
.seg4 button { background: transparent; border: none; color: var(--text2); padding: 9px 4px; font-size: 12.5px; font-weight: 650; border-radius: 8px; transition: all .15s var(--ease); }
.seg4 button:hover { color: var(--text); }
.seg4 button.active { background: var(--brand); color: #fff; }
@media (max-width: 560px) { .seg4 { grid-template-columns: 1fr 1fr; } }

/* 买卖对比 */
.vs2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .vs2 { grid-template-columns: 1fr; } }
.vscard { background: var(--panel2); border: 1px solid var(--border); border-radius: 12px; padding: 16px; text-align: center; }
.vst { font-weight: 700; font-size: 13.5px; margin-bottom: 8px; color: var(--text); }
.vsp { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text); }
.vsn { font-size: 12px; color: var(--text2); margin-top: 5px; min-height: 30px; }

/* 价值分解堆叠条 */
.stackbar { display: flex; height: 32px; border-radius: 8px; overflow: hidden; margin: 8px 0 12px; border: 1px solid var(--border); background: var(--panel2); }
.sb-in { background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; min-width: 0; transition: width .3s; }
.sb-time { background: var(--amber); color: #1a1200; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; min-width: 0; transition: width .3s; }

/* 希腊字母说明 */
.glab { margin-top: 12px; background: var(--panel2); border: 1px solid var(--border); border-radius: 11px; padding: 13px 16px; font-size: 13px; display: flex; flex-direction: column; gap: 7px; color: var(--text); }
.glab strong { color: var(--brand); }

/* 策略 chips + 腿表 */
.chips { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 10px; }
.chips button { background: var(--panel2); border: 1px solid var(--border); color: var(--text2); padding: 7px 13px; border-radius: 18px; font-size: 12.5px; font-weight: 600; transition: all .15s var(--ease); }
.chips button:hover { border-color: var(--border-hi); color: var(--text); }
.chips button.active { border-color: var(--brand); color: #fff; background: var(--brand); }
.legtable { margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.legrow { display: flex; align-items: center; gap: 10px; background: var(--panel2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 13px; font-size: 13.5px; color: var(--text); }
.legd { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 6px; }
.legd.buy { color: var(--green); background: rgba(20,201,138,.13); }
.legd.sell { color: var(--red); background: rgba(246,70,93,.13); }
.legc { margin-left: auto; color: var(--text2); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* 游戏场景 */
.scene { background: var(--panel2); border: 1px solid var(--border); border-left: 3px solid var(--brand); border-radius: 11px; padding: 15px 17px; font-size: 14.5px; line-height: 1.7; margin-bottom: 10px; color: var(--text); }
.done2 { text-align: center; padding: 8px; }
.done2 .emoji { font-size: 42px; }
.done2 h3 { margin: 8px 0 6px; font-weight: 700; color: var(--text); }
.done2 p { color: var(--text2); font-size: 14px; margin-bottom: 14px; }

/* 通关区 + 按钮 */
#footer .done2 { text-align: center; padding: 28px; border-radius: 16px; background: var(--card); border: 1px solid var(--border); animation: fadeUp .35s var(--ease) both; }
.wbox .done2 { background: none; border: none; padding: 8px; }
.emoji { font-size: 42px; }
.cg { animation: bounce .55s var(--ease); }
.lnav { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn { border: none; border-radius: 11px; padding: 11px 18px; font-size: 14px; font-weight: 700; transition: all .18s var(--ease); }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; filter: none; transform: none; }
.btn-go { background: var(--brand); color: #fff; }
.btn-blue { background: var(--brand); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-plain { background: var(--panel2); color: var(--text); border: 1px solid var(--border); }
.btn-plain:hover { border-color: var(--border-hi); filter: none; }
.btn-block { width: 100%; }

/* H5 底栏 */
.mbar { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg2) 92%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--border); gap: 10px; }
.mbar .btn { padding: 13px 18px; font-size: 14.5px; }

/* toast / modal */
#toastWrap { position: fixed; top: 64px; right: 16px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--brand); color: var(--text); padding: 12px 18px; border-radius: 11px; font-size: 14px; box-shadow: 0 10px 30px var(--shadow); animation: fadeUp .3s var(--ease); max-width: 320px; }
.toast.xp { border-left-color: var(--brand); }
.toast.badge { border-left-color: var(--amber); }
.toast.good { border-left-color: var(--green); }
.toast.bad { border-left-color: var(--red); }
#modalWrap { position: fixed; inset: 0; z-index: 998; background: rgba(5,8,14,.72); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn .2s ease; }
.modal { background: var(--panel); border: 1px solid var(--border-hi); border-radius: 18px; padding: 30px 32px; max-width: 420px; width: 100%; text-align: center; animation: popIn .26s var(--ease); box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.modal h3 { margin: 10px 0 8px; font-size: 19px; font-weight: 700; color: var(--text); }
.modal p { color: var(--text2); font-size: 14px; margin-bottom: 18px; }
.modal .lnav { flex-direction: column; gap: 8px; }
.modal .lnav .btn { width: 100%; padding: 13px; white-space: normal; line-height: 1.45; }
#confettiCv { position: fixed; inset: 0; z-index: 1000; pointer-events: none; }
.footer { text-align: center; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); color: var(--text3); font-size: 12px; border-top: 1px solid var(--border); }

/* ============ 首屏加载 ============ */
#bootLoader { position: fixed; inset: 0; z-index: 1500; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: var(--bg); transition: opacity .3s; }
#bootLoader .bl-spin { width: 38px; height: 38px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: blspin .7s linear infinite; }
#bootLoader .bl-txt { color: var(--text2); font-size: 13px; }
#bootLoader .bl-reload { display: none; background: var(--brand); color: #fff; border: none; padding: 10px 22px; border-radius: 10px; font-size: 14px; font-weight: 700; }
@keyframes blspin { to { transform: rotate(360deg); } }

/* ============ H5 适配 ============ */
@media (max-width: 760px) {
  .mbar { display: flex; }
  #lessonView { padding-bottom: calc(94px + env(safe-area-inset-bottom)); }
  #footer .done2 .lnav { display: none; }
  #footer .done2 { padding: 18px; }
  .footer { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .topbar { padding: 9px 14px; row-gap: 8px; }
  .topbar-left { width: 100%; gap: 9px; }
  .back-site { padding: 5px 11px; font-size: 12px; }
  .brand-name { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; }
  .brand-icon { width: 28px; height: 28px; font-size: 14px; flex-shrink: 0; }
  .topbar-right { width: 100%; justify-content: space-between; }
  .xp-box { flex: 1; max-width: 240px; }
  .xp-bar { flex: 1; width: auto; }
  #main { padding: 0 14px 56px; }
  .hero { margin: 16px 0 4px; padding: 28px 18px 28px; border-radius: 18px; }
  .hero-cta { width: 100%; max-width: 360px; }
  .hstats { width: 100%; gap: 8px; }
  .hstat { flex: 1; min-width: 0; padding: 12px 6px; }
  .hstat .n { font-size: 21px; }
  .cicon { width: 40px; height: 40px; font-size: 19px; }
  .ctitle { font-size: 16px; }
  .cprog .cbar { display: none; }
  .lgrid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .lcard { padding: 13px 13px 12px; min-height: 96px; }
  .lcard .ltitle { font-size: 13.5px; }
  .txt, .quiz, .wbox { padding: 18px 16px; }
  .txt table { display: block; overflow-x: auto; white-space: nowrap; }
  .opt { padding: 12px 14px; }
  .rgrid { grid-template-columns: 1fr 1fr; }
  .ctrl label { min-width: 62px; }
  .bwall { padding: 16px 16px; }
  .bi { width: 46px; height: 46px; font-size: 21px; }
  .bitem { width: 64px; }
  #toastWrap { top: auto; bottom: 88px; left: 12px; right: 12px; }
  .toast { max-width: 100%; }
}
@media (max-width: 380px) { .lgrid { grid-template-columns: 1fr; } .hstats { flex-wrap: wrap; } .hstat { min-width: 30%; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
