/* بی بی گل — design tokens
   Concept: the competition answer sheet (پاسخ‌برگ). Bubbles are the one bold motif;
   everything else is quiet paper + ink. */
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Variable.woff2") format("woff2-variations"),
       url("../fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --paper: #EEF1F6;
  --surface: #FFFFFF;
  --surface-2: #F6F8FB;
  --ink: #17213A;
  --ink-2: #47526B;
  --muted: #6B7590;
  --line: #D9DFE9;
  --line-2: #E7EBF2;
  --sheet: #3346C8;          /* answer-sheet print color = primary accent */
  --sheet-soft: #E6E9FB;
  --graphite: #262B38;       /* pencil fill */
  --good: #12805A;
  --good-soft: #E2F3EC;
  --bad: #C5392F;
  --bad-soft: #FBE7E5;
  --flag: #B87908;
  --flag-soft: #FBF0D9;
  --focus: #3346C8;
  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 22px;
  --shadow: 0 1px 0 rgba(23, 33, 58, .04), 0 8px 24px -12px rgba(23, 33, 58, .18);
  --fs-xs: .8125rem; --fs-s: .9375rem; --fs-m: 1.0625rem; --fs-l: 1.375rem;
  --fs-xl: 1.875rem; --fs-xxl: 3rem;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #121826;
  --surface: #1A2133;
  --surface-2: #20283C;
  --ink: #E8ECF5;
  --ink-2: #BAC3D6;
  --muted: #8F9AB3;
  --line: #2E3850;
  --line-2: #262F45;
  --sheet: #8C9BFF;
  --sheet-soft: #262F5A;
  --graphite: #E8ECF5;
  --good: #4CC79A;
  --good-soft: #163A31;
  --bad: #FF8A7E;
  --bad-soft: #43221F;
  --flag: #F2B84B;
  --flag-soft: #3F3120;
  --focus: #8C9BFF;
  --shadow: 0 1px 0 rgba(0,0,0,.2), 0 10px 30px -14px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Vazirmatn", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.8;
  color: var(--ink);
  background: var(--paper);
  font-feature-settings: "ss01";
}
a { color: var(--sheet); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 4px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { line-height: 1.35; margin: 0; }
h1 { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: var(--fs-l); font-weight: 750; }
h3 { font-size: var(--fs-m); font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-s); }
.xs { font-size: var(--fs-xs); }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------------------------------------------------------- shell */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 1120px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; font-size: 1.2rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; grid-template-columns: repeat(2, 9px); gap: 3px; }
.brand-mark i { width: 9px; height: 9px; border-radius: 50%; border: 1.6px solid var(--sheet); }
.brand-mark i.f { background: var(--graphite); border-color: var(--graphite); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  color: var(--ink-2); padding: 6px 12px; border-radius: 999px; font-size: var(--fs-s); font-weight: 500;
}
.nav a:hover { background: var(--surface); text-decoration: none; }
.nav a.on { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: var(--shadow); }
.who { display: flex; align-items: center; gap: 8px; font-size: var(--fs-s); color: var(--ink-2); }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { color: var(--ink); border-color: var(--muted); }
.menu-btn { display: none; }

main { max-width: 1120px; margin: 0 auto; padding: 32px 20px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: var(--fs-s); color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
section + section { margin-top: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head .muted { font-size: var(--fs-s); }

/* ---------------------------------------------------------------- surfaces */
.panel {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-m);
  box-shadow: var(--shadow);
}
.pad { padding: 22px 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ---------------------------------------------------------------- buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: var(--fs-s);
  padding: 9px 18px; border-radius: 999px; border: 1px solid transparent; cursor: pointer;
  background: var(--sheet); color: #fff; line-height: 1.6; white-space: nowrap;
}
:root[data-theme="dark"] .btn { color: #10152A; }
.btn:hover { text-decoration: none; filter: brightness(1.07); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--muted); background: var(--surface); }
.btn.danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.lg { padding: 12px 26px; font-size: var(--fs-m); }
.btn.sm { padding: 4px 12px; font-size: var(--fs-xs); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: var(--fs-s); font-weight: 600; margin-bottom: 4px; color: var(--ink-2); }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: 9px 12px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--sheet); box-shadow: 0 0 0 3px var(--sheet-soft); }
textarea { min-height: 140px; resize: vertical; font-size: var(--fs-s); }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form input { width: auto; padding: 4px 10px; font-size: var(--fs-s); }

