/* ============================================================
   Оформление курсов «теория и разбор случаев».

   Задания здесь текстовые, а не кодовые: варианты ответа,
   выпадающие списки, поле для свободного текста. Акцентный цвет
   каждый курс задаёт у себя — тут только общая вёрстка.
   ============================================================ */

#app { display: flex; min-height: 100vh; }

/* ============ Сайдбар ============ */

#sidebar {
  width: 290px;
  min-width: 290px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  height: 100vh;
  overflow-y: auto;
  position: sticky;
  top: 0;
}

.logo {
  font-size: 21px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 16px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.logo-badge {
  background: var(--accent);
  color: var(--on-accent);
  padding: 2px 9px;
  border-radius: 8px;
}

.nav-progress { margin: 0 6px 14px; }
.np-bar { height: 7px; background: var(--bg3); border-radius: 999px; overflow: hidden; }
.np-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.np-text { font-size: 12px; color: var(--text-dim); margin-top: 5px; }

.nav-item {
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-dim);
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--bg3); color: var(--accent); }

.nav-section { margin-bottom: 4px; }
.nav-section-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  user-select: none;
  transition: background .15s;
}
.nav-section-head:hover { background: var(--bg3); }
.nav-stitle { min-width: 0; overflow-wrap: anywhere; }
.nav-pct { margin-left: auto; font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.nav-section.done .nav-pct { color: var(--green); }

.nav-num {
  background: var(--bg3);
  color: var(--text-dim);
  min-width: 24px;
  height: 24px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}
.nav-section.done .nav-num { background: var(--green); color: #05320f; }

.nav-lessons { display: none; padding-left: 10px; }
.nav-section.open .nav-lessons { display: block; }

.nav-lesson {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-dim);
  transition: background .15s, color .15s;
}
.nav-lesson:hover { background: var(--bg3); color: var(--text); }
.nav-lesson.active { background: var(--bg3); color: var(--accent); }
.nav-lesson span:not(.dot) { min-width: 0; overflow-wrap: anywhere; }
.nav-lesson .dot {
  width: 8px; height: 8px; min-width: 8px;
  border-radius: 50%;
  background: var(--border);
}
.nav-lesson.done .dot { background: var(--green); }
.nav-lesson.partial .dot { background: var(--orange); }
.nav-lesson.quiz-link .dot { border-radius: 2px; }
.nav-score { margin-left: auto; font-size: 11px; }

.nav-exam {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  text-align: center;
  color: var(--text-dim);
}
.nav-exam.unlocked { border-color: var(--accent-dim); color: var(--accent); border-style: solid; }
.nav-exam:hover { background: var(--bg3); }

/* ============ Основная колонка ============ */

#main {
  flex: 1 1 auto;
  width: 100%;
  padding: 32px 44px 90px;
  max-width: 1560px;
  min-width: 0;
  margin: 0 auto;   /* центрируем колонку на широких экранах */
}

h1 { font-size: 28px; margin-bottom: 8px; line-height: 1.3; }
h2 { font-size: 21px; margin: 32px 0 14px; }
p { margin-bottom: 12px; }
.subtitle { color: var(--text-dim); margin-bottom: 22px; font-size: 15px; }
.crumbs { color: var(--text-mute); font-size: 13px; margin-bottom: 6px; }

code {
  font-family: var(--mono);
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 14px;
  color: var(--accent);
}
pre {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  margin: 0 0 14px;
  white-space: pre-wrap;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin: 20px 0;
}
.stat {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 18px;
}
.stat-val { font-size: 26px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 13px; color: var(--text-dim); }

.infobox, .tipbox {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 16px 0;
}
.tipbox { border-left-color: var(--blue); font-size: 14.5px; }
.infobox p:last-child, .tipbox p:last-child { margin-bottom: 0; }

/* ============ Теория ============
   Строку с текстом не растягиваем: длиннее сотни знаков читать
   тяжело — глаз теряет место при переходе на следующую строку.
   А вот схемы, таблицы и код от ширины только выигрывают, поэтому
   ограничение стоит на абзацах и списках, а не на всей теории. */

.theory { max-width: 1180px; }
.theory p, .theory > blockquote { max-width: 100ch; }
.theory p { color: var(--text); line-height: 1.7; }
.theory ul, .theory ol, .tipbox ul, .infobox ul {
  margin: 0 0 14px 22px;
  padding: 0;
  max-width: 100ch;
}
.theory li, .tipbox li, .infobox li { margin-bottom: 6px; line-height: 1.65; }
.infobox, .tipbox { max-width: 100ch; }

/* ============ Разделы на обзоре ============ */

