/* =====================================================================
 * GIAO DIỆN ĐỀ CƯƠNG ÔN TẬP TIỂU HỌC
 * Phong cách tươi sáng, chữ to rõ, thân thiện trên máy tính & iPad/điện thoại
 * ===================================================================== */

:root {
  --bg-page: #f2f8ff;
  --bg-card: #ffffff;
  --bg-soft: #f8fafc;
  --text-main: #1e293b;
  --text-muted: #475569;
  --text-light: #64748b;

  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-border: #bfdbfe;

  --accent: #f59e0b;
  --accent-soft: #fffbeb;
  --accent-border: #fde68a;

  --success: #15803d;
  --success-bg: #dcfce7;
  --success-border: #86efac;

  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --danger-border: #fca5a5;

  --ref-color: #92400e;
  --ref-bg: #fffbeb;
  --ref-border: #fcd34d;

  --border: #e2e8f0;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 8px 24px rgba(30, 58, 138, 0.07);
  --shadow-soft: 0 2px 10px rgba(15, 23, 42, 0.05);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-main);
  background:
    radial-gradient(circle at 10% 0%, #dbeafe 0%, transparent 32%),
    radial-gradient(circle at 92% 8%, #fef3c7 0%, transparent 28%),
    var(--bg-page);
  min-height: 100vh;
  padding-bottom: 56px;
}

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 18px;
}

.hidden {
  display: none !important;
}

/* ---------------------------------------------------------------------
 * Buttons
 * --------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 11px 22px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
  text-decoration: none;
  min-height: 44px;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #eff6ff;
  color: var(--primary-dark);
  border-color: var(--primary-border);
}

.btn-secondary:hover {
  background: #dbeafe;
}

.btn-outline {
  background: #ffffff;
  color: var(--text-main);
  border-color: #cbd5e1;
}

.btn-outline:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn-print {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.btn-print:hover {
  background: #fde68a;
}

.btn-sm {
  padding: 8px 18px;
  font-size: 15px;
  min-height: 40px;
}

.btn-lg {
  padding: 14px 30px;
  font-size: 18px;
  min-height: 52px;
}

/* ---------------------------------------------------------------------
 * Sticky Top Bar
 * --------------------------------------------------------------------- */
.sticky-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.05);
}

.sticky-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 10px;
  padding-bottom: 10px;
  flex-wrap: wrap;
}

.section-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.section-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 14px;
  text-decoration: none;
  border: 1.5px solid var(--primary-border);
  transition: background 0.15s ease, transform 0.15s ease;
}

.section-pill:hover {
  background: #dbeafe;
  transform: translateY(-1px);
}

.progress-wrap {
  flex: 1;
  min-width: 180px;
  max-width: 340px;
}

.progress-text {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
}

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

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6 0%, #10b981 100%);
  transition: width 0.3s ease;
}

/* ---------------------------------------------------------------------
 * Subject Switcher (Đa môn học)
 * --------------------------------------------------------------------- */
.subject-switcher {
  margin-top: 18px;
}

.subject-switcher-bar {
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #dbeafe;
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.subject-switcher-label {
  font-size: 15px;
  font-weight: 900;
  color: var(--text-muted);
  white-space: nowrap;
}

.subject-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
}

