* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1c1f23;
  background: #f6f7f9;
  line-height: 1.55;
}
a { color: #0b62d6; text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-header {
  background: #fff;
  border-bottom: 1px solid #e6e8eb;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.brand { font-weight: 700; font-size: 18px; color: #111; }
.top-nav a { margin-left: 16px; }

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 28px;
  padding: 28px 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.sidebar {
  background: #fff;
  border: 1px solid #e6e8eb;
  border-radius: 10px;
  padding: 16px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

/* ============ Заголовки разделов сайдбара ============ */

.sidebar-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #111827;
}
.sidebar-title:not(:first-child) {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid #e6e8eb;
}

/* ============ Предметы — «лёгкие кнопки» ============ */

.subject-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.subject-list > li {
  margin-bottom: 8px;
}

/* Основная «кнопка» — предмет или категория библиотеки */
.subject-list > li > a {
  display: block;
  padding: 10px 14px;
  border-radius: 8px;
  background: #f3f4f6;
  border: 1px solid transparent;
  color: #111827;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.35;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
.subject-list > li > a:hover {
  background: #e5e7eb;
  text-decoration: none;
}
.subject-list > li > a:active {
  transform: translateY(1px);
}

/* Активный предмет — синий */
.subject-list > li > a.active {
  background: #eaf1fe;
  border-color: #b8d2f7;
  color: #0b62d6;
}
.subject-list > li > a.active:hover {
  background: #dde9fd;
}

/* Счётчик заметок у категорий библиотеки */
.subject-list > li > a .muted.small {
  font-weight: 400;
  color: inherit;
  opacity: 0.65;
  margin-left: 4px;
}

/* ============ Подпункты (темы, заметки) ============ */

.topic-list {
  list-style: none;
  margin: 6px 0 4px 6px;
  padding: 0 0 0 12px;
  border-left: 2px solid #e6e8eb;
}
.topic-list a {
  display: block;
  padding: 6px 10px;
  color: #4b5563;
  font-size: 14px;
  line-height: 1.4;
  border-radius: 6px;
  transition: background 0.1s ease, color 0.1s ease;
}
.topic-list a:hover {
  background: #f3f4f6;
  color: #111827;
  text-decoration: none;
}
.topic-list a.active {
  background: #eaf1fe;
  color: #0b62d6;
  font-weight: 500;
}

.content h1 { margin-top: 0; }
.hero { margin-bottom: 20px; }
.muted { color: #6b7280; }

.topic-cards {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}
.topic-cards li {
  background: #fff;
  border: 1px solid #e6e8eb;
  border-radius: 10px;
  padding: 12px 16px;
}

.breadcrumbs { font-size: 14px; color: #6b7280; margin-bottom: 8px; }

.task {
  background: #fff;
  border: 1px solid #e6e8eb;
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.task-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.task-num { color: #9ca3af; font-weight: 600; }
.task-header h2 { font-size: 18px; margin: 0; flex: 1; }
.badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #374151;
}
.badge-d1, .badge-d2 { background: #e6f7ec; color: #1a7a3d; }
.badge-d3         { background: #fff7e5; color: #946200; }
.badge-d4, .badge-d5 { background: #fdeaea; color: #a32323; }

.solution {
  margin-top: 12px;
  border-top: 1px dashed #e6e8eb;
  padding-top: 10px;
}
.solution summary {
  cursor: pointer;
  color: #0b62d6;
  font-weight: 600;
  user-select: none;
}
.solution-body { margin-top: 10px; }

.site-footer {
  background: #fff;
  border-top: 1px solid #e6e8eb;
  padding: 16px 0;
  color: #6b7280;
  font-size: 14px;
  margin-top: 40px;
}

/* Hero на главной */
.hero {
  padding: 8px 0 24px;
}
.hero h1 {
  font-size: 32px;
  margin: 0 0 12px;
}
.hero-lead {
  font-size: 17px;
  color: #4b5563;
  max-width: 640px;
  margin: 0;
}

/* Большие кнопки выбора предмета */
.subject-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin: 12px 0 40px;
}
.subject-button {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 32px 28px;
  border-radius: 14px;
  border: 1px solid #e6e8eb;
  background: #fff;
  color: #111;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  min-height: 140px;
}
.subject-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  border-color: #cfd6df;
  text-decoration: none;
}
.subject-button-label {
  font-size: 22px;
  font-weight: 700;
}
.subject-button-desc {
  font-size: 14px;
  color: #6b7280;
}
/* Акцентные цвета для двух предметов */
.subject-button-oge { border-left: 5px solid #2f8f4a; }
.subject-button-ege { border-left: 5px solid #b1472a; }

/* Блок "Как устроен каталог" */
.how-it-works {
  background: #fff;
  border: 1px solid #e6e8eb;
  border-radius: 12px;
  padding: 22px 26px;
}
.how-it-works h2 {
  margin: 0 0 12px;
  font-size: 18px;
}
.steps {
  margin: 0;
  padding-left: 20px;
  color: #4b5563;
}
.steps li { margin-bottom: 6px; }

/* ============ Типографика тела задачи ============ */

.task-body,
.solution-body {
  font-size: 16px;
  line-height: 1.65;
  color: #1f2937;
}

/* Заголовки внутри текста задачи */
.task-body h3,
.solution-body h3 {
  font-size: 18px;
  margin: 22px 0 10px;
  color: #111827;
}
.task-body h4,
.solution-body h4 {
  font-size: 16px;
  margin: 18px 0 8px;
  color: #374151;
}

/* Абзацы */
.task-body p,
.solution-body p {
  margin: 0 0 12px;
}

/* Списки */
.task-body ul,
.task-body ol,
.solution-body ul,
.solution-body ol {
  margin: 0 0 14px;
  padding-left: 22px;
}
.task-body li,
.solution-body li {
  margin-bottom: 4px;
}

/* Inline-код */
.task-body code:not([class*="language-"]),
.solution-body code:not([class*="language-"]) {
  background: #eef1f4;
  color: #b8005e;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.92em;
  font-family: "JetBrains Mono", "Fira Code", Consolas, Menlo, monospace;
}

.code-block {
  position: relative;
  margin: 16px 0;
  border-radius: 10px;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.55;
}
.code-block code {
  display: block;
  padding: 16px 18px;
  font-family: "JetBrains Mono", "Fira Code", Consolas, Menlo, monospace;
  font-size: 14px;
  white-space: pre;
  overflow-x: auto;
}




/* ============ Нумерация строк ============ */

.code-block.line-numbers {
    position: relative;
    padding-left: 0.5em;
}

/* Код: жёстко фиксируем типографику, чтобы тема Prism не перебивала */
.code-block.line-numbers > code {
    padding-left: 2em !important;
    padding-top: 16px !important;
    padding-bottom: 16px !important;
    font-size: 14px !important;
    line-height: 22px !important;    /* фиксируем в пикселях, не в "1.55" */
}

/* Колонка номеров — точь-в-точь те же метрики */
.code-block.line-numbers .line-numbers-rows {
    position: absolute;
    top: 0;
    left: 0;
    width: 1.8em;
    height: 100%;
    padding: 16px 0;
    font-size: 14px;
    line-height: 22px;
    border-right: 1px solid #3a3a3a;
    pointer-events: none;
    user-select: none;
    counter-reset: linenumber;
}

.code-block.line-numbers .line-numbers-rows > span {
    display: block;
    counter-increment: linenumber;
    height: 22px;                    /* высота строки в пикселях */
    line-height: 22px;
    font-size: 14px;
    padding: 0;
    margin: 0;
}

.code-block.line-numbers .line-numbers-rows > span::before {
    content: counter(linenumber);
    display: block;
    font-size: inherit;
    line-height: inherit;
    color: #6b7280;
    text-align: right;
    padding-right: 10px;
}



/* Prism немного переопределяем, чтобы наш фон был главным */
.code-block[class*="language-"]::before,
.code-block[class*="language-"]::after { display: none; }
.code-block pre[class*="language-"] { margin: 0; }

/* Цитата (можно использовать для «Условия задачи») */
.task-body blockquote,
.solution-body blockquote {
  margin: 14px 0;
  padding: 8px 16px;
  border-left: 4px solid #cfd6df;
  color: #4b5563;
  background: #f9fafb;
  border-radius: 0 8px 8px 0;
}

/* ============ Таблицы в контенте ============ */

.task-body table,
.solution-body table,
.block-body table,
.practice-task-body table,
.callout-body table {
    width: auto;
    max-width: 100%;
    margin: 16px 0;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    border: 1px solid #c8cfd6;
    border-radius: 10px;
    overflow: hidden;
    font-size: 15px;
}

.task-body th,
.task-body td,
.solution-body th,
.solution-body td,
.block-body th,
.block-body td,
.practice-task-body th,
.practice-task-body td,
.callout-body th,
.callout-body td {
    padding: 8px 14px;
    text-align: center;
    vertical-align: top;
    border-bottom: 1px solid #dfe3e8;
    border-right: 1px solid #dfe3e8;
}

.task-body th,
.solution-body th,
.block-body th,
.practice-task-body th,
.callout-body th {
    background: #eef1f4;
    color: #374151;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Убираем правую границу у последней колонки */
.task-body th:last-child, .task-body td:last-child,
.solution-body th:last-child, .solution-body td:last-child,
.block-body th:last-child, .block-body td:last-child,
.practice-task-body th:last-child, .practice-task-body td:last-child,
.callout-body th:last-child, .callout-body td:last-child {
    border-right: none;
}

/* Убираем нижнюю границу у последней строки */
.task-body tr:last-child td,
.solution-body tr:last-child td,
.block-body tr:last-child td,
.practice-task-body tr:last-child td,
.callout-body tr:last-child td {
    border-bottom: none;
}

/* ============ Врезки ============ */

.callout {
    margin: 14px 0;
    border-radius: 8px;
    border-left: 4px solid;
    overflow: hidden;
    font-size: 15px;
}
.callout-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    user-select: none;
}
.callout-icon {
    font-size: 15px;
    line-height: 1;
}
.callout-name {
    letter-spacing: 0.01em;
}
.callout-body {
    padding: 10px 16px;
}
.callout-body > :first-child { margin-top: 0; }
.callout-body > :last-child  { margin-bottom: 0; }

.callout-note { background: #fff8e5; border-color: #e3a800; color: #6b4e00; }
.callout-note .callout-title { background: rgba(227, 168, 0, 0.14); }

.callout-warn { background: #fdeaea; border-color: #d9534f; color: #8a1f1c; }
.callout-warn .callout-title { background: rgba(217, 83, 79, 0.14); }

.callout-tip  { background: #e6f7ec; border-color: #2f8f4a; color: #14532d; }
.callout-tip .callout-title { background: rgba(47, 143, 74, 0.14); }

/* ============ Обёртка блока кода ============ */

.code-wrapper {
    margin: 16px 0;
    border-radius: 10px;
    overflow: hidden;
    background: #1e1e1e;
}
.code-wrapper .code-block {
    margin: 0;
    border-radius: 0;
}
.code-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #171717;
    color: #9ca3af;
    font-family: "JetBrains Mono", "Fira Code", Consolas, Menlo, monospace;
    font-size: 12.5px;
    border-bottom: 1px solid #2a2a2a;
    user-select: none;
}
.code-header-icon { font-size: 14px; line-height: 1; }
.code-header-lang {
    font-weight: 500;
    letter-spacing: 0.02em;
}


.btn {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #cfd6df;
  background: #fff;
  color: #111;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { background: #f3f4f6; }
.btn-small { padding: 5px 10px; font-size: 13px; }

.topic-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 0 20px;
  padding: 10px 14px;
  background: #f3f4f6;
  border-radius: 10px;
  font-size: 14px;
}

/* ============ Блоки «Теория» и «Практика» ============ */

.block {
  margin: 24px 0 32px;
  background: #fff;
  border: 1px solid #e6e8eb;
  border-radius: 12px;
  padding: 22px 26px;
}
.block-theory  { border-left: 4px solid #0b62d6; }
.block-practice { border-left: 4px solid #2f8f4a; }

.block-title {
  margin: 0 0 16px;
  font-size: 20px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.block-title-count {
  font-size: 13px;
  font-weight: 400;
  color: #6b7280;
}

/* ============ Задание практики ============ */

.practice-task {
  border-top: 1px dashed #e6e8eb;
  padding: 18px 0;
}
.practice-task:first-of-type { border-top: none; padding-top: 0; }

.practice-task-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.practice-task-num {
  font-size: 13px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.practice-task-title {
  font-size: 17px;
  margin: 0 0 10px;
}
.practice-task-body {
  margin-bottom: 14px;
}

/* Форма ответа */
.practice-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.practice-form-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.practice-input {
  flex: 1;
  padding: 9px 12px;
  font-size: 15px;
  font-family: inherit;
  border: 1px solid #cfd6df;
  border-radius: 8px;
  background: #fff;
}
.practice-input:focus {
  outline: none;
  border-color: #0b62d6;
  box-shadow: 0 0 0 3px rgba(11, 98, 214, 0.12);
}
.practice-input:disabled {
  background: #f3f4f6;
  color: #6b7280;
}

.practice-hint {
  font-size: 13px;
  color: #6b7280;
}

/* Фидбэк */
.practice-feedback {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 15px;
  margin-top: 4px;
}
.practice-feedback-ok {
  background: #e6f7ec;
  color: #14532d;
  border-left: 4px solid #2f8f4a;
}
.practice-feedback-error {
  background: #fdeaea;
  color: #8a1f1c;
  border-left: 4px solid #d9534f;
}
.practice-solution {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(0, 0, 0, 0.1);
  color: #1f2937;
}

/* Кнопки админа на публичной странице */
.admin-toolbar-public {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 12px 0 20px;
  padding: 10px 14px;
  background: #fff8e5;
  border: 1px dashed #e3a800;
  border-radius: 10px;
  font-size: 14px;
}
.admin-toolbar-label {
  color: #6b4e00;
  font-weight: 600;
  margin-right: 4px;
}

.sidebar-admin {
  margin-bottom: 12px;
}

.top-nav-admin {
  padding: 4px 10px;
  border-radius: 6px;
  background: #eef2f7;
}
.top-nav-admin:hover {
  background: #e2e8f0;
  text-decoration: none;
}

/* Фон для блоков кода — тема Prism его не задаёт */
pre[class*="language-"],
code[class*="language-"],
.code-block,
.code-block code {
    background: #1e1e1e !important;
}

/* Базовый цвет кода до применения подсветки */
pre[class*="language-"],
code[class*="language-"],
.code-block code {
    color: #d4d4d4;            /* как в VS Code Dark+ */
    background: #1e1e1e !important;
}

/* ============ Подсветка строки под курсором ============ */

.code-hover-line {
    position: absolute;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.07);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.08s ease, top 0.06s ease;
    z-index: 1;
}

/* ============ Условие задачи ============ */

.problem-block {
    margin: 18px 0;
    background: #f6f8fb;
    border-left: 4px solid #0b62d6;
    border-radius: 0 10px 10px 0;
    overflow: hidden;
}
.problem-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    font-weight: 600;
    font-size: 14px;
    color: #0b62d6;
    background: rgba(11, 98, 214, 0.08);
    border-bottom: 1px solid rgba(11, 98, 214, 0.12);
    user-select: none;
}
.problem-icon { font-size: 15px; line-height: 1; }
.problem-body {
    padding: 12px 18px;
}
.problem-body > :first-child { margin-top: 0; }
.problem-body > :last-child  { margin-bottom: 0; }

/* ============ Решение ============ */

.solution-block {
    margin: 18px 0;
    background: #f3faf5;
    border-left: 4px solid #2f8f4a;
    border-radius: 0 10px 10px 0;
    overflow: hidden;
}
.solution-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-weight: 600;
    font-size: 14px;
    color: #1a7a3d;
    background: rgba(47, 143, 74, 0.10);
    border-bottom: 1px solid rgba(47, 143, 74, 0.16);
    user-select: none;
}
.solution-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #2f8f4a;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}
.solution-name {
    letter-spacing: 0.02em;
}
.solution-body {
    padding: 12px 18px;
}
.solution-body > :first-child { margin-top: 0; }
.solution-body > :last-child  { margin-bottom: 0; }

/* ============ Библиотека заметок ============ */

.card-meta {
    margin-top: 8px;
    font-size: 13px;
    color: #6b7280;
}

.note-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}
.note-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e6e8eb;
    border-radius: 10px;
}
.note-list li:hover {
    border-color: #cfd6df;
}
.note-list-title {
    font-weight: 600;
    color: #111;
}
.note-list-views {
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
}

.note-article {
    background: #fff;
    border: 1px solid #e6e8eb;
    border-radius: 12px;
    padding: 24px 28px;
}
.note-header {
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid #eef1f4;
}
.note-header h1 {
    margin: 0 0 6px;
    font-size: 26px;
}
.note-meta {
    font-size: 13px;
    color: #6b7280;
}
.note-body {
    font-size: 16px;
    line-height: 1.65;
    color: #1f2937;
}
.note-related {
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px dashed #e6e8eb;
}
.note-related h2 {
    margin: 0 0 8px;
    font-size: 16px;
}
.note-related-list {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
}
.note-related-list li {
    padding: 6px 0;
}
.note-back {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #eef1f4;
}

.small { font-size: 13px; }

/* ============ Блок «Помощь» на странице задачи ============ */

.task-help {
    margin-top: 14px;
    padding: 12px 16px;
    background: #f0f6ff;
    border-left: 4px solid #0b62d6;
    border-radius: 0 8px 8px 0;
}
.task-help-title {
    font-weight: 600;
    font-size: 14px;
    color: #0b62d6;
    margin-bottom: 8px;
}
.task-help-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.task-help-list li {
    padding: 3px 0;
    font-size: 14px;
}
.task-help-list a {
    font-weight: 500;
}
.task-help-list .small { font-size: 13px; }


/* ============ Красная строка ============ */
/* Применяется ко всем абзацам <p> в контенте.
   Заголовки, код и списки не затронуты — они не <p>. */

.task-body p,
.solution-body p,
.block-body p,
.practice-task-body p,
.practice-solution p,
.note-body p,
.callout-body p,
.problem-body p,
.solution-block .solution-body p,
blockquote p {
    text-indent: 1.5em;
}

/* ============ Выравнивание текста по ширине ============ */

.task-body p,
.solution-body p,
.block-body p,
.practice-task-body p,
.practice-solution p,
.note-body p,
.callout-body p,
.problem-body p {
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  text-align-last: left;
}

/* На узких экранах justify смотрится плохо — «рваные» пробелы.
   Отключаем, оставляем обычный левый край. */
@media (max-width: 700px) {
    .task-body p,
    .solution-body p,
    .block-body p,
    .practice-task-body p,
    .practice-solution p,
    .note-body p,
    .callout-body p,
    .problem-body p {
        text-align: left;
        hyphens: none;
        -webkit-hyphens: none;
        -ms-hyphens: none;
    }
}

/* ============ Заметки библиотеки в сайдбаре ============ */

.topic-list-notes a {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-color: #cfd6df;
    text-underline-offset: 3px;
}
.topic-list-notes a:hover {
    text-decoration-color: #0b62d6;
}

.topic-list-notes a.active {
    text-decoration-color: #0b62d6;
}