:root {
  --bg: #070b14;
  --bg-2: #0c1220;
  --panel: #111a2b;
  --panel-2: #16223a;
  --panel-3: #1c2b47;
  --border: #22314f;
  --border-soft: #1a2740;
  --text: #e6edf7;
  --text-dim: #9aa9c2;
  --text-faint: #6b7a94;
  --accent: #38bdf8;
  --accent-2: #22d3ee;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --violet: #a78bfa;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  background: radial-gradient(1200px 800px at 80% -10%, #10203a 0%, var(--bg) 55%);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Sidebar ---------- */
#sidebar {
  width: 272px;
  min-width: 272px;
  background: linear-gradient(180deg, #0b1120, #0a0f1c);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px 14px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; font-size: 20px;
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: 0.2px; }
.brand-tag { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.6px; }

.nav { padding: 4px 12px 8px; }
.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-faint); padding: 14px 10px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--text-dim); cursor: pointer; font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--panel-2); color: #fff; }
.nav-item .ico { width: 20px; text-align: center; font-size: 15px; }
.nav-item .count { margin-left: auto; font-size: 11px; color: var(--text-faint); background: var(--panel-3); padding: 1px 7px; border-radius: 20px; }

.mod-list { padding: 0 12px; }
.mod-item { margin-bottom: 2px; }
.mod-head {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 9px; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-dim); font-weight: 600; font-size: 13.5px; border: none; background: none; text-align: left;
}
.mod-head:hover { background: var(--panel); color: var(--text); }
.mod-head .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px rgba(255,255,255,0.04); }
.mod-head .chev { margin-left: auto; transition: transform 0.15s; color: var(--text-faint); font-size: 11px; }
.mod-item.open .mod-head .chev { transform: rotate(90deg); }
.mod-progress { height: 3px; background: var(--panel-3); border-radius: 3px; margin: 3px 9px 6px 26px; overflow: hidden; }
.mod-progress > span { display: block; height: 100%; border-radius: 3px; transition: width 0.3s; }

.lesson-list { display: none; padding: 0 0 6px 14px; }
.mod-item.open .lesson-list { display: block; }
.lesson-link {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 9px; border-radius: 7px; cursor: pointer; font-size: 13px;
  color: var(--text-dim); border: none; background: none; text-align: left;
}
.lesson-link:hover { background: var(--panel); color: var(--text); }
.lesson-link.active { background: var(--panel-2); color: #fff; }
.lesson-link .status { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--text-faint); flex: none; font-size: 9px; display: grid; place-items: center; }
.lesson-link.done .status { background: var(--green); border-color: var(--green); color: #052e1b; }
.lesson-link .lt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-foot { margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--border-soft); }
.streak-mini { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }

/* ---------- Main column ---------- */
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 22px; border-bottom: 1px solid var(--border-soft);
  background: rgba(7, 11, 20, 0.7); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30;
}
.icon-btn {
  background: var(--panel); border: 1px solid var(--border); color: var(--text-dim);
  width: 36px; height: 36px; border-radius: 9px; cursor: pointer; font-size: 16px; display: grid; place-items: center;
}
.view-title { font-size: 17px; font-weight: 700; margin: 0; flex: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search-wrap { position: relative; }
#search-input {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 8px 13px; font-size: 13.5px; width: 260px; outline: none;
  transition: border 0.12s, width 0.2s;
}
#search-input:focus { border-color: var(--accent); width: 320px; }
.search-results {
  position: absolute; top: calc(100% + 6px); right: 0; width: 360px; max-height: 420px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); z-index: 50;
}
.search-results .sr-item { display: block; padding: 10px 13px; cursor: pointer; border-bottom: 1px solid var(--border-soft); }
.search-results .sr-item:last-child { border-bottom: none; }
.search-results .sr-item:hover { background: var(--panel-2); }
.sr-title { font-size: 13.5px; font-weight: 600; }
.sr-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }
.streak-badge { font-size: 13px; color: var(--amber); font-weight: 600; white-space: nowrap; }