.subject-tab {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 15px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: #ffffff;
  color: var(--text-main);
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.subject-tab:hover {
  border-color: #93c5fd;
  background: #f8fbff;
  transform: translateY(-1px);
}

.subject-tab.is-active {
  background: var(--primary-soft);
  border-color: var(--subject-accent, var(--primary));
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.subject-tab-icon {
  font-size: 20px;
  line-height: 1;
}

.subject-tab-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.subject-tab-name {
  font-size: 15.5px;
  font-weight: 900;
  color: #0f172a;
}

.subject-tab-meta {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
}

.subject-tab-status {
  font-size: 12px;
  font-weight: 900;
  padding: 3px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--text-muted);
}

.subject-tab-status.is-done {
  background: var(--success-bg);
  color: var(--success);
}

/* ---------------------------------------------------------------------
 * Hero Header
 * --------------------------------------------------------------------- */
.hero {
  margin-top: 16px;
  margin-bottom: 24px;
}

.hero-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 28px 30px;
  border: 2px solid #dbeafe;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  background: linear-gradient(90deg, #3b82f6 0%, #10b981 50%, #f59e0b 100%);
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.hero-badge {
  display: inline-block;
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 800;
  font-size: 14px;
  padding: 5px 14px;
  border-radius: 999px;
}

.autosave-pill {
  font-size: 13px;
  font-weight: 700;
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  padding: 4px 12px;
  border-radius: 999px;
}

.hero-title {
  margin: 4px 0 6px;
  font-size: clamp(26px, 4vw, 36px);
  font-weight: 900;
  color: #0f172a;
  line-height: 1.2;
}

.hero-subtitle {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-dark);
}

.hero-instructions {
  background: #f0f9ff;
  border-left: 5px solid #38bdf8;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  color: #0c4a6e;
  font-weight: 600;
  margin-bottom: 18px;
}

.student-info {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.student-field {
  flex: 1 1 260px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
}

.student-field-small {
  flex: 0 1 180px;
}

.student-field span {
  font-weight: 800;
  font-size: 15px;
  color: var(--text-muted);
  white-space: nowrap;
}

.student-field input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  outline: none;
}

/* ---------------------------------------------------------------------
 * Result Banner (Post-Submit)
 * --------------------------------------------------------------------- */
.result-banner {
  margin-bottom: 26px;
}

.result-card {
  background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
  border: 2.5px solid #86efac;
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.result-stars {
  font-size: 28px;
  letter-spacing: 3px;
  margin-bottom: 4px;
}

.result-headline {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 900;
  color: #14532d;
}

.result-message {
  margin: 0 0 14px;
  color: #166534;
  font-weight: 700;
}

.result-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 15px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 15px;
  background: #ffffff;
  border: 1.5px solid #bbf7d0;
  color: #15803d;
}

.stat-chip.stat-essay {
  border-color: #fde68a;
  color: #92400e;
  background: #fffbeb;
}

.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------------
 * Sections (Phần I, Phần II)
 * --------------------------------------------------------------------- */
.quiz-section {
  margin-bottom: 34px;
  scroll-margin-top: 84px;
}

.section-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.2);
}

.section-header.section-essay {
  background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  box-shadow: 0 6px 18px rgba(217, 119, 6, 0.22);
}

.section-badge {
  background: rgba(255, 255, 255, 0.22);
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 15px;
  white-space: nowrap;
}

.section-title {
  margin: 0 0 2px;
  font-size: 22px;
  font-weight: 900;
}

.section-desc {
  margin: 0;
  font-size: 15px;
  opacity: 0.94;
}

/* ---------------------------------------------------------------------
 * Question Card + Side-by-Side Layout After Submit
 * --------------------------------------------------------------------- */
.question-list {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.question-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 2px solid var(--border);
  box-shadow: var(--shadow-card);
  padding: 22px 24px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.question-card.status-correct {
  border-color: var(--success-border);
}

.question-card.status-partial {
  border-color: #fdba74;
}

.question-card.status-wrong {
  border-color: var(--danger-border);
}

.question-card.status-reference {
  border-color: var(--ref-border);
}

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

.question-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.question-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #ffffff;
  font-weight: 900;
  font-size: 15px;
  padding: 5px 14px;
  border-radius: 999px;
}

.question-card[data-type="essay"] .question-number {
  background: #d97706;
}

.question-type-tag {
  background: #f1f5f9;
  color: var(--text-muted);
  font-weight: 800;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
}