/* toggle rows: tick boxes styled as answer-sheet bubbles */
.toggle {
  display: flex; align-items: flex-start; gap: 14px; padding: 14px 0; cursor: pointer;
  border-bottom: 1px solid var(--line-2);
}
.toggle:last-child { border-bottom: 0; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .bub {
  flex: none; width: 24px; height: 24px; margin-top: 3px; border-radius: 50%;
  border: 2px solid var(--sheet); position: relative; transition: background .15s;
}
.toggle input:checked + .bub { background: var(--graphite); border-color: var(--graphite); }
.toggle input:checked + .bub::after {
  content: ""; position: absolute; inset: 5px 7px 7px 7px; border: solid var(--surface);
  border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.toggle input:focus-visible + .bub { outline: 3px solid var(--focus); outline-offset: 2px; }
.toggle b { display: block; font-weight: 700; }
.toggle small { color: var(--muted); font-size: var(--fs-s); }
.toggle .extra { margin-top: 6px; display: flex; align-items: center; gap: 8px; font-size: var(--fs-s); }
.toggle .extra input[type=number] { width: 90px; padding: 4px 10px; position: static; opacity: 1; pointer-events: auto; }

/* ---------------------------------------------------------------- flash */
.flashes { display: grid; gap: 8px; margin-bottom: 20px; }
.flash { padding: 10px 16px; border-radius: var(--radius-s); font-size: var(--fs-s); border: 1px solid; }
.flash.ok { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 30%, transparent); color: var(--ink); }
.flash.err { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); color: var(--ink); }
.form-error { color: var(--bad); font-size: var(--fs-s); margin-bottom: 12px; }

