:root {
  /* цвета и шрифты сайта школы «Тенгр» */
  --bg: #F3F5F7;
  --card: #FFFFFF;
  --ink: #14161A;
  --muted: #5B6270;
  --line: #DFE3E8;
  --line-2: #C2C8D1;
  --soft: #F6F8FA;
  --blue: #1C3766;
  --blue-2: #13294B;
  --bsoft: #EAEFF6;
  --akane: #8C2B3D;
  --green: #2E7D5B;
  --gsoft: #E0EFE6;
  --amber: #A5680C;
  --asoft: #F6EAD2;
  --red: #A93A36;
  --rsoft: #F6E1DE;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(19, 41, 75, .05), 0 8px 24px rgba(19, 41, 75, .06);
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --body: "PT Serif", Georgia, "Times New Roman", serif;
  --sans: "PT Sans", -apple-system, "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg { max-width: 100%; }
a { color: var(--blue); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; font-weight: 700; text-wrap: balance; }
h1 { font-family: var(--serif); line-height: 1.1; }
h1 { font-size: clamp(28px, 6vw, 38px); }
h2 { font-size: 21px; }
h3 { font-size: 18px; }
p { margin: 0 0 1em; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(28, 55, 102, .45); outline-offset: 2px; }

/* ---------- каркас ---------- */
.top {
  border-bottom: 1px solid var(--line);
  background: rgba(243, 245, 247, .94);
}
.top-in, .wrap, .foot-in {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}
.wrap-wide { max-width: 1180px; }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.brand { font-family: var(--serif); font-weight: 700; font-size: 20px; color: var(--ink); text-decoration: none; letter-spacing: .05em; white-space: nowrap; }
.brand em { font-style: italic; font-weight: 600; color: #535E76; }
.brand-mark { display: none; }
.top-link { font-size: 14px; font-weight: 700; color: var(--blue); text-decoration: none; white-space: nowrap; }
main { flex: 1; padding: 28px 0 40px; }
body.running main { padding-top: 0; }
.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.foot-in { padding-top: 18px; padding-bottom: 24px; display: flex; flex-wrap: wrap; gap: 8px 20px; }
.foot a { color: var(--muted); }

.lead { font-size: 18px; color: var(--muted); max-width: 36em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.section-title { font-size: 15px; font-weight: 600; color: var(--muted); text-transform: none; margin: 28px 0 12px; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 12px 22px;
  border-radius: 4px; border: 1px solid transparent;
  font-weight: 600; font-size: 17px; line-height: 1.2;
  text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-2); }
.btn-secondary { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { border-color: var(--line-2); }
.btn-ghost { background: transparent; color: var(--blue); padding-left: 10px; padding-right: 10px; }
.btn-danger { background: var(--red); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 8px 14px; font-size: 15px; border-radius: 4px; }
.btn[disabled] { opacity: .55; cursor: default; }

/* ---------- главная ---------- */
.grades { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grade-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 16px; min-height: 88px;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--card); cursor: pointer; text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.grade-btn b { font-size: 30px; line-height: 1.1; white-space: nowrap; }
.grade-btn b small { font-size: 17px; font-weight: 600; }
.grade-btn span { font-size: 14px; color: var(--muted); }
.grade-btn[aria-pressed="true"] { border-color: var(--blue); background: var(--bsoft); box-shadow: inset 0 0 0 1px var(--blue); }
.subjects { display: grid; gap: 10px; }
.subject {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
}
.subject:hover { border-color: var(--line-2); }
.subject-body { flex: 1; min-width: 0; }
.subject-name { font-weight: 600; font-size: 18px; }
.subject-meta { color: var(--muted); font-size: 14px; }
.subject-arrow { color: var(--blue); font-size: 22px; line-height: 1; }
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; white-space: nowrap; vertical-align: 2px;
  background: var(--bsoft); color: var(--blue);
}
.chip-good { background: var(--gsoft); color: var(--green); }
.chip-gaps { background: var(--asoft); color: var(--amber); }
.chip-bad { background: var(--rsoft); color: var(--red); }
.chip-muted { background: #E9EDF1; color: var(--muted); }
.empty { padding: 20px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); background: rgba(255,255,255,.5); }

/* ---------- формы ---------- */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.field-label .optional { font-weight: 400; color: var(--muted); }
.input, select.input {
  display: block; width: 100%;
  min-height: 52px; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 4px; background: #fff;
  font-size: 18px; appearance: none; -webkit-appearance: none;
}
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(28,55,102,.15); }
.input.invalid { border-color: var(--red); }
.field-error { color: var(--red); font-size: 14px; margin-top: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span {
  display: flex; align-items: center; justify-content: center; min-height: 50px;
  border: 1.5px solid var(--line); border-radius: 4px; background: #fff; font-weight: 600; cursor: pointer;
}
.seg input:checked + span { border-color: var(--blue); background: var(--bsoft); color: var(--blue); }
.seg input:focus-visible + span { outline: 3px solid rgba(28,55,102,.45); outline-offset: 2px; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: 15px; line-height: 1.45; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--blue); }
.alert { padding: 12px 14px; border-radius: 4px; font-size: 15px; }
.alert-error { background: var(--rsoft); color: #7d2a22; }
.alert-warn { background: var(--asoft); color: #6d4a0c; }
.alert-info { background: var(--bsoft); color: #213f60; }
.profile-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- тест ---------- */
.runbar {
  position: sticky; top: 0; z-index: 5;
  background: rgba(243, 245, 247, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.runbar-in { max-width: 760px; margin: 0 auto; padding: 10px 16px; }
.runbar-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.runbar-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; white-space: nowrap; color: var(--muted); }
.timer.low { color: var(--amber); }
.timer.over { color: var(--red); }
.progress-line { display: flex; align-items: center; gap: 12px; margin-top: 6px; font-size: 14px; color: var(--muted); }
.bar { flex: 1; height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--blue); border-radius: 999px; transition: width .2s; }
.q-card { margin-top: 18px; }
.q-num { font-size: 14px; font-weight: 600; color: var(--blue); margin-bottom: 8px; }
.q-text { font-size: 18px; line-height: 1.55; }
.q-text p:last-child { margin-bottom: 0; }
.q-extra { font-size: 14px; color: var(--muted); margin-top: 10px; }
.q-input { margin-top: 18px; }
.hint { font-size: 14px; color: var(--muted); margin: 8px 0 0; }
.opts { display: grid; gap: 10px; }
.opt { position: relative; display: block; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.opt input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.opt-body {
  display: flex; align-items: flex-start; gap: 12px;
  min-height: 56px; padding: 14px 16px;
  border: 1.5px solid var(--line); border-radius: 4px; background: #fff;
  font-size: 17px; line-height: 1.4;
  transition: border-color .12s, background-color .12s;
}
.opt-mark {
  flex: none; width: 22px; height: 22px; margin-top: 1px;
  border: 2px solid var(--line-2); border-radius: 50%; background: #fff; position: relative;
}
.opt-multi .opt-mark { border-radius: 6px; }
.opt input:checked + .opt-body { border-color: var(--blue); background: var(--bsoft); }
.opt input:checked + .opt-body .opt-mark { border-color: var(--blue); background: var(--blue); }
.opt input:checked + .opt-body .opt-mark::after {
  content: ''; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.opt input:focus-visible + .opt-body { outline: 3px solid rgba(28,55,102,.45); outline-offset: 2px; }
.opt-text { min-width: 0; overflow-wrap: anywhere; }
.nav-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.dots { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.dot {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1.5px solid var(--line); background: #fff; color: var(--muted);
  font-size: 14px; font-weight: 600; cursor: pointer; padding: 0;
  font-variant-numeric: tabular-nums;
}
.dot.done { background: var(--blue); border-color: var(--blue); color: #fff; }
.dot.cur { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--ink); }
.finish-row { margin-top: 22px; }
.timeout { margin-top: 16px; }

/* markdown внутри условий */
.md table { border-collapse: collapse; font-size: 16px; min-width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--soft); font-weight: 600; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 12px 0; border-radius: 8px; max-width: 100%; }
.md ul, .md ol { padding-left: 1.3em; }
.md blockquote { margin: 0 0 1em; padding: 8px 14px; border-left: 3px solid var(--line); color: var(--muted); }
.md code { background: #EEF1F5; padding: 1px 5px; border-radius: 5px; font-size: .92em; }
.md pre { background: #EEF1F5; padding: 12px; border-radius: 4px; overflow-x: auto; }
.katex { font-size: 1.08em; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* ---------- модальное окно ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(19, 41, 75, .45);
  display: flex; align-items: flex-end; justify-content: center; padding: 16px;
}
.modal { background: #fff; border-radius: 8px; padding: 22px; width: 100%; max-width: 440px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal h2 { font-size: 20px; }
.modal-actions { display: grid; gap: 10px; margin-top: 18px; }
@media (min-width: 560px) {
  .modal-back { align-items: center; }
  .modal-actions { grid-template-columns: 1fr 1fr; }
}

/* ---------- результат ---------- */
.result-head { margin-bottom: 20px; }
.big-score { font-size: clamp(30px, 8vw, 42px); font-weight: 700; letter-spacing: -.02em; margin: 0 0 4px; }
.topics { display: grid; gap: 12px; }
.topic-row { padding: 16px 18px; }
.topic-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.topic-name { font-weight: 600; font-size: 17px; }
.topic-bar { height: 10px; background: #E9EDF1; border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.topic-bar > i { display: block; height: 100%; border-radius: 999px; }
.topic-bar .good { background: var(--green); }
.topic-bar .gaps { background: var(--amber); }
.topic-bar .bad { background: var(--red); }
.topic-meta { font-size: 14px; color: var(--muted); }
.topic-advice { font-size: 15px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.marks { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
.mark {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  height: 44px; border-radius: 4px; font-weight: 600; font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.mark.ok { background: var(--gsoft); color: var(--green); }
.mark.no { background: var(--rsoft); color: var(--red); }
.callout { background: var(--bsoft); border-radius: var(--radius); padding: 18px 20px; margin: 24px 0 16px; }
.callout p { margin: 0; }
.callout .phone { font-size: 20px; font-weight: 700; margin-top: 6px; display: inline-block; }

/* ---------- админка ---------- */
.admin-top .top-in { max-width: 1180px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { border: 1px solid var(--line); background: #fff; padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: 15px; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.filters .input { min-height: 44px; font-size: 16px; padding: 8px 12px; }
.filters .search { grid-column: 1 / -1; }
.filters .actions { grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; }
@media (min-width: 900px) {
  .filters { grid-template-columns: 140px 220px 1fr auto; }
  .filters .search, .filters .actions { grid-column: auto; }
}
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.data { border-collapse: collapse; width: 100%; font-size: 14.5px; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: top; }
table.data th { font-size: 13px; color: var(--muted); font-weight: 600; background: var(--soft); position: sticky; top: 0; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.link { cursor: pointer; }
table.data tbody tr.link:hover td { background: var(--soft); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .sub { display: block; color: var(--muted); font-size: 13px; white-space: normal; max-width: 220px; }
.flag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--rsoft); color: var(--red); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.aq { margin-top: 12px; }
.aq-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.aq-head .q-num { margin: 0; }
.aq .q-text { font-size: 16px; }
.aq-opts { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.aq-opts li { padding: 8px 12px; border: 1px solid var(--line); border-radius: 4px; font-size: 15px; display: flex; gap: 10px; justify-content: space-between; }
.aq-opts li.correct { border-color: var(--green); background: var(--gsoft); }
.aq-opts li.picked-wrong { border-color: var(--red); background: var(--rsoft); }
.aq-opts .tag { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.aq-answers { display: grid; gap: 4px; margin-top: 12px; font-size: 15px; }
.aq-answers code { background: #EEF1F5; padding: 1px 6px; border-radius: 6px; font-family: inherit; font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.aq-solution { margin-top: 12px; padding: 10px 12px; background: var(--soft); border-radius: 4px; font-size: 15px; }
.login-box { max-width: 380px; margin: 40px auto; }
.summary-grid { display: grid; gap: 16px; }
@media (min-width: 900px) { .summary-grid { grid-template-columns: 1fr 1fr; } }
.two-col { display: grid; gap: 16px; }
@media (min-width: 900px) { .two-col { grid-template-columns: 1fr 1fr; } }

/* ---------- политика ---------- */
.draft-banner { background: var(--asoft); color: #6d4a0c; border-radius: 4px; padding: 12px 16px; font-weight: 600; margin-bottom: 20px; }
.prose h2 { margin-top: 1.4em; }

@media (max-width: 420px) {
  body { font-size: 16px; }
  .card { padding: 16px; }
  .grade-btn { padding: 12px; min-height: 80px; }
  .grade-btn b { font-size: 26px; }
  .grade-btn b small { font-size: 15px; }
  .row2 { grid-template-columns: 1fr; gap: 0; }
}

/* таблица прохождений на телефоне: строки превращаются в карточки */
@media (max-width: 700px) {
  table.data.cards thead { display: none; }
  table.data.cards, table.data.cards tbody, table.data.cards tr, table.data.cards td { display: block; width: 100%; }
  table.data.cards tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.data.cards tr:last-child { border-bottom: 0; }
  table.data.cards td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0; border: 0; white-space: normal; text-align: right; }
  table.data.cards td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; flex: none; }
  table.data.cards td:empty { display: none; }
  table.data.cards .sub { max-width: none; }
  table.data.cards tbody tr.link:hover td { background: transparent; }
}

/* одиночный выбор: точка вместо галочки */
.opts:not(.opt-multi) .opt input:checked + .opt-body .opt-mark::after {
  left: 4px; top: 4px; width: 10px; height: 10px; border: 0; border-radius: 50%; background: #fff; transform: none;
}

/* ---------- текст в стиле сайта ---------- */
.lead, .q-text, .md, .topic-advice, .prose p { font-family: var(--body); }
.big-score { font-family: var(--serif); }
.section-title { font-family: var(--sans); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; font-weight: 700; color: var(--muted); }
.btn-primary { background: var(--blue); }
.md pre, .md code { font-family: Menlo, Consolas, "Roboto Mono", "Liberation Mono", monospace; font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
/* длинные строки кода переносим, а не прячем за прокрутку: на телефоне ученик может не заметить конец строки */
.md pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.md pre code { background: none; padding: 0; font-size: 14px; white-space: inherit; }
@media (max-width: 420px) { .md pre code { font-size: 13px; } }
