/* ===== Живой дизайн для AI-библиотеки ===== */

:root {
  --ds-blue: #4dabf7;
  --ds-blue-deep: #1971c2;
  --ds-glow: rgba(77, 171, 247, 0.35);
}

/* Мягкий фон с лёгким градиентом */
.md-main {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(77, 171, 247, 0.08), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(25, 113, 194, 0.06), transparent 60%);
}

/* Плавные ссылки и заголовки */
.md-content a {
  transition: color 0.2s ease;
}
.md-content h1,
.md-content h2,
.md-content h3 {
  scroll-margin-top: 3.4rem;
}

/* Заголовок h1 — с акцентной линией */
.md-content h1 {
  position: relative;
  padding-bottom: 0.35em;
}
.md-content h1::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 64px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--ds-blue), transparent);
}

/* Таблицы: скругление и подсветка строки при наведении */
.md-typeset table:not([class]) {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}
.md-typeset table:not([class]) tbody tr {
  transition: background-color 0.15s ease;
}
.md-typeset table:not([class]) tbody tr:hover {
  background-color: rgba(77, 171, 247, 0.08);
}

/* Блоки кода */
.md-typeset code {
  border-radius: 6px;
}
.md-typeset pre > code {
  border-radius: 12px;
  border: 1px solid rgba(77, 171, 247, 0.15);
}

/* Блоки admonition — мягче и красивее */
.md-typeset .admonition {
  border-radius: 12px;
  border-left-width: 4px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.md-typeset .admonition:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

/* Плавное появление контента */
.md-content {
  animation: fadeUp 0.4s ease both;
}
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Тёплый скроллбар */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: rgba(77, 171, 247, 0.4);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(77, 171, 247, 0.7);
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* Акцентная подсветка найденного в поиске */
.md-search-result__article mark {
  background: var(--ds-glow);
  border-radius: 3px;
}

/* Красивые бейджи тегов */
.md-typeset .md-tag {
  border-radius: 20px;
  font-weight: 600;
}

/* Текущий пункт меню — не кликабелен, но подсветка остаётся */
.md-nav__link--active {
  pointer-events: none;
  cursor: default;
}

/* Активная вкладка в верхнем меню — тоже не кликабельна */
.md-tabs__item--active .md-tabs__link {
  pointer-events: none;
  cursor: default;
}

/* Кнопка "наверх" с свечением */
.md-top {
  box-shadow: 0 4px 20px var(--ds-glow);
}

/* ===== Оформление футера =====
   background-color темы обязательно возвращаем: шорткат `background` сбрасывал
   его в прозрачный, и верхняя часть футера (ссылки «предыдущая/следующая»)
   рисовалась цветом страницы — белой полосой над тёмной .md-footer-meta,
   а сами ссылки были белым по белому. */
.md-footer {
  background-color: var(--md-footer-bg-color);
  background-image: linear-gradient(180deg, transparent, rgba(25, 113, 194, 0.06));
}
.md-footer-meta {
  background-color: #1a1e26;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
}
.md-footer-meta__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.md-footer-copyright {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.75rem;
  padding: 1.2rem 0;
}
.md-footer-copyright__highlight {
  color: #ffffff;
  font-weight: 600;
}

/* Кнопка обратной связи в футере */
.feedback-open {
  white-space: nowrap;
  font-size: 0.75rem;
  padding: 6px 14px;
}

/* Карточки разделов на главной */
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 24px 0;
}

/* Когда обе боковые колонки скрыты (как на главной) —
   даём контенту занять весь освободившийся простор,
   а не оставаться в узкой центральной колонке */
.md-content:has(+ .md-sidebar--hidden),
.md-main__inner:not(:has(.md-sidebar--primary)) .md-content__inner {
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}
.card {
  display: block;
  background: var(--md-default-bg-color);
  border: 1px solid rgba(77, 171, 247, 0.18);
  border-radius: 14px;
  padding: 18px 20px;
  color: inherit;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
.card:hover {
  transform: translateY(-4px);
  border-color: rgba(77, 171, 247, 0.6);
  box-shadow: 0 12px 30px rgba(77, 171, 247, 0.18);
}
.card h3 {
  margin-top: 0;
}
.card p:last-child {
  margin-bottom: 0;
}

/* Адаптивность карточек на главной */
@media (max-width: 600px) {
  .card-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 16px 0;
  }
  .card {
    padding: 14px 16px;
    border-radius: 12px;
  }
}

@media (min-width: 601px) and (max-width: 960px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
}

/* Вариант «ровно три колонки» — для страниц, где карточек немного
   и auto-fit растягивал их в 4–6 узких столбцов (Лаборатория).
   Медиазапросы нужны свои: у .card-grid.three специфичность выше,
   поэтому общие правила выше на мобильных его бы не перебили. */
.card-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (min-width: 601px) and (max-width: 1100px) {
  .card-grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 600px) {
  .card-grid.three {
    grid-template-columns: 1fr;
  }
}

/* ===== Модалка обратной связи ("Написать нам") ===== */

/* Скрыта по умолчанию, показывается как оверлей поверх всей страницы */
.feedback-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.feedback-modal.is-open {
  display: flex;
}

/* Затемняющая подложка */
.feedback-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 15, 30, 0.6);
  backdrop-filter: blur(2px);
}

/* Само окно формы */
.feedback-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(90vw, 480px);
  max-height: 85vh;
  overflow-y: auto;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  border-radius: 16px;
  padding: 28px 28px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  animation: feedback-pop 0.2s ease-out;
}
@keyframes feedback-pop {
  from { transform: scale(0.96); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.feedback-modal__close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--md-default-fg-color--light);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.feedback-modal__close:hover {
  background: rgba(77, 171, 247, 0.12);
  color: var(--ds-blue-deep);
}

#feedback-title {
  margin: 0 0 8px;
  font-size: 1.25rem;
}
.feedback-modal__text {
  margin: 0 0 20px;
  font-size: 0.9rem;
  color: var(--md-default-fg-color--light);
}

.feedback-field {
  display: block;
  margin-bottom: 14px;
  font-size: 0.85rem;
  font-weight: 600;
}
.feedback-field span {
  display: block;
  margin-bottom: 6px;
}
.feedback-required {
  color: #e03131;
  font-style: normal;
}
.feedback-field input,
.feedback-field textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(77, 171, 247, 0.3);
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  font: inherit;
  font-weight: 400;
  resize: vertical;
}
.feedback-field input:focus,
.feedback-field textarea:focus {
  outline: none;
  border-color: var(--ds-blue-deep);
  box-shadow: 0 0 0 3px var(--ds-glow);
}

/* Honeypot-поле — спрятано от людей, видно ботам */
.feedback-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Чекбокс согласия на обработку персональных данных */
.feedback-consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--md-default-fg-color--light);
}
.feedback-consent input[type="checkbox"] {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--ds-blue-deep);
  cursor: pointer;
}
.feedback-consent span {
  margin-bottom: 0;
}
.feedback-consent a {
  color: var(--ds-blue-deep);
  text-decoration: underline;
}

#feedback-form button[type="submit"] {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 42px;
  margin-top: 8px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #4dabf7, #1971c2);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(25, 113, 194, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

#feedback-form button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(25, 113, 194, 0.35);
  filter: brightness(1.05);
}

#feedback-form button[type="submit"]:active {
  transform: translateY(0);
  box-shadow: 0 6px 16px rgba(25, 113, 194, 0.28);
}

