/* ===== JLPT Practice System - Main Stylesheet ===== */

/* ===== ALERT TYPES (extended) ===== */
/* .alert-success .alert-danger .alert-warning .alert-info defined below */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;700&family=Be+Vietnam+Pro:wght@300;400;500;600;700&display=swap');

:root {
  /* Vỏ trang: navy sâu (không tím / không xanh quá chói) */
  --navy-950: #050a14;
  --navy-900: #0a1628;
  --navy-800: #0f2847;
  --navy-700: #1a3352;
  --primary: #1e40af;
  --primary-dark: #1e3a8a;
  --primary-light: #eff6ff;
  --success: #0f9d58;
  --success-light: #e6f4ea;
  --danger: #d32f2f;
  --danger-light: #fce8e6;
  --warning: #f57c00;
  --warning-light: #fef3e2;
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-500: #6c757d;
  --gray-700: #343a40;
  --shadow: 0 2px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.15);
  --radius: 12px;
  --radius-sm: 8px;
}

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

/* Nền html tránh viền sáng; gradient cố định khi cuộn */
html {
  background-color: var(--navy-950);
}
body {
  font-family: 'Be Vietnam Pro', 'Noto Sans JP', sans-serif;
  background: linear-gradient(160deg, var(--navy-950) 0%, var(--navy-900) 28%, var(--navy-800) 58%, var(--navy-700) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  color: var(--gray-700);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== HEADER ===== */
.site-header {
  background: rgba(5, 10, 20, 0.72);
  backdrop-filter: blur(12px);
  padding: 15px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.site-header .logo {
  font-size: 1.35rem;
  font-weight: 800;
  color: white;
  text-decoration: none;
  letter-spacing: -.01em;
  text-shadow: 0 2px 8px rgba(0,0,0,.2);
  transition: opacity .2s;
}
.site-header .logo:hover { opacity: .85; }
.site-header nav a {
  color: rgba(255,255,255,.9);
  text-decoration: none;
  margin-left: 20px;
  font-size: .9rem;
  transition: color .2s;
}
.site-header nav a:hover { color: white; }

/* ===== CONTAINER ===== */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 30px 20px;
}

.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  margin-bottom: 24px;
}

/* ===== HOME PAGE ===== */
.hero {
  text-align: center;
  padding: 64px 20px 36px;
  color: white;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 90% 70% at 50% 0%, rgba(255,255,255,.18) 0%, transparent 70%);
  pointer-events: none;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.3);
  padding: 6px 20px;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 500;
  margin-bottom: 22px;
  color: rgba(255,255,255,.95);
  position: relative;
}
.hero h1 {
  font-size: 3.2rem;
  font-weight: 800;
  margin-bottom: 16px;
  text-shadow: 0 4px 24px rgba(0,0,0,.25);
  letter-spacing: -.03em;
  position: relative;
  line-height: 1.1;
}
.hero p {
  font-size: 1.1rem;
  opacity: .9;
  margin-bottom: 0;
  position: relative;
}

/* ── Resume banner: phiên thi dang dở ── */
.resume-banner {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 2px solid #f59e0b;
  border-radius: 14px;
  margin: -10px auto 24px;
  max-width: 1100px;
  padding: 18px 24px;
  box-shadow: 0 4px 16px rgba(245, 158, 11, .15);
  animation: resumePulse .6s ease-out;
}
@keyframes resumePulse {
  0% { transform: scale(.97); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.resume-banner-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.resume-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}
.resume-icon {
  font-size: 2rem;
  flex-shrink: 0;
}
.resume-info strong {
  display: block;
  font-size: .95rem;
  color: #92400e;
}
.resume-info p {
  margin: 4px 0 0;
  font-size: .84rem;
  color: #a16207;
  line-height: 1.4;
  opacity: 1;
  position: static;
}
.resume-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
  flex-shrink: 0;
  justify-content: flex-end;
}
.resume-actions .resume-action-btn,
.resume-actions a.resume-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  font-size: .87rem;
  font-weight: 600;
  border-radius: 10px;
  box-sizing: border-box;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.2;
}
.resume-actions .btn-secondary.resume-action-btn {
  background: #fff;
  border: 2px solid #d97706;
  color: #92400e;
}
.resume-actions .btn-secondary.resume-action-btn:hover {
  background: #fffbeb;
  border-color: #b45309;
  color: #78350f;
}
.resume-actions .resume-action-warn {
  border-color: #c2410c !important;
  color: #9a3412 !important;
  background: #fff7ed !important;
}
.resume-actions .resume-action-warn:hover {
  background: #ffedd5 !important;
  border-color: #9a3412 !important;
}
.resume-actions a.btn-primary.resume-action-btn {
  box-shadow: 0 2px 10px rgba(30, 64, 175, .35);
}
@media (max-width: 600px) {
  .resume-banner { padding: 14px 16px; margin: -6px 10px 18px; }
  .resume-banner-inner { flex-direction: column; align-items: stretch; text-align: center; }
  .resume-info { flex-direction: column; text-align: center; }
  .resume-actions {
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    justify-content: stretch;
  }
  .resume-actions .resume-action-btn,
  .resume-actions a.resume-action-btn {
    width: 100%;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
  }
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin: 30px 0;
}