/* ---------------------------------------------------------------- badges & meters */
.tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 600;
  padding: 1px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line-2); white-space: nowrap;
}
.tag.accent { background: var(--sheet-soft); color: var(--sheet); border-color: transparent; }
.tag.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.tag.flag { background: var(--flag-soft); color: var(--flag); border-color: transparent; }
.tag.hidden { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.meter { height: 6px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: var(--sheet); }
.score { font-weight: 800; font-variant-numeric: tabular-nums; }
.score.hi { color: var(--good); }
.score.lo { color: var(--bad); }

/* ---------------------------------------------------------------- home */
.hello { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; margin-bottom: 40px; }
.hello-main { padding: 28px 30px; display: flex; flex-direction: column; justify-content: space-between; gap: 20px; }
.hello-main h1 { font-size: 2.1rem; }
.kpis { display: flex; gap: 32px; flex-wrap: wrap; }
.kpi b { display: block; font-size: var(--fs-xl); font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi span { font-size: var(--fs-s); color: var(--muted); }
.resume {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; border-radius: var(--radius-m); background: var(--flag-soft); margin-bottom: 24px;
}

.shelf { display: grid; gap: 10px; }
.book-row {
  display: grid; grid-template-columns: 1fr 220px auto; gap: 24px; align-items: center;
  padding: 18px 22px; color: var(--ink);
}
.book-row:hover { text-decoration: none; border-color: var(--line); }
.book-row h3 { font-size: 1.15rem; }
.book-row .meta { font-size: var(--fs-s); color: var(--muted); }
.book-row .prog { display: grid; gap: 6px; font-size: var(--fs-xs); color: var(--muted); }
.book-row .go { color: var(--sheet); font-weight: 700; font-size: var(--fs-s); }

/* ---------------------------------------------------------------- test lists */
.test-list { display: grid; gap: 8px; }
.test-row {
  display: grid; grid-template-columns: 52px 1fr auto auto; gap: 18px; align-items: center;
  padding: 14px 20px;
}
.chap-bubble {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--sheet);
  display: grid; place-items: center; font-weight: 800; color: var(--sheet); font-size: 1.05rem;
}
.chap-bubble.done { background: var(--graphite); border-color: var(--graphite); color: var(--surface); }
.chap-bubble.wide { border-radius: 999px; width: auto; min-width: 44px; padding: 0 10px; font-size: var(--fs-xs); }
.test-row h3 { font-size: var(--fs-m); }
.test-row .meta { font-size: var(--fs-s); color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.test-row .best { text-align: center; min-width: 76px; line-height: 1.3; }
.test-row .best b { display: block; font-size: 1.15rem; }
.test-row .best span { font-size: var(--fs-xs); color: var(--muted); }
.empty {
  padding: 28px; text-align: center; color: var(--muted); border: 1.5px dashed var(--line);
  border-radius: var(--radius-m); font-size: var(--fs-s);
}

/* ---------------------------------------------------------------- intro */
.intro { display: grid; grid-template-columns: 1fr 360px; gap: 24px; align-items: start; }
.facts { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 14px; }
.facts div b { display: block; font-size: var(--fs-l); font-weight: 800; }
.facts div span { font-size: var(--fs-xs); color: var(--muted); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-s); }
th, td { text-align: right; padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: var(--fs-xs); background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: center; font-variant-numeric: tabular-nums; }
.matrix td.cell { text-align: center; font-weight: 700; }
.matrix th.rot { white-space: nowrap; }

/* ---------------------------------------------------------------- exam */
.exam-bar {
  position: sticky; top: 0; z-index: 40; background: var(--surface); border-bottom: 1px solid var(--line);
}
.exam-bar-in { max-width: 1240px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 18px; }
.exam-bar h1 { font-size: var(--fs-m); font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer {
  font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.25rem; padding: 2px 14px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); min-width: 96px; text-align: center;
}
.timer.warn { color: var(--flag); border-color: var(--flag); }
.timer.crit { color: var(--bad); border-color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.exam-progress { height: 3px; background: var(--line-2); }
.exam-progress > i { display: block; height: 100%; background: var(--sheet); transition: width .25s; }

.exam { max-width: 1240px; margin: 0 auto; padding: 28px 20px 120px; display: grid; grid-template-columns: 1fr 300px; gap: 28px; align-items: start; }
.qcard { padding: 30px 34px; }
.qnum { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; color: var(--muted); font-size: var(--fs-s); }
.qstem { font-size: 1.2rem; line-height: 2; font-weight: 500; margin-bottom: 24px; max-width: 70ch; }
.opts { display: grid; gap: 10px; }
.opt {
  display: grid; grid-template-columns: 34px 1fr; gap: 14px; align-items: center; text-align: right;
  width: 100%; font: inherit; color: var(--ink); background: var(--surface-2);
  border: 1.5px solid var(--line-2); border-radius: var(--radius-m); padding: 12px 16px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.opt:hover { border-color: var(--sheet); }
.opt .ob {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--sheet); display: grid; place-items: center;
  font-size: var(--fs-s); font-weight: 700; color: var(--sheet); transition: background .12s;
}
.opt[aria-pressed="true"] { border-color: var(--graphite); background: var(--surface); }
.opt[aria-pressed="true"] .ob { background: var(--graphite); border-color: var(--graphite); color: var(--surface); }
.qnav { display: flex; justify-content: space-between; gap: 10px; margin-top: 28px; flex-wrap: wrap; }
.flag-btn[aria-pressed="true"] { background: var(--flag-soft); color: var(--flag); border-color: var(--flag); }
.kbd-hint { font-size: var(--fs-xs); color: var(--muted); margin-top: 14px; }
kbd { font: inherit; font-size: .75rem; padding: 0 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-2); }
.exam.all-mode .q { margin-bottom: 18px; }
.exam:not(.all-mode) .q:not(.cur) { display: none; }
.exam.all-mode .qnav-single { display: none; }

/* the answer sheet (signature element) */
.sheet { padding: 18px 18px 20px; position: sticky; top: 76px; max-height: calc(100vh - 96px); display: flex; flex-direction: column; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sheet-head h2 { font-size: var(--fs-m); }
.sheet-legend { display: flex; gap: 12px; font-size: var(--fs-xs); color: var(--muted); margin-bottom: 10px; flex-wrap: wrap; }
.sheet-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-left: 4px; }
.sheet-rows { overflow-y: auto; padding-left: 4px; margin: 0 -4px; }
.srow {
  display: grid; grid-template-columns: 30px repeat(4, 1fr); align-items: center; gap: 4px;
  padding: 3px 6px; border-radius: 8px; cursor: pointer; border: 1px solid transparent;
  background: none; width: 100%; font: inherit; color: inherit;
}
.srow:hover { background: var(--surface-2); }
.srow.cur { border-color: var(--sheet); background: var(--sheet-soft); }
.srow .n { font-size: var(--fs-xs); color: var(--muted); font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.srow.flagged .n { color: var(--flag); }
.srow.flagged .n::after { content: "•"; }
.sb {
  justify-self: center; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid color-mix(in srgb, var(--sheet) 70%, transparent);
  font-size: 9px; line-height: 17px; text-align: center; color: color-mix(in srgb, var(--sheet) 70%, transparent); font-weight: 700;
}
.sb.on { background: var(--graphite); border-color: var(--graphite); color: transparent; }
.sb.ok { background: var(--good); border-color: var(--good); color: transparent; }
.sb.key { border: 2px solid var(--good); background: var(--good-soft); color: transparent; }
.sb.no { background: var(--bad); border-color: var(--bad); color: transparent; }
.sheet-foot { margin-top: 14px; display: grid; gap: 10px; }
.sheet-count { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--muted); }

.sheet-toggle { display: none; }

/* ---------------------------------------------------------------- modal */
dialog {
  border: 0; border-radius: var(--radius-l); padding: 0; max-width: 440px; width: calc(100% - 40px);
  background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0,0,0,.45);
}
dialog::backdrop { background: rgba(14, 20, 36, .45); backdrop-filter: blur(3px); }
.modal-body { padding: 26px 28px 22px; }
.modal-body h2 { margin-bottom: 10px; }
.modal-body [data-detail] { line-height: 1.9; }
.modal-body .btn-row { margin-top: 22px; justify-content: flex-start; }

