/* ============================================
   AECK TSA Practice — Stylesheet v2
   Theo screenshot AECK gốc:
   - Header đỏ AECK + tên đề
   - Layout 2 cột: câu hỏi (trái) + sidebar info+grid (phải)
   - Question số trong circle ở trái, bookmark cờ ở phải
   - Sidebar: Họ tên/Mã + Timer + Nộp bài + Indicator + Grid 8x5
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700&family=Newsreader:ital,wght@0,500;0,700;1,500&display=swap');

:root {
  --aeck-red: #c8102e;
  --aeck-red-dark: #a30d24;
  --aeck-red-light: #fee2e6;
  --primary: #1d4ed8;
  --primary-2: #2563eb;
  --primary-light: #dbeafe;
  --warn: #f59e0b;
  --warn-light: #fef3c7;
  --success: #16a34a;
  --success-light: #dcfce7;
  --danger: #dc2626;
  --danger-light: #fee2e2;

  --ink: #1a1a1a;
  --ink-muted: #525252;
  --ink-dim: #9a9a9a;
  --bg: #f7f7f5;
  --card: #ffffff;
  --border: #e5e5e5;
  --border-strong: #d1d1d1;
  --border-dashed: #cccccc;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 2px 8px rgba(0,0,0,.06);

  --font-display: "Newsreader", Georgia, serif;
  --font-body: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; height: auto; }
button { font-family: inherit; cursor: pointer; }

/* ========== TOPBAR (home/history/result) ========== */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  position: sticky; top: 0; z-index: 50;
}
.topbar .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -.5px;
  color: var(--aeck-red);
}
.topbar .brand small { color: var(--ink-muted); font-family: var(--font-body); font-size: 11px; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; }
.topbar .nav { margin-left: auto; display: flex; gap: 22px; }
.topbar .nav a {
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 14px;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
}
.topbar .nav a.active { color: var(--ink); border-bottom-color: var(--aeck-red); }
.topbar .nav a:hover { color: var(--ink); text-decoration: none; }

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* ========== HOME ========== */
.hero { padding: 32px 0 22px; }
.hero h1 {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -1px;
  margin: 0 0 8px;
}
.hero h1 em { color: var(--aeck-red); font-style: italic; }
.hero p { color: var(--ink-muted); margin: 0; max-width: 640px; }

.stats { display: flex; gap: 22px; margin: 18px 0 28px; flex-wrap: wrap; }
.stat {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; flex: 1; min-width: 180px;
}
.stat .label { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-dim); margin-bottom: 4px; }
.stat .value { font-size: 26px; font-weight: 700; line-height: 1; font-family: var(--font-display); }
.stat .value small { font-size: 14px; color: var(--ink-muted); font-weight: 500; }

.subject-section { margin-top: 28px; }
.subject-section h2 {
  font-family: var(--font-display); font-size: 22px; margin: 0 0 14px;
  display: flex; align-items: baseline; gap: 10px;
}
.subject-section h2 small {
  font-family: var(--font-body); font-size: 13px; font-weight: 500; color: var(--ink-dim);
}

.exam-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px;
}
.exam-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 8px;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.exam-card:hover {
  text-decoration: none; transform: translateY(-2px);
  box-shadow: var(--shadow); border-color: var(--border-strong);
}
.exam-card .title { font-weight: 600; line-height: 1.35; color: var(--ink); }
.exam-card .meta { font-size: 13px; color: var(--ink-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.exam-card .badge-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 99px; font-weight: 600;
  background: var(--primary-light); color: var(--primary); letter-spacing: .2px;
}
.badge.done { background: var(--success-light); color: var(--success); }
.badge.best { background: var(--warn-light); color: #92400e; }

/* ============================================
   EXAM PAGE — match giao diện AECK
   ============================================ */

/* Top bar: logo AECK đỏ + tên đề ở giữa */
.aeck-bar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  position: sticky; top: 0; z-index: 30;
}
.aeck-bar .aeck-logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  color: var(--aeck-red);
  letter-spacing: -.5px;
  flex-shrink: 0;
}
.aeck-bar .exam-title-bar {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}
.aeck-bar .exam-title-bar .code {
  color: var(--aeck-red);
  font-weight: 700;
  margin-left: 14px;
  letter-spacing: .4px;
}
.aeck-bar .exit-link {
  margin-left: auto;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 500;
}

/* Body padding-bottom để chừa chỗ cho sticky footer */
body.exam-page { padding-bottom: 64px; }

