/* ============================================================
   QUIZ SETUP
   ============================================================ */
.quiz-setup-wrap {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
}

.quiz-setup-container {
  padding-top: 24px;
  padding-bottom: 40px;
}

.quiz-group-wrap {
  max-width: 600px;
  margin: 0 auto;
}

.setup-header {
  text-align: center;
  margin-bottom: 28px;
}

.setup-title {
  font-weight: 700;
  font-size: 23px;
  color: var(--indigo);
  font-family: var(--font-main);
  letter-spacing: -0.02em;
}

.setup-sub {
  color: var(--text-secondary);
  margin-top: 4px;
  font-size: 14px;
}

.setup-row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.anat-mode-toggle {
  background: var(--surface-2);
  padding: 3px;
  border-radius: 99px;
  border: 1px solid var(--border);
  display: inline-flex;
}

.chip-sm {
  padding: 4px 12px !important;
  font-size: 11.5px !important;
  border-radius: 99px !important;
  font-weight: 700 !important;
  border: none !important;
}

.btn-start-quiz {
  padding: 15px 28px !important;
  font-size: 15.5px !important;
  font-weight: 700 !important;
  border-radius: 99px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  box-shadow: 0 8px 20px -4px rgba(37, 99, 235, 0.4) !important;
  white-space: nowrap !important;
}

.setup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px 16px;
  margin-bottom: 18px;
  box-shadow: 0 2px 10px -2px rgba(15, 23, 42, 0.03), 0 1px 3px rgba(15, 23, 42, 0.02);
  transition: all 0.25s ease;
}
.setup-card:last-of-type {
  margin-bottom: 0;
}
[data-theme="dark"] .setup-card {
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.25);
}

.setup-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 768px) {
  .setup-grid {
    grid-template-columns: 1fr 1fr;
  }
  .setup-full { grid-column: span 2; }
}

.setup-section { 
  position: relative; 
  text-align: left; 
}
.setup-section:not(:last-child) {
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}
[data-theme="dark"] .setup-section:not(:last-child) {
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

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

.setup-label { 
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Be Vietnam Pro', sans-serif; 
  font-weight: 700; 
  font-size: 11.5px; 
  letter-spacing: 0.06em; 
  text-transform: uppercase; 
  color: var(--indigo); 
  margin-bottom: 10px; 
}

.setup-label-icon {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--indigo-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--indigo);
  transition: all 0.2s ease;
}

[data-theme="dark"] .setup-label-icon {
  background: rgba(56, 189, 248, 0.14);
  color: #38bdf8;
}

.setup-label-icon svg,
.setup-svg-icon {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.form-select {
  width: 100%; 
  padding: 12px 16px; 
  border: 1.5px solid var(--border); 
  border-radius: 14px;
  background-color: var(--surface); 
  color: var(--text-primary); 
  font-family: 'Inter', sans-serif;
  font-size: 14px; 
  font-weight: 600; 
  outline: none; 
  cursor: pointer; 
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; 
  background-position: right 14px center; 
  padding-right: 40px;
  transition: border-color 0.2s;
}
.form-select:hover, .form-select:focus { border-color: var(--indigo); }

.chips-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-start; }
#learned-chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
}
#learned-chips .chip {
  padding: 8px 6px;
  font-size: 13px;
  width: 100%;
  white-space: nowrap;
  justify-content: center;
}
.chip {
  padding: 8px 16px; border-radius: 100px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text-primary); font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all 0.15s ease; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  user-select: none;
}
.chip:hover {
  border-color: var(--indigo-light);
}
.chip.active { background: var(--indigo-dim); color: var(--indigo); border-color: var(--indigo); }

