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

:root {
  --bg: #f8fafc;
  --bg2: #ffffff;
  --bg3: #f1f5f9;
  --text: #1e293b;
  --text2: #475569;
  --text3: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
  --radius: 12px;
  --sidebar-w: 260px;
  --header-h: 60px;
  --accent: #3B82F6;
  --accent-light: #EFF6FF;
  --green: #10B981;
  --yellow: #F59E0B;
  --red: #EF4444;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg2: #1e293b;
  --bg3: #334155;
  --text: #f1f5f9;
  --text2: #cbd5e1;
  --text3: #64748b;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.4);
}

html { scroll-behavior: smooth; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text); transition: background 0.3s, color 0.3s; overflow-x: hidden; }

/* ===== HEADER ===== */
.header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h); background: var(--bg2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 16px;
  box-shadow: var(--shadow);
}
.header-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--accent); }
.header-logo span { font-size: 22px; }
.header-search {
  flex: 1; max-width: 400px; position: relative;
}
.header-search input {
  width: 100%; padding: 8px 16px 8px 40px; border-radius: 24px;
  border: 1.5px solid var(--border); background: var(--bg3); color: var(--text);
  font-size: 14px; outline: none; transition: all 0.2s;
}
.header-search input:focus { border-color: var(--accent); background: var(--bg2); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.header-search .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text3); font-size: 16px; }
.header-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.btn-icon { background: var(--bg3); border: 1px solid var(--border); color: var(--text2); cursor: pointer; border-radius: 8px; padding: 8px 10px; font-size: 16px; transition: all 0.2s; }
.btn-icon:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* ===== LAYOUT ===== */
.layout { display: flex; min-height: 100vh; padding-top: var(--header-h); }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--bg2);
  border-right: 1px solid var(--border); position: fixed;
  top: var(--header-h); bottom: 0; overflow-y: auto;
  transition: transform 0.3s; z-index: 50; padding: 16px 0 80px;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.main { margin-left: var(--sidebar-w); flex: 1; padding: 32px 40px 80px; min-width: 0; }

/* ===== SIDEBAR NAV ===== */
.sidebar-section { padding: 8px 16px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; color: var(--text3); text-transform: uppercase; }
.sidebar-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  cursor: pointer; color: var(--text2); font-size: 14px; font-weight: 500;
  transition: all 0.15s; border-left: 3px solid transparent; position: relative;
}
.sidebar-item:hover { background: var(--bg3); color: var(--text); }
.sidebar-item.active { background: var(--accent-light); color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
[data-theme="dark"] .sidebar-item.active { background: rgba(59,130,246,0.15); }
.sidebar-item .item-icon { font-size: 18px; flex-shrink: 0; }
.sidebar-item .item-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-item .progress-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--border);
}
.sidebar-item .progress-dot.done { background: var(--green); }
.sidebar-item .progress-dot.partial { background: var(--yellow); }

/* ===== UNIT CARD (Homepage) ===== */
.home-header { margin-bottom: 32px; }
.home-header h1 { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.home-header p { color: var(--text2); font-size: 15px; }
.progress-overview {
  background: var(--bg2); border-radius: var(--radius); padding: 20px 24px;
  border: 1px solid var(--border); margin-bottom: 32px;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.progress-overview .prog-stat { text-align: center; }
.progress-overview .prog-stat .num { font-size: 28px; font-weight: 800; color: var(--accent); }
.progress-overview .prog-stat .label { font-size: 12px; color: var(--text3); }
.progress-bar-wrap { flex: 1; min-width: 200px; }
.progress-bar-wrap label { font-size: 13px; color: var(--text2); margin-bottom: 6px; display: block; }
.progress-bar { height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--green)); border-radius: 4px; transition: width 0.5s ease; }

