/* ===================== Tokens ===================== */
:root {
  --paper: #f6f5f1; --card: #ffffff; --ink: #18212f; --ink-2: #3c475a; --muted: #6b7486; --line: #e3e1da; --line-2: #d3d0c7;
  --brand: #1f3a5f; --brand-2: #2c5282; --brand-soft: #e8eef6; --brand-ink: #ffffff;
  --mock: #a0561b; --mock-soft: #fbf0e4;
  --ok: #17663a; --ok-soft: #e8f5ec; --bad: #b42318; --bad-soft: #fdeceb; --warn: #9a5b00; --warn-soft: #fdf3dc;
  --radius: 12px; --shadow: 0 1px 2px rgba(20, 30, 50, .05), 0 4px 16px rgba(20, 30, 50, .04);
  --sans: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12161d; --card: #1a2029; --ink: #e8ebf0; --ink-2: #c3c9d4; --muted: #8d96a6; --line: #2a313c; --line-2: #3a4250;
    --brand: #8fb4e8; --brand-2: #a9c6ef; --brand-soft: #1f2b3c; --brand-ink: #0f1520;
    --mock: #e6a466; --mock-soft: #2e2418;
    --ok: #6fcf97; --ok-soft: #16281d; --bad: #f28b82; --bad-soft: #2e1a19; --warn: #f2c26b; --warn-soft: #2e2615;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .tiny { font-size: 12.5px; } .mono { font-family: ui-monospace, Consolas, monospace; }
.center { text-align: center; justify-content: center; }
.bad-text { color: var(--bad); }
.row { display: flex; align-items: center; } .gap { gap: 10px; } .wrap { flex-wrap: wrap; } .between { justify-content: space-between; } .grow { flex: 1; min-width: 160px; }
.page { max-width: 1120px; margin: 0 auto; padding: 24px 16px 80px; }

/* ===================== Controls ===================== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 9px;
  padding: 9px 16px; font: 600 14.5px var(--sans); cursor: pointer; background: var(--brand); color: var(--brand-ink); white-space: nowrap; transition: filter .15s, background .15s; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.btn.ghost { background: transparent; color: var(--brand-2); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn.big { padding: 14px 22px; font-size: 16px; }
.btn.block { display: flex; width: 100%; margin-top: 18px; }
.btn.warn { background: var(--warn); color: #fff; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn.sm.danger:not(.ghost) { background: var(--bad); color: #fff; }
.btn.google { background: var(--card); color: var(--ink); border-color: var(--line-2); padding: 12px 20px; width: 100%; font-size: 15px; }
.input { width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--card); color: var(--ink); font: 15px var(--sans); outline: none; }
.input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
.input.search { max-width: 300px; }
.input.code { font-family: ui-monospace, Consolas, monospace; letter-spacing: .12em; text-transform: uppercase; text-align: center; font-size: 17px; }
textarea.input { resize: vertical; line-height: 1.55; }
select.input { cursor: pointer; }
.lbl { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: var(--ink-2); }
.check { display: flex; gap: 8px; align-items: center; margin: 10px 0; cursor: pointer; font-size: 14px; }
.form > * + * { margin-top: 10px; }
.form h3 { margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.flush { padding: 0; overflow-x: auto; }
.card .pad { padding: 16px 20px 6px; }
.card.empty { text-align: center; color: var(--muted); padding: 40px; }
.error-card { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.note { margin-top: 14px; padding: 10px 12px; background: var(--brand-soft); border-radius: 9px; font-size: 13.5px; color: var(--ink-2); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--brand-soft); color: var(--brand-2); vertical-align: middle; }
.pill.mock { background: var(--mock-soft); color: var(--mock); }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.teacher { background: var(--brand); color: var(--brand-ink); }
.loading { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 40px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line-2); border-top-color: var(--brand-2); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(92vw, 440px); }
.toast { background: var(--ink); color: var(--paper); padding: 11px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.18); transition: opacity .4s, transform .4s; }
.toast.ok { background: var(--ok); color: #fff; } .toast.error { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ===================== Gate ===================== */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.gate-card { width: min(100%, 440px); background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow); text-align: center; }
.gate-card h2 { margin-top: 18px; }
.gate-body { color: var(--ink-2); margin: 10px 0 20px; text-align: left; }
.gate-card .tiny { margin-top: 18px; }
.brand { font-weight: 700; color: var(--brand); letter-spacing: -.02em; font-size: 18px; }
.brand.big { font-size: 30px; }
.code-form { display: flex; gap: 8px; margin-top: 14px; }

