/* ============================================
   Python 趣学营 — 主样式表
   主题：亮色 / 暗色 / 跟随系统
   ============================================ */

/* ---------- CSS 变量：亮色主题（默认） ---------- */
:root,
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-code: #f8f9fa;
  --bg-hover: #f1f5f9;

  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --text-on-primary: #ffffff;

  --border-tertiary: rgba(0, 0, 0, 0.08);
  --border-secondary: rgba(0, 0, 0, 0.15);
  --border-primary: rgba(0, 0, 0, 0.25);

  --accent: #3776ab;
  --accent-hover: #2c5f8c;
  --accent-light: #e6f1fb;
  --accent-bg: #f0f7ff;

  --yellow: #ffd43b;
  --yellow-bg: #fffbeb;
  --green: #22c55e;
  --green-light: #dcfce7;
  --green-bg: #f0fdf4;
  --orange: #f97316;
  --orange-light: #fed7aa;
  --orange-bg: #fff7ed;
  --red: #ef4444;
  --red-light: #fecaca;
  --red-bg: #fef2f2;
  --purple: #8b5cf6;
  --purple-light: #e9d5ff;
  --purple-bg: #faf5ff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, "Courier New", monospace;
}

/* ---------- CSS 变量：暗色主题 ---------- */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-card: #1e293b;
  --bg-code: #0d1117;
  --bg-hover: #334155;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-on-primary: #ffffff;

  --border-tertiary: rgba(255, 255, 255, 0.08);
  --border-secondary: rgba(255, 255, 255, 0.15);
  --border-primary: rgba(255, 255, 255, 0.25);

  --accent: #5b9fd6;
  --accent-hover: #7cb8e6;
  --accent-light: rgba(91, 159, 214, 0.12);
  --accent-bg: rgba(91, 159, 214, 0.08);

  --yellow: #fbbf24;
  --yellow-bg: rgba(251, 191, 36, 0.1);
  --green: #4ade80;
  --green-light: rgba(74, 222, 128, 0.15);
  --green-bg: rgba(74, 222, 128, 0.08);
  --orange: #fb923c;
  --orange-light: rgba(251, 146, 60, 0.15);
  --orange-bg: rgba(251, 146, 60, 0.08);
  --red: #f87171;
  --red-light: rgba(248, 113, 113, 0.15);
  --red-bg: rgba(248, 113, 113, 0.08);
  --purple: #a78bfa;
  --purple-light: rgba(167, 139, 250, 0.15);
  --purple-bg: rgba(167, 139, 250, 0.08);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.4);
}

/* ---------- 基础重置 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
*::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 15px;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-hover); }

button { font-family: inherit; cursor: pointer; border: none; background: none; }

code, pre { font-family: var(--font-mono); }

/* ---------- 导航栏 ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-tertiary);
  backdrop-filter: blur(12px);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.3s, border-color 0.3s;
}

.navbar-left { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.navbar-logo { font-size: 22px; }
.navbar-title { font-size: 17px; font-weight: 600; color: var(--text-primary); }
.navbar-title .accent { color: var(--accent); }

.navbar-right { display: flex; align-items: center; gap: 8px; }

.nav-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
  font-size: 18px;
}
.nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-btn.active { background: var(--accent-light); color: var(--accent); }

/* ---------- 主容器 ---------- */
.container { max-width: 960px; margin: 0 auto; padding: 32px 24px 64px; }
.container-wide { max-width: 1100px; margin: 0 auto; padding: 32px 24px 64px; }

/* ---------- 首页：欢迎区 ---------- */
.hero {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  margin-bottom: 28px;
  border: 1px solid var(--border-tertiary);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, var(--accent-light) 0%, transparent 70%);
  border-radius: 50%;
  opacity: 0.6;
}
.hero-greeting { font-size: 14px; color: var(--text-secondary); margin-bottom: 4px; position: relative; }
.hero-name { font-size: 26px; font-weight: 700; color: var(--text-primary); margin-bottom: 20px; position: relative; }

