/* ============================================================
 * AI 学园 · 样式表（深色主题 / 渐变强调色 / 卡片式布局）
 * ============================================================ */
:root {
  --bg: #0b0f1a;
  --bg-soft: #111827;
  --card: #151c2c;
  --card-2: #1a2336;
  --line: #26304a;
  --text: #e7ecf5;
  --muted: #94a3b8;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --accent-3: #f59e0b;
  --good: #34d399;
  --bad: #f87171;
  --orange: #fb923c;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(124,92,255,.14), transparent 60%),
    radial-gradient(900px 400px at -10% 30%, rgba(34,211,238,.10), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", "Noto Sans SC", system-ui, sans-serif;
  line-height: 1.75;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
main#app { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.35; }
.muted { color: var(--muted); }
.page-loading { text-align: center; color: var(--muted); padding: 80px 0; }

/* ---------- 顶栏 ---------- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px;
  background: rgba(11,15,26,.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); font-size: 18px; display: flex; align-items: baseline; gap: 10px; }
.brand:hover { text-decoration: none; }
.brand b { font-size: 20px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-sub { color: var(--muted); font-size: 12px; }
#topnav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
#topnav .navlink { color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: 14px; }
#topnav .navlink:hover { color: var(--text); background: var(--card-2); text-decoration: none; }
#topnav .navlink.active { color: var(--text); background: var(--card-2); }
.nav-user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.xp-pill { background: linear-gradient(90deg, rgba(124,92,255,.25), rgba(34,211,238,.25)); border: 1px solid var(--line); padding: 3px 10px; border-radius: 999px; font-size: 12px; color: var(--text); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  padding: 9px 16px; border-radius: 10px; cursor: pointer; font-size: 14px;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
  font-family: inherit; user-select: none;
}
.btn:hover { background: #223; border-color: #35415f; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(90deg, var(--accent), #5a8bff); border-color: transparent; color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: #5b2b2b; color: #fca5a5; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }

/* ---------- 首页（落地页） ---------- */
.hero { padding: 56px 0 30px; text-align: center; }
.hero h1 { font-size: clamp(30px, 5vw, 46px); margin: 0 0 14px; }
.hero h1 .grad { background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--good)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { color: var(--muted); font-size: 17px; max-width: 680px; margin: 0 auto 26px; }
.hero .cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero .cta .btn { font-size: 16px; padding: 12px 26px; border-radius: 12px; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 30px 0; }
.feature { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.feature .ico { font-size: 26px; }
.feature h3 { margin: 8px 0 6px; font-size: 16px; }
.feature p { color: var(--muted); font-size: 14px; margin: 0; }
.path-preview { margin-top: 26px; }
.section-title { font-size: 18px; margin: 34px 0 12px; display: flex; align-items: center; gap: 10px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- 认证表单 ---------- */
.auth-wrap { max-width: 420px; margin: 48px auto; }
.auth-wrap h2 { margin-top: 0; }
.auth-form label { display: block; font-size: 14px; color: var(--muted); margin: 14px 0 6px; }
.auth-form input {
  width: 100%; padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  font-size: 15px; font-family: inherit; outline: none;
}
.auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,92,255,.18); }
.form-err { color: var(--bad); font-size: 13px; min-height: 20px; margin-top: 10px; }
.auth-switch { margin-top: 16px; font-size: 14px; color: var(--muted); }
.demo-note { font-size: 13px; color: var(--muted); background: var(--bg-soft); border: 1px dashed var(--line); padding: 10px 12px; border-radius: 10px; margin-top: 16px; }

/* ---------- 课程总览（学习路径） ---------- */
.learn-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.progressbar { height: 10px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; flex: 1; min-width: 180px; }
.progressbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s ease; }
.path { position: relative; margin: 20px 0; }
.path-item {
  position: relative; display: flex; gap: 16px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px; transition: border-color .15s ease, transform .15s ease;
}
.path-item:hover { transform: translateX(4px); }
.path-item::before {
  content: ""; position: absolute; left: 39px; top: 58px; bottom: -16px; width: 2px; background: var(--line);
}
.path-item:last-child::before { display: none; }
.path-badge {
  flex: 0 0 44px; width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  background: var(--bg-soft); border: 1px solid var(--line); z-index: 1;
}
.path-item.done .path-badge { background: rgba(52,211,153,.14); border-color: rgba(52,211,153,.5); }
.path-item.locked { opacity: .55; }
.path-item.current { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,92,255,.15); }
.path-body { flex: 1; min-width: 0; }
.path-body h3 { margin: 2px 0 4px; font-size: 16px; }
.path-body .desc { color: var(--muted); font-size: 14px; margin: 0 0 8px; }
.path-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px;
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--muted);
  padding: 2px 9px; border-radius: 999px;
}
.chip.prereq { cursor: pointer; color: var(--accent-2); border-color: rgba(34,211,238,.35); }
.chip.ok { color: var(--good); border-color: rgba(52,211,153,.4); }
.chip.lock { color: var(--muted); }
.chip.now { color: var(--accent); border-color: rgba(124,92,255,.5); }

