/* ==========================================================================
   Университет Мемов «ISHAK» — Стили руководства по агентному ИИ
   Версия: 0.0.1
   ========================================================================== */

/* --------------------------------------------------------------------------
   ПЕРЕМЕННЫЕ ТЕМ
   -------------------------------------------------------------------------- */
:root {
  --guide-bg: #f7f9fc;
  --guide-surface: #ffffff;
  --guide-surface-alt: #f0f4f9;
  --guide-text: #1a1a1a;
  --guide-text-muted: #5a6472;
  --guide-border: #e2e8f0;
  --guide-accent: #1a5ba8;
  --guide-accent-dark: #0a1f3d;
  --guide-code-bg: #0a1f3d;
  --guide-code-text: #e8eef7;
  --guide-shadow: 0 4px 16px rgba(10, 31, 61, 0.08);
  --guide-blue: #1a5ba8;
  --guide-purple: #7c3aed;
  --guide-amber: #d97706;
  --guide-teal: #0d9488;
  --guide-green: #16a34a;
  --guide-red: #dc2626;
  --guide-highlight: #fef08a;
  --guide-highlight-current: #f59e0b;
}

body[data-theme="dark"] {
  --guide-bg: #0f172a;
  --guide-surface: #1e293b;
  --guide-surface-alt: #273449;
  --guide-text: #e2e8f0;
  --guide-text-muted: #94a3b8;
  --guide-border: #334155;
  --guide-accent: #60a5fa;
  --guide-accent-dark: #93c5fd;
  --guide-code-bg: #0b1120;
  --guide-code-text: #dbeafe;
  --guide-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  --guide-blue: #60a5fa;
  --guide-purple: #a78bfa;
  --guide-amber: #fbbf24;
  --guide-teal: #2dd4bf;
  --guide-green: #4ade80;
  --guide-red: #f87171;
  --guide-highlight: #854d0e;
  --guide-highlight-current: #ca8a04;
}

/* --------------------------------------------------------------------------
   ПАНЕЛЬ ИНСТРУМЕНТОВ
   -------------------------------------------------------------------------- */
.guide-toolbar {
  position: sticky;
  top: var(--guide-header-height, 64px);
  z-index: 900;
  background-color: var(--guide-surface);
  border-bottom: 1px solid var(--guide-border);
  box-shadow: var(--guide-shadow);
}

.guide-toolbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.guide-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--guide-surface-alt);
  border: 1px solid var(--guide-border);
  border-radius: 24px;
  padding: 6px 14px;
  flex: 1;
  min-width: 240px;
  max-width: 520px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.guide-search.is-visible {
  display: flex;
}

.guide-btn.guide-search-toggle {
  display: none;
}

.guide-search:focus-within {
  border-color: var(--guide-accent);
  box-shadow: 0 0 0 3px rgba(26, 91, 168, 0.15);
}

.guide-search-icon {
  width: 18px;
  height: 18px;
  color: var(--guide-text-muted);
  flex-shrink: 0;
}

.guide-search-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.95rem;
  color: var(--guide-text);
  font-family: inherit;
}

.guide-search-input::placeholder {
  color: var(--guide-text-muted);
}

.guide-search-count {
  font-size: 0.8rem;
  color: var(--guide-text-muted);
  white-space: nowrap;
}

.guide-search-nav {
  border: none;
  background: transparent;
  color: var(--guide-text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.guide-search-nav:hover {
  background-color: var(--guide-border);
  color: var(--guide-accent);
}

.guide-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Если поиск скрыт, группа управления всё равно должна быть справа. */
.guide-toolbar-inner:not(:has(.guide-search.is-visible)) .guide-toolbar-actions {
  margin-left: auto;
}

.guide-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--guide-border);
  border-radius: 20px;
  background-color: var(--guide-surface);
  color: var(--guide-text);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
}

.guide-btn:hover {
  background-color: var(--guide-surface-alt);
  border-color: var(--guide-accent);
}

.guide-btn:active {
  transform: scale(0.97);
}

.guide-btn-icon {
  width: 16px;
  height: 16px;
}

/* Иконки темы */
.guide-icon-sun {
  display: none;
}

body[data-theme="dark"] .guide-icon-moon {
  display: none;
}

body[data-theme="dark"] .guide-icon-sun {
  display: block;
}

