/* MIHAN QUIZ - MODERN, NATURAL & ACCESSIBLE DESIGN SYSTEM */
@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');

:root {
  --primary: #1D4ED8;
  --primary-hover: #1E40AF;
  --primary-light: #EFF6FF;
  --primary-border: #BFDBFE;
  
  --emerald: #059669;
  --emerald-hover: #047857;
  --emerald-light: #ECFDF5;
  --emerald-border: #A7F3D0;
  
  --rose: #DC2626;
  --rose-hover: #B91C1C;
  --rose-light: #FEF2F2;
  --rose-border: #FECACA;
  
  --amber: #D97706;
  --amber-hover: #B45309;
  --amber-light: #FFFBEB;
  --amber-border: #FDE68A;

  --bg: #F8FAFC;
  --card-bg: #FFFFFF;
  --card-border: #E2E8F0;
  --border: #E2E8F0;
  --border-focus: #2563EB;
  
  --text: #0F172A;
  --text-muted: #475569;
  --text-light: #64748B;

  --shadow-xs: 0 1px 2px 0 rgb(15 23 42 / 0.04);
  --shadow-sm: 0 1px 3px 0 rgb(15 23 42 / 0.06), 0 1px 2px -1px rgb(15 23 42 / 0.04);
  --shadow-md: 0 4px 6px -1px rgb(15 23 42 / 0.06), 0 2px 4px -2px rgb(15 23 42 / 0.04);
  --shadow-lg: 0 10px 15px -3px rgb(15 23 42 / 0.06), 0 4px 6px -4px rgb(15 23 42 / 0.03);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --font: 'Plus Jakarta Sans', 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

[data-theme="dark"] {
  --bg: #0B0F17;
  --card-bg: #121824;
  --card-border: #1E293B;
  --border: #1E293B;
  --border-focus: #3B82F6;
  
  --text: #F1F5F9;
  --text-muted: #94A3B8;
  --text-light: #64748B;

  --primary: #3B82F6;
  --primary-hover: #60A5FA;
  --primary-light: rgba(59, 130, 246, 0.12);
  --primary-border: rgba(59, 130, 246, 0.3);
  
  --emerald: #10B981;
  --emerald-hover: #059669;
  --emerald-light: rgba(16, 185, 129, 0.12);
  --emerald-border: rgba(16, 185, 129, 0.3);

  --rose: #F43F5E;
  --rose-hover: #E11D48;
  --rose-light: rgba(244, 63, 94, 0.12);
  --rose-border: rgba(244, 63, 94, 0.3);

  --amber: #F59E0B;
  --amber-hover: #D97706;
  --amber-light: rgba(245, 158, 11, 0.12);
  --amber-border: rgba(245, 158, 11, 0.3);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img, svg, video, canvas {
  max-width: 100%;
  height: auto;
}

/* HEADER */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: background-color 0.2s, border-color 0.2s;
  backdrop-filter: blur(8px);
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(29, 78, 216, 0.2);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1.2;
}

.brand-text span {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* BUTTONS */
.btn-svg {
  width: 15px;
  height: 15px;
  stroke-width: 2.1;
  flex-shrink: 0;
  vertical-align: middle;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.01em;
  box-shadow: var(--shadow-xs);
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn-primary {
  background-color: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 2px 6px rgba(29, 78, 216, 0.2);
}

.btn-warning {
  background-color: var(--amber);
  color: #FFFFFF;
  border-color: var(--amber);
}

.btn-warning:hover {
  background-color: var(--amber-hover);
  border-color: var(--amber-hover);
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.2);
}

.btn-emerald {
  background-color: var(--emerald);
  color: #FFFFFF;
  border-color: var(--emerald);
}

.btn-emerald:hover {
  background-color: var(--emerald-hover);
}

.btn-secondary {
  background-color: var(--card-bg);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background-color: var(--bg);
  border-color: var(--text-light);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-muted);
  box-shadow: none;
}

.btn-ghost:hover {
  background-color: var(--border);
  color: var(--text);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

/* MAIN CONTAINER */
.app-container {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 48px;
  flex: 1;
}

/* VIEWS */
.view-section {
  display: none;
  animation: fadeIn 0.2s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* HERO BOX */
.hero-box {
  text-align: center;
  margin-bottom: 28px;
}

.hero-eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background-color: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  margin-bottom: 12px;
}

.hero-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.25;
}

.hero-desc {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto;
}

/* PRELOADED EXAM CARD */
.quick-start-card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.quick-start-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.quick-header {
  margin-bottom: 12px;
}

.quick-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  background-color: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  margin-bottom: 6px;
}

