/* TOEIC Buổi Tối — kiểm tra, làm đề, năng lực, ôn điểm yếu. [v-tests]
   Chỉ chứa class tiền tố tests-; màu lấy hết từ token của css/app.css nên chạy ở cả hai theme.
   Mục lục: 1 chung · 2 trung tâm kiểm tra · 3 trước và trong khi làm đề · 4 kết quả · 5 biểu đồ (#stats) · 6 ôn điểm yếu. */

/* ───────────────────────── 1. Chung ───────────────────────── */
.tests-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
.tests-actions .btn-lg { flex: 1 1 220px; max-width: 360px; }
.tests-end { padding-top: var(--s2); border-top: 1px solid var(--line); }
.tests-hint { color: var(--muted); font-size: var(--fs-sm); max-width: 68ch; }
.tests-fine { color: var(--muted); font-size: var(--fs-sm); max-width: 72ch; }
.tests-notes { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); max-width: 68ch; }
.tests-notes li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s3); align-items: start; }
.tests-notes .icon { margin-top: 5px; color: var(--ok-ink); }
.tests-callout-body { display: grid; gap: var(--s2); }
.tests-async { display: grid; gap: var(--s3); min-width: 0; }
.tests-wait { display: grid; gap: var(--s3); max-width: 420px; }

/* ───────────────────────── 2. Trung tâm kiểm tra (#tests) ───────────────────────── */
.tests-today { background: var(--brand-soft); border-color: transparent; }
.tests-today-text { max-width: 62ch; }
/* hàng của một bài: [icon] [tên + mô tả] [trạng thái] [mũi tên]; ở màn hình hẹp trạng thái xuống dòng dưới tên bài */
.tests-row { grid-template-columns: auto minmax(0, 1fr) auto; }
.tests-row-go { grid-column: 3; grid-row: 1; }
.tests-row.has-end { gap: 6px var(--s3); }
.tests-row.has-end .list-ico { grid-row: 1 / span 2; align-self: start; margin-top: 2px; }
.tests-row.has-end .tests-row-end { grid-column: 2; grid-row: 2; justify-self: start; }
.tests-row.has-end .tests-row-go { grid-row: 1 / span 2; }
@media (min-width: 600px) {
  .tests-row.has-end { grid-template-columns: auto minmax(0, 1fr) auto auto; gap: var(--s3); }
  .tests-row.has-end .list-ico { grid-row: auto; align-self: center; margin-top: 0; }
  .tests-row.has-end .tests-row-end { grid-column: 3; grid-row: 1; justify-self: end; }
  .tests-row.has-end .tests-row-go { grid-column: 4; grid-row: 1; }
}
.tests-best { color: var(--muted); }
.tests-best b { font-size: var(--fs-lg); color: var(--ink); }

/* lịch sử kết quả: bảng thật; ở màn hình hẹp mỗi dòng gập thành 2 hàng để khỏi cuộn ngang */
.tests-hist-box { display: grid; gap: var(--s2); }
.tests-hist-name a { display: inline-flex; align-items: center; min-height: 40px; font-weight: 600; color: var(--ink); text-decoration: none; }
.tests-hist-name a:hover { color: var(--brand); text-decoration: underline; }
.tests-hist-mode { display: block; font-size: var(--fs-xs); color: var(--muted); }
.tests-hist-date { white-space: nowrap; color: var(--muted); }
.tests-hist-res { white-space: nowrap; }
@media (max-width: 599px) {
  .tests-hist-wrap { overflow-x: visible; }
  .tests-hist, .tests-hist tbody { display: block; }
  .tests-hist thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .tests-hist tr { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 2px var(--s3); align-items: baseline; padding: 10px var(--s4); border-top: 1px solid var(--line); }
  .tests-hist tbody tr:first-child { border-top: 0; }
  .tests-hist td, .tests-hist thead + tbody tr:first-child td { display: block; padding: 0; border: 0; }
  .tests-hist .is-num { text-align: left; }
  .tests-hist-name { grid-column: 1 / 4; grid-row: 1; min-height: 28px; }
  .tests-hist-name a { padding-block: 4px; }
  .tests-hist-res { grid-column: 4; grid-row: 1; }
  .tests-hist-date, .tests-hist-l, .tests-hist-r { grid-row: 2; font-size: var(--fs-sm); color: var(--muted); }
  .tests-hist-l::before, .tests-hist-r::before { content: attr(data-label) " "; }
  .tests-hist td.is-none, .tests-hist thead + tbody tr:first-child td.is-none { display: none; }
}