/* Уведомление об отправке */
.feedback-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 20px);
  z-index: 1100;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.feedback-banner.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.feedback-banner.success { background: #2f9e44; }
.feedback-banner.error   { background: #e03131; }

/* ===== Блог: сетка постов ===== */
.md-content__inner:has(> .md-post--excerpt) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.md-content__inner:has(> .md-post--excerpt) > .md-typeset {
  grid-column: 1 / -1;
}

.md-content__inner:has(> .md-post--excerpt) .md-post {
  margin: 0;
  padding: 20px;
  border: 1px solid rgba(77, 171, 247, 0.18);
  border-radius: 14px;
  background: var(--md-default-bg-color);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
}

.md-content__inner:has(> .md-post--excerpt) .md-post:hover {
  transform: translateY(-4px);
  border-color: rgba(77, 171, 247, 0.6);
  box-shadow: 0 12px 30px rgba(77, 171, 247, 0.18);
}

.md-content__inner:has(> .md-post--excerpt) .md-post__content {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Обложка всегда сверху и одинаковой высоты */
.md-content__inner:has(> .md-post--excerpt) .md-post__content > p:has(img) {
  order: 1;
  margin: 0;
}

.md-content__inner:has(> .md-post--excerpt) .md-post__content > h2 {
  order: 2;
  margin: 16px 0 8px;
}

.md-content__inner:has(> .md-post--excerpt) .md-post__content > *:not(h2):not(p:has(img)) {
  order: 3;
}

.md-content__inner:has(> .md-post--excerpt) .md-post__content img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 10px;
}

/* Кнопка «Читать» прижата к низу карточки */
.md-content__inner:has(> .md-post--excerpt) .md-post__action {
  margin-top: auto;
  padding-top: 12px;
}

@media (max-width: 960px) {
  .md-content__inner:has(> .md-post--excerpt) {
    grid-template-columns: 1fr;
  }
}

/* ===== Аккордеон в глоссарии ===== */
.md-typeset details {
  margin: 8px 0;
  padding: 0;
  border: 1px solid rgba(77, 171, 247, 0.18);
  border-radius: 10px;
  overflow: hidden;
  background: var(--md-default-bg-color);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.md-typeset details:hover {
  border-color: rgba(77, 171, 247, 0.5);
}

.md-typeset details[open] {
  border-color: rgba(77, 171, 247, 0.5);
  box-shadow: 0 4px 16px rgba(77, 171, 247, 0.12);
}

.md-typeset details > summary {
  margin: 0;
  padding: 10px 16px;
  background: rgba(77, 171, 247, 0.08);
  color: var(--md-default-fg-color);
  font-weight: 600;
  cursor: pointer;
}

.md-typeset details > summary:hover {
  color: var(--ds-blue-deep);
}

.md-typeset details[open] > *:not(summary) {
  padding-left: 16px;
  padding-right: 16px;
  margin-top: 12px;
  margin-bottom: 12px;
}

/* Аккордеоны ??? question — в фирменном синем, как у остальных details.
   Материал по умолчанию красит их в зелёный — переопределяем. */
.md-typeset .admonition.question,
.md-typeset details.question {
  border-color: var(--md-primary-fg-color);
}
.md-typeset .admonition.question:focus-within,
.md-typeset details.question:focus-within {
  box-shadow: 0 0 0 .2rem var(--md-primary-fg-color--transparent);
}
.md-typeset details.question > summary {
  background: rgba(77, 171, 247, 0.08);
}
.md-typeset details.question > summary::before,
.md-typeset details.question > summary::after {
  background-color: var(--ds-blue);
}

/* ===== Навигация по буквам в глоссарии ===== */
.glossary-search {
  margin: 16px 0 12px;
}

.glossary-search input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid rgba(77, 171, 247, 0.3);
  border-radius: 12px;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  font-size: 0.95rem;
  outline: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.glossary-search input:focus {
  border-color: var(--ds-blue-deep);
  box-shadow: 0 0 0 3px var(--ds-glow);
}

.glossary-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid rgba(77, 171, 247, 0.18);
  border-radius: 14px;
  background: var(--md-default-bg-color);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 8px;
  z-index: 20;
}

.glossary-tabs.is-hidden,
.glossary-letter.is-hidden,
.glossary-letter details.is-hidden {
  display: none !important;
}

.glossary-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid rgba(77, 171, 247, 0.25);
  border-radius: 8px;
  background: transparent;
  color: var(--ds-blue-deep);
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.glossary-tab:hover {
  background: rgba(77, 171, 247, 0.12);
  transform: translateY(-2px);
}

.glossary-tab.is-active {
  background: var(--ds-blue);
  color: #ffffff;
  border-color: var(--ds-blue);
}

@media (max-width: 600px) {
  .glossary-tabs {
    top: 4px;
    gap: 4px;
  }
  .glossary-tab {
    min-width: 32px;
    height: 32px;
  }
}

/* ===== Квиз ===== */
#quiz-app {
  max-width: 720px;
  margin: 0;
}

.quiz-progress {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--md-default-fg-color--light);
  margin-bottom: 8px;
}

.quiz-term {
  margin: 0 0 4px;
  font-size: 1.6rem;
  color: var(--ds-blue-deep);
}

.quiz-hint {
  margin: 0 0 20px;
  color: var(--md-default-fg-color--light);
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 18px;
  border: 1px solid rgba(77, 171, 247, 0.3);
  border-radius: 12px;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--ds-blue);
  background: rgba(77, 171, 247, 0.06);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(77, 171, 247, 0.15);
}

.quiz-option:disabled {
  cursor: default;
  transform: none;
  box-shadow: none;
}

.quiz-option.correct {
  border-color: #2f9e44;
  background: rgba(47, 158, 68, 0.12);
  color: #2b8a3e;
  font-weight: 600;
}

.quiz-option.wrong {
  border-color: #e03131;
  background: rgba(224, 49, 49, 0.1);
  color: #c92a2a;
  font-weight: 600;
}

.quiz-result {
  text-align: center;
  padding: 24px 0;
}

.quiz-result-title {
  font-size: 1.5rem;
  color: var(--ds-blue-deep);
  margin: 0 0 12px;
}

.quiz-score {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--md-default-fg-color);
  margin-bottom: 24px;
}

.quiz-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.quiz-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 22px;
  border: 1px solid rgba(77, 171, 247, 0.4);
  border-radius: 999px;
  background: transparent;
  color: var(--ds-blue-deep);
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.quiz-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(25, 113, 194, 0.2);
}

.quiz-btn-primary {
  border: 0;
  background: linear-gradient(135deg, #4dabf7, #1971c2);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(25, 113, 194, 0.25);
}

.quiz-btn-primary:hover {
  box-shadow: 0 12px 28px rgba(25, 113, 194, 0.35);
  filter: brightness(1.05);
}

@media (max-width: 600px) {
  .quiz-term {
    font-size: 1.3rem;
  }
  .quiz-score {
    font-size: 1.8rem;
  }
}

/* ===== Виджеты главной страницы ===== */
.hero-search {
  max-width: 560px;
  margin: 20px 0 12px;
}

.hero-search input {
  width: 100%;
  box-sizing: border-box;
  padding: 14px 20px;
  border: 1px solid rgba(77, 171, 247, 0.35);
  border-radius: 999px;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  font: inherit;
  font-size: 1rem;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.06);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hero-search input:focus {
  outline: none;
  border-color: var(--ds-blue-deep);
  box-shadow: 0 0 0 3px var(--ds-glow);
}

.term-of-day {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  max-width: 680px;
  margin: 24px 0 28px;
  padding: 18px 22px;
  border: 1px solid rgba(77, 171, 247, 0.25);
  border-radius: 14px;
  background: var(--md-default-bg-color);
  box-shadow: 0 4px 18px rgba(77, 171, 247, 0.12);
}

.term-of-day__icon {
  font-size: 1.6rem;
  line-height: 1.2;
}

.term-of-day__label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ds-blue-deep);
}

