/* Общая база: шрифт, цвета, кнопки, поля, виджеты вопросов. */
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/onest-cyrillic-400-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/onest-cyrillic-500-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/onest-cyrillic-600-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/onest-cyrillic-700-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/onest-cyrillic-ext-400-normal.woff2) format('woff2'); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/onest-cyrillic-ext-500-normal.woff2) format('woff2'); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/onest-cyrillic-ext-600-normal.woff2) format('woff2'); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/onest-cyrillic-ext-700-normal.woff2) format('woff2'); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/onest-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 500; font-display: swap; src: url(/fonts/onest-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/onest-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/onest-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/onest-latin-ext-400-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 600; font-display: swap; src: url(/fonts/onest-latin-ext-600-normal.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --ink: #18202f;
  --ink-2: #3a4456;
  --muted: #5d6778;
  --paper: #f2f4f7;
  --surface: #ffffff;
  --sunken: #e9ecf1;
  --line: #dce1e8;
  --line-strong: #c3cad5;
  --accent: #2d4be0;
  --accent-deep: #1f36b3;
  --accent-soft: #e6eafd;
  --ok: #16875a;
  --ok-soft: #e2f4ec;
  --warn: #a96f08;
  --warn-soft: #fbf1dc;
  --bad: #cc3340;
  --bad-soft: #fbe6e8;
  --r-lg: 16px;
  --r-md: 10px;
  --r-sm: 6px;
  --shadow: 0 1px 2px rgba(24, 32, 47, 0.06), 0 6px 24px -12px rgba(24, 32, 47, 0.18);
  --font: 'Onest', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', 'Consolas', 'SF Mono', monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 15px/1.5 var(--font); color: var(--ink); background: var(--paper); font-feature-settings: 'tnum' 0; }
h1, h2, h3, h4 { font-weight: 650; line-height: 1.2; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 0.8em; }
a { color: var(--accent); }
code { font-family: var(--mono); font-size: 0.92em; background: var(--sunken); padding: 1px 5px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden, [hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

/* кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 500 14px/1 var(--font); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 10px 14px; min-height: 40px;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--sunken); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.solid-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--sunken); }
.btn.small { padding: 6px 10px; min-height: 32px; font-size: 13px; border-radius: var(--r-sm); }
.btn.wide { width: 100%; }
.icon { font: 600 15px/1 var(--font); width: 32px; height: 32px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; color: var(--ink); }
.icon:hover:not(:disabled) { background: var(--sunken); }
.icon:disabled { opacity: 0.35; cursor: default; }

/* поля */
input[type=text], input[type=password], input[type=number], input[type=search], input[type=datetime-local], input[type=email], input:not([type]), select, textarea {
  font: 400 15px/1.4 var(--font); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 9px 12px; min-height: 40px; width: 100%;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field > small { color: var(--muted); font-size: 12.5px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.error { color: var(--bad); font-size: 14px; min-height: 1em; margin-top: 8px; }

/* текст вопросов */
.rich p { margin: 0 0 0.6em; }
.rich p:last-child { margin-bottom: 0; }
.rich ul, .rich ol { margin: 0 0 0.6em; padding-left: 1.4em; }
.codeblock { font: 13.5px/1.55 var(--mono); background: #f6f7f9; border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; overflow-x: auto; white-space: pre; margin: 0 0 0.8em; }
.qimage { display: block; max-width: 100%; max-height: 420px; border-radius: var(--r-md); border: 1px solid var(--line); margin: 4px 0 14px; background: #fff; }

/* виджеты ответа */
.answer .hint { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.answer .hint.right { text-align: right; margin: 6px 0 0; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left;
  font: 400 15px/1.45 var(--font); color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.opt:hover:not(:disabled) { border-color: var(--line-strong); background: #fafbfc; }
.opt .mark { flex: none; width: 20px; height: 20px; margin-top: 1px; border: 2px solid var(--line-strong); border-radius: 50%; display: grid; place-items: center; }
.opt.multi .mark { border-radius: 5px; }
.opt .letter { flex: none; font-weight: 600; color: var(--muted); min-width: 14px; }
.opt .otext { flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; }
.opt.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt.selected .mark { border-color: var(--accent); background: var(--accent); }
.opt.selected .mark::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.opt.multi.selected .mark::after { width: 10px; height: 5px; border-radius: 0; background: none; border: solid #fff; border-width: 0 0 2px 2px; transform: rotate(-45deg) translate(1px, -1px); }
.tfrow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tfrow .opt { justify-content: center; align-items: center; padding: 16px; font-weight: 500; }
.textans { font-size: 16px !important; max-width: 520px; }
.essay { min-height: 220px; font-size: 15.5px !important; }
.order-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.order-item { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 8px 10px 8px 12px; cursor: grab; }
.order-item:active { cursor: grabbing; border-color: var(--accent); }
.order-item .onum { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--sunken); display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.order-item .otext { flex: 1; white-space: pre-wrap; }
.order-item .omove { display: flex; gap: 4px; }
.answer-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.match-grid { display: flex; flex-direction: column; gap: 8px; }
.match-row { display: grid; grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr); gap: 10px; align-items: center; }
.match-left { background: var(--sunken); border-radius: var(--r-md); padding: 10px 12px; white-space: pre-wrap; }
.match-arrow { color: var(--muted); text-align: center; }
.match-row select.set { border-color: var(--accent); background: var(--accent-soft); }
@media (max-width: 640px) {
  .match-row { grid-template-columns: 1fr; gap: 4px; }
  .match-arrow { display: none; }
}

/* статусы */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 500; padding: 2px 9px; border-radius: 999px; background: var(--sunken); color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent-deep); }
.pill.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

/* диалоги и уведомления */
.dialog-back { position: fixed; inset: 0; background: rgba(24, 32, 47, 0.42); display: grid; place-items: center; padding: 20px; z-index: 9500; }
.dialog { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); width: min(520px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 24px; }
.dialog.wide { width: min(920px, 100%); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 10050; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r-md); font-size: 14px; box-shadow: var(--shadow); transition: opacity 0.3s; max-width: 90vw; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
.toast.out { opacity: 0; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