.units-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.unit-card {
  background: var(--bg2); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 20px; cursor: pointer; transition: all 0.2s; position: relative; overflow: hidden;
}
.unit-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--card-color, var(--accent)); }
.unit-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--card-color, var(--accent)); }
.unit-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.unit-card-icon { font-size: 28px; }
.unit-card-title { font-weight: 700; font-size: 16px; }
.unit-card-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }
.unit-card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tag { font-size: 11px; padding: 3px 8px; border-radius: 20px; background: var(--bg3); color: var(--text2); font-weight: 500; }
.unit-card-footer { display: flex; justify-content: space-between; align-items: center; }
.unit-card-stats { display: flex; gap: 14px; }
.stat { font-size: 12px; color: var(--text3); display: flex; align-items: center; gap: 4px; }
.stat strong { color: var(--text2); font-weight: 600; }
.btn-open { padding: 7px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; border: none; cursor: pointer; background: var(--card-color, var(--accent)); color: white; transition: opacity 0.2s; }
.btn-open:hover { opacity: 0.85; }

/* ===== UNIT VIEW ===== */
.unit-header { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.unit-header-icon { font-size: 44px; }
.unit-header-info h2 { font-size: 26px; font-weight: 800; }
.unit-header-info .unit-meta { font-size: 14px; color: var(--text3); margin-top: 4px; }
.back-btn { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text3); cursor: pointer; margin-bottom: 20px; transition: color 0.2s; }
.back-btn:hover { color: var(--accent); }

/* ===== TABS ===== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 28px; overflow-x: auto; }
.tab-btn {
  padding: 10px 20px; font-size: 14px; font-weight: 600; cursor: pointer;
  border: none; background: none; color: var(--text3); border-bottom: 2px solid transparent;
  white-space: nowrap; transition: all 0.2s;
}
.tab-btn:hover { color: var(--text2); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; animation: fadeIn 0.25s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== STUDY NOTES ===== */
.notes-section { margin-bottom: 28px; }
.notes-section-title {
  font-size: 16px; font-weight: 700; color: white; padding: 10px 16px;
  border-radius: 8px 8px 0 0; background: var(--unit-color, var(--accent));
  display: flex; align-items: center; gap: 8px;
}
.notes-points { background: var(--bg2); border: 1px solid var(--border); border-top: none; border-radius: 0 0 8px 8px; padding: 16px 20px; }
.notes-point {
  display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 14px; line-height: 1.6; color: var(--text2);
}
.notes-point:last-child { border-bottom: none; }
.notes-point::before { content: '→'; color: var(--unit-color, var(--accent)); font-weight: 700; flex-shrink: 0; }

