:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --text: #0f172a;
  --text-muted: #475569;
  --border: #e2e8f0;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
}

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

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  color: #ffffff;
  padding: 16px 24px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: #ffffff;
  color: #1e40af;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 900;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 13px;
  opacity: 0.9;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Container */
.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  border: none;
  transition: all 0.18s ease;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.25);
}
.btn-success:hover {
  background: #15803d;
  transform: translateY(-1px);
}

.btn-outline {
  background: #fff;
  color: var(--text);
  border: 2px solid var(--border);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-ghost-light {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.btn-ghost-light:hover {
  background: rgba(255, 255, 255, 0.26);
}

/* Hero & Generator Banner */
.hero-banner {
  background: linear-gradient(120deg, #eff6ff 0%, #f5f3ff 50%, #fffbeb 100%);
  border: 2px solid #bfdbfe;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 28px;
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 24px;
  align-items: center;
}

@media (max-width: 860px) {
  .hero-banner {
    grid-template-columns: 1fr;
  }
}

.hero-title {
  font-size: 24px;
  font-weight: 800;
  color: #1e3a8a;
  margin-bottom: 8px;
}

.hero-desc {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 16px;
}

.generator-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  border: 2px solid #e0e7ff;
  box-shadow: var(--shadow-sm);
}

.generator-card h3 {
  font-size: 17px;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.gen-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.form-select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 2px solid var(--border);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  background: #f8fafc;
}

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

.section-title {
  font-size: 20px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.level-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.level-tab {
  padding: 8px 16px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.level-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Exam Cards Grid */
.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  margin-bottom: 36px;
}

.exam-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.exam-card:hover {
  border-color: #93c5fd;
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.exam-card.original-highlight {
  border-color: #f59e0b;
  background: linear-gradient(180deg, #fffbeb 0%, #ffffff 45%);
}

.exam-badges {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge-l1 { background: #dcfce7; color: #15803d; }
.badge-l2 { background: #dbeafe; color: #1d4ed8; }
.badge-l3 { background: #fae8ff; color: #86198f; }
.badge-orig { background: #fef3c7; color: #b45309; }

.exam-card h4 {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--text);
}

.exam-card p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.exam-meta {
  display: flex;
  gap: 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.exam-actions {
  display: flex;
  gap: 8px;
}

.exam-actions .btn {
  flex: 1;
  padding: 9px 12px;
  font-size: 14px;
}

/* Topic Practice Grid */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 14px;
}

.topic-card {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.18s;
}
.topic-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.topic-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.topic-card h4 {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 4px;
}

.topic-card p {
  font-size: 13px;
  color: var(--text-muted);
}

/* EXAM TAKING VIEW */
.exam-toolbar {
  background: #ffffff;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 78px;
  z-index: 90;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.timer-pill {
  background: #fef3c7;
  color: #b45309;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.progress-pill {
  background: #eff6ff;
  color: #1d4ed8;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 14px;
}

.view-Switch {
  display: inline-flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
}

.view-switch-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
}
.view-switch-btn.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.exam-layout {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 960px) {
  .exam-layout {
    grid-template-columns: 1fr;
  }
}

/* Question Card (Matches Google Form + Kid-Friendly UI) */
.question-card {
  background: #ffffff;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s;
}

.question-card.answered {
  border-color: #93c5fd;
}

.question-card.review-correct {
  border-color: #22c55e;
  background: #f0fdf4;
}

.question-card.review-wrong {
  border-color: #ef4444;
  background: #fef2f2;
}

.q-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.q-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.q-num-badge {
  background: var(--primary);
  color: #fff;
  padding: 4px 12px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 16px;
}

.q-cat-tag {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

.q-prompt {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  margin-top: 6px;
}

.tts-btn {
  background: #eff6ff;
  color: var(--primary);
  border: 2px solid #bfdbfe;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.tts-btn:hover {
  background: var(--primary);
  color: #fff;
}

.q-visual {
  background: #ffffff;
  border: 1px solid #f1f5f9;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Options List & Visual Options Grid */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.options-list.visual-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 18px;
  font-weight: 700;
}

.visual-options-grid .option-item {
  flex-direction: column;
  justify-content: center;
  padding: 16px;
}

.option-item:hover {
  border-color: #60a5fa;
  background: #f8fafc;
}

.option-item.selected {
  border-color: var(--primary);
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.option-item.correct-answer {
  border-color: #16a34a;
  background: #dcfce7;
}

.option-item.wrong-answer {
  border-color: #dc2626;
  background: #fee2e2;
}

.option-radio {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: #475569;
  flex-shrink: 0;
}

.option-item.selected .option-radio {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.option-item.correct-answer .option-radio {
  border-color: #16a34a;
  background: #16a34a;
  color: #fff;
}

.option-item.wrong-answer .option-radio {
  border-color: #dc2626;
  background: #dc2626;
  color: #fff;
}

/* Explanation Box */
.explanation-box {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  color: #92400e;
  font-size: 15px;
}

.explanation-box strong {
  display: block;
  margin-bottom: 4px;
  color: #78350f;
}

/* Flashcard Navigation */
.flashcard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  gap: 12px;
}

/* Sidebar Question Palette */
.sidebar-card {
  background: #ffffff;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  position: sticky;
  top: 156px;
}

.sidebar-card h4 {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--text);
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.palette-btn {
  height: 38px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #f8fafc;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.12s;
}

.palette-btn:hover {
  border-color: var(--primary);
}

.palette-btn.current {
  outline: 2.5px solid #1e40af;
}

.palette-btn.done {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.palette-btn.rev-ok {
  background: #16a34a;
  color: #fff;
  border-color: #16a34a;
}

.palette-btn.rev-err {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}

/* Results Summary Card */
.result-banner {
  background: #ffffff;
  border: 3px solid #60a5fa;
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}

.result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 2px dashed var(--border);
}

.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3);
}

.score-circle .big-score {
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
}

.score-circle .sub-score {
  font-size: 13px;
  opacity: 0.9;
  margin-top: 4px;
}

.skill-bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.skill-bar-card {
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.skill-bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 6px;
}

.skill-track {
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.skill-fill {
  height: 100%;
  border-radius: 999px;
}

/* PRINT PDF STYLES (A4 Exam Paper) */
.print-only-header,
.print-only-answer-key {
  display: none;
}

@media print {
  body {
    background: #ffffff;
    font-size: 12pt;
  }
  .app-header,
  .exam-toolbar,
  .sidebar-card,
  .flashcard-nav,
  .tts-btn,
  .no-print {
    display: none !important;
  }
  .container {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }
  .exam-layout {
    display: block;
  }
  .print-only-header {
    display: block;
    border: 2px solid #000;
    padding: 14px;
    margin-bottom: 18px;
    border-radius: 8px;
  }
  .question-card {
    page-break-inside: avoid;
    break-inside: avoid;
    border: 1.5px solid #cbd5e1;
    box-shadow: none;
    margin-bottom: 14px;
    padding: 14px;
  }
  .print-only-answer-key {
    display: block;
    page-break-before: always;
    padding-top: 20px;
  }
  .answer-key-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-top: 12px;
  }
  .answer-key-cell {
    border: 1px solid #64748b;
    padding: 6px;
    text-align: center;
    font-weight: 700;
  }
}
