/* IGCSE Bio Challenge - Styles */
:root {
  --bg: #f5f7ff;
  --surface: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --basic: #10b981;
  --basic-dark: #059669;
  --advanced: #8b5cf6;
  --advanced-dark: #7c3aed;
  --vocab: #0ea5e9;
  --vocab-dark: #0369a1;
  --shadow: 0 10px 30px -8px rgba(0,0,0,0.12);
  --radius: 18px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding-bottom: 80px;
  min-height: 100vh;
  position: relative;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 2rem;
}

.logo-text h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary), var(--advanced));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text small {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.header-stats {
  display: flex;
  gap: 10px;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.main {
  padding: 24px 20px;
}

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 640px) {
  .card-grid.two-col {
    grid-template-columns: 1fr 1fr;
  }
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform var(--transition), box-shadow var(--transition);
}

.card-hover {
  cursor: pointer;
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px -10px rgba(0,0,0,0.15);
}

.card-gradient-basic {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border-color: #a7f3d0;
}

.card-gradient-advanced {
  background: linear-gradient(135deg, #f3e8ff 0%, #e9d5ff 100%);
  border-color: #d8b4fe;
}

.card-gradient-vocab {
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
  border-color: #7dd3fc;
}

.card-gradient-mock {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border-color: #fed7aa;
}

.card-gradient-practice {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-color: #bfdbfe;
}

.card-gradient-review {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border-color: #fecaca;
}

.card-gradient-fav {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #fde68a;
}

.card-gradient-create {
  background: linear-gradient(135deg, #ecfeff 0%, #cffafe 100%);
  border-color: #a5f3fc;
}

.card-icon {
  font-size: 2.25rem;
  margin-bottom: 12px;
}

.card h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: 800;
}

.card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}

.btn-basic {
  background: linear-gradient(135deg, var(--basic), var(--basic-dark));
  color: white;
}

.btn-advanced {
  background: linear-gradient(135deg, var(--advanced), var(--advanced-dark));
  color: white;
}

.btn-vocab {
  background: linear-gradient(135deg, var(--vocab), var(--vocab-dark));
  color: white;
}

.btn-outline {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn-outline:hover {
  background: #f9fafb;
}

.btn-danger {
  background: linear-gradient(135deg, #f87171, var(--danger));
  color: white;
}

.btn-success {
  background: linear-gradient(135deg, #34d399, var(--success));
  color: white;
}

.btn-block {
  width: 100%;
}

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

/* Typography */
.title {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 8px;
}

.subtitle {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 0.95rem;
}

/* Views */
.view {
  animation: fadeIn 0.35s ease;
}

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

.hidden {
  display: none !important;
}

/* Home view */
.hero {
  text-align: center;
  margin-bottom: 28px;
}

.hero h2 {
  font-size: 1.75rem;
  font-weight: 800;
  margin: 0 0 8px;
}

.hero p {
  color: var(--text-muted);
  margin: 0;
}

.theme-select {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 640px) {
  .theme-select {
    grid-template-columns: 1fr 1fr;
  }
}

.theme-card {
  padding: 28px;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}

.theme-card:hover {
  transform: translateY(-5px) scale(1.01);
}

.theme-card .badge {
  margin-top: 4px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: white;
}

.theme-card h3 {
  margin: 0;
  font-size: 1.4rem;
}

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

/* Dashboard */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.back-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
}

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

/* Practice / Question */
.question-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.question-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 8px;
}

.question-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--text-muted);
}

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

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--transition);
}

.icon-btn:hover {
  transform: scale(1.1);
  background: #f9fafb;
}

.icon-btn.active {
  background: #fee2e2;
  border-color: #fecaca;
}

.question-stem {
  font-size: 1.15rem;
  line-height: 1.55;
  margin-bottom: 18px;
  font-weight: 500;
}

.question-image {
  max-width: 100%;
  border-radius: 12px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  background: white;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: white;
  cursor: pointer;
  text-align: left;
  font-size: 1rem;
  transition: all 0.15s ease;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: #f5f7ff;
}

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

