/* =============================================
   PytonLearn - Complete Dark Theme Stylesheet
   ============================================= */

/* ---------- CSS Reset ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; font: inherit; }
input, textarea, select { font: inherit; }
ul, ol { list-style: none; }

/* ---------- CSS Variables ---------- */
:root {
  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #273548;
  --border: #334155;
  --border-light: #475569;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.15);
  --purple: #8b5cf6;
  --purple-bg: rgba(139, 92, 246, 0.15);
  --cyan: #06b6d4;
  --gradient-xp: linear-gradient(90deg, #6366f1, #8b5cf6, #a855f7);
  --gradient-accent: linear-gradient(135deg, #6366f1, #8b5cf6);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.2);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: 0.2s ease;
  --navbar-height: 64px;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ---------- Navbar ---------- */
#navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.nav-logo {
  font-size: 1.6rem;
  animation: snakeWiggle 3s ease-in-out infinite;
}

@keyframes snakeWiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(10deg); }
  75% { transform: rotate(-10deg); }
}

.nav-title {
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-link {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: var(--bg-secondary);
}

.nav-link.active {
  color: var(--accent);
}

.nav-stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-streak {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--warning-bg);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
}

.streak-icon {
  font-size: 1.1rem;
  animation: fireFlicker 1s ease-in-out infinite alternate;
}

@keyframes fireFlicker {
  0% { transform: scale(1) rotate(-3deg); }
  100% { transform: scale(1.15) rotate(3deg); }
}

.nav-xp {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-xp-info {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-level-icon {
  font-size: 1rem;
}

.nav-level-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
}

.nav-xp-bar {
  width: 80px;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
}

.nav-xp-fill {
  height: 100%;
  background: var(--gradient-xp);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.nav-xp-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.nav-badges {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--purple-bg);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
}

.nav-badges:hover {
  background: rgba(139, 92, 246, 0.25);
}

.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
  background: none;
}

.nav-hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all var(--transition);
}

/* ---------- Main Content ---------- */
#app {
  max-width: 1280px;
  margin: 0 auto;
  padding: calc(var(--navbar-height) + 24px) 24px 48px;
  min-height: 100vh;
}

/* ---------- Card Component ---------- */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition);
}

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

.card-clickable {
  cursor: pointer;
}

.card-clickable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.card-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ---------- Day Cards Grid ---------- */
.days-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.day-card {
  position: relative;
  overflow: hidden;
}

.day-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--day-color, var(--accent));
}

.day-card .day-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--day-color, var(--accent));
  color: white;
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
}

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

.day-card .day-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.day-card .day-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.day-card .day-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.day-card .day-progress {
  margin-top: 12px;
}

.day-card .day-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.day-card .day-status-icon {
  font-size: 1.2rem;
}

/* ---------- Progress Bar ---------- */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
  background: var(--accent);
}

.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.gradient { background: var(--gradient-xp); }

/* ---------- XP Bar (Large) ---------- */
.xp-section {
  margin-bottom: 32px;
}

.xp-bar-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.xp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.xp-level {
  display: flex;
  align-items: center;
  gap: 10px;
}

.xp-level-icon {
  font-size: 2rem;
}

.xp-level-info h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.xp-level-info p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.xp-numbers {
  text-align: right;
}

.xp-current {
  font-size: 1.4rem;
  font-weight: 800;
  background: var(--gradient-xp);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.xp-next {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.xp-bar-large {
  width: 100%;
  height: 14px;
  background: var(--bg-tertiary);
  border-radius: 7px;
  overflow: hidden;
  margin-top: 4px;
}

.xp-bar-fill {
  height: 100%;
  background: var(--gradient-xp);
  border-radius: 7px;
  transition: width 0.8s ease;
  position: relative;
}

.xp-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.15), transparent);
  border-radius: 7px 7px 0 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--transition);
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover {
  background: #16a34a;
}

.btn-warning {
  background: var(--warning);
  color: #1a1a1a;
}
.btn-warning:hover {
  background: #d97706;
}

.btn-danger {
  background: var(--error);
  color: white;
}
.btn-danger:hover {
  background: #dc2626;
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  color: var(--text);
  background: var(--bg-tertiary);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

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

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Tab Component ---------- */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  padding: 12px 20px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
}

.tab-btn:hover {
  color: var(--text);
  background: var(--bg-tertiary);
}

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