/* ===== SUMMARY ===== */
.summary-list { list-style: none; }
.summary-item {
  display: flex; gap: 14px; padding: 14px 16px; border-radius: 8px;
  margin-bottom: 10px; background: var(--bg2); border: 1px solid var(--border);
  font-size: 14px; line-height: 1.6; color: var(--text2);
}
.summary-num {
  min-width: 28px; height: 28px; border-radius: 50%; background: var(--unit-color, var(--accent));
  color: white; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ===== FLASHCARDS ===== */
.flashcard-controls { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.flashcard-count { font-size: 14px; color: var(--text2); }
.fc-nav-btn {
  padding: 8px 18px; border-radius: 8px; font-size: 14px; font-weight: 600;
  border: 1.5px solid var(--border); background: var(--bg2); color: var(--text);
  cursor: pointer; transition: all 0.2s;
}
.fc-nav-btn:hover:not(:disabled) { background: var(--accent); color: white; border-color: var(--accent); }
.fc-nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.fc-shuffle { margin-left: auto; }

.flashcard-wrapper { perspective: 1200px; margin-bottom: 24px; }
.flashcard {
  width: 100%; min-height: 240px; position: relative; cursor: pointer;
  transform-style: preserve-3d; transition: transform 0.55s cubic-bezier(0.4,0,0.2,1);
  border-radius: var(--radius);
}
.flashcard.flipped { transform: rotateY(180deg); }
.fc-face {
  position: absolute; width: 100%; min-height: 240px; border-radius: var(--radius);
  backface-visibility: hidden; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 32px 40px;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.fc-front { background: var(--bg2); }
.fc-back { background: var(--unit-light, var(--accent-light)); transform: rotateY(180deg); }
[data-theme="dark"] .fc-back { background: var(--bg3); }
.fc-label { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text3); margin-bottom: 16px; }
.fc-text { font-size: 18px; font-weight: 600; text-align: center; color: var(--text); line-height: 1.5; }
.fc-back .fc-text { font-size: 16px; font-weight: 500; color: var(--text2); }
.fc-flip-hint { font-size: 12px; color: var(--text3); margin-top: 12px; }

.fc-progress-bar { height: 5px; background: var(--bg3); border-radius: 3px; overflow: hidden; margin-bottom: 20px; }
.fc-progress-fill { height: 100%; border-radius: 3px; background: var(--unit-color, var(--accent)); transition: width 0.4s ease; }

.fc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.fc-grid-item {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; cursor: pointer; transition: all 0.2s; position: relative;
}
.fc-grid-item:hover { border-color: var(--unit-color, var(--accent)); transform: translateY(-2px); box-shadow: var(--shadow); }
.fc-grid-item .fc-q { font-size: 13px; font-weight: 600; margin-bottom: 10px; color: var(--text); }
.fc-grid-item .fc-a { font-size: 12px; color: var(--text2); line-height: 1.5; }
.view-toggle { display: flex; gap: 4px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.view-btn { padding: 6px 12px; font-size: 13px; border: none; cursor: pointer; background: var(--bg2); color: var(--text2); transition: all 0.2s; }
.view-btn.active { background: var(--accent); color: white; }

/* ===== QUESTIONS ===== */
.question-item {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 16px; overflow: hidden;
}
.question-header {
  padding: 16px 20px; display: flex; align-items: flex-start; gap: 14px; cursor: pointer;
  transition: background 0.15s;
}
.question-header:hover { background: var(--bg3); }
.question-num {
  min-width: 32px; height: 32px; border-radius: 50%; background: var(--unit-color, var(--accent));
  color: white; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.question-text { font-size: 15px; font-weight: 600; line-height: 1.5; color: var(--text); flex: 1; }
.question-opts { padding: 4px 20px 0 66px; }
.question-opts li { font-size: 13px; color: var(--text2); padding: 3px 0; list-style: none; }
.question-opts li::before { content: attr(data-opt) ') '; font-weight: 600; color: var(--text3); }
.question-toggle { font-size: 12px; color: var(--text3); flex-shrink: 0; padding-top: 2px; transition: transform 0.2s; }
.question-toggle.open { transform: rotate(180deg); }
.question-answer { display: none; padding: 0 20px 16px 66px; }
.question-answer.open { display: block; animation: fadeIn 0.2s; }
.answer-box {
  background: var(--bg3); border-radius: 8px; padding: 14px 16px;
  border-left: 3px solid var(--green);
}
.answer-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; color: var(--green); text-transform: uppercase; margin-bottom: 6px; }
.answer-text { font-size: 14px; color: var(--text2); line-height: 1.6; }
.hint-box {
  margin-top: 10px; background: #FFFBEB; border-radius: 8px; padding: 10px 14px;
  border-left: 3px solid var(--yellow); font-size: 13px; color: #92400e; line-height: 1.5;
}
[data-theme="dark"] .hint-box { background: rgba(245,158,11,0.1); color: #fbbf24; }
.hint-label { font-size: 11px; font-weight: 700; color: var(--yellow); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }

/* ===== SEARCH RESULTS ===== */
.search-results { }
.search-result-item { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; margin-bottom: 10px; cursor: pointer; transition: all 0.2s; }
.search-result-item:hover { border-color: var(--accent); transform: translateX(3px); }
.search-result-unit { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; }
.search-result-text { font-size: 14px; color: var(--text); margin-top: 4px; line-height: 1.5; }
.search-result-text mark { background: rgba(59,130,246,0.2); color: var(--accent); border-radius: 2px; padding: 0 2px; }
.search-empty { text-align: center; padding: 48px 20px; color: var(--text3); font-size: 15px; }

/* ===== TOAST ===== */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg2); color: var(--text); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease; min-width: 180px;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; padding: 20px 20px 80px; }
  .units-grid { grid-template-columns: 1fr; }
  .fc-grid { grid-template-columns: 1fr; }
}
.menu-btn { display: none; }
@media (max-width: 768px) { .menu-btn { display: flex; } }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 49; }
.sidebar-overlay.open { display: block; }

