:root {
  --bg: #f1f4f7;
  --surface: #ffffff;
  --text: #14202b;
  --muted: #566574;
  --border: #d5dde5;
  --accent: #1d5fc4;
  --accent-text: #ffffff;
  --accent-soft: #e3edfb;
  --good: #17714a;
  --good-soft: #dff2e8;
  --bad: #b3261e;
  --bad-soft: #fbe4e2;
  --flag: #a85d00;
  --warn-soft: #fff4d6;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f161d;
    --surface: #17212a;
    --text: #e6edf3;
    --muted: #94a4b3;
    --border: #2a3845;
    --accent: #6aa5f2;
    --accent-text: #0b1520;
    --accent-soft: #1c2d44;
    --good: #5fd09a;
    --good-soft: #143326;
    --bad: #ff8a80;
    --bad-soft: #3a1c1a;
    --flag: #f0b25a;
    --warn-soft: #3a3115;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--sans);
}
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 800px; margin: 0 auto; padding: 0 16px; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .9rem; margin: 0; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 8px; font-weight: 600; text-wrap: balance; }
h2 { font-size: 1.1rem; margin: 0; font-weight: 600; }
p { margin: 0; }

/* Header and footer */
header.site { border-bottom: 1px solid var(--border); background: var(--surface); }
header.site .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { font-weight: 600; font-size: 1.1rem; color: var(--text); text-decoration: none; }
#account { display: flex; align-items: center; gap: 10px; min-width: 0; }
#account .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; font-size: .9rem; }
main { padding: 28px 0 64px; }
footer.site { border-top: 1px solid var(--border); padding: 20px 0; font-size: .85rem; }

/* Generic blocks */
.card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; min-width: 0; }
.panel { display: flex; flex-direction: column; gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spacer { flex: 1; }
.label { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.notice { border-radius: var(--radius); padding: 14px 16px; background: var(--accent-soft); display: flex; flex-direction: column; gap: 10px; }
.notice.warn { background: var(--warn-soft); }

/* Home page exam cards */
.exam-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; transition: border-color .15s; }
.exam-card:hover { border-color: var(--accent); }
.exam-card .code { font-family: var(--mono); font-weight: 600; font-size: 1.1rem; color: var(--accent); }
.exam-card .meta { margin-top: auto; font-size: .9rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text); font-weight: 600; text-decoration: none;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-small { padding: 6px 12px; font-size: .9rem; }

/* Segmented controls and chips */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 8px 14px; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px;
  font-size: .9rem; display: inline-flex; gap: 6px; align-items: center; text-align: left;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); font-weight: 500; }
.chip .n { font-family: var(--mono); font-size: .75rem; color: var(--muted); font-weight: 400; }
.chip:disabled { cursor: default; }

/* Forms (login page) */
.field { display: block; font-weight: 600; margin-bottom: 6px; }
select, input[type=email] {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}

/* Question sets and objective coverage */
.sets { display: flex; flex-direction: column; gap: 12px; }
.set-group .name { font-size: .9rem; margin-bottom: 6px; }
details.cov { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
details.cov summary { cursor: pointer; font-weight: 600; }
.covbox { display: flex; flex-direction: column; gap: 2px; max-height: 420px; overflow: auto; margin-top: 8px; }
.covrow {
  display: flex; justify-content: space-between; gap: 12px; text-align: left; background: transparent;
  border: 1px solid transparent; border-radius: 8px; padding: 6px 8px;
}
.covrow:hover:not(:disabled) { border-color: var(--border); }
.covrow:disabled { opacity: .55; cursor: default; }
.covrow .n { font-family: var(--mono); font-size: .8rem; color: var(--muted); white-space: nowrap; }

/* Quiz */
.bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.prog { flex: 1; min-width: 100px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.prog > i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.meta { font-family: var(--mono); font-size: .82rem; color: var(--muted); white-space: nowrap; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: .78rem; border: 1px solid var(--border); border-radius: 4px; padding: 1px 7px; color: var(--muted); }
.timer { font-family: var(--mono); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.timer.low { color: var(--bad); }
.qtext { font-size: 1.06rem; font-weight: 500; overflow-wrap: anywhere; }
.opts { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.opt {
  width: 100%; text-align: left; display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 11px 13px; min-width: 0;
}
.opt .k { font-family: var(--mono); font-weight: 500; flex: none; width: 1.5em; color: var(--muted); }
.opt .t { overflow-wrap: anywhere; min-width: 0; }
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled { cursor: default; }
.expl { border-left: 3px solid var(--accent); padding: 2px 0 2px 12px; display: flex; flex-direction: column; gap: 6px; }
.verdict { font-weight: 600; }
.verdict.ok { color: var(--good); }
.verdict.no { color: var(--bad); }
.refs { font-size: .88rem; display: flex; flex-direction: column; gap: 2px; }
.refs .label { margin: 4px 0 0; }
.refs a { overflow-wrap: anywhere; }
.nav { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.flagbtn[aria-pressed="true"] { color: var(--flag); border-color: var(--flag); }
.map { display: flex; flex-wrap: wrap; gap: 6px; }
.map button {
  width: 34px; height: 34px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 6px; font-family: var(--mono); font-size: .8rem; position: relative;
}
.map button.done { background: var(--accent-soft); border-color: var(--accent); }
.map button.cur { outline: 2px solid var(--accent); outline-offset: 1px; }
.map button.fl::after { content: ""; position: absolute; top: 2px; right: 2px; width: 7px; height: 7px; border-radius: 50%; background: var(--flag); }

/* Results */
.score { font-size: 2.6rem; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.score.pass { color: var(--good); }
.score.fail { color: var(--bad); }
.dom { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; }
.dom .pc { font-family: var(--mono); text-align: right; font-size: .85rem; }
.dom .b { grid-column: 1 / -1; height: 7px; background: var(--border); border-radius: 4px; overflow: hidden; }
.dom .b i { display: block; height: 100%; background: var(--accent); }
.rev { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 16px; }
.rev:first-child { border-top: 0; padding-top: 0; }
.ansline { font-size: .92rem; }

@media (max-width: 560px) {
  h1 { font-size: 1.35rem; }
  .card, .panel { padding: 14px; }
  #account .email { display: none; }
  .seg button { padding: 8px 11px; }
}
@media (prefers-reduced-motion: reduce) { .prog > i { transition: none; } }

.brandline { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.crumb { font-family: var(--mono); font-weight: 600; color: var(--accent); white-space: nowrap; }
.crumb:not(:empty)::before { content: "/"; color: var(--muted); margin-right: 10px; font-weight: 400; }
.official { margin-top: 6px; }
#account .btn { white-space: nowrap; }
.paywall { border-color: var(--accent); background: var(--accent-soft); }
.legal h2 { margin-top: 8px; }
.legal ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.admin-filters { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.admin-filters .wide { grid-column: 1 / -1; }
input[type=search] { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