.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot-basic { background-color: #10b981; }
.dot-mid { background-color: #f59e0b; }
.dot-hard { background-color: #ef4444; }
.dot-unlearned { background-color: #94a3b8; }
.dot-mastered { background-color: #10b981; }
.dot-weak { background-color: #ef4444; }

.chip-icon-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Knowledge Cards */
.knowledge-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
}

.knowledge-card {
  position: relative;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 8px 9px;
  text-align: center;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.knowledge-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px -4px rgba(15, 23, 42, 0.08);
}

.knowledge-card:active {
  transform: scale(0.97);
}

.knowledge-card .kc-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  margin-bottom: 5px;
  transition: all 0.22s ease;
}

.knowledge-card .kc-svg-icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.knowledge-card .kc-label {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-weight: 700;
  font-size: 13px;
  transition: color 0.2s;
  line-height: 1.2;
}

/* ============================================================
   KNOWLEDGE CARD THEMES (Unselected + Active)
   ============================================================ */

/* 1. Theme Tất cả (All - Indigo / Blue) */
.knowledge-card.kc-all {
  border-color: var(--border);
}
.knowledge-card.kc-all .kc-icon {
  background: var(--indigo-dim);
  color: var(--indigo);
}
.knowledge-card.kc-all .kc-label {
  color: var(--indigo);
}
.knowledge-card.kc-all:hover {
  border-color: var(--indigo-light);
}
.knowledge-card.kc-all.active {
  border: 2px solid var(--indigo);
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.14) 0%, rgba(37, 99, 235, 0.04) 100%);
  box-shadow: 0 4px 18px -2px rgba(37, 99, 235, 0.25);
}
.knowledge-card.kc-all.active .kc-icon {
  background: rgba(37, 99, 235, 0.2);
}

/* 2. Theme Giải phẫu (Anatomy - Teal / Emerald) */
.knowledge-card.kc-anat {
  border-color: var(--border);
}
.knowledge-card.kc-anat .kc-icon {
  background: rgba(13, 148, 136, 0.1);
  color: #0d9488;
}
.knowledge-card.kc-anat .kc-label {
  color: #0d9488;
}
.knowledge-card.kc-anat:hover {
  border-color: rgba(13, 148, 136, 0.45);
}
.knowledge-card.kc-anat.active {
  border: 2px solid #0d9488;
  background: linear-gradient(180deg, rgba(13, 148, 136, 0.14) 0%, rgba(13, 148, 136, 0.04) 100%);
  box-shadow: 0 4px 18px -2px rgba(13, 148, 136, 0.25);
}
.knowledge-card.kc-anat.active .kc-icon {
  background: rgba(13, 148, 136, 0.22);
}

/* 3. Theme Sinh lý (Physiology - Rose / Crimson) */
.knowledge-card.kc-phys {
  border-color: var(--border);
}
.knowledge-card.kc-phys .kc-icon {
  background: rgba(225, 29, 72, 0.1);
  color: #e11d48;
}
.knowledge-card.kc-phys .kc-label {
  color: #e11d48;
}
.knowledge-card.kc-phys:hover {
  border-color: rgba(225, 29, 72, 0.45);
}
.knowledge-card.kc-phys.active {
  border: 2px solid #e11d48;
  background: linear-gradient(180deg, rgba(225, 29, 72, 0.14) 0%, rgba(225, 29, 72, 0.04) 100%);
  box-shadow: 0 4px 18px -2px rgba(225, 29, 72, 0.25);
}
.knowledge-card.kc-phys.active .kc-icon {
  background: rgba(225, 29, 72, 0.22);
}

/* Dark Mode Overrides for Knowledge Cards */
[data-theme="dark"] .knowledge-card.kc-all .kc-icon {
  background: rgba(96, 165, 250, 0.14);
  color: #60a5fa;
}
[data-theme="dark"] .knowledge-card.kc-all .kc-label {
  color: #60a5fa;
}
[data-theme="dark"] .knowledge-card.kc-all.active {
  border-color: #3b82f6;
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.2) 0%, rgba(59, 130, 246, 0.06) 100%);
  box-shadow: 0 4px 20px -2px rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] .knowledge-card.kc-anat .kc-icon {
  background: rgba(45, 212, 191, 0.14);
  color: #2dd4bf;
}
[data-theme="dark"] .knowledge-card.kc-anat .kc-label {
  color: #2dd4bf;
}
[data-theme="dark"] .knowledge-card.kc-anat.active {
  border-color: #2dd4bf;
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.2) 0%, rgba(45, 212, 191, 0.06) 100%);
  box-shadow: 0 4px 20px -2px rgba(45, 212, 191, 0.3);
}

[data-theme="dark"] .knowledge-card.kc-phys .kc-icon {
  background: rgba(251, 113, 133, 0.14);
  color: #fb7185;
}
[data-theme="dark"] .knowledge-card.kc-phys .kc-label {
  color: #fb7185;
}
[data-theme="dark"] .knowledge-card.kc-phys.active {
  border-color: #fb7185;
  background: linear-gradient(180deg, rgba(251, 113, 133, 0.2) 0%, rgba(251, 113, 133, 0.06) 100%);
  box-shadow: 0 4px 20px -2px rgba(251, 113, 133, 0.3);
}