/* ===== NCERT QUESTION BANK ===== */
.qbank-tabs { display:flex; gap:6px; margin-bottom:20px; flex-wrap:wrap; }
.qbank-tab { padding:7px 16px; border-radius:20px; font-size:13px; font-weight:600; cursor:pointer; border:1.5px solid var(--border); background:var(--bg2); color:var(--text2); transition:all 0.2s; }
.qbank-tab.active { background:var(--unit-color,var(--accent)); color:white; border-color:var(--unit-color,var(--accent)); }
.qbank-count { font-size:12px; font-weight:500; background:rgba(0,0,0,0.15); padding:1px 7px; border-radius:10px; margin-left:4px; }

.ncert-q { background:var(--bg2); border:1px solid var(--border); border-radius:10px; margin-bottom:12px; overflow:hidden; }
.ncert-q-header { display:flex; align-items:flex-start; gap:12px; padding:14px 16px; cursor:pointer; transition:background 0.15s; }
.ncert-q-header:hover { background:var(--bg3); }
.ncert-q-badge { background:var(--unit-color,var(--accent)); color:white; font-size:11px; font-weight:700; padding:3px 9px; border-radius:12px; white-space:nowrap; flex-shrink:0; margin-top:1px; }
.ncert-q-text { font-size:14px; font-weight:600; line-height:1.55; flex:1; color:var(--text); }
.ncert-q-arrow { font-size:11px; color:var(--text3); flex-shrink:0; padding-top:2px; transition:transform 0.2s; }
.ncert-q-arrow.open { transform:rotate(180deg); }
.ncert-q-answer { display:none; padding:0 16px 14px 54px; }
.ncert-q-answer.open { display:block; animation:fadeIn 0.2s; }
.ncert-answer-box { background:var(--bg3); border-radius:8px; padding:12px 14px; border-left:3px solid var(--green); }
.ncert-answer-label { font-size:10px; font-weight:700; color:var(--green); text-transform:uppercase; letter-spacing:0.08em; margin-bottom:5px; }
.ncert-answer-text { font-size:13.5px; color:var(--text2); line-height:1.65; }