.hero-stats { display: flex; gap: 24px; flex-wrap: wrap; position: relative; }
.hero-stat { display: flex; flex-direction: column; gap: 2px; }
.hero-stat-value { font-size: 24px; font-weight: 700; color: var(--accent); }
.hero-stat-label { font-size: 13px; color: var(--text-secondary); }

.hero-progress { margin-top: 20px; position: relative; }
.hero-progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}
.hero-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.hero-progress-text { font-size: 13px; color: var(--text-secondary); margin-top: 8px; }

/* ---------- 章节标题 ---------- */
.section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title-icon { font-size: 20px; }

/* ---------- 路径地图 ---------- */
.path-map {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  border: 1px solid var(--border-tertiary);
  box-shadow: var(--shadow-sm);
  margin-bottom: 28px;
}

.week-section { margin-bottom: 20px; }
.week-section:last-child { margin-bottom: 0; }

.week-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 15px;
  font-weight: 600;
}
.week-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.week-dot.w1 { background: var(--accent); }
.week-dot.w2 { background: var(--green); }
.week-dot.w3 { background: var(--orange); }
.week-dot.w4 { background: var(--purple); }
.week-desc { font-size: 13px; color: var(--text-secondary); font-weight: 400; }

.week-nodes { display: flex; align-items: center; gap: 0; flex-wrap: wrap; }

.path-node {
  width: 100px;
  padding: 10px 8px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-tertiary);
  background: var(--bg-card);
  text-align: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  flex-shrink: 0;
}
.path-node:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.path-node.locked { opacity: 0.5; cursor: not-allowed; }
.path-node.locked:hover { transform: none; box-shadow: none; }
.path-node.completed { border-color: var(--green); background: var(--green-bg); }
.path-node.current { border-color: var(--accent); background: var(--accent-bg); box-shadow: 0 0 0 3px var(--accent-light); }

.path-node-day { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 2px; }
.path-node.completed .path-node-day { color: var(--green); }
.path-node.current .path-node-day { color: var(--accent); }
.path-node-title { font-size: 12px; color: var(--text-primary); line-height: 1.3; }
.path-node-badge { font-size: 18px; margin-bottom: 4px; }
.path-node-lock { font-size: 14px; color: var(--text-tertiary); }

.path-arrow { color: var(--text-tertiary); font-size: 14px; padding: 0 4px; flex-shrink: 0; }
.week-separator { text-align: center; color: var(--text-tertiary); font-size: 16px; margin: 8px 0; }

/* ---------- 仪表盘卡片 ---------- */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 28px; }

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border-tertiary);
  box-shadow: var(--shadow-sm);
}
.stat-card-title { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; font-weight: 500; }
.stat-card-list { display: flex; flex-direction: column; gap: 10px; }
.stat-card-item { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.stat-card-item .badge-icon { font-size: 22px; }
.stat-card-item .badge-info { flex: 1; }
.stat-card-item .badge-name { font-weight: 500; color: var(--text-primary); }
.stat-card-item .badge-day { font-size: 12px; color: var(--text-tertiary); }

.stat-number { font-size: 32px; font-weight: 700; color: var(--accent); }
.stat-sub { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ---------- CTA 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); }
.btn-secondary:hover { background: var(--border-tertiary); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-large { padding: 14px 36px; font-size: 16px; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ---------- 关卡详情页 ---------- */
.lesson-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.lesson-back {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  transition: all 0.2s;
}
.lesson-back:hover { background: var(--bg-hover); color: var(--text-primary); }

.lesson-title-area { display: flex; align-items: center; gap: 12px; }
.lesson-day-badge {
  background: var(--accent);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}
.lesson-title { font-size: 24px; font-weight: 700; color: var(--text-primary); }

.lesson-badge-earned {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--green-bg);
  color: var(--green);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}

/* ---------- Tab 导航 ---------- */
.lesson-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 6px;
  margin-bottom: 24px;
  border: 1px solid var(--border-tertiary);
}
.lesson-tab {
  flex: 1;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.25s;
  text-align: center;
}
.lesson-tab:hover { color: var(--text-primary); }
.lesson-tab.active { background: var(--accent); color: #fff; }
.lesson-tab.completed::after { content: ' ✓'; color: var(--green); }
.lesson-tab.active.completed::after { color: #fff; }

/* ---------- 知识讲解区 ---------- */
.concept-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 28px;
  border: 1px solid var(--border-tertiary);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.concept-heading { font-size: 18px; font-weight: 600; color: var(--text-primary); margin-bottom: 14px; }
.concept-text { font-size: 15px; color: var(--text-primary); line-height: 1.8; margin-bottom: 14px; }
.concept-text strong { color: var(--accent); font-weight: 600; }
.concept-text code {
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--accent);
}

.concept-example {
  background: var(--bg-code);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin: 14px 0;
  border: 1px solid var(--border-tertiary);
  overflow-x: auto;
}
.concept-example pre { font-size: 13px; line-height: 1.6; color: var(--text-primary); }
.concept-example-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  font-weight: 500;
}