/* ===================== Shell ===================== */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 24px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.nav a:hover { background: var(--brand-soft); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav .admin-link { color: var(--mock); }
.me { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.me:hover { text-decoration: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.avatar.sm { width: 26px; height: 26px; font-size: 12px; }
.me-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
body.exam-mode .top { display: none; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 0; }
.back { display: inline-block; margin-bottom: 12px; font-weight: 500; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 14px; font: 600 14.5px var(--sans); color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.chips button { border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2); border-radius: 99px; padding: 4px 12px; font: 500 13px var(--sans); cursor: pointer; }
.chips button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.cols .card { margin: 0; }
.cols + .card, .card + .cols { margin-top: 16px; }

/* ===================== Library ===================== */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.tcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.tcard:hover { border-color: var(--line-2); transform: translateY(-1px); }
.tcard.mock { border-top: 3px solid var(--mock); }
.tcard-top { display: flex; justify-content: space-between; align-items: center; }
.tcard h3 { font-size: 16px; margin: 0; flex: 1; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.tcard-foot { display: flex; justify-content: space-between; align-items: center; border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 2px; }
.best { font-weight: 600; color: var(--ok); font-size: 13.5px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table.small td { padding: 6px 8px; font-size: 13px; }
.table .r { text-align: right; white-space: nowrap; }
.table tr.link { cursor: pointer; } .table tr.link:hover td { background: var(--brand-soft); }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 16px 0; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; }
.devices, .plain { list-style: none; padding: 0; margin: 0; }
.devices li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.devices li .row { margin-top: 6px; }
.plain li { padding: 5px 0; }

/* ===================== Exam ===================== */
.exam-bar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); margin: -24px -16px 20px; }
.exam-bar-in { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 14px; align-items: center; }
.exam-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; padding: 5px 12px; border-radius: 8px; background: var(--card); border: 1px solid var(--line-2); }
.timer.low { color: var(--bad); border-color: var(--bad); background: var(--bad-soft); }
.instr { background: var(--brand-soft); border-radius: 9px; padding: 10px 14px; margin-bottom: 14px; font-size: 14.5px; color: var(--ink-2); }
.sec { margin-bottom: 34px; }
.sec-title { font-size: 1.15rem; padding-bottom: 8px; border-bottom: 2px solid var(--brand); display: inline-block; margin-bottom: 12px; }
.audio { margin-bottom: 14px; } .audio audio { width: 100%; }
.passage { font: 16.5px/1.75 var(--serif); text-align: justify; hyphens: auto; }
.passage p:first-child { margin-top: 0; } .passage p:last-child { margin-bottom: 0; }
@media (min-width: 980px) {
  .sec.split .sec-body { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
  .sec.split .passage { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; margin: 0; }
}
.q { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; }
.q-head { display: flex; gap: 10px; align-items: flex-start; }
.num { flex: none; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 15px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.q-text { flex: 1; padding-top: 3px; }
.q-text p:first-child { margin-top: 0; }
.pts { flex: none; font-size: 12px; color: var(--muted); padding-top: 5px; }
.q > .input, .q > select, .q > textarea { margin-top: 10px; }
.opts { display: grid; gap: 6px; margin-top: 10px; }
.opts.inline { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; transition: background .12s; }
.opt:hover { background: var(--brand-soft); }
.opt:has(input:checked) { border-color: var(--brand-2); background: var(--brand-soft); font-weight: 500; }
.opt input { margin-top: 5px; accent-color: var(--brand-2); }
.err-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.arrow { color: var(--muted); }
.input.writing { font: 16px/1.7 var(--serif); min-height: 260px; }
.wc { text-align: right; margin-top: 4px; }
.q.ok { border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.q.bad { border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.q.partial, .q.review { border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.fb { margin-top: 10px; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.fb.ok { background: var(--ok-soft); color: var(--ok); } .fb.bad { background: var(--bad-soft); color: var(--bad); }
.fb.partial, .fb.review { background: var(--warn-soft); color: var(--warn); }
.fb-head { font-weight: 700; }
.fb .why { color: var(--ink-2); margin-top: 4px; }
.only-wrong .q.ok, .only-wrong .q.review { display: none; }
.only-wrong .sec:not(:has(.q.bad, .q.partial)) { display: none; }

.result-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.result-head h1, .result-head h2 { margin: 4px 0 10px; }
.score-big { text-align: center; } .score-big b { font-size: 44px; color: var(--brand); line-height: 1; } .score-big span { font-size: 20px; color: var(--muted); margin-left: 4px; }
.result-actions { margin-bottom: 20px; }

/* ===================== Forum ===================== */
.threads { list-style: none; margin: 0; padding: 0; }
.thread { display: flex; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--line); cursor: pointer; }
.thread:last-child { border-bottom: 0; }
.thread:hover { background: var(--brand-soft); }
.t-main { flex: 1; min-width: 0; } .t-title { font-weight: 600; margin-bottom: 3px; }
.t-stats { display: flex; flex-direction: column; align-items: flex-end; min-width: 80px; }
.threads .empty { padding: 30px; text-align: center; color: var(--muted); list-style: none; }
.thread-head h1 { margin: 6px 0 10px; }
.admin-bar { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.post { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; }
.post.is-hidden { opacity: .55; border-style: dashed; }
.post-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.post-body { white-space: normal; overflow-wrap: anywhere; }
.post-actions { display: flex; gap: 12px; margin-top: 6px; }
.post-actions button { background: none; border: 0; padding: 0; color: var(--muted); font: 13px var(--sans); cursor: pointer; }
.post-actions button:hover { color: var(--brand-2); }

/* ===================== Admin ===================== */
.admin-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.admin-tabs a { padding: 6px 12px; border-radius: 8px; color: var(--ink-2); font-size: 14px; font-weight: 500; }
.admin-tabs a.on { background: var(--brand); color: var(--brand-ink); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; color: var(--ink); }
.tile:hover { text-decoration: none; border-color: var(--brand-2); }
.tile b { font-size: 30px; color: var(--brand); } .tile span { color: var(--muted); font-size: 13.5px; }
.tile.warn { border-color: var(--warn); background: var(--warn-soft); } .tile.warn b { color: var(--warn); }
.log { margin: 0; padding-left: 22px; font-size: 14px; } .log li { padding: 3px 0; }
.answer-box { margin: 10px 0 6px; padding: 10px 12px; border-radius: 8px; background: var(--paper); border: 1px solid var(--line); }
.answer-box.writing-ans { font: 16px/1.7 var(--serif); white-space: pre-wrap; }
.grade-row { margin-top: 10px; } .grade-row label { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.pts-in { width: 80px; }
details summary { cursor: pointer; font-weight: 600; margin: 20px 0 10px; }

/* ===================== Protection ===================== */
body.protected { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.protected .input, body.protected .allow-copy { -webkit-user-select: text; user-select: text; }
#watermark { position: fixed; inset: 0; pointer-events: none; z-index: 60; background-repeat: repeat; }
@media (prefers-color-scheme: dark) { #watermark { filter: invert(1); } }
#shield { position: fixed; inset: 0; z-index: 70; display: none; place-items: center; text-align: center; padding: 24px; cursor: pointer;
  background: color-mix(in srgb, var(--paper) 94%, transparent); font-size: 16px; }
#shield.show { display: grid; }
body.away #view { filter: blur(10px); }
/* Printing: only the picture copy made by the "In đề" button can be printed */
#printArea, #printStage .p-foot { display: none; }
#printStage { position: absolute; left: -10000px; top: 0; background: #fff; color: #111; }
.p-block { width: 720px; padding: 6px 4px; background: #fff; color: #111; font: 15px/1.55 "Source Serif 4", Georgia, "Times New Roman", serif; }
.p-block h1 { font: 700 21px/1.3 "Be Vietnam Pro", sans-serif; margin: 4px 0; }
.p-block h2 { font: 700 16px/1.3 "Be Vietnam Pro", sans-serif; margin: 14px 0 4px; border-bottom: 1.5px solid #111; padding-bottom: 3px; }
.p-site { font: 600 12px "Be Vietnam Pro", sans-serif; letter-spacing: .08em; text-transform: uppercase; color: #555; }
.p-meta { font-size: 13px; color: #444; }
.p-fill { display: flex; gap: 18px; margin-top: 10px; font-size: 13px; }
.p-instr { font-style: italic; margin: 4px 0; }
.p-note { font-size: 13px; color: #555; }
.p-list { margin: 6px 0; padding: 6px 10px; border: 1px solid #999; }
.p-passage { text-align: justify; } .p-passage p { margin: 0 0 6px; }
.p-q { display: flex; gap: 8px; }
.p-num { min-width: 28px; }
.p-qbody { flex: 1; }
.p-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.p-opts.four { grid-template-columns: repeat(4, 1fr); }
.p-tf, .p-err { color: #333; }
.p-blank { color: #333; }
.p-line { border-bottom: 1px dotted #555; height: 26px; }
@media print {
  @page { size: A4; margin: 12mm; }
  body:not(.printing) * { display: none !important; }
  body:not(.printing)::after { content: "Hãy dùng nút \"🖨 In đề\" trong trang làm bài để in."; display: block; padding: 40px; }
  body.printing > *:not(#printArea) { display: none !important; }
  body.printing { background: #fff !important; }
  body.printing #printArea { display: block !important; }
  #printArea img { display: block; width: 100%; break-inside: avoid; page-break-inside: avoid; margin: 0 0 4px; }
  #printArea .p-foot { display: block !important; position: fixed; bottom: 0; left: 0; right: 0; font: 9px sans-serif; color: #666; text-align: center; }
}

@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .top-in { gap: 10px; } .me-name { display: none; }
  .exam-bar-in { gap: 8px; flex-wrap: wrap; } #progress { display: none; }
  .err-row { flex-direction: column; align-items: stretch; } .arrow { display: none; }
  .input.search { max-width: none; }
  .thread { flex-direction: column; gap: 4px; } .t-stats { flex-direction: row; gap: 6px; align-items: baseline; }
  .code-form { flex-direction: column; }
}

/* ===================== Payments ===================== */
.gate-card.wide { width: min(100%, 620px); }
.gate-sub { font-size: 15px; margin: 22px 0 10px; text-align: left; }
.span2 { grid-column: 1 / -1; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.plan { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 18px 12px 14px;
  border: 1.5px solid var(--line-2); border-radius: 12px; background: var(--card); color: var(--ink); cursor: pointer; font-family: var(--sans); transition: border-color .15s, transform .15s; }
.plan:hover { border-color: var(--brand-2); transform: translateY(-1px); }
.plan:disabled { opacity: .6; }
.plan-note { position: absolute; top: -10px; background: var(--mock); color: #fff; font-size: 11.5px; font-weight: 600; padding: 1px 9px; border-radius: 99px; }
.plan-name { font-weight: 600; }
.plan-price { font-size: 22px; font-weight: 700; color: var(--brand); }
.checkout { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; text-align: left; }
.qr { width: 100%; border-radius: 10px; background: #fff; border: 1px solid var(--line); }
.pay-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 10px 0; font-size: 14.5px; }
.pay-dl dt { color: var(--muted); } .pay-dl dd { margin: 0; }
.pay-code { font-family: ui-monospace, Consolas, monospace; font-size: 18px; letter-spacing: .06em; color: var(--mock); }
.link-btn { background: none; border: 0; padding: 0 0 0 6px; color: var(--brand-2); font: 600 12.5px var(--sans); cursor: pointer; }
.pay-status { display: flex; gap: 10px; align-items: center; margin: 14px 0; padding: 10px 12px; border-radius: 9px; background: var(--paper); font-size: 14px; }
.ok-text { color: var(--ok); }
.warn-card { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
@media (max-width: 640px) { .checkout { grid-template-columns: 1fr; } .qr-col { max-width: 260px; margin: 0 auto; } }

/* ===================== Free tier, diamonds, ads ===================== */
.gems { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 99px; background: var(--brand-soft); color: var(--ink); font-size: 14px; white-space: nowrap; }
.gems:hover { text-decoration: none; filter: brightness(.97); }
.gem { margin-right: 2px; }
.premium-btn { background: linear-gradient(135deg, #c98a1b, #e0a93b); color: #1d1405; border: 0; }
.premium-btn:hover { filter: brightness(1.05); }
.pill.premium { background: linear-gradient(135deg, #c98a1b, #e0a93b); color: #1d1405; }
.top-up { padding: 4px 10px; }
.wallet { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 14px 18px; }
.wallet-gems { font-size: 26px; font-weight: 700; line-height: 1.1; }
.wallet-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.locked { border-style: dashed; }
.ad-wrap { position: relative; margin: 0 0 16px; min-height: 90px; text-align: center; }
.ad-label { position: absolute; top: -9px; left: 8px; font-size: 10.5px; color: var(--muted); background: var(--paper); padding: 0 4px; }
.house-ad { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 0 0 16px; padding: 12px 16px; border-radius: var(--radius);
  border: 1px dashed #d1a34a; background: color-mix(in srgb, #e0a93b 10%, var(--card)); color: var(--ink); font-size: 14px; }
.house-ad:hover { text-decoration: none; border-style: solid; }
.house-ad b { color: #a26c0c; } .house-cta { margin-left: auto; font-weight: 600; color: var(--brand-2); }
@media (prefers-color-scheme: dark) { .house-ad b { color: #e6b45a; } }
body.exam-mode .ad-wrap, body.exam-mode .house-ad, body.exam-mode .google-auto-placed, body.exam-mode ins.adsbygoogle { display: none !important; }

.modal-back { position: fixed; inset: 0; z-index: 90; background: rgba(10, 15, 25, .55); display: grid; place-items: center; padding: 16px; }
.modal { width: min(100%, 440px); background: var(--card); border-radius: 16px; padding: 24px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h3 { margin: 10px 0; }
.ad-step { display: flex; gap: 10px; align-items: center; justify-content: center; min-height: 48px; margin: 10px 0 16px; color: var(--ink-2); }
.popup-score b { font-size: 40px; color: var(--brand); margin: 0 4px; } .popup-score span { color: var(--muted); }
.popup-score .tiny { display: block; }
.perks { list-style: none; padding: 0; margin: 12px 0 18px; text-align: left; display: inline-block; }
.perks li { padding: 3px 0; }
.close-later { display: block; margin: 16px auto 0; color: var(--muted); }
.close-later:disabled { cursor: default; opacity: .6; }

.unlock, .locked-box { text-align: center; padding: 32px 24px; }
.unlock-icon { font-size: 34px; }
.unlock-more { margin: 18px 0; }
.compare-wrap { margin-bottom: 18px; }
.compare td, .compare th { text-align: left; }
.compare .pcol { background: color-mix(in srgb, #e0a93b 9%, transparent); font-weight: 500; }

/* ===================== Highlighter (test page) ===================== */
body.protected .hl-zone { -webkit-user-select: text; user-select: text; }
.hl-zone::selection, .hl-zone *::selection { background: #bcd4ff; }
mark.hl { background: #ffe86b; color: inherit; border-radius: 2px; padding: 0 1px; cursor: pointer; }
mark.hl.hl-g { background: #b9f0c5; }
@media (prefers-color-scheme: dark) { mark.hl { background: #8a7400; } mark.hl.hl-g { background: #2f6b3c; } }
#hlBar { position: absolute; z-index: 80; display: flex; gap: 4px; padding: 4px; border-radius: 10px; background: var(--ink); box-shadow: 0 6px 20px rgba(0,0,0,.2); }
#hlBar[hidden] { display: none; }
#hlBar button { border: 0; border-radius: 7px; padding: 6px 10px; font: 600 13px var(--sans); cursor: pointer; background: #ffe86b; color: #1d1405; }
#hlBar button[data-c="g"] { background: #b9f0c5; }

/* ===================== Leaderboard & bundles ===================== */
.table.lb .rank { width: 48px; font-size: 18px; }
.table.lb tr.me-row td { background: var(--brand-soft); font-weight: 600; }
.lb-me { padding: 12px 16px; }
.table td.empty { text-align: center; color: var(--muted); padding: 28px; }
.pill.bundle { background: #e7f3ff; color: #155b9b; }
@media (prefers-color-scheme: dark) { .pill.bundle { background: #18324b; color: #9cc8f2; } }
.plan-desc { color: var(--ink-2); text-align: center; margin-top: 2px; }

/* ===================== YouTube listening ===================== */
.video { position: relative; width: 100%; max-width: 760px; aspect-ratio: 16 / 9; margin: 0 0 14px; border-radius: 12px; overflow: hidden; background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Per-test access: free trial / Premium-only */
.acc-sel { width: auto; min-width: 150px; padding: 4px 8px; font-size: .85rem; }
.acc-sel.acc-free { border-color: var(--ok); color: var(--ok); }
.acc-sel.acc-paid { border-color: #c98a1b; color: #a26a06; }
.pill.trial { background: #fdeee0; color: #b4530b; }
.pill.paid { background: #fbf1d9; color: #8a5a00; }
@media (prefers-color-scheme: dark) { .pill.trial { background: #4a2a12; color: #f7b98a; } .pill.paid { background: #3d2f10; color: #f0cd7a; } }
.tcard.is-locked h3 { opacity: .75; }

/* Batch import */
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center; display: grid; gap: 10px; transition: background .15s, border-color .15s; }
.dropzone.over { border-color: var(--brand-2); background: var(--brand-soft); }
.drop-title { font-weight: 600; }
.table-wrap { overflow-x: auto; }
tr.bad-row td { background: rgba(200, 40, 40, .05); }
.progress { height: 8px; border-radius: 4px; background: rgba(127, 127, 127, .2); overflow: hidden; margin: 6px 0; }
.progress span { display: block; height: 100%; background: var(--brand-2); transition: width .2s; }
.progress.done span { background: var(--ok); }

/* Answer key editor */
.key-card { padding: 14px 16px; margin-bottom: 10px; }
.key-card .q-head { display: flex; gap: 10px; align-items: flex-start; }
.key-card .q-text { flex: 1; }
.key-chips, .stu-ans { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.key-chip, .ans-chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 99px; padding: 3px 10px; font-size: 13.5px; border: 1px solid var(--line); }
.key-chip { background: var(--ok-soft); color: var(--ok); border-color: transparent; font-weight: 600; }
.ans-chip.wrong { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.ans-chip.pending { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.ans-chip.right { color: var(--ok); }
.ans-chip b { font-weight: 600; opacity: .8; }
.sec-h { margin: 22px 0 8px; }

/* Difficulty + ratings */
.diff { display: inline-flex; align-items: center; gap: 2px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.diff i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }
.diff i.off { opacity: .22; }
.diff i:last-of-type { margin-right: 4px; }
.diff.d1 { color: #2e8b57; } .diff.d2 { color: #6a9a1f; } .diff.d3 { color: #c98a1b; } .diff.d4 { color: #d0602a; } .diff.d5 { color: #c0392b; }
@media (prefers-color-scheme: dark) { .diff.d1 { color: #6fcf97; } .diff.d2 { color: #a8d468; } .diff.d3 { color: #f2c46d; } .diff.d4 { color: #f49b6a; } .diff.d5 { color: #ff8a80; } }
.stars-sm { color: #d49b00; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.lib-tools { margin: -6px 0 14px; }
.lib-tools .input { width: auto; padding: 6px 10px; font-size: 14px; }
.rate-card h3 { margin-top: 0; }
.rate-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.rate-row .lbl { min-width: 120px; margin: 0; }
.star-pick button { background: none; border: 0; font-size: 28px; line-height: 1; padding: 0 2px; color: var(--line-2); cursor: pointer; }
.star-pick button.on { color: #f0b400; }
.diff-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.diff-pick button { border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2); border-radius: 99px; padding: 4px 12px; font: 500 13px var(--sans); cursor: pointer; }
.diff-pick button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.diff-sel { width: auto; min-width: 120px; padding: 4px 8px; font-size: .85rem; }

/* Pagination */
.pager-wrap:empty { display: none; }
#pagerTop { margin: -4px 0 10px; text-align: right; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 22px 0 8px; }
.pager .pg { min-width: 38px; height: 38px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--card);
  color: var(--ink); font: 600 14px var(--sans); cursor: pointer; }
.pager .pg:hover:not(:disabled):not(.on) { border-color: var(--brand); color: var(--brand); }
.pager .pg.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); cursor: default; }
.pager .pg:disabled { opacity: .35; cursor: default; }
.pager .pg-gap { color: var(--muted); padding: 0 2px; }
.pager .pg-info { margin-left: 8px; font-size: 13px; color: var(--muted); }
.pager .pg-size { width: auto; padding: 6px 8px; font-size: 13px; }
@media (max-width: 560px) { .pager .pg { min-width: 34px; height: 34px; padding: 0 6px; } .pager .pg-info { width: 100%; text-align: center; margin: 4px 0 0; } }

/* Explanations: Vietnamese / English */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--card); color: var(--ink-2); padding: 6px 12px; font: 600 13px var(--sans); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--brand); color: var(--brand-ink); }
.why-tag { display: none; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .7; margin-bottom: 2px; }
.expl-both .why-tag { display: block; }
.expl-vi .why.lang-en, .expl-en .why.lang-vi { display: none; }
#view:not(.expl-vi):not(.expl-en):not(.expl-both) .why.lang-en { display: none; }
.expl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0; }
@media (max-width: 700px) { .expl-grid { grid-template-columns: 1fr; } }

/* Multi-select in the tests table */
.sel-table .selcell { width: 44px; text-align: center; cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none; }
.sel-table .selcell input { pointer-events: none; width: 17px; height: 17px; }
.sel-table thead .selcell input { pointer-events: auto; }
.sel-table tr.selected td { background: var(--brand-soft); }
.selbar { position: sticky; top: 8px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 10px 0;
  padding: 10px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--brand); box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.selbar-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.selbar .input { width: auto; padding: 5px 8px; font-size: 13px; }

/* Sổ câu sai */
.nb-tools { margin: 4px 0 14px; align-items: center; }
.nb-tools .input { width: auto; padding: 6px 10px; font-size: 14px; }
.nb-tiles { margin-bottom: 12px; }
.nb-card { padding: 14px 16px; margin-bottom: 12px; transition: opacity .3s; }
.nb-card.done { opacity: .55; }
.nb-card .q { border: 0; padding: 6px 0; margin: 0; background: none; box-shadow: none; }
.nb-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 4px; }
.nb-ctx { margin: 4px 0 8px; }
.nb-ctx .passage { max-height: 320px; overflow: auto; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-top: 6px; font-size: 15px; }
.nb-fb { margin-top: 8px; }
.streak { display: inline-flex; gap: 3px; margin-left: 6px; vertical-align: middle; }
.streak i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--ok); display: inline-block; }
.streak i.on { background: var(--ok); }
.empty-nb { padding: 30px 16px; }
.big-emoji { font-size: 40px; }

/* Thống kê */
.page-head .seg { margin-top: 6px; }
.chart-wrap { position: relative; }
.line-chart { width: 100%; height: auto; display: block; overflow: visible; }
.line-chart .grid { stroke: var(--line); stroke-width: 1; }
.line-chart .ax { fill: var(--muted); font: 11px var(--sans); }
.line-chart .line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line-chart .dot { fill: var(--brand); stroke: var(--card); stroke-width: 2; }
.line-chart .hit { fill: transparent; cursor: pointer; }
.line-chart .pt.on .dot, .line-chart .pt:focus .dot { r: 6.5; }
.line-chart .pt:focus { outline: none; }
.chart-tip { position: absolute; transform: translate(-50%, -100%); background: var(--card); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 6px 10px; font-size: 12.5px; line-height: 1.4; box-shadow: 0 6px 16px rgba(0,0,0,.12); pointer-events: none; white-space: nowrap; color: var(--ink); }
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; align-items: center; gap: 10px; font-size: 14px; }
.hb-name a { color: var(--ink); }
.hb-track { height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; }
.hb-fill { display: block; height: 100%; background: var(--brand); border-radius: 0 4px 4px 0; }
.hb-val { white-space: nowrap; font-size: 13px; }
.warn-pill { background: var(--warn-soft); color: var(--warn); font-size: 11px; }
@media (max-width: 560px) { .hbar { grid-template-columns: 1fr auto; } .hb-track { grid-column: 1 / -1; order: 3; } }
.tiles + .card, .tiles + section, .tiles + .cols { margin-top: 14px; }
.hbar { grid-template-columns: minmax(110px, 36%) 1fr 116px; }
.hb-val { text-align: right; }
@media (max-width: 560px) { .hbar { grid-template-columns: 1fr auto; } }

/* Gói bài – student shop */
.bshop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
@media (max-width: 400px) { .bshop-grid { grid-template-columns: 1fr; } }
.bshop { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.bshop h3 { margin: 0; }
.chips.static { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.static .chip { font-size: 12.5px; padding: 3px 10px; border-radius: 99px; background: var(--brand-soft); color: var(--ink-2); }
.bplans { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; margin-top: 6px; }
.bplan { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px 10px; border-radius: 12px;
  border: 1.5px solid var(--line-2); background: var(--card); color: var(--ink); cursor: pointer; font: inherit; }
.bplan:hover { border-color: var(--brand); }
.bplan.best { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.bp-days { font-size: 13px; color: var(--ink-2); }
.bp-price { font-size: 18px; font-weight: 700; }
.bplan .plan-note { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); white-space: nowrap; }
.bundle-hint { display: inline-block; margin-top: 2px; }
.note-card { background: var(--brand-soft); border-color: transparent; }
/* admin price table */
.price-tbl input.input { padding: 5px 8px; font-size: 14px; }
.price-tbl td:nth-child(1) input { width: 80px; }
.price-tbl td:nth-child(2) input { width: 120px; }
.price-tbl td:nth-child(4) { text-align: center; }
.chips.static { margin-bottom: 0; }
#shopBox + section { margin-top: 14px; }
.bshop > p:first-of-type { font-size: 15px; color: var(--ink-2); margin: 2px 0; }

/* Bundle list + one-bundle editor */
.bundle-list td { vertical-align: middle; }
.bundle-list .nowrap { white-space: nowrap; }
.bundle-list .btn.sm { padding: 3px 9px; }
.bundle-nav { margin-bottom: 12px; align-items: center; }
.bundle-nav .input { width: auto; max-width: 260px; padding: 5px 10px; font-size: 14px; }
.bundle-edit { align-items: start; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; max-height: 340px; overflow: auto; }
.cat-grid .check { margin: 0; font-size: 14px; }
.tests-in { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
#inList { max-height: 260px; overflow: auto; line-height: 1.7; }
.savebar { position: sticky; bottom: 0; z-index: 5; margin-top: 12px; padding: 12px 16px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 -4px 14px rgba(0,0,0,.06); align-items: center; }
#dirty { color: var(--warn); }
.price-tbl { width: 100%; }
.price-tbl th, .price-tbl td { padding-left: 4px; padding-right: 4px; }
.price-tbl td:nth-child(1) input { width: 64px; }
.price-tbl td:nth-child(2) input { width: 104px; }
.price-tbl td:nth-child(3) input { width: 100%; min-width: 100px; }
.price-tbl td:nth-child(1) { white-space: nowrap; }
.locked-why { background: var(--warn-soft); color: var(--ink-2); border-radius: 8px; padding: 6px 10px; }
.partial-note { margin: 10px 0; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px 12px; margin: 6px 0 10px; }
.type-pick { font-size: .92em; }
.nowrap { white-space: nowrap; }
