/* ===== RESET & VARIABLES ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg2: #1a1d27;
  --bg3: #242736;
  --surface: #1e2130;
  --surface2: #262a3d;
  --border: #2e3350;
  --text: #e8eaf6;
  --text2: #9fa8da;
  --text3: #5c6bc0;
  --accent: #7c4dff;
  --accent2: #651fff;
  --accent-glow: rgba(124,77,255,0.3);
  --green: #00e676;
  --green-soft: #1b5e20;
  --red: #ff5252;
  --red-soft: #b71c1c;
  --yellow: #ffd740;
  --yellow-soft: #f57f17;
  --blue: #40c4ff;
  --orange: #ff6d00;
  --pink: #f48fb1;
  --teal: #1de9b6;
  --sidebar-w: 280px;
  --header-h: 60px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

[data-theme="light"] {
  --bg: #f0f2ff;
  --bg2: #e8eaf6;
  --bg3: #dde1f9;
  --surface: #ffffff;
  --surface2: #f5f5ff;
  --border: #c5cae9;
  --text: #1a1d2e;
  --text2: #3949ab;
  --text3: #7986cb;
  --accent: #5c35d8;
  --accent2: #4527a0;
  --accent-glow: rgba(92,53,216,0.2);
  --shadow: 0 4px 24px rgba(0,0,0,0.1);
}

/* ===== BASE ===== */
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ===== LAYOUT ===== */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ===== SIDEBAR ===== */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: width var(--transition);
  z-index: 100;
}

#sidebar.collapsed { width: 60px; }

.sidebar-logo {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), #e040fb);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 0 20px var(--accent-glow);
}

.sidebar-logo .logo-text {
  font-size: 13px; font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-logo .logo-text span { color: var(--accent); }

/* Player Stats */
.player-card {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.player-name { font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.xp-bar-wrap { display: flex; align-items: center; gap: 8px; }
.xp-bar { flex: 1; height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.xp-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #e040fb); border-radius: 3px; transition: width 0.5s ease; }
.xp-label { font-size: 10px; color: var(--text3); white-space: nowrap; }
.level-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--accent-glow); border: 1px solid var(--accent);
  color: var(--accent); font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 20px; margin-bottom: 6px;
}

/* Search */
.sidebar-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-search input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px 7px 32px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
  position: relative;
}
.sidebar-search input:focus { border-color: var(--accent); }
.search-wrap { position: relative; }
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text3); font-size: 14px; pointer-events: none;
}

/* Nav */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-section { margin-bottom: 4px; }
.nav-section-header {
  padding: 8px 16px 4px;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text3);
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  user-select: none;
}
.nav-section-header:hover { color: var(--text2); }
.nav-section-arrow { transition: transform var(--transition); font-size: 10px; }
.nav-section.open .nav-section-arrow { transform: rotate(90deg); }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px 8px 28px;
  cursor: pointer;
  border-radius: 0;
  font-size: 13px;
  color: var(--text2);
  transition: all var(--transition);
  position: relative;
  text-decoration: none;
  user-select: none;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; background: var(--accent); border-radius: 0 2px 2px 0;
}
.nav-item .nav-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-item .nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .nav-done {
  width: 16px; height: 16px;
  background: var(--green);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px;
  color: #000;
  flex-shrink: 0;
}
.nav-subsection { padding-left: 12px; }

/* Bottom controls */
.sidebar-bottom {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px;
  flex-shrink: 0;
}
.sidebar-btn {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 7px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.sidebar-btn:hover { background: var(--surface2); color: var(--text); border-color: var(--accent); }

/* ===== MAIN CONTENT ===== */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
#header {
  height: var(--header-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
}

.header-breadcrumb {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text3);
}
.header-breadcrumb .crumb { cursor: pointer; }
.header-breadcrumb .crumb:hover { color: var(--accent); }
.header-breadcrumb .crumb.current { color: var(--text); font-weight: 600; }
.breadcrumb-sep { color: var(--border); }

.header-actions { display: flex; align-items: center; gap: 10px; }
.header-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all var(--transition);
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.header-btn:hover { border-color: var(--accent); color: var(--accent); }
.header-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.mode-pill {
  display: flex;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.mode-pill button {
  background: none; border: none;
  color: var(--text2); padding: 6px 12px;
  cursor: pointer; font-size: 12px; font-weight: 600;
  transition: all var(--transition);
}
.mode-pill button.active { background: var(--accent); color: #fff; }

/* Progress bar */
#progress-bar {
  height: 3px;
  background: var(--bg3);
  flex-shrink: 0;
}
#progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #e040fb, var(--teal));
  transition: width 0.5s ease;
}