.concept-tip {
  background: var(--yellow-bg);
  border-left: 3px solid var(--yellow);
  padding: 12px 16px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 14px 0;
  font-size: 14px;
}
.concept-tip-label { font-weight: 600; color: #92760a; margin-bottom: 4px; }
[data-theme="dark"] .concept-tip-label { color: var(--yellow); }

.concept-scene {
  background: var(--purple-bg);
  border-left: 3px solid var(--purple);
  padding: 12px 16px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 14px 0;
  font-size: 14px;
}
.concept-scene-label { font-weight: 600; color: var(--purple); margin-bottom: 4px; }

/* ---------- 流程图 ---------- */
.flowchart {
  margin: 16px 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-tertiary);
  border-radius: var(--radius-md);
  padding: 20px 16px;
}
.flowchart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 16px;
}
.flowchart-body {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.flow-node {
  max-width: 440px;
  width: 100%;
  text-align: center;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
  border: 1.5px solid;
  background: var(--bg-card);
}
.flow-node-text { color: var(--text-primary); }
.flow-start, .flow-end {
  border-radius: 999px;
  border-color: var(--green);
  background: var(--green-bg);
}
.flow-process { border-color: var(--accent); background: var(--accent-bg); }
.flow-decision { border-color: var(--orange); background: var(--orange-bg); }
.flow-loop { border-color: var(--purple); background: var(--purple-bg); }
.flow-arrow {
  color: var(--text-tertiary);
  font-size: 16px;
  line-height: 1.3;
  padding: 2px 0;
}
.flow-branches { display: flex; gap: 8px; margin-top: 8px; }
.flow-branch {
  flex: 1;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-tertiary);
  color: var(--text-secondary);
  text-align: left;
}
.flow-branch-yes { border-color: var(--green); color: var(--green); }
.flow-branch-no { border-color: var(--red); color: var(--red); }
.flow-loop-back { margin-top: 6px; font-size: 12px; color: var(--purple); }

