:root {
  --bg: #f4f6f9; --card: #ffffff; --ink: #14202e; --muted: #5d6b7a; --line: #dfe4ea;
  --brand: #0b5cab; --brand-ink: #ffffff; --good: #137a3a; --good-bg: #e5f5eb;
  --bad: #b42318; --bad-bg: #fdecea; --warn-bg: #fff6dd; --chip: #eef2f7;
  --radius: 14px; --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f141a; --card: #18202a; --ink: #e8edf3; --muted: #9aa8b6; --line: #2a3542;
    --brand: #4c9be8; --brand-ink: #06121f; --good: #5bd28a; --good-bg: #12301f; --bad: #ff8a7a; --bad-bg: #3a1714;
    --warn-bg: #2f2814; --chip: #222c38; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
button { font: inherit; color: inherit; }
header#top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px; background: var(--brand); color: var(--brand-ink); }
header h1 { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#topRight { font-size: 14px; font-variant-numeric: tabular-nums; opacity: .95; }
.icon-btn { background: none; border: 0; font-size: 26px; line-height: 1; padding: 2px 8px; cursor: pointer; color: inherit; }
main { max-width: 680px; margin: 0 auto; padding: 14px 14px calc(110px + var(--safe-b)); outline: none; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 4px 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.test-card { display: block; width: 100%; text-align: left; cursor: pointer; }
.test-card .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.test-card b { font-size: 18px; }
.test-card small, .muted { color: var(--muted); font-size: 14px; }
.meter { height: 6px; background: var(--chip); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--good); }
.btn { display: block; width: 100%; padding: 15px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); text-align: center; font-weight: 600; cursor: pointer; margin-top: 8px; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn-row { display: flex; gap: 8px; } .btn-row .btn { flex: 1; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 2px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--brand); flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--chip); border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; font-size: 15px; cursor: pointer; }
.chip.done { border-color: var(--good); }
.chip .n { color: var(--muted); font-size: 13px; margin-left: 4px; }
/* question */
.progress { height: 5px; background: var(--chip); border-radius: 3px; overflow: hidden; margin: 2px 0 12px; }
.progress i { display: block; height: 100%; background: var(--brand); transition: width .2s; }
.qmeta { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.qtext { font-size: 20px; font-weight: 600; margin: 0 0 14px; }
.opts { display: grid; gap: 10px; }
.opt { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; padding: 14px; min-height: 56px;
  background: var(--card); border: 2px solid var(--line); border-radius: 12px; cursor: pointer; }
.opt .L { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--chip); font-weight: 700; font-size: 15px; }
.opt.sel { border-color: var(--brand); }
.opt.correct { border-color: var(--good); background: var(--good-bg); }
.opt.correct .L { background: var(--good); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong .L { background: var(--bad); color: #fff; }
.opt[disabled] { cursor: default; }
.feedback { margin-top: 14px; border-radius: var(--radius); padding: 14px; border: 1px solid var(--line); background: var(--card); }
.feedback.good { border-color: var(--good); }
.feedback.bad { border-color: var(--bad); }
.feedback .verdict { font-weight: 700; font-size: 18px; margin-bottom: 6px; }
.feedback.good .verdict { color: var(--good); } .feedback.bad .verdict { color: var(--bad); }
.answer { font-weight: 600; margin: 4px 0 10px; }
.passage { background: var(--warn-bg); border-left: 4px solid #d9a400; padding: 10px 12px; border-radius: 6px; margin: 8px 0; font-size: 16px; }
.passage .lbl, .why .lbl { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 2px; }
.why { margin: 8px 0; font-size: 16px; }
.pageref { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; font-size: 15px; }
.pageref .tag { background: var(--chip); border-radius: 8px; padding: 4px 8px; font-weight: 600; }
.linkbtn { background: none; border: 0; color: var(--brand); font-weight: 600; padding: 4px 0; cursor: pointer; text-decoration: underline; }
.fig { margin: 10px 0; text-align: center; }
.fig img { max-width: 100%; max-height: 60vh; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: zoom-in; }
.fig figcaption { font-size: 13px; color: var(--muted); }
.bottom-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; padding: 10px 14px calc(10px + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 70%, transparent); }
.bottom-bar .inner { max-width: 680px; margin: 0 auto; }
.bottom-bar .btn { margin: 0; }
/* results */
.score { text-align: center; padding: 22px 14px; }
.score .big { font-size: 46px; font-weight: 800; line-height: 1.1; }
.score.pass .big { color: var(--good); } .score.fail .big { color: var(--bad); }
.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-weight: 700; margin-top: 6px; }
.pass .badge { background: var(--good-bg); color: var(--good); } .fail .badge { background: var(--bad-bg); color: var(--bad); }
.review-item { padding: 12px 14px; }
.review-item .q { font-weight: 600; margin-bottom: 6px; }
.review-item .you { color: var(--bad); font-size: 15px; }
.review-item .right { color: var(--good); font-size: 15px; font-weight: 600; }
details summary { cursor: pointer; color: var(--brand); font-weight: 600; margin-top: 6px; }
/* sheet */
.sheet { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column; }
.sheet[hidden] { display: none; }
.sheet-bar { display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top,0px) + 8px) 12px 8px;
  background: var(--card); border-bottom: 1px solid var(--line); font-weight: 600; }
.sheet-body { overflow: auto; -webkit-overflow-scrolling: touch; flex: 1; padding: 10px; touch-action: pan-x pan-y pinch-zoom; }
.page-img { width: 100%; height: auto; background: #fff; display: block; }
.sheet-nav { display: flex; gap: 8px; padding: 8px 10px calc(8px + var(--safe-b)); background: var(--card); border-top: 1px solid var(--line); }
.sheet-nav .btn { margin: 0; }
.fig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.fig-grid button { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px; cursor: pointer; }
.fig-grid img { width: 100%; height: 130px; object-fit: contain; background: #fff; border-radius: 6px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.kbd-hint { display: none; }
@media (hover: hover) and (pointer: fine) { .kbd-hint { display: block; text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; } }