/* ===== WORKED EXAMPLES ===== */
.example-card { background:var(--bg2); border:1px solid var(--border); border-radius:10px; margin-bottom:16px; overflow:hidden; }
.example-header { display:flex; align-items:center; gap:12px; padding:14px 16px; cursor:pointer; transition:background 0.15s; }
.example-header:hover { background:var(--bg3); }
.example-badge { background:linear-gradient(135deg, var(--unit-color,var(--accent)), color-mix(in srgb, var(--unit-color,var(--accent)) 70%, white)); color:white; font-size:11px; font-weight:700; padding:4px 10px; border-radius:12px; flex-shrink:0; }
.example-topic { font-size:14px; font-weight:600; color:var(--text); flex:1; }
.example-arrow { font-size:11px; color:var(--text3); transition:transform 0.2s; }
.example-arrow.open { transform:rotate(180deg); }
.example-body { display:none; padding:0 16px 16px; }
.example-body.open { display:block; animation:fadeIn 0.2s; }
.example-problem { background:#F0F7FF; border-radius:8px; padding:12px 14px; margin-bottom:10px; border-left:3px solid var(--accent); }
[data-theme="dark"] .example-problem { background:rgba(59,130,246,0.1); }
.example-section-label { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:0.08em; color:var(--accent); margin-bottom:5px; }
.example-solution { background:#F0FFF4; border-radius:8px; padding:12px 14px; border-left:3px solid var(--green); }
[data-theme="dark"] .example-solution { background:rgba(16,185,129,0.1); }
.example-solution .example-section-label { color:var(--green); }
.example-text { font-size:13.5px; color:var(--text2); line-height:1.65; }

/* ===== DATA TABLES ===== */
.data-table-wrap { overflow-x:auto; margin-bottom:20px; border-radius:10px; border:1px solid var(--border); }
.data-table { width:100%; border-collapse:collapse; font-size:13px; }
.data-table-title { font-size:14px; font-weight:700; color:var(--text); padding:12px 16px; background:var(--bg3); border-bottom:1px solid var(--border); }
.data-table thead th { background:var(--unit-color,var(--accent)); color:white; padding:10px 14px; text-align:left; font-size:12px; font-weight:700; }
.data-table tbody tr:nth-child(even) { background:var(--bg3); }
.data-table tbody tr:hover { background:color-mix(in srgb, var(--unit-color,var(--accent)) 8%, transparent); }
.data-table td { padding:9px 14px; color:var(--text2); border-bottom:1px solid var(--border); }
.data-table tbody tr:last-child td { border-bottom:none; }

/* ===== DIAGRAMS ===== */
.diagram-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:16px; }
.diagram-card { background:var(--bg2); border:1px solid var(--border); border-radius:10px; overflow:hidden; }
.diagram-card-title { font-size:13px; font-weight:700; color:white; padding:8px 14px; background:var(--unit-color,var(--accent)); }
.diagram-card-body { padding:12px; display:flex; align-items:center; justify-content:center; min-height:160px; }
.diagram-card-body svg { max-width:100%; height:auto; }

/* ===== STATS BAR ===== */
.unit-stats-bar { display:flex; gap:14px; flex-wrap:wrap; padding:12px 0; border-bottom:1px solid var(--border); margin-bottom:20px; }
.unit-stat-item { display:flex; align-items:center; gap:6px; font-size:13px; color:var(--text2); }
.unit-stat-num { font-weight:700; color:var(--text); }

/* ===== SECTION BANNER ===== */
.section-banner { display:flex; align-items:center; gap:12px; padding:12px 16px; border-radius:10px; margin-bottom:20px; }
.section-banner-icon { font-size:22px; }
.section-banner-info h3 { font-size:16px; font-weight:700; margin-bottom:2px; }
.section-banner-info p { font-size:13px; color:var(--text3); }

/* ===== 3-MODE LEARN TAB ===== */
.mode-selector {
  display: flex; gap: 0; border-radius: 12px; overflow: hidden;
  border: 1.5px solid var(--border); width: fit-content; margin-bottom: 28px;
}
.mode-btn {
  padding: 10px 22px; font-size: 13px; font-weight: 700; cursor: pointer;
  border: none; background: var(--bg2); color: var(--text2); transition: all 0.2s;
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
}
.mode-btn:not(:last-child) { border-right: 1.5px solid var(--border); }
.mode-btn.active { background: var(--unit-color,var(--accent)); color: white; }
.mode-btn .mode-icon { font-size: 16px; }
.mode-desc-bar {
  background: var(--bg3); border-radius: 10px; padding: 10px 16px;
  font-size: 13px; color: var(--text2); margin-bottom: 24px;
  border-left: 3px solid var(--unit-color, var(--accent));
}

/* Prerequisites */
.prereq-section { margin-bottom: 32px; }
.prereq-title { font-size: 13px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 12px; }
.prereq-list { display: flex; gap: 10px; flex-wrap: wrap; }
.prereq-item {
  background: var(--bg2); border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 14px; font-size: 13px; max-width: 260px;
  transition: border-color 0.2s;
}
.prereq-item:hover { border-color: var(--unit-color, var(--accent)); }
.prereq-topic { font-weight: 700; color: var(--text); margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.prereq-desc { color: var(--text3); font-size: 12px; line-height: 1.5; }

/* Learn topic card */
.learn-topic { margin-bottom: 32px; }
.learn-topic-header {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  border-radius: 12px 12px 0 0; cursor: pointer;
  background: var(--unit-color, var(--accent));
  transition: opacity 0.2s;
}
.learn-topic-header:hover { opacity: 0.92; }
.learn-topic-num {
  background: rgba(255,255,255,0.25); color: white; font-size: 12px; font-weight: 800;
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.learn-topic-title { font-size: 16px; font-weight: 700; color: white; flex: 1; }
.learn-topic-toggle { color: rgba(255,255,255,0.8); font-size: 14px; transition: transform 0.25s; }
.learn-topic-toggle.open { transform: rotate(180deg); }
.learn-topic-body {
  display: none; border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 12px 12px; overflow: hidden;
}
.learn-topic-body.open { display: block; animation: fadeIn 0.25s; }

/* Mode content panels */
.mode-content { display: none; padding: 20px 22px; }
.mode-content.active { display: block; }

/* Quick mode */
.quick-bullets { list-style: none; }
.quick-bullet {
  display: flex; gap: 12px; padding: 9px 0;
  border-bottom: 1px solid var(--border); font-size: 14px; line-height: 1.6; color: var(--text2);
}
.quick-bullet:last-child { border-bottom: none; }
.quick-bullet::before { content: '⚡'; flex-shrink: 0; }

/* Learn mode */
.learn-prose {
  font-size: 15px; line-height: 1.8; color: var(--text2);
  max-width: 760px;
}
.learn-prose p { margin-bottom: 16px; }
.learn-prose strong { color: var(--text); font-weight: 700; }
.learn-block {
  background: var(--bg3); border-radius: 10px; padding: 16px 20px;
  margin: 20px 0; border-left: 4px solid var(--unit-color, var(--accent));
}
.learn-block-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--unit-color, var(--accent)); margin-bottom: 8px; }
.learn-text-block { white-space: pre-wrap; font-size: 14.5px; line-height: 1.85; color: var(--text2); }

/* Deep mode */
.deep-section { margin-bottom: 24px; }
.deep-section-title {
  font-size: 14px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1.5px solid var(--border);
}
.derivation-steps { }
.derivation-step {
  display: flex; gap: 16px; padding: 12px 0; border-bottom: 1px dashed var(--border);
}
.derivation-step:last-child { border-bottom: none; }
.step-num {
  min-width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--unit-color, var(--accent)); color: white;
  font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.step-content { font-size: 14px; line-height: 1.7; color: var(--text2); }
.step-math { font-family: 'Georgia', serif; font-size: 15px; color: var(--text); margin-top: 4px; }

/* Real-world cards */
.rw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 12px; margin-top: 12px; }
.rw-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; transition: all 0.2s;
}
.rw-card:hover { border-color: var(--unit-color, var(--accent)); transform: translateY(-2px); box-shadow: var(--shadow); }
.rw-card-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.rw-card-title::before { content: '🌍'; }
.rw-card-desc { font-size: 12.5px; color: var(--text2); line-height: 1.6; }