/* ---------- 读代码选择题（quiz） ---------- */
.quiz-options { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border: 1.5px solid var(--border-tertiary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-card);
}
.quiz-option:hover { border-color: var(--border-secondary); background: var(--bg-hover); }
.quiz-option.selected { border-color: var(--accent); background: var(--accent-bg); }
.quiz-option.correct { border-color: var(--green); background: var(--green-bg); }
.quiz-option.wrong { border-color: var(--red); background: var(--red-bg); }
.quiz-option-letter {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.quiz-option.selected .quiz-option-letter { background: var(--accent); color: #fff; }
.quiz-option.correct .quiz-option-letter { background: var(--green); color: #fff; }
.quiz-option.wrong .quiz-option-letter { background: var(--red); color: #fff; }
.quiz-option-text { font-size: 14px; color: var(--text-primary); line-height: 1.6; }

/* ---------- 找 Bug / 测试设计 横幅 ---------- */
.debug-banner {
  background: var(--red-bg);
  border: 1px dashed var(--red);
  color: var(--red);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  font-size: 14px;
}
.test-design-banner {
  background: var(--purple-bg);
  border: 1px dashed var(--purple);
  color: var(--purple);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  font-size: 14px;
}
.bug-reveal {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--orange);
  font-size: 13px;
  color: var(--text-secondary);
  text-align: left;
  line-height: 1.7;
}

/* ---------- 代码编辑器区 ---------- */
.editor-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border-tertiary);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.editor-task { margin-bottom: 16px; }
.editor-task-title { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.editor-task-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.7; }
.editor-task-desc code { background: var(--bg-code); padding: 1px 5px; border-radius: 3px; font-size: 13px; color: var(--accent); }

.editor-wrapper {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-tertiary);
  margin-bottom: 12px;
}
#code-editor {
  width: 100%;
  height: 260px;
  font-size: 14px;
}

.editor-toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

.output-section {
  margin-top: 16px;
  border-top: 1px solid var(--border-tertiary);
  padding-top: 16px;
}
.output-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 8px; }
.output-box {
  background: var(--bg-code);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  min-height: 48px;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid var(--border-tertiary);
  color: var(--text-primary);
}
.output-box.error { border-color: var(--red); background: var(--red-bg); color: var(--red); }
.output-box.success { border-color: var(--green); background: var(--green-bg); }
.output-box .output-prefix { color: var(--text-tertiary); }
.output-box:empty::before { content: '点击「运行」查看输出结果...'; color: var(--text-tertiary); font-style: italic; }

/* ---------- 练习验证结果 ---------- */
.verify-result {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  display: none;
}
.verify-result.show { display: block; animation: slideIn 0.3s ease; }
.verify-result.pass { background: var(--green-bg); color: var(--green); border: 1px solid var(--green); }
.verify-result.fail { background: var(--orange-bg); color: var(--orange); border: 1px solid var(--orange); }

.verify-comparison { margin-top: 8px; font-size: 13px; font-family: var(--font-mono); }
.verify-comparison-row { display: flex; gap: 8px; margin-top: 4px; }
.verify-comparison-label { color: var(--text-tertiary); min-width: 70px; }

/* ---------- 挑战测试结果 ---------- */
.test-results { margin-top: 12px; }
.test-result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 4px;
}
.test-result-item.pass { background: var(--green-bg); color: var(--green); }
.test-result-item.fail { background: var(--red-bg); color: var(--red); }
.test-result-icon { font-size: 14px; }

/* ---------- 提示系统 ---------- */
.hint-box {
  background: var(--orange-bg);
  border: 1px solid var(--orange);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-top: 12px;
  font-size: 14px;
  color: var(--orange);
  display: none;
}
.hint-box.show { display: block; animation: slideIn 0.3s ease; }
.hint-box-label { font-weight: 600; margin-bottom: 4px; }

/* ---------- 步骤导航 ---------- */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border-tertiary);
}

/* ---------- 成就墙 ---------- */
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 16px;
}
.achievement-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px 12px;
  border: 1px solid var(--border-tertiary);
  text-align: center;
  transition: all 0.25s;
}
.achievement-card.earned { border-color: var(--green); box-shadow: 0 0 0 2px var(--green-light); }
.achievement-card.earned:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.achievement-card.locked { opacity: 0.4; filter: grayscale(1); }
.achievement-icon { font-size: 36px; margin-bottom: 8px; }
.achievement-name { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.achievement-desc { font-size: 11px; color: var(--text-tertiary); line-height: 1.4; }
.achievement-day { font-size: 11px; color: var(--accent); margin-top: 4px; font-weight: 500; }

/* ---------- 设置页 ---------- */
.settings-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 28px;
  border: 1px solid var(--border-tertiary);
  box-shadow: var(--shadow-sm);
}
.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-tertiary);
}
.settings-item:last-child { border-bottom: none; }
.settings-label { font-size: 15px; color: var(--text-primary); }
.settings-desc { font-size: 13px; color: var(--text-tertiary); margin-top: 2px; }