.content { padding: 26px 30px 60px; max-width: 1080px; width: 100%; margin: 0 auto; }

/* ---------- Cards / panels ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 16px; }
.module-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.module-card { position: relative; overflow: hidden; cursor: pointer; transition: transform 0.15s, border-color 0.15s; }
.module-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.module-card .mc-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.module-card .mc-icon { font-size: 28px; }
.module-card h3 { margin: 0; font-size: 17px; }
.module-card .mc-short { color: var(--text-faint); font-size: 12px; text-transform: uppercase; letter-spacing: 0.7px; }
.module-card p { color: var(--text-dim); font-size: 13.5px; margin: 0 0 14px; }
.module-card .mc-stats { display: flex; gap: 14px; font-size: 12px; color: var(--text-dim); flex-wrap: wrap; }
.module-card .bar { height: 5px; background: var(--panel-3); border-radius: 4px; margin-top: 14px; overflow: hidden; }
.module-card .bar > span { display: block; height: 100%; border-radius: 4px; }

/* ---------- Stat tiles ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
}
.stat .num { font-size: 26px; font-weight: 700; }
.stat .lbl { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 9px 15px; border-radius: 10px; cursor: pointer; font-size: 13.5px; font-weight: 600;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.btn:hover { background: var(--panel-3); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, #1d4ed8, #0ea5e9); border: none; color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.success { background: linear-gradient(135deg, #059669, #10b981); border: none; color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Lesson content ---------- */
.lesson-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.lesson-hero .crumb { color: var(--text-faint); font-size: 12.5px; margin-bottom: 5px; }
.lesson-hero h2 { margin: 0; font-size: 24px; line-height: 1.25; }
.lesson-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.mode-toggle { display: flex; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.mode-toggle button { background: none; border: none; color: var(--text-dim); padding: 8px 14px; cursor: pointer; font-size: 12.5px; font-weight: 600; }
.mode-toggle button.active { background: var(--panel-3); color: #fff; }

.doc { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px 30px; }
.doc h3 { font-size: 16px; margin: 26px 0 8px; color: var(--accent-2); }
.doc h3:first-child { margin-top: 0; }
.doc p { margin: 10px 0; color: var(--text); }
.doc ul { margin: 8px 0; padding-left: 20px; }
.doc li { margin: 6px 0; }
.doc .divider { height: 1px; background: var(--border-soft); margin: 22px 0; border: none; }

.recall-item { cursor: pointer; border-radius: 7px; transition: background 0.12s; }
.recall-item:hover { background: rgba(56, 189, 248, 0.06); }
.recall-hidden { filter: blur(7px); user-select: none; transition: filter 0.2s; }

.lesson-meta { display: flex; gap: 16px; margin-top: 22px; font-size: 12.5px; color: var(--text-faint); flex-wrap: wrap; }
.lesson-meta .chip { background: var(--panel); border: 1px solid var(--border); padding: 5px 11px; border-radius: 20px; }

/* ---------- Flashcards ---------- */
.deck-picker { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.deck-chip {
  background: var(--panel); border: 1px solid var(--border); color: var(--text-dim);
  padding: 8px 14px; border-radius: 20px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.deck-chip.active { background: var(--panel-3); color: #fff; border-color: var(--accent); }

.fc-stage { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.fc-counter { font-size: 13px; color: var(--text-dim); }
.fc-card {
  width: 100%; max-width: 620px; min-height: 260px; perspective: 1200px; cursor: pointer;
}
.fc-inner { position: relative; width: 100%; height: 100%; min-height: 260px; transform-style: preserve-3d; transition: transform 0.5s; }
.fc-card.flipped .fc-inner { transform: rotateX(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 20px; padding: 28px; text-align: center;
}
.fc-back { transform: rotateX(180deg); background: linear-gradient(160deg, #131f38, var(--panel)); }
.fc-face .hint { position: absolute; top: 16px; font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 1px; }
.fc-face .text { font-size: 20px; font-weight: 600; line-height: 1.4; max-height: 200px; overflow: auto; }
.fc-face.back .text { font-size: 17px; font-weight: 500; color: var(--text); }

.fc-grades { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.grade-btn { padding: 11px 18px; border-radius: 12px; border: 1px solid var(--border); cursor: pointer; font-weight: 700; font-size: 13.5px; color: #fff; transition: transform 0.08s, filter 0.12s; }
.grade-btn:active { transform: translateY(1px); }
.grade-btn:hover { filter: brightness(1.12); }
.g-again { background: #7f1d1d; border-color: #b91c1c; }
.g-hard { background: #7c2d12; border-color: #ea580c; }
.g-good { background: #14532d; border-color: #16a34a; }
.g-easy { background: #164e63; border-color: #0891b2; }

.fc-empty { text-align: center; padding: 50px 20px; color: var(--text-dim); }
.fc-empty .big { font-size: 46px; margin-bottom: 12px; }

/* ---------- Quiz ---------- */
.quiz-setup { max-width: 560px; margin: 0 auto; }
.q-option {
  display: block; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--border);
  padding: 13px 16px; border-radius: 12px; cursor: pointer; font-size: 14px; margin-bottom: 10px;
  transition: border-color 0.12s, background 0.12s; color: var(--text);
}
.q-option:hover { background: var(--panel-2); }
.q-option.correct { background: rgba(16, 185, 129, 0.16); border-color: var(--green); }
.q-option.wrong { background: rgba(248, 113, 113, 0.14); border-color: var(--red); }
.q-option:disabled { cursor: default; }

.q-card { max-width: 720px; margin: 0 auto; }
.q-stem { font-size: 16.5px; margin: 14px 0 18px; color: var(--text); padding: 14px 16px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.q-progress { height: 6px; background: var(--panel-3); border-radius: 4px; overflow: hidden; margin-bottom: 18px; }
.q-progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.2s; }
.q-feedback { padding: 13px 16px; border-radius: 12px; margin-top: 14px; font-size: 13.5px; }
.q-feedback.good { background: rgba(16,185,129,0.12); border: 1px solid rgba(16,185,129,0.4); }
.q-feedback.bad { background: rgba(248,113,113,0.12); border: 1px solid rgba(248,113,113,0.4); }
.q-cloze-input { background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 11px 14px; border-radius: 10px; font-size: 14px; width: 100%; max-width: 420px; }
.q-cloze-input:focus { border-color: var(--accent); outline: none; }

.result-ring { text-align: center; padding: 10px; }
.result-ring .score { font-size: 52px; font-weight: 800; }
.result-ring .pct { color: var(--text-dim); font-size: 14px; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast { background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13.5px; animation: slidein 0.2s ease; }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

.hidden { display: none !important; }
.muted { color: var(--text-dim); }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.section-title { font-size: 15px; font-weight: 700; margin: 26px 0 12px; color: var(--text); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-dim); }

/* Responsive */
@media (max-width: 860px) {
  #sidebar { position: fixed; left: -280px; z-index: 60; transition: left 0.2s; box-shadow: var(--shadow); }
  #sidebar.open { left: 0; }
  .icon-btn { display: grid; place-items: center; }
  .content { padding: 18px 16px 50px; }
  #search-input { width: 150px; }
  #search-input:focus { width: 200px; }
  .lesson-hero { flex-direction: column; }
  .hero { flex-direction: column; }
  .hero-stats { flex-direction: row; width: 100%; }
}

/* =====================================================================
   Gamification & visual enrichments
   ===================================================================== */

/* Inline term highlighting */
b.term { color: var(--accent-2); font-weight: 700; }

/* Lesson emoji */
.l-emoji { font-size: 12px; }
.l-emoji-lg { font-size: 26px; margin-right: 6px; }

/* Key takeaways */
.takeaways { border-left: 3px solid var(--amber); margin-bottom: 18px; background: linear-gradient(160deg, rgba(251,191,36,0.06), var(--panel)); }
.takeaways-title { font-weight: 700; color: var(--amber); margin-bottom: 8px; font-size: 14px; }
.takeaways ul { margin: 0; padding-left: 0; list-style: none; }
.takeaways li { margin: 8px 0; font-size: 13.5px; color: var(--text); }

/* Roadmap chips */
.roadmap { margin-bottom: 18px; }
.roadmap-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-faint); margin-bottom: 7px; font-weight: 600; }
.roadmap-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.roadmap-chip { background: var(--panel); border: 1px solid var(--border); color: var(--text-dim); font-size: 12px; padding: 5px 11px; border-radius: 20px; }

/* Dashboard hero */
.hero { display: flex; align-items: center; gap: 20px; margin-bottom: 20px; background: linear-gradient(140deg, #131f38, var(--panel)); }
.hero-icon { font-size: 48px; flex: none; filter: drop-shadow(0 4px 12px rgba(56,189,248,0.4)); }
.hero-main { flex: 1; min-width: 0; }
.hero-rank { font-size: 22px; font-weight: 800; }
.hero-sub { color: var(--text-dim); font-size: 13px; margin: 2px 0 10px; }
.hero-bar { height: 8px; }
.hero-stats { display: flex; gap: 22px; flex: none; }
.hs { text-align: center; }
.hs-num { font-size: 24px; font-weight: 800; }
.hs-lbl { font-size: 11px; color: var(--text-faint); }

/* Rank bar (sidebar) */
.rank-bar { height: 6px; background: var(--panel-3); border-radius: 4px; overflow: hidden; }
.rank-bar > span { display: block; height: 100%; background: linear-gradient(90deg, #f59e0b, #fbbf24); border-radius: 4px; transition: width 0.4s; }
.rank-row { display: flex; align-items: center; gap: 10px; }
.rank-icon { font-size: 24px; }
.rank-body { flex: 1; min-width: 0; }
.rank-line { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text); }
.xp-num { color: var(--amber); font-weight: 700; font-size: 11.5px; }
.rank-next { font-size: 10.5px; color: var(--text-faint); margin-top: 4px; }

/* Achievements */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.badge { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--border); text-align: center; }
.badge-icon { font-size: 28px; }
.badge-name { font-size: 12px; color: var(--text-dim); font-weight: 600; line-height: 1.2; }
.badge.unlocked { border-color: rgba(251,191,36,0.5); background: linear-gradient(160deg, rgba(251,191,36,0.08), var(--panel)); }
.badge.unlocked .badge-name { color: var(--amber); }
.badge.locked { opacity: 0.55; filter: grayscale(0.8); }

/* Diagrams */
.diagram-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.diagram-grid.lg { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.diagram-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: transform 0.15s, border-color 0.15s; }
.diagram-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.diagram-svg { padding: 14px; }
.diagram-svg svg { width: 100%; height: auto; display: block; border-radius: 8px; }
.diagram-svg.big svg { background: #0a0f1c; }
.diagram-cap { padding: 12px 16px; border-top: 1px solid var(--border-soft); }
.diagram-cap b { font-size: 14px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(4,7,14,0.72); backdrop-filter: blur(5px); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 20px; padding: 30px; max-width: 420px; width: 100%; text-align: center; box-shadow: var(--shadow); position: relative; animation: popin 0.2s ease; }
@keyframes popin { from { transform: scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }
.levelup-icon { font-size: 60px; margin-bottom: 8px; }
.levelup-title { font-size: 13px; text-transform: uppercase; letter-spacing: 2px; color: var(--amber); font-weight: 700; }
.levelup-rank { font-size: 28px; font-weight: 800; margin: 6px 0; }
.dg-modal { max-width: 760px; text-align: left; max-height: 90vh; overflow-y: auto; }
.modal-close { position: absolute; top: 14px; right: 14px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.modal-close:hover { color: #fff; }
.rel-lessons { display: flex; flex-wrap: wrap; gap: 8px; }

/* Toasts */
.toast.xp { border-left-color: var(--amber); }
.toast.badge { border-left-color: var(--violet); background: linear-gradient(160deg, rgba(167,139,250,0.12), var(--panel-2)); }

/* =====================================================================
   Cloud sync
   ===================================================================== */
.sync-indicator { font-size: 16px; cursor: default; min-width: 18px; text-align: center; }
.sync-indicator.saving { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sync-indicator.error { filter: drop-shadow(0 0 4px var(--red)); }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.field small { display: block; margin-top: 5px; font-size: 11.5px; }
.field code { background: var(--panel-2); padding: 1px 6px; border-radius: 5px; font-family: var(--mono); font-size: 11px; }

.sync-status { margin-top: 14px; font-size: 13px; color: var(--text-dim); padding: 9px 12px; background: var(--panel-2); border-radius: 9px; }

/* =====================================================================
   Collapsible sidebar (rail mode) — desktop only
   ===================================================================== */
#sidebar { transition: width 0.2s ease, min-width 0.2s ease; }
@media (min-width: 861px) {
  #app.sidebar-collapsed #sidebar { width: 68px; min-width: 68px; }
  #app.sidebar-collapsed .brand { justify-content: center; padding: 18px 6px 14px; }
  #app.sidebar-collapsed .brand-text,
  #app.sidebar-collapsed .nav-label,
  #app.sidebar-collapsed .nav-item > span:not(.ico),
  #app.sidebar-collapsed .nav-item .count,
  #app.sidebar-collapsed .mod-head > span:not(.dot),
  #app.sidebar-collapsed .mod-head .chev,
  #app.sidebar-collapsed .mod-progress,
  #app.sidebar-collapsed .lesson-list,
  #app.sidebar-collapsed .rank-body,
  #app.sidebar-collapsed .rank-next { display: none; }
  #app.sidebar-collapsed .nav-item { justify-content: center; padding: 10px 0; }
  #app.sidebar-collapsed .nav-item .ico { font-size: 20px; }
  #app.sidebar-collapsed .mod-head { justify-content: center; padding: 10px 0; }
  #app.sidebar-collapsed .mod-head .dot { width: 11px; height: 11px; }
  #app.sidebar-collapsed .rank-row { justify-content: center; }
  #app.sidebar-collapsed .rank-icon { font-size: 26px; }
  #app.sidebar-collapsed .sidebar-foot { padding: 12px 6px; }
}

/* Reading progress bar */
.read-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--violet));
  transform-origin: 0 50%; transform: scaleX(0); z-index: 200; transition: transform 0.08s linear;
}

/* =====================================================================
   More engaging lesson content
   ===================================================================== */
.doc { font-size: 15.5px; }
.doc h3 {
  border-left: 3px solid var(--accent-2); padding-left: 11px;
  border-radius: 0 6px 6px 0;
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.06), transparent);
}
.doc ul { list-style: none; padding-left: 4px; }
.doc ul li { position: relative; padding-left: 18px; }
.doc ul li::before { content: '▸'; position: absolute; left: 0; top: 0; color: var(--accent); font-weight: 700; }
.doc p { color: var(--text); }
.doc b.term { background: rgba(34, 211, 238, 0.08); padding: 0 3px; border-radius: 4px; }

/* Diagram cards: constrain height so SVGs stay tidy */
.diagram-svg { display: flex; align-items: center; justify-content: center; background: #0a0f1c; }
.diagram-svg svg { width: 100%; height: auto; max-height: 240px; }

/* =====================================================================
   Mobile / phone layout
   ===================================================================== */
@media (max-width: 860px) {
  .content { padding: 16px 12px 48px; }
  .module-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .hero-stats { gap: 14px; }
  .hs-num { font-size: 20px; }
  .fc-card { min-height: 220px; }
  .fc-face .text { font-size: 17px; }
  .fc-face.back .text { font-size: 15px; }
  .q-stem { font-size: 15px; }
  .doc { padding: 20px 16px; }
  .search-results { width: calc(100vw - 24px); right: -60px; }
  .view-title { font-size: 15px; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .lesson-actions .btn { padding: 8px 11px; font-size: 12.5px; }
  .diagram-grid, .diagram-grid.lg { grid-template-columns: 1fr; }
  .badge-grid { grid-template-columns: repeat(3, 1fr); }
  .badge { padding: 12px 6px; }
  .badge-icon { font-size: 22px; }
}
