@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&display=swap');

:root {
  --primary: #00E5FF;
  --primary-dark: #651FFF;
  --primary-light: #FF1744;
  --accent: #76FF03;
  --accent-light: #121212;
  --success: #059669;
  --success-light: #D1FAE5;
  --danger: #DC2626;
  --danger-light: #FEE2E2;
  --warning: #D97706;
  --warning-light: #FEF3C7;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-alt: #F1F5F9;
  --border: #E2E8F0;
  --border-focus: #93C5FD;
  --text: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

::selection {
  background: var(--primary);
  color: white;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px 100px;
}

/* Header */
.app-header {
  padding: 32px 0 24px;
  text-align: center;
}

.header-inner {
  position: relative;
}

.app-title {
  font-family: 'Fraunces', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.title-icon {
  font-size: 1.6rem;
  filter: drop-shadow(0 2px 4px rgba(124, 58, 237, 0.3));
}

.app-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
  font-weight: 400;
}

/* Tab Navigation */
.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 4px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  position: sticky;
  top: 8px;
  z-index: 100;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.tab-icon {
  font-size: 1.1rem;
}

/* Skeleton Loading */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  padding: 8px 0;
}

.skeleton-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 24px;
  border: 1px solid var(--border);
}

.skeleton-bar {
  background: linear-gradient(90deg, var(--surface-alt) 25%, var(--border) 50%, var(--surface-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
  margin-bottom: 12px;
}

.skeleton-title {
  height: 20px;
  width: 70%;
}

.skeleton-text {
  height: 14px;
  width: 100%;
}

.skeleton-text.short {
  width: 50%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

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

.module-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 24px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.4s ease both;
}

.module-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0;
  transition: opacity 0.2s ease;
}

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

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

.module-card.completed {
  border-color: var(--success);
  background: linear-gradient(135deg, var(--surface), var(--success-light));
}

.completed-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--success);
  background: var(--success-light);
  padding: 3px 10px;
  border-radius: 20px;
}

.card-category {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.card-title {
  font-family: 'Fraunces', serif;
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.3;
}

.card-excerpt {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}

.card-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.meta-item {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.card-action-btn {
  border: none;
  background: var(--primary-light);
  color: var(--primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.card-action-btn:hover {
  background: var(--primary);
  color: white;
}

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

/* Filter Row */
.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-secondary);
}

.filter-chip.active,
.filter-chip:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

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

.empty-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.3rem;
  margin-bottom: 8px;
}

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

/* Creator Section */
.creator-section {
  padding: 8px 0;
}

.creator-start {
  max-width: 640px;
  margin: 0 auto;
}

.ai-generator {
  background: linear-gradient(135deg, var(--accent-light), var(--primary-light));
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}

.ai-generator h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.2rem;
  margin-bottom: 6px;
}

.ai-generator p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 16px;
}

.ai-input-row {
  display: flex;
  gap: 10px;
}

.ai-input {
  flex: 1;
}

.divider-text {
  text-align: center;
  margin: 24px 0;
  position: relative;
}

.divider-text::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