/* ───────────────────────── 3. Trước và trong khi làm đề ───────────────────────── */
.tests-intro { display: grid; gap: var(--s5); grid-template-columns: minmax(0, 1fr); min-width: 0; }
.tests-facts { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); padding: var(--s3) var(--s4); border-radius: var(--r-lg); background: var(--sunken); }
.tests-facts .stat-value { font-size: var(--fs-xl); }
.tests-facts .stat-sub { font-size: var(--fs-xs); }
.tests-mode .seg-label { display: inline-flex; align-items: center; gap: 6px; }
/* nút bắt đầu luôn trong tầm tay: dính đáy khung nhìn cho tới khi cuộn tới vị trí thật của nó (cuối khung intro) */
.tests-start {
  position: sticky; z-index: 5; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  margin-inline: calc(var(--gutter) * -1); padding: var(--s3) var(--gutter); background: var(--bg); border-top: 1px solid var(--line);
}
.tests-start .btn-lg { max-width: none; }
@media (min-width: 900px) {
  .tests-start { bottom: env(safe-area-inset-bottom, 0px); margin-inline: 0; padding-inline: 0; border-top: 0; }
  .tests-start .btn-lg { max-width: 360px; }
}
#tests-structure td:first-child { white-space: nowrap; }   /* "Phần nghe" / "Part 5" không gãy dòng ở 360px */
.tests-resume .card-title { color: var(--ink); }
.tests-last p { margin: 0; }
.tests-runbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 40px; }
.tests-runbar-info { display: inline-flex; align-items: center; gap: var(--s2); min-width: 0; }
.tests-runbar-step { font-size: var(--fs-sm); color: var(--muted); font-weight: 500; }

/* ───────────────────────── 4. Kết quả ───────────────────────── */
.tests-score { gap: var(--s4); }
.tests-score-row { display: grid; gap: var(--s4); grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.tests-score-total { grid-column: 1 / -1; order: -1; }
.tests-stat-text .stat-value { font-size: var(--fs-xl); line-height: 1.3; }
.tests-score-note { max-width: 68ch; }
.tests-gains { display: flex; flex-wrap: wrap; gap: var(--s2); }
.tests-week-head { display: flex; align-items: center; gap: var(--s4) var(--s5); flex-wrap: wrap; }
.tests-week-main { display: grid; gap: var(--s2); justify-items: start; min-width: 0; }
.tests-week-score { font-size: var(--fs-lg); }
.tests-week-score .num { font-size: var(--fs-2xl); }
@media (min-width: 640px) {
  .tests-score-row { grid-template-columns: 1.25fr 1fr 1fr; }
  .tests-score-total { grid-column: auto; }
}

.tests-parts { gap: var(--s3); }
.tests-part { display: grid; gap: 2px var(--s4); grid-template-columns: minmax(0, 1fr); align-items: center; }
.tests-part-name { display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap; min-width: 0; }
.tests-part-topic { font-size: var(--fs-sm); color: var(--muted); }
.tests-part .bar-val { min-width: 11ch; }
@media (min-width: 640px) { .tests-part { grid-template-columns: minmax(0, 290px) minmax(0, 1fr); } }   /* đủ cho "Nền tảng nghe · Số, từ và câu ngắn" trên một dòng */

.tests-weak-item { grid-template-columns: auto minmax(0, 1fr) auto; }

.tests-pace { gap: var(--s4); }
.tests-pace-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: var(--s2) var(--s3); align-items: center; }
.tests-pace-name { font-weight: 600; }
.tests-pace-track { position: relative; height: 14px; border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--sunken); }
.tests-pace-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--sk-r); }
.tests-pace-std { position: absolute; top: -6px; bottom: -6px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--ink); }
.tests-pace-val { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tests-pace-val b { color: var(--ink); }
.tests-pace-verdict { grid-column: 2 / -1; }
@media (min-width: 720px) {
  .tests-pace-row { grid-template-columns: 56px minmax(0, 1fr) auto minmax(150px, auto); }
  .tests-pace-verdict { grid-column: auto; }
}

.tests-wrong { gap: var(--s3); }
.tests-wrong-group { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s2); align-items: start; }
.tests-wrong-part { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.tests-wrong-nums { display: flex; flex-wrap: wrap; gap: 6px; }
.tests-qnum {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border-radius: 50%;
  border: 1.5px solid var(--bad); background: var(--bad-soft); color: var(--bad-ink);
  font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums;
}
.tests-qnum:hover { background: var(--surface); }
.tests-qnum.is-blank { border-style: dashed; border-color: var(--line-strong); background: none; color: var(--ink); }
@media (min-width: 640px) { .tests-wrong-group { grid-template-columns: 110px minmax(0, 1fr); } .tests-wrong-part { padding-top: 10px; } }

.tests-advice { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s4); }
.tests-advice-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s3); align-items: start; }
.tests-advice-n {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--line-strong);
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-sm);
}
.tests-advice-body { display: grid; gap: var(--s1); justify-items: start; max-width: 68ch; }
.tests-advice-body .btn { margin-left: calc(var(--s3) * -1); }