/* Content area */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
#content::-webkit-scrollbar { width: 6px; }
#content::-webkit-scrollbar-track { background: transparent; }
#content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== HOME PAGE ===== */
.home-hero {
  text-align: center;
  padding: 40px 20px 30px;
}
.home-hero h1 {
  font-size: 2.5rem; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #e040fb, var(--blue));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
}
.home-hero p { font-size: 1rem; color: var(--text2); max-width: 600px; margin: 0 auto 24px; }

.stats-row {
  display: flex; gap: 16px; justify-content: center;
  flex-wrap: wrap; margin-bottom: 32px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
  text-align: center;
  min-width: 120px;
}
.stat-card .val { font-size: 2rem; font-weight: 800; color: var(--accent); }
.stat-card .label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 1px; }

/* Map */
.ml-map {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.ml-map h2 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
#map-canvas { width: 100%; border-radius: var(--radius-sm); }

/* Cards grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.algo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.algo-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-color, var(--accent));
}
.algo-card:hover {
  border-color: var(--card-color, var(--accent));
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.algo-card .card-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.algo-card .card-emoji { font-size: 28px; }
.algo-card .card-title { font-size: 15px; font-weight: 700; }
.algo-card .card-role { font-size: 11px; color: var(--text3); font-style: italic; }
.algo-card .card-desc { font-size: 13px; color: var(--text2); line-height: 1.5; margin-bottom: 12px; }
.algo-card .card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.algo-card .card-progress {
  margin-top: 12px;
  display: flex; align-items: center; gap: 8px;
}
.mini-bar { flex: 1; height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.mini-bar-fill { height: 100%; background: var(--card-color, var(--accent)); border-radius: 2px; }
.mini-pct { font-size: 10px; color: var(--text3); }

/* ===== TOPIC PAGE ===== */
.topic-layout { display: flex; gap: 24px; }

.topic-main { flex: 1; min-width: 0; }

.topic-sidebar {
  width: 240px;
  flex-shrink: 0;
}

/* Connection map */
.connection-map {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.connection-map h3 { font-size: 13px; font-weight: 700; color: var(--text2); margin-bottom: 12px; }
.conn-from, .conn-to {
  margin-bottom: 10px;
}
.conn-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text3); margin-bottom: 6px; }
.conn-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 4px;
  transition: all var(--transition);
}
.conn-item:hover { border-color: var(--accent); color: var(--accent); }
.conn-arrow { color: var(--text3); font-size: 10px; }

/* Topic hero */
.topic-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.topic-hero-header { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.topic-emoji-big { font-size: 48px; }
.topic-title { font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.topic-subtitle { font-size: 14px; color: var(--text2); }
.character-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent-glow); border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 8px 14px;
  margin-top: 12px;
}
.character-name { font-weight: 700; color: var(--accent); font-size: 13px; }
.character-desc { font-size: 12px; color: var(--text2); }

/* Tabs */
.topic-tabs {
  display: flex;
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 16px;
  gap: 2px;
  flex-wrap: wrap;
}
.topic-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text2);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}
.topic-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.topic-tab:hover:not(.active) { color: var(--text); }

/* Content sections */
.content-section { display: none; }
.content-section.active { display: block; }