.term-of-day__term {
  display: inline-block;
  margin: 2px 0 4px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--md-default-fg-color);
  text-decoration: none;
}

.term-of-day__term:hover {
  color: var(--ds-blue-deep);
}

.term-of-day__def {
  margin: 0 0 6px;
  color: var(--md-default-fg-color--light);
}

.term-of-day__more {
  font-weight: 600;
  color: var(--ds-blue-deep);
  text-decoration: none;
}

.term-of-day__more:hover {
  text-decoration: underline;
}

.homepage-stats {
  display: inline-block;
  margin: 8px 0 20px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(77, 171, 247, 0.1);
  color: var(--ds-blue-deep);
  font-weight: 700;
  font-size: 0.9rem;
}

.homepage-posts {
  margin: 0 0 28px;
}

.homepage-posts__head h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
}

.posts-slider {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.posts-slider__viewport {
  flex: 1 1 auto;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.posts-slider__viewport::-webkit-scrollbar {
  display: none;
}

.posts-slider__track {
  display: flex;
  gap: 16px;
}

.post-card {
  flex: 0 0 280px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(77, 171, 247, 0.18);
  border-radius: 14px;
  overflow: hidden;
  background: var(--md-default-bg-color);
  color: inherit;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.post-card:hover {
  transform: translateY(-4px);
  border-color: rgba(77, 171, 247, 0.6);
  box-shadow: 0 12px 30px rgba(77, 171, 247, 0.18);
}

.post-card__img img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.post-card__body {
  padding: 12px 16px 14px;
}

.post-card__title {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--md-default-fg-color);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card__date {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--md-default-fg-color--light);
}

.posts-slider__nav {
  flex: 0 0 auto;
  width: 40px;
  border: 1px solid rgba(77, 171, 247, 0.3);
  border-radius: 10px;
  background: var(--md-default-bg-color);
  color: var(--ds-blue-deep);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.posts-slider__nav:hover:not(:disabled) {
  border-color: var(--ds-blue);
  background: rgba(77, 171, 247, 0.08);
}

.posts-slider__nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.homepage-posts__all {
  margin-top: 16px;
  text-align: center;
}

@media (max-width: 960px) {
  .post-card {
    flex: 0 0 240px;
  }
}

@media (max-width: 600px) {
  .term-of-day {
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px;
  }
  .post-card {
    flex: 0 0 100%;
  }
  .posts-slider__nav {
    display: none;
  }
}

/* ===== 404 страница ===== */
.not-found {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 20px 80px;
  text-align: center;
}

.not-found__emoji {
  font-size: 3.5rem;
  line-height: 1;
  animation: nf-float 3s ease-in-out infinite;
}

.not-found__title {
  margin: 16px 0 8px;
  font-size: 1.7rem;
  color: var(--ds-blue-deep);
}

.not-found__text {
  margin: 0 0 24px;
  color: var(--md-default-fg-color--light);
}

.not-found__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.not-found__particles span {
  position: absolute;
  font-size: 1.5rem;
  opacity: 0.45;
  animation: nf-float 4s ease-in-out infinite;
  pointer-events: none;
}

.not-found__particles span:nth-child(1) { top: 8%;  left: 4%;   animation-delay: 0s;    }
.not-found__particles span:nth-child(2) { top: 24%; right: 8%;  animation-delay: 0.5s;  }
.not-found__particles span:nth-child(3) { top: 48%; left: 2%;   animation-delay: 1s;    }
.not-found__particles span:nth-child(4) { top: 56%; right: 4%;  animation-delay: 1.5s;  }
.not-found__particles span:nth-child(5) { top: 14%; right: 22%; animation-delay: 2s;   }
.not-found__particles span:nth-child(6) { top: 70%; left: 18%;  animation-delay: 2.5s;  }

@keyframes nf-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

@media (max-width: 600px) {
  .not-found {
    padding: 32px 16px 60px;
  }
  .not-found__title {
    font-size: 1.4rem;
  }
  .not-found__particles span {
    display: none;
  }
}

/* Два блока-карточки под приветствием: термин дня + квиз */
.hero-widgets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 24px 0 28px;
}

/* Сетка квизов на странице «Проверь себя» */
.quiz-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 24px 0 28px;
}

@media (max-width: 600px) {
  .quiz-grid {
    grid-template-columns: 1fr;
  }
}

.hero-widgets .term-of-day {
  margin: 0;
  max-width: none;
}

.quiz-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 22px;
  border: 1px solid rgba(77, 171, 247, 0.25);
  border-radius: 14px;
  background: var(--md-default-bg-color);
  color: inherit;
  text-decoration: none;
  box-shadow: 0 4px 18px rgba(77, 171, 247, 0.12);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.quiz-card:hover {
  transform: translateY(-3px);
  border-color: rgba(77, 171, 247, 0.6);
  box-shadow: 0 12px 30px rgba(77, 171, 247, 0.18);
}

.quiz-card__icon {
  font-size: 1.6rem;
  line-height: 1.2;
}

.quiz-card__label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ds-blue-deep);
}

.quiz-card__title {
  margin: 2px 0 4px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--md-default-fg-color);
}

.quiz-card__text {
  margin: 0 0 6px;
  color: var(--md-default-fg-color--light);
}

.quiz-card__more {
  font-weight: 600;
  color: var(--ds-blue-deep);
}

/* Глоссарий: сетка 2 колонки */
.glossary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
  align-items: start;
}

.glossary-letter > h2 {
  display: none;
}

@media (max-width: 960px) {
  .glossary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .hero-widgets {
    grid-template-columns: 1fr;
  }
  .quiz-card {
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px;
  }
}

/* ===== Виджет «Спроси библиотеку» ===== */
.ask-widget__fab {
  position: fixed;
  right: 20px;
  bottom: 88px;
  z-index: 1030;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #4dabf7, #1971c2);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(25, 113, 194, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.ask-widget__fab:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(25, 113, 194, 0.45);
  filter: brightness(1.05);
}

.ask-widget {
  position: fixed;
  right: 20px;
  bottom: 154px;
  z-index: 1040;
  display: none;
  width: min(360px, calc(100vw - 40px));
  max-height: min(70vh, 560px);
  flex-direction: column;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  border: 1px solid rgba(77, 171, 247, 0.3);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.ask-widget.is-open {
  display: flex;
}

.ask-widget__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, #4dabf7, #1971c2);
  color: #fff;
}

.ask-widget__title {
  font-weight: 700;
  font-size: 0.85rem;
}

.ask-widget__close {
  border: 0;
  background: none;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.ask-widget__messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.75rem;
  line-height: 1.4;
}

.ask-widget__msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
}

.ask-widget__msg--assistant {
  align-self: flex-start;
  background: rgba(77, 171, 247, 0.1);
  border-bottom-left-radius: 4px;
}

.ask-widget__msg--user {
  align-self: flex-end;
  background: rgba(25, 113, 194, 0.12);
  border-bottom-right-radius: 4px;
}

.ask-widget__msg a {
  color: var(--ds-blue-deep);
  font-weight: 600;
}

.ask-widget__typing {
  font-style: italic;
  color: var(--md-default-fg-color--light);
}

.ask-widget__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px 0;
}

.ask-widget__suggestion {
  border: 1px solid rgba(77, 171, 247, 0.35);
  border-radius: 999px;
  background: transparent;
  color: var(--ds-blue-deep);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ask-widget__suggestion:hover {
  background: rgba(77, 171, 247, 0.1);
  border-color: var(--ds-blue);
}

.ask-widget__form {
  display: flex;
  gap: 8px;
  padding: 12px 16px 14px;
  border-top: 1px solid rgba(77, 171, 247, 0.15);
}

.ask-widget__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid rgba(77, 171, 247, 0.3);
  border-radius: 10px;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  font: inherit;
  font-size: 0.78rem;
}

