@font-face { font-family: 'Inter'; font-weight: 400; font-display: swap; src: url('fonts/Inter-Regular.woff') format('woff'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-display: swap; src: url('fonts/Inter-Medium.woff') format('woff'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-display: swap; src: url('fonts/Inter-SemiBold.woff') format('woff'); }
@font-face { font-family: 'Inter'; font-weight: 700; font-display: swap; src: url('fonts/Inter-Bold.woff') format('woff'); }
@font-face { font-family: 'Inter'; font-weight: 800; font-display: swap; src: url('fonts/Inter-ExtraBold.woff') format('woff'); }

:root {
  --bg: #F2F2F2;
  --card: #FFFFFF;
  --ink: #222222;
  --muted: #5E5E5E;
  --line: #E4E4E4;
  --line-soft: #EDEDED;
  --field: #CFCFCF;
  --moss: #2B4A3C;
  --moss-dark: #1D3329;
  --bamboo: #E3E8D8;
  --stone: #8A9B8F;
  --stone-soft: #C9D2CB;
  --ok-bg: #D9E6DA;
  --blossom: #FFA7A7;
  --bad-bg: #FFE0E0;
  --bad-ink: #8C2A2A;
  --bad-dark: #4A1515;
  --radius: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px; line-height: 1.5;
}
a { color: var(--moss); }
a:hover { color: var(--moss-dark); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--blossom); outline-offset: 2px; }
h1 { margin: 0 0 6px; font-size: 30px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
h2 { margin: 0 0 4px; font-size: 19px; font-weight: 800; }
h3 { margin: 0 0 4px; font-size: 16px; font-weight: 800; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 13px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- Шапка --- */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); }
.topbar.teacher { background: var(--moss); border-bottom: none; color: #fff; }
.topbar .in { max-width: 1180px; margin: 0 auto; padding: 12px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; text-decoration: none; color: inherit; }
.brand:hover { color: inherit; }
.logo { width: 36px; height: 36px; border-radius: 10px; background: var(--moss); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
.teacher .logo { background: var(--bamboo); color: var(--moss); }
.nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }
.nav a { height: 40px; padding: 0 12px; border-radius: 10px; display: flex; align-items: center; text-decoration: none; font-weight: 700; color: var(--muted); }
.nav a:hover { background: var(--line-soft); color: var(--ink); }
.nav a.active { background: var(--bamboo); color: var(--moss); }
.teacher .nav a { color: #D5DDCF; }
.teacher .nav a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.teacher .nav a.active { background: var(--bamboo); color: var(--moss); }
.who { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.teacher .who { color: #D5DDCF; }
.who form { margin: 0; }
.who .linkbtn { color: inherit; opacity: 0.85; }

main.page { max-width: 1180px; margin: 0 auto; padding: 32px 24px 80px; }
.narrow { max-width: 820px; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.row-end { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; justify-content: space-between; }
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.split > .main { flex: 999 1 520px; min-width: 0; }
.split > .side { flex: 1 1 320px; min-width: 0; }
.split > .half { flex: 1 1 380px; min-width: 0; }
.back { display: inline-flex; align-items: center; height: 40px; font-weight: 700; text-decoration: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.card.tight { padding: 16px 20px; }
.card + .card { margin-top: 0; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 16px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 800; margin-top: 2px; }
.stat .value small { font-size: 15px; color: var(--muted); font-weight: 600; }

/* --- Кнопки --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 20px; border-radius: 10px; border: none; font-weight: 700; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--moss); color: #fff; }
.btn-primary:hover { background: var(--moss-dark); color: #fff; }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--field); }
.btn-secondary:hover { background: var(--line-soft); color: var(--ink); }
.btn-outline { background: #fff; color: var(--moss); border: 1px solid var(--moss); }
.btn-outline:hover { background: var(--bamboo); color: var(--moss); }
.btn-error { background: var(--blossom); color: var(--bad-dark); }
.btn-error:hover { background: #F59494; color: var(--bad-dark); }
.btn-soft { background: var(--bamboo); color: var(--moss); }
.btn-soft:hover { background: #D6DDC6; color: var(--moss); }
.btn-danger { background: #fff; color: var(--bad-ink); border: 1px solid #EBC1C1; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 14px; }
.btn[disabled], .btn.disabled { opacity: 0.45; cursor: not-allowed; }
.linkbtn { background: none; border: none; padding: 0; font-weight: 700; color: var(--moss); text-decoration: underline; text-underline-offset: 3px; }
.inline { display: inline; margin: 0; }

/* --- Метки --- */
.chip { display: inline-flex; align-items: center; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--line-soft); color: var(--ink); white-space: nowrap; }
.chip-ege { background: var(--bamboo); color: var(--moss); border-radius: 8px; font-weight: 800; }
.chip-oge { background: var(--stone-soft); color: #22332A; border-radius: 8px; font-weight: 800; }
.chip-all { background: var(--line-soft); color: var(--ink); border-radius: 8px; font-weight: 800; }
.chip-ok { background: var(--ok-bg); color: var(--moss); }
.chip-bad { background: var(--bad-bg); color: var(--bad-ink); }
.chip-wait { background: var(--bamboo); color: var(--moss); }
.chip-new { background: var(--line-soft); color: var(--ink); }
.chip-square { border-radius: 8px; }
.warn { color: var(--bad-ink); font-weight: 700; }

/* --- Сообщения --- */
.flash { padding: 14px 18px; border-radius: 12px; background: var(--ok-bg); color: var(--moss); font-weight: 600; }
.flash.bad { background: var(--bad-bg); color: var(--bad-ink); }
.flash.info { background: var(--bamboo); color: var(--moss); }
.rule-box { white-space: pre-line; padding: 12px 16px; border-radius: 10px; background: var(--bamboo); color: var(--moss); font-size: 14px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* --- Формы --- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-weight: 700; font-size: 14px; }
.field .hint { font-size: 13px; color: var(--muted); }
.input, select.input, textarea.input {
  height: 44px; padding: 0 12px; border: 1px solid var(--field); border-radius: 10px; background: #fff; color: var(--ink); width: 100%; min-width: 0;
}
textarea.input { height: auto; min-height: 90px; padding: 12px; resize: vertical; line-height: 1.55; }
.input:disabled { background: var(--line-soft); border-color: var(--line); }
.input.over { border: 2px solid var(--bad-ink); background: var(--bad-bg); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.checkline { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; cursor: pointer; }
.checkline input { width: 20px; height: 20px; accent-color: var(--moss); }
fieldset { border: none; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; font-weight: 700; font-size: 14px; margin-bottom: 8px; }

/* сегменты и пилюли на радиокнопках/галочках */
.seg { display: inline-flex; flex-wrap: wrap; background: var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 9px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg input:checked + span { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.12); }
.seg input:focus-visible + span { outline: 3px solid var(--blossom); }
.seg a { display: flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 9px; font-weight: 700; color: var(--muted); text-decoration: none; }
.seg a.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.12); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pills label { position: relative; }
.pills input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pills span, .pills a { display: inline-flex; align-items: center; height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--field); background: #fff; font-weight: 700; cursor: pointer; text-decoration: none; color: var(--ink); }
.pills input:checked + span, .pills a.on { border: 2px solid var(--moss); background: var(--bamboo); color: var(--moss); padding: 0 15px; }
.pills input:focus-visible + span { outline: 3px solid var(--blossom); }

/* --- Таблицы --- */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 13px; font-weight: 700; color: var(--muted); padding: 14px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table td.name { font-weight: 700; }
.table td.name .sub { display: block; font-weight: 500; font-size: 13px; color: var(--muted); }
.table tr.absent td { background: #F7F7F7; }
.table .num-input { width: 110px; font-weight: 700; font-size: 16px; }
.table-plain { width: 100%; border-collapse: collapse; }
.table-plain td, .table-plain th { padding: 10px 8px 10px 0; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
.table-plain th { font-size: 13px; color: var(--muted); font-weight: 700; }

/* --- Списки --- */
.list-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 16px 20px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.list-row .grow { flex: 1 1 260px; min-width: 0; }
.list-row .title { font-weight: 700; font-size: 16px; }
.line-item { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.line-item:last-child { border-bottom: none; }

/* --- Прогресс --- */
.pmap { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 8px; }
.pcell { height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; text-decoration: none; }
.lv0 { background: var(--line-soft); color: var(--muted); }
.lv1 { background: var(--blossom); color: var(--bad-dark); }
.lv2 { background: var(--stone); color: var(--ink); }
.lv3 { background: var(--moss); color: #fff; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 16px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.track { height: 8px; background: var(--line-soft); border-radius: 4px; overflow: hidden; }
.track > div { height: 100%; border-radius: 4px; background: var(--moss); }
.track.thick { height: 10px; }
.track .bad { background: var(--blossom); }
.track .bad-soft { background: #FFC4C4; }
.bars { display: flex; align-items: flex-end; justify-content: space-around; gap: 12px; min-height: 200px; border-bottom: 1px solid var(--line); }
.bars .col { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.bars .bar { width: 100%; max-width: 56px; border-radius: 8px 8px 0 0; background: var(--stone); }
.bars .bar.last { background: var(--moss); }
.bars-labels { display: flex; justify-content: space-around; gap: 12px; margin-top: 8px; }
.bars-labels span { flex: 1; min-width: 0; text-align: center; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

/* --- Тест --- */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.steps li { font-size: 14px; font-weight: 700; padding: 8px 14px; border-radius: 999px; background: var(--line-soft); color: var(--muted); }
.steps li.now { background: var(--moss); color: #fff; }
.steps li.done { background: var(--ok-bg); color: var(--moss); }
.q { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.q:last-child { border-bottom: none; }
.q .n { width: 28px; color: var(--muted); font-weight: 700; flex: none; }
.q .text { flex: 1 1 240px; font-size: 18px; font-weight: 600; white-space: pre-line; min-width: 0; }
.q .text.big { font-size: 22px; font-weight: 700; letter-spacing: 0.01em; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opts label { position: relative; }
.opts input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opts span { display: inline-flex; align-items: center; justify-content: center; min-width: 56px; min-height: 48px; padding: 6px 16px; border-radius: 10px; border: 2px solid var(--field); background: #fff; font-size: 18px; font-weight: 700; cursor: pointer; }
.opts input:checked + span { border-color: var(--moss); background: var(--moss); color: #fff; }
.opts input:focus-visible + span { outline: 3px solid var(--blossom); outline-offset: 2px; }
.q .answer-input { max-width: 260px; font-size: 18px; font-weight: 700; height: 48px; }
.fix-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; display: flex; flex-direction: column; gap: 12px; }
.fix-card .tries { font-size: 13px; color: var(--muted); }

/* --- Карточки --- */
.flashcard { border: 2px solid var(--line); border-radius: 20px; padding: 20px 20px 24px; display: flex; flex-direction: column; gap: 18px; min-height: 300px; }
.card-text { text-align: center; font-size: 19px; font-weight: 600; white-space: pre-line; line-height: 1.5; }
.card-text.big { font-size: 30px; font-weight: 800; letter-spacing: 0.01em; }
.card-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.card-opt { min-height: 64px; padding: 8px 14px; border-radius: 14px; border: 2px solid var(--field); background: #fff; color: var(--ink); font-size: 22px; font-weight: 800; display: flex; align-items: center; justify-content: center; text-align: center; }
button.card-opt:hover { border-color: var(--moss); }
.card-opt.good { border-color: var(--moss); background: var(--moss); color: #fff; }
.card-opt.dim { border-color: var(--line); color: #AAAAAA; }
.card-opt.struck { border-color: #E4A0A0; color: #B07070; text-decoration: line-through; cursor: not-allowed; }
.card-msg { text-align: center; font-weight: 800; font-size: 16px; color: var(--moss); }
.card-msg.bad { color: var(--bad-ink); }
.slot-text { font-size: 20px; line-height: 2.3; text-align: left; }
.slot { position: relative; display: inline-block; vertical-align: baseline; margin: 0 2px; }
.slot input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.slot span { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 4px; border-radius: 10px; border: 2px dashed var(--stone); background: #fff; cursor: pointer; vertical-align: middle; }
.slot span b { display: none; font-size: 26px; line-height: 1; margin-right: 1px; color: var(--moss); }
.slot span sup { font-size: 13px; font-weight: 700; color: var(--muted); top: 0; }
.slot input:checked + span { border-style: solid; border-color: var(--moss); background: var(--bamboo); }
.slot input:checked + span b { display: inline; }
.slot input:focus-visible + span { outline: 3px solid var(--blossom); outline-offset: 2px; }
.slot-shown { display: inline-block; font-weight: 800; color: var(--muted); margin: 0 2px; }
.slot-shown.on { color: var(--moss); font-size: 24px; }
.slot-shown sup { font-size: 11px; color: var(--muted); font-weight: 600; }

/* --- Сочинение --- */
.photos { display: flex; flex-wrap: wrap; gap: 12px; }
.photo { position: relative; width: 120px; height: 150px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo form { position: absolute; top: 6px; right: 6px; margin: 0; }
.photo .x { width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--ink); color: #fff; font-weight: 700; font-size: 16px; }
.photo-add { width: 120px; height: 150px; border: 2px dashed var(--field); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--moss); font-weight: 700; font-size: 14px; text-align: center; cursor: pointer; padding: 8px; }
.photo-add:hover { background: var(--bamboo); }
.photo-big { display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.photo-big img { display: block; width: 100%; height: auto; }
.essay-text { padding: 18px 20px; background: var(--bg); border-radius: 12px; font-size: 16px; line-height: 1.7; white-space: pre-wrap; }
.source-text { white-space: pre-wrap; line-height: 1.65; }

/* --- Конспекты --- */
.note-body { white-space: pre-wrap; line-height: 1.65; }
.notelist a { display: block; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: #fff; text-decoration: none; color: var(--ink); font-weight: 700; }
.notelist a .tag { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
.notelist a.on { background: var(--bamboo); border-color: var(--stone); }
.file-chip { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border: 1px solid var(--field); border-radius: 10px; text-decoration: none; font-weight: 700; color: var(--ink); }

/* --- Диалог --- */
dialog { border: none; border-radius: var(--radius); padding: 24px; max-width: 640px; width: calc(100% - 32px); box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
dialog::backdrop { background: rgba(0,0,0,0.35); }

details.card > summary { cursor: pointer; font-weight: 700; }
details.card[open] > summary { margin-bottom: 14px; }

/* --- Вход --- */
.auth { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; }
.auth .box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 20px; }
.auth .card { display: flex; flex-direction: column; gap: 16px; }

@media (max-width: 640px) {
  main.page { padding: 20px 16px 64px; }
  .topbar .in { padding: 10px 16px; }
  h1 { font-size: 25px; }
  .card { padding: 18px; }
  .pmap { gap: 6px; }
  .pcell { height: 38px; font-size: 14px; }
  .list-row { padding: 14px 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 22px; }
  .nav a { height: 36px; padding: 0 10px; font-size: 14px; }
  .who { font-size: 14px; }
}

/* Задание «как на экзамене» */
.exam-task { display: flex; flex-direction: column; gap: 12px; max-width: 560px; margin: 0 auto; width: 100%; }
.exam-q { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.45; }
.exam-rows { white-space: pre-line; font-size: 19px; font-weight: 600; line-height: 1.75; }
@media (max-width: 520px) { .exam-rows { font-size: 17px; } }