.option-letter {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f3f4f6;
  color: var(--text);
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.option-btn.selected .option-letter,
.option-btn.correct .option-letter,
.option-btn.wrong .option-letter {
  color: white;
}

.option-btn.selected {
  border-color: var(--primary);
  background: #eef2ff;
}

.option-btn.selected .option-letter {
  background: var(--primary);
}

.option-btn.correct {
  border-color: var(--success);
  background: #ecfdf5;
}

.option-btn.correct .option-letter {
  background: var(--success);
}

.option-btn.wrong {
  border-color: var(--danger);
  background: #fef2f2;
}

.option-btn.wrong .option-letter {
  background: var(--danger);
}

.option-text {
  line-height: 1.45;
  padding-top: 4px;
}

.explanation {
  margin-top: 18px;
  padding: 16px;
  border-radius: 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #065f46;
}

.explanation h4 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.explanation p {
  margin: 0;
  font-size: 0.95rem;
}

/* Practice layout helpers */
.form-row {
  display: flex;
  gap: 14px;
}
.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.explanation.wrong-exp {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}
.explanation.mock-saved {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #3730a3;
}

/* Mock mode: chosen option marked without revealing correctness */
.option-btn.mock-picked {
  border-color: #cbd5e1;
  background: #f8fafc;
}
.option-btn.mock-picked .option-letter {
  background: #94a3b8;
  color: #fff;
}

/* End-of-session review */
.review-section {
  margin-top: 18px;
}
.section-title {
  font-size: 1.15rem;
  margin-bottom: 4px;
}
.review-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
}
.review-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: #fff;
}
.review-item.is-correct {
  border-left: 4px solid var(--success);
}
.review-item.is-wrong {
  border-left: 4px solid var(--danger);
}
.review-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.review-num {
  font-weight: 800;
}
.review-verdict {
  margin-left: auto;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 3px 10px;
  border-radius: 999px;
}
.review-verdict.ok {
  background: #ecfdf5;
  color: #047857;
}
.review-verdict.bad {
  background: #fef2f2;
  color: #b91c1c;
}
.review-stem {
  font-weight: 600;
  margin-bottom: 10px;
  line-height: 1.45;
}
.review-image {
  max-width: 100%;
  border-radius: 10px;
  margin: 6px 0 10px;
  border: 1px solid var(--border);
}
.review-answers {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 0.92rem;
}
.review-ans.correct-ans {
  color: #047857;
}
.review-exp {
  font-size: 0.92rem;
  color: #374151;
  background: #f9fafb;
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.5;
}

/* Controls */
.practice-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.progress-bar {
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}

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

.timer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.1rem;
  padding: 8px 14px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.timer.warning {
  color: var(--danger);
  border-color: #fecaca;
  background: #fef2f2;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Result */
.result-card {
  text-align: center;
  padding: 36px 24px;
}

.result-score {
  font-size: 3.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--advanced));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

.result-label {
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 20px;
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin: 24px 0;
}

.result-stat {
  background: #f9fafb;
  border-radius: 12px;
  padding: 14px;
}

.result-stat .value {
  font-size: 1.4rem;
  font-weight: 800;
  display: block;
}

.result-stat .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Forms */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.form-group select,
.form-group input[type="number"],
.form-group input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  background: white;
  transition: border-color var(--transition);
}

.form-group select:focus,
.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.filter-tag {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: white;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}

.filter-tag:hover {
  border-color: var(--primary);
}

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

/* Stats/profile */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.stat-card .value {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--primary);
}

.stat-card .label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

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

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: white;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.history-item .mode {
  font-weight: 700;
  font-size: 0.9rem;
}

.history-item .score {
  font-weight: 800;
  color: var(--primary);
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 900px;
  margin: 0 auto;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 10px 0;
  z-index: 40;
}

.nav-btn {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: color var(--transition);
}

.nav-btn:hover,
.nav-btn.active {
  color: var(--primary);
}

.nav-icon {
  font-size: 1.4rem;
}

/* Utility */
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }

/* ---------- Vocabulary modules ---------- */
.q-counter {
  text-align: center;
  color: var(--text-muted);
  font-weight: 700;
  margin: 4px 0 10px;
  font-size: 0.95rem;
}
.v-word {
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 6px 0 2px;
}
.v-ipa {
  text-align: center;
  color: var(--vocab-dark);
  font-style: italic;
  margin-bottom: 12px;
}
.v-hint {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.v-dict-input { text-align: center; }
.v-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  outline: none;
}
.v-input:focus { border-color: var(--vocab); }
.v-select {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  background: white;
  outline: none;
}
.v-select:focus { border-color: var(--vocab); }
.v-cloze-text {
  font-size: 1.1rem;
  line-height: 1.7;
  margin-bottom: 14px;
}
.blank-slot {
  display: inline-block;
  min-width: 90px;
  padding: 2px 8px;
  margin: 0 4px;
  border-bottom: 2px dashed var(--vocab);
  color: var(--vocab-dark);
  font-weight: 700;
  text-align: center;
}
.review-list {
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
}
.rev-item {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fafafa;
}
.rev-item.rev-ok { border-left-color: var(--success); }
.rev-item.rev-bad { border-left-color: var(--danger); }
.rev-word { font-weight: 800; font-size: 1.05rem; }
.rev-ipa { color: var(--vocab-dark); font-style: italic; font-weight: 500; }
.rev-line { font-size: 0.92rem; margin-top: 2px; }
.rev-zh { font-size: 0.88rem; color: var(--text-muted); margin-top: 2px; }
.mb-2 { margin-bottom: 16px; }
.w-100 { width: 100%; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .emoji {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
}

.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.loading::after {
  content: "";
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 10px;
  vertical-align: middle;
}

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

/* Confetti-ish badge */
.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: white;
  font-weight: 800;
  font-size: 0.85rem;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);
}

/* Review list */
.review-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.review-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: white;
  border-radius: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}

.review-item:hover {
  border-color: var(--primary);
  background: #f5f7ff;
}

.review-item .q-title {
  font-weight: 700;
  font-size: 0.95rem;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

/* ---------- Cloud sync status chip ---------- */
.cloud-chip {
  cursor: default;
  user-select: none;
  opacity: 0.85;
}
.cloud-chip.cloud-online {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  opacity: 1;
}

/* ---------- Modal (student setup) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}
.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow);
  animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-card h2 {
  margin: 0 0 6px;
}
.text-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}
.text-input:focus {
  border-color: var(--primary);
}
@keyframes popIn {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