.ask-widget__input:focus {
  outline: none;
  border-color: var(--ds-blue-deep);
  box-shadow: 0 0 0 3px var(--ds-glow);
}

.ask-widget__send {
  flex: 0 0 auto;
  border: 0;
  border-radius: 10px;
  padding: 0 16px;
  background: linear-gradient(135deg, #4dabf7, #1971c2);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.ask-widget__send:hover:not(:disabled) {
  filter: brightness(1.05);
}

.ask-widget__send:disabled {
  opacity: 0.6;
  cursor: default;
}

@media (max-width: 600px) {
  .ask-widget {
    right: 10px;
    width: calc(100vw - 20px);
  }
  .ask-widget__fab {
    right: 12px;
    bottom: 88px;
  }
}

/* ===== Кейсы (витрина-портфолио) ===== */
.case-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin: 24px 0;
}

@media (max-width: 600px) {
  .case-grid {
    grid-template-columns: 1fr;
  }
}

.case-card {
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(77, 171, 247, 0.18);
  border-radius: 14px;
  overflow: hidden;
  background: var(--md-default-bg-color);
  color: inherit;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.case-card:hover {
  transform: translateY(-4px);
  border-color: rgba(77, 171, 247, 0.6);
  box-shadow: 0 12px 30px rgba(77, 171, 247, 0.18);
}

.case-card__img img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.case-card__img--soon {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 9;
  font-size: 3rem;
  background: rgba(77, 171, 247, 0.08);
}

.case-card__body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.case-card__badge {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  background: linear-gradient(135deg, #4dabf7, #1971c2);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 8px;
}

.case-card__badge--soon {
  background: rgba(77, 171, 247, 0.25);
  color: var(--ds-blue-deep);
}

.case-card__title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--md-default-fg-color);
  margin-bottom: 8px;
}

.case-card__text {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--md-default-fg-color--light);
  flex: 1;
}

.case-card__more {
  font-weight: 600;
  color: var(--ds-blue-deep);
}

.case-card--soon {
  opacity: 0.85;
}

@media (max-width: 600px) {
  .case-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

/* Обёртка картинки карточки кейса */
.case-card__img {
  display: block;
  aspect-ratio: 16 / 9;
  background-size: cover;
  background-position: center;
}

/* Картинка-обложка внутри кейса: 30% ширины, обтекание текстом */
.case-hero-img {
  float: right;
  width: 30%;
  min-width: 220px;
  margin: 0 0 16px 20px;
  border-radius: 12px;
}

@media (max-width: 600px) {
  .case-hero-img {
    float: none;
    width: 100%;
    min-width: 0;
    margin: 0 0 16px 0;
  }
}

/* Обложки в ленте блога — кликабельны, ведут на статью */
.blog-cover-link {
  display: block;
}

/* Пагинация кейсов */
.case-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 20px 0 28px;
}

.case-pagination button {
  min-width: 34px;
  height: 34px;
  border: 1px solid rgba(77, 171, 247, 0.3);
  border-radius: 8px;
  background: var(--md-default-bg-color);
  color: var(--ds-blue-deep);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.case-pagination button:hover:not(:disabled) {
  border-color: var(--ds-blue);
  background: rgba(77, 171, 247, 0.08);
}

.case-pagination button.is-active {
  background: var(--ds-blue);
  border-color: var(--ds-blue);
  color: #fff;
}

.case-pagination button:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Ссылки в копирайте футера — столбиком, без больших отступов */
.md-copyright {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.md-copyright .md-footer__link {
  display: block;
  padding: 0;
  margin: 0;
  line-height: 1.4;
}

/* Карта сайта: сетка из двух колонок */
.sitemap-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 40px;
  align-items: start;
}

.sitemap-grid h2 {
  margin-bottom: 8px;
}

@media (max-width: 600px) {
  .sitemap-grid {
    grid-template-columns: 1fr;
  }
}

/* Хлебные крошки в блог-постах: рендерятся внутри .md-typeset,
   из-за чего на них действуют отступы Material (margin у .md-path
   и margin-left: 1.25em у li). Гасим их и выравниваем в строку. */
.md-content .md-typeset .md-path {
  margin: 0;
}

.md-content .md-typeset .md-path__list {
  display: flex;
  align-items: flex-start;
  gap: 0.2rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.md-content .md-typeset .md-path__item {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin-left: 0;
  white-space: nowrap;
}


/* --- Блок ссылок на код и артефакты в кейсах -------------------------- */

.case-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0.2rem 0 1.4rem;
  clear: both;
}

.case-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.6rem;
  background-color: var(--md-code-bg-color);
  color: var(--md-default-fg-color);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: border-color .15s ease, color .15s ease, transform .15s ease,
              box-shadow .15s ease;
}

.case-link svg,
.md-typeset .case-link svg {
  width: 1.1rem;
  height: 1.1rem;
  min-width: 1.1rem;
  max-width: 1.1rem;
  flex: 0 0 1.1rem;
  fill: currentColor;
}

.case-link:hover,
.case-link:focus {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .10);
}

.case-link--github:hover,
.case-link--github:focus {
  border-color: #24292f;
  color: #24292f;
}

[data-md-color-scheme="slate"] .case-link--github:hover,
[data-md-color-scheme="slate"] .case-link--github:focus {
  border-color: #ffffff;
  color: #ffffff;
}

.case-link--hf:hover,
.case-link--hf:focus {
  border-color: #ff9d00;
  color: #ff9d00;
}

@media screen and (max-width: 480px) {
  .case-links { gap: 8px; }
  .case-link { font-size: 0.68rem; padding: 0.45rem 0.7rem; }
}

/* ===== Лекции: обложка курса и дорожная карта уроков ===== */

/* Сетка курсов на странице «Лекции» */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.course-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px 24px;
  border: 1px solid rgba(77, 171, 247, 0.2);
  border-radius: 16px;
  background: var(--md-default-bg-color);
  color: inherit;
  text-decoration: none;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.course-card:hover {
  transform: translateY(-4px);
  border-color: rgba(77, 171, 247, 0.6);
  box-shadow: 0 12px 30px rgba(77, 171, 247, 0.18);
}

.course-card__eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ds-blue-deep);
}

.course-card__title {
  margin: 0;
  font-size: 1.4rem;
  color: var(--md-default-fg-color);
}

.course-card__desc {
  margin: 0;
  color: var(--md-default-fg-color--light);
  font-size: 0.95rem;
  line-height: 1.5;
}

.course-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--md-default-fg-color--light);
}

.course-card__bar {
  height: 8px;
  border-radius: 999px;
  background: var(--md-default-fg-color--lightest);
  overflow: hidden;
}

.course-card__bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4dabf7, #1971c2);
}

.course-card__more {
  font-weight: 700;
  color: var(--ds-blue-deep);
}

/* Шапка курса: сводка по урокам */
.course-hero {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 20px 0 28px;
  padding: 16px 20px;
  border: 1px solid rgba(77, 171, 247, 0.2);
  border-radius: 14px;
  background: rgba(77, 171, 247, 0.06);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--md-default-fg-color);
}

/* Дорожная карта уроков */
.lecture-track {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0 28px;
}

.lecture-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid rgba(77, 171, 247, 0.16);
  border-radius: 14px;
  background: var(--md-default-bg-color);
  color: inherit;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.lecture-item:hover {
  transform: translateY(-2px);
  border-color: rgba(77, 171, 247, 0.55);
  box-shadow: 0 10px 26px rgba(77, 171, 247, 0.16);
}