/* --------------------------------------------------------------------------
   ПРОГРЕСС ЧТЕНИЯ
   -------------------------------------------------------------------------- */
.guide-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 1100;
  background-color: transparent;
  pointer-events: none;
}

.guide-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #1a5ba8, #7c3aed);
  transition: width 0.1s linear;
}

/* --------------------------------------------------------------------------
   ОСНОВНОЙ КОНТЕНТ
   -------------------------------------------------------------------------- */
.guide-main {
  flex: 1;
  background-color: var(--guide-bg);
  color: var(--guide-text);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.guide-layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

.guide-article {
  flex: 1;
  min-width: 0;
  max-width: 100%;
}

/* --------------------------------------------------------------------------
   БОКОВОЕ ОГЛАВЛЕНИЕ
   -------------------------------------------------------------------------- */
.guide-toc {
  width: 280px;
  flex-shrink: 0;
  position: sticky;
  top: 140px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  background-color: var(--guide-surface);
  border: 1px solid var(--guide-border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--guide-shadow);
}

/* Полоса прокрутки оглавления подстраивается под тему интерфейса. */
.guide-toc {
  scrollbar-width: thin;
  scrollbar-color: var(--guide-accent) var(--guide-surface-alt);
}

.guide-toc::-webkit-scrollbar {
  width: 8px;
}

.guide-toc::-webkit-scrollbar-track {
  background: var(--guide-surface-alt);
  border-radius: 8px;
}

.guide-toc::-webkit-scrollbar-thumb {
  background: var(--guide-accent);
  border-radius: 8px;
  border: 2px solid var(--guide-surface-alt);
}

.guide-toc::-webkit-scrollbar-thumb:hover {
  background: var(--guide-accent-dark);
}

.guide-toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.guide-toc-title {
  font-size: 1.1rem;
  color: var(--guide-accent-dark);
  margin: 0;
}

.guide-toc-close {
  display: none;
  border: none;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--guide-text-muted);
  cursor: pointer;
}

.guide-toc-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.guide-toc-link {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--guide-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background-color 0.2s ease, color 0.2s ease;
  border-left: 2px solid transparent;
}

/* Иерархия оглавления: главы заметнее, подпункты визуально вложены. */
.guide-toc-link.guide-toc-chapter {
  margin-top: 8px;
  padding-left: 10px;
  color: var(--guide-accent);
  font-weight: 700;
}

.guide-toc-link.guide-toc-subchapter {
  padding-left: 24px;
  color: var(--guide-text-muted);
}

.guide-toc-link:hover {
  background-color: var(--guide-surface-alt);
  color: var(--guide-accent);
}

.guide-toc-link.active {
  background-color: rgba(26, 91, 168, 0.1);
  color: var(--guide-accent);
  border-left-color: var(--guide-accent);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   ОБЛОЖКА
   -------------------------------------------------------------------------- */
.guide-cover {
  text-align: center;
  padding: 60px 32px;
  background: linear-gradient(135deg, #0a1f3d 0%, #1a5ba8 50%, #7c3aed 100%);
  border-radius: 16px;
  color: #ffffff;
  margin-bottom: 40px;
  position: relative;
  overflow: hidden;
  animation: guide-cover-in 0.8s ease-out;
}

.guide-cover::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.12), transparent 50%),
              radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.08), transparent 50%);
  pointer-events: none;
}

.guide-cover-badge {
  display: inline-block;
  background-color: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.guide-cover-title {
  font-size: 3rem;
  color: #ffffff;
  margin-bottom: 12px;
  line-height: 1.15;
}

.guide-cover-title-en {
  display: block;
  font-size: 1.8rem;
  font-weight: 400;
  opacity: 0.85;
}

.guide-cover-subtitle {
  font-size: 1.15rem;
  color: rgba(255, 255, 255, 0.9);
  max-width: 640px;
  margin: 0 auto 32px;
}

.guide-cover-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.guide-cover-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.guide-cover-stat-num {
  font-size: 2.2rem;
  font-weight: 700;
}

.guide-cover-stat-label {
  font-size: 0.85rem;
  opacity: 0.8;
}

.guide-cover-source {
  font-size: 0.85rem;
  opacity: 0.7;
}

@keyframes guide-cover-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   СЕКЦИИ
   -------------------------------------------------------------------------- */
.guide-section {
  background-color: var(--guide-surface);
  border: 1px solid var(--guide-border);
  border-radius: 12px;
  padding: 32px;
  margin-bottom: 32px;
  box-shadow: var(--guide-shadow);
  scroll-margin-top: 140px;
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}

.guide-h2 {
  font-size: 1.8rem;
  color: var(--guide-accent-dark);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--guide-border);
}