.tab-btn .tab-check {
  margin-left: 6px;
  font-size: 0.8rem;
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Editor + Output ---------- */
.editor-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.editor-toolbar-title {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.editor-toolbar .btn-group {
  gap: 6px;
}

.CodeMirror {
  height: auto;
  min-height: 120px;
  max-height: 500px;
  font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.6;
}

.CodeMirror-gutters {
  background: #1a1a2e !important;
  border-right: 1px solid var(--border) !important;
}

.output-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 12px;
  overflow: hidden;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.output-body {
  padding: 16px;
  min-height: 60px;
  max-height: 300px;
  overflow-y: auto;
  background: #0d1117;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.output-body.success {
  color: var(--success);
}

.output-body.error {
  color: var(--error);
}

.output-body .output-placeholder {
  color: var(--text-muted);
  font-style: italic;
}

/* ---------- Input Collection UI ---------- */
.input-collection {
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 12px;
  background: rgba(99, 102, 241, 0.05);
}

.input-collection h4 {
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 0.9rem;
}

.input-field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.input-field-group label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.input-field-group input {
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}

.input-field-group input:focus {
  border-color: var(--accent);
}

/* ---------- Quiz Styles ---------- */
.quiz-container {
  max-width: 700px;
}

.quiz-question {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 20px;
  line-height: 1.6;
}

.quiz-code-block {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.95rem;
}

.quiz-option:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
}

.quiz-option.selected {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.15);
}

.quiz-option.correct {
  border-color: var(--success);
  background: var(--success-bg);
}

.quiz-option.wrong {
  border-color: var(--error);
  background: var(--error-bg);
}

.quiz-option-marker {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

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

.quiz-option.correct .quiz-option-marker {
  border-color: var(--success);
  background: var(--success);
  color: white;
}

.quiz-option.wrong .quiz-option-marker {
  border-color: var(--error);
  background: var(--error);
  color: white;
}

.quiz-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition);
  margin-bottom: 16px;
}

.quiz-input:focus {
  border-color: var(--accent);
}

.quiz-input.correct {
  border-color: var(--success);
}

.quiz-input.wrong {
  border-color: var(--error);
}

.quiz-tf-buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.quiz-tf-btn {
  flex: 1;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
  transition: all var(--transition);
}

.quiz-tf-btn:hover {
  border-color: var(--accent);
}

.quiz-tf-btn.selected {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.15);
}

.quiz-tf-btn.correct {
  border-color: var(--success);
  background: var(--success-bg);
}

.quiz-tf-btn.wrong {
  border-color: var(--error);
  background: var(--error-bg);
}

/* Ordering quiz */
.quiz-ordering {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.quiz-order-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: grab;
  transition: all var(--transition);
  user-select: none;
}

.quiz-order-item:active {
  cursor: grabbing;
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
  box-shadow: var(--shadow-md);
}

.quiz-order-item.dragging {
  opacity: 0.5;
  border-color: var(--accent);
}