.lecture-item__num {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.95rem;
  background: rgba(77, 171, 247, 0.14);
  color: var(--ds-blue-deep);
}

.lecture-item__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.lecture-item__title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--md-default-fg-color);
}

.lecture-item__desc {
  margin: 2px 0 8px;
  color: var(--md-default-fg-color--light);
  font-size: 0.9rem;
  line-height: 1.45;
}

.lecture-item__status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.lecture-item--done .lecture-item__status {
  background: rgba(47, 158, 68, 0.14);
  color: #2b8a3e;
}

.lecture-item--current {
  border-color: rgba(77, 171, 247, 0.55);
  box-shadow: 0 8px 24px rgba(77, 171, 247, 0.16);
}

.lecture-item--current .lecture-item__status {
  background: rgba(77, 171, 247, 0.18);
  color: var(--ds-blue-deep);
}

.lecture-item--soon {
  opacity: 0.78;
}

.lecture-item--soon .lecture-item__num {
  background: var(--md-default-fg-color--lightest);
  color: var(--md-default-fg-color--light);
}

.lecture-item--soon .lecture-item__status {
  background: var(--md-default-fg-color--lightest);
  color: var(--md-default-fg-color--light);
}

@media (max-width: 600px) {
  .lecture-item {
    gap: 12px;
    padding: 14px;
  }
  .lecture-item__num {
    width: 36px;
    height: 36px;
    font-size: 0.85rem;
  }
}

/* ===== Ширина основной сетки =====
   У Material по умолчанию .md-grid зажат в 61rem. Из-за колонки меню
   и колонки содержания основному тексту оставалось совсем мало места:
   длинные схемы и код в лекциях уходили в горизонтальную прокрутку.
   78rem даёт комфортную ширину и при двух колонках, и при свёрнутых. */
.md-grid {
  max-width: 78rem;
}

/* ===== Собственная прокрутка текста лекции =====
   На страницах лекций (класс is-lecture ставит javascripts/lecture-mode.js)
   текст получает свой скролл: шапка, меню и содержание остаются на месте,
   а лекцию можно листать колесом, не прокручивая всю страницу. */
@media screen and (min-width: 76.25em) {
  /* Лекция забирает всю высоту под шапкой (2.4rem шапка + 2.4rem вкладки),
     поэтому полоса прокрутки длиннее и начинается выше. */
  html.is-lecture .md-main__inner {
    margin-top: 0.4rem;
  }

  html.is-lecture .md-content {
    max-height: calc(100vh - 5.2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    /* Полоса должна быть заметной: scrollbar-width: auto (а не thin) и
       контрастный бегунок на светлом треке. */
    scrollbar-width: auto;
    scrollbar-color: rgba(25, 113, 194, 0.8) rgba(25, 113, 194, 0.12);
    /* Место под полосу зарезервировано всегда — текст не дёргается */
    scrollbar-gutter: stable;
  }

  /* Ширина полосы: за неё удобнее браться мышью */
  html.is-lecture .md-content::-webkit-scrollbar {
    width: 14px;
  }

  html.is-lecture .md-content::-webkit-scrollbar-track {
    background: rgba(25, 113, 194, 0.1);
    border-radius: 8px;
  }

  html.is-lecture .md-content::-webkit-scrollbar-thumb {
    background: rgba(25, 113, 194, 0.8);
    border-radius: 8px;
    /* На очень длинной лекции ползунок иначе вырождается в точку */
    min-height: 5rem;
  }

  html.is-lecture .md-content::-webkit-scrollbar-thumb:hover {
    background: rgba(25, 113, 194, 1);
  }

  /* Внешняя полоса окна на лекции тоже заметная: страница прокручивается на
     высоту футера, и по полосе видно, что ниже есть ещё содержимое. */
  html.is-lecture {
    scrollbar-gutter: stable;
  }

  html.is-lecture::-webkit-scrollbar {
    width: 14px;
  }

  html.is-lecture::-webkit-scrollbar-track {
    background: rgba(25, 113, 194, 0.08);
  }

  html.is-lecture::-webkit-scrollbar-thumb {
    background: rgba(25, 113, 194, 0.7);
    border-radius: 8px;
  }

  html.is-lecture::-webkit-scrollbar-thumb:hover {
    background: rgba(25, 113, 194, 0.95);
  }

  /* ===== Индикация места в лекции =====
     Нативная полоса видна не всегда (при системной настройке «скрывать
     полосы» её нет вовсе), а штатный scrollspy темы не работает: прокручивается
     внутренний контейнер, а не окно. Поэтому показываем полосу прогресса
     чтения и подсвечиваем активный пункт «Содержания».
     Класс lecture-toc-active и саму полосу ставит javascripts/lecture-mode.js. */
  html.is-lecture .lecture-progress {
    position: sticky;
    top: 0;
    z-index: 4;
    height: 3px;
    margin-bottom: -3px;
    background: rgba(25, 113, 194, 0.12);
    pointer-events: none;
  }

  html.is-lecture .lecture-progress > span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--md-primary-fg-color);
  }

  html.is-lecture .md-sidebar--secondary .md-nav__link.lecture-toc-active,
  html.is-lecture .md-nav--secondary .md-nav__link.lecture-toc-active {
    color: var(--md-primary-fg-color);
    font-weight: 700;
  }

  /* ===== Читаемое «Содержание» лекции =====
     Блок есть и на других страницах, поэтому оформляем только под is-lecture:
     длинные заголовки лекций, вложенные уровни и подсветку текущего раздела. */
  html.is-lecture .md-sidebar--secondary .md-nav__link {
    font-size: 0.72rem;
    line-height: 1.3;
    /* Место под маркер текущего пункта. Отрицательный text-indent тут нельзя:
       он выталкивал первую букву за колонку и текст обрезался. */
    padding-left: 0.3rem;
    border-left: 2px solid transparent;
    border-radius: 2px;
    transition: color 125ms, background-color 125ms, border-color 125ms;
  }

  /* Длинные формулировки из заголовков переносим по словам и выравниваем
     длину строк: иначе вопрос разваливается на 2–3 рваные строки. */
  html.is-lecture .md-sidebar--secondary .md-nav__link .md-ellipsis {
    white-space: normal;
    text-wrap: balance;
  }

  /* Вложенные уровни: отступ заметнее темы (там 0.6rem) плюс направляющая
     линия, чтобы иерархия читалась, а не сливалась с родительскими пунктами. */
  html.is-lecture .md-sidebar--secondary .md-nav__list .md-nav__list {
    margin-left: 0.15rem;
    padding-left: 1rem;
    border-left: 1px solid var(--md-default-fg-color--lightest);
  }

  /* Текущий раздел: акцентный цвет, жирный и полоса слева. */
  html.is-lecture .md-sidebar--secondary .md-nav__link.lecture-toc-active {
    color: var(--md-primary-fg-color);
    font-weight: 700;
    border-left-color: var(--md-primary-fg-color);
    background-color: rgba(25, 113, 194, 0.1);
  }

  /* Прочитанное выше приглушено — взгляд цепляется за текущий раздел. */
  html.is-lecture .md-sidebar--secondary .md-nav__link.lecture-toc-read {
    color: var(--md-default-fg-color--light);
    opacity: 0.7;
  }
}

/* ===== Лекции на всю ширину окна =====
   На широких экранах лекция выглядела узкой: .md-grid зажат в 78rem, поэтому
   по бокам оставалось пустое место, а картинки и таблицы не использовали
   ширину экрана. На страницах-лекциях (класс is-lecture ставит
   javascripts/lecture-mode.js — только уроку с колонкой содержания, порог 60em)
   снимаем ограничение сетки: текст, картинки, таблицы и схемы занимают всю
   ширину колонки лекции (владелица просила именно это — чем компактнее
   вёрстка, тем лучше). Остальные страницы сайта не затронуты:
   правила работают только под html.is-lecture и только от 60em, как и сам класс. */