/* 主题选择器 */
.theme-selector { display: flex; gap: 8px; }
.theme-option {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-tertiary);
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.2s;
}
.theme-option:hover { border-color: var(--border-secondary); }
.theme-option.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }

/* 字体大小调节 */
.font-size-selector { display: flex; gap: 6px; }
.font-size-option {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-tertiary);
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.font-size-option.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }

/* ---------- Pyodide 加载遮罩 ---------- */
.pyodide-loading {
  position: fixed;
  inset: 0;
  background: var(--bg-secondary);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease;
}
.pyodide-loading.hidden { opacity: 0; pointer-events: none; }
.pyodide-loading-inner { text-align: center; }
.pyodide-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--border-tertiary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}
.pyodide-loading-text { font-size: 16px; color: var(--text-primary); font-weight: 500; margin-bottom: 8px; }
.pyodide-loading-sub { font-size: 13px; color: var(--text-tertiary); }

/* ---------- Toast 通知 ---------- */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-tertiary);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 14px;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.3s ease;
  max-width: 400px;
}
.toast.success { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.toast.error { border-color: var(--red); background: var(--red-bg); color: var(--red); }
.toast.info { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }

/* ---------- 庆祝动画 ---------- */
#celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  pointer-events: none;
  display: none;
}
#celebration-overlay.show { display: block; }

.celebration-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 40px 48px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-tertiary);
  z-index: 3001;
  pointer-events: auto;
  animation: celebratePop 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 90vw;
}
.celebration-badge { font-size: 64px; margin-bottom: 16px; animation: bounce 0.6s ease; }
.celebration-title { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.celebration-desc { font-size: 15px; color: var(--text-secondary); margin-bottom: 8px; }
.celebration-score { font-size: 14px; color: var(--accent); font-weight: 600; margin-bottom: 20px; }

.confetti {
  position: absolute;
  width: 10px; height: 10px;
  animation: confettiFall 2s ease-out forwards;
}

/* ---------- 通用动画 ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(20px); } }
@keyframes celebratePop { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); } 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes confettiFall { to { transform: translateY(100vh) rotate(720deg); opacity: 0; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.fade-in { animation: fadeIn 0.3s ease; }
.page-in { animation: pageIn 0.3s ease; }

/* ---------- 空状态 ---------- */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-tertiary); }
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-text { font-size: 15px; }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .container, .container-wide { padding: 20px 16px 48px; }
  .hero { padding: 24px 20px; }
  .hero-name { font-size: 22px; }
  .hero-stats { gap: 16px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .path-node { width: 80px; padding: 8px 4px; }
  .path-node-title { font-size: 11px; }
  .lesson-tabs { flex-direction: column; }
  .concept-section, .editor-section { padding: 20px 16px; }
  #code-editor { height: 220px; }
  .navbar { padding: 0 16px; }
  .navbar-title { font-size: 15px; }
  .achievements-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 12px; }
  .week-nodes { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 8px; }
}

@media (max-width: 480px) {
  .hero-stats { flex-direction: column; gap: 12px; }
  .lesson-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .lesson-nav { flex-direction: column; gap: 12px; }
}

/* ---------- Ace Editor 暗色适配 ---------- */
[data-theme="dark"] .ace_editor { background: var(--bg-code) !important; }
[data-theme="dark"] .ace_gutter { background: var(--bg-secondary) !important; color: var(--text-tertiary) !important; }
.ace_editor { font-family: var(--font-mono) !important; }

/* ---------- 滚动条美化 ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-secondary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-primary); }

/* ---------- 选中文本 ---------- */
::selection { background: var(--accent-light); color: var(--accent); }