.quiz-order-item .order-grip {
  color: var(--text-muted);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.quiz-order-item .order-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.quiz-order-item code {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.9rem;
}

.quiz-result {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-top: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.quiz-result.correct {
  background: var(--success-bg);
  border: 1px solid var(--success);
  color: var(--success);
}

.quiz-result.wrong {
  background: var(--error-bg);
  border: 1px solid var(--error);
  color: var(--error);
}

.quiz-result .result-explanation {
  font-weight: 400;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* ---------- Quiz Page (Per-Day) ---------- */
.quiz-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.quiz-progress-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.quiz-progress-bar {
  flex: 1;
  max-width: 300px;
}

/* ---------- Exam Page ---------- */
.exam-timer-bar {
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  right: 0;
  height: 4px;
  background: var(--bg-tertiary);
  z-index: 999;
}

.exam-timer-fill {
  height: 100%;
  background: var(--gradient-xp);
  transition: width 1s linear;
}

.exam-timer-fill.warning {
  background: var(--warning);
}

.exam-timer-fill.danger {
  background: var(--error);
  animation: timerPulse 1s ease-in-out infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.exam-layout {
  display: flex;
  gap: 24px;
}

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

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

.exam-sidebar-sticky {
  position: sticky;
  top: calc(var(--navbar-height) + 20px);
}

.exam-timer-display {
  text-align: center;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.exam-timer-display .timer-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.exam-timer-display .timer-value {
  font-size: 1.8rem;
  font-weight: 800;
  font-family: 'Cascadia Code', 'Consolas', monospace;
  color: var(--text);
}

.exam-timer-display .timer-value.warning {
  color: var(--warning);
}

.exam-timer-display .timer-value.danger {
  color: var(--error);
  animation: timerPulse 1s ease-in-out infinite;
}

.exam-nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.exam-nav-item {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  cursor: pointer;
}

.exam-nav-item:hover {
  border-color: var(--accent);
}

.exam-nav-item.current {
  border-color: var(--warning);
  background: var(--warning);
  color: #1a1a1a;
}

.exam-nav-item.answered {
  border-color: var(--success);
  background: var(--success);
  color: white;
}

/* Exam results */
.exam-results {
  max-width: 700px;
  margin: 0 auto;
}

.exam-score-circle {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 6px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  position: relative;
}

.exam-score-circle.pass {
  border-color: var(--success);
  box-shadow: 0 0 30px rgba(34, 197, 94, 0.3);
}

.exam-score-circle.fail {
  border-color: var(--error);
  box-shadow: 0 0 30px rgba(239, 68, 68, 0.3);
}

.exam-score-value {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
}

.exam-score-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.exam-breakdown {
  margin-top: 24px;
}

.exam-breakdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.exam-breakdown-item:last-child {
  border-bottom: none;
}

.exam-breakdown-label {
  min-width: 140px;
  font-size: 0.9rem;
  font-weight: 600;
}

.exam-breakdown-bar {
  flex: 1;
  height: 10px;
  background: var(--bg-tertiary);
  border-radius: 5px;
  overflow: hidden;
}

.exam-breakdown-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.8s ease;
}

.exam-breakdown-fill.good { background: var(--success); }
.exam-breakdown-fill.ok { background: var(--warning); }
.exam-breakdown-fill.bad { background: var(--error); }

.exam-breakdown-value {
  min-width: 50px;
  text-align: right;
  font-weight: 700;
  font-size: 0.9rem;
}

.weak-topic-alert {
  margin-top: 16px;
  padding: 16px;
  background: var(--error-bg);
  border: 1px solid var(--error);
  border-radius: var(--radius-md);
}

.weak-topic-alert h4 {
  color: var(--error);
  margin-bottom: 8px;
}

.weak-topic-alert ul {
  padding-left: 20px;
}

.weak-topic-alert li {
  list-style: disc;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* ---------- Badge Grid ---------- */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.badge-card {
  text-align: center;
  padding: 24px 16px;
  position: relative;
  transition: all var(--transition);
}

.badge-card.locked {
  opacity: 0.5;
  filter: grayscale(0.8);
}

.badge-card.earned {
  border-color: var(--purple);
}

.badge-card.earned:hover {
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
}

.badge-icon-large {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
}

.badge-card.locked .badge-icon-large {
  filter: grayscale(1);
  opacity: 0.4;
}

.badge-name {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 4px;
}

.badge-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.badge-earned-label {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 10px;
  text-transform: uppercase;
}

.badge-card.earned .badge-earned-label {
  background: var(--purple-bg);
  color: var(--purple);
}

.badge-card.locked .badge-earned-label {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

/* ---------- Example Cards List ---------- */
.example-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.example-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  cursor: pointer;
}

.example-status {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.example-status.completed {
  background: var(--success-bg);
  border: 2px solid var(--success);
}

.example-status.in-progress {
  background: var(--warning-bg);
  border: 2px solid var(--warning);
}

.example-status.not-started {
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
}

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

.example-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.example-category {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.example-arrow {
  color: var(--text-muted);
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ---------- Section Headers ---------- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 800;
}

.section-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ---------- Dashboard Stats Row ---------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  text-align: center;
  padding: 20px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ---------- Notification Toasts ---------- */
#notification-container {
  position: fixed;
  top: calc(var(--navbar-height) + 16px);
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.notification {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 400px;
  animation: slideInRight 0.4s ease;
  pointer-events: auto;
  position: relative;
  overflow: hidden;
}

.notification::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}

.notification.success::before { background: var(--success); }
.notification.warning::before { background: var(--warning); }
.notification.error::before { background: var(--error); }
.notification.info::before { background: var(--accent); }
.notification.xp::before { background: var(--gradient-xp); }
.notification.badge::before { background: var(--purple); }
.notification.levelup::before { background: var(--gradient-xp); }

.notification-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.notification-text {
  flex: 1;
}

.notification-title {
  font-weight: 700;
  font-size: 0.9rem;
}

.notification-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.notification.dismiss {
  animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* Level up notification */
.notification.levelup {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow), var(--shadow-lg);
  animation: slideInRight 0.4s ease, levelUpGlow 1.5s ease-in-out;
}

@keyframes levelUpGlow {
  0% { box-shadow: var(--shadow-lg); }
  50% { box-shadow: 0 0 40px var(--accent-glow), var(--shadow-lg); }
  100% { box-shadow: var(--shadow-lg); }
}

/* Badge notification */
.notification.badge {
  border-color: var(--purple);
}

.notification.badge .notification-icon {
  animation: badgePop 0.5s ease;
}

@keyframes badgePop {
  0% { transform: scale(0); }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--text-secondary);
  transition: color var(--transition);
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb .separator {
  color: var(--text-muted);
}

.breadcrumb .current {
  color: var(--text);
  font-weight: 600;
}

/* ---------- Topic Explanation ---------- */
.topic-content {
  line-height: 1.8;
  font-size: 0.95rem;
}

.topic-content h3 {
  color: var(--accent);
  margin: 20px 0 10px;
  font-size: 1.1rem;
}

.topic-content p {
  margin-bottom: 14px;
  color: var(--text-secondary);
}

.topic-content code {
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.9em;
  color: var(--accent-hover);
}

.topic-content pre {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 12px 0;
  overflow-x: auto;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
}

.topic-content ul, .topic-content ol {
  padding-left: 24px;
  margin-bottom: 14px;
}

.topic-content li {
  list-style: disc;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.topic-content ol li {
  list-style: decimal;
}

.topic-content strong {
  color: var(--text);
}

/* ---------- Code Walkthrough ---------- */
.walkthrough {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.walkthrough-line {
  display: flex;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.walkthrough-line:last-child {
  border-bottom: none;
}

.walkthrough-line:hover,
.walkthrough-line.highlighted {
  background: rgba(99, 102, 241, 0.08);
}

.walkthrough-line.highlighted {
  background: rgba(99, 102, 241, 0.12);
}

.walkthrough-num {
  width: 44px;
  padding: 8px 12px;
  text-align: right;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: 'Cascadia Code', 'Consolas', monospace;
  background: rgba(0,0,0,0.15);
  flex-shrink: 0;
  user-select: none;
}

.walkthrough-code {
  flex: 1;
  padding: 8px 16px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.9rem;
  white-space: pre;
  overflow-x: auto;
  min-width: 0;
}

.walkthrough-desc {
  min-width: 200px;
  max-width: 300px;
  padding: 8px 16px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  align-items: center;
}

/* ---------- Example Navigation ---------- */
.example-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 0;
  gap: 16px;
}

.example-nav .btn {
  min-width: 120px;
}

.example-nav .example-counter {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ---------- Hint Box ---------- */
.hint-box {
  padding: 16px 20px;
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  border-radius: var(--radius-md);
  margin-top: 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.hint-box .hint-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.hint-box .hint-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ---------- Continue Button ---------- */
.continue-section {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 32px 0;
}

.continue-btn {
  padding: 16px 40px;
  font-size: 1.1rem;
  border-radius: var(--radius-lg);
  background: var(--gradient-accent);
  color: white;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.continue-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-glow);
}

/* ---------- Dashboard Badge Showcase ---------- */
.badge-showcase {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.badge-showcase-item {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 2px solid var(--purple);
  border-radius: 50%;
  font-size: 1.5rem;
  transition: all var(--transition);
}

.badge-showcase-item:hover {
  transform: scale(1.1);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.4);
}

.badge-showcase-more {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 2px dashed var(--border);
  border-radius: 50%;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}

.badge-showcase-more:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Page Header with Back Button ---------- */
.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ---------- Loading Spinner ---------- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  flex-direction: column;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ---------- Simulation Output ---------- */
.simulation-output {
  background: #0d1117;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 12px;
}

.simulation-output .sim-label {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 8px;
}

.simulation-output pre {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.9rem;
  color: var(--success);
  white-space: pre-wrap;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  :root {
    --navbar-height: 56px;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 8px;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-hamburger {
    display: flex;
  }

  .nav-stats {
    gap: 8px;
  }

  .nav-xp-bar {
    width: 50px;
  }

  .nav-level-name {
    display: none;
  }

  .nav-xp-text {
    display: none;
  }

  #app {
    padding: calc(var(--navbar-height) + 16px) 16px 32px;
  }

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

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .section-title {
    font-size: 1.3rem;
  }

  .exam-layout {
    flex-direction: column;
  }

  .exam-sidebar {
    width: 100%;
    order: -1;
  }

  .exam-sidebar-sticky {
    position: relative;
    top: 0;
  }

  .exam-nav-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .walkthrough-desc {
    display: none;
  }

  .badge-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .tabs {
    gap: 0;
  }

  .tab-btn {
    padding: 10px 12px;
    font-size: 0.8rem;
  }

  .page-header h1 {
    font-size: 1.4rem;
  }

  .example-nav {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .stats-row {
    grid-template-columns: 1fr;
  }

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

  .quiz-tf-buttons {
    flex-direction: column;
  }

  .exam-nav-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* ---------- Utility Classes ---------- */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.hidden { display: none !important; }