@media screen and (min-width: 60em) {
  /* Только основная сетка: .md-grid есть ещё у шапки и подвала, их не трогаем —
     иначе селектор языка в шапке уезжает за правый край окна. */
  html.is-lecture .md-main .md-grid {
    max-width: none;
  }

  /* У Material есть правило, которое режет содержимое до 1400px на страницах
     без колонки навигации; лекциям это ограничение не нужно. */
  html.is-lecture .md-content__inner {
    max-width: none;
  }

  /* Ширину текста больше ничем не ограничиваем: абзацы занимают всю колонку
     лекции, как и просила владелица. Единственное исключение — блоки кода:
     34rem (примерно 100 символов строки) хватает длинным строкам, но не
     превращает текстовые схемы-цепочки в огромные пустые прямоугольники. */
  html.is-lecture .md-typeset > :is(pre, .highlight) {
    max-width: 34rem;
  }

  /* Картинки, таблицы, формулы и сетки-компоненты тоже занимают всю ширину
     колонки. */
  html.is-lecture .md-typeset > :is(
      figure,
      table,
      .md-typeset__table,
      .arithmatex,
      iframe,
      .mermaid,
      .flow-grid,
      .grid,
      .card-grid
    ) {
    max-width: none;
  }
}

/* ===== Формулы KaTeX =====
   Широкие формулы (матрицы, длинные дроби) не должны растягивать колонку —
   лучше дать им собственную горизонтальную прокрутку. */
.md-typeset .arithmatex .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}

/* ===== Иллюстрации в лекциях =====
   Картинки генерируются без текста: все подписи — обычный HTML в figcaption,
   поэтому на телефоне они остаются крупными, адаптивными и меняют цвет вместе с темой. */
.lecture-figure {
  margin: 1.8rem 0;
}

.lecture-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
}

.lecture-figure figcaption {
  margin: 0.7rem 0 0;
  max-width: none;
  width: 100%;
  font-size: 0.76rem;
  line-height: 1.55;
  color: var(--md-default-fg-color--light);
}

/* в тёмной теме светлый фон картинки слегка приглушаем */
[data-md-color-scheme="slate"] .lecture-figure img {
  filter: brightness(0.9) contrast(1.02);
}

/* Рисунок и описание рядом: картинка слева, подпись справа.
   На узких экранах схема возвращается в обычную колонку. */
.lecture-figure--side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.4rem;
  align-items: center;
}

.lecture-figure--side figcaption {
  margin: 0;
}

@media screen and (max-width: 44.9375em) {
  .lecture-figure--side {
    grid-template-columns: minmax(0, 1fr);
  }

  .lecture-figure--side figcaption {
    margin: 0.7rem 0 0;
  }
}

/* ===== «Путь машинного обучения»: восемь карточек =====
   Карточки вырезаны из сгенерированной иллюстрации, а подписи к ним —
   обычный HTML-текст. Поэтому схема читается и на телефоне, и в тёмной теме,
   а не превращается в мелкий растр. */
.flow-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.2rem 1rem;
  margin: 1.8rem 0 1rem;
}

.flow-cell img {
  display: block;
  width: 4.2rem;
  height: auto;
  margin: 0 auto 0.45rem;
}

.flow-cell b {
  display: block;
  font-size: 0.74rem;
  line-height: 1.3;
  text-align: center;
}

.flow-cell span {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.68rem;
  line-height: 1.4;
  color: var(--md-default-fg-color--light);
  text-align: center;
}

.flow-note {
  margin: 0 0 1.7rem;
  font-size: 0.74rem;
  line-height: 1.5;
  color: var(--md-default-fg-color--light);
  text-align: center;
}

@media screen and (max-width: 60em) {
  .flow-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media screen and (max-width: 30em) {
  .flow-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ===== Шрифт блоков кода =====

   JetBrains Mono приходит из Google Fonts урезанным набором: символов рамок
   (│ ─ ┌ ┐ └ ┘ ├ ┤ ┼) в нём нет. Браузер подставляет их из другого шрифта,
   а у него другая ширина (замерено: 7.48 px против 8.17 px) — из-за этого
   ASCII-схемы в лекциях разъезжаются, стрелки отрываются от линий.

   Берём локальный моноширинный шрифт с полным покрытием: все знаки в нём
   одной ширины, поэтому схемы сходятся на любой платформе. */
:root,
[data-md-color-scheme] {
  --md-code-font: Consolas, "DejaVu Sans Mono", "Liberation Mono", Menlo,
    "Courier New", monospace;
}

.md-typeset code,
.md-typeset pre > code,
.md-typeset kbd {
  font-family: Consolas, "DejaVu Sans Mono", "Liberation Mono", Menlo,
    "Courier New", monospace;
}

/* ===== Компоненты лекций: задания и итоговая карта =====

   Оба блока пишутся в markdown внутри <div class="..." markdown>,
   формулы в них обрабатываются KaTeX как обычно. */

/* --- Задания для самостоятельной работы ---
   Блок стоит ровно с текстом: рамка-обёртка и внутренние отступы убраны
   (task-92, эталон — раздел «Что нужно уметь объяснить…»). Вопросы внутри
   получают свои карточки отдельных правилом ниже (task-93). */
.lecture-check {
  margin: 1.4rem 0;
  padding: 0;
  border: 0;
  border-radius: 0;
}

.lecture-check > h3 {
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
  font-weight: 700;
}

.lecture-check > p:first-of-type {
  margin: 0 0 0.4rem;
  color: var(--md-default-fg-color--light);
  font-size: 0.72rem;
}

.lecture-check .task-list {
  margin: 0.4rem 0 0;
  padding: 0;
  list-style: none;
}

.lecture-check .task-list-item {
  margin: 0;
  padding: 0.8rem 0 0.8rem 2rem;
  border-top: 1px solid var(--md-default-fg-color--lightest);
  list-style: none;
}

.lecture-check .task-list-item:first-child {
  border-top: 0;
}

/* Кружок-маркер.
   Material прячет настоящий input (opacity: 0) и рисует свой маркер через
   .task-list-indicator::before — его отключаем ниже, а видимым делаем сам input.
   Checkbox настоящий: его можно нажать, отметка запоминается
   (это делает javascripts/lecture-check.js). */
.lecture-check .task-list-item {
  position: relative;
}

.lecture-check .task-list-control {
  position: absolute;
  margin-top: 0.1rem;
}

.lecture-check .task-list-control input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  opacity: 1;                    /* Material держит его прозрачным */
  border: 1.5px solid var(--md-default-fg-color--light);
  border-radius: 50%;
  background: transparent;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.lecture-check .task-list-control:hover input[type="checkbox"] {
  border-color: var(--md-primary-fg-color);
}

.lecture-check .task-list-control input[type="checkbox"]:checked {
  border-color: var(--md-primary-fg-color);
  background: var(--md-primary-fg-color);
  box-shadow: inset 0 0 0 3px var(--md-default-bg-color);
}

.lecture-check .task-list-indicator::before {
  display: none;   /* свой кружок вместо стандартной галочки material */
}

/* Отмеченное задание слегка приглушаем */
.lecture-check .task-list-item:has(input:checked) > p,
.lecture-check .task-list-item:has(input:checked) {
  color: var(--md-default-fg-color--light);
}

.lecture-check__answers {
  margin-top: 0.9rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--md-default-fg-color--lightest);
}

.lecture-check__answers > summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--md-primary-fg-color);
  list-style: none;
}

.lecture-check__answers > summary::-webkit-details-marker {
  display: none;
}