.section-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.section-card.done { border-color: rgba(74, 222, 128, .4); }
.sc-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 17px;
  cursor: pointer;
}
.sc-head:hover { background: var(--bg3); }
.sc-num {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.sc-body { flex: 1; min-width: 0; }
.sc-title { font-weight: 700; font-size: 16px; }
.sc-desc { font-size: 13.5px; color: var(--text-dim); }
.sc-pct { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

.sc-lessons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 17px 15px;
}
.chip {
  font-size: 12.5px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text-dim);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.chip:hover { color: var(--text); border-color: var(--text-mute); }
.chip.done { color: var(--green); border-color: rgba(74, 222, 128, .45); }
.chip.partial { color: var(--orange); border-color: rgba(251, 146, 60, .45); }
.chip.quiz { border-style: dashed; }

.exam-card {
  background: var(--bg2);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 18px;
  cursor: pointer;
}
.exam-card.locked { border-color: var(--border); opacity: .75; cursor: default; }
.exam-card p { margin: 6px 0 0; font-size: 13.5px; color: var(--text-dim); }

/* ============ Задания ============ */

.task {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.task.solved { border-color: rgba(74, 222, 128, .45); }

.task-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.task-num { font-weight: 700; font-size: 14px; }
/* Уровень задания подписан словом: значок из точек читался как
   счётчик правильных ответов. */
.task-diff {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 2px 8px;
  border-radius: 999px;
}
.task-diff.diff-1 { background: rgba(74, 222, 128, .15); color: var(--green); }
.task-diff.diff-2 { background: rgba(251, 146, 60, .15); color: var(--orange); }
.task-diff.diff-3 { background: rgba(248, 113, 113, .15); color: var(--red); }
.task-done { margin-left: auto; color: var(--green); font-size: 13px; }
.task-prompt { margin-bottom: 12px; line-height: 1.6; }

.options { display: grid; gap: 8px; margin-bottom: 12px; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 13px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14.5px;
  line-height: 1.5;
  transition: border-color .15s, background .15s;
}
.option:hover { border-color: var(--accent-dim); }
.option input { margin-top: 3px; flex-shrink: 0; accent-color: var(--accent); }
.option span { min-width: 0; overflow-wrap: anywhere; }

.match { display: grid; gap: 9px; margin-bottom: 12px; }
.match-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
}
.match-left { flex: 1; min-width: 160px; font-size: 14.5px; }
.match-select {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
  font: inherit;
  font-size: 14px;
  max-width: 100%;
}

.task-input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font: inherit;
  font-size: 14.5px;
  line-height: 1.6;
  resize: vertical;
}
.task-input:focus { outline: none; border-color: var(--accent-dim); }
.task-note {
  font-size: 12.5px;
  color: var(--text-mute);
  margin: 8px 0 12px;
  line-height: 1.5;
}

.task-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.task-result {
  display: none;
  margin-top: 12px;
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.task-result.show { display: block; }
.task-result.pass { background: rgba(74, 222, 128, .12); border: 1px solid rgba(74, 222, 128, .45); color: #bdf5d0; }
.task-result.fail { background: rgba(248, 113, 113, .12); border: 1px solid rgba(248, 113, 113, .45); color: #ffcccc; }
.task-result.sample { background: var(--bg3); border: 1px solid var(--border); color: var(--text); }

/* ============ Контрольные ============ */

.quiz-q {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 17px;
  margin-bottom: 14px;
}
.quiz-text { margin-bottom: 11px; line-height: 1.6; }
.quiz-why {
  display: none;
  margin-top: 10px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.55;
}
.quiz-why.show { display: block; }
.quiz-why.ok { background: rgba(74, 222, 128, .12); color: #bdf5d0; }
.quiz-why.bad { background: rgba(248, 113, 113, .12); color: #ffcccc; }

/* ============ Кнопки и низ урока ============ */

.btn {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 17px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s;
  white-space: normal;
  overflow-wrap: anywhere;
}
.btn:hover { filter: brightness(1.15); }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn-sm { padding: 7px 14px; font-size: 13.5px; }

.lesson-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* ============ Телефоны ============ */

@media (max-width: 700px) {
  #main { padding: 20px 14px 80px; }
  h1 { font-size: 23px; }
  h2 { font-size: 19px; }
  .task { padding: 14px; }
  .sc-head { padding: 13px 14px; gap: 11px; }
  .sc-lessons { padding: 0 14px 13px; }
  .lesson-nav .btn { flex: 1 1 45%; }
  .match-row { gap: 8px; }
  .match-select { width: 100%; }
}

/* ---- Работа над ошибками ---- */

.nav-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--orange);
  color: #2b1500;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.mistake-cta {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--orange);
  border-radius: var(--radius);
  padding: 14px 17px;
  margin: 18px 0 0;
  cursor: pointer;
  transition: border-color .15s;
}
.mistake-cta:hover { border-color: var(--orange); }
.mistake-cta p { margin: 5px 0 0; font-size: 13.5px; color: var(--text-dim); }

.mistake {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--orange);
  border-radius: var(--radius);
  padding: 14px 17px;
  margin-bottom: 12px;
}
.mistake.fixed { border-left-color: var(--green); opacity: .75; }
.mistake-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.mistake-where { font-size: 12.5px; color: var(--text-mute); }
.mistake-count { margin-left: auto; font-size: 12.5px; color: var(--orange); }
.mistake.fixed .mistake-count { color: var(--green); }
.mistake-prompt { margin-bottom: 12px; line-height: 1.6; }