/* ---------------------------------------------------------------- result */
.result-hero { display: grid; grid-template-columns: auto 1fr auto; gap: 36px; align-items: center; padding: 30px 34px; margin-bottom: 28px; }
.big-score { font-size: 4rem; font-weight: 900; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.big-score small { display: block; font-size: var(--fs-s); font-weight: 500; color: var(--muted); letter-spacing: 0; margin-top: 10px; }
.tally { display: flex; gap: 26px; flex-wrap: wrap; }
.tally div b { display: block; font-size: var(--fs-l); font-weight: 800; }
.tally div span { font-size: var(--fs-xs); color: var(--muted); }
.tally .g b { color: var(--good); } .tally .r b { color: var(--bad); }
.stack { display: flex; height: 10px; border-radius: 999px; overflow: hidden; gap: 2px; margin-top: 16px; background: var(--surface); }
.stack i { display: block; height: 100%; }
.stack .g { background: var(--good); } .stack .r { background: var(--bad); } .stack .b { background: var(--line); }

.review-filter { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.review-filter button {
  font: inherit; font-size: var(--fs-s); padding: 4px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--ink-2); cursor: pointer;
}
.review-filter button[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.rq { padding: 22px 26px; margin-bottom: 12px; border-inline-start: 4px solid var(--line); }
.rq.is-ok { border-inline-start-color: var(--good); }
.rq.is-no { border-inline-start-color: var(--bad); }
.rq-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 8px; font-size: var(--fs-s); color: var(--muted); }
.rq .qstem { font-size: var(--fs-m); margin-bottom: 14px; }
.ropts { display: grid; gap: 6px; }
.ropt { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; padding: 6px 12px; border-radius: 10px; font-size: var(--fs-s); }
.ropt .ob { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 700; color: var(--muted); }
.ropt.key { background: var(--good-soft); }
.ropt.key .ob { background: var(--good); border-color: var(--good); color: #fff; }
.ropt.picked-no { background: var(--bad-soft); }
.ropt.picked-no .ob { background: var(--bad); border-color: var(--bad); color: #fff; }
.ropt .why { font-size: var(--fs-xs); font-weight: 700; }
.ropt.key .why { color: var(--good); } .ropt.picked-no .why { color: var(--bad); }
.src { margin-top: 12px; font-size: var(--fs-s); color: var(--ink-2); display: flex; gap: 8px; align-items: baseline; }
.src b { color: var(--sheet); font-weight: 700; white-space: nowrap; }
.expl { margin-top: 8px; font-size: var(--fs-s); color: var(--ink-2); }

/* ---------------------------------------------------------------- chart */
.chart { position: relative; }
.chart svg { direction: ltr; display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line-2); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .line { fill: none; stroke: var(--sheet); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--sheet); stroke: var(--surface); stroke-width: 2; }
.chart .dot.cross { fill: var(--surface); stroke: var(--sheet); stroke-width: 2; }
.chart .xhair { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart .tip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--surface); font-size: var(--fs-xs);
  padding: 6px 10px; border-radius: 8px; line-height: 1.6; white-space: nowrap; transform: translate(50%, -110%);
}
.chart-empty { padding: 30px; text-align: center; color: var(--muted); font-size: var(--fs-s); }

/* ---------------------------------------------------------------- upload */
.drop {
  display: block;
  border: 2px dashed var(--line); border-radius: var(--radius-m); padding: 34px; text-align: center;
  background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--sheet); background: var(--sheet-soft); }