.guide-chapter-title {
  color: var(--guide-accent);
}

.guide-h3 {
  font-size: 1.3rem;
  color: var(--guide-accent-dark);
  margin: 28px 0 12px;
}

.guide-h4 {
  font-size: 1.1rem;
  color: var(--guide-text);
  margin: 20px 0 10px;
}

.guide-section p {
  color: var(--guide-text);
  margin-bottom: 14px;
  line-height: 1.75;
}

.guide-section strong {
  color: var(--guide-accent-dark);
}

.guide-phase-pill {
  display: inline-block;
  background-color: rgba(26, 91, 168, 0.1);
  color: var(--guide-accent);
  border: 1px solid rgba(26, 91, 168, 0.3);
  padding: 6px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* --------------------------------------------------------------------------
   СПИСКИ
   -------------------------------------------------------------------------- */
.guide-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.guide-list li {
  position: relative;
  padding-left: 24px;
  margin-bottom: 8px;
  color: var(--guide-text);
  line-height: 1.7;
}

.guide-list li::before {
  content: '•';
  position: absolute;
  left: 4px;
  color: var(--guide-accent);
  font-weight: 700;
}

.guide-ordered-list {
  list-style: none;
  counter-reset: guide-counter;
  padding: 0;
  margin: 0 0 16px;
}

.guide-ordered-list li {
  counter-increment: guide-counter;
  position: relative;
  padding-left: 36px;
  margin-bottom: 10px;
  color: var(--guide-text);
  line-height: 1.7;
}

.guide-ordered-list li::before {
  content: counter(guide-counter);
  position: absolute;
  left: 0;
  top: 2px;
  width: 24px;
  height: 24px;
  background-color: var(--guide-accent);
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   ОПРЕДЕЛЕНИЯ ТЕРМИНОВ
   -------------------------------------------------------------------------- */
.guide-def {
  background-color: var(--guide-surface-alt);
  border-left: 4px solid var(--guide-purple);
  border-radius: 8px;
  padding: 16px 20px;
  margin: 16px 0;
}

.guide-def-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--guide-purple);
  font-weight: 700;
  margin-bottom: 6px;
}