.level-card {
  background: white;
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  display: block;
  border: 3px solid transparent;
}
.level-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}
.level-card.n5 { border-color: #4caf50; }
.level-card.n4 { border-color: #2196f3; }
.level-card.n3 { border-color: #ff9800; }
.level-card.n2 { border-color: #4338ca; }
.level-card.n1 { border-color: #f44336; }

.level-badge {
  font-size: 2.8rem;
  font-weight: 800;
  margin-bottom: 10px;
  font-family: 'Noto Sans JP', sans-serif;
}
.n5 .level-badge { color: #4caf50; }
.n4 .level-badge { color: #2196f3; }
.n3 .level-badge { color: #ff9800; }
.n2 .level-badge { color: #4338ca; }
.n1 .level-badge { color: #f44336; }

.level-card h3 { font-size: 1rem; color: #555; margin-bottom: 8px; }
.level-card p { font-size: .85rem; color: #888; line-height: 1.5; }

.level-info {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 15px;
  flex-wrap: wrap;
}
.level-info span {
  background: var(--gray-100);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: .78rem;
  color: var(--gray-500);
}

/* ===== LEVEL EXAM GRID (trang chủ inline exams) ===== */
.level-exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
  margin: 30px 0;
}
.level-exam-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  overflow: hidden;
  transition: transform .25s ease, box-shadow .25s ease;
}
.level-exam-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 16px 48px rgba(0,0,0,.18);
}
.level-exam-card.n5 { border-color: #4caf50; }
.level-exam-card.n4 { border-color: #2196f3; }
.level-exam-card.n3 { border-color: #ff9800; }
.level-exam-card.n2 { border-color: #4338ca; }
.level-exam-card.n1 { border-color: #f44336; }
/* Colored gradient header per level */
.level-exam-card.n5 .lec-header { background: linear-gradient(135deg, #e8f5e9 0%, #f1f8f1 100%); }
.level-exam-card.n4 .lec-header { background: linear-gradient(135deg, #e3f2fd 0%, #edf5ff 100%); }
.level-exam-card.n3 .lec-header { background: linear-gradient(135deg, #fff3e0 0%, #fff9ed 100%); }
.level-exam-card.n2 .lec-header { background: linear-gradient(135deg, #e0e7ff 0%, #eef2ff 100%); }
.level-exam-card.n1 .lec-header { background: linear-gradient(135deg, #ffebee 0%, #fdf2f2 100%); }

.lec-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #f0f0f0;
}
.lec-header .level-badge {
  font-size: 2rem;
  margin-bottom: 0;
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
}
.level-exam-card.n5 .lec-header .level-badge { background: rgba(76,175,80,.14); }
.level-exam-card.n4 .lec-header .level-badge { background: rgba(33,150,243,.14); }
.level-exam-card.n3 .lec-header .level-badge { background: rgba(255,152,0,.14); }
.level-exam-card.n2 .lec-header .level-badge { background: rgba(67,56,202,.14); }
.level-exam-card.n1 .lec-header .level-badge { background: rgba(244,67,54,.14); }
.lec-meta h3 { font-size: .95rem; color: #444; margin-bottom: 2px; }
.lec-meta p  { font-size: .8rem; color: #888; margin-bottom: 6px; }
.lec-meta .level-info { justify-content: flex-start; margin-top: 0; }
.lec-stats { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.lec-stat-item { font-size: .75rem; font-weight: 600; color: #555; background: #eff6ff; border: 1px solid #bfdbfe; padding: 2px 8px; border-radius: 12px; }

.lec-search-row { padding: 6px 12px 2px; }
.lec-search-label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 4px;
  letter-spacing: .02em;
}
.lec-exam-filter {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 2px solid rgba(0,0,0,.08);
  border-radius: 10px;
  font-size: .88rem;
  font-family: inherit;
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.lec-exam-filter:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.14);
}
.level-exam-card.n5 .lec-exam-filter:focus { border-color: #43a047; box-shadow: 0 0 0 3px rgba(76,175,80,.18); }
.level-exam-card.n4 .lec-exam-filter:focus { border-color: #1e88e5; box-shadow: 0 0 0 3px rgba(33,150,243,.18); }
.level-exam-card.n3 .lec-exam-filter:focus { border-color: #fb8c00; box-shadow: 0 0 0 3px rgba(255,152,0,.2); }
.level-exam-card.n2 .lec-exam-filter:focus { border-color: #4338ca; box-shadow: 0 0 0 3px rgba(67,56,202,.2); }
.level-exam-card.n1 .lec-exam-filter:focus { border-color: #e53935; box-shadow: 0 0 0 3px rgba(244,67,54,.15); }
.lec-filter-empty {
  margin: 4px 0 0;
  padding: 10px 8px;
  text-align: center;
  font-size: .8rem;
  color: #64748b;
  background: #f1f5f9;
  border-radius: 8px;
  border: 1px dashed #cbd5e1;
}

.lec-exams { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #ccc transparent; }
.lec-exams::-webkit-scrollbar { width: 5px; }
.lec-exams::-webkit-scrollbar-track { background: transparent; }
.lec-exams::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.lec-exam-row {
  display: flex;
  align-items: flex-start;
  flex-wrap: nowrap;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8f9fa;
  border: 1px solid #eee;
  margin: 0;
  transition: background .15s, border-color .15s, transform .12s;
}
.lec-exam-row .btn-start {
  align-self: center;
}
.lec-exam-row:hover { background: #eff6ff; border-color: #bfdbfe; transform: translateX(2px); }
.lec-exam-row.lec-random { background: #fffbf0; border-color: #ffe082; }
.lec-exam-row.lec-random:hover { background: #fff3d4; border-color: #ffca28; transform: translateX(2px); }
.lec-exam-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lec-exam-name {
  font-size: .88rem;
  font-weight: 600;
  color: #333;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}
.lec-exam-sub {
  font-size: .75rem;
  color: #999;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}
.btn-start {
  flex-shrink: 0;
  padding: 7px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
  color: white;
  transition: opacity .15s, transform .12s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(30,64,175,.32);
  white-space: nowrap;
}
.btn-start:hover { opacity: .88; transform: scale(1.06); box-shadow: 0 5px 16px rgba(30,64,175,.42); }
.btn-start-random {
  background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
  box-shadow: 0 2px 8px rgba(255,152,0,.35);
}
.btn-start-random:hover { opacity: .88; box-shadow: 0 5px 16px rgba(255,152,0,.5); }

/* Chọn cấp độ cho đề ngẫu nhiên (đầu trang chủ) */
.random-level-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.random-level-form-row {
  display: grid;
  gap: 16px 22px;
  align-items: start;
}
.random-level-form-row--top {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.random-level-form-row--bottom {
  grid-template-columns: minmax(0, 1fr) minmax(140px, 200px);
  align-items: end;
}
.random-level-field,
.random-level-tts-block,
.random-level-class-block {
  min-width: 0;
}
.random-level-tts-block {
  margin-top: 0;
}
.random-level-class-field {
  margin-top: 0;
}
.random-level-submit-wrap {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-self: stretch;
  min-width: 0;
}
.random-level-tts label {
  display: block;
  font-size: .82rem;
  font-weight: 700;
  margin-bottom: 6px;
  opacity: .95;
}
.random-level-tts .random-tts-hint {
  font-weight: 500;
  opacity: .88;
  font-size: .78rem;
}
.random-level-tts input {
  width: 100%;
  max-width: none;
  padding: 12px 14px;
  min-height: 46px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.95);
  font-size: .92rem;
  box-sizing: border-box;
}
.random-level-tts input:focus {
  outline: none;
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}
.random-tts-note {
  margin: 8px 0 0;
  font-size: .72rem;
  line-height: 1.45;
  opacity: 0.92;
  max-width: none;
}

.random-level-card {
  margin-bottom: 24px;
  padding: 26px 30px;
  background: linear-gradient(135deg, #f97316 0%, #ea580c 60%, #dc2626 100%);
  border: none;
  color: white;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(234,88,12,.35);
}
.random-level-card::before {
  content: '🎲';
  position: absolute;
  font-size: 10rem;
  right: -16px;
  top: -24px;
  opacity: .1;
  line-height: 1;
  pointer-events: none;
  user-select: none;
  transform: rotate(12deg);
}
.random-level-card h3 {
  margin: 0 0 6px;
  font-size: 1.2rem;
  color: white;
  font-weight: 700;
}
.random-level-sub {
  margin: 0 0 20px;
  font-size: .88rem;
  color: rgba(255,255,255,.88);
  line-height: 1.5;
}
.random-level-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.random-level-field label {
  font-weight: 600;
  font-size: .85rem;
  color: rgba(255,255,255,.9);
}
.random-level-field select {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  min-height: 46px;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,.35);
  font-family: inherit;
  font-size: .92rem;
  background: rgba(255,255,255,.95);
  color: #333;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}
.random-level-submit {
  width: 100%;
  min-height: 46px;
  padding: 12px 20px;
  font-size: .95rem;
  background: rgba(255,255,255,.22) !important;
  border: 2px solid rgba(255,255,255,.55) !important;
  box-shadow: 0 2px 12px rgba(0,0,0,.12) !important;
  color: white !important;
  backdrop-filter: blur(6px);
  font-weight: 700;
  letter-spacing: .02em;
  border-radius: 10px;
}
.random-level-submit:hover {
  background: rgba(255,255,255,.35) !important;
  border-color: rgba(255,255,255,.8) !important;
  box-shadow: 0 6px 20px rgba(0,0,0,.2) !important;
  opacity: 1 !important;
  transform: scale(1.04) !important;
}

@media (max-width: 720px) {
  .random-level-form-row--top,
  .random-level-form-row--bottom {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .random-level-submit-wrap {
    width: 100%;
  }
  .random-level-submit {
    width: 100%;
  }
}

.lec-exam-row-blocked {
  background: #fafafa;
  border: 1px dashed #cfd8dc;
  opacity: 0.95;
}
.lec-exam-guard {
  font-size: .72rem;
  font-weight: 700;
  color: #c62828;
  margin-top: 3px;
  letter-spacing: .01em;
}
.btn-start-disabled,
.btn-start:disabled {
  background: #9e9e9e !important;
  color: #fff;
  cursor: not-allowed;
  transform: none !important;
  opacity: 0.9;
  box-shadow: none !important;
}
.btn-start-disabled:hover { transform: none !important; background: #9e9e9e !important; }

/* ===== FEATURE GRID (homepage bottom) ===== */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 12px;
}
.feature-card {
  padding: 26px 20px 22px;
  text-align: center;
  transition: transform .2s ease, box-shadow .2s ease;
}
.feature-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 14px 44px rgba(0,0,0,.18);
}
.feature-icon {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin: 0 auto 16px;
}
.feature-card:nth-child(1) .feature-icon { background: linear-gradient(135deg, #e8f0fe, #c8dbfc); }
.feature-card:nth-child(2) .feature-icon { background: linear-gradient(135deg, #e6f4ea, #b9e4c5); }
.feature-card:nth-child(3) .feature-icon { background: linear-gradient(135deg, #fef3e2, #fddba8); }
.feature-card:nth-child(4) .feature-icon { background: linear-gradient(135deg, #dbeafe, #93c5fd); }
.feature-card h4 { font-size: .95rem; margin-bottom: 6px; color: #333; font-weight: 700; }
.feature-card p { font-size: .82rem; color: #888; line-height: 1.5; }

/* ===== ENTRANCE ANIMATIONS ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}
.random-level-card { animation: fadeInUp .4s ease both; }
.level-exam-card { animation: fadeInUp .45s ease both; }
.level-exam-card:nth-child(1) { animation-delay: .06s; }
.level-exam-card:nth-child(2) { animation-delay: .12s; }
.level-exam-card:nth-child(3) { animation-delay: .18s; }
.level-exam-card:nth-child(4) { animation-delay: .24s; }
.level-exam-card:nth-child(5) { animation-delay: .30s; }
.feature-card { animation: fadeInUp .4s ease both; }
.feature-card:nth-child(1) { animation-delay: .15s; }
.feature-card:nth-child(2) { animation-delay: .22s; }
.feature-card:nth-child(3) { animation-delay: .29s; }
.feature-card:nth-child(4) { animation-delay: .36s; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: white;
  border-radius: var(--radius);
  padding: 36px;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: slideUp .3s ease;
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal h2 { font-size: 1.4rem; margin-bottom: 8px; }
.modal p { color: var(--gray-500); margin-bottom: 24px; font-size: .9rem; }
.modal input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: border-color .2s;
  margin-bottom: 16px;
  font-family: inherit;
}
.modal input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  border-radius: 10px;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .25s cubic-bezier(.4,0,.2,1);
  border: none;
  text-decoration: none;
  font-family: inherit;
  position: relative;
  overflow: hidden;
  letter-spacing: .01em;
  line-height: 1.5;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.btn-primary {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
  color: white;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
  box-shadow: 0 4px 14px rgba(30,64,175,.4);
}
.btn-block {
  width: 100%;
  justify-content: center;
}
.btn-secondary {
  background: white;
  color: var(--gray-700);
  border: 1.5px solid var(--gray-200);
}
.btn-secondary:hover {
  background: var(--gray-100);
  border-color: #ccc;
}
.btn-success {
  background: linear-gradient(135deg, #0f9d58 0%, #34a853 100%);
  color: white;
}
.btn-success:hover {
  background: linear-gradient(135deg, #0b7a44 0%, #0f9d58 100%);
  box-shadow: 0 4px 14px rgba(15,157,88,.4);
}
.btn-danger {
  background: linear-gradient(135deg, #d32f2f 0%, #ef5350 100%);
  color: white;
}
.btn-danger:hover {
  background: linear-gradient(135deg, #b71c1c 0%, #d32f2f 100%);
  box-shadow: 0 4px 14px rgba(211,47,47,.4);
}
.btn-warning {
  background: linear-gradient(135deg, #f57c00 0%, #ff9800 100%);
  color: white;
}
.btn-warning:hover {
  background: linear-gradient(135deg, #e65100 0%, #f57c00 100%);
  box-shadow: 0 4px 14px rgba(245,124,0,.4);
}
.btn-outline {
  background: white;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover {
  background: var(--primary-light);
}
.btn-ghost {
  background: transparent;
  color: var(--gray-500);
  box-shadow: none;
}
.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--gray-700);
  box-shadow: none;
}
.btn-lg { padding: 14px 32px; font-size: 1.05rem; border-radius: 12px; }
.btn-sm { padding: 7px 14px; font-size: .82rem; border-radius: 8px; }

/* ===== EXAM PAGE ===== */
.exam-header {
  background: white;
  box-shadow: var(--shadow);
  padding: 14px 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}
.exam-title {
  grid-column: 2;
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #d32f2f !important;
}
.exam-progress {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .9rem;
  color: var(--gray-500);
}

.timer {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 1rem;
  min-width: 80px;
  justify-content: center;
}
.timer.warning { background: var(--warning-light); color: var(--warning); }
.timer.danger { background: var(--danger-light); color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.6; } }

.progress-bar-wrap {
  background: var(--gray-200);
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 20px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #0c4a6e);
  border-radius: 3px;
  transition: width .3s;
}

/* ===== SECTION HEADER ===== */
.section-header {
  background: linear-gradient(135deg, var(--primary) 0%, #0c4a6e 100%);
  color: white;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  margin: 24px 0 16px;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ===== QUESTION CARD ===== */
.question-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: visible;
  transition: box-shadow .2s;
}
.question-card:hover { box-shadow: var(--shadow-lg); }

.question-number {
  background: var(--gray-100);
  padding: 10px 20px;
  font-size: .82rem;
  color: var(--gray-500);
  font-weight: 600;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.question-number .topic-tag {
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: .75rem;
}

.question-body {
  padding: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.passage {
  background: #fffef0;
  border-left: 4px solid var(--warning);
  padding: 16px 20px;
  margin-bottom: 20px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  line-height: 2;
  font-size: .95rem;
}

.question-text {
  font-size: 1.05rem;
  line-height: 1.8;
  margin-bottom: 20px;
  font-family: 'Noto Sans JP', sans-serif;
  word-break: break-word;
  overflow-wrap: break-word;
  color: #1e293b;
}
/* Nội dung từ editor đôi khi có màu xám mờ inline — ép đọc rõ trên nền sáng */
.question-text * {
  color: inherit !important;
}
/* TinyMCE: YouTube / video / ảnh — vừa khung màn hình điện thoại */
.question-text iframe,
.question-text video,
.review-question iframe,
.review-question video {
  max-width: 100%;
  width: 100%;
  border: 0;
  display: block;
  margin: 12px auto;
}
.question-text iframe,
.review-question iframe {
  aspect-ratio: 16 / 9;
  height: auto;
  min-height: 200px;
}
.question-text img,
.review-question img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 12px auto;
}
.question-text audio,
.review-question audio {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 12px auto;
}
/* Tách yêu cầu (hướng dẫn) và nội dung câu hỏi tiếng Nhật */
.question-text hr.q-req-sep {
  border: 0;
  border-top: 1px solid var(--gray-300, #d0d0d0);
  margin: 14px 0 16px;
}
.question-text b:first-of-type {
  color: var(--gray-800, #333);
  font-weight: 700;
}
.review-question hr.q-req-sep,
.preview-box .q-text hr.q-req-sep {
  border: 0;
  border-top: 1px solid var(--gray-300, #d0d0d0);
  margin: 14px 0 16px;
}
.review-question b:first-of-type,
.preview-box .q-text b:first-of-type {
  font-weight: 700;
  color: var(--gray-800, #333);
}
.question-text ruby rt, .passage-wrap ruby rt, .review-question ruby rt,
.preview-box .q-text ruby rt, .preview-box .opt ruby rt {
  font-size: 0.65em;
  font-weight: 400;
}

/* Cụm Kanji + furigana: tránh Chrome tách khoảng khi một <rt> dài phủ nhiều chữ */
.ruby-phrase {
  display: inline-block;
  white-space: nowrap;
  max-width: 100%;
}
.question-text ruby,
.passage-wrap ruby,
.review-question ruby,
.preview-box .q-text ruby,
.preview-box .opt ruby {
  white-space: nowrap;
}
.question-text,
.preview-box .q-text {
  word-break: normal;
  line-break: strict;
}

/* ===== ANSWER OPTIONS ===== */
.options { display: grid; gap: 10px; }

/* 聴解 — đáp án toàn ảnh: xếp ngang (JFT / đề mẫu nhiều lựa chọn hình) */
.options.options--listening-img-row {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: stretch;
}
.options.options--listening-img-row .option-label {
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 100%;
}
.options.options--listening-img-row .option-letter {
  margin-bottom: 4px;
}
.options.options--listening-img-row .opt-image {
  margin-top: 8px;
}

/* Trang xem lại kết quả — cùng lưới ngang */
.review-answers.options--listening-img-row {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.review-answers.options--listening-img-row .review-option {
  text-align: center;
}
.review-answers.options--listening-img-row .opt-image {
  display: block;
  margin: 8px auto 0;
  max-width: 100%;
}
.option-label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .2s;
  font-size: .95rem;
  font-family: 'Noto Sans JP', sans-serif;
  word-break: break-word;
  overflow-wrap: break-word;
  min-width: 0;
  color: #1e293b;
}
.option-text {
  min-width: 0;
  word-break: break-word;
  overflow-wrap: break-word;
}
.option-text * {
  color: inherit !important;
}
.option-label:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.option-label input[type=radio] { display: none; }
.option-letter {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
  font-family: 'Be Vietnam Pro', sans-serif;
}

input[type=radio]:checked + .option-label {
  border-color: var(--primary);
  background: var(--primary-light);
}
input[type=radio]:checked + .option-label .option-letter {
  background: var(--primary);
  color: white;
}

/* ===== RESULT PAGE ===== */
.score-hero {
  text-align: center;
  padding: 40px 20px;
}
.score-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  margin: 0 auto 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.score-circle.pass { background: linear-gradient(135deg, #0f9d58, #00e676); }
.score-circle.fail { background: linear-gradient(135deg, #d32f2f, #ff5252); }

.score-number { font-size: 2.8rem; font-weight: 800; color: white; line-height: 1; }
.score-label { font-size: .85rem; color: rgba(255,255,255,.8); }
.result-label { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.result-label.pass { color: var(--success); }
.result-label.fail { color: var(--danger); }

.result-student-info {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px 20px;
  margin: 16px auto 12px;
  max-width: 420px;
  text-align: left;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.result-student-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 1rem;
}
.result-student-row:last-child { margin-bottom: 0; }
.result-student-label {
  color: #64748b;
  font-weight: 600;
  min-width: 80px;
  flex-shrink: 0;
}
.result-student-value {
  color: #1e293b;
  font-weight: 700;
  font-size: 1.05rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin: 24px 0;
}
.stat-card {
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}
.stat-number { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: .8rem; color: var(--gray-500); margin-top: 4px; }

/* ===== AUDIO PLAYER (聴解) ===== */
.audio-player-wrap {
  position: relative;
  background: linear-gradient(135deg, #eff6ff, #e0e7ff);
  border: 2px solid #93c5fd;
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
/*
 * Chrome thường không decode/phát ổn định khi <audio> có chiều cao 0. Giữ kích thước hợp lệ,
 * đưa ra ngoài màn hình — không đè nút «Phát audio», vẫn tải/giải mã bình thường.
 */
.audio-player-wrap > audio {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 320px;
  height: 48px;
  margin: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  border: 0;
}
.audio-controls {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.audio-play-btn {
  background: linear-gradient(135deg, #1e40af, #0c4a6e);
  color: white;
  border: none;
  padding: 11px 22px;
  border-radius: 30px;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all .2s;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
  justify-content: center;
}
.audio-play-btn:hover:not(:disabled) {
  transform: scale(1.04);
  box-shadow: 0 4px 16px rgba(30,64,175,.38);
}
.audio-play-btn:disabled { cursor: not-allowed; transform: none; box-shadow: none; }
.audio-play-info { display: flex; flex-direction: column; gap: 4px; }
.audio-plays-badge {
  background: white;
  border: 1.5px solid #93c5fd;
  color: #1e3a8a;
  font-size: .8rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  display: inline-block;
  transition: all .3s;
}
.audio-plays-hint { font-size: .74rem; color: #888; padding-left: 4px; }
.audio-progress-bar {
  height: 5px;
  background: #bfdbfe;
  border-radius: 4px;
  overflow: hidden;
}
.audio-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #1e40af, #0c4a6e);
  width: 0%;
  transition: width .1s linear;
  border-radius: 4px;
}

/* ===== RESULT QUESTION REVIEW ===== */
.review-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: visible;
}
.review-header {
  padding: 10px 20px;
  font-size: .85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.review-header.correct { background: var(--success-light); color: var(--success); }
.review-header.wrong { background: var(--danger-light); color: var(--danger); }
.review-header.skipped { background: var(--warning-light); color: var(--warning); }

.review-body {
  padding: 16px 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.review-question {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 1rem;
  margin-bottom: 14px;
  line-height: 1.8;
  word-break: break-word;
  overflow-wrap: break-word;
}
.review-answers { display: grid; gap: 8px; }
.review-option {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Noto Sans JP', sans-serif;
  word-break: break-word;
  overflow-wrap: break-word;
  min-width: 0;
}
.review-option.user-correct { background: var(--success-light); color: var(--success); font-weight: 600; }
.review-option.correct-answer { background: var(--success-light); color: var(--success); font-weight: 600; border: 2px solid var(--success); }
.review-option.user-wrong { background: var(--danger-light); color: var(--danger); }
.review-option.normal { background: var(--gray-100); color: var(--gray-500); }

.explanation {
  background: #f0f7ff;
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
  font-size: .88rem;
  margin-top: 12px;
  line-height: 1.7;
  color: #333;
}
.explanation strong { color: var(--primary); }

/* ===== STATS PAGE ===== */
.stats-section { margin-bottom: 32px; }
.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--gray-700);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.history-table th {
  background: var(--gray-100);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--gray-200);
  font-weight: 600;
  font-size: .83rem;
  color: var(--gray-500);
}
.history-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-200);
}
.history-table tr:last-child td { border-bottom: none; }

.topic-bar {
  background: var(--gray-100);
  border-radius: 10px;
  overflow: hidden;
  height: 10px;
  margin-top: 4px;
}
.topic-bar-fill {
  height: 100%;
  border-radius: 10px;
  transition: width .8s ease;
}
.topic-row { margin-bottom: 14px; }
.topic-info { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: 4px; }
.topic-info .name { font-family: 'Noto Sans JP', sans-serif; }
.topic-info .pct { font-weight: 700; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
}
.badge-n5 { background: #e8f5e9; color: #2e7d32; }
.badge-n4 { background: #e3f2fd; color: #1565c0; }
.badge-n3 { background: #fff3e0; color: #e65100; }
.badge-n2 { background: #e0e7ff; color: #3730a3; }
.badge-n1 { background: #ffebee; color: #b71c1c; }
.badge-pass { background: var(--success-light); color: var(--success); }
.badge-fail { background: var(--danger-light); color: var(--danger); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--gray-500);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 14px; }
.empty-state p { font-size: .95rem; }

/* ===== HEADER NAV ===== */
.site-header { position: relative; }
.nav-toggle {
  display: none;
  background: rgba(255,255,255,.18);
  border: none;
  color: white;
  font-size: 1.3rem;
  cursor: pointer;
  border-radius: 8px;
  padding: 6px 12px;
  line-height: 1;
  font-family: inherit;
  transition: background .15s;
}
.nav-toggle:hover { background: rgba(255,255,255,.3); }
.site-header .nav-link { color: rgba(255,255,255,.88); text-decoration: none; margin-left: 6px; font-size: .88rem; transition: color .18s, background .18s, transform .15s; padding: 6px 12px; border-radius: 8px; }
.site-header .nav-link:hover { color: white; background: rgba(255,255,255,.18); transform: translateY(-1px); }
.site-header .nav-user { color: rgba(255,255,255,.72); margin-left: 6px; font-size: .83rem; padding: 6px 10px; }
.site-header .nav-btn { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); }
.site-header .nav-btn-primary { background: rgba(255,255,255,.25); border: 1px solid rgba(255,255,255,.4); font-weight: 600; }
.site-header .nav-btn-primary:hover { background: rgba(255,255,255,.38); }
.site-header .nav-link.nav-active {
  color: white;
  background: rgba(255,255,255,.25);
  border: 1px solid rgba(255,255,255,.35);
  font-weight: 600;
}

/* ===== HOME FLOATING BUTTON ===== */
.home-fab {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 999;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #1a1a2e;
  font-size: 1.3rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 4px 18px rgba(0,0,0,.22);
  transition: transform .2s, box-shadow .2s, background .2s;
}
.home-fab:hover {
  transform: scale(1.12);
  box-shadow: 0 8px 28px rgba(0,0,0,.3);
  background: white;
}

/* ===== FAB: SCROLL TO TOP ===== */
.fab-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 998;
  background: rgba(30,64,175,.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: white;
  font-size: 1.4rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(30,64,175,.4);
  transition: opacity .3s, transform .2s;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.fab-top.visible { opacity: 1; pointer-events: auto; }
.fab-top:hover { transform: scale(1.1); }

/* ===== PASSAGE WRAP (Đọc hiểu) ===== */
.passage-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
  background: #fffef0;
  border-left: 4px solid var(--warning);
  padding: 14px 18px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  line-height: 2;
  font-size: .95rem;
  font-family: 'Noto Sans JP', sans-serif;
  word-break: break-word;
  overflow-wrap: break-word;
}
/* Ảnh / media trong đoạn (TinyMCE) — co vừa khung, tránh phải kéo thanh ngang */
.passage-wrap img,
.passage-wrap picture img,
.passage-wrap svg {
  /* !important: ghi đè width inline từ TinyMCE */
  max-width: 100% !important;
  height: auto !important;
  display: block;
  margin: 12px auto;
  box-sizing: border-box;
}
.passage-wrap iframe,
.passage-wrap video {
  max-width: 100%;
  width: 100%;
  border: 0;
  display: block;
  margin: 12px auto;
}
.passage-wrap iframe {
  aspect-ratio: 16 / 9;
  height: auto;
  min-height: 160px;
}

/* ===== SECTION QUICK NAV ===== */
.section-nav {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  background: white;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.section-nav::-webkit-scrollbar { display: none; }
.section-nav-btn {
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  color: var(--gray-700);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  font-family: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.section-nav-btn:hover,
.section-nav-btn:active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* ===== QUESTION TRACKER ===== */
.q-tracker-wrap {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px 14px;
  margin-bottom: 16px;
}
.q-tracker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 6px;
}
.q-tracker-title {
  font-size: .8rem;
  font-weight: 700;
  color: #555;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.q-tracker-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: .76rem;
  color: #777;
}
.q-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.q-dot-sample {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid #ddd;
  background: #f0f0f0;
  flex-shrink: 0;
}
.q-dot-sample.q-dot-done {
  background: linear-gradient(135deg, #34a853, #0f9d58);
  border-color: #0f9d58;
}
.q-tracker {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.q-dot {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 2px solid #e0e0e0;
  background: #f5f5f5;
  color: #aaa;
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s, color .15s, transform .12s;
  font-family: inherit;
  padding: 0;
  line-height: 1;
  touch-action: manipulation;
}
.q-dot:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
  transform: scale(1.18);
  position: relative;
  z-index: 1;
}
.q-dot.answered {
  background: linear-gradient(135deg, #34a853, #0f9d58);
  border-color: #0f9d58;
  color: white;
}
.q-dot.answered:hover {
  background: linear-gradient(135deg, #2d9248, #0a8048);
  border-color: #0a8048;
  color: white;
}
.q-dot.q-dot-info {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  border-color: #6d28d9;
  color: white;
  cursor: pointer;
  font-size: .65rem;
}
.q-dot.q-dot-info:hover {
  background: linear-gradient(135deg, #6d28d9, #5b21b6);
}
.q-dot.flagged {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #d97706;
  color: white;
}
.q-dot.flagged:hover {
  background: linear-gradient(135deg, #d97706, #b45309);
  border-color: #b45309;
  color: white;
}
.q-dot.answered.flagged {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #d97706;
  color: white;
}
.flag-btn {
  margin-left: auto;
  background: none;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  padding: 3px 10px;
  font-size: .78rem;
  cursor: pointer;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background .15s, border-color .15s, color .15s;
  font-family: inherit;
  white-space: nowrap;
}
.flag-btn:hover {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #b45309;
}
.flag-btn.active {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #b45309;
  font-weight: 600;
}
.flag-filter-btn {
  border: 1.5px solid #d1d5db;
  background: #f9fafb;
  border-radius: 8px;
  padding: 4px 12px;
  font-size: .8rem;
  cursor: pointer;
  color: #374151;
  font-family: inherit;
  transition: background .15s, border-color .15s;
}
.flag-filter-btn.active {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #b45309;
  font-weight: 600;
}
.q-dot-sample.flagged {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #d97706;
}

/* ===== REVIEW FILTER BUTTONS (Trang kết quả) ===== */
.review-filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.review-filter-btn {
  background: rgba(255,255,255,.18);
  border: 1.5px solid rgba(255,255,255,.35);
  color: white;
  padding: 7px 16px;
  border-radius: 20px;
  font-size: .83rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.review-filter-btn.active {
  background: white;
  color: var(--primary);
  border-color: white;
}
.review-filter-btn:hover { background: rgba(255,255,255,.28); }
.review-filter-btn.active:hover { background: white; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .container { padding: 20px 14px; }
  .card { padding: 22px; }
  .level-grid { gap: 14px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  /* --- Homepage: level exam grid 1 cột trên tablet nhỏ --- */
  .level-exam-grid { grid-template-columns: 1fr; gap: 14px; margin: 20px 0; }
  .lec-header { padding: 14px 16px 12px; }
  .lec-header .level-badge { width: 52px; height: 52px; font-size: 1.8rem; }
  .lec-exams { max-height: 260px; }

  /* --- Feature grid 2 cột --- */
  .feature-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .feature-card { padding: 18px 14px 16px; }
  .feature-icon { width: 48px; height: 48px; font-size: 1.4rem; border-radius: 14px; margin-bottom: 12px; }

  /* --- Random card compact --- */
  .random-level-card { padding: 18px 20px; }
}

@media (max-width: 600px) {
  /* --- Header hamburger --- */
  .nav-toggle { display: block; }
  .site-header { padding: 11px 14px; flex-wrap: nowrap; }
  .site-header .logo { font-size: 1.15rem; }
  #siteNav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: rgba(20, 30, 80, .97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-direction: column;
    padding: 8px 12px 14px;
    gap: 2px;
    z-index: 500;
    border-bottom: 2px solid rgba(255,255,255,.15);
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
  }
  #siteNav.open { display: flex; }
  .site-header .nav-link,
  .site-header .nav-user {
    margin-left: 0 !important;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: .93rem;
    width: 100%;
    box-sizing: border-box;
    display: block;
  }
  .site-header .nav-user { color: rgba(255,255,255,.6); font-size: .82rem; padding: 6px 12px; }
  .site-header .nav-btn { background: rgba(255,255,255,.1); margin-top: 2px; }
  .site-header .nav-btn-primary { background: rgba(30,64,175,.55); }
  .site-header .nav-link:hover { background: rgba(255,255,255,.12); }

  /* --- General --- */
  .container { padding: 14px 10px; }
  .card { padding: 16px; }

  /* --- Hero --- */
  .hero { padding: 28px 14px 16px; }
  .hero-badge { font-size: .78rem; padding: 5px 14px; margin-bottom: 14px; }
  .hero h1 { font-size: 2rem; margin-bottom: 8px; letter-spacing: -.02em; }
  .hero p { font-size: .92rem; }

  /* --- Level cards --- */
  .level-card { padding: 18px 14px; }
  .level-badge { font-size: 2.3rem; }
  .level-card h3 { font-size: .92rem; }
  .level-card p { font-size: .8rem; }
  .level-info { gap: 8px; }
  .level-info span { font-size: .72rem; padding: 3px 8px; }

  /* --- Modal --- */
  .modal { padding: 22px 16px; border-radius: 14px 14px 0 0; }
  .modal-overlay { align-items: flex-end; }
  .modal { max-width: 100%; width: 100%; animation: slideUp .25s ease; }
  .modal h2 { font-size: 1.2rem; }

  /* --- Exam header --- */
  .exam-header {
    padding: 10px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .exam-title { font-size: .88rem; width: 100%; text-align: center; grid-column: unset; color: #d32f2f !important; }
  .exam-progress { grid-column: unset; justify-self: unset; gap: 8px; font-size: .8rem; margin-left: auto; }
  .timer { padding: 5px 10px; font-size: .88rem; min-width: 68px; }

  /* --- Question cards --- */
  .question-body { padding: 14px 12px; }
  .question-text { font-size: .97rem; margin-bottom: 14px; }
  .question-number { padding: 8px 12px; font-size: .78rem; }
  .section-header { padding: 10px 12px; font-size: .88rem; margin: 16px 0 12px; }

  /* --- Reading passage --- */
  .passage-wrap { padding: 12px 14px; font-size: .9rem; line-height: 1.9; }

  /* --- Question text: không nhỏ hơn 1rem để đọc được chữ Nhật --- */
  .question-text { font-size: 1rem; }

  /* --- Audio player: xếp dọc trên màn nhỏ --- */
  .audio-controls { flex-direction: column; align-items: stretch; gap: 8px; }
  .audio-play-btn { min-width: unset; width: 100%; }

  /* --- Question tracker (mobile) --- */
  .q-tracker-wrap { padding: 10px 12px 12px; margin-bottom: 12px; }
  .q-tracker-title { font-size: .74rem; }
  .q-tracker-legend { gap: 10px; font-size: .72rem; }
  .q-tracker { gap: 4px; }
  .q-dot { width: 32px; height: 32px; border-radius: 8px; font-size: .78rem; }

  /* --- Section quick nav --- */
  .section-nav { padding: 6px 8px; gap: 5px; margin-bottom: 12px; }
  .section-nav-btn { padding: 5px 12px; font-size: .75rem; }

  /* --- Level exam cards (mobile) --- */
  .lec-header { padding: 12px 14px 10px; gap: 12px; }
  .lec-header .level-badge { width: 48px; height: 48px; font-size: 1.6rem; border-radius: 12px; }
  .lec-meta h3 { font-size: .88rem; }
  .lec-exams { padding: 8px 10px 10px; max-height: 220px; }
  .lec-exam-row { padding: 9px 10px; }
  .lec-exam-name { font-size: .83rem; }
  .btn-start { padding: 7px 13px; font-size: .78rem; }
  .random-level-card { padding: 16px 16px; }
  .random-level-card h3 { font-size: 1rem; }
  .random-level-card::before { font-size: 7rem; }
  .random-level-submit {
    min-height: 48px;
    padding: 14px 22px !important;
  }

  /* --- Feature grid (mobile: 2 cột) --- */
  .feature-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .feature-card { padding: 16px 12px 14px; }
  .feature-icon { width: 44px; height: 44px; font-size: 1.3rem; border-radius: 12px; margin-bottom: 10px; }
  .feature-card h4 { font-size: .88rem; }
  .feature-card p { font-size: .78rem; }

  /* --- FAB scroll-to-top: đẩy lên trên thanh home bar iOS --- */
  .fab-top { bottom: 76px; right: 14px; width: 44px; height: 44px; font-size: 1.2rem; }

  /* --- Review filter --- */
  .review-filter-bar { gap: 6px; }
  .review-filter-btn { padding: 6px 12px; font-size: .78rem; }

  /* --- Answer options: bigger touch targets --- */
  .option-label {
    padding: 13px 14px;
    font-size: .92rem;
    min-height: 50px;
  }
  .option-letter { width: 28px; height: 28px; font-size: .8rem; }
  .options { gap: 8px; }

  /* --- Submit area --- */
  .submit-area { padding: 18px 0; }
  .btn-lg { padding: 13px 24px; font-size: .97rem; }

  /* --- Result page --- */
  .score-hero { padding: 28px 12px; }
  .score-circle { width: 130px; height: 130px; }
  .result-student-info { padding: 12px 16px; margin: 12px auto 10px; }
  .result-student-row { font-size: .92rem; }
  .result-student-value { font-size: 1rem; }
  .score-number { font-size: 2.2rem; }
  .result-label { font-size: 1.3rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 12px 8px; }
  .stat-number { font-size: 1.5rem; }

  /* --- Review cards --- */
  .review-body { padding: 12px; }
  .review-header { padding: 9px 12px; font-size: .8rem; flex-wrap: wrap; }
  .review-question { font-size: .9rem; margin-bottom: 10px; }
  .review-option { padding: 7px 10px; font-size: .84rem; }
  .review-answers { gap: 6px; }
  .explanation { padding: 10px 12px; font-size: .83rem; }

  /* --- Stats page --- */
  .history-table { font-size: .8rem; }
  .history-table th, .history-table td { padding: 8px 8px; }

  /* --- iOS auto-zoom prevention (inputs must be ≥16px) --- */
  input, select, textarea { font-size: 1rem; }

  /* --- Safe area insets for notch/home-bar devices --- */
  @supports (padding: env(safe-area-inset-left)) {
    .site-header {
      padding-left: max(14px, env(safe-area-inset-left));
      padding-right: max(14px, env(safe-area-inset-right));
    }
    .container {
      padding-left: max(10px, env(safe-area-inset-left));
      padding-right: max(10px, env(safe-area-inset-right));
    }
    .submit-area {
      padding-bottom: calc(18px + env(safe-area-inset-bottom));
    }
  }
}

@media (max-width: 400px) {
  .hero h1 { font-size: 1.65rem; letter-spacing: -.02em; }
  .hero-badge { font-size: .72rem; padding: 4px 12px; }
  .level-badge { font-size: 2rem; }
  .score-circle { width: 110px; height: 110px; }
  .score-number { font-size: 1.9rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 14px; }
  .option-label { padding: 12px 10px; font-size: .88rem; }
  /* Q-tracker dots nhỏ hơn chút trên màn siêu nhỏ */
  .q-dot { width: 28px; height: 28px; border-radius: 6px; font-size: .72rem; }
  .q-tracker { gap: 3px; }
  /* Feature grid: 1 cột ở màn rất nhỏ */
  .feature-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  /* Random card: ẩn deco emoji */
  .random-level-card::before { display: none; }
}

/* ===== TOUCH OPTIMIZATIONS ===== */
.btn,
.nav-toggle,
.fab-top,
.section-nav-btn,
.review-filter-btn,
.q-dot,
.btn-start {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.option-label,
.level-card {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ===== SAFE AREA (notch / home bar) ===== */
@supports (padding: env(safe-area-inset-left)) {
  .site-header {
    padding-left: max(30px, env(safe-area-inset-left));
    padding-right: max(30px, env(safe-area-inset-right));
  }
  .exam-header {
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
  }
}

/* ===== IMAGES IN QUESTIONS & OPTIONS ===== */

/* Ảnh minh họa trong câu hỏi – không giới hạn chiều cao */
.q-image {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  border-radius: 8px;
  border: 1px solid #ddd;
  margin: 0 auto 12px;
  /* KHÔNG dùng max-height vì sẽ cắt mất chữ trong ảnh */
}

/* Ảnh trong đáp án */
.opt-image {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  border-radius: 6px;
  border: 1px solid #ddd;
  margin-top: 6px;
  /* Không giới hạn max-height – để ảnh hiện đầy đủ */
}

/* Khi đáp án chứa ảnh: canh lên đầu để ảnh không bị đẩy lệch */
.option-label:has(.opt-image) {
  align-items: flex-start;
}
/* Fallback cho trình duyệt chưa hỗ trợ :has() */
.option-label.has-img {
  align-items: flex-start;
}

/* Mobile: ảnh chiếm toàn bộ chiều rộng, không bị tràn viền */
@media (max-width: 600px) {
  .q-image {
    width: 100%;
    border-radius: 6px;
  }
  .opt-image {
    width: 100%;
    border-radius: 4px;
    margin-top: 8px;
  }
}

/* ===== SUBMIT AREA ===== */
.submit-area {
  text-align: center;
  padding: 30px 0;
}
.submit-area .warning-text {
  color: var(--warning);
  font-size: .88rem;
  margin-bottom: 16px;
}

/* ===== SECTION DIVIDER ===== */
.section-divider {
  border: none;
  border-top: 2px dashed var(--gray-200);
  margin: 24px 0;
}

/* Alert */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: .9rem;
}
.alert-warning { background: var(--warning-light); color: var(--warning); border-left: 4px solid var(--warning); }
.alert-info    { background: var(--primary-light); color: var(--primary-dark); border-left: 4px solid var(--primary); }
.alert-success { background: var(--success-light); color: var(--success); border-left: 4px solid var(--success); }
.alert-danger  { background: var(--danger-light); color: var(--danger); border-left: 4px solid var(--danger); }

/* ===== MATCHING QUESTION — Exam & Result ===== */
.mt-corner-label {
  display: block; font-size: .72rem; font-weight: 700; color: #3949ab; line-height: 1.3;
}
.mt-col-cap { font-size: .68rem; font-weight: 600; color: #5c6bc0; display: block; line-height: 1.2; }
.mt-sub { font-size: .68rem; font-weight: 500; color: #5c6bc0; }

.matching-table-wrap { overflow-x: auto; margin: 12px 0 4px; }
.matching-table {
  width: 100%; border-collapse: collapse;
  font-family: 'Noto Sans JP','Be Vietnam Pro',sans-serif;
  font-size: .9rem; background: white;
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
}
.matching-table thead tr:first-child { background: #e8f0fe; }
.matching-table thead tr:nth-child(2) { background: #f0f4ff; }
.mt-col-head {
  text-align: center; padding: 8px 6px; font-weight: 700;
  color: #1a237e; border: 1px solid #c5cae9; min-width: 40px;
}
.mt-vn-head { padding: 8px 10px; border: 1px solid #c5cae9; min-width: 130px; }
.mt-jp-label-head {
  padding: 7px 10px; font-size: .78rem; font-weight: 700;
  color: #3949ab; border: 1px solid #c5cae9; background: #f5f7ff;
}
.mt-jp-word {
  text-align: center; padding: 8px 6px;
  font-family: 'Noto Sans JP',sans-serif; font-size: .92rem; font-weight: 600;
  border: 1px solid #c5cae9; color: #1a237e; background: #f5f7ff;
}
.mt-row { transition: background .15s; }
.mt-row:hover { background: #f8f9ff; }
.mt-row:nth-child(even) { background: #fcfcff; }
.mt-row:nth-child(even):hover { background: #f0f4ff; }
.mt-vn-cell {
  padding: 10px 12px; border: 1px solid #e0e0e0;
  font-weight: 500; color: #333; white-space: nowrap;
}
.mt-radio-cell { text-align: center; padding: 8px 4px; border: 1px solid #e0e0e0; }
.mt-radio-cell input[type=radio] {
  width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary);
}
.mt-hint { font-size: .78rem; color: #546e7a; margin-top: 10px; text-align: center; line-height: 1.45; padding: 0 4px; }

/* Matching result display */
.matching-result-table .mt-cell-user-correct { background: #e8f5e9; font-size: 1rem; }
.matching-result-table .mt-cell-user-wrong   { background: #ffebee; font-size: 1rem; }
.matching-result-table .mt-cell-should-be    { background: #fff8e1; font-size: 1rem; font-weight: 700; }
.matching-result-table .mt-row-correct .mt-vn-cell { border-left: 3px solid #0f9d58; }
.matching-result-table .mt-row-wrong .mt-vn-cell   { border-left: 3px solid #d32f2f; }
.matching-result-table .mt-row-correct { background: #f1faf3; }
.matching-result-table .mt-row-wrong   { background: #fff5f5; }

/* type badge Matching */
.type-badge.type-matching { background: #e3f2fd; color: #0d47a1; }


/* ===== SITE COPYRIGHT FOOTER ===== */
/* Mặc định: nền navy (body gradient) → chữ trắng */
.site-copyright {
  text-align: center;
  padding: 14px 16px;
  margin-top: 32px;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.65);
  border-top: 1px solid rgba(255,255,255,0.2);
}
.site-copyright a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
}
.site-copyright a:hover {
  text-decoration: underline;
  color: #fff;
}
/* Khi nằm trong vùng nội dung sáng màu → chữ xám */
.container .site-copyright,
.public-card .site-copyright,
.exam-wrap .site-copyright,
.result-wrap .site-copyright,
.stats-wrap .site-copyright,
.change-pw-wrap .site-copyright,
main .site-copyright {
  color: #aaa;
  border-top-color: #e5e7eb;
}
.container .site-copyright a,
.public-card .site-copyright a,
.exam-wrap .site-copyright a,
main .site-copyright a {
  color: #2563eb;
}
/* Admin layout: footer bên trong main content */
.admin-main .site-copyright {
  margin-top: 40px;
  color: #b0b8c1;
  border-top-color: #e2e8f0;
}