/* Segmented Control / Count Buttons */
.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
}
.seg-btn {
  border: 1.5px solid var(--border);
  background: var(--surface);
  padding: 12px 6px;
  border-radius: 12px;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--text-primary);
  transition: all 0.2s ease;
  text-align: center;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}
.seg-btn:hover {
  border-color: var(--indigo-light);
  transform: translateY(-1px);
}
.seg-btn:active {
  transform: scale(0.97);
}
.seg-btn.active {
  border: 2px solid var(--indigo);
  background: var(--indigo-dim);
  color: var(--indigo);
  font-weight: 800;
  box-shadow: 0 4px 14px -2px rgba(37, 99, 235, 0.22);
}

@media (max-width: 480px) {
  .knowledge-cards-grid {
    gap: 6px;
  }
  .knowledge-card {
    padding: 8px 4px 7px;
    border-radius: 12px;
  }
  .knowledge-card .kc-icon {
    width: 32px;
    height: 32px;
    margin-bottom: 4px;
    border-radius: 8px;
  }
  .knowledge-card .kc-svg-icon {
    width: 18px;
    height: 18px;
  }
  .knowledge-card .kc-label {
    font-size: 12px;
  }
  .segmented-control {
    gap: 6px;
  }
  .seg-btn {
    padding: 10px 3px;
    font-size: 12.5px;
    border-radius: 11px;
  }
  #learned-chips {
    gap: 6px;
  }
  #learned-chips .chip {
    padding: 9px 2px;
    font-size: 12px;
    gap: 4px;
  }
  #learned-chips .chip-dot {
    width: 6px;
    height: 6px;
  }
}

/* Pool message and Start CTA */
.pool-msg-wrap {
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 18px;
  padding: 4px 0;
}
.pool-count-highlight {
  font-weight: 800;
  color: var(--indigo);
}

/* Circle indicators for difficulty */
.diff-option { display: flex; align-items: center; gap: 10px; }
.diff-dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-basic { background: var(--teal); }
.dot-inter { background: var(--amber); }
.dot-adv   { background: var(--red); }

/* ============================================================
   QUIZ ACTIVE & QUESTIONS
   ============================================================ */
.quiz-active-wrap { max-width: 900px; margin: 0 auto; padding: 16px 12px 40px; }
.quiz-top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.quiz-btn-nav { padding: 8px 12px !important; font-size: 13px !important; }
.review-nav-btns { display: flex; gap: 6px; }
.timer { font-family: var(--font-mono); font-size: 16px; font-weight: 500; color: var(--text-secondary); text-align: right; }

.quiz-progress-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.quiz-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.quiz-progress-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.quiz-progress-percent {
  font-size: 13px;
  font-weight: 800;
  color: var(--indigo);
}
.quiz-progress-track {
  width: 100%;
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.quiz-progress-bar {
  height: 100%;
  width: 5%;
  background: var(--indigo);
  border-radius: 999px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.question-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 24px 20px; box-shadow: 0 4px 24px rgba(0,0,0,0.05); }
.question-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.question-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.btn-flag { background: none; border: none; font-size: 18px; cursor: pointer; opacity: 0.3; transition: 0.2s; }
.btn-flag:hover { opacity: 0.8; }
.question-text { font-size: 15px; font-weight: 600; line-height: 1.6; color: var(--text-primary); margin-bottom: 20px; }

.option-item {
  display: flex; align-items: flex-start; gap: 14px; padding: 16px 18px;
  border: 2px solid var(--border); border-radius: 14px; cursor: pointer;
  background: var(--surface); margin-bottom: 10px;
  transition: transform 0.1s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.15s, background 0.15s;
  font-size: 14px; font-weight: 500; color: var(--text-primary);
  user-select: none;
}
.option-item:active:not(.locked) {
  transform: scale(0.96);
  background: var(--surface-2);
  opacity: 0.92;
}
.option-item.correct   { border-color: var(--green);  background: var(--green-dim); color: var(--green); }
.option-item.incorrect { border-color: var(--red);    background: var(--red-dim);   color: var(--red); }
.option-item.selected  { border-color: var(--indigo); background: var(--indigo-dim); }
.option-item.locked    { cursor: default; }

.review-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 20px;
}
.review-item-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.review-tag { font-size: 10px; font-weight: 800; text-transform: uppercase; padding: 3px 10px; border-radius: 6px; }
.review-opt { padding: 12px 14px; border-radius: 10px; margin-bottom: 6px; border: 1.5px solid var(--border); font-size: 14px; font-weight: 500; }
.review-opt.correct { border-color: var(--green); background: var(--green-dim); color: var(--green); }
.review-opt.incorrect { border-color: var(--red); background: var(--red-dim); color: var(--red); }

