/* ============================================================
   THINKING MASTERY SYSTEM — COMPONENTS
   Every UI component fully styled
   ============================================================ */


/* ──────────────────────────────────────────
   1. APP SHELL / LAYOUT
   ────────────────────────────────────────── */

#app {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}


/* ──────────────────────────────────────────
   2. SIDEBAR
   ────────────────────────────────────────── */

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: transform var(--transition-medium), width var(--transition-medium);
  overflow: hidden;
}

/* Sidebar Header */
.sidebar-header {
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  text-decoration: none;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(167, 139, 250, 0.35);
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.logo-title {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-wide);
}

.logo-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--font-medium);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  margin-top: 2px;
}

/* User Level Display */
.user-level {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.level-badge {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--accent-glow);
  position: relative;
}

.level-badge::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent), transparent);
  z-index: -1;
  opacity: 0.5;
}

.level-number {
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  color: white;
  line-height: 1;
}

.user-meta {
  flex: 1;
  min-width: 0;
}

.user-name {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* XP Bar */
.xp-bar {
  height: 4px;
  background: var(--surface-overlay);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-1);
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-blue));
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.xp-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: var(--font-medium);
}


/* ── Navigation ── */

#main-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-3);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border var(--transition);
  position: relative;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  user-select: none;
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--surface-active);
  color: var(--accent);
  border-left-color: var(--accent);
}

.nav-item.active .nav-icon {
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: filter var(--transition);
}

.nav-label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-indicator {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--accent-emerald);
  flex-shrink: 0;
}

.nav-badge {
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: var(--font-bold);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
  line-height: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-badge:empty {
  display: none;
}


/* Sidebar Footer */
.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.streak-display {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: rgba(251, 191, 36, 0.08);
  border-radius: var(--radius);
  border: 1px solid rgba(251, 191, 36, 0.15);
  margin-bottom: var(--space-3);
}

.streak-icon {
  font-size: 18px;
}

.streak-count {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--accent-gold);
  line-height: 1;
}

.streak-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--font-medium);
}

.sidebar-footer-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.version-label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: var(--tracking-wider);
}

/* Hamburger Toggle */
.sidebar-toggle-btn {
  display: none;
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  z-index: calc(var(--z-sidebar) + 10);
  width: 40px;
  height: 40px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
  padding: 0;
}

.sidebar-toggle-btn:hover {
  background: var(--surface-overlay);
  box-shadow: var(--shadow);
}

.hamburger-line {
  width: 18px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: var(--radius-full);
  transition: transform var(--transition), opacity var(--transition);
}

/* Sidebar collapsed on mobile */
#sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-width)));
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: calc(var(--z-sidebar) - 1);
}


/* ──────────────────────────────────────────
   3. MAIN CONTENT
   ────────────────────────────────────────── */

#main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-medium);
}

#page-container {
  flex: 1;
  padding: var(--space-8) var(--space-8);
  max-width: 1400px;
  width: 100%;
}

#view-root {
  animation: fadeIn 0.25s ease;
}


/* ──────────────────────────────────────────
   4. PAGE HEADER
   ────────────────────────────────────────── */

.page-header {
  margin-bottom: var(--space-8);
}

.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  font-weight: var(--font-medium);
}

.page-breadcrumb span + span::before {
  content: '›';
  margin-right: var(--space-2);
}

.page-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.page-title {
  font-size: var(--text-4xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
}

.page-subtitle {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin-top: var(--space-2);
  line-height: var(--leading-relaxed);
}

.page-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-shrink: 0;
}


/* ──────────────────────────────────────────
   5. CARDS
   ────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  position: relative;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.card-sm {
  padding: var(--space-4);
}

.card-lg {
  padding: var(--space-8);
}

.card-hover {
  cursor: pointer;
}

.card-hover:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-raised {
  background: var(--surface-raised);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.card-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.card-footer {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

/* Topic card with colored left border */
.card-topic {
  border-left: 3px solid var(--topic-color, var(--accent));
  padding-left: calc(var(--space-6) - 3px);
}

.card-accent {
  border-top: 2px solid var(--accent);
}

/* Glowing card on hover */
.card-glow:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-accent);
}