/* Layout 2 cột: nội dung trái + sidebar phải (full width, không bị bó hẹp) */
.exam-shell {
  display: grid;
  grid-template-columns: 1fr 340px;
  margin: 0;
  padding: 16px 20px;
  gap: 20px;
  align-items: start;
}

/* Passage mode: ẩn sidebar inline, chỉ hiện khi mở drawer */
.exam-shell.is-passage {
  grid-template-columns: 1fr;
}
.exam-shell.is-passage .exam-side {
  /* Trở thành drawer trượt từ phải */
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 360px;
  max-width: 92vw;
  z-index: 90;
  border-radius: 0;
  border-top: 0; border-bottom: 0; border-right: 0;
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform .25s ease;
  overflow-y: auto;
  padding-top: 22px;
}
.exam-shell.is-passage .exam-side.open {
  transform: translateX(0);
  box-shadow: -8px 0 30px rgba(0,0,0,.12);
}
.exam-shell.is-passage .side-close { display: flex; }

/* Backdrop khi drawer mở */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(20,20,20,.35);
  z-index: 85;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}
.drawer-backdrop.open { opacity: 1; visibility: visible; }

.side-close {
  display: none;
  position: absolute;
  top: 8px; right: 12px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #f4f4f0;
  align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink-muted);
  user-select: none;
}
.side-close:hover { background: var(--danger-light); color: var(--danger); }

.exam-content {
  background: transparent;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 180px);
}

.page-view {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
  flex: 1;
}
.exam-shell.is-passage .page-view {
  padding: 18px 20px;
}

/* ========== Question block (1 câu hỏi) ========== */
.q-block {
  position: relative;
  padding: 4px 0;
}
.q-block + .q-block {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.q-row {
  display: grid;
  grid-template-columns: 44px 1fr 36px;
  gap: 14px;
  align-items: flex-start;
}

.q-circle {
  width: 30px; height: 30px;
  border: 1.5px solid var(--ink-muted);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  color: var(--ink);
  font-size: 13px;
  background: #fff;
  margin-top: 1px;
}

.q-content {
  font-size: 15px;
  line-height: 1.65;
  min-width: 0;
}
.q-content img { border-radius: var(--radius-sm); margin: 8px 0; max-width: 100%; }

/* ===== TABLE STYLES =====
 * AECK lưu bảng ở 3 dạng:
 *   - <table class="word-table"> (paste từ MS Word)
 *   - <figure class="table"><table><tbody>... (CKEditor 5)
 *   - <table> trần (được wrap trong .table-scroll bởi formatContent)
 * Bọc trong scroll container để không tràn ra ngoài cột passage.
 */
.table-scroll,
.q-content figure.table,
.passage-content figure.table {
  margin: 12px 0;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  display: block;
}
.table-scroll table {
  margin: 0;
}
.q-content table,
.passage-content table {
  border-collapse: collapse;
  border: 1px solid #999;
  background: #fff;
  margin: 12px 0;
  font-size: 14px;
  line-height: 1.45;
}
.q-content figure.table > table,
.passage-content figure.table > table {
  margin: 0;
  min-width: 100%;
}
.q-content table td,
.q-content table th,
.passage-content table td,
.passage-content table th {
  border: 1px solid #bbb;
  padding: 8px 12px;
  vertical-align: middle;
  word-break: normal;
  white-space: normal;
  min-width: 40px;
  text-align: left;
}
.q-content table th,
.passage-content table th {
  background: #fafafa;
  font-weight: 600;
}
.q-content table p,
.passage-content table p {
  margin: 0;
}
/* Table có <br/> ở cuối mỗi cell (do paste từ Word) → kill br dư trong cell */
.q-content table td > br:last-child,
.q-content table th > br:last-child,
.passage-content table td > br:last-child,
.passage-content table th > br:last-child {
  display: none;
}
.q-content table img,
.passage-content table img {
  margin: 4px auto;
  display: block;
  border-radius: 4px;
  max-width: 100%;
}
/* MS Word table — header row (first row) thường là tiêu đề */
.q-content table.word-table tr:first-child td,
.passage-content table.word-table tr:first-child td {
  background: #fafafa;
  font-weight: 600;
}

.q-bookmark {
  width: 32px; height: 32px;
  background: transparent;
  border: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-dim);
  border-radius: var(--radius-sm);
  transition: all .12s;
  padding: 0;
  position: relative;
}
.q-bookmark:hover { color: var(--warn); background: var(--warn-light); }
.q-bookmark.active { color: var(--warn); }
.q-bookmark svg { width: 20px; height: 20px; fill: currentColor; }

