:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --text: #17202e;
  --muted: #5a6577;
  --border: #dce2eb;
  --navy: #0b2545;
  --accent: #1f6fd1;
  --accent-text: #ffffff;
  --accent-soft: #e5effc;
  --ok: #17803a;
  --ok-soft: #e4f4e9;
  --bad: #c42b2b;
  --bad-soft: #fbe8e8;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(15 30 60 / 6%), 0 2px 8px rgb(15 30 60 / 6%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d121a;
    --surface: #151c27;
    --text: #e4e9f1;
    --muted: #97a3b6;
    --border: #273244;
    --navy: #0a1a30;
    --accent: #5b9dff;
    --accent-text: #08111f;
    --accent-soft: #1a2a42;
    --ok: #46c06a;
    --ok-soft: #12291b;
    --bad: #ff7070;
    --bad-soft: #351719;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 9rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); }
h1, h2 { line-height: 1.25; margin: 0; }
img { max-width: 100%; height: auto; vertical-align: middle; }

.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }

/* Header */
.top { background: var(--navy); color: #fff; }
.top__in { display: flex; align-items: center; justify-content: space-between; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.brand__icon { width: 26px; height: 26px; transform: rotate(45deg); }
.tag { font-size: .8rem; padding: .15rem .6rem; border: 1px solid rgb(255 255 255 / 35%); border-radius: 999px; color: rgb(255 255 255 / 85%); }

main.wrap { padding-top: 1.25rem; padding-bottom: 2rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .55rem 1rem;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { border-color: var(--accent); }
.btn small { font-weight: 400; color: var(--muted); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn--primary small { color: inherit; opacity: .85; }
.btn--primary:hover { filter: brightness(1.08); }
.btn--small { min-height: 36px; padding: .3rem .75rem; font-size: .9rem; }
.btn--big { min-height: 52px; padding: .75rem 2rem; font-size: 1.1rem; }
.btn--off { opacity: .45; cursor: default; pointer-events: none; }
.btn:focus-visible, button.ans:focus-visible, label.ans:has(input:focus-visible), .jump a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Home */
.hero { margin-bottom: 1.5rem; }
.hero h1 { font-size: clamp(1.5rem, 4.5vw, 2.1rem); margin-bottom: .4rem; }
.lead { color: var(--muted); margin: 0 0 1rem; }
.modes { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.mode { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.mode h2 { font-size: 1rem; margin-bottom: .25rem; }
.mode p { margin: 0; color: var(--muted); font-size: .95rem; }

.subjects { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.card__head { display: flex; align-items: center; gap: .65rem; }
.card__head h2 { font-size: 1.1rem; }
.card__num { flex: none; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.card__desc { margin: 0; color: var(--muted); font-size: .92rem; flex: 1; }
.card__meta { margin: 0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem .75rem; font-size: .9rem; color: var(--muted); }
.card__last.is-pass { color: var(--ok); font-weight: 600; }
.card__last.is-fail { color: var(--bad); font-weight: 600; }
.card__actions { display: grid; gap: .5rem; }
.card__actions .btn { justify-content: space-between; }
.card--off { opacity: .6; box-shadow: none; }
.card__soon { font-style: italic; }

/* Sticky bar of tests */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
  margin: -1.25rem -16px 1rem; padding: .6rem 16px;
  background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
}
.bar__title { display: flex; align-items: center; gap: .6rem; flex: 1 1 auto; min-width: 0; }
.bar__title strong { display: block; line-height: 1.2; }
.bar__mode { display: block; font-size: .82rem; color: var(--muted); }
.bar__back { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; text-decoration: none; font-size: 1.2rem; border: 1px solid var(--border); flex: none; }
.bar__status { display: flex; align-items: center; gap: .6rem; font-size: .95rem; white-space: nowrap; }
.bar__status progress { width: 90px; height: 8px; accent-color: var(--accent); }
.bar__timer { color: var(--muted); font-variant-numeric: tabular-nums; }
.mega-stats .ok { color: var(--ok); }
.mega-stats .bad { color: var(--bad); }

/* Question navigator */
.jump { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.jump a {
  display: grid; place-items: center; width: 2.4rem; height: 2.4rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text); text-decoration: none; font-size: .9rem; font-variant-numeric: tabular-nums;
}
.jump a.is-done { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* Questions */
.q { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
.q__title { display: flex; gap: .5rem; font-weight: 600; margin-bottom: .75rem; }
.q__num { flex: none; color: var(--accent); font-variant-numeric: tabular-nums; }
.q__body { min-width: 0; overflow-wrap: anywhere; }
.q__body img, .ans__body img { background: #fff; border-radius: 4px; }
.q__body table, .ans__body table { border-collapse: collapse; margin: .5rem 0; font-weight: 400; }
.q__body td, .q__body th, .ans__body td, .ans__body th { border: 1px solid var(--border); padding: .2rem .5rem; }
.q__note { margin: .5rem 0 0; color: var(--bad); font-size: .9rem; font-weight: 600; }

.answers { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.ans {
  display: flex; align-items: flex-start; gap: .65rem;
  width: 100%; min-height: 44px; padding: .6rem .75rem;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  color: var(--text); font: inherit; text-align: left; overflow-wrap: anywhere;
}
label.ans, button.ans { cursor: pointer; }
label.ans { position: relative; }
label.ans:hover, button.ans:not(:disabled):hover { border-color: var(--accent); }
.ans input { position: absolute; opacity: 0; pointer-events: none; }
.ans__letter {
  flex: none; display: grid; place-items: center; width: 1.75rem; height: 1.75rem;
  border-radius: 50%; border: 1px solid var(--border); font-weight: 700; font-size: .95rem;
}
.ans__body { flex: 1; min-width: 0; padding-top: .1rem; }
.ans__note { flex: none; align-self: center; font-size: .8rem; color: var(--muted); }

label.ans:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
label.ans:has(input:checked) .ans__letter { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.ans--correct { border-color: var(--ok); background: var(--ok-soft); }
.ans--correct .ans__letter { background: var(--ok); border-color: var(--ok); color: #fff; }
.ans--wrong { border-color: var(--bad); background: var(--bad-soft); }
.ans--wrong .ans__letter { background: var(--bad); border-color: var(--bad); color: #fff; }
button.ans:disabled { cursor: default; }
.q.is-answered button.ans:not(.ans--correct):not(.ans--wrong) { opacity: .55; }

.q--ok { border-left: 4px solid var(--ok); }
.q--bad { border-left: 4px solid var(--bad); }
.review.only-wrong .q--ok { display: none; }

.submit { text-align: center; margin: 1.5rem 0; }

/* Result */
.score { display: flex; align-items: center; gap: 1.25rem; padding: 1.25rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.score--pass { background: var(--ok-soft); border-color: var(--ok); }
.score--fail { background: var(--bad-soft); border-color: var(--bad); }
.score__pct { flex: none; display: grid; place-items: center; width: 6.5rem; height: 6.5rem; border-radius: 50%; font-size: 1.7rem; font-weight: 800; color: #fff; }
.score--pass .score__pct { background: var(--ok); }
.score--fail .score__pct { background: var(--bad); }
.score__text p { margin: .25rem 0 0; }
.score__subject { color: var(--muted); font-size: .9rem; }
.score h1 { font-size: 1.6rem; }
.result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: 1rem; }
.toggle { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; min-height: 44px; }
.toggle input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }

/* Pager */
.pager { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: 0 0 1rem; }
.pager__jump select { font: inherit; min-height: 40px; padding: 0 .4rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.pager__jump { margin: 0; }

.notice { padding: .75rem 1rem; border-radius: var(--radius); background: var(--bad-soft); color: var(--bad); }

/* Error */
.error { text-align: center; padding: 3rem 0; }
.error__code { font-size: 3rem; font-weight: 800; color: var(--accent); margin: 0; }
.error h1 { font-size: 1.3rem; margin-bottom: 1.5rem; }

/* Footer */
.foot { border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; padding: 1rem 0 2rem; }
.foot p { margin: .25rem 0; }

@media (max-width: 600px) {
  html { scroll-padding-top: 11rem; }
  .jump { flex-wrap: nowrap; overflow-x: auto; margin-left: -16px; margin-right: -16px; padding: 0 16px 4px; scrollbar-width: thin; }
  .jump a { flex: none; }
  .bar__status { order: 3; width: 100%; justify-content: space-between; }
  .bar__submit { min-height: 38px; padding: .3rem .8rem; }
  .pager .btn { min-width: 52px; font-size: 1.1rem; }
  .pager__text { display: none; }
  .score { flex-direction: column; text-align: center; }
  .q { padding: .85rem; }
}