.lecture-check__answers > summary::after {
  content: " ↓";
  display: inline-block;
  transition: transform 0.18s ease;
}

.lecture-check__answers[open] > summary::after {
  transform: rotate(180deg);
}

.lecture-check__answers > * + * {
  margin-top: 0.5rem;
}

/* --- Итоговая карта темы: вся тема одной цепочкой ---
   Рамка-обёртка убрана (task-92): карточки стоят ровно с текстом. */
.lecture-map {
  /* Отступ между карточками. От него же считаем положение стрелки, поэтому
     меняется он в одном месте. */
  --lecture-map-gap: 1.7rem;
  margin: 1.4rem 0;
  padding: 0;
  border: 0;
  border-radius: 0;
}

.lecture-map ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: none;
}

/* Селектор намеренно с .md-typeset и ol: у Material есть правило
   `.md-typeset ol li { margin-bottom: .5em }` (специфичность выше), которое
   перебивало отступ между карточками — промежуток был 0.5em вместо 1.7rem,
   и стрелка попадала на карточку. */
.md-typeset .lecture-map ol > li {
  position: relative;
  margin: 0 0 var(--lecture-map-gap);
  padding: 0.85rem 1rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 8px;
  text-align: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.lecture-map li:last-child {
  margin-bottom: 0;
}

.lecture-map li:hover {
  transform: translateY(-2px);
  border-color: var(--md-primary-fg-color);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

/* Стрелка между шагами: её центр — ровно середина промежутка между карточками.
   top берём как половину отступа, а translateY(-50%) центрирует саму стрелку,
   поэтому положение не зависит ни от кегля, ни от line-height. */
.lecture-map li + li::before {
  content: "↓";
  position: absolute;
  top: calc(var(--lecture-map-gap) / -2);
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--md-default-fg-color--light);
  font-size: 1.15rem;
  line-height: 1;
  font-weight: 600;
}

.lecture-map li > p:first-child {
  margin-top: 0;
}

.lecture-map li > p:last-child {
  margin-bottom: 0;
}

/* Формулы внутри карты шагов — по центру карточки (владелица просила
   центрировать именно в этом блоке: карточки и текст там уже по центру).
   В обычном тексте лекции формула остаётся по левому краю — это её
   отдельное требование, поэтому правило узкое: только .lecture-map. */
html:has(.lecture-practice) .md-typeset .lecture-map .arithmatex {
  text-align: center;
}

html:has(.lecture-practice) .md-typeset .lecture-map .arithmatex .katex-display {
  margin-left: auto;
  margin-right: auto;
}

/* Пока схема перерисовывается под нужное направление (ПК/телефон),
   не показываем промежуточный вариант — иначе видно мигание.
   Класс ставит javascripts/lecture-mode.js. */
.lecture-diagram-wait {
  visibility: hidden;
}

/* ===== Практика в Лаборатории =====

   Блок из трёх действий со ссылками на демонстрации. Пишется как
   <div class="lecture-practice" markdown> — тогда внутри работают ссылки
   и разметка markdown. Образец — лекция 06. */

.lecture-practice {
  margin: 1.4rem 0;
  padding: 0;
  border: 0;
  border-radius: 0;
}

.lecture-practice > h2,
.lecture-practice > h3 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 700;
}

.lecture-practice > p:first-of-type {
  margin: 0 0 0.5rem;
  color: var(--md-default-fg-color--light);
  font-size: 0.72rem;
}

.lecture-practice ol {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: practice;
}

