:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6a66;
  --line: #e2e0da;
  --accent: #2f5bd3;
  --accent-soft: #e6ecfb;
  --ok: #1f7a4a;
  --bad: #b3261e;
  --warn-bg: #fff4d6;
  --warn-line: #e9c46a;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --surface: #1f1f1d;
    --text: #ecebe7;
    --muted: #9b9a95;
    --line: #34332f;
    --accent: #7c9cf0;
    --accent-soft: #232c45;
    --ok: #5fc48d;
    --bad: #ef7a71;
    --warn-bg: #3a3220;
    --warn-line: #8a7433;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 760px; margin: 0 auto; padding: 32px 16px 64px; }
.wrap.wide { max-width: 1180px; }
h1 { font-size: 26px; line-height: 1.25; margin: 0 0 6px; }
h2 { font-size: 19px; margin: 36px 0 10px; }
.sub { color: var(--muted); margin: 0 0 24px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
}
.warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 16px 0;
}
label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type=text] {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
input[type=text]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin-top: 14px; }
.check input { margin-top: 4px; }
button {
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--accent); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
kbd {
  display: inline-block;
  min-width: 28px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 6px;
  background: var(--surface);
  font: 600 14px/1.4 ui-monospace, Menlo, Consolas, monospace;
  text-align: center;
}
ol.steps { padding-left: 20px; }
ol.steps li { margin: 6px 0; }

/* ---------- экран теста ---------- */
#stage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: var(--muted);
  font-size: 14px;
}
.progress { flex: 1; max-width: 360px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
}
.question {
  font-size: clamp(24px, 4.2vw, 40px);
  line-height: 1.3;
  font-weight: 600;
  max-width: 900px;
  min-height: 2.6em;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fixation { font-size: 48px; color: var(--muted); }
.hint { color: var(--muted); margin-top: 22px; }
.keys {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 18px 16px 28px;
}
.keys button {
  min-width: 140px;
  padding: 14px 18px;
  font-size: 18px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}
.keys button kbd { margin-left: 8px; }
.feedback { margin-top: 18px; font-weight: 600; min-height: 1.5em; }
.feedback.ok { color: var(--ok); }
.feedback.bad { color: var(--bad); }

/* ---------- отчёт и результаты ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; }
ul.contra { padding-left: 20px; }
ul.contra li { margin: 8px 0; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; margin-right: 6px; }
.tag.logic { background: var(--accent-soft); color: var(--accent); }
.tag.double { background: var(--warn-bg); color: var(--text); border: 1px solid var(--warn-line); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-weight: 600; color: var(--muted); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
th.sortable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent-soft); }
.sig { color: var(--ok); font-weight: 600; }
.ns { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.chart { width: 100%; max-width: 760px; height: auto; display: block; margin: 0 auto; }
.chart text { fill: var(--text); font: 13px system-ui, sans-serif; }
.chart .axis { stroke: var(--line); }
.chart .bar { fill: var(--accent); }
.chart .err { stroke: var(--text); stroke-width: 1.5; }
.chart .lineplot { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .dot { fill: var(--accent); }
.downloads a { margin-right: 16px; }
details summary { cursor: pointer; font-weight: 600; }
.pill-yes { color: var(--ok); font-weight: 600; }
.pill-no { color: var(--bad); font-weight: 600; }
@media (max-width: 600px) {
  .keys button { min-width: 0; flex: 1; }
  .keys button kbd { display: none; }
}