/* ──────────────────────────────────────────
   6. BUTTONS
   ────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  line-height: 1;
  cursor: pointer;
  transition:
    background var(--transition),
    color var(--transition),
    border-color var(--transition),
    box-shadow var(--transition),
    transform var(--transition-fast);
  border: 1px solid transparent;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Primary */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 12px rgba(167, 139, 250, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #b99ffc, var(--accent));
  box-shadow: 0 4px 20px rgba(167, 139, 250, 0.45);
  color: white;
  text-decoration: none;
}

/* Secondary */
.btn-secondary {
  background: var(--surface-raised);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-overlay);
  border-color: var(--border-accent);
  color: var(--accent);
  text-decoration: none;
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
  text-decoration: none;
}

/* Danger */
.btn-danger {
  background: rgba(248, 113, 113, 0.1);
  color: var(--accent-red);
  border-color: rgba(248, 113, 113, 0.25);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.2);
  border-color: rgba(248, 113, 113, 0.5);
  text-decoration: none;
}

/* Emerald */
.btn-emerald {
  background: rgba(52, 211, 153, 0.1);
  color: var(--accent-emerald);
  border-color: rgba(52, 211, 153, 0.25);
}

.btn-emerald:hover:not(:disabled) {
  background: rgba(52, 211, 153, 0.2);
  border-color: rgba(52, 211, 153, 0.5);
  text-decoration: none;
}

/* Sizes */
.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-md);
  border-radius: var(--radius-md);
}

/* Icon-only button */
.btn-icon {
  padding: var(--space-2);
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.btn-icon:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-icon.btn-sm {
  width: 28px;
  height: 28px;
  padding: var(--space-1);
}

/* Loading state */
.btn.loading {
  color: transparent;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
  color: white;
}

/* Button group */
.btn-group {
  display: flex;
  gap: 0;
}

.btn-group .btn {
  border-radius: 0;
}

.btn-group .btn:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.btn-group .btn:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
}


/* ──────────────────────────────────────────
   7. PROGRESS BARS
   ────────────────────────────────────────── */

.progress-container {
  width: 100%;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--font-medium);
}

.progress-track {
  height: 8px;
  background: var(--surface-overlay);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent), var(--accent-blue));
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 40px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15));
  border-radius: var(--radius-full);
}

.progress-fill-thin {
  height: 4px;
}

/* Color variants */
.progress-fill-emerald {
  background: linear-gradient(90deg, var(--accent-emerald), #6ee7b7);
}

.progress-fill-gold {
  background: linear-gradient(90deg, var(--accent-gold), #fde68a);
}

.progress-fill-blue {
  background: linear-gradient(90deg, var(--accent-blue), #93c5fd);
}

/* Circular Progress Ring */
.progress-ring {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.progress-ring svg {
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: var(--surface-overlay);
  stroke-width: 4;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-ring-label {
  position: absolute;
  text-align: center;
}


/* ──────────────────────────────────────────
   8. BADGES
   ────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-wide);
  line-height: 1.4;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* Rarity tiers */
.badge-common {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-secondary);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.badge-uncommon {
  background: rgba(52, 211, 153, 0.12);
  color: var(--accent-emerald);
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.badge-rare {
  background: rgba(96, 165, 250, 0.12);
  color: var(--accent-blue);
  border: 1px solid rgba(96, 165, 250, 0.25);
}

.badge-epic {
  background: rgba(167, 139, 250, 0.15);
  color: var(--accent);
  border: 1px solid rgba(167, 139, 250, 0.3);
}

.badge-legendary {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(251, 146, 60, 0.15));
  color: var(--accent-gold);
  border: 1px solid rgba(251, 191, 36, 0.35);
  animation: pulse 3s infinite;
}

/* Category / Topic badge */
.badge-topic {
  border-radius: var(--radius-sm);
  padding: 2px var(--space-2);
  font-size: 10px;
  background: rgba(167, 139, 250, 0.1);
  color: var(--accent);
  border: 1px solid rgba(167, 139, 250, 0.2);
}

/* Achievement badge (large) */
.achievement-badge {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  flex-shrink: 0;
  position: relative;
}

.achievement-badge-common   { background: rgba(148, 163, 184, 0.1); border: 2px solid rgba(148, 163, 184, 0.2); }
.achievement-badge-uncommon { background: rgba(52, 211, 153, 0.1);  border: 2px solid rgba(52, 211, 153, 0.25); }
.achievement-badge-rare     { background: rgba(96, 165, 250, 0.1);  border: 2px solid rgba(96, 165, 250, 0.3); }
.achievement-badge-epic     { background: rgba(167, 139, 250, 0.12);border: 2px solid rgba(167, 139, 250, 0.35); box-shadow: 0 0 20px rgba(167, 139, 250, 0.2); }
.achievement-badge-legendary{
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), rgba(251, 146, 60, 0.12));
  border: 2px solid rgba(251, 191, 36, 0.4);
  box-shadow: 0 0 24px rgba(251, 191, 36, 0.25);
  animation: pulse 3s infinite;
}

/* Locked achievement overlay */
.achievement-badge.locked {
  filter: grayscale(1);
  opacity: 0.4;
}


/* ──────────────────────────────────────────
   9. QUIZ COMPONENTS
   ────────────────────────────────────────── */

.quiz-container {
  max-width: 760px;
  margin: 0 auto;
}

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.quiz-progress-track {
  flex: 1;
  height: 6px;
  background: var(--surface-overlay);
  border-radius: var(--radius-full);
  overflow: hidden;
  min-width: 120px;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-blue));
  border-radius: var(--radius-full);
  transition: width var(--transition-medium);
}

.quiz-counter {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: var(--font-medium);
  white-space: nowrap;
}

.quiz-timer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  padding: var(--space-1) var(--space-3);
  background: var(--surface-raised);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.quiz-timer.urgent {
  color: var(--accent-red);
  border-color: rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.08);
  animation: pulse 1s infinite;
}