.lecture-practice li {
  position: relative;
  margin: 0 0 0.55rem;
  padding: 0.7rem 0.9rem 0.7rem 2.7rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 8px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.lecture-practice li:last-child {
  margin-bottom: 0;
}

.lecture-practice li:hover {
  transform: translateY(-2px);
  border-color: var(--md-primary-fg-color);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.lecture-practice li::before {
  counter-increment: practice;
  content: counter(practice);
  position: absolute;
  left: 0.85rem;
  top: 0.75rem;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.2rem;
  text-align: center;
}

.lecture-practice li p:first-child {
  margin-top: 0;
}

.lecture-practice li p:last-child {
  margin-bottom: 0;
}

.lecture-practice a {
  font-weight: 600;
}

/* ===== Время чтения под заголовком =====

   Плашку ставит хук hooks/reading_time.py: считает слова в прозе (без кода
   и формул) и делит на скорость чтения. Показывается не везде — короткие
   заметки и карточки терминов пропускаются. */

.reading-time {
  margin: -0.3rem 0 1.1rem;
  color: var(--md-default-fg-color--light);
  font-size: 0.72rem;
  letter-spacing: 0.01em;
}

/* ===== Даты в блоге не показываем =====

   В списке постов карточку рисует шаблон темы, и дата с временем чтения лежат
   в одном списке .md-meta__list. Оба элемента не нужны, поэтому скрываем список
   целиком — иначе на месте даты оставался бы пустой маркер.
   На странице самого поста этот блок вырезан в overrides/blog-post.html. */

.md-post--excerpt .md-meta__list {
  display: none;
}

/* ===== Единый стиль лекций (task-83) =====
   1. Блочные формулы KaTeX — по левому краю: центрированные «столбики» из одной
      формулы разрывали мысль и выглядели неаккуратно.
   2. Длинные списки (10+ пунктов) — в 2–3 колонки. Класс .lecture-cols
      проставлен в лекциях вручную, поэтому короткие списки и вложенность
      не затронуты (никаких :has()).
   3. Служебные блоки (таблицы, карточки-компоненты) не растягиваются на всю
      ширину колонки: абзацы остаются широкими, а таблицы держат разумную
      ширину и не «разъезжаются» на две колонки по краям. */
html.is-lecture .md-typeset .katex-display,
html.is-lecture .md-typeset .katex-display > .katex {
  text-align: left;
}

html.is-lecture .md-typeset .lecture-cols > ul,
html.is-lecture .md-typeset .lecture-cols > ol {
  column-count: 2;
  column-gap: 2.4rem;
}

html.is-lecture .md-typeset .lecture-cols li {
  break-inside: avoid;
}

@media screen and (min-width: 76.25em) {
  html.is-lecture .md-typeset .lecture-cols > ul,
  html.is-lecture .md-typeset .lecture-cols > ol {
    column-count: 3;
  }
}

@media screen and (max-width: 44.9375em) {
  html.is-lecture .md-typeset .lecture-cols > ul,
  html.is-lecture .md-typeset .lecture-cols > ol {
    column-count: 1;
  }
}

/* Таблицы: не на всю ширину, по размеру содержимого */
html.is-lecture .md-typeset > .md-typeset__table {
  max-width: 46rem;
}

html.is-lecture .md-typeset > .md-typeset__table > table {
  width: auto;
  min-width: 0;
}

html.is-lecture .md-typeset > table {
  max-width: 46rem;
  width: auto;
}

/* Компоненты лекций стоят ровно с текстом: ширину не ограничиваем (task-92). */
html:has(.lecture-practice) .md-typeset .lecture-map,
html:has(.lecture-practice) .md-typeset .lecture-check,
html:has(.lecture-practice) .md-typeset .lecture-practice {
  max-width: none;
}

/* Компактные таблицы: у Material ячейки щедро раздвинуты (min-width 5rem и
   padding 1.25em), поэтому таблица из двух чисел выглядела «криво» — числа
   стояли далеко друг от друга. Для лекций делаем ячейки плотнее. */
html.is-lecture .md-typeset table:not([class]) th,
html.is-lecture .md-typeset table:not([class]) td {
  padding: 0.55rem 0.9rem;
}

html.is-lecture .md-typeset table:not([class]) th {
  min-width: 0;
}

/* ===== Лекции: формулы, заголовки, блоки (task-89 → переделано в task-90) =====
   ВАЖНО: класс is-lecture ставится только с 60em — на нём держится «своя
   прокрутка». Из-за этого на телефоне пропадало ВСЁ оформление лекций.
   Теперь оформление привязано к самой странице лекции по её компонентам
   (:has(.lecture-practice) есть во всех 13 лекциях обеих версий), а «своя
   прокрутка» осталась отдельно и включается только на широком экране.

   1. Формула — рамка по ширине формулы (fit-content) и один визуальный язык
      со схемами mermaid: тот же радиус и та же рамка.
   2. \boxed{} — внутренние рамки и лишний padding убраны совсем (работает
      и в тёмной теме: рамки просто нет).
   3. Заголовки: одинаковый голубой border и одинаковый цвет текста у всех
      уровней («где-то голубой, где-то чёрный» было ошибкой).
   4. Вертикальные поля вокруг формул и разделителей уменьшены. */
html:has(.lecture-practice) .md-typeset .arithmatex {
  margin: 0.3rem 0 0.45rem;
}

html:has(.lecture-practice) .md-typeset .arithmatex .katex-display {
  margin: 0;
  padding: 0.4rem 0.7rem;
  /* Ширина по формуле, но не шире колонки: длинные формулы прокручиваются. */
  width: fit-content;
  max-width: 100%;
  background: var(--md-mermaid-node-bg-color, rgba(68, 138, 255, 0.08));
  border: 1px solid var(--md-mermaid-node-fg-color, #448aff);
  border-radius: 0.3rem;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Схемы: рамку-обёртку убрали (task-92) — у самих узлов схемы рамка есть,
   а вокруг схемы она выглядела лишней. Прокрутки внутри блока нет (откат
   task-90): схема просто масштабируется по ширине блока. Вертикальную
   раскладку узлов CSS задать не может — это делает markdown (flowchart TD). */
html:has(.lecture-practice) .md-typeset .mermaid {
  max-width: 100%;
  margin: 0.7rem 0;
}

html:has(.lecture-practice) .md-typeset .mermaid svg {
  max-width: 100%;
  height: auto;
}

/* ===== Лекции: нижняя навигация «Назад / Вперёд» (task-94) =====
   На странице лекции навигации и без неё много: меню лекций слева,
   «Содержание» справа, шапка и полоса прогресса чтения. Поэтому блок
   prev/next в футере убираем — но только на лекциях: маркер тот же
   (:has(.lecture-practice)), поэтому работает и на телефоне, где is-lecture
   не ставится. Остальной футер (копирайт, политика, карта сайта, обратная
   связь) остаётся нетронутым, на обычных страницах навигация как была. */
html:has(.lecture-practice) .md-footer__inner {
  display: none;
}

/* ===== Лекции: вопросы в «Заданиях для самопроверки» (task-93, леc06-a) =====
   Мягкая рамка-карточка у каждого вопроса. Раньше её давал Material через
   task-list-item, но чекбоксы убрали — вместе с ними ушло и оформление.
   Селектор только внутри .lecture-check, остальные H4 лекции не затронуты;
   маркер :has(.lecture-practice) вместо is-lecture, чтобы работало и на телефоне. */
html:has(.lecture-practice) .md-typeset .lecture-check h4 {
  margin: 1.1rem 0 0.5rem;
  padding: 0.55rem 0.8rem;
  background: var(--md-default-fg-color--lightest);
  border: 1px solid var(--md-default-fg-color--lighter);
  border-radius: 0.4rem;
  max-width: 54rem;
}

html:has(.lecture-practice) .md-typeset .highlight,
html:has(.lecture-practice) .md-typeset pre {
  border-radius: 0.3rem;
}

/* \boxed{}: KaTeX рисует рамку и padding, гасим и то и другое — в обеих темах. */
html:has(.lecture-practice) .md-typeset .katex .fbox {
  border: 0 !important;
  padding: 0 !important;
}

/* Заголовки: один голубой border и один цвет текста на всех уровнях. */
html:has(.lecture-practice) .md-typeset h1,
html:has(.lecture-practice) .md-typeset h2,
html:has(.lecture-practice) .md-typeset h3,
html:has(.lecture-practice) .md-typeset h4 {
  color: var(--md-default-fg-color);
  padding-left: 0.7rem;
  border-left: 4px solid var(--md-accent-fg-color, #448aff);
}

html:has(.lecture-practice) .md-typeset h2 {
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.25;
  margin: 1.8rem 0 0.7rem;
}

html:has(.lecture-practice) .md-typeset h3 {
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 1.35rem 0 0.5rem;
}

html:has(.lecture-practice) .md-typeset h4 {
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 1rem 0 0.4rem;
}

/* «Важно:» — единственный тёплый акцент: блок не должен читаться как формула. */
html:has(.lecture-practice) .md-typeset .lecture-alert {
  margin: 0.6rem 0 0.7rem;
  padding: 0.5rem 0.8rem;
  background: rgba(245, 159, 0, 0.08);
  border: 0;
  border-left: 3px solid #f59f00;
  border-radius: 0.2rem;
  max-width: 54rem;
}

html:has(.lecture-practice) .md-typeset .lecture-alert p {
  margin: 0;
}

/* Пустые абзацы и жирные разделители вокруг формул — только пустота. */
html:has(.lecture-practice) .md-typeset > p:empty {
  display: none;
}

html:has(.lecture-practice) .md-typeset hr {
  margin: 1rem 0;
}

/* ===== Лекции на телефоне (task-90) =====
   Меньше отступов, ничего не вылезает за экран: формулы прокручиваются внутри
   своей рамки, таблицы переносят текст, схемы масштабируются. */
@media screen and (max-width: 44.9375em) {
  html:has(.lecture-practice) .md-typeset .arithmatex {
    margin: 0.25rem 0 0.35rem;
  }

  html:has(.lecture-practice) .md-typeset .arithmatex .katex-display {
    padding: 0.35rem 0.55rem;
    /* Длинные формулы чуть масштабируются под экран, но остаются читаемыми. */
    font-size: 0.96em;
  }

  html:has(.lecture-practice) .md-typeset h1,
  html:has(.lecture-practice) .md-typeset h2,
  html:has(.lecture-practice) .md-typeset h3,
  html:has(.lecture-practice) .md-typeset h4 {
    padding-left: 0.55rem;
    border-left-width: 3px;
  }

  html:has(.lecture-practice) .md-typeset h2 {
    font-size: 1.25rem;
    margin: 1.4rem 0 0.55rem;
  }

  html:has(.lecture-practice) .md-typeset h3 {
    font-size: 1.06rem;
    margin: 1.1rem 0 0.45rem;
  }

  html:has(.lecture-practice) .md-typeset h4 {
    font-size: 0.96rem;
    margin: 0.9rem 0 0.35rem;
  }

  html:has(.lecture-practice) .md-typeset .lecture-map,
  html:has(.lecture-practice) .md-typeset .lecture-check,
  html:has(.lecture-practice) .md-typeset .lecture-practice {
    margin: 1.1rem 0;
  }

  /* Таблицы: текст переносится, страница не «разъезжается». */
  html:has(.lecture-practice) .md-typeset table:not([class]) {
    width: 100%;
    table-layout: fixed;
    font-size: 0.86em;
  }

  html:has(.lecture-practice) .md-typeset table:not([class]) th,
  html:has(.lecture-practice) .md-typeset table:not([class]) td {
    padding: 0.35rem 0.45rem;
    word-break: break-word;
  }

  html:has(.lecture-practice) .md-typeset .lecture-alert {
    margin: 0.5rem 0 0.6rem;
    padding: 0.45rem 0.7rem;
  }
}
