/* Phòng thi – Thầy Quyền Math
   Cùng chất liệu với Toán Lab: tường xanh nhạt, giấy thi trắng, không bo góc.
   Mực tím là phần học sinh viết, bút đỏ là phần thầy chấm. */
:root {
  color-scheme: light;
  --wall: #E8EEE3;
  --paper: #FFFFFF;
  --paper-2: #FBFCF8;
  --rule: #DFE9DA;
  --rule-strong: #C2D5BA;
  --ink: #123524;
  --ink-soft: #3E5247;
  --muted: #6B7A70;
  --tim: #4A3A99;
  --do: #C4342C;
  --deep: #0A6A3B;
  --green: #2E8B57;
  --pastel: #9DC46E;
  --mint: #EFF6EA;
  --yellow: #F2C94C;
  --f-body: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-head: "Barlow Condensed", "Be Vietnam Pro", "Arial Narrow", sans-serif;
  --f-hand: "Patrick Hand", "Be Vietnam Pro", "Segoe Print", cursive;
}
* { box-sizing: border-box; }
html { background: var(--wall); }
body {
  margin: 0; color: var(--ink-soft); font-family: var(--f-body); font-size: 16px; line-height: 1.55;
  background: var(--wall);
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 64px max(16px, env(safe-area-inset-left, 0px));
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; color: var(--ink); line-height: 1.15; font-family: var(--f-head); font-weight: 800; text-wrap: balance; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.wrap { max-width: 860px; margin: 0 auto; }
.wide { max-width: 1180px; }

/* ---------- thanh trên ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: .95rem; }
.brand img { width: 38px; height: auto; display: block; }
.brand small { display: block; font-weight: 500; font-size: .76rem; color: var(--ink-soft); }
.who { display: flex; align-items: center; gap: 10px; font-size: .88rem; min-width: 0; }
.who img { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.who .nm { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }

/* ---------- giấy ---------- */
.sheet { background: var(--paper); border: 1px solid var(--rule-strong); box-shadow: 0 1px 0 var(--rule), 0 10px 26px rgba(18, 53, 36, .07); padding: 28px clamp(18px, 4vw, 44px); }
.sheet + .sheet { margin-top: 18px; }
.lead { color: var(--ink-soft); }
.small { font-size: .86rem; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- nút ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 20px; border: 2px solid var(--deep);
  background: var(--deep); color: #fff; font-weight: 700; cursor: pointer; text-decoration: none; border-radius: 0; }
.btn:hover { background: #08592F; }
.btn.ghost { background: transparent; color: var(--deep); }
.btn.ghost:hover { background: var(--mint); }
.btn.warn { background: var(--do); border-color: var(--do); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .86rem; border-width: 1.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, .opt:focus-visible, .tfb:focus-visible, .mv:focus-visible, .cell:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.link { background: none; border: 0; color: var(--deep); text-decoration: underline; cursor: pointer; padding: 6px 2px; font-size: .88rem; }

/* ---------- ô nhập ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; color: var(--ink); font-size: .92rem; }
.field input, .field select { min-height: 48px; padding: 10px 14px; border: 1.5px solid #CBD5CE; background: #fff; border-radius: 0; font-weight: 500; }
.field input:focus { border-color: var(--green); outline: none; }
.err { color: var(--do); font-size: .9rem; min-height: 1.4em; }

/* ---------- trang đăng nhập ---------- */
.gate { display: grid; gap: 22px; padding-top: 6vh; }
.gate h1 { font-size: clamp(2rem, 6vw, 3rem); }
.gate .stamp { display: inline-block; color: var(--do); border: 2px solid currentColor; outline: 1px solid currentColor; outline-offset: 2px;
  padding: 2px 10px; font-weight: 800; font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; transform: rotate(-3deg); width: max-content; }
#gbtn { min-height: 44px; }

/* ---------- danh sách đề ---------- */
.slips { display: grid; gap: 14px; margin-top: 18px; }
.slip { background: var(--paper); border: 1px solid var(--rule-strong); border-left: 6px solid var(--deep); padding: 18px 20px; display: grid; gap: 10px; }
.slip.closed { border-left-color: var(--rule-strong); }
.slip.want { border: 2px solid var(--deep); border-left-width: 6px; box-shadow: 0 0 0 4px var(--mint); }
.slip h3 { font-size: 1.45rem; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .88rem; color: var(--muted); }
.meta b { color: var(--ink); font-weight: 600; }
.mark-score { font-family: var(--f-head); font-weight: 800; color: var(--do); font-size: 1.35rem; line-height: 1; }

/* ---------- đầu bài thi ---------- */
.head { display: grid; grid-template-columns: 1fr 1.3fr; gap: 14px; text-align: center; border-bottom: 1.5px solid var(--ink); padding-bottom: 14px; }
.head .l { font-weight: 700; color: var(--ink); font-size: .86rem; letter-spacing: .04em; text-transform: uppercase; }
.head .l small { display: block; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); }
.head .r h1 { font-size: clamp(1.4rem, 3.6vw, 1.9rem); }
.head .r p { font-size: .9rem; }
.cand { display: flex; flex-wrap: wrap; gap: 6px 26px; padding: 14px 0 4px; font-size: .95rem; }
.cand .hand { font-family: var(--f-hand); color: var(--tim); font-size: 1.3rem; line-height: 1; border-bottom: 1px dotted var(--muted); padding: 0 6px; }
@media (max-width: 560px) { .head { grid-template-columns: 1fr; } }

/* ---------- thanh giờ (dính trên cùng) ---------- */
.clock { position: sticky; top: 0; z-index: 20; background: rgba(232, 238, 227, .96); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; margin-bottom: 12px; border-bottom: 1px solid var(--rule-strong); }
.time { font-family: var(--f-head); font-weight: 800; font-size: 1.7rem; color: var(--ink); border: 2px solid var(--ink); padding: 0 12px; min-width: 104px; text-align: center; font-variant-numeric: tabular-nums; }
.time.low { color: var(--do); border-color: var(--do); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .time.low { animation: none; } }
.prog { font-size: .86rem; color: var(--ink-soft); }
.saved { font-size: .78rem; color: var(--muted); }

/* ---------- câu hỏi ---------- */
.sec { margin-top: 26px; }
.sec h2 { font-size: 1.3rem; }
.sec .note { font-size: .86rem; color: var(--muted); font-style: italic; margin-top: 2px; }
.q { padding: 18px 0; border-bottom: 1px dashed var(--rule-strong); scroll-margin-top: 80px; }
.q:last-child { border-bottom: 0; }
.qt { color: var(--ink); }
.qt .no { font-weight: 800; color: var(--deep); margin-right: 4px; }
.qt .pt { font-size: .78rem; color: var(--muted); font-weight: 500; }
.qimg { display: block; max-width: min(100%, 560px); margin: 12px auto; }

.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; margin-top: 12px; }
@media (max-width: 560px) { .opts { grid-template-columns: 1fr; } }
.opt { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 10px; background: transparent; border: 1px solid transparent; text-align: left; cursor: pointer; border-radius: 0; }
.opt:hover { background: var(--mint); }
.bub { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--ink); display: grid; place-items: center; font-weight: 700; font-size: .9rem; color: var(--ink); }
.opt[aria-checked="true"] .bub { background: var(--tim); border-color: var(--tim); color: #fff; }
.opt[aria-checked="true"] { border-color: var(--rule-strong); background: #F4F2FB; }

.tf { width: 100%; border-collapse: collapse; margin-top: 12px; }
.tf td { border-top: 1px solid var(--rule); padding: 8px 6px; vertical-align: middle; }
.tf td.lt { width: 30px; font-weight: 700; color: var(--ink); }
.tf td.ch { width: 132px; white-space: nowrap; text-align: right; }
.tfb { min-width: 56px; min-height: 40px; border: 1.5px solid var(--ink); background: #fff; cursor: pointer; font-weight: 700; border-radius: 0; }
.tfb + .tfb { margin-left: 6px; }
.tfb[aria-pressed="true"] { background: var(--tim); border-color: var(--tim); color: #fff; }

.gap { display: inline-block; width: 7.5em; min-height: 40px; margin: 2px 4px; padding: 4px 8px; border: 0; border-bottom: 2px solid var(--ink); background: #F7F6FC;
  font-family: var(--f-hand); font-size: 1.3rem; color: var(--tim); text-align: center; border-radius: 0; vertical-align: baseline; }
.gap:focus { outline: none; border-bottom-color: var(--tim); background: #EEEBFA; }

.ord { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.ord li { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--rule-strong); background: var(--paper-2); padding: 6px 8px; }
.ord .k { flex: none; width: 30px; height: 30px; display: grid; place-items: center; background: var(--tim); color: #fff; font-weight: 700; font-size: .85rem; }
.ord .tx { flex: 1; min-width: 0; color: var(--ink); }
.mvs { flex: none; display: flex; flex-direction: column; gap: 4px; }
.mv { width: 44px; height: 34px; border: 1.5px solid var(--ink); background: #fff; cursor: pointer; font-size: 1.1rem; border-radius: 0; }
.mv:disabled { opacity: .3; }

/* ---------- phiếu trả lời (lưới số câu) ---------- */
.card { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cell { width: 40px; height: 40px; border: 1.5px solid var(--ink); background: #fff; font-weight: 700; cursor: pointer; border-radius: 0; font-size: .9rem; }
.cell.done { background: var(--tim); border-color: var(--tim); color: #fff; }
.cell.right { background: var(--deep); border-color: var(--deep); color: #fff; }
.cell.part { background: var(--yellow); border-color: #C9A42A; color: var(--ink); }
.cell.wrong, .cell.blank-r { background: #fff; border-color: var(--do); color: var(--do); }

/* ---------- kết quả (bút đỏ) ---------- */
.score { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; }
.box { border: 2px solid var(--do); color: var(--do); width: 132px; text-align: center; padding: 6px 4px 10px; }
.box small { display: block; font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; border-bottom: 1px solid var(--do); padding-bottom: 4px; margin-bottom: 4px; }
.box .v { font-family: var(--f-head); font-weight: 800; font-size: 3.4rem; line-height: 1; }
.phe { font-family: var(--f-hand); color: var(--do); font-size: 1.35rem; line-height: 1.3; }
.rv { margin-top: 10px; padding: 10px 12px; background: var(--paper-2); border-left: 3px solid var(--rule-strong); font-size: .93rem; }
.rv.right { border-left-color: var(--deep); }
.rv.part { border-left-color: var(--yellow); }
.rv.wrong, .rv.blank { border-left-color: var(--do); }
.rv .tag { font-family: var(--f-hand); font-size: 1.15rem; }
.rv .tag.right { color: var(--deep); } .rv .tag.part { color: #9A7A10; } .rv .tag.wrong, .rv .tag.blank { color: var(--do); }
.ok-ans { color: var(--deep); font-weight: 600; }
.your { color: var(--tim); }
.opt.is-right .bub { background: var(--deep); border-color: var(--deep); color: #fff; }
.opt.is-wrong .bub { background: var(--do); border-color: var(--do); color: #fff; }
.tfb.is-right { background: var(--deep); border-color: var(--deep); color: #fff; }
.tfb.is-wrong { background: var(--do); border-color: var(--do); color: #fff; }
.review .opt, .review .tfb, .review .mv { cursor: default; }

/* ---------- hộp xác nhận ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(18, 53, 36, .45); display: grid; place-items: center; padding: 16px; }
.modal .sheet { max-width: 460px; width: 100%; }
.modal h2 { font-size: 1.5rem; margin-bottom: 8px; }
.modal .row { margin-top: 18px; justify-content: flex-end; }

.notice { border: 1.5px dashed var(--rule-strong); background: var(--paper-2); padding: 14px 16px; font-size: .92rem; }
.notice.warn { border-color: var(--do); color: var(--do); }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; z-index: 60; font-size: .9rem; max-width: calc(100vw - 32px); }

/* ---------- trang giáo viên ---------- */
.tbl-wrap { overflow-x: auto; margin-top: 14px; border: 1px solid var(--rule-strong); background: #fff; }
table.t { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.t th, table.t td { padding: 9px 10px; border-bottom: 1px solid var(--rule); text-align: left; white-space: nowrap; }
table.t td.wrap-cell { white-space: normal; min-width: 220px; }
table.t th { background: var(--mint); color: var(--ink); font-weight: 700; position: sticky; top: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #F6FAF3; }
.dots { display: flex; gap: 3px; }
.dot { width: 14px; height: 14px; border: 1px solid var(--rule-strong); }
.dot.right { background: var(--deep); border-color: var(--deep); }
.dot.part { background: var(--yellow); border-color: #C9A42A; }
.dot.wrong { background: #fff; border-color: var(--do); }
.dot.blank { background: repeating-linear-gradient(45deg, #fff 0 3px, #F2D3D1 3px 5px); border-color: var(--do); }
.sw { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: .88rem; }
.sw input { width: 20px; height: 20px; accent-color: var(--deep); }
.pill { display: inline-block; padding: 2px 10px; border: 1px solid currentColor; font-size: .76rem; font-weight: 700; }
.pill.on { color: var(--deep); background: var(--mint); }
.pill.off { color: var(--muted); }

/* ---------- KaTeX ---------- */
.katex { font-size: 1.06em; }

@media (max-width: 520px) {
  .brand small { display: none; }
  .brand { font-size: .88rem; }
  .who .nm { max-width: 34vw; }
  .who .link { white-space: nowrap; }
  .clock .btn { padding: 8px 14px; }
}