.quiz-question {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  margin-bottom: var(--space-6);
}

.quiz-question-number {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  margin-bottom: var(--space-3);
}

.quiz-question-text {
  font-size: var(--text-xl);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  line-height: var(--leading-snug);
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
  text-align: left;
  width: 100%;
}

.option-btn:hover:not(:disabled):not(.correct):not(.incorrect) {
  background: var(--surface-hover);
  border-color: var(--border-accent);
}

.option-letter {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  color: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}

.option-text {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  transition: color var(--transition);
}

.option-btn:hover:not(:disabled):not(.correct):not(.incorrect) .option-letter {
  background: rgba(167, 139, 250, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.option-btn:hover:not(:disabled):not(.correct):not(.incorrect) .option-text {
  color: var(--text-primary);
}

.option-btn.selected {
  border-color: var(--accent);
  background: rgba(167, 139, 250, 0.08);
}

.option-btn.selected .option-letter {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.option-btn.correct {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.4);
  cursor: default;
}

.option-btn.correct .option-letter {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: white;
}

.option-btn.correct .option-text {
  color: var(--accent-emerald);
}

.option-btn.incorrect {
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.3);
  cursor: default;
}

.option-btn.incorrect .option-letter {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: white;
}

.option-btn.incorrect .option-text {
  color: var(--accent-red);
}

.quiz-explanation {
  padding: var(--space-5);
  background: rgba(167, 139, 250, 0.06);
  border: 1px solid rgba(167, 139, 250, 0.2);
  border-radius: var(--radius-lg);
  margin-top: var(--space-5);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  animation: fadeIn 0.3s ease;
}

.quiz-explanation-title {
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  margin-bottom: var(--space-2);
}

.quiz-results {
  text-align: center;
  padding: var(--space-10) var(--space-6);
  animation: slideUp 0.4s ease;
}

.quiz-score-display {
  font-size: 72px;
  font-weight: var(--font-bold);
  line-height: 1;
  margin-bottom: var(--space-2);
  background: linear-gradient(135deg, var(--accent), var(--accent-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}


/* ──────────────────────────────────────────
   10. LESSON VIEWER
   ────────────────────────────────────────── */

.lesson-container {
  max-width: 800px;
  margin: 0 auto;
}

.lesson-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.lesson-content {
  color: var(--text-secondary);
  line-height: var(--leading-loose);
  font-size: var(--text-md);
}

.lesson-content h2 {
  font-size: var(--text-2xl);
  color: var(--text-primary);
  margin: var(--space-8) 0 var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.lesson-content h3 {
  font-size: var(--text-xl);
  color: var(--text-primary);
  margin: var(--space-7) 0 var(--space-3);
}

.lesson-content h4 {
  font-size: var(--text-lg);
  color: var(--text-primary);
  margin: var(--space-6) 0 var(--space-3);
}

.lesson-content p {
  margin-bottom: var(--space-4);
}

.lesson-content ul,
.lesson-content ol {
  padding-left: var(--space-6);
  margin-bottom: var(--space-4);
}

.lesson-content ul {
  list-style: disc;
}

.lesson-content ol {
  list-style: decimal;
}

.lesson-content li {
  margin-bottom: var(--space-2);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

/* Callout boxes */
.callout {
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  margin: var(--space-6) 0;
  border-left: 3px solid;
  position: relative;
}

.callout-icon {
  font-size: 16px;
  margin-right: var(--space-2);
}

.callout-title {
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
}

.callout-info {
  background: rgba(96, 165, 250, 0.08);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.callout-info .callout-title { color: var(--accent-blue); }
.callout-info p { color: rgba(148, 163, 184, 0.9); }

.callout-warning {
  background: rgba(251, 191, 36, 0.08);
  border-color: var(--accent-gold);
}

.callout-warning .callout-title { color: var(--accent-gold); }
.callout-warning p { color: rgba(148, 163, 184, 0.9); }

.callout-success {
  background: rgba(52, 211, 153, 0.08);
  border-color: var(--accent-emerald);
}

.callout-success .callout-title { color: var(--accent-emerald); }
.callout-success p { color: rgba(148, 163, 184, 0.9); }

.callout-example {
  background: rgba(167, 139, 250, 0.08);
  border-color: var(--accent);
}

.callout-example .callout-title { color: var(--accent); }
.callout-example p { color: rgba(148, 163, 184, 0.9); }

/* Exercise card */
.exercise-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin: var(--space-7) 0;
}

.exercise-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.exercise-icon {
  width: 40px;
  height: 40px;
  background: rgba(167, 139, 250, 0.12);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.exercise-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

/* Takeaways / Key points */
.takeaways {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.05), rgba(96, 165, 250, 0.05));
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin: var(--space-7) 0;
}

.takeaways-title {
  font-size: var(--text-md);
  font-weight: var(--font-bold);
  color: var(--accent);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.takeaways-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.takeaways-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.takeaways-list li::before {
  content: '◆';
  color: var(--accent);
  font-size: 8px;
  margin-top: 6px;
  flex-shrink: 0;
}

/* Lesson navigation */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-6) 0;
  margin-top: var(--space-8);
  border-top: 1px solid var(--border);
  gap: var(--space-4);
}


/* ──────────────────────────────────────────
   11. KNOWLEDGE GRAPH
   ────────────────────────────────────────── */

#knowledge-graph-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  position: relative;
  min-height: 600px;
}

#knowledge-graph-container svg {
  width: 100%;
  height: 100%;
}

.graph-controls {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: var(--z-raised);
}

.graph-controls .btn {
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  font-size: 16px;
}

.graph-node-tooltip {
  position: absolute;
  background: var(--surface-raised);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  pointer-events: none;
  z-index: var(--z-overlay);
  max-width: 220px;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.15s ease;
}

.graph-node-tooltip h4 {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: 4px;
}

.graph-node-tooltip p {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin: 0;
}

.graph-legend {
  position: absolute;
  bottom: var(--space-4);
  left: var(--space-4);
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  background: rgba(15, 15, 26, 0.85);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
}

.graph-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 10px;
  color: var(--text-muted);
  font-weight: var(--font-medium);
}

