/* ============================================================
   DSH 插件开发学院 · 样式表
   深色主题 · DeepSeek 蓝紫渐变点缀
   ============================================================ */

:root {
  --bg: #0b0f1a;
  --bg-soft: #101828;
  --panel: #131c2e;
  --panel-2: #1a2440;
  --panel-3: #223052;
  --line: #26344f;
  --line-soft: #1d2a45;
  --text: #e6edf7;
  --text-dim: #9aa8c0;
  --text-faint: #66748f;
  --accent: #4d7cfe;
  --accent-2: #7c5cff;
  --accent-grad: linear-gradient(135deg, #4d7cfe 0%, #7c5cff 100%);
  --good: #34d399;
  --bad: #f87171;
  --warn: #fbbf24;
  --info: #38bdf8;
  --code-bg: #0a0f1d;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .35);
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(124, 92, 255, .12), transparent 60%),
    radial-gradient(1000px 500px at -10% 0%, rgba(77, 124, 254, .10), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.75;
  font-size: 15.5px;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }
#view-root { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }

/* ---------------- 顶部导航 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11, 15, 26, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 8px; cursor: pointer; user-select: none; }
.brand-mark {
  background: var(--accent-grad); -webkit-background-clip: text; background-clip: text;
  color: transparent; font-size: 26px; line-height: 1;
}
.brand-text { font-weight: 700; font-size: 17px; letter-spacing: .3px; }
.brand-sub { font-size: 11px; color: var(--text-faint); letter-spacing: .5px; }

.main-nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav-btn {
  background: transparent; border: 1px solid transparent; color: var(--text-dim);
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 14px;
  transition: all .18s ease; font-family: inherit;
}
.nav-btn:hover { color: var(--text); background: var(--panel-2); }
.nav-btn.active {
  color: #fff; background: var(--accent-grad); border-color: transparent;
  box-shadow: 0 4px 14px rgba(77, 124, 254, .35);
}

.topbar-right { display: flex; align-items: center; gap: 10px; }
.progress-pill {
  display: flex; align-items: center; gap: 8px; background: var(--panel);
  border: 1px solid var(--line-soft); border-radius: 999px; padding: 5px 12px; font-size: 12.5px;
}
.pill-label { color: var(--text-faint); }
.pill-bar { width: 64px; height: 6px; border-radius: 99px; background: var(--panel-3); overflow: hidden; }
.pill-fill { display: block; height: 100%; width: 0; background: var(--accent-grad); border-radius: 99px; transition: width .4s ease; }
.pill-num { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.icon-btn {
  background: var(--panel); color: var(--text-dim); border: 1px solid var(--line-soft);
  border-radius: 8px; width: 32px; height: 32px; cursor: pointer; font-size: 15px; transition: all .18s;
}
.icon-btn:hover { color: var(--bad); border-color: var(--bad); }

/* ---------------- 通用卡片 / 按钮 ---------------- */
.card {
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent-grad); color: #fff; border: none;
  padding: 10px 20px; border-radius: 10px; font-size: 14.5px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: transform .12s ease, box-shadow .18s ease;
  box-shadow: 0 4px 16px rgba(77, 124, 254, .3);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(77, 124, 254, .4); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.ghost {
  background: transparent; color: var(--text-dim); border: 1px solid var(--line);
  box-shadow: none;
}
.btn.ghost:hover { color: var(--text); border-color: var(--accent); }
.btn.good { background: linear-gradient(135deg, #10b981, #34d399); box-shadow: 0 4px 16px rgba(52, 211, 153, .3); }
.btn.bad { background: linear-gradient(135deg, #ef4444, #f87171); box-shadow: 0 4px 16px rgba(248, 113, 113, .3); }

.page-title { font-size: 26px; font-weight: 800; margin-bottom: 4px; letter-spacing: .2px; }
.page-sub { color: var(--text-dim); margin-bottom: 22px; font-size: 14.5px; }
.grad-text {
  background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------------- 首页 ---------------- */
.dash-hero {
  background: linear-gradient(135deg, rgba(77, 124, 254, .16), rgba(124, 92, 255, .14)), var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 30px 28px; margin-bottom: 22px;
  display: flex; align-items: center; gap: 26px; flex-wrap: wrap;
}
.dash-hero h1 { font-size: 25px; line-height: 1.4; }
.dash-hero p { color: var(--text-dim); margin-top: 6px; max-width: 720px; font-size: 14.5px; }
.dash-hero .hero-cta { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-card .stat-num { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-card .stat-label { color: var(--text-faint); font-size: 12.5px; margin-top: 2px; }
.stat-card .stat-bar { height: 6px; background: var(--panel-3); border-radius: 99px; margin-top: 10px; overflow: hidden; }
.stat-card .stat-bar > span { display: block; height: 100%; background: var(--accent-grad); border-radius: 99px; transition: width .4s; }

.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.chapter-card {
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 20px; cursor: pointer; transition: transform .15s ease, border-color .15s ease, box-shadow .2s;
  display: flex; flex-direction: column; gap: 8px; position: relative; overflow: hidden;
}
.chapter-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow); }
.chapter-card .ch-num {
  font-size: 12px; font-weight: 700; letter-spacing: 1px; color: var(--accent);
  text-transform: uppercase;
}
.chapter-card .ch-title { font-size: 17px; font-weight: 700; }
.chapter-card .ch-desc { color: var(--text-dim); font-size: 13.5px; flex: 1; }
.chapter-card .ch-meta { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text-faint); }
.chapter-card .ch-meta .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--panel-3); }
.chapter-card .ch-meta .dot.done { background: var(--good); }
.chapter-card .ch-meta .dot.partial { background: var(--warn); }
.chapter-card.done-card { border-color: rgba(52, 211, 153, .4); }
.chapter-card.done-card::after {
  content: "✓ 已学完"; position: absolute; top: 12px; right: 12px;
  font-size: 11px; font-weight: 700; color: var(--good);
  border: 1px solid rgba(52, 211, 153, .4); border-radius: 99px; padding: 2px 9px;
}

/* ---------------- 学习视图 ---------------- */
.learn-layout { display: grid; grid-template-columns: 250px 1fr; gap: 20px; align-items: start; }
.chapter-sidebar {
  position: sticky; top: 74px;
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 12px; display: flex; flex-direction: column; gap: 4px; max-height: calc(100vh - 110px); overflow: auto;
}
.sidebar-title { font-size: 12px; color: var(--text-faint); letter-spacing: 1px; padding: 6px 10px; font-weight: 700; }
.side-item {
  display: flex; gap: 9px; align-items: baseline; padding: 8px 10px; border-radius: 8px;
  cursor: pointer; font-size: 13.5px; color: var(--text-dim); transition: all .15s; border: 1px solid transparent;
}
.side-item:hover { background: var(--panel-2); color: var(--text); }
.side-item.active { background: var(--panel-3); color: #fff; border-color: var(--accent); }
.side-item .si-num { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; min-width: 22px; }
.side-item.active .si-num { color: var(--accent); }
.side-item .si-state { margin-left: auto; font-size: 12px; }
.side-item .si-state.done { color: var(--good); }

.lesson-card { margin-bottom: 20px; }
.lesson-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.lesson-head .lh-ch { font-size: 12.5px; color: var(--accent); font-weight: 700; letter-spacing: .6px; }
.lesson-head h2 { font-size: 22px; font-weight: 800; }
.lesson-head .lh-done { margin-left: auto; color: var(--good); font-size: 13px; font-weight: 600; }

.lesson-body { color: #dbe4f2; }
.lesson-body p { margin: 10px 0; }
.inline-code {
  background: var(--panel-3); border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 6px; font-family: var(--mono); font-size: .88em; color: #a5d8ff;
  white-space: nowrap;
}
.callout .inline-code, .lesson-summary .inline-code, .q-feedback .inline-code { color: #a5d8ff; }
.lesson-body h3 { font-size: 16.5px; margin: 22px 0 8px; color: #fff; }
.lesson-body h4 { font-size: 15px; margin: 16px 0 6px; color: #eef3fb; }
.lesson-body ul, .lesson-body ol { margin: 10px 0 10px 22px; }
.lesson-body li { margin: 5px 0; }
.lesson-body strong { color: #fff; }
.lesson-body em { color: var(--accent); font-style: normal; font-weight: 600; }

.lesson-body table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 13.5px; }
.lesson-body th, .lesson-body td { border: 1px solid var(--line); padding: 8px 11px; text-align: left; }
.lesson-body th { background: var(--panel-2); color: #fff; font-weight: 700; }
.lesson-body tr:nth-child(even) td { background: rgba(255,255,255,.015); }

/* 代码块 */
.code-block { position: relative; margin: 14px 0; }
.code-block pre {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.65;
  color: #d7e3f8;
}
.code-block .code-lang {
  position: absolute; top: 8px; right: 10px; font-size: 10.5px; color: var(--text-faint);
  font-family: var(--mono); letter-spacing: .6px;
}
.code-block .copy-btn {
  position: absolute; top: 7px; right: 52px; background: var(--panel-3); color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 6px; font-size: 11px; padding: 2px 8px; cursor: pointer;
  opacity: 0; transition: opacity .15s;
}
.code-block:hover .copy-btn { opacity: 1; }
.code-block .copy-btn:hover { color: #fff; }
/* 简单高亮 token */
.tok-k { color: #7dd3fc; }   /* keyword */
.tok-s { color: #86efac; }   /* string */
.tok-c { color: #64748b; font-style: italic; } /* comment */
.tok-f { color: #c4b5fd; }   /* function */
.tok-n { color: #fca5a5; }   /* number */
.tok-p { color: #fbbf24; }   /* property */

/* 提示框 */
.callout {
  border-radius: 10px; padding: 12px 15px; margin: 14px 0; font-size: 14px;
  border: 1px solid; display: flex; gap: 10px; align-items: flex-start;
}
.callout .co-icon { font-size: 16px; line-height: 1.5; }
.callout.info { background: rgba(56, 189, 248, .08); border-color: rgba(56, 189, 248, .35); }
.callout.tip { background: rgba(52, 211, 153, .07); border-color: rgba(52, 211, 153, .35); }
.callout.warn { background: rgba(251, 191, 36, .07); border-color: rgba(251, 191, 36, .4); }
.callout.danger { background: rgba(248, 113, 113, .07); border-color: rgba(248, 113, 113, .4); }
.callout strong { color: #fff; }

/* 术语行内高亮 */
.term {
  color: var(--accent-2); font-weight: 600; cursor: help;
  border-bottom: 1px dashed rgba(124, 92, 255, .5); padding-bottom: 1px;
}
.term:hover { color: #a78bfa; }

/* 章节小结 / 导航按钮 */
.lesson-summary {
  background: linear-gradient(135deg, rgba(77,124,254,.10), rgba(124,92,255,.10));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 20px 0;
}
.lesson-summary h4 { color: #fff; margin-bottom: 6px; font-size: 15px; }
.lesson-summary li { margin: 4px 0; font-size: 14px; }
.lesson-nav { display: flex; justify-content: space-between; gap: 10px; margin: 24px 0 8px; }

/* ---------------- 答题视图 ---------------- */
.quiz-intro { text-align: center; padding: 40px 20px; }
.quiz-intro .qi-title { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.quiz-intro .qi-sub { color: var(--text-dim); max-width: 620px; margin: 0 auto 22px; }
.quiz-packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; text-align: left; }
.quiz-pack {
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 18px; cursor: pointer; transition: all .15s;
}
.quiz-pack:hover { transform: translateY(-2px); border-color: var(--accent); }
.quiz-pack .qp-title { font-weight: 700; font-size: 15.5px; }
.quiz-pack .qp-meta { color: var(--text-faint); font-size: 12.5px; margin-top: 4px; }
.quiz-pack .qp-score { margin-top: 10px; font-size: 13px; color: var(--text-dim); }

.quiz-running { max-width: 780px; margin: 0 auto; }
.quiz-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.quiz-head .qh-info { font-size: 13.5px; color: var(--text-dim); }
.quiz-progress { flex: 1; min-width: 140px; height: 8px; border-radius: 99px; background: var(--panel-3); overflow: hidden; }
.quiz-progress > span { display: block; height: 100%; background: var(--accent-grad); transition: width .3s; border-radius: 99px; }

.question-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.q-multi-tag {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .5px;
  background: rgba(251, 191, 36, .15); color: var(--warn);
  border: 1px solid rgba(251, 191, 36, .35); border-radius: 99px; padding: 1px 9px; margin-left: 8px;
}
.q-text { font-size: 16.5px; font-weight: 600; line-height: 1.6; margin: 12px 0 16px; }
.q-opts { display: flex; flex-direction: column; gap: 10px; }
.q-opt {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--panel-2); border: 1.5px solid var(--line); border-radius: 10px;
  padding: 12px 15px; cursor: pointer; transition: all .15s; font-size: 14.5px;
}
.q-opt:hover { border-color: var(--accent); background: var(--panel-3); }
.q-opt .q-letter {
  width: 26px; height: 26px; border-radius: 8px; background: var(--panel-3); color: var(--text-dim);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.q-opt.selected { border-color: var(--accent); background: rgba(77, 124, 254, .12); }
.q-opt.selected .q-letter { background: var(--accent); color: #fff; }
.q-opt.correct { border-color: var(--good); background: rgba(52, 211, 153, .12); }
.q-opt.correct .q-letter { background: var(--good); color: #06281c; }
.q-opt.wrong { border-color: var(--bad); background: rgba(248, 113, 113, .12); }
.q-opt.wrong .q-letter { background: var(--bad); color: #fff; }
.q-opt.dimmed { opacity: .5; }
.q-opt input { display: none; }

.q-feedback { margin-top: 16px; border-radius: 10px; padding: 14px 16px; border: 1px solid; font-size: 14px; }
.q-feedback.ok { background: rgba(52, 211, 153, .08); border-color: rgba(52, 211, 153, .4); }
.q-feedback.no { background: rgba(248, 113, 113, .08); border-color: rgba(248, 113, 113, .4); }
.q-feedback .fb-head { font-weight: 800; margin-bottom: 4px; }
.q-feedback.ok .fb-head { color: var(--good); }
.q-feedback.no .fb-head { color: var(--bad); }
.q-feedback .fb-explain { color: var(--text-dim); }
.q-feedback .fb-explain .term { color: #a78bfa; }

.quiz-actions { display: flex; justify-content: space-between; margin-top: 18px; gap: 10px; flex-wrap: wrap; }

.quiz-result { text-align: center; padding: 30px 20px; }
.result-ring {
  width: 150px; height: 150px; border-radius: 50%; margin: 10px auto 18px;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--panel-3) 0);
  position: relative;
}
.result-ring::before { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--bg-soft); }
.result-ring .rr-num { position: relative; font-size: 30px; font-weight: 800; }
.result-ring .rr-label { position: relative; font-size: 12px; color: var(--text-faint); }
.result-title { font-size: 22px; font-weight: 800; margin: 6px 0; }
.result-sub { color: var(--text-dim); margin-bottom: 18px; }

/* ---------------- 术语表 ---------------- */
.glossary-search { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.glossary-search input {
  flex: 1; min-width: 220px; background: var(--panel); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: 11px 15px; font-size: 14.5px; font-family: inherit;
  outline: none; transition: border-color .15s;
}
.glossary-search input:focus { border-color: var(--accent); }
.glossary-search input::placeholder { color: var(--text-faint); }
.gloss-cats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.cat-chip {
  background: var(--panel); color: var(--text-dim); border: 1px solid var(--line-soft);
  border-radius: 999px; padding: 5px 13px; font-size: 12.5px; cursor: pointer; transition: all .15s;
}
.cat-chip:hover { color: var(--text); }
.cat-chip.active { background: var(--accent-grad); color: #fff; border-color: transparent; }
.gloss-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.gloss-card {
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 16px 18px;
}
.gloss-card .gl-en { font-family: var(--mono); font-size: 13.5px; color: var(--accent); font-weight: 700; }
.gloss-card .gl-zh { font-size: 15px; font-weight: 700; margin: 2px 0 6px; color: #fff; }
.gloss-card .gl-desc { color: var(--text-dim); font-size: 13.5px; }
.gloss-card .gl-ana {
  margin-top: 8px; font-size: 12.5px; color: var(--text-faint); border-top: 1px dashed var(--line);
  padding-top: 7px;
}
.gloss-card .gl-ana b { color: var(--text-dim); }

/* ---------------- 成就 ---------------- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.badge-card {
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 20px 16px; text-align: center; transition: all .2s;
}
.badge-card.locked { opacity: .45; filter: grayscale(.9); }
.badge-card .bd-icon { font-size: 34px; margin-bottom: 8px; }
.badge-card .bd-name { font-weight: 700; font-size: 14.5px; }
.badge-card .bd-desc { color: var(--text-faint); font-size: 12px; margin-top: 4px; }
.badge-card.unlocked { border-color: rgba(251, 191, 36, .5); box-shadow: 0 4px 18px rgba(251, 191, 36, .12); }

/* ---------------- 页脚 / 其他 ---------------- */
.app-footer {
  border-top: 1px solid var(--line-soft); padding: 16px 20px; text-align: center;
  color: var(--text-faint); font-size: 12.5px;
}

.empty-hint { text-align: center; color: var(--text-faint); padding: 40px 10px; font-size: 14px; }

/* 进度动画 */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp .3s ease both; }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--line); }

/* 响应式 */
@media (max-width: 860px) {
  .learn-layout { grid-template-columns: 1fr; }
  .chapter-sidebar { position: static; max-height: 220px; }
  .brand-sub { display: none; }
  #view-root { padding: 16px 12px 50px; }
}