.question-status-badge {
  display: none;
  align-items: center;
  gap: 6px;
  font-weight: 900;
  font-size: 14px;
  padding: 5px 14px;
  border-radius: 999px;
}

.question-card.is-submitted .question-status-badge {
  display: inline-flex;
}

.badge-correct {
  background: var(--success-bg);
  color: var(--success);
  border: 1.5px solid var(--success-border);
}

.badge-wrong {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1.5px solid var(--danger-border);
}

.badge-partial {
  background: #ffedd5;
  color: #c2410c;
  border: 1.5px solid #fdba74;
}

.badge-reference {
  background: var(--ref-bg);
  color: var(--ref-color);
  border: 1.5px solid var(--ref-border);
}

.question-prompt {
  margin: 0 0 16px;
  font-size: 19px;
  font-weight: 800;
  color: #0f172a;
}

/* Bố cục 1 cột trước khi nộp -> 2 cột bên cạnh nhau sau khi nộp */
.question-layout {
  display: block;
}

.question-card.is-submitted:not([data-type="essay"]) .question-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(290px, 0.95fr);
  gap: 22px;
  align-items: start;
}

.column-heading {
  display: none;
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 0 0 10px;
}

.question-card.is-submitted .student-column > .column-heading {
  display: block;
  color: var(--text-muted);
}

/* Cột đáp án bên cạnh */
.answer-column {
  display: none;
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  background: #f8fafc;
  border: 2px solid #cbd5e1;
}

.question-card.is-submitted .answer-column {
  display: block;
}

.question-card.status-correct .answer-column {
  background: #f0fdf4;
  border-color: var(--success-border);
}

.question-card.status-wrong .answer-column {
  background: #fef2f2;
  border-color: var(--danger-border);
}

.question-card.status-partial .answer-column {
  background: #fff7ed;
  border-color: #fdba74;
}

.answer-panel-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 8px;
}

.answer-key-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.answer-key-item {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.answer-key-item.item-ok {
  border-color: var(--success-border);
}

.answer-key-item.item-bad {
  border-color: var(--danger-border);
}

.mini-pill {
  font-size: 12px;
  font-weight: 900;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.mini-pill.ok {
  background: var(--success-bg);
  color: var(--success);
}

.mini-pill.bad {
  background: var(--danger-bg);
  color: var(--danger);
}

.answer-explanation {
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.85);
  border-left: 4px solid #3b82f6;
  font-size: 15px;
  color: #334155;
}

/* ---------------------------------------------------------------------
 * Media / Image Box
 * --------------------------------------------------------------------- */
.question-media {
  margin-bottom: 16px;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  text-align: center;
}

.question-media img {
  max-width: 100%;
  max-height: 310px;
  height: auto;
  border-radius: 12px;
  display: block;
  margin: 0 auto;
}

.question-media figcaption {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-light);
}

.context-box {
  margin-bottom: 16px;
  padding: 15px 18px;
  border-radius: var(--radius-md);
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  color: #78350f;
  font-weight: 700;
}

/* ---------------------------------------------------------------------
 * Type 1 & 2: Multiple Choice / Image Choice
 * --------------------------------------------------------------------- */