.graph-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}


/* ──────────────────────────────────────────
   12. DASHBOARD WIDGETS
   ────────────────────────────────────────── */

/* Stat card */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  background: rgba(167, 139, 250, 0.1);
}

.stat-content {
  flex: 1;
  min-width: 0;
}

.stat-value {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: var(--tracking-tight);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: var(--font-medium);
  margin-top: var(--space-1);
}

.stat-trend {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  margin-top: var(--space-2);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.stat-trend.positive {
  background: rgba(52, 211, 153, 0.12);
  color: var(--accent-emerald);
}

.stat-trend.negative {
  background: rgba(248, 113, 113, 0.12);
  color: var(--accent-red);
}

/* Level badge (large, for dashboard) */
.level-badge-large {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px var(--accent-glow);
  position: relative;
}

.level-badge-large .level-number {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: white;
  line-height: 1;
}

.level-badge-large .level-label {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
}

/* Activity Heatmap */
.activity-heatmap {
  display: grid;
  grid-template-columns: repeat(53, 1fr);
  gap: 2px;
  overflow: hidden;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--surface-overlay);
  transition: background var(--transition);
  cursor: pointer;
}

.heatmap-cell:hover {
  opacity: 0.8;
  transform: scale(1.15);
}

.heatmap-cell[data-level="1"] { background: rgba(167, 139, 250, 0.2); }
.heatmap-cell[data-level="2"] { background: rgba(167, 139, 250, 0.4); }
.heatmap-cell[data-level="3"] { background: rgba(167, 139, 250, 0.65); }
.heatmap-cell[data-level="4"] { background: var(--accent); }