.quick-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.35;
  letter-spacing: -0.015em;
}

.quick-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.quick-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 18px;
}

.meta-chip {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  background-color: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* DROPZONE */
.dropzone {
  background-color: var(--card-bg);
  border: 1.5px dashed var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-xs);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.dropzone-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.dropzone-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.dropzone-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto 14px;
}

.dropzone-formats {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.format-pill {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  background-color: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* PREVIEW VIEW */
.preview-card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}

.preview-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.preview-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
}

.preview-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.preview-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding: 12px;
  background-color: var(--bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.preview-badge {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.preview-badge b {
  color: var(--primary);
}

.preview-item {
  border-top: 1px solid var(--border);
  padding: 16px 0;
}

.preview-item:first-child {
  border-top: none;
}

.preview-item-num {
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.preview-item-stem {
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: var(--text);
}

.preview-item-img {
  max-width: 320px;
  max-height: 200px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  display: block;
}

.preview-item-options {
  font-size: 0.88rem;
  color: var(--text-muted);
  padding-left: 16px;
}

/* INTERACTIVE PREVIEW CLICK-TO-SET ANSWER */
.preview-opt-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
}

.preview-opt-btn:hover {
  border-color: var(--primary);
  background: var(--card-bg);
  transform: translateY(-1px);
}

.preview-opt-btn.is-correct-key {
  border-color: var(--emerald);
  background: var(--emerald-light);
  box-shadow: 0 0 0 1px var(--emerald);
}

.opt-correct-pill {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--emerald-border);
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
}

.opt-set-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.65;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.preview-opt-btn:hover .opt-set-hint {
  opacity: 1;
  color: var(--primary);
  font-weight: 600;
}

.preview-tf-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.9rem;
  transition: background 0.15s;
}

.preview-tf-row:hover {
  background: var(--card-bg);
}