/* Theory cards */
.theory-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.theory-block h3 {
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.theory-block p { font-size: 14px; color: var(--text2); line-height: 1.7; margin-bottom: 10px; }
.theory-block p:last-child { margin-bottom: 0; }

/* Formula */
.formula-box {
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
  text-align: center;
}
.formula-main {
  font-size: 1.4rem;
  padding: 10px 0;
}
.formula-legend {
  margin-top: 14px;
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.formula-legend table { width: 100%; font-size: 13px; }
.formula-legend td { padding: 4px 8px; color: var(--text2); }
.formula-legend td:first-child { color: var(--yellow); font-family: monospace; font-weight: 700; width: 80px; }
.formula-intuition {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--accent-glow);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px; color: var(--text2);
  text-align: left;
}

/* Pros/Cons */
.pros-cons { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
.pros, .cons {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.pros { border-left: 3px solid var(--green); }
.cons { border-left: 3px solid var(--red); }
.pros h4 { color: var(--green); margin-bottom: 10px; font-size: 13px; }
.cons h4 { color: var(--red); margin-bottom: 10px; font-size: 13px; }
.pros li, .cons li { font-size: 13px; color: var(--text2); margin-left: 16px; margin-bottom: 6px; }

/* Use when */
.use-when-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.use-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.use-card.yes { border-top: 3px solid var(--green); }
.use-card.no { border-top: 3px solid var(--red); }
.use-card h4 { font-size: 13px; margin-bottom: 10px; }
.use-card.yes h4 { color: var(--green); }
.use-card.no h4 { color: var(--red); }
.use-card li { font-size: 12px; color: var(--text2); margin-left: 14px; margin-bottom: 5px; }

/* Simulator */
.simulator-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.sim-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.sim-header h3 { font-size: 14px; font-weight: 700; }
.sim-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.sim-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all var(--transition);
}
.sim-btn:hover { border-color: var(--accent); color: var(--accent); }
.sim-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.sim-btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.sim-canvas-wrap { padding: 16px; }
canvas.sim-canvas {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: block;
  margin: 0 auto;
  cursor: crosshair;
  background: var(--bg);
}
.sim-info {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text2);
  background: var(--bg3);
}
.sim-sliders { padding: 12px 20px; display: flex; flex-wrap: wrap; gap: 16px; }
.slider-group { flex: 1; min-width: 150px; }
.slider-label { font-size: 11px; color: var(--text3); margin-bottom: 4px; display: flex; justify-content: space-between; }
.slider-label span { color: var(--accent); font-weight: 700; }
input[type=range] {
  width: 100%; cursor: pointer;
  -webkit-appearance: none;
  height: 4px; background: var(--border); border-radius: 2px; outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  background: var(--accent); border-radius: 50%;
  cursor: pointer; box-shadow: 0 0 8px var(--accent-glow);
}

/* Quiz */
.quiz-container { max-width: 700px; margin: 0 auto; }
.quiz-question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.q-number { font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; margin-bottom: 8px; }
.q-text { font-size: 16px; font-weight: 600; line-height: 1.5; margin-bottom: 20px; }
.q-options { display: flex; flex-direction: column; gap: 10px; }
.q-option {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 14px;
}
.q-option:hover { border-color: var(--accent); background: var(--accent-glow); }
.q-option.selected { border-color: var(--accent); background: var(--accent-glow); }
.q-option.correct { border-color: var(--green); background: rgba(0,230,118,0.1); }
.q-option.wrong { border-color: var(--red); background: rgba(255,82,82,0.1); }
.q-option-letter {
  width: 24px; height: 24px; flex-shrink: 0;
  background: var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.q-option.correct .q-option-letter { background: var(--green); color: #000; }
.q-option.wrong .q-option-letter { background: var(--red); color: #fff; }
.q-explanation {
  margin-top: 16px;
  padding: 14px;
  background: var(--bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px; color: var(--text2);
  display: none;
}
.q-explanation.show { display: block; }
.q-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }

/* Achievements */
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.achievement-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  transition: all var(--transition);
}
.achievement-card.locked { opacity: 0.4; filter: grayscale(1); }
.achievement-card.unlocked { border-color: var(--yellow); }
.achievement-card .ach-icon { font-size: 32px; margin-bottom: 8px; }
.achievement-card .ach-name { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.achievement-card .ach-desc { font-size: 11px; color: var(--text2); }

/* Mission */
.mission-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.mission-scenario {
  background: var(--bg);
  border-left: 4px solid var(--yellow);
  padding: 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 15px;
  margin-bottom: 20px;
  color: var(--text);
}
.mission-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.mission-option {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}
.mission-option:hover { border-color: var(--accent); }
.mission-option .opt-emoji { font-size: 28px; margin-bottom: 6px; }
.mission-option .opt-name { font-size: 13px; font-weight: 700; }
.mission-option.correct-ans { border-color: var(--green); background: rgba(0,230,118,0.1); }
.mission-option.wrong-ans { border-color: var(--red); background: rgba(255,82,82,0.1); }

/* Notification toast */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 9999;
  display: flex; align-items: center; gap: 10px;
  animation: slideUp 0.3s ease;
  max-width: 300px;
}
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }
.toast.xp { border-color: var(--yellow); }
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* History panel */
.history-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.history-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.history-item:last-child { border-bottom: none; }
.h-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.h-dot.wrong { background: var(--red); }
.h-dot.correct { background: var(--green); }
.h-text { flex: 1; color: var(--text2); }
.h-topic { font-weight: 600; color: var(--text); }

/* Responsive */
@media (max-width: 900px) {
  #sidebar { position: fixed; height: 100vh; z-index: 200; transform: translateX(-100%); transition: transform var(--transition); }
  #sidebar.mobile-open { transform: translateX(0); }
  .topic-layout { flex-direction: column; }
  .topic-sidebar { width: 100%; }
  .pros-cons, .use-when-grid { grid-template-columns: 1fr; }
  .mission-options { grid-template-columns: 1fr; }
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }
.pulse { animation: pulse 1.5s ease infinite; }

/* Highlight / code */
code {
  background: var(--bg3);
  color: var(--yellow);
  font-family: 'Fira Code', monospace;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Info box */
.info-box {
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px; color: var(--text);
  margin: 12px 0;
  display: flex; gap: 10px;
}
.warn-box {
  background: rgba(255,215,64,0.1);
  border: 1px solid var(--yellow);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px; color: var(--text);
  margin: 12px 0;
}

/* Confetti placeholder */
.xp-popup {
  position: fixed; top: 80px; right: 24px;
  background: var(--yellow);
  color: #000;
  font-weight: 800;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  animation: floatUp 1.5s ease forwards;
  z-index: 9999;
}
@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-60px); }
}