/* Dashboard welcome banner */
.welcome-banner {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.08) 0%, rgba(96, 165, 250, 0.05) 50%, rgba(52, 211, 153, 0.05) 100%);
  border: 1px solid rgba(167, 139, 250, 0.15);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  position: relative;
  overflow: hidden;
  margin-bottom: var(--space-8);
}

.welcome-banner::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 240px;
  height: 240px;
  border-radius: var(--radius-full);
  background: radial-gradient(circle, rgba(167, 139, 250, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

.welcome-greeting {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-2);
}

.welcome-date {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-5);
}


/* ──────────────────────────────────────────
   13. MENTAL MODEL CARD
   ────────────────────────────────────────── */

.model-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}

.model-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--model-color, var(--accent));
  opacity: 0.6;
  transition: opacity var(--transition);
}

.model-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.model-card:hover::before {
  opacity: 1;
}

.model-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.model-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  background: rgba(167, 139, 250, 0.1);
}

.model-name {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  line-height: var(--leading-tight);
  margin-bottom: 3px;
}

.model-tagline {
  font-size: var(--text-sm);
  color: var(--accent);
  font-weight: var(--font-medium);
  font-style: italic;
}

.model-description {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin: var(--space-3) 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.model-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.model-tag {
  font-size: 10px;
  padding: 2px 8px;
  background: var(--surface-overlay);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-weight: var(--font-medium);
}

.model-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.model-related {
  font-size: var(--text-xs);
  color: var(--text-muted);
}


/* ──────────────────────────────────────────
   14. CHALLENGE CARD
   ────────────────────────────────────────── */

.challenge-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
  position: relative;
}

.challenge-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.challenge-card.completed {
  opacity: 0.65;
}

.challenge-card.completed::after {
  content: '✓ Done';
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  background: rgba(52, 211, 153, 0.12);
  color: var(--accent-emerald);
  border: 1px solid rgba(52, 211, 153, 0.25);
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: var(--font-bold);
  padding: 2px 8px;
  letter-spacing: var(--tracking-wide);
}

.challenge-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.challenge-type-badge {
  font-size: 10px;
  font-weight: var(--font-bold);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.challenge-type-quiz        { background: rgba(96, 165, 250, 0.1); color: var(--accent-blue); }
.challenge-type-reflection  { background: rgba(167, 139, 250, 0.1); color: var(--accent); }
.challenge-type-exercise    { background: rgba(52, 211, 153, 0.1); color: var(--accent-emerald); }
.challenge-type-reading     { background: rgba(251, 191, 36, 0.1); color: var(--accent-gold); }

.challenge-name {
  font-size: var(--text-md);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  line-height: var(--leading-tight);
}

.challenge-description {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-4);
}

.challenge-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.difficulty-stars {
  display: flex;
  gap: 2px;
}

.difficulty-star {
  font-size: 12px;
  color: var(--border-strong);
}

.difficulty-star.filled {
  color: var(--accent-gold);
}

.xp-reward {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  color: var(--accent-gold);
}

.xp-reward-icon {
  font-size: 14px;
}