.preview-tf-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.preview-tf-toggle {
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.preview-tf-toggle:hover {
  border-color: var(--border-focus);
  color: var(--text);
}

.preview-tf-toggle.tf-true-active {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.preview-tf-toggle.tf-false-active {
  background: var(--rose);
  border-color: var(--rose);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
}

/* QUIZ VIEW */
.quiz-wrapper {
  max-width: 840px;
  margin: 0 auto;
}

.quiz-info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.info-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: -0.01em;
}

.badge-primary {
  background-color: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  font-variant-numeric: tabular-nums;
}

.badge-outline {
  background-color: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-mode {
  background-color: var(--emerald-light);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
}

.badge-mode.exam {
  background-color: var(--amber-light);
  color: var(--amber);
  border: 1px solid var(--amber-border);
}

.badge-timer {
  background-color: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* PROGRESS BAR */
.progress-container {
  height: 4px;
  background-color: var(--border);
  border-radius: 2px;
  margin-bottom: 20px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}

/* QUIZ CARD */
.quiz-card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.quiz-stem {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 20px;
}

/* MEDIA CONTAINER */
.media-container {
  margin: 16px 0 24px;
  text-align: center;
}

.quiz-image {
  max-width: 100%;
  max-height: 380px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}

.quiz-image:hover {
  transform: scale(1.01);
  box-shadow: var(--shadow-md);
}

.media-hint {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 6px;
  display: block;
}

/* MCQ OPTIONS */
.mcq-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.mcq-btn {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background-color: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  text-align: left;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.98rem;
  color: var(--text);
  transition: border-color 0.12s, background-color 0.12s, box-shadow 0.12s, transform 0.06s;
  position: relative;
  box-shadow: var(--shadow-xs);
  user-select: none;
}

.mcq-btn:hover {
  border-color: var(--text-light);
  background-color: var(--bg);
}

.mcq-btn:active {
  transform: scale(0.995);
}

.mcq-btn.selected {
  border-color: var(--primary);
  background-color: var(--primary-light);
  box-shadow: 0 0 0 1px var(--primary);
  font-weight: 600;
}

.mcq-letter {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background-color: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-top: 1px;
  box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.08);
  transition: all 0.12s ease;
}

.mcq-btn.selected .mcq-letter {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: none;
}

.mcq-text {
  flex: 1;
  line-height: 1.55;
}

.mcq-btn.is-correct {
  border-color: var(--emerald) !important;
  background-color: var(--emerald-light) !important;
  box-shadow: 0 0 0 1px var(--emerald) !important;
}

.mcq-btn.is-correct .mcq-letter {
  background-color: var(--emerald) !important;
  color: white !important;
  border-color: var(--emerald) !important;
  box-shadow: none;
}

.mcq-btn.is-wrong {
  border-color: var(--rose) !important;
  background-color: var(--rose-light) !important;
  box-shadow: 0 0 0 1px var(--rose) !important;
}

.mcq-btn.is-wrong .mcq-letter {
  background-color: var(--rose) !important;
  color: white !important;
  border-color: var(--rose) !important;
  box-shadow: none;
}

.feedback-pill {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  margin-left: auto;
}

.pill-correct {
  background-color: var(--emerald);
  color: white;
}

.pill-wrong {
  background-color: var(--rose);
  color: white;
}

/* TRUE / FALSE (TF) CONTAINER - COMPACT & SPACE EFFICIENT */
.tf-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tf-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.tf-row:hover {
  background-color: var(--card-bg);
  border-color: var(--border-focus);
}

.tf-row.row-correct {
  border-color: rgba(16, 185, 129, 0.4);
  background-color: rgba(16, 185, 129, 0.04);
}

.tf-row.row-wrong {
  border-color: rgba(244, 63, 94, 0.4);
  background-color: rgba(244, 63, 94, 0.04);
}

.tf-stem-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.tf-letter {
  font-weight: 800;
  color: var(--primary);
  font-size: 0.95rem;
  line-height: 1.4;
  flex-shrink: 0;
  text-transform: lowercase;
}

.tf-text-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.tf-text {
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text);
  word-break: break-word;
}

.tf-mini-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  width: fit-content;
  margin-top: 2px;
}

.tf-mini-badge.is-correct {
  background-color: var(--emerald-light);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
}

.tf-mini-badge.is-wrong {
  background-color: var(--rose-light);
  color: var(--rose);
  border: 1px solid var(--rose-border);
}

/* SEGMENTED SWITCH FOR TRUE / FALSE */
.tf-segmented {
  display: inline-flex;
  align-items: center;
  background-color: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
  margin-top: 1px;
}

