:root {
  --bg: #f6f4ef;
  --paper: #ffffff;
  --ink: #1f2328;
  --muted: #6b6f76;
  --line: #e2ded5;
  --accent: #8a3b12;
  --accent-soft: #f4e6dc;
  --ok: #1f7a3a;
  --ok-soft: #e3f3e8;
  --bad: #b42318;
  --bad-soft: #fbe7e5;
  --part: #a15c00;
  --bank: #1d4ed8;
  --bank-soft: #e6edfd;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.55 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
a { color: var(--accent); }
/* шапка по ширине колонки: название и разделы слева, вход учителя справа (specs/screens/teacher.md, «Шапка») */
.top { background: var(--paper); border-bottom: 1px solid var(--line); }
.top-in { max-width: 860px; margin: 0 auto; padding: 12px 16px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 28px; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.menu { display: flex; flex-wrap: wrap; gap: 2px 18px; font-size: 15px; }
.menu a { color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; padding: 2px 0; }
.menu a:hover { color: var(--ink); }
.menu a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.account { margin-left: auto; display: flex; align-items: baseline; gap: 12px; font-size: 15px; }
.account .link { font-size: 15px; }
.account-login { color: var(--muted); }
@media (max-width: 560px) {
  .brand { order: 1; }
  .account { order: 2; }
  .menu { order: 3; width: 100%; }
}
main { max-width: 860px; margin: 0 auto; padding: 20px 16px 40px; }
h1 { font-size: 26px; line-height: 1.25; margin: 4px 0 18px; }
h2 { font-size: 20px; margin: 28px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.crumbs { margin: 0 0 6px; font-size: 14px; color: var(--muted); }
.notice { background: var(--accent-soft); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 16px; }

/* разделы */
.cards { display: grid; gap: 12px; }
.card {
  display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; column-gap: 12px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; text-decoration: none; color: var(--ink);
}
.card:hover { border-color: var(--accent); }
.card-num { grid-row: span 2; font-size: 28px; font-weight: 700; color: var(--accent); align-self: center; text-align: center; }
.card-title { font-weight: 600; font-size: 18px; }
.card-meta { color: var(--muted); font-size: 14px; }

/* настройка теста */
.setup fieldset { border: 0; padding: 0; margin: 0 0 20px; }
.setup legend { font-weight: 700; margin-bottom: 8px; }
.topic { display: flex; gap: 10px; align-items: flex-start; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 6px; cursor: pointer; }
.topic input { margin-top: 5px; }
.topic:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.topic.off { cursor: default; color: var(--muted); background: transparent; }
.kes-code { font-weight: 700; }
/* формулировка банка, если не как в кодификаторе — specs/screens/sections.md */
.bank-wording { display: block; margin-top: 4px; padding: 2px 6px; border-radius: 4px; color: var(--bank);
  background: var(--bank-soft); font-weight: 600; }
.bank-wording.inline { display: inline; margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.row legend { width: 100%; }
.pill { cursor: pointer; }
.pill input { position: absolute; opacity: 0; }
.pill span { display: inline-block; min-width: 56px; text-align: center; padding: 8px 14px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--paper); }
.pill input:checked + span { border-color: var(--accent); background: var(--accent); color: #fff; }
.pill input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.name { display: block; margin: 0 0 20px; font-weight: 700; }
.name input { display: block; width: 100%; max-width: 420px; margin-top: 6px; font: inherit; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; font-weight: 400; }

.btn { display: inline-block; font: inherit; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .4; cursor: default; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; font-size: 14px; padding: 0; }

/* тест */
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 6px 0 14px; }
.bar { height: 100%; background: var(--accent); }
.qhead { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.question, .context { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.context summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.context .rich { margin-top: 10px; }
.hint { margin: 0 0 8px; font-weight: 600; color: var(--accent); }
.rich p { margin: 0 0 8px; }
.rich img { max-width: 100%; height: auto; display: block; margin: 8px 0; }
.rich table { border-collapse: collapse; margin: 6px 0; max-width: 100%; }
.rich td, .rich th { padding: 2px 6px; vertical-align: top; }
.rich { overflow-x: auto; }

.answer-input { font-weight: 700; }
.answer-input input { display: block; width: 100%; max-width: 420px; margin-top: 6px; font: inherit; font-size: 19px;
  padding: 8px 10px; border: 2px solid var(--line); border-radius: 8px; }
.answer-input input:focus { border-color: var(--accent); outline: none; }
.options { margin-top: 12px; display: grid; gap: 6px; }
.option { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; align-items: start; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.option input { margin-top: 6px; }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.option-num { font-weight: 700; }
.option-body p { margin: 0; }
.matching { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; }
.matching label { display: flex; flex-direction: column; align-items: center; font-weight: 700; }
.matching select { font: inherit; font-size: 19px; padding: 6px 8px; min-width: 64px; margin-top: 4px; }
/* «Распределение»: колонки рядом, на узком экране — одна под другой (specs/screens/test.md) */
.distribution { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; }
.dist-col { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px 12px; margin: 0; display: flex; gap: 10px; flex-wrap: wrap; }
.dist-col legend { font-weight: 700; padding: 0 4px; }
.dist-col select { font: inherit; font-size: 19px; padding: 6px 8px; min-width: 64px; }
.nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.dots { display: flex; flex-wrap: wrap; gap: 6px; }
.dot { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); font: inherit;
  font-size: 13px; cursor: pointer; }
.dot.done { background: var(--accent-soft); border-color: var(--accent); }
.dot.cur { outline: 2px solid var(--accent); }
.finish-early { margin-top: 14px; }

/* итог */
.result { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; text-align: center; }
.who { font-size: 22px; font-weight: 700; margin: 0; }
.big { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 10px 0; flex-wrap: wrap; }
.mark { font-size: 84px; font-weight: 800; line-height: 1; width: 120px; height: 120px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; }
.mark-5 .mark, .mark-4 .mark { background: var(--ok-soft); color: var(--ok); }
.mark-3 .mark { background: var(--accent-soft); color: var(--accent); }
.mark-2 .mark { background: var(--bad-soft); color: var(--bad); }
.score { font-size: 24px; font-weight: 600; }

/* аналитика */
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.stats { border-collapse: collapse; width: 100%; font-size: 15px; }
.stats th, .stats td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.stats th { font-size: 13px; color: var(--muted); font-weight: 600; }
.stats .num { text-align: right; white-space: nowrap; }
.stats tr.small-topic td { background: var(--accent-soft); }
.stats tr.off td { color: var(--muted); }
.stats tr.total td { font-weight: 700; border-bottom: 0; }
.stats tr.off td.mine { color: var(--ink); }
.stats tr td.mine.zero { color: var(--bad); font-weight: 700; }
.kes-markup { margin: 16px 0 28px; }
.kes-markup h3 { margin: 0 0 6px; font-size: 18px; }
.mk-point { border-bottom: 1px solid var(--line); padding: 6px 0; }
.mk-point summary { cursor: pointer; }
.mk-list { list-style: none; margin: 6px 0 4px; padding: 0 0 0 18px; }
.mk-list li { padding: 6px 0; border-top: 1px dashed var(--line); }
.mk-list p { margin: 2px 0; }
.mk-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.mk-status.ok { color: var(--ok); }
.mk-status.disputed { color: var(--part); }
.mk-empty { margin-top: 8px; font-weight: 600; color: var(--bad); }
.stats.summary td:first-child { width: 100%; }
.stats.summary tr.total td { font-weight: 400; }
.legend { display: inline-block; width: 28px; height: 14px; vertical-align: -2px; border: 1px solid var(--line); border-radius: 3px; }
.legend.small-topic { background: var(--accent-soft); }

@media (max-width: 560px) {
  body { font-size: 16px; }
  h1 { font-size: 22px; }
  .mark { font-size: 64px; width: 96px; height: 96px; }
}

/* --- экран задания: заметная смена, подсказка к ответу, панель кнопок всегда на виду --- */
.qnum { font-size: 22px; margin: 0; }
.qnum .muted { font-weight: 400; font-size: 18px; }
.context summary { font-weight: 600; }
.answer-box { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.answer-input { display: flex; flex-direction: column; gap: 6px; margin-top: 0; }
.answer-hint { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.matching.seq { align-items: flex-end; }
.matching .arrow { align-self: flex-end; padding-bottom: 10px; color: var(--muted); font-size: 20px; }
.navbar {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 14px -16px 0; padding: 10px 16px; background: rgba(246, 244, 239, .96); border-top: 1px solid var(--line);
  backdrop-filter: blur(4px);
}
.navbar .btn { min-width: 120px; }
.navbar-pos { color: var(--muted); font-size: 14px; }
.dots { margin-top: 6px; }
@keyframes flash { from { box-shadow: 0 0 0 3px var(--accent); } to { box-shadow: 0 0 0 0 transparent; } }
.question.flash { animation: flash .9s ease-out; }
@media (prefers-reduced-motion: reduce) { .question.flash { animation: none; } }
.error { color: var(--bad); margin: 10px 0 0; }
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .35); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--paper); border-radius: var(--radius); padding: 20px; max-width: 440px; width: 100%; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.modal-box h2 { margin: 0 0 8px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.btn:focus-visible, .dot:focus-visible, .link:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* --- итог --- */
.score { text-align: left; line-height: 1.2; }
.percent { font-size: 18px; color: var(--muted); font-weight: 400; }

/* клетки для ответа из цифр — как в бланке */
.cells { border: 0; padding: 0; margin: 0; }
.cells legend { font-weight: 700; margin-bottom: 6px; }
.cells-row { display: flex; flex-wrap: wrap; gap: 8px; }
.cell { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.cell input { width: 48px; height: 52px; text-align: center; font: inherit; font-size: 24px; font-weight: 700; color: var(--ink);
  border: 2px solid var(--line); border-radius: 8px; background: var(--paper); }
.cell input:focus { border-color: var(--accent); outline: none; }

/* общий материал на экране задания и в работе над ошибками — после условия, всегда раскрыт */
.material { margin-top: 14px; padding: 12px 14px; background: #faf8f3; border: 1px solid var(--line); border-radius: 8px; }
.material-title { margin: 0 0 8px; font-weight: 700; color: var(--accent); }

/* имя в окне сдачи */
.name-field { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; font-weight: 700; }
.name-field input { font: inherit; font-weight: 400; padding: 8px 10px; border: 2px solid var(--line); border-radius: 8px; }
.name-field input:focus { border-color: var(--accent); outline: none; }
.name-field .small { font-weight: 400; }

/* шапка результата */
.result-info { margin: 0 auto 6px; border-collapse: collapse; text-align: left; }
.result-info th { padding: 3px 14px 3px 0; color: var(--muted); font-weight: 400; vertical-align: top; white-space: nowrap; }
.result-info td { padding: 3px 0; }
.result-info .who { font-size: 20px; font-weight: 700; }

/* работа над ошибками */
.wm-title { margin-bottom: 2px; }
.wm { display: grid; gap: 12px; }
.wm-item { background: var(--paper); border: 1px solid var(--line); border-left-width: 6px; border-radius: var(--radius); padding: 14px 16px; }
.wm-item.ok { border-left-color: var(--ok); }
.wm-item.bad { border-left-color: var(--bad); background: #fffafa; }
.wm-item h3 { margin: 0 0 8px; font-size: 18px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.wm-verdict { font-size: 15px; font-weight: 600; }
.wm-item.ok .wm-verdict, .wm-ok { color: var(--ok); font-weight: 700; }
.wm-item.bad .wm-verdict { color: var(--bad); }
.wm-item.part { border-left-color: var(--part); background: #fffcf6; }
.wm-item.part .wm-verdict { color: var(--part); }
.qmeta { text-align: right; }
.start-variant { margin: 20px 0; }
.wm-options { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 4px; }
.wm-options li { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: start; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 8px; }
.wm-options li.right { border-color: var(--ok); background: var(--ok-soft); }
.wm-options li.wrong { border-color: var(--bad); background: var(--bad-soft); }
.wm-options .option-body p { margin: 0; }
.wm-flag { font-size: 14px; white-space: nowrap; color: var(--muted); }
.wm-options li.right .wm-flag { color: var(--ok); font-weight: 600; }
.wm-options li.wrong .wm-flag { color: var(--bad); font-weight: 600; }
.wm-answers { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.wm-answers p { margin: 0 0 4px; }
.wm-correct { display: inline-block; background: var(--ok-soft); color: var(--ok); border-radius: 6px; padding: 4px 10px; }
.wm-correct b { color: var(--ink); }

/* задания экзамена по номерам — specs/screens/exam-spec.md */
.exam-task { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 10px; }
.exam-head { display: grid; grid-template-columns: 44px 1fr; column-gap: 12px; align-items: start; }
.exam-num { font-size: 28px; font-weight: 700; color: var(--accent); text-align: center; line-height: 1.2; }
.exam-work { margin: 2px 0 0; font-weight: 600; }
.exam-head .muted { margin: 2px 0 0; }
.exam-essay { margin: 8px 0 0 56px; color: var(--muted); font-size: 14px; }
.exam-topics { margin: 8px 0 0 56px; }
.exam-topics summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.exam-topics > .muted { margin: 6px 0 0; }
.exam-sec { margin: 10px 0 2px; font-weight: 700; font-size: 15px; }
.exam-links { list-style: none; padding: 0; margin: 0; }
.exam-links li { padding: 3px 0; }
.exam-links li.off { color: var(--muted); }
.exam-links .error { margin: 2px 0 0; font-size: 14px; }
.topic-link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline;
  cursor: pointer; text-align: left; }
.topic-link:disabled { cursor: default; opacity: .6; }
@media (max-width: 560px) {
  .exam-task { padding: 10px 12px; }
  .exam-head { grid-template-columns: 32px 1fr; column-gap: 8px; }
  .exam-num { font-size: 22px; }
  .exam-essay, .exam-topics { margin-left: 0; }
}

/* вход, кабинет учителя, приглашение (specs/screens/teacher.md) */
.auth { max-width: 380px; }
.auth .name-field { margin: 0 0 14px; }
.auth .actions { margin: 6px 0 0; }

/* кабинет: вкладки, «Что нового», вопросы учителю (specs/screens/teacher.md) */
.tabs, .subtabs { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.tabs a, .subtabs a { color: var(--muted); text-decoration: none; padding: 6px 0; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a { font-size: 18px; font-weight: 600; }
.tabs a:hover, .subtabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"], .subtabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.subtabs { border-bottom-style: dashed; }
.badge { display: inline-block; padding: 0 7px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; vertical-align: 2px; }
.news { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.news li { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.news li.fresh { border-color: var(--accent); background: var(--accent-soft); }
.news-date { margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.news-text { margin: 0; white-space: pre-line; }
.q-intro { margin: 0 0 12px; }
.q-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.q-head { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; margin: 0 0 10px; font-size: 18px; }
.q-head .muted, .q-head a { font-size: 15px; font-weight: 400; }
.q-ask { background: var(--bank-soft); border-radius: 8px; padding: 10px 14px; margin: 0 0 12px; font-size: 17px; }
.q-ask p { margin: 0 0 6px; }
.q-ask p:last-child { margin-bottom: 0; }
.q-options { margin: 8px 0 0; padding-left: 24px; }
.q-options .rich p { margin: 0; }
.q-task { margin-bottom: 4px; }
.resolution { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.resolution .name-field { margin-top: 0; }
.resolution textarea { font: inherit; font-weight: 400; padding: 8px 10px; border: 2px solid var(--line); border-radius: 8px; resize: vertical; }
.resolution textarea:focus { border-color: var(--accent); outline: none; }
.resolution .actions { margin: 10px 0 0; }
.reopened { background: var(--accent-soft); border-radius: 8px; padding: 8px 12px; margin: 0 0 10px; font-weight: 600; }
.sent { margin-top: 18px; }
.sent > summary { cursor: pointer; font-weight: 700; color: var(--accent); margin-bottom: 10px; }
.q-card.done { padding: 12px 16px; }
.q-fold > summary { cursor: pointer; color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.resolution-text { margin: 0 0 4px; white-space: pre-line; }
.edit-row { margin: 6px 0 0; }
@media (max-width: 560px) { .q-card { padding: 12px; } .q-ask { font-size: 16px; } }
.tab-title { margin-top: 0; }