/* ──────────────────────────────────────────
   15. MODALS
   ────────────────────────────────────────── */

#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-medium);
}

#modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

#modal-container {
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-2xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  transform: translateY(24px) scale(0.97);
  transition: transform var(--transition-medium);
  overflow: hidden;
}

#modal-overlay.active #modal-container {
  transform: translateY(0) scale(1);
}

#modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#modal-title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
}

#modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

#modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  flex-shrink: 0;
}

#modal-footer:empty {
  display: none;
}


/* ──────────────────────────────────────────
   16. TOAST NOTIFICATIONS
   ────────────────────────────────────────── */

#toast-container {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 380px;
  width: 100%;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: slideInRight 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.toast.toast-exit {
  animation: slideOut 0.25s ease forwards;
}

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toast-message {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.toast-close {
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  flex-shrink: 0;
  transition: color var(--transition);
  background: none;
  border: none;
}

.toast-close:hover {
  color: var(--text-primary);
}

/* Toast progress bar */
.toast::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: currentColor;
  opacity: 0.4;
  animation: progressFill 4s linear forwards;
}

/* Toast variants */
.toast-success {
  border-left: 3px solid var(--accent-emerald);
  color: var(--accent-emerald);
}

.toast-success .toast-title { color: var(--accent-emerald); }

.toast-error {
  border-left: 3px solid var(--accent-red);
  color: var(--accent-red);
}

.toast-error .toast-title { color: var(--accent-red); }

.toast-info {
  border-left: 3px solid var(--accent);
  color: var(--accent);
}

.toast-info .toast-title { color: var(--accent); }

.toast-warning {
  border-left: 3px solid var(--accent-gold);
  color: var(--accent-gold);
}

.toast-warning .toast-title { color: var(--accent-gold); }


/* ──────────────────────────────────────────
   17. SEARCH
   ────────────────────────────────────────── */

.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 120px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-medium);
}

.search-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.search-container {
  width: 100%;
  max-width: 640px;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  transform: translateY(-16px);
  transition: transform var(--transition-medium);
}