.tf-btn {
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 44px;
  height: 28px;
  padding: 0 8px;
  border-radius: 5px;
  border: 1px solid transparent;
  background-color: transparent;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tf-btn:hover {
  color: var(--text);
  background-color: rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .tf-btn:hover {
  background-color: rgba(255, 255, 255, 0.06);
}

/* Selected states in Exam / Default */
.tf-btn.selected-true {
  background-color: var(--primary) !important;
  color: white !important;
  border-color: var(--primary) !important;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.tf-btn.selected-false {
  background-color: #475569 !important;
  color: white !important;
  border-color: #475569 !important;
  box-shadow: 0 1px 2px rgba(71, 85, 105, 0.2);
}

/* Practice mode correctness feedback */
.tf-btn.is-correct {
  background-color: var(--emerald) !important;
  color: white !important;
  border-color: var(--emerald) !important;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.3);
}

.tf-btn.is-wrong {
  background-color: var(--rose) !important;
  color: white !important;
  border-color: var(--rose) !important;
  box-shadow: 0 1px 3px rgba(244, 63, 94, 0.3);
}

.tf-btn.should-be {
  border: 1.5px dashed var(--emerald) !important;
  color: var(--emerald) !important;
  background-color: var(--emerald-light) !important;
  font-weight: 800 !important;
}

/* PRACTICE FEEDBACK BAR */
.practice-feedback {
  margin-top: 18px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.practice-feedback.correct {
  background-color: var(--emerald-light);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
}

.practice-feedback.wrong {
  background-color: var(--rose-light);
  color: var(--rose);
  border: 1px solid var(--rose-border);
}

/* QUIZ NAV BAR */
.quiz-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}

/* RESULT VIEW */
.result-card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.score-circle {
  width: 104px;
  height: 104px;
  margin: 0 auto 16px;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xs);
}

.score-number {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.score-max {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.04em;
}

.result-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.result-subtitle {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 22px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  max-width: 600px;
  margin: 0 auto 28px;
}

.stat-item {
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}

.stat-val {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.2;
}

.stat-val.correct { color: var(--emerald); }
.stat-val.wrong { color: var(--rose); }
.stat-val.skipped { color: var(--amber); }

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 4px;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* REVIEW CARDS */
.review-card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.review-card.correct {
  border-left: 5px solid var(--emerald);
}

.review-card.wrong {
  border-left: 5px solid var(--rose);
}

.review-card.partial {
  border-left: 5px solid var(--amber);
}

/* MATRIX DRAWER */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.45);
  z-index: 50;
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.drawer-overlay.open {
  display: block;
  opacity: 1;
}

.drawer-content {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 380px;
  background-color: var(--card-bg);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.drawer-overlay.open .drawer-content {
  transform: translateX(0);
}

.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.matrix-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.matrix-cell {
  height: 42px;
  border-radius: var(--radius-sm);
  background-color: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.matrix-cell:hover {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.matrix-cell.answered {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}

.matrix-cell.current {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.matrix-cell.correct {
  background-color: var(--emerald) !important;
  color: white !important;
  border-color: var(--emerald) !important;
}

.matrix-cell.wrong {
  background-color: var(--rose) !important;
  color: white !important;
  border-color: var(--rose) !important;
}

/* MODAL DIALOGS */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  background-color: var(--card-bg);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background-color: var(--bg);
}

/* LIGHTBOX */
.lightbox-container {
  max-width: 90vw;
  max-height: 90vh;
  position: relative;
}

.lightbox-img {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  background-color: white;
}

.lightbox-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #0F172A;
  color: white;
  border: 2px solid white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* RESPONSIVE DESIGN */

/* RESPONSIVE DESIGN & ZERO OVERFLOW SYSTEM */
@media (max-width: 640px) {
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    position: relative;
  }

  .site-header {
    width: 100%;
    overflow: hidden;
  }

  .header-inner {
    padding: 8px 12px;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
  }

  .brand-group {
    gap: 8px;
    min-width: 0;
    flex-shrink: 1;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
  }

  .brand-icon svg {
    width: 18px;
    height: 18px;
  }

  .brand-text h1 {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand-text span {
    display: none !important;
  }

  .header-actions {
    gap: 4px;
    flex-shrink: 0;
  }

  .header-actions .btn {
    padding: 6px 8px;
    font-size: 0.8rem;
    height: 32px;
  }

  .header-actions .btn .btn-label {
    display: none !important;
  }

  .app-container {
    padding: 14px 10px 48px;
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box;
    overflow-x: hidden !important;
  }

  .hero-box {
    margin-bottom: 18px;
  }

  .hero-eyebrow {
    font-size: 0.7rem;
    padding: 3px 10px;
    max-width: 100%;
    white-space: normal;
  }

  .hero-title {
    font-size: 1.45rem;
    line-height: 1.3;
  }

  .hero-desc {
    font-size: 0.88rem;
  }

  .quick-start-card {
    padding: 16px 14px;
    margin-bottom: 16px;
    border-radius: var(--radius-md);
  }

  .quick-badge {
    font-size: 0.7rem;
    white-space: normal;
    line-height: 1.4;
  }

  .quick-title {
    font-size: 1.15rem;
    line-height: 1.35;
  }

  .quick-desc {
    font-size: 0.88rem;
  }

  .quick-meta {
    gap: 6px;
    margin: 12px 0 16px;
  }

  .meta-chip {
    font-size: 0.75rem;
    padding: 4px 8px;
  }

  .quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .quick-actions .btn {
    width: 100%;
    padding: 12px;
    font-size: 0.9rem;
    white-space: normal;
    text-align: center;
  }

  .dropzone {
    padding: 24px 14px;
  }

  .dropzone-title {
    font-size: 1rem;
  }

  .dropzone-desc {
    font-size: 0.85rem;
  }

  /* PREVIEW MOBILE */
  .preview-card {
    padding: 16px 12px;
    margin-bottom: 16px;
    overflow-x: hidden;
  }

  .preview-top {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .preview-title {
    font-size: 1.25rem;
  }

  .preview-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .preview-actions .btn {
    width: 100%;
    padding: 9px 4px;
    font-size: 0.8rem;
    white-space: normal;
    text-align: center;
    justify-content: center;
  }

  .preview-summary {
    font-size: 0.8rem;
    gap: 6px;
    padding: 8px 10px;
  }

  .preview-image-box img {
    max-width: 100% !important;
    height: auto !important;
  }

  /* QUIZ MOBILE */
  .quiz-wrapper {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .quiz-info-bar {
    gap: 8px;
    margin-bottom: 12px;
  }

  .info-badges {
    gap: 6px;
  }

  .badge {
    font-size: 0.75rem;
    padding: 4px 8px;
  }

  .quiz-card {
    padding: 16px 12px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    width: 100%;
    box-sizing: border-box;
  }

  .quiz-stem {
    font-size: 1rem;
    line-height: 1.55;
    margin-bottom: 16px;
    word-break: break-word;
  }

  .quiz-image {
    max-width: 100%;
    height: auto;
    max-height: 260px;
    object-fit: contain;
  }

  .mcq-btn {
    padding: 10px 12px;
    font-size: 0.9rem;
    gap: 10px;
    word-break: break-word;
  }

  .mcq-letter {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
  }

  /* COMPACT TRUE / FALSE ON MOBILE - HORIZONTAL ROW WITHOUT EXCESS SPACE */
  .tf-container {
    gap: 6px;
  }

  .tf-row {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    padding: 7px 9px;
    gap: 8px;
    box-sizing: border-box;
  }

  .tf-stem-box {
    width: auto;
    flex: 1;
    min-width: 0;
    gap: 6px;
  }

  .tf-letter {
    font-size: 0.9rem;
    line-height: 1.35;
  }

  .tf-text {
    font-size: 0.86rem;
    line-height: 1.4;
  }

  .tf-segmented {
    width: auto;
    display: inline-flex;
    margin-top: 1px;
    flex-shrink: 0;
    padding: 2px;
    gap: 2px;
  }

  .tf-btn {
    min-width: 40px;
    height: 28px;
    font-size: 0.78rem;
    padding: 0 6px;
  }

  .practice-feedback {
    margin-top: 8px;
    padding: 8px 12px;
    font-size: 0.82rem;
  }

  /* QUIZ NAV BAR STICKY & FULL WIDTH WITHOUT OVERFLOW */
  .quiz-nav-bar {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    padding: 10px 8px;
    margin: 16px 0 0;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    gap: 6px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    z-index: 35;
  }

  .quiz-nav-bar .btn {
    flex: 1;
    min-width: 0;
    padding: 10px 4px;
    font-size: 0.85rem;
    white-space: nowrap;
    justify-content: center;
  }

  /* RESULTS VIEW MOBILE */
  .result-card {
    padding: 24px 14px;
  }

  .score-circle {
    width: 100px;
    height: 100px;
  }

  .score-number {
    font-size: 1.8rem;
  }

  .result-title {
    font-size: 1.35rem;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .result-actions {
    flex-direction: column;
    gap: 8px;
  }

  .result-actions .btn {
    width: 100%;
  }

  /* DRAWER MOBILE */
  .drawer-content {
    max-width: 100vw;
    width: 100%;
  }

  .matrix-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }

  .matrix-cell {
    height: 38px;
    font-size: 0.85rem;
  }
}

/* SHUFFLE / RANDOMIZE STYLES */
.badge-shuffled {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  background-color: rgba(99, 102, 241, 0.12);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
  animation: fadeIn 0.2s ease;
}

.shuffle-toggle-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--bg);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.shuffle-toggle-card:hover {
  border-color: var(--primary);
  background-color: var(--card-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.shuffle-toggle-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}


/* --- CLOZE / GAP FILL STYLES --- */
.cloze-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 6px;
}

.cloze-sub-card {
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.cloze-sub-card:hover {
  border-color: var(--border-focus);
}

.cloze-sub-card.card-correct {
  border-color: rgba(16, 185, 129, 0.4);
  background-color: rgba(16, 185, 129, 0.03);
}

.cloze-sub-card.card-wrong {
  border-color: rgba(244, 63, 94, 0.4);
  background-color: rgba(244, 63, 94, 0.03);
}

.cloze-sub-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

.cloze-sub-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--primary);
  background-color: var(--primary-light);
  border: 1px solid var(--primary-border);
  padding: 3px 10px;
  border-radius: 12px;
}

.cloze-mini-feedback {
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cloze-mini-feedback.is-correct {
  color: var(--emerald);
}

.cloze-mini-feedback.is-wrong {
  color: var(--rose);
}

.cloze-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.cloze-opt-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  font-size: 0.88rem;
  font-weight: 500;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  box-sizing: border-box;
}

.cloze-opt-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--primary);
}

.cloze-opt-btn.selected {
  background-color: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
}

.cloze-opt-btn.is-correct {
  background-color: var(--emerald-light) !important;
  border-color: var(--emerald) !important;
  color: var(--emerald) !important;
  font-weight: 700;
}

.cloze-opt-btn.is-wrong {
  background-color: var(--rose-light) !important;
  border-color: var(--rose) !important;
  color: var(--rose) !important;
  font-weight: 700;
}

.cloze-opt-btn.should-be {
  background-color: var(--emerald-light) !important;
  border-color: var(--emerald) !important;
  color: var(--emerald) !important;
  font-weight: 700;
  box-shadow: 0 0 0 1px var(--emerald);
}

.cloze-opt-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 800;
  flex-shrink: 0;
  color: var(--primary);
}


/* ==========================================================================
   SHORT ANSWER & CALCULATION QUESTION STYLES (ĐỊA LÍ 11 & TOÁN/KHTN)
   ========================================================================== */
.short-answer-container {
  margin: 18px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.short-answer-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.short-answer-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.short-answer-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.short-answer-input {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  padding: 12px 16px;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-md, 8px);
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
}

.short-answer-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.short-answer-unit {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  background: var(--bg-muted, #f1f5f9);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: var(--radius-md, 8px);
  border: 1px solid var(--border);
}

.short-answer-submit-btn {
  padding: 10px 20px;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--radius-md, 8px);
}

.short-answer-hint {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Data Table Formatting inside Questions (Stem & Solutions) */
.quiz-table-wrapper {
  overflow-x: auto;
  margin: 14px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.quiz-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  text-align: center;
}

.quiz-data-table th {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  padding: 10px 14px;
  border-bottom: 2px solid var(--primary-border);
}

.quiz-data-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.quiz-data-table tr:last-child td {
  border-bottom: none;
}

.quiz-data-table tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.015);
}

.stem-paragraph {
  margin-bottom: 8px;
  line-height: 1.6;
}

.source-caption {
  font-size: 0.84rem;
  color: var(--text-muted);
  display: block;
  margin-top: 4px;
}