/* Misconception cards */
.misconception-list { display: flex; flex-direction: column; gap: 10px; }
.misconception-card { border-radius: 10px; overflow: hidden; }
.mc-wrong {
  background: #FEF2F2; border: 1px solid #FECACA; padding: 10px 14px;
  font-size: 13px; color: #991B1B; display: flex; gap: 8px; align-items: flex-start;
}
[data-theme="dark"] .mc-wrong { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); color: #FCA5A5; }
.mc-wrong::before { content: '✗'; font-weight: 800; flex-shrink: 0; margin-top: 1px; }
.mc-right {
  background: #F0FDF4; border: 1px solid #BBF7D0; padding: 10px 14px;
  font-size: 13px; color: #166534; display: flex; gap: 8px; align-items: flex-start;
}
[data-theme="dark"] .mc-right { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.3); color: #6EE7B7; }
.mc-right::before { content: '✓'; font-weight: 800; flex-shrink: 0; margin-top: 1px; }

/* Deep prose */
.deep-prose { font-size: 14px; line-height: 1.85; color: var(--text2); max-width: 760px; }
.deep-prose p { margin-bottom: 16px; }
.deep-prose strong { color: var(--text); font-weight: 700; }
.deep-prose ul, .deep-prose ol { margin: 12px 0 12px 24px; }
.deep-prose li { margin-bottom: 6px; }
.learn-prose ul, .learn-prose ol { margin: 12px 0 12px 24px; }
.learn-prose li { margin-bottom: 6px; }
.learn-prose .katex-display, .deep-prose .katex-display { margin: 16px 0; overflow-x: auto; }
.quick-bullet .katex { font-size: 0.95em; }
