* { box-sizing: border-box; }
:root {
  --bg: #f5f6fb; --card: #fff; --ink: #1f2330; --muted: #6b7180;
  --pri: #4f46e5; --pri-soft: #eef0ff; --ok: #16a34a; --ok-soft: #e7f8ee;
  --bad: #dc2626; --bad-soft: #fdecec; --line: #e3e5ee;
}
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif; font-size: 17px; line-height: 1.5; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--pri); color: #fff; }
.top h1 { font-size: 18px; margin: 0; flex: 1; }
.icon-btn { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 10px;
  width: 38px; height: 38px; font-size: 20px; cursor: pointer; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; direction: ltr; }
.timer.warn { color: #fde047; }
main { max-width: 640px; margin: 0 auto; padding: 14px 14px 80px; }

.card { background: var(--card); border-radius: 16px; padding: 16px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(20,20,50,.06); }
.card h2 { margin: 0 0 6px; font-size: 19px; }
.muted { color: var(--muted); font-size: 15px; }
.btn { display: block; width: 100%; padding: 14px; border: 0; border-radius: 12px; font-size: 17px;
  font-weight: 600; background: var(--pri); color: #fff; cursor: pointer; margin-top: 10px; font-family: inherit; }
.btn.sec { background: var(--pri-soft); color: var(--pri); }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.cat { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.cat:last-child { border-bottom: 0; }
.cat .name { flex: 1; font-weight: 600; }
.cat .stat { font-size: 14px; color: var(--muted); }
.group-title { font-size: 14px; color: var(--pri); font-weight: 700; margin: 12px 0 0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 13px; background: var(--pri-soft); color: var(--pri); }

.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 12px; }
.progress > div { height: 100%; background: var(--pri); transition: width .3s; }
.qmeta { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.prompt { font-size: 18px; font-weight: 600; margin-bottom: 12px; white-space: pre-line; }
.visual { margin: 8px 0 14px; overflow-x: auto; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.seq { direction: ltr; font-size: 24px; font-weight: 700; letter-spacing: 1px; text-align: center;
  background: var(--pri-soft); padding: 12px; border-radius: 12px; word-spacing: 8px; }

.opts { display: grid; gap: 10px; }
.opts.grid2 { grid-template-columns: 1fr 1fr; }
.opt { text-align: right; padding: 14px; border-radius: 12px; border: 2px solid var(--line);
  background: #fff; font-size: 17px; cursor: pointer; font-family: inherit; color: var(--ink);
  display: flex; align-items: center; gap: 10px; }
.opt .num { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--line);
  display: grid; place-items: center; font-size: 14px; font-weight: 700; }
.opt.visual-opt { justify-content: center; position: relative; padding: 8px; }
.opt.visual-opt .num { position: absolute; top: 6px; right: 6px; }
.opt.sel { border-color: var(--pri); background: var(--pri-soft); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.explain { margin-top: 12px; padding: 12px; border-radius: 12px; background: #fffbea; border: 1px solid #f5e3a0; white-space: pre-line; }
.explain b { display: block; margin-bottom: 4px; }

/* matrices */
.matrix { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; max-width: 300px; margin: 0 auto;
  background: var(--line); padding: 4px; border-radius: 10px; }
.matrix > div { background: #fff; aspect-ratio: 1; display: grid; place-items: center; border-radius: 6px; }
.matrix .q { font-size: 34px; font-weight: 800; color: var(--pri); }
.strip { display: flex; gap: 4px; justify-content: center; flex-wrap: nowrap; direction: rtl; }
.strip > div { background: #fff; border: 1px solid var(--line); border-radius: 8px; width: 54px; height: 54px; display: grid; place-items: center; }
.strip .q { font-size: 28px; font-weight: 800; color: var(--pri); }

table.data { width: 100%; border-collapse: collapse; font-size: 15px; background: #fff; }
table.data th, table.data td { border: 1px solid var(--line); padding: 6px; text-align: center; }
table.data th { background: var(--pri-soft); }
table.pairs td { font-family: ui-monospace, Menlo, monospace; direction: ltr; }
table.pairs td.he { font-family: inherit; direction: rtl; }

.result-big { font-size: 46px; font-weight: 800; text-align: center; color: var(--pri); }
.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar > div { height: 100%; background: var(--ok); }
ul.tips { padding-inline-start: 20px; margin: 6px 0; }
ul.tips li { margin-bottom: 6px; }
.footer-actions { position: fixed; bottom: 0; left: 0; right: 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(245,246,251,.95); backdrop-filter: blur(6px); border-top: 1px solid var(--line); }
.footer-actions .inner { max-width: 640px; margin: 0 auto; }
.footer-actions .btn { margin: 0; }
.hint-btn { margin-top: 12px; }
.hint { margin-top: 12px; padding: 12px; border-radius: 12px; background: #eef6ff; border: 1px solid #bcd7f5; }
.hint b { display: block; margin-bottom: 4px; }
.opt.elim { opacity: .3; text-decoration: line-through; pointer-events: none; }
.passage { background: #fafbff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 16px; line-height: 1.7; }
.hint-btn { margin: 0 0 12px; padding: 8px 14px; border: 1px solid #bcd7f5; background: #eef6ff; color: #1d4ed8;
  border-radius: 99px; font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit; }
.hint { margin: 0 0 12px; }
.toggle { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--pri); }
.access { border: 2px solid var(--pri-soft); }
.access.ok { border-color: var(--ok); background: var(--ok-soft); }
.input { width: 100%; padding: 12px; border: 2px solid var(--line); border-radius: 10px; font-size: 18px; margin-top: 10px; font-family: inherit; }
.likert { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.likert label { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; text-align: center; color: var(--muted); cursor: pointer; }
.likert input { width: 22px; height: 22px; accent-color: var(--pri); }
/* --- UX review fixes --- */
:focus-visible { outline: 3px solid #b45309; outline-offset: 2px; }
.icon-btn { width: 44px; height: 44px; }
.hint-btn { min-height: 44px; }
button.cat { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); font: inherit; color: inherit; text-align: right; }
a.btn { text-align: center; text-decoration: none; box-sizing: border-box; }
.opt { border-color: #b9bdcc; }
.opt > span:last-child { unicode-bidi: plaintext; }
.explain, .hint { unicode-bidi: plaintext; }
.err { color: #b91c1c; font-weight: 600; }
.likert label { font-size: 13px; }
fieldset.int-item { border: 0; margin: 0 0 12px; min-width: 0; }
fieldset.int-item legend { padding: 0; float: right; width: 100%; margin-bottom: 8px; }
fieldset.int-item .likert { clear: both; }
.int-item.missing { box-shadow: 0 0 0 2px #b91c1c; }
.int-progress { position: sticky; top: 64px; z-index: 4; background: var(--pri); color: #fff; border-radius: 99px; padding: 4px 12px; width: max-content; margin: 0 auto 10px; font-size: 14px; }
.seq { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; word-spacing: normal; }
@media (max-width: 380px) { .seq { font-size: 20px; } .row .btn { font-size: 15px; } }
.soon { background: var(--pri-soft); border-radius: 12px; padding: 12px; margin-top: 10px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.consent { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin: 8px 0; }
.consent input { width: 18px; height: 18px; margin-top: 3px; flex: none; }
.input { border-color: #9aa0b4; }