/* ---------- 课程页 ---------- */
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.lesson-hero { display: flex; gap: 18px; align-items: center; background: linear-gradient(120deg, rgba(124,92,255,.16), rgba(34,211,238,.10)); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 16px; }
.lesson-hero .big-ico { font-size: 44px; }
.lesson-hero h1 { margin: 0 0 4px; font-size: 24px; }
.lesson-hero .tagline { color: var(--muted); margin: 0; }
.concept-bar {
  margin: 14px 0; padding: 12px 16px; border-radius: 12px; font-size: 15px;
  background: rgba(34,211,238,.08); border: 1px solid rgba(34,211,238,.3);
}
.concept-bar b { color: var(--accent-2); }
.build-on { margin: 14px 0 22px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.build-on .chip.prereq { font-size: 13px; }
.lesson-body h2 { font-size: 19px; margin: 30px 0 10px; scroll-margin-top: 80px; }
.lesson-body h2 .knum { display: inline-flex; width: 26px; height: 26px; border-radius: 8px; background: var(--card-2); border: 1px solid var(--line); color: var(--accent-2); font-size: 13px; align-items: center; justify-content: center; margin-right: 8px; vertical-align: middle; }
.lesson-body p { font-size: 15px; color: #d6deeb; }
.lesson-body code { background: var(--bg-soft); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
.callout { border-left: 3px solid var(--accent); background: rgba(124,92,255,.09); padding: 12px 16px; border-radius: 0 12px 12px 0; margin: 18px 0; font-size: 14.5px; }
.callout.warn { border-left-color: var(--accent-3); background: rgba(245,158,11,.09); }
.callout.good { border-left-color: var(--good); background: rgba(52,211,153,.09); }
.callout .t { font-weight: 700; margin-right: 6px; }
.formula { text-align: center; font-size: 20px; margin: 18px 0; font-family: "Cambria Math", Georgia, serif; letter-spacing: .5px; }
.formula .v { color: var(--accent-2); }

/* ---------- 互动组件 ---------- */
.widget {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 20px 0;
}
.widget-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.widget-head .tag { font-size: 12px; color: var(--accent); border: 1px solid rgba(124,92,255,.45); background: rgba(124,92,255,.1); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
.widget-head h3 { font-size: 16px; margin: 0; }
.widget-desc { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }
.widget-controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 10px 0; }
.ctl { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
.ctl b.val { color: var(--text); min-width: 46px; font-variant-numeric: tabular-nums; }
input[type="range"] { accent-color: var(--accent); width: 150px; cursor: pointer; }
select.ctl-select { background: var(--card-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-family: inherit; font-size: 13.5px; }
.wstat { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; min-width: 100px; text-align: center; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .v.good { color: var(--good); } .stat .v.bad { color: var(--bad); } .stat .v.acc { color: var(--accent-2); }
.wmsg { margin-top: 10px; font-size: 14px; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; min-height: 22px; }
canvas.widget-cv { display: block; margin: 0 auto; max-width: 100%; border-radius: 10px; background: #0d1322; border: 1px solid var(--line); touch-action: none; }

/* ---------- 测验 ---------- */
.quiz-card { margin-top: 34px; border: 1px solid rgba(124,92,255,.4); }
.quiz-card h2 { margin-top: 4px; }
.q-item { margin: 18px 0; padding: 14px 16px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; }
.q-item .q { font-weight: 600; margin-bottom: 10px; }
.q-opt { display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; margin: 7px 0; cursor: pointer; font-size: 14.5px; transition: background .12s; }
.q-opt:hover { background: var(--card-2); }
.q-opt input { margin-top: 4px; accent-color: var(--accent); }
.q-opt.sel { border-color: var(--accent); background: rgba(124,92,255,.12); }
.q-opt.right { border-color: var(--good); background: rgba(52,211,153,.12); }
.q-opt.wrong { border-color: var(--bad); background: rgba(248,113,113,.12); }
.q-explain { font-size: 13.5px; color: var(--muted); margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.quiz-result { margin: 16px 0; padding: 14px 16px; border-radius: 12px; font-size: 15px; }
.quiz-result.pass { background: rgba(52,211,153,.12); border: 1px solid rgba(52,211,153,.5); }
.quiz-result.fail { background: rgba(248,113,113,.10); border: 1px solid rgba(248,113,113,.45); }

/* ---------- 结业 / 摘要 ---------- */
.takeaways { margin: 26px 0 10px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; }
.takeaways h3 { margin: 0 0 10px; font-size: 16px; color: var(--accent-2); }
.takeaways ul { margin: 0; padding-left: 20px; }
.takeaways li { font-size: 14.5px; margin: 5px 0; }
.lesson-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 30px; flex-wrap: wrap; }
.grad-banner {
  margin-top: 18px; padding: 26px; text-align: center; border-radius: var(--radius);
  background: linear-gradient(120deg, rgba(124,92,255,.25), rgba(34,211,238,.18), rgba(52,211,153,.2));
  border: 1px solid rgba(124,92,255,.5);
}
.grad-banner h2 { margin: 6px 0; }

/* ---------- 知识地图 ---------- */
.map-card { overflow-x: auto; }
.map-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.map-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; }
svg.kmap { min-width: 720px; }
.kmap text { font-family: inherit; }
.knode { cursor: pointer; }
.knode rect { transition: filter .15s; }
.knode:hover rect { filter: brightness(1.3); }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px); z-index: 99; display: flex; flex-direction: column; gap: 8px; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-item { background: var(--card-2); border: 1px solid var(--line); color: var(--text); padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; max-width: 90vw; }

/* ---------- 页脚 ---------- */
#footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 16px 24px; }

@media (max-width: 640px) {
  .brand-sub { display: none; }
  .lesson-hero { flex-direction: column; text-align: center; }
  .path-item::before { left: 27px; }
  input[type="range"] { width: 110px; }
}