.wrong-answer-card {
  padding: 14px 18px;
  background: var(--red-dim);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  gap: 12px;
  align-items: center;
  transition: all 0.2s;
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
}
.wrong-answer-card:hover { border-color: var(--red); }

.explanation-box { 
  margin-top: 24px; 
  padding: 20px 22px; 
  background: var(--green-dim); 
  border-left: 4px solid var(--green); 
  border-radius: 20px; 
}
.exp-header { font-size: 11px; font-weight: 800; text-transform: uppercase; margin-bottom: 10px; }
.exp-text { font-size: 14.5px; line-height: 1.6; color: var(--text-primary); margin-bottom: 16px; }
.btn-exp-continue { padding: 14px !important; }
.btn-exam-next { margin-top: 20px; padding: 14px !important; }

.pearl-box {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(79, 70, 229, 0.2);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 20px;
}
[data-theme="dark"] .pearl-box {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.25);
}
.pearl-header { font-size: 10px; font-weight: 800; text-transform: uppercase; color: var(--indigo); letter-spacing: 0.05em; margin-bottom: 6px; }
.pearl-content { font-size: 13.5px; line-height: 1.5; color: var(--indigo); font-weight: 500; }

/* ============================================================
   QUIZ RESULT & STATS
   ============================================================ */
.result-wrap {
  text-align: center;
  padding: 40px 20px;
  max-width: 600px;
  margin: 0 auto;
}
.result-emoji { font-size: 72px; margin-bottom: 20px; }
.result-title { font-size: 24px; font-weight: 800; margin-bottom: 8px; font-family: var(--font-main); }
.result-score-line { 
  font-size: 18px; 
  color: var(--text-primary); 
  font-weight: 600; 
  margin-bottom: 28px; 
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}
.result-score-line .score-highlight {
  font-size: 26px;
  font-weight: 900;
  color: var(--indigo);
  line-height: 1;
}

.result-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}
.result-stat-card {
  padding: 16px 12px;
  border-radius: 16px;
  background: var(--surface-2);
  text-align: center;
}
.result-stat-card .rs-val {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
}
.result-stat-card .rs-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
}
.result-stat-card.correct { background: var(--teal-dim); }
.result-stat-card.correct .rs-val, .result-stat-card.correct .rs-label { color: var(--teal); }
.result-stat-card.wrong { background: var(--red-dim); }
.result-stat-card.wrong .rs-val, .result-stat-card.wrong .rs-label { color: var(--red); }

.result-insights-box {
  margin-bottom: 32px;
  background: var(--indigo-dim);
  border: 1px solid rgba(2, 132, 199, 0.15);
  padding: 20px;
  border-radius: 20px;
  text-align: left;
}
.result-insights-header {
  font-size: 13px;
  font-weight: 800;
  color: var(--indigo);
  text-transform: uppercase;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.insights-icon { font-size: 16px; }
.insights-content {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-primary);
  opacity: 0.9;
}

.result-rating-box {
  margin-bottom: 40px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  padding: 24px;
  border-radius: 24px;
  margin-top: 20px;
}
.rating-title { font-weight: 700; margin-bottom: 12px; font-size: 14px; }
.star-rating-stars { display: flex; justify-content: center; gap: 10px; font-size: 28px; cursor: pointer; }
.rating-status-text { font-size: 12px; color: var(--text-secondary); font-weight: 600; margin-top: 8px; }

.result-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 32px;
}
.btn-grid-span-2 { grid-column: span 2; }

.incorrect-section { margin-top: 40px; }

.wrong-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 16px 20px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.wrong-item:hover { border-color: var(--red); transform: translateX(4px); }
.wrong-icon { font-size: 18px; color: var(--red); flex-shrink: 0; }
.wrong-text { font-size: 14px; font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.4; }

/* Review section header */
.review-header {
  margin-top: 40px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-main);
  color: var(--red);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.1em;
}