.mc-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.mc-options.mc-options-visual {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.question-card.is-submitted .mc-options.mc-options-visual {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mc-options-visual .mc-option {
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px;
  gap: 8px;
}

.mc-opt-img {
  width: 100%;
  max-width: 132px;
  height: auto;
  border-radius: 10px;
  display: block;
}

.question-subprompt {
  margin: 0 0 12px;
  font-size: 17.5px;
  font-weight: 800;
  color: #0f172a;
}

.mc-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: #ffffff;
  cursor: pointer;
  transition: all 0.14s ease;
  user-select: none;
  min-height: 54px;
}

.mc-option:hover:not(.is-locked) {
  border-color: #93c5fd;
  background: #f8fbff;
}

.mc-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mc-letter {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #eff6ff;
  color: var(--primary-dark);
  border: 2px solid var(--primary-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 16px;
  flex-shrink: 0;
}

.mc-text {
  font-weight: 700;
  font-size: 17px;
  flex: 1;
}

.mc-option.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.mc-option.is-selected .mc-letter {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.mc-option.is-correct-choice {
  border-color: var(--success);
  background: var(--success-bg);
}

.mc-option.is-correct-choice .mc-letter {
  background: var(--success);
  color: #ffffff;
  border-color: var(--success);
}

.mc-option.is-wrong-choice {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.mc-option.is-wrong-choice .mc-letter {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}

.mc-option.is-locked {
  cursor: default;
}

/* ---------------------------------------------------------------------
 * Type: Multi-Select (Đánh dấu X vào ô vuông ☐)
 * --------------------------------------------------------------------- */
.ms-box {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 2.5px solid #94a3b8;
  background: #ffffff;
  color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 19px;
  line-height: 1;
  flex-shrink: 0;
  transition: all 0.14s ease;
}

.mc-option.is-selected .ms-box {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.mc-option.is-correct-choice .ms-box {
  background: var(--success);
  border-color: var(--success);
  color: #ffffff;
}

.mc-option.is-wrong-choice .ms-box {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.mc-option.is-missed-choice {
  border-color: var(--success);
  border-style: dashed;
  background: #f0fdf4;
}

/* ---------------------------------------------------------------------
 * Type 3: Image Fill
 * --------------------------------------------------------------------- */
.fill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.fill-item {
  background: #f8fafc;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fill-item.is-ok {
  border-color: var(--success);
  background: #f0fdf4;
}

.fill-item.is-bad {
  border-color: var(--danger);
  background: #fef2f2;
}

.fill-label {
  font-size: 15px;
  font-weight: 900;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fill-input {
  width: 100%;
  padding: 10px 13px;
  border-radius: 10px;
  border: 2px solid #cbd5e1;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  background: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.fill-input:disabled {
  background: rgba(255, 255, 255, 0.8);
  color: var(--text-main);
}

/* ---------------------------------------------------------------------
 * Type 4: Word Bank (Điền cụm từ cho trước vào câu)
 * --------------------------------------------------------------------- */
.word-bank-box {
  background: #eff6ff;
  border: 2px dashed #93c5fd;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.word-bank-label {
  font-size: 14px;
  font-weight: 900;
  color: var(--primary-dark);
  margin-bottom: 10px;
  display: block;
}

.word-bank-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.word-chip {
  padding: 8px 16px;
  border-radius: 999px;
  background: #ffffff;
  border: 2px solid #60a5fa;
  color: #1e3a8a;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(37, 99, 235, 0.12);
  transition: transform 0.12s ease, opacity 0.15s ease, background 0.15s ease;
}

.word-chip:hover:not(:disabled) {
  background: #dbeafe;
  transform: translateY(-2px);
}

.word-chip.is-used {
  opacity: 0.42;
  border-style: dashed;
  box-shadow: none;
}

.word-chip:disabled {
  cursor: default;
}

.wb-passage {
  background: #ffffff;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  font-size: 18px;
  line-height: 2.25;
  font-weight: 600;
}

.wb-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  padding: 2px 14px;
  margin: 0 4px;
  border-radius: 10px;
  border: 2px dashed #94a3b8;
  background: #f8fafc;
  color: #64748b;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  vertical-align: baseline;
  transition: all 0.15s ease;
  line-height: 1.5;
}

.wb-slot.is-active {
  border-color: var(--primary);
  border-style: solid;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.wb-slot.is-filled {
  border-style: solid;
  border-color: #3b82f6;
  background: #dbeafe;
  color: #1e3a8a;
}

.wb-slot.is-dragover {
  border-color: #10b981;
  background: #dcfce7;
  transform: scale(1.03);
}

.wb-slot.is-ok {
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
}

.wb-slot.is-bad {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}

.wb-slot:disabled {
  cursor: default;
}

.wb-hint {
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-light);
  font-weight: 700;
}

/* ---------------------------------------------------------------------
 * Type 5: True / False
 * --------------------------------------------------------------------- */
.tf-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tf-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: #ffffff;
}

.tf-row.is-ok {
  border-color: var(--success-border);
  background: #f0fdf4;
}

.tf-row.is-bad {
  border-color: var(--danger-border);
  background: #fef2f2;
}

.tf-text {
  font-weight: 700;
  font-size: 17px;
  flex: 1;
}

.tf-index {
  display: inline-block;
  font-weight: 900;
  color: var(--primary-dark);
  margin-right: 6px;
}

.tf-buttons {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.tf-btn {
  min-width: 78px;
  min-height: 42px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 2px solid #cbd5e1;
  background: #f8fafc;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.14s ease;
}

.tf-btn:not(.is-selected-true):not(.is-selected-false):hover:not(:disabled) {
  border-color: #93c5fd;
  background: #eff6ff;
}

.tf-btn.is-selected-true {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.tf-btn.is-selected-true:hover:not(:disabled) {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.tf-btn.is-selected-false {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #ffffff;
}

.tf-btn.is-selected-false:hover:not(:disabled) {
  background: #6d28d9;
  border-color: #6d28d9;
}

.tf-btn.is-ok-selected {
  background: var(--success);
  border-color: var(--success);
  color: #ffffff;
}

.tf-btn.is-bad-selected {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

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

/* ---------------------------------------------------------------------
 * Type 6: Matching (Nối câu ở 2 bảng kèm đường nối SVG)
 * --------------------------------------------------------------------- */
.matching-instruction {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.matching-clear-btn {
  background: transparent;
  border: 1.5px solid #cbd5e1;
  border-radius: 999px;
  padding: 4px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
  cursor: pointer;
}

.matching-clear-btn:hover:not(:disabled) {
  background: #f1f5f9;
}

.matching-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
}

.matching-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}

.matching-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 3;
}

.matching-col-title {
  text-align: center;
  font-size: 15px;
  font-weight: 900;
  color: var(--primary-dark);
  background: #eff6ff;
  border: 1.5px solid var(--primary-border);
  border-radius: 10px;
  padding: 7px 10px;
}

.match-node {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: #ffffff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  min-height: 62px;
  transition: transform 0.12s ease, border-color 0.14s ease, background 0.14s ease;
}

.match-node:hover:not(:disabled) {
  border-color: #60a5fa;
  background: #f8fbff;
}

.match-node.is-active {
  border-color: var(--primary);
  background: #dbeafe;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
  transform: scale(1.01);
}

.match-node:disabled {
  cursor: default;
}

.match-id-badge {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #f1f5f9;
  color: #334155;
  font-weight: 900;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.match-pair-tag {
  margin-left: auto;
  font-size: 12px;
  font-weight: 900;
  padding: 3px 9px;
  border-radius: 999px;
  color: #ffffff;
  white-space: nowrap;
  flex-shrink: 0;
}

.match-node.is-ok {
  border-color: var(--success) !important;
  background: #f0fdf4 !important;
}

.match-node.is-bad {
  border-color: var(--danger) !important;
  background: #fef2f2 !important;
}

/* ---------------------------------------------------------------------
 * Type 7: Essay (Tự luận gồm các câu hỏi nhỏ — Đáp án tham khảo ở bên cạnh)
 * --------------------------------------------------------------------- */
.essay-sub-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.essay-sub-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  background: #fcfdff;
}

.essay-sub-prompt {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
}

.essay-sub-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  border: 1.5px solid #fcd34d;
  font-weight: 900;
  font-size: 14.5px;
  margin-right: 8px;
}

/* Trước khi nộp: 1 cột. Sau khi nộp: chia 2 cột cạnh nhau cho từng ý nhỏ! */
.essay-sub-grid {
  display: block;
}

.question-card.is-submitted .essay-sub-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.essay-student-col-title {
  display: none;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.question-card.is-submitted .essay-student-col-title {
  display: block;
}

.essay-textarea {
  width: 100%;
  min-height: 112px;
  padding: 12px 15px;
  border-radius: 12px;
  border: 2px solid #cbd5e1;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.6;
  color: var(--text-main);
  background: #ffffff;
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.essay-textarea:focus {
  outline: none;
  border-color: #d97706;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.essay-textarea:disabled {
  background: #f8fafc;
  color: var(--text-main);
}

.essay-empty-note {
  display: none;
  margin-top: 6px;
  font-size: 14px;
  font-weight: 700;
  color: #b45309;
}

.question-card.is-submitted .essay-empty-note.show-empty {
  display: block;
}

/* Cột Đáp án tham khảo bên cạnh cho từng ý tự luận */
.essay-ref-box {
  display: none;
  background: var(--ref-bg);
  border: 2px solid var(--ref-border);
  border-radius: 14px;
  padding: 14px 16px;
}

.question-card.is-submitted .essay-ref-box {
  display: block;
}

.essay-ref-title {
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--ref-color);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.essay-ref-text {
  margin: 0;
  white-space: pre-line;
  font-size: 15.5px;
  font-weight: 700;
  color: #451a03;
  line-height: 1.65;
}

.essay-keypoints {
  margin: 10px 0 0;
  padding: 10px 12px 10px 28px;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #78350f;
}

.essay-keypoints li + li {
  margin-top: 4px;
}

/* ---------------------------------------------------------------------
 * Submit Footer
 * --------------------------------------------------------------------- */
.submit-footer {
  margin-top: 28px;
}

.submit-footer-card {
  background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
  border: 2px solid var(--primary-border);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.submit-footer-text strong {
  display: block;
  font-size: 20px;
  color: #0f172a;
}

.submit-footer-text p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-weight: 600;
}

.submit-footer-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------------
 * Friendly Confirmation Modal
 * --------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-xl);
  max-width: 440px;
  width: 100%;
  padding: 28px 26px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  border: 2px solid #dbeafe;
}

.modal-icon {
  font-size: 44px;
  margin-bottom: 6px;
}

.modal-title {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 900;
}

.modal-desc {
  margin: 0 0 22px;
  color: var(--text-muted);
  font-weight: 700;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------------
 * Responsive (Tablet & Mobile)
 * --------------------------------------------------------------------- */
@media (max-width: 860px) {
  .question-card.is-submitted:not([data-type="essay"]) .question-layout,
  .question-card.is-submitted .essay-sub-grid {
    grid-template-columns: 1fr;
  }

  .matching-stage {
    grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .hero-card,
  .question-card,
  .result-card,
  .submit-footer-card {
    padding: 18px 16px;
    border-radius: 18px;
  }

  .tf-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .tf-buttons {
    width: 100%;
  }

  .tf-btn {
    flex: 1;
  }

  .matching-stage {
    grid-template-columns: minmax(0, 1fr) 26px minmax(0, 1fr);
  }

  .match-node {
    padding: 10px 9px;
    font-size: 14px;
    gap: 6px;
  }

  .match-id-badge {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .sticky-actions {
    width: 100%;
  }

  .sticky-actions .btn {
    width: 100%;
  }
}

/* ---------------------------------------------------------------------
 * Print Friendly Styles
 * --------------------------------------------------------------------- */
@media print {
  .sticky-bar,
  .subject-switcher,
  .submit-footer,
  .result-actions,
  .matching-clear-btn,
  .autosave-pill {
    display: none !important;
  }

  body {
    background: #ffffff;
    padding-bottom: 0;
  }

  .question-card,
  .hero-card,
  .result-card {
    box-shadow: none;
    break-inside: avoid;
  }
}