.guide-def-title {
  font-weight: 700;
  color: var(--guide-accent-dark);
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.guide-def p {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   ВЫДЕЛЕННЫЕ БЛОКИ (CALL-OUT)
   -------------------------------------------------------------------------- */
.guide-callout {
  border-radius: 8px;
  padding: 16px 20px;
  margin: 16px 0;
  border-left: 4px solid;
}

.guide-callout-title {
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 1rem;
}

.guide-callout p {
  margin-bottom: 0;
}

.guide-callout-blue {
  background-color: rgba(26, 91, 168, 0.08);
  border-left-color: var(--guide-blue);
}

.guide-callout-blue .guide-callout-title {
  color: var(--guide-blue);
}

.guide-callout-amber {
  background-color: rgba(217, 119, 6, 0.08);
  border-left-color: var(--guide-amber);
}

.guide-callout-amber .guide-callout-title {
  color: var(--guide-amber);
}

.guide-callout-teal {
  background-color: rgba(13, 148, 136, 0.08);
  border-left-color: var(--guide-teal);
}

.guide-callout-teal .guide-callout-title {
  color: var(--guide-teal);
}

.guide-callout-red {
  background-color: rgba(220, 38, 38, 0.08);
  border-left-color: var(--guide-red);
}

.guide-callout-red .guide-callout-title {
  color: var(--guide-red);
}

/* --------------------------------------------------------------------------
   УПРАЖНЕНИЯ
   -------------------------------------------------------------------------- */
.guide-exercise {
  background-color: rgba(22, 163, 74, 0.07);
  border: 1px solid rgba(22, 163, 74, 0.25);
  border-radius: 10px;
  padding: 20px;
  margin: 20px 0;
}

.guide-exercise-label {
  font-weight: 700;
  color: var(--guide-green);
  font-size: 1.05rem;
  margin-bottom: 12px;
}

/* --------------------------------------------------------------------------
   РЕЗЮМЕ
   -------------------------------------------------------------------------- */
.guide-summary {
  background-color: rgba(13, 148, 136, 0.08);
  border: 1px solid rgba(13, 148, 136, 0.25);
  border-radius: 10px;
  padding: 20px;
  margin: 20px 0 0;
}

.guide-summary-label {
  font-weight: 700;
  color: var(--guide-teal);
  font-size: 1.05rem;
  margin-bottom: 12px;
}

.guide-summary p {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   КОД
   -------------------------------------------------------------------------- */
.guide-section code {
  background-color: var(--guide-surface-alt);
  color: var(--guide-accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
}

.guide-code {
  background-color: var(--guide-code-bg);
  color: var(--guide-code-text);
  padding: 20px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 16px 0;
  font-size: 0.9rem;
  line-height: 1.6;
  max-width: 100%;
}

.guide-code code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
}

/* --------------------------------------------------------------------------
   ТАБЛИЦЫ
   -------------------------------------------------------------------------- */
.guide-table-wrap {
  overflow-x: auto;
  margin: 16px 0;
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.guide-table th {
  background-color: var(--guide-accent-dark);
  color: #ffffff;
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
}

.guide-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--guide-border);
  color: var(--guide-text);
  vertical-align: top;
}

.guide-table tbody tr {
  transition: background-color 0.2s ease;
}

.guide-table tbody tr:hover {
  background-color: var(--guide-surface-alt);
}

.guide-table tbody tr:last-child td {
  border-bottom: none;
}

/* Цветные точки в таблице типов блоков */
.guide-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
}

.guide-dot-blue { background-color: var(--guide-blue); }
.guide-dot-purple { background-color: var(--guide-purple); }
.guide-dot-amber { background-color: var(--guide-amber); }
.guide-dot-teal { background-color: var(--guide-teal); }
.guide-dot-green { background-color: var(--guide-green); }

/* --------------------------------------------------------------------------
   ФАЗЫ (ДОРОЖНАЯ КАРТА)
   -------------------------------------------------------------------------- */
.guide-phases {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.guide-phase {
  background: linear-gradient(135deg, var(--guide-accent) 0%, var(--guide-purple) 100%);
  color: #ffffff;
  padding: 16px;
  border-radius: 10px;
  text-align: center;
  font-size: 0.9rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.guide-phase:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(26, 91, 168, 0.3);
}

.guide-phase strong {
  color: #ffffff;
  font-size: 1.05rem;
}

/* --------------------------------------------------------------------------
   ДИАГРАММЫ
   -------------------------------------------------------------------------- */
.guide-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 20px 0;
  padding: 20px;
  background-color: var(--guide-surface-alt);
  border-radius: 10px;
}

.guide-diagram-step {
  background-color: var(--guide-surface);
  border: 1px solid var(--guide-border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--guide-accent-dark);
  text-align: center;
}

.guide-diagram-arrow {
  font-size: 1.3rem;
  color: var(--guide-accent);
  font-weight: 700;
}

.guide-diagram-vertical {
  flex-direction: column;
  align-items: stretch;
  text-align: center;
}

.guide-diagram-vertical .guide-diagram-step {
  width: 100%;
}

/* --------------------------------------------------------------------------
   ГЛОССАРИЙ
   -------------------------------------------------------------------------- */
.guide-glossary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.guide-glossary-item {
  background-color: var(--guide-surface-alt);
  border: 1px solid var(--guide-border);
  border-radius: 10px;
  padding: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.guide-glossary-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--guide-shadow);
}

.guide-glossary-item .guide-h4 {
  margin: 0 0 4px;
  color: var(--guide-accent);
}

.guide-glossary-en {
  font-size: 0.8rem;
  color: var(--guide-text-muted);
  font-style: italic;
  margin-bottom: 8px;
}

.guide-glossary-item p:last-child {
  margin-bottom: 0;
  font-size: 0.92rem;
}

/* --------------------------------------------------------------------------
   РЕСУРСЫ
   -------------------------------------------------------------------------- */