.search-overlay.active .search-container {
  transform: translateY(0);
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.search-input-icon {
  font-size: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: var(--text-lg);
  color: var(--text-primary);
  caret-color: var(--accent);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-kbd {
  font-size: var(--text-xs);
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.search-results {
  max-height: 480px;
  overflow-y: auto;
  padding: var(--space-3);
}

.search-results-empty {
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.search-category-label {
  font-size: 10px;
  font-weight: var(--font-bold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
}

.search-result-item:hover,
.search-result-item.focused {
  background: var(--surface-hover);
  text-decoration: none;
}

.search-result-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--surface-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.search-result-title {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

.search-result-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 1px;
}

.search-shortcut {
  font-size: 10px;
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-left: auto;
  flex-shrink: 0;
}

.search-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.search-footer-hint {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}


/* ──────────────────────────────────────────
   18. TABS
   ────────────────────────────────────────── */

.tabs {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tabs-header {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs-header::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  transition: color var(--transition);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-btn:hover {
  color: var(--text-secondary);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  padding: var(--space-6) 0;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.2s ease;
}

.tab-panel.active {
  display: block;
}


/* ──────────────────────────────────────────
   19. REFLECTION JOURNAL
   ────────────────────────────────────────── */

.reflection-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.reflection-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.reflection-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.reflection-date {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.reflection-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.mood-indicator {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.mood-indicator[data-mood="great"]   { background: var(--accent-emerald); box-shadow: 0 0 6px rgba(52, 211, 153, 0.5); }
.mood-indicator[data-mood="good"]    { background: var(--accent-blue); box-shadow: 0 0 6px rgba(96, 165, 250, 0.5); }
.mood-indicator[data-mood="neutral"] { background: var(--text-muted); }
.mood-indicator[data-mood="rough"]   { background: var(--accent-gold); }
.mood-indicator[data-mood="bad"]     { background: var(--accent-red); }

.journal-entry {
  padding: var(--space-5) var(--space-6);
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: var(--leading-loose);
}

.journal-entry.collapsed {
  max-height: 80px;
  overflow: hidden;
  position: relative;
}

.journal-entry.collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--surface));
}

.reflection-expand-btn {
  width: 100%;
  padding: var(--space-3);
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  text-align: center;
}

.reflection-expand-btn:hover {
  background: var(--surface-hover);
  color: var(--accent);
}

/* Journal Compose */
.journal-compose {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}

.journal-compose:focus-within {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-accent);
}

.journal-textarea {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  font-size: var(--text-base);
  color: var(--text-primary);
  line-height: var(--leading-loose);
  resize: none;
  min-height: 120px;
  font-family: var(--font-sans);
}

.journal-textarea::placeholder {
  color: var(--text-muted);
}


/* ──────────────────────────────────────────
   20. SKELETON / LOADING STATES
   ────────────────────────────────────────── */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-overlay) 25%,
    rgba(255, 255, 255, 0.04) 50%,
    var(--surface-overlay) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

.skeleton-text {
  height: 14px;
  width: 100%;
  border-radius: var(--radius-sm);
}

.skeleton-text.w-3-4 { width: 75%; }
.skeleton-text.w-2-3 { width: 66%; }
.skeleton-text.w-half { width: 50%; }
.skeleton-text.w-1-3 { width: 33%; }

.skeleton-title {
  height: 24px;
  width: 60%;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
}

.skeleton-card {
  height: 160px;
  width: 100%;
  border-radius: var(--radius-lg);
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.skeleton-line {
  height: 1px;
  width: 100%;
  background: var(--border);
  margin: var(--space-4) 0;
}

/* Loading spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-lg {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

/* Full page loader */
.page-loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  z-index: 999;
}

.page-loader-logo {
  font-size: 40px;
  animation: pulse 2s infinite;
}

.page-loader-text {
  font-size: var(--text-sm);
  color: var(--text-muted);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
}


/* ──────────────────────────────────────────
   21. TOPIC GRID
   ────────────────────────────────────────── */

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
}

.topic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  cursor: pointer;
  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
  position: relative;
  overflow: hidden;
}

.topic-card:hover {
  border-color: var(--topic-card-color, var(--accent));
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  transform: translateY(-2px);
}

.topic-card-stripe {
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--topic-card-color, var(--accent));
  border-radius: 0;
}

.topic-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: var(--space-3);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.topic-card-name {
  font-size: var(--text-md);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
  text-transform: capitalize;
}

.topic-card-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-4);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Mastery level indicator */
.mastery-level {
  display: flex;
  gap: 3px;
  margin-bottom: var(--space-3);
}

.mastery-pip {
  height: 4px;
  flex: 1;
  background: var(--surface-overlay);
  border-radius: var(--radius-full);
  transition: background var(--transition);
}

.mastery-pip.filled {
  background: var(--topic-card-color, var(--accent));
}

.topic-lessons-count {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-2);
}


/* ──────────────────────────────────────────
   22. LEARNING PATH CARD
   ────────────────────────────────────────── */

.path-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-7);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}

.path-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--path-color-start, var(--accent)), var(--path-color-end, var(--accent-blue)));
}

.path-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.path-icon {
  font-size: 36px;
  margin-bottom: var(--space-4);
}

.path-name {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  line-height: var(--leading-tight);
}

.path-description {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-5);
}

.path-meta {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.path-meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: var(--font-medium);
}

.path-topics {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}


/* ──────────────────────────────────────────
   23. PROGRESS & ANALYTICS
   ────────────────────────────────────────── */

.chart-container {
  position: relative;
  width: 100%;
  min-height: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
}

.chart-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-5);
}

/* Skill radar */
.radar-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}


/* ──────────────────────────────────────────
   24. ACHIEVEMENTS VIEW
   ────────────────────────────────────────── */

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}

.achievement-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  display: flex;
  gap: var(--space-4);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.achievement-card.unlocked {
  border-color: var(--border-strong);
}

.achievement-card.locked {
  opacity: 0.55;
}

.achievement-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-accent);
}

.achievement-info {
  flex: 1;
  min-width: 0;
}

.achievement-name {
  font-size: var(--text-md);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.achievement-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-3);
}

