/* ============================================================
   SCORM 课件播放器样式 · 改配色/字体只动 :root 变量
   ============================================================ */
:root {
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --primary-soft: #eef2ff;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --amber: #d97706;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(2, 6, 23, .08);
  --sidebar-w: 288px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- 顶栏 ---------- */
#topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  color: #fff; flex: 0 0 auto;
}
#brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
#course-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mode-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: rgba(255,255,255,.22); white-space: nowrap;
}
#progress-wrap {
  flex: 1; height: 8px; border-radius: 999px;
  background: rgba(255,255,255,.25); overflow: hidden;
}
#progress-bar { height: 100%; width: 0; background: #fff; border-radius: 999px; transition: width .4s ease; }
#progress-text { font-size: 13px; font-weight: 600; min-width: 38px; text-align: right; }

/* ---------- 主区 ---------- */
#main { display: flex; flex: 1; min-height: 0; }

/* ---------- 左侧目录 ---------- */
#sidebar {
  width: var(--sidebar-w); flex: 0 0 auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
#toc { flex: 1; overflow-y: auto; padding: 14px 10px; }
.toc-chapter { margin-bottom: 6px; }
.toc-chapter-title {
  font-size: 12px; font-weight: 700; color: var(--muted);
  letter-spacing: .4px; text-transform: none;
  padding: 10px 10px 6px;
}
.toc-page {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 10px;
  font-size: 13.5px; cursor: pointer; color: var(--text);
  border: 1px solid transparent;
}
.toc-page:hover { background: var(--primary-soft); }
.toc-page.active { background: var(--primary-soft); border-color: #c7d2fe; font-weight: 600; color: var(--primary); }
.toc-check {
  flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid #cbd5e1; font-size: 11px; line-height: 15px; text-align: center;
  color: transparent; transition: all .25s;
}
.toc-page.done .toc-check { background: var(--green); border-color: var(--green); color: #fff; }
.toc-page.done { color: var(--muted); }
.toc-page.done.active { color: var(--primary); }
#sidebar-footer {
  padding: 8px 14px; font-size: 10.5px; color: var(--muted);
  border-top: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- 右侧舞台 ---------- */
#stage { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 18px 22px 12px; }
.slide {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 38px 48px 48px;
  max-width: 1040px; width: 100%; margin: 0 auto;
  animation: slideIn .35s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

#controls {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  gap: 18px; padding-top: 12px;
}
.btn {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 10px; padding: 9px 18px;
  font-size: 14px; cursor: pointer; transition: all .2s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); color: #fff; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
#page-indicator { font-size: 13px; color: var(--muted); min-width: 70px; text-align: center; }

/* ---------- 通用排版 ---------- */
.slide h1 { font-size: 30px; line-height: 1.25; margin-bottom: 14px; }
.slide h3 { font-size: 17px; margin: 22px 0 12px; }
.slide p { font-size: 15px; line-height: 1.8; margin-bottom: 10px; }
.slide b { color: var(--primary); }
.slide code {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 6px;
  padding: 1px 6px; font-size: 13px; font-family: Consolas, Menlo, monospace; color: #be185d;
}
.slide pre {
  background: #0f172a; color: #e2e8f0; border-radius: 12px;
  padding: 18px 20px; overflow-x: auto; margin: 12px 0;
  font-size: 13.5px; line-height: 1.65;
  font-family: Consolas, Menlo, "Courier New", monospace;
}
.lead { font-size: 16px !important; color: #334155; }
.muted { color: var(--muted); }

.hero { text-align: center; padding: 26px 0 10px; margin-bottom: 10px; }
.hero-badge {
  display: inline-block; font-size: 11.5px; letter-spacing: 1px;
  color: var(--primary); background: var(--primary-soft);
  border: 1px solid #c7d2fe; border-radius: 999px; padding: 4px 14px; margin-bottom: 14px;
}
.hero h1 {
  font-size: 38px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { color: var(--muted); margin-top: 6px; }

.callout {
  background: var(--primary-soft); border: 1px solid #c7d2fe;
  border-left: 4px solid var(--primary);
  border-radius: 10px; padding: 14px 16px; margin: 14px 0;
  font-size: 14.5px; line-height: 1.75;
}
.tag {
  display: inline-block; font-size: 11px; font-weight: 700; color: var(--primary);
  background: var(--primary-soft); border-radius: 999px; padding: 2px 10px; margin-bottom: 8px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 12px 0; }
.card {
  background: #fafbfe; border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px; font-size: 14px; line-height: 1.75;
}
.card p { margin-bottom: 0; font-size: 14px; }
.kpi {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; font-weight: 700; font-size: 14px; margin-bottom: 8px;
}

/* ---------- code 页 ---------- */
.code-block { position: relative; }
.code-lang {
  position: absolute; top: 10px; right: 14px; font-size: 11px;
  color: #94a3b8; text-transform: uppercase; letter-spacing: 1px;
}
.code-points { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.code-point { background: #fafbfe; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; line-height: 1.7; }
.code-point .pt-label { font-weight: 700; color: var(--primary); display: block; margin-bottom: 4px; }

/* ---------- steps 页 ---------- */
.steps-wrap { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 14px; }
.step-chip {
  border: 1.5px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 8px 16px; font-size: 13.5px; cursor: pointer; transition: all .2s;
}
.step-chip:hover { border-color: var(--primary); color: var(--primary); }
.step-chip.active { background: linear-gradient(90deg, var(--primary), var(--primary-2)); color: #fff; border-color: transparent; font-weight: 600; }
.step-detail {
  background: #fafbfe; border: 1px solid var(--border); border-radius: 12px;
  padding: 20px 22px; font-size: 14.5px; line-height: 1.8; min-height: 120px;
  animation: slideIn .25s ease;
}
.step-detail h4 { color: var(--primary); font-size: 16px; margin-bottom: 8px; }

/* ---------- flashcards ---------- */
.fc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; }
.fc { perspective: 900px; height: 168px; cursor: pointer; }
.fc-inner { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.fc.flipped .fc-inner { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 12px; padding: 16px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  font-size: 14px; line-height: 1.6;
}
.fc-front { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; font-weight: 700; font-size: 16px; }
.fc-front .fc-hint { font-size: 10.5px; font-weight: 400; opacity: .75; margin-top: 10px; }
.fc-back { background: var(--surface); border: 1.5px solid #c7d2fe; transform: rotateY(180deg); font-size: 13px; }

/* ---------- match ---------- */
.match-cols { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; margin-top: 18px; }
.match-item {
  background: #fafbfe; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-size: 13.5px; line-height: 1.6; margin-bottom: 10px;
  cursor: pointer; transition: all .2s; min-height: 52px;
}
.match-item:hover { border-color: var(--primary); }
.match-item.selected { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.match-item.locked { border-color: var(--green); background: var(--green-soft); cursor: default; color: #14532d; }
.match-item.wrong { animation: shake .4s; border-color: var(--red); background: var(--red-soft); }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.match-done-banner {
  display: none; margin-top: 14px; padding: 12px 16px; border-radius: 10px;
  background: var(--green-soft); color: #14532d; font-weight: 700; font-size: 14.5px;
}
.match-done-banner.show { display: block; animation: slideIn .3s ease; }

/* ---------- quiz ---------- */
.q-block { background: #fafbfe; border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-bottom: 14px; }
.q-title { font-size: 14.5px; font-weight: 700; margin-bottom: 12px; }
.q-opt {
  border: 1.5px solid var(--border); border-radius: 9px; background: var(--surface);
  padding: 10px 14px; font-size: 13.5px; margin-bottom: 8px; cursor: pointer; transition: all .2s;
}
.q-opt:hover { border-color: var(--primary); }
.q-opt.correct { border-color: var(--green); background: var(--green-soft); color: #14532d; font-weight: 600; }
.q-opt.wrong { border-color: var(--red); background: var(--red-soft); color: #7f1d1d; }
.q-opt.disabled { pointer-events: none; opacity: .92; }
.q-explain {
  display: none; margin-top: 8px; font-size: 13px; line-height: 1.7;
  padding: 10px 12px; border-radius: 8px; background: #f1f5f9; color: #334155;
}
.q-explain.show { display: block; }
.quiz-result {
  display: none; margin: 6px 0 16px; padding: 18px 20px; border-radius: 12px;
  background: linear-gradient(90deg, var(--primary-soft), #f5f3ff);
  border: 1px solid #c7d2fe; align-items: center; justify-content: space-between; gap: 14px;
}
.quiz-result.show { display: flex; }
.quiz-score { font-size: 26px; font-weight: 800; color: var(--primary); }
.quiz-msg { font-size: 13.5px; color: #334155; }

/* ---------- 音频讲解条（视频课模式） ---------- */
#transcript {
  flex: 0 0 auto; max-height: 132px; overflow-y: auto;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 16px; margin: 10px auto 0; width: 100%; max-width: 1040px;
  font-size: 13.5px; line-height: 1.75; color: #334155;
}
#transcript::before { content: "🎙 旁白"; font-size: 10.5px; font-weight: 700; color: var(--primary); display: block; margin-bottom: 4px; letter-spacing: 1px; }
#transcript { position: relative; }
#transcript .cue-line {
  display: block; padding: 3px 10px; margin: 1px 0;
  border-left: 3px solid transparent; border-radius: 6px;
  color: #64748b; transition: background .2s, color .2s;
}
#transcript .cue-line.active {
  color: var(--text); background: var(--primary-soft);
  border-left-color: var(--primary); font-weight: 600;
}
#audio-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 8px 14px; margin: 10px auto 0; width: 100%; max-width: 1040px;
}
#audio-bar.disabled { opacity: .45; }
.abtn {
  border: none; cursor: pointer; background: var(--primary-soft); color: var(--primary);
  border-radius: 999px; min-width: 34px; height: 34px; font-size: 13px; font-weight: 700;
  transition: all .2s; padding: 0 12px;
}
.abtn:hover:not(:disabled) { background: #c7d2fe; }
.abtn.toggle { font-size: 12.5px; opacity: .5; }
.abtn.toggle.on { opacity: 1; background: var(--primary); color: #fff; }
#btn-play { width: 40px; font-size: 13px; background: var(--primary); color: #fff; }
#btn-play:disabled { opacity: .5; cursor: default; }
#audio-progress-wrap { flex: 1; height: 6px; background: #e2e8f0; border-radius: 999px; cursor: pointer; overflow: hidden; }
#audio-played { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: 999px; }
#audio-time { font-size: 11.5px; color: var(--muted); min-width: 76px; text-align: center; font-variant-numeric: tabular-nums; }
#audio-rate { border: 1px solid var(--border); border-radius: 8px; height: 30px; font-size: 12.5px; background: var(--surface); color: var(--text); cursor: pointer; }

/* ---------- terminal 页（执行结果演示） ---------- */
.terminal { background: #0b1220; border: 1px solid #1e293b; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); margin: 14px 0; }
.terminal-bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: #111a2e; border-bottom: 1px solid #1e293b; }
.tdot { width: 10px; height: 10px; border-radius: 50%; }
.tdot.r { background: #ff5f57; } .tdot.y { background: #febc2e; } .tdot.g { background: #28c840; }
.terminal-title { color: #7d8db1; font-size: 11.5px; margin-left: 8px; flex: 1; font-family: Consolas, Menlo, monospace; }
.terminal-replay { background: transparent; border: 1px solid #2c3a55; color: #8fa3c8; border-radius: 6px; font-size: 11px; padding: 2px 10px; cursor: pointer; }
.terminal-replay:hover { color: #fff; border-color: #43597f; }
.terminal-body { padding: 14px 18px; font-family: Consolas, Menlo, monospace; font-size: 13px; line-height: 1.8; overflow-x: auto; }
.tline { white-space: pre; opacity: 0; animation: tlineIn .25s ease forwards; }
@keyframes tlineIn { from { opacity: 0; transform: translateX(6px); } to { opacity: 1; transform: none; } }
.t-cmd { color: #e2e8f0; font-weight: 600; }
.t-cmd::before { content: "$ "; color: #4ade80; }
.t-err { color: #f87171; } .t-ok { color: #4ade80; } .t-dim { color: #64748b; }
.tbadge { color: #facc15; margin-right: 8px; }

/* ---------- diagram 页（架构图） ---------- */
.diagram-stage { position: relative; margin: 14px 0; }
.diagram-boxes { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; position: relative; z-index: 1; }
.dbox {
  min-height: 64px; border-radius: 10px; border: 1.5px solid var(--border); background: #fafbfe;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 13px; line-height: 1.45; padding: 8px 10px; cursor: pointer; transition: all .2s;
}
.dbox:hover { border-color: var(--primary); transform: translateY(-1px); }
.dbox.active { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 6px 18px rgba(79, 70, 229, .18); font-weight: 700; color: var(--primary); }
.k-data { background: #fffbeb; border-color: #fcd34d; }
.k-store { background: #ecfdf5; border-color: #6ee7b7; }
.k-usecase { background: #eef2ff; border-color: #a5b4fc; }
.k-day { background: #f1f5f9; border-color: #cbd5e1; font-weight: 700; color: #334155; }
.diagram-arrows { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; overflow: visible; }
.diagram-arrows path { fill: none; stroke: #94a3b8; stroke-width: 1.6; }
.diagram-arrows path.hot { stroke: var(--primary); stroke-width: 2.6; }
.diagram-note {
  background: #fafbfe; border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: 10px; padding: 12px 16px; font-size: 14px; line-height: 1.75; min-height: 60px; margin-bottom: 12px;
}
.diagram-note b { color: var(--primary); }

/* ---------- code 页多文件 tab ---------- */
.code-tabs { display: flex; gap: 6px; margin: 14px 0 -8px; position: relative; z-index: 1; }
.code-tab {
  border: 1px solid var(--border); background: #f1f5f9; border-radius: 8px 8px 0 0;
  padding: 6px 14px; font-size: 12.5px; cursor: pointer; color: var(--muted);
  font-family: Consolas, Menlo, monospace; transition: all .2s;
}
.code-tab.active { background: #0f172a; color: #e2e8f0; border-color: #0f172a; }
.code-block.hidden { display: none; }

/* ---------- toast ---------- */
#toast {
  position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; font-size: 13px;
  padding: 10px 20px; border-radius: 999px; box-shadow: var(--shadow);
  z-index: 99; opacity: .96; animation: slideIn .3s ease;
}
.hidden { display: none !important; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  #main { flex-direction: column; }
  #sidebar { width: 100%; flex: 0 0 auto; max-height: 34vh; border-right: none; border-bottom: 1px solid var(--border); }
  .slide { padding: 24px 20px 32px; }
  .grid2, .code-points, .fc-grid, .match-cols { grid-template-columns: 1fr; }
  .fc { height: 140px; }
  .hero h1 { font-size: 28px; }
  #audio-time { display: none; }
}