/* ───────────────────────── 5. Biểu đồ (#stats) ───────────────────────── */
.tests-grid2 { display: grid; gap: var(--s5); grid-template-columns: minmax(0, 1fr); align-items: start; }
.tests-grid2 > * { min-width: 0; }
@media (min-width: 760px) { .tests-grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.tests-fig { align-content: start; }
/* biểu đồ chưa có số liệu: một dòng "cần làm gì", không chiếm cả màn hình */
.tests-todo { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s3); align-items: start; }
.tests-todo-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md); background: var(--sunken); color: var(--muted); }
.tests-todo-body { display: grid; gap: 2px; max-width: 62ch; }
.tests-todo-title { font-weight: 600; }
.tests-todo-text { font-size: var(--fs-sm); color: var(--muted); }
.tests-fig-empty .tests-actions { margin-left: 36px; }   /* chữ của nút thẳng hàng với phần chữ bên trên */
.tests-fig-note { color: var(--muted); font-size: var(--fs-sm); max-width: 72ch; }
.tests-plot { width: 100%; min-width: 0; line-height: 0; }
.tests-svg { display: block; overflow: visible; }
.tests-ax { font-family: var(--font-ui); font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.tests-ax-strong { font-family: var(--font-ui); font-size: 12px; font-weight: 500; fill: var(--ink); font-variant-numeric: tabular-nums; }
.tests-val { font-family: var(--font-ui); font-size: 12.5px; font-weight: 600; fill: var(--ink); font-variant-numeric: tabular-nums; }
.tests-grid { stroke: var(--line); stroke-width: 1; }
.tests-base { stroke: var(--line-strong); stroke-width: 1; }
.tests-target { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 5 4; opacity: 0.75; }
.tests-line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tests-dot { fill: var(--brand); stroke: var(--surface); stroke-width: 2; }
.tests-dot-hot { pointer-events: none; }
.tests-mock { fill: var(--mark); stroke: var(--on-mark); stroke-width: 1.5; }
.tests-cross { stroke: var(--line-strong); stroke-width: 1; pointer-events: none; }
.tests-std { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
rect.tests-hit:not(.tests-cell) { fill: transparent; }
.tests-hit { touch-action: pan-y; }
.tests-col-l { fill: var(--sk-l); }
.tests-col-r { fill: var(--sk-r); }
.tests-seg { fill: var(--sk-v); stroke: var(--surface); stroke-width: 1.5px; }   /* viền tách ba nhóm: không chỉ dựa vào độ đậm nhạt (theme tối tương phản thấp) */
.tests-seg-learning { fill-opacity: 0.6; }
.tests-seg-fresh { fill-opacity: 0.32; }
.tests-slot:hover .tests-col, .tests-slot:hover .tests-seg { filter: brightness(1.14) saturate(1.1); }
.tests-cell { stroke: none; }
.tests-cell-0 { fill: var(--sunken); }
.tests-cell-1 { fill: var(--brand); fill-opacity: 0.3; }
.tests-cell-2 { fill: var(--brand); fill-opacity: 0.52; }
.tests-cell-3 { fill: var(--brand); fill-opacity: 0.76; }
.tests-cell-4 { fill: var(--brand); }
.tests-cell.is-future { fill: none; stroke: var(--line); stroke-width: 1; }
.tests-cell.is-today { stroke: var(--ink); stroke-width: 2; }
.tests-cell:hover { stroke: var(--ink); stroke-width: 1.5; }

.tests-legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); font-size: var(--fs-sm); color: var(--muted); }
.tests-key { display: inline-flex; align-items: center; gap: 6px; }
.tests-swatch { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 3px; }
.tests-swatch-line { width: 18px; height: 2px; border-radius: 1px; background: var(--brand); }
.tests-swatch-target { width: 18px; height: 0; border-radius: 0; border-top: 2px dashed var(--ink); opacity: 0.75; }
.tests-swatch-mock { width: 9px; height: 9px; border-radius: 0; margin-inline: 2px; background: var(--mark); outline: 1.5px solid var(--on-mark); transform: rotate(45deg); }
.tests-swatch-std { width: 2px; height: 14px; border-radius: 1px; background: var(--ink); }
.tests-swatch-l { background: var(--sk-l); }
.tests-swatch-r { background: var(--sk-r); }
.tests-swatch-mastered { background: var(--sk-v); }
.tests-swatch-learning { background: var(--sk-v); opacity: 0.6; }
.tests-swatch-fresh { background: var(--sk-v); opacity: 0.32; }
.tests-swatch-c0 { background: var(--sunken); box-shadow: inset 0 0 0 1px var(--line); }
.tests-swatch-c1 { background: var(--brand); opacity: 0.3; }
.tests-swatch-c2 { background: var(--brand); opacity: 0.52; }
.tests-swatch-c3 { background: var(--brand); opacity: 0.76; }
.tests-swatch-c4 { background: var(--brand); }
.tests-swatch-today { background: none; box-shadow: inset 0 0 0 2px var(--ink); }