.guide-resources li {
  margin-bottom: 12px;
}

/* --------------------------------------------------------------------------
   ПОДВАЛ СТАТЬИ
   -------------------------------------------------------------------------- */
.guide-footer-note {
  margin-top: 24px;
  padding: 20px;
  background-color: var(--guide-surface-alt);
  border-radius: 10px;
  text-align: center;
}

.guide-footer-links {
  font-size: 0.9rem;
}

.guide-footer-links a {
  color: var(--guide-accent);
}

/* --------------------------------------------------------------------------
   ПОДСВЕТКА РЕЗУЛЬТАТОВ ПОИСКА
   -------------------------------------------------------------------------- */
.guide-search-highlight {
  background-color: var(--guide-highlight);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.guide-search-highlight.current {
  background-color: var(--guide-highlight-current);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   АНИМАЦИИ ПОЯВЛЕНИЯ СЕКЦИЙ
   -------------------------------------------------------------------------- */
.guide-section {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.guide-section.guide-visible {
  opacity: 1;
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   АДАПТИВНОСТЬ
   -------------------------------------------------------------------------- */

/* Планшеты и ноутбуки (до 1200px) — компактный тулбар */
@media (max-width: 1200px) {
  .guide-toolbar-inner {
    gap: 10px;
  }

  .guide-search {
    min-width: 200px;
  }
}

/* Планшеты (до 900px) — колонка основного контента */
@media (max-width: 900px) {
  .guide-layout {
    flex-direction: column;
    padding: 24px 16px;
  }

  .guide-toc {
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: none;
    z-index: 1200;
    border-radius: 0;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.3s ease, visibility 0.3s ease;
  }

  .guide-toc.guide-toc-open {
    transform: translateX(0);
    visibility: visible;
  }

  .guide-toc-close {
    display: block;
  }

  .guide-cover-title {
    font-size: 2rem;
  }

  .guide-cover-title-en {
    font-size: 1.3rem;
  }

  .guide-section {
    padding: 20px;
  }

  .guide-toolbar {
    top: var(--guide-header-height, 72px);
  }

  /* Тулбар: поиск на всю ширину, кнопки в отдельной строке */
  .guide-toolbar-inner {
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 8px;
  }

  .guide-search {
    display: none;
    flex: 1 1 100%;
    max-width: 100%;
    min-width: 0;
    order: 1;
  }

  .guide-search.is-visible {
    display: flex;
  }

  .guide-btn.guide-search-toggle {
    display: flex;
  }

  .guide-toolbar-actions {
    flex: 1 1 100%;
    justify-content: space-between;
    order: 2;
    gap: 6px;
  }

  .guide-btn {
    flex: 1;
    justify-content: center;
    padding: 8px 10px;
  }
}

/* Мобильные устройства (до 768px) */
@media (max-width: 768px) {
  .guide-section {
    padding: 18px 14px;
    margin-bottom: 20px;
  }

  .guide-h2 {
    font-size: 1.5rem;
    margin-bottom: 14px;
  }

  .guide-h3 {
    font-size: 1.2rem;
    margin: 22px 0 10px;
  }

  .guide-h4 {
    font-size: 1.05rem;
  }

  .guide-layout {
    padding: 16px 12px;
    gap: 20px;
  }

  .guide-def,
  .guide-callout {
    padding: 14px 16px;
    margin: 14px 0;
  }

  .guide-exercise,
  .guide-summary {
    padding: 16px;
    margin: 16px 0;
  }

  .guide-code {
    padding: 14px;
    font-size: 0.82rem;
  }

  /* Таблицы: минимальная ширина для корректной прокрутки */
  .guide-table {
    min-width: 560px;
  }

  .guide-table-wrap {
    margin: 14px -4px;
    padding-right: 4px;
  }

  .guide-table th,
  .guide-table td {
    padding: 10px 12px;
  }

  .guide-phases {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 16px 0;
  }

  .guide-phase {
    padding: 14px 10px;
  }

  .guide-glossary {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .guide-glossary-item {
    padding: 14px;
  }

  .guide-diagram {
    padding: 16px;
    gap: 8px;
  }

  .guide-diagram-arrow {
    font-size: 1.1rem;
  }

  .guide-ordered-list li {
    padding-left: 32px;
  }

  .guide-cover {
    padding: 36px 16px;
    margin-bottom: 24px;
  }

  .guide-cover-title {
    font-size: 1.8rem;
  }

  .guide-cover-title-en {
    font-size: 1.2rem;
  }

  .guide-cover-subtitle {
    font-size: 1rem;
    margin-bottom: 24px;
  }

  .guide-cover-stats {
    gap: 20px;
    margin-bottom: 20px;
  }

  .guide-cover-stat-num {
    font-size: 1.8rem;
  }

  .guide-cover-badge {
    font-size: 0.75rem;
    padding: 5px 12px;
  }

  .guide-footer-note {
    padding: 16px;
  }
}

/* Малые мобильные (до 480px) */
@media (max-width: 480px) {
  .guide-toolbar {
    top: 64px;
  }

  .guide-layout {
    padding: 12px 10px;
  }

  .guide-section {
    padding: 16px 12px;
    border-radius: 10px;
  }

  .guide-h2 {
    font-size: 1.35rem;
    padding-bottom: 10px;
  }

  .guide-h3 {
    font-size: 1.1rem;
  }

  .guide-cover {
    padding: 32px 12px;
    border-radius: 12px;
  }

  .guide-cover-title {
    font-size: 1.6rem;
  }

  .guide-cover-title-en {
    font-size: 1.05rem;
  }

  .guide-cover-stats {
    gap: 14px;
  }

  .guide-cover-stat-num {
    font-size: 1.5rem;
  }

  .guide-cover-stat-label {
    font-size: 0.75rem;
  }

  .guide-btn-label {
    display: none;
  }

  .guide-btn {
    padding: 8px;
  }

  .guide-toolbar-inner {
    padding: 8px;
  }

  .guide-search {
    padding: 6px 10px;
  }

  .guide-search-input {
    font-size: 0.85rem;
  }

  .guide-search-count {
    display: none;
  }

  .guide-def,
  .guide-callout {
    padding: 12px 14px;
  }

  .guide-exercise,
  .guide-summary {
    padding: 14px;
  }

  .guide-code {
    padding: 12px;
    font-size: 0.78rem;
  }

  .guide-phase {
    padding: 12px 8px;
    font-size: 0.8rem;
  }

  .guide-phase strong {
    font-size: 0.95rem;
  }

  .guide-table th,
  .guide-table td {
    padding: 8px 10px;
    font-size: 0.85rem;
  }

  .guide-ordered-list li {
    padding-left: 30px;
  }

  .guide-list li {
    padding-left: 20px;
  }

  .guide-diagram {
    padding: 14px;
  }

  .guide-diagram-step {
    padding: 10px 12px;
    font-size: 0.82rem;
  }

  .guide-toc {
    padding: 16px;
  }

  .guide-toc-link {
    padding: 8px 10px;
    font-size: 0.85rem;
  }

  .guide-phase-pill {
    font-size: 0.8rem;
    padding: 5px 12px;
  }

  .guide-summary-label,
  .guide-exercise-label {
    font-size: 0.95rem;
  }
}

/* Очень узкие экраны (до 360px) */
@media (max-width: 360px) {
  .guide-section {
    padding: 14px 10px;
  }

  .guide-layout {
    padding: 10px 8px;
  }

  .guide-h2 {
    font-size: 1.25rem;
  }

  .guide-h3 {
    font-size: 1.05rem;
  }

  .guide-cover {
    padding: 28px 10px;
  }

  .guide-cover-title {
    font-size: 1.45rem;
  }

  .guide-cover-subtitle {
    font-size: 0.92rem;
  }

  .guide-cover-stats {
    gap: 12px;
  }

  .guide-cover-stat-num {
    font-size: 1.35rem;
  }

  .guide-def,
  .guide-callout {
    padding: 11px 12px;
  }

  .guide-exercise,
  .guide-summary {
    padding: 12px;
  }

  .guide-phases {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .guide-phase {
    padding: 10px 6px;
  }

  .guide-code {
    padding: 10px;
    font-size: 0.75rem;
  }

  .guide-table th,
  .guide-table td {
    padding: 7px 8px;
    font-size: 0.8rem;
  }

  .guide-btn {
    padding: 7px;
  }

  .guide-btn-icon {
    width: 15px;
    height: 15px;
  }
}