.divider-text span {
  background: var(--bg);
  padding: 0 16px;
  position: relative;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Form */
.input-field {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

.input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-field.textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

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

.form-header h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.3rem;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* Questions Section */
.questions-section {
  margin-top: 28px;
}

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

.section-header h4 {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
}

.question-card {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

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

.q-number {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 10px;
  border-radius: 12px;
}

.options-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.option-row.correct {
  border-color: var(--success);
  background: var(--success-light);
}

.option-row input[type="radio"] {
  accent-color: var(--success);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.option-input {
  flex: 1;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 4px 0 !important;
}

.hint-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 8px;
  font-style: italic;
}

/* Compact Module List */
.my-modules {
  margin-top: 32px;
}

.my-modules h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.module-list-compact {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.compact-module-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  transition: all 0.2s ease;
  animation: fadeInUp 0.3s ease both;
}

.compact-module-item:hover {
  border-color: var(--border-focus);
}

.compact-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.compact-cat {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.compact-info strong {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-qs {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.compact-actions {
  display: flex;
  gap: 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-accent {
  background: var(--accent);
  color: white;
}

.btn-accent:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-alt);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary-light);
}

.btn-large {
  padding: 14px 28px;
  font-size: 0.95rem;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.btn-icon:hover {
  background: var(--border);
}

.btn-icon.danger:hover {
  background: var(--danger-light);
}

.btn-icon.small {
  width: 28px;
  height: 28px;
  font-size: 0.8rem;
}

/* Player */
.player-container {
  max-width: 640px;
  margin: 0 auto;
}

.back-btn {
  margin-bottom: 16px;
}

.lesson-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.lesson-header {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  padding: 28px;
  color: white;
}

.lesson-category {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.85;
}

.lesson-title {
  font-family: 'Fraunces', serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 8px;
}

.lesson-body {
  padding: 28px;
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

.lesson-body p {
  margin-bottom: 14px;
}

.lesson-body p:last-child {
  margin-bottom: 0;
}

.lesson-footer {
  padding: 20px 28px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.quiz-preview {
  display: flex;
  gap: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Quiz */
.quiz-progress-bar {
  height: 6px;
  background: var(--surface-alt);
  border-radius: 3px;
  margin-bottom: 12px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px;
  transition: width 0.4s ease;
}

.quiz-status {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.score-live {
  font-weight: 600;
  color: var(--primary);
}

.quiz-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  animation: fadeInUp 0.3s ease both;
}

.quiz-question {
  font-family: 'Fraunces', serif;
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 24px;
  line-height: 1.4;
}

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

.quiz-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-light);
}

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

.quiz-option.wrong {
  border-color: var(--danger);
  background: var(--danger-light);
}

.quiz-option:disabled {
  cursor: default;
}

.option-letter {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

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

.quiz-option.wrong .option-letter {
  background: var(--danger);
  color: white;
}

.option-text {
  flex: 1;
}

.option-icon {
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.feedback-banner {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 20px;
  animation: fadeInUp 0.3s ease both;
}

.feedback-banner.correct {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid var(--success);
}

.feedback-banner.wrong {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger);
}

/* Results */
.results-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.4s ease both;
}

.results-hero {
  padding: 40px;
  text-align: center;
}

.results-hero.passed {
  background: linear-gradient(135deg, var(--success-light), #ecfdf5);
}

.results-hero.failed {
  background: linear-gradient(135deg, var(--warning-light), #fffbeb);
}

.results-badge {
  font-size: 4rem;
  margin-bottom: 12px;
  animation: bounceIn 0.5s ease both;
}

@keyframes bounceIn {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.results-hero h2 {
  font-family: 'Fraunces', serif;
  font-size: 1.5rem;
}

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

.results-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.stat-block {
  text-align: center;
}

.stat-block .stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  font-family: 'Fraunces', serif;
}

.stat-block .stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.results-review {
  padding: 24px;
}

.results-review h4 {
  font-family: 'Fraunces', serif;
  margin-bottom: 12px;
}

.review-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

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

.review-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.review-item.correct .review-icon {
  background: var(--success-light);
  color: var(--success);
}

.review-item.wrong .review-icon {
  background: var(--danger-light);
  color: var(--danger);
}

.review-q {
  color: var(--text-secondary);
  line-height: 1.4;
}

.results-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 20px 24px 28px;
}

/* Dashboard */
.dashboard-section {
  padding: 8px 0;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  transition: all 0.2s ease;
  animation: fadeInUp 0.4s ease both;
}

.stat-card:nth-child(1) { animation-delay: 0s; }
.stat-card:nth-child(2) { animation-delay: 0.06s; }
.stat-card:nth-child(3) { animation-delay: 0.12s; }
.stat-card:nth-child(4) { animation-delay: 0.18s; }

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

.stat-icon {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.stat-number {
  font-family: 'Fraunces', serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}

.stat-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Progress Bar */
.progress-overview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
}

.progress-overview h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.progress-track {
  height: 12px;
  background: var(--surface-alt);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 6px;
  transition: width 0.6s ease;
  min-width: 2px;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Chart */
.chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
}

.chart-section h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  margin-bottom: 16px;
}

.chart-container {
  height: 250px;
  position: relative;
}

/* Badges */
.badges-section {
  margin-bottom: 24px;
}

.badges-section h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  margin-bottom: 14px;
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.badge-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 12px;
  text-align: center;
  transition: all 0.2s ease;
  animation: fadeInUp 0.4s ease both;
}

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

.badge-icon {
  font-size: 2.2rem;
  margin-bottom: 6px;
}

.badge-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.badge-module {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-score {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 4px;
}

/* History */
.history-section {
  margin-bottom: 24px;
}

.history-section h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  margin-bottom: 14px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  animation: fadeInUp 0.3s ease both;
}

.history-badge {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.history-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.history-info strong {
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-cat {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.history-score {
  flex-shrink: 0;
}

.score-pill {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
}

.score-pill.high {
  background: var(--success-light);
  color: var(--success);
}

.score-pill.mid {
  background: var(--primary-light);
  color: var(--primary);
}

.score-pill.low {
  background: var(--warning-light);
  color: var(--warning);
}

.history-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .app-title {
    font-size: 1.6rem;
  }

  .app-header {
    padding: 20px 0 16px;
  }

  .tab-label {
    display: none;
  }

  .tab-btn {
    padding: 10px;
  }

  .tab-icon {
    font-size: 1.3rem;
  }

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

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

  .ai-input-row {
    flex-direction: column;
  }

  .results-stats {
    gap: 16px;
  }

  .stat-block .stat-value {
    font-size: 1.2rem;
  }

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

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

  .compact-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .compact-qs {
    display: none;
  }

  .quiz-card {
    padding: 20px;
  }

  .lesson-header,
  .lesson-body {
    padding: 20px;
  }

  .history-item {
    flex-wrap: wrap;
    gap: 8px;
  }

  .history-date {
    width: 100%;
    text-align: right;
    margin-top: -4px;
  }
}
```

<!-- WALKTHROUGH_SCRIPT:
[
  {"step": 1, "narration": "Welcome to LearnBit! This is your personal learning platform where you create bite-sized modules and track your mastery.", "view": "user", "highlight_selector": ".app-header", "wait_for": "tap_to_continue"},
  {"step": 2, "narration": "The Modules tab shows all your learning modules. It's empty now — let's create your first one!", "view": "user", "highlight_selector": ".tab-btn:nth-child(1)", "wait_for": "tap_to_continue"},
  {"step": 3, "narration": "Switch to the Create tab. You can use AI to generate a module from any topic, or build one manually.", "view": "user", "highlight_selector": ".tab-btn:nth-child(2)", "wait_for": "user_interaction"},
  {"step": 4, "narration": "Try the AI generator! Type a topic like 'Photosynthesis' and click Generate. The AI will create a full lesson with quiz questions.", "view": "user", "highlight_selector": ".ai-generator", "wait_for": "user_interaction"},
  {"step": 5, "narration": "Review the generated content, edit anything you want, and click Publish Module to save it.", "view": "user", "highlight_selector": ".form-actions", "wait_for": "user_interaction"},
  {"step": 6, "narration": "Back on the Modules tab, click your new module to start learning. Read the lesson, then take the quiz.", "view": "user", "highlight_selector": ".module-grid", "wait_for": "user_interaction"},
  {"step": 7, "narration": "Answer each question — you'll get instant feedback. Score 70% or higher to earn a completion badge!", "view": "user", "highlight_selector": ".quiz-card", "wait_for": "user_interaction"},
  {"step": 8, "narration": "Check the Progress tab to see your stats, badges, score chart by category, and completion history. Keep learning to fill your badge collection!", "view": "user", "highlight_selector": ".tab-btn:nth-child(3)", "wait_for": "user_interaction"}
]
-->

/* Auth / identity flow */
.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-card {
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  text-align: center;
}

.auth-hero {
  font-size: 3rem;
  margin-bottom: 12px;
}

.auth-card h2 {
  font-family: 'Fraunces', serif;
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.auth-card p {
  color: var(--text-secondary);
  margin-bottom: 18px;
}

.auth-signin-btn {
  width: 100%;
}

.auth-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 14px;
}

.auth-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

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

.user-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.user-avatar-fallback {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  flex-shrink: 0;
}

.user-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.user-greeting {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.user-submeta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.app-main {
  padding-top: 4px;
}

@media (max-width: 640px) {
  .auth-card {
    padding: 24px 18px;
  }

  .user-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .user-chip {
    border-radius: var(--radius-md);
  }

  .user-greeting {
    max-width: 180px;
  }
}

.rich-editor {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}

.rich-editor-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}

.rich-editor-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
}

.rich-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  padding: 12px;
}

.rich-block-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.rich-block-type {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rich-block-actions {
  display: flex;
  gap: 6px;
}

.rich-input {
  background: var(--surface) !important;
}

.heading-input {
  font-weight: 700;
}

.lesson-preview-card {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
}

.lesson-preview-card h4 {
  font-family: 'Fraunces', serif;
  font-size: 1rem;
  margin-bottom: 10px;
}

.lesson-preview-content {
  color: var(--text-secondary);
  line-height: 1.7;
}

.lesson-preview-content h4 {
  color: var(--text);
  margin: 16px 0 8px;
}

.lesson-preview-content p,
.lesson-preview-content li {
  margin-bottom: 10px;
}

.lesson-preview-content ul {
  padding-left: 20px;
  margin-bottom: 10px;
}

.progress-dashboard .dashboard-tab-switcher {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.progress-dashboard .dashboard-tab-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  border-radius: 999px;
  padding: 0.65rem 1rem;
  cursor: pointer;
}

.progress-dashboard .dashboard-tab-btn.active {
  background: var(--primary-color);
  color: #fff;
}

.progress-dashboard .stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.progress-dashboard .stat-card,
.progress-dashboard .chart-card,
.progress-dashboard .progress-table {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 1rem;
}

.progress-dashboard .stat-label,
.progress-dashboard .chart-card-header p,
.progress-dashboard .table-cell {
  color: rgba(255, 255, 255, 0.72);
}

.progress-dashboard .stat-value {
  display: block;
  font-size: 1.6rem;
  margin-top: 0.4rem;
}

.progress-dashboard .chart-panel,
.progress-dashboard .chart-stack,
.progress-dashboard .chart-grid {
  display: grid;
  gap: 1rem;
}

.progress-dashboard .chart-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.progress-dashboard .chart-card-wide {
  grid-column: 1 / -1;
}

.progress-dashboard canvas {
  width: 100% !important;
  max-height: 280px;
}

.progress-dashboard .table-grid {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
}

.progress-dashboard .table-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.6rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.progress-dashboard .table-title {
  font-weight: 600;
  color: #fff;
}

.progress-dashboard .empty-state.compact {
  padding: 1rem 0;
}

.progress-dashboard .certificate-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
}

.progress-dashboard .certificate-section h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  margin-bottom: 14px;
}

.progress-dashboard .certificate-controls {
  display: flex;
  gap: 12px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.progress-dashboard .certificate-select-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 240px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.progress-dashboard .certificate-preview-wrap {
  display: grid;
  gap: 16px;
}

.progress-dashboard .certificate-preview {
  background: linear-gradient(135deg, #fffdf7, #ffffff);
  border: 1px solid #e7d7a8;
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow-md);
}

.progress-dashboard .certificate-border {
  border: 2px solid #d6b25e;
  border-radius: 16px;
  padding: 20px;
}

.progress-dashboard .certificate-content {
  text-align: center;
  padding: 16px;
}

.progress-dashboard .certificate-kicker {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 700;
  color: #9a6b11;
  margin-bottom: 10px;
}

.progress-dashboard .certificate-badge {
  font-size: 2.6rem;
  margin-bottom: 8px;
}

.progress-dashboard .certificate-content h2 {
  font-family: 'Fraunces', serif;
  font-size: 1.8rem;
  margin-bottom: 10px;
  color: var(--text);
}

.progress-dashboard .certificate-line {
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.progress-dashboard .certificate-content h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.5rem;
  margin-bottom: 10px;
  color: var(--primary-dark);
}

.progress-dashboard .certificate-content h4 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 18px;
}

.progress-dashboard .certificate-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.progress-dashboard .certificate-meta > div {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid #ecdcae;
  border-radius: 12px;
  padding: 10px;
}

.progress-dashboard .certificate-meta-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8a6b2b;
  margin-bottom: 4px;
}

.progress-dashboard .certificate-meta-value {
  display: block;
  font-weight: 700;
  color: var(--text);
  font-size: 0.9rem;
}

.progress-dashboard .certificate-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #ecdcae;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.progress-dashboard .certificate-export-canvas {
  position: absolute;
  inset: auto;
  width: 900px;
  opacity: 0;
  pointer-events: none;
  left: 0;
  top: 0;
}

@media (max-width: 640px) {
  .progress-dashboard .certificate-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .progress-dashboard .certificate-meta {
    grid-template-columns: 1fr;
  }

  .progress-dashboard .certificate-footer {
    justify-content: center;
    text-align: center;
  }
}

.share-controls {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.share-link-btn {
  border: 1px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.share-link-btn:hover {
  background: var(--primary);
  color: white;
}

.share-link-btn.secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text-secondary);
}

.share-link-btn.secondary:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.share-feedback,
.share-locked {
  font-size: 0.78rem;
  color: var(--text-muted);
}