.tests-tip {
  position: fixed; z-index: 45; left: 0; top: 0; pointer-events: none; max-width: min(260px, calc(100vw - 16px));
  padding: var(--s2) var(--s3); border-radius: var(--r-md); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); line-height: 1.35;
}
.tests-tip[hidden] { display: none; }
.tests-tip-t, .tests-tip-x { font-size: var(--fs-xs); color: var(--muted); }
.tests-tip-v { font-size: var(--fs-md); font-weight: 700; font-variant-numeric: tabular-nums; }

.tests-data > summary {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; cursor: pointer; list-style: none;
  color: var(--brand); font-size: var(--fs-sm); font-weight: 500; border-radius: var(--r-sm);
}
.tests-data > summary::-webkit-details-marker { display: none; }
.tests-data > summary:hover { text-decoration: underline; }
.tests-data[open] > summary { margin-bottom: var(--s2); }

.tests-skills { display: grid; gap: var(--s3); }
.tests-skill { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; align-items: center; gap: var(--s3); min-height: 36px; }
.tests-skill-none { font-size: var(--fs-sm); color: var(--muted); }
.tests-skill-n { min-width: 62px; text-align: right; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.tests-cal { display: grid; gap: var(--s5); grid-template-columns: minmax(0, 1fr); align-items: start; }
.tests-plot-cal { max-width: 400px; }
.tests-streak { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }
@media (min-width: 760px) { .tests-cal { grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: var(--s7); } }

/* ───────────────────────── 6. Ôn điểm yếu (#review) ───────────────────────── */
.tests-weak-list { display: grid; gap: var(--s3); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 760px) { .tests-weak-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tests-weak-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2) var(--s3); flex-wrap: wrap; }
.tests-weak-title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 700; line-height: var(--lh-tight); }
.tests-lesson { display: inline-flex; align-items: flex-start; gap: var(--s2); min-height: 40px; padding-block: 8px; color: var(--brand); font-size: var(--fs-sm); font-weight: 500; text-decoration: none; border-radius: var(--r-sm); }
a.tests-lesson:hover { text-decoration: underline; }
.tests-lesson.is-later { color: var(--muted); font-weight: 400; }
.tests-lesson .icon { margin-top: 4px; }
.tests-missed-item { cursor: pointer; }
.tests-missed-stem { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-weight: 500; }
.tests-word { grid-template-columns: auto minmax(0, 1fr) auto; }
.tests-word-audio { display: inline-flex; }
.tests-word-w { font-weight: 600; }
.tests-word-ipa { margin-left: var(--s2); }

@media (prefers-reduced-motion: reduce) {
  .tests-slot:hover .tests-col, .tests-slot:hover .tests-seg { filter: none; }
}