/* ========== TN — trắc nghiệm 1 chọn ========== */
.opt-list {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.opt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 4px 0;
  cursor: pointer;
  transition: all .12s;
  border-radius: var(--radius-sm);
}
.opt:hover .opt-mark { border-color: var(--primary); }
.opt-mark {
  width: 22px; height: 22px;
  border: 1.5px solid var(--ink-dim);
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  margin-top: 2px;
  transition: all .12s;
}
.opt-mark::after {
  content: '';
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary-2);
  opacity: 0;
  transition: opacity .12s;
}
.opt.selected .opt-mark { border-color: var(--primary-2); }
.opt.selected .opt-mark::after { opacity: 1; }

.opt-content { flex: 1; min-width: 0; }

/* MA — chọn nhiều: checkbox vuông */
.opt.ma .opt-mark { border-radius: 4px; }
.opt.ma .opt-mark::after {
  width: 12px; height: 12px;
  border-radius: 2px;
  background: var(--primary-2);
}
.opt.ma.selected .opt-mark {
  background: var(--primary-2);
  border-color: var(--primary-2);
}
.opt.ma.selected .opt-mark::after {
  width: 6px; height: 12px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  background: transparent;
  border-radius: 0;
  transform: rotate(45deg) translate(-1px,-1px);
  opacity: 1;
}

/* ========== TLN — Trả lời ngắn ========== */
.tln-row {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.tln-label {
  font-weight: 500;
  color: var(--ink-muted);
}
.tln-input {
  border: 0;
  border-bottom: 1.5px solid var(--ink-dim);
  padding: 4px 8px;
  font: inherit;
  background: transparent;
  min-width: 140px;
  text-align: center;
}
.tln-input:focus { outline: none; border-bottom-color: var(--primary-2); }

/* Inline blank trong nội dung câu TLN_M */
.tln-inline {
  display: inline-block;
  border: 0;
  border-bottom: 1.5px solid var(--ink-dim);
  padding: 0 8px;
  margin: 0 3px;
  min-width: 80px;
  max-width: 200px;
  font: inherit;
  background: transparent;
  text-align: center;
  vertical-align: baseline;
}
.tln-inline:focus { outline: none; border-bottom-color: var(--primary-2); background: var(--primary-light); }

/* ========== DS — Đúng/Sai (bảng) ========== */
.ds-wrap { margin-top: 14px; }
.ds-head {
  display: grid;
  grid-template-columns: 1fr 60px 60px;
  align-items: center;
  padding: 4px 12px 8px;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 600;
}
.ds-head > :nth-child(2),
.ds-head > :nth-child(3) { text-align: center; }
.ds-row {
  display: grid;
  grid-template-columns: 1fr 60px 60px;
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.ds-row > .stmt { padding-right: 14px; }
.ds-row > .ds-cell { display: flex; justify-content: center; }
.ds-pick {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-dim);
  background: #fff;
  cursor: pointer;
  transition: all .12s;
  position: relative;
  padding: 0;
}
.ds-pick:hover { border-color: var(--primary); }
.ds-pick.selected {
  background: var(--primary-2);
  border-color: var(--primary-2);
  box-shadow: inset 0 0 0 3.5px #fff;
}

/* ========== KT — Kéo thả ========== */
.kt-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 14px;
  min-height: 56px;
  align-items: center;
}
.kt-chips:empty::before {
  content: 'Tất cả thẻ đã được dùng';
  color: var(--ink-dim);
  font-size: 13px;
  font-style: italic;
}
.kt-chip {
  background: #fff;
  border: 1px solid var(--border-strong);
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: grab;
  user-select: none;
  transition: all .12s;
  font-size: 14px;
}
.kt-chip:hover {
  border-color: var(--primary-2);
  box-shadow: 0 1px 3px rgba(37,99,235,.18);
}
.kt-chip.selected {
  background: var(--primary-2);
  color: #fff;
  border-color: var(--primary-2);
}
.kt-chip.used {
  opacity: .3;
  pointer-events: none;
  text-decoration: line-through;
}
.kt-chip.dragging { opacity: .4; }
.kt-chip:active { cursor: grabbing; }