.drop b, .drop > span { display: block; }
.drop b { font-size: var(--fs-m); margin-bottom: 4px; }
.drop input { display: none; }
.file-list { margin-top: 10px; font-size: var(--fs-s); color: var(--ink-2); }
.preview { padding: 18px 22px; margin-bottom: 12px; }
.preview ul { margin: 8px 0 0; padding-inline-start: 20px; font-size: var(--fs-s); }
.preview li.e { color: var(--bad); }
.preview li.w { color: var(--flag); }
details summary { cursor: pointer; font-size: var(--fs-s); color: var(--sheet); margin-top: 8px; }
pre.code {
  direction: ltr; text-align: left; background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: var(--radius-s); padding: 14px; font-size: 13px; overflow-x: auto; line-height: 1.7;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
pre.code.rtl { margin-top: 10px; direction: rtl; text-align: right; font-family: inherit; }

/* ---------------------------------------------------------------- auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; padding: 34px 32px; }
.auth-card .brand { justify-content: center; font-size: 1.6rem; margin-bottom: 6px; }
.auth-card .brand-mark { grid-template-columns: repeat(2, 12px); gap: 4px; }
.auth-card .brand-mark i { width: 12px; height: 12px; }
.auth-card > p { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: var(--fs-s); }
.auth-card .btn { width: 100%; margin-top: 8px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 960px) {
  .exam { grid-template-columns: 1fr; }
  .sheet {
    position: fixed; inset: auto 0 0 0; top: auto; max-height: 70vh; border-radius: var(--radius-l) var(--radius-l) 0 0;
    transform: translateY(100%); transition: transform .25s ease; z-index: 50;
  }
  .sheet.open { transform: none; }
  .sheet-toggle {
    display: inline-flex; position: fixed; bottom: 18px; left: 18px; z-index: 45; box-shadow: var(--shadow);
  }
  .intro, .hello, .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .result-hero { grid-template-columns: 1fr; gap: 20px; }
}
@media (max-width: 720px) {
  main { padding: 22px 14px 70px; }
  .topbar-in { gap: 10px; padding: 8px 14px; }
  .topbar .brand { font-size: 1rem; gap: 8px; }
  .menu-btn { display: inline-grid; }
  .nav {
    display: none; position: absolute; top: 100%; right: 0; left: 0; flex-direction: column;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 14px;
  }
  .nav.open { display: flex; }
  .who .name { display: none; }
  .book-row { grid-template-columns: 1fr; gap: 10px; }
  .test-row { grid-template-columns: 44px 1fr; gap: 12px; padding: 14px; }
  .test-row .best { grid-column: 2; text-align: right; display: flex; gap: 8px; align-items: baseline; }
  .test-row .best b { display: inline; }
  .test-row .act { grid-column: 1 / -1; }
  .test-row .act .btn { width: 100%; }
  .qcard { padding: 22px 18px; }
  .qstem { font-size: 1.08rem; }
  .grid-3 { grid-template-columns: 1fr; }
  .hello-main h1 { font-size: 1.7rem; }
  .big-score { font-size: 3.2rem; }
  .exam-bar-in { padding: 8px 14px; gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
@media print {
  .topbar, .exam-bar, .sheet, .sheet-toggle, .review-filter, .btn { display: none !important; }
  body { background: #fff; }
}

/* ---------------------------------------------------------------- small-screen exam bar */
.qstem, .opt, .ropt, .rq .qstem { overflow-wrap: anywhere; }
.bar-short { display: none; }
@media (max-width: 720px) {
  .exam-bar .brand, .exam-bar h1, #viewToggle { display: none; }
  .exam-bar-in { justify-content: space-between; }
  .bar-short { display: inline; font-size: var(--fs-s); color: var(--muted); }
  .exam { padding: 16px 12px 110px; }
}
.chap-bubble.wide { white-space: nowrap; }
.test-row { grid-template-columns: minmax(52px, auto) 1fr auto auto; }
@media (max-width: 720px) {
  .kbd-hint { display: none; }
  .test-row { grid-template-columns: minmax(44px, auto) 1fr; }
}

/* reading / cloze passages (English tests) */
.passage { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 18px; }
.passage summary { cursor: pointer; padding: 8px 14px; font-size: var(--fs-s); font-weight: 700; color: var(--muted); }
.passage-body { padding: 4px 16px 14px; line-height: 1.9; max-height: 45vh; overflow-y: auto; }
[dir="ltr"] .passage-body, .passage[dir="ltr"] .passage-body { text-align: left; }
.qstem[dir="ltr"], .opts[dir="ltr"], .ropts[dir="ltr"] { text-align: left; }
.rq .passage-body { font-size: var(--fs-s); }