.achievement-unlock-date {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Achievement unlock celebration overlay */
.achievement-unlock-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-toast) + 10);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.achievement-unlock-popup {
  background: var(--surface-raised);
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: var(--radius-2xl);
  padding: var(--space-8) var(--space-10);
  text-align: center;
  box-shadow: 0 0 60px rgba(251, 191, 36, 0.2), var(--shadow-xl);
  animation: bounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
}

.unlock-label {
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  margin-bottom: var(--space-3);
}

.unlock-icon {
  font-size: 56px;
  margin-bottom: var(--space-4);
  animation: spin 1s ease;
}

.unlock-name {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.unlock-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}


/* ──────────────────────────────────────────
   25. FORMS / INPUTS
   ────────────────────────────────────────── */

.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23475569' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-select option {
  background: var(--surface-raised);
  color: var(--text-primary);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: var(--leading-relaxed);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--accent-red);
  margin-top: var(--space-1);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: rgba(248, 113, 113, 0.5);
}


/* ──────────────────────────────────────────
   26. DIVIDER
   ────────────────────────────────────────── */

.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-6) 0;
}

.divider-label {
  position: relative;
  text-align: center;
}

.divider-label::before,
.divider-label::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}

.divider-label::before { left: 0; }
.divider-label::after  { right: 0; }

.divider-label span {
  position: relative;
  background: var(--bg);
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--font-medium);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
}


/* ──────────────────────────────────────────
   27. EMPTY STATES
   ────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-8);
  text-align: center;
}

.empty-state-icon {
  font-size: 56px;
  margin-bottom: var(--space-5);
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.empty-state-desc {
  font-size: var(--text-base);
  color: var(--text-muted);
  max-width: 360px;
  margin: 0 auto var(--space-6);
  line-height: var(--leading-relaxed);
}


/* ──────────────────────────────────────────
   28. TOOLTIP
   ────────────────────────────────────────── */

[data-tooltip] {
  position: relative;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: var(--z-overlay);
  box-shadow: var(--shadow);
}

[data-tooltip]:hover::before {
  opacity: 1;
}


/* ──────────────────────────────────────────
   29. XP GAIN ANIMATION
   ────────────────────────────────────────── */

.xp-gain-popup {
  position: fixed;
  z-index: var(--z-toast);
  pointer-events: none;
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--accent-gold);
  text-shadow: 0 2px 8px rgba(251, 191, 36, 0.4);
  animation: xpFloat 1.5s ease-out forwards;
}

@keyframes xpFloat {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  60%  { opacity: 1; transform: translateY(-40px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-80px) scale(0.9); }
}


/* ──────────────────────────────────────────
   30. RESPONSIVE BREAKPOINTS
   ────────────────────────────────────────── */

/* Tablet: 768 – 1024px */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 220px;
  }

  #page-container {
    padding: var(--space-6) var(--space-6);
  }

  .topic-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }

  .achievements-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

/* Mobile: < 768px */
@media (max-width: 767px) {
  #sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
    box-shadow: var(--shadow-xl);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle-btn {
    display: flex;
  }

  #main-content {
    margin-left: 0;
  }

  #page-container {
    padding: var(--space-5) var(--space-4);
    padding-top: 72px; /* offset for hamburger */
  }

  .page-title {
    font-size: var(--text-3xl);
  }

  .page-header-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .topic-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--space-3);
  }

  .achievements-grid {
    grid-template-columns: 1fr;
  }

  .welcome-banner {
    padding: var(--space-5);
  }

  .quiz-question {
    padding: var(--space-5);
  }

  .quiz-question-text {
    font-size: var(--text-lg);
  }

  .path-card {
    padding: var(--space-5);
  }

  #toast-container {
    left: var(--space-4);
    right: var(--space-4);
    max-width: none;
    top: auto;
    bottom: var(--space-5);
  }

  .modal-overlay {
    padding: var(--space-4);
    align-items: flex-end;
  }

  #modal-container {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    max-height: 85vh;
  }

  .search-overlay {
    padding-top: 60px;
  }

  .stat-card {
    padding: var(--space-4);
  }

  .stat-value {
    font-size: var(--text-2xl);
  }
}

/* Large desktop: > 1400px */
@media (min-width: 1400px) {
  #page-container {
    padding: var(--space-10) var(--space-10);
  }
}