.kt-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
  padding: 5px 14px;
  margin: 0 4px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  vertical-align: middle;
  min-height: 30px;
  font-size: 14px;
  transition: all .12s;
  position: relative;
}
.kt-slot:empty::before {
  content: '\00a0\00a0\00a0\00a0';
}
.kt-slot:hover { border-color: var(--primary-2); }
.kt-slot.filled {
  background: var(--primary-light);
  border-color: var(--primary-2);
  color: var(--primary);
  font-weight: 600;
  padding-right: 26px;
}
.kt-slot.filled .kt-clear {
  position: absolute;
  right: 4px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  background: rgba(0,0,0,.08);
  border-radius: 50%;
  border: 0;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-muted);
  padding: 0;
  line-height: 1;
}
.kt-slot.filled .kt-clear:hover { background: rgba(220,38,38,.15); color: var(--danger); }
.kt-slot.drop-target {
  background: var(--warn-light);
  border-color: var(--warn);
  border-style: dashed;
}

/* ========== MQ — Passage split layout ========== */
.passage-page {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.passage-page {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.passage-page .passage-col {
  padding-right: 26px;
  border-right: 1px solid var(--border);
  max-height: calc(100vh - 170px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  min-width: 0;  /* cho phép thu nhỏ khi nội dung lớn */
}
.passage-page .questions-col {
  padding-left: 26px;
  max-height: calc(100vh - 170px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  min-width: 0;
}
.passage-page .questions-col .q-block + .q-block {
  margin-top: 16px;
  padding-top: 16px;
}
.passage-page .passage-intro {
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--ink);
}
.passage-page .passage-content {
  font-size: 14.5px;
  line-height: 1.7;
}
.passage-page .passage-content p { margin: 0 0 10px; }

/* Marker [1], [2], ... trong đoạn văn */
.passage-marker {
  color: var(--primary);
  font-weight: 700;
  margin-right: 4px;
}
/* Tiêu đề tự động (nếu trước [1] có 1 dòng ngắn) */
.passage-title-auto {
  font-weight: 800;
  font-size: 16px;
  color: #111827;
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.4;
  letter-spacing: 0.3px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
/* Markdown image trong câu hỏi */
.qimg-wrap {
  display: flex;
  margin: 10px 0;
}
.qimg-wrap img {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  max-width: 100%;
  height: auto;
}

/* Trong passage page, hàng câu hỏi gọn hơn vì cột hẹp */
.passage-page .q-row {
  grid-template-columns: 34px 1fr 30px;
  gap: 10px;
}
.passage-page .q-circle {
  width: 26px; height: 26px; font-size: 12px;
}
.passage-page .q-content { font-size: 14px; line-height: 1.55; }

/* DS table trong passage: dùng layout vertical compact để không bị bóp */
.passage-page .ds-wrap {
  margin-top: 10px;
}
.passage-page .ds-head {
  grid-template-columns: 1fr 50px 50px;
  padding: 4px 8px 6px;
  font-size: 12px;
}
.passage-page .ds-row {
  grid-template-columns: 1fr 50px 50px;
  padding: 10px 8px;
}
.passage-page .ds-row .stmt {
  padding-right: 8px;
  font-size: 13.5px;
  line-height: 1.5;
}
.passage-page .ds-pick {
  width: 20px; height: 20px;
}

/* Options trong passage: compact hơn */
.passage-page .opt-list { margin-top: 10px; gap: 6px; }
.passage-page .opt-mark { width: 20px; height: 20px; }

/* ========== SIDEBAR ========== */
.exam-side {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: sticky;
  top: 70px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  scrollbar-width: thin;
}
.side-block + .side-block {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.side-h { color: var(--ink); font-weight: 600; font-size: 14px; margin: 0 0 10px; }
.student-info { font-size: 13.5px; color: var(--ink-muted); }
.student-info .row { display: flex; justify-content: space-between; padding: 3px 0; }
.student-info .row b { color: var(--ink); font-weight: 600; }

.time-box {
  display: flex;
  align-items: center;
  gap: 12px;
}
.time-box .time-info {
  flex: 1;
}
.time-box .time-info .lbl {
  font-size: 12px;
  color: var(--ink-muted);
  margin-bottom: 2px;
}
.time-box .time-info .val {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  line-height: 1;
}
.time-box .time-info .val.warning { color: var(--warn); }
.time-box .time-info .val.danger { color: var(--danger); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

.btn-nopbai {
  background: var(--aeck-red);
  color: #fff;
  border: 0;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-sm);
  transition: background .12s;
}
.btn-nopbai:hover { background: var(--aeck-red-dark); }

.indicator-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
}
.indicator-row .lbl {
  font-size: 13.5px;
  color: var(--ink-muted);
  margin-right: 4px;
}
.ind-circle {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ind-circle.unans {
  background: #f2f2f2; color: var(--ink-muted); border: 1px solid var(--border-strong);
}
.ind-circle.ans { background: var(--primary-2); color: #fff; }
.ind-circle.bm { background: #fff; color: var(--warn); border: 1.5px solid var(--warn); }

.qgrid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin-top: 6px;
}
.qbtn {
  width: 100%;
  aspect-ratio: 1;
  border: 1.5px solid var(--border-strong);
  background: #fff;
  border-radius: 50%;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all .1s;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  font-variant-numeric: tabular-nums;
}
.qbtn:hover { border-color: var(--primary-2); }
.qbtn.answered {
  background: var(--primary-2);
  color: #fff;
  border-color: var(--primary-2);
}
.qbtn.current {
  outline: 2px solid var(--primary-2);
  outline-offset: 2px;
}
.qbtn.bookmarked {
  border-color: var(--warn);
  border-width: 2px;
  color: var(--warn);
}
.qbtn.bookmarked.answered {
  background: var(--primary-2);
  color: #fff;
  border-color: var(--warn);
}

/* ========== FOOTER NAV — sticky bottom, luôn cố định ========== */
.page-nav {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 10px 24px;
  background: #fff;
  border-top: 1px solid var(--border);
  border-bottom: 0;
  border-left: 0;
  border-right: 0;
  border-radius: 0;
  margin: 0;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  box-shadow: 0 -2px 8px rgba(0,0,0,.04);
}
.btn-prev, .btn-next {
  border-radius: var(--radius-sm);
  border: 0;
  padding: 10px 22px;
  font-weight: 600;
  font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .12s;
  cursor: pointer;
}
.btn-prev {
  background: #f0f0ed;
  color: var(--ink-muted);
  padding: 10px 18px;
}
.btn-prev:hover { background: #e2e2de; color: var(--ink); }
.btn-prev:disabled, .btn-next:disabled { opacity: .4; cursor: not-allowed; }
.btn-next {
  background: var(--primary-2);
  color: #fff;
}
.btn-next:hover { background: var(--primary); }
.qtime {
  color: var(--ink-muted);
  font-size: 13.5px;
  margin-left: 10px;
}
.qtime b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin-left: 6px;
  font-weight: 700;
}

/* Phần phải của footer — chỉ hiển thị trong passage mode */
.nav-right {
  margin-left: auto;
  display: none;
  gap: 16px;
  align-items: center;
}
body.passage-mode .page-nav .nav-right {
  display: flex;
}
.nav-time {
  color: var(--ink-muted);
  font-size: 13.5px;
}
.nav-time b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin-left: 6px;
  font-weight: 700;
  font-size: 15px;
}
.btn-open-menu {
  background: var(--aeck-red);
  color: #fff;
  border: 0;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background .12s;
}
.btn-open-menu:hover { background: var(--aeck-red-dark); }
.btn-open-menu svg {
  transform: scaleX(-1);
}

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20,20,20,.5);
  display: none; align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 26px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
}
.modal h3 { font-family: var(--font-display); margin: 0 0 12px; font-size: 22px; }
.modal p { margin: 0 0 18px; color: var(--ink-muted); }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border: 0; border-radius: var(--radius-sm); background: var(--primary-2); color: #fff; font-weight: 600; font-size: 14px; transition: all .12s; cursor: pointer; }
.btn:hover { background: var(--primary); }
.btn.outline { background: transparent; border: 1.5px solid var(--border-strong); color: var(--ink); }
.btn.outline:hover { background: #fafafa; border-color: var(--ink-muted); }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }

/* ========== RESULT ========== */
.score-hero {
  background: linear-gradient(135deg, #fff, #fafafa);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin: 22px 0;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 28px;
  align-items: center;
}
.score-ring { width: 180px; height: 180px; position: relative; margin: 0 auto; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring .ring-bg { fill: none; stroke: var(--border); stroke-width: 12; }
.score-ring .ring-fill { fill: none; stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.score-ring .ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-ring .ring-text .big { font-family: var(--font-display); font-size: 44px; font-weight: 700; line-height: 1; }
.score-ring .ring-text .small { color: var(--ink-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .8px; margin-top: 6px; }

.score-breakdown { display: flex; flex-direction: column; gap: 14px; }
.score-row { display: flex; align-items: center; gap: 14px; }
.score-row .name { width: 160px; font-weight: 500; }
.score-row .bar { flex: 1; height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.score-row .bar > div { height: 100%; background: var(--primary-2); }
.score-row .val { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 80px; text-align: right; }

.review-list { display: flex; flex-direction: column; gap: 12px; }
.review-card {
  background: #fff; border: 1px solid var(--border);
  border-left: 4px solid var(--success);
  border-radius: var(--radius); padding: 14px 18px;
}
.review-card.wrong { border-left-color: var(--danger); }
.review-card.unanswered { border-left-color: var(--ink-dim); }
.review-card h4 { margin: 0 0 6px; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.review-card .ans-row { font-size: 14px; margin-top: 6px; }
.review-card .ans-row b { color: var(--success); }
.review-card.wrong .ans-row .your { color: var(--danger); }
.review-card details { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.review-card details summary { cursor: pointer; color: var(--primary); font-weight: 500; }
.review-card .explain { margin-top: 8px; background: var(--warn-light); border-left: 3px solid var(--warn); padding: 8px 12px; border-radius: var(--radius-sm); }

.history-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.history-table th, .history-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.history-table th { background: #fafafa; font-weight: 600; color: var(--ink-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.history-table tr:last-child td { border-bottom: 0; }
.history-table tr:hover td { background: #fafafa; }
.history-table .score-pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-weight: 600; font-size: 13px; background: var(--success-light); color: var(--success); }
.history-table .score-pill.low { background: var(--danger-light); color: var(--danger); }
.history-table .score-pill.mid { background: var(--warn-light); color: #92400e; }

.empty-state {
  background: #fff; border: 1px dashed var(--border-strong);
  border-radius: var(--radius); padding: 50px 30px; text-align: center;
  color: var(--ink-muted);
}
.empty-state h3 { font-family: var(--font-display); color: var(--ink); margin: 0 0 8px; }
.empty-state code { background: #f0f0ed; padding: 2px 6px; border-radius: 4px; font-size: 13px; }

/* ========== RESPONSIVE ========== */
@media (max-width: 1100px) {
  /* Single mode dùng drawer luôn ở mobile */
  .exam-shell { grid-template-columns: 1fr; }
  .exam-shell .exam-side {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 340px;
    max-width: 92vw;
    z-index: 90;
    border-radius: 0;
    border-top: 0; border-bottom: 0; border-right: 0;
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform .25s ease;
    overflow-y: auto;
    padding-top: 22px;
    max-height: 100vh;
  }
  .exam-shell .exam-side.open {
    transform: translateX(0);
    box-shadow: -8px 0 30px rgba(0,0,0,.12);
  }
  .exam-shell .side-close { display: flex; }
  /* Hiện nút mở menu trong footer khi ở mobile */
  body.exam-page .nav-right { display: flex; }

  .passage-page { grid-template-columns: 1fr; }
  .passage-page .passage-col {
    border-right: 0; border-bottom: 1px solid var(--border);
    padding-right: 0; padding-bottom: 16px; margin-bottom: 16px;
    max-height: 45vh;
  }
  .passage-page .questions-col { padding-left: 0; max-height: none; }
  .score-hero { grid-template-columns: 1fr; text-align: center; }
}
@media (max-width: 640px) {
  .aeck-bar { padding: 10px 14px; gap: 10px; }
  .aeck-bar .aeck-logo { font-size: 22px; }
  .aeck-bar .exam-title-bar { font-size: 13px; }
  .aeck-bar .exit-link { display: none; }
  .container { padding: 12px; }
  .exam-shell { padding: 10px; }
  .page-view { padding: 14px 16px; }
  .q-row { grid-template-columns: 32px 1fr 28px; gap: 10px; }
  .q-circle { width: 26px; height: 26px; font-size: 12px; }
  .qgrid { grid-template-columns: repeat(8, 1fr); }
  .hero h1 { font-size: 26px; }
  .page-nav { padding: 8px 12px; gap: 8px; }
  .btn-prev, .btn-next { padding: 8px 12px; font-size: 13px; }
  .qtime { display: none; }
  .nav-time { font-size: 12px; }
}
