/* ════════════════════════════════════════════════════════════════════
   AIDB · Оболочка приложения
   Правило: здесь нет ни одного захардкоженного цвета - только
   переменные из brand.css (--aidb-*) и токены базовой ДС.
   ════════════════════════════════════════════════════════════════════ */

@import "core/fonts.css";
@import "core/colors.css";
@import "core/typography.css";
@import "core/effects.css";
@import "core/utilities.css";
@import "core/components.css";
@import "brand.css";

/* ── База ───────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--aidb-bg);
  color: var(--aidb-ink);
  font-family: var(--aidb-font);
}

:focus-visible {
  outline: 2px solid var(--aidb-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--aidb-accent-soft); }

/* ── Каркас: сайдбар + контент ─────────────────────────────────────── */

.aidb-app {
  display: flex;
  min-height: 100dvh;
}

.aidb-sidebar {
  position: sticky;
  top: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  width: 300px;
  height: 100dvh;
  padding: 24px 16px 16px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  transition: margin-left 0.25s ease, visibility 0.25s ease;
}

/* Свёрнутый сайдбар (десктоп): состояние хранится на <html>,
   ставит его app.js до первой отрисовки */
@media (min-width: 1024px) {
  html[data-aidb-side="collapsed"] .aidb-sidebar {
    margin-left: -300px;
    visibility: hidden;
  }
}

.aidb-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 0 24px;
}

.aidb-content {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  flex: 1;
}

.aidb-footer {
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 8px 20px;
  font-size: var(--text-caption);
  color: var(--aidb-faint);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.aidb-footer a { color: var(--aidb-muted); }
.aidb-footer a:hover { color: var(--aidb-ink); }

/* Точечный широкий режим для страниц-тренажёров: класс ставится
   на .aidb-content и .aidb-topbar конкретной страницы */
.aidb-content--wide, .aidb-topbar--wide { max-width: none; }

/* ── Шапка сайдбара ────────────────────────────────────────────────── */

.aidb-side-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 20px;
  color: inherit;
  text-decoration: none;
}

.aidb-side-head:hover { color: inherit; }

.aidb-side-head > span:last-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* Марка: оригинальные PNG из Core, светлая и тёмная версии.
   Показывается та, что соответствует теме. */
.aidb-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  user-select: none;
}

.aidb-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.aidb-mark .aidb-mark-dark { display: none; }
[data-theme="dark"] .aidb-mark .aidb-mark-light { display: none; }
[data-theme="dark"] .aidb-mark .aidb-mark-dark { display: block; }

/* Запасной вариант white label: текстовая марка на плашке */
.aidb-mark--text {
  border-radius: 14px;
  background: var(--backgrounds-dark2);
  color: var(--text-light);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.aidb-side-title {
  display: block;
  color: var(--aidb-ink);
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.aidb-side-sub {
  display: block;
  font-size: var(--text-overline);
  line-height: 1.4;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--aidb-faint);
}

/* Бейдж мероприятия (white label): появляется, если в brand.js задан event */
.aidb-event {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 8px 16px;
  padding: 8px 12px;
  border: 1px solid var(--aidb-line);
  border-radius: var(--aidb-radius-menu);
  background: var(--aidb-accent-soft);
  font-size: var(--text-caption);
  color: var(--aidb-ink);
}

.aidb-event img { height: 20px; width: auto; }

/* ── Навигация ─────────────────────────────────────────────────────── */

.aidb-nav { margin-bottom: 20px; }

.aidb-nav-caption {
  padding: 8px 12px 6px;
  font-size: var(--text-overline);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--aidb-faint);
}

.aidb-nav details { margin: 0; }
.aidb-nav summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.aidb-nav summary::-webkit-details-marker { display: none; }

/* Уровень (1-я ступень) */
.aidb-level-row,
.aidb-leaf {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--aidb-radius-menu);
  font-size: var(--text-body-2);
  font-weight: 600;
  color: var(--aidb-muted);
  text-decoration: none;
  transition: color var(--transition-duration), background var(--transition-duration);
}

.aidb-level-row:hover, .aidb-leaf:hover {
  color: var(--aidb-ink);
  background: var(--backgrounds-highlight);
}

.aidb-leaf.active {
  color: var(--aidb-ink);
  background: var(--aidb-pop);
  box-shadow: var(--box-shadow-depth-menu);
}

.aidb-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--aidb-accent);
}

.aidb-count {
  margin-left: auto;
  min-width: 24px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border-radius: var(--aidb-radius-chip);
  background: var(--backgrounds-highlight);
  border: 1px solid var(--aidb-line-soft);
  font-size: var(--text-caption);
  font-weight: 500;
  color: var(--aidb-faint);
}

.aidb-chev {
  margin-left: auto;
  flex-shrink: 0;
  fill: currentColor;
  opacity: 0.6;
  transition: transform var(--transition-duration);
}
.aidb-count + .aidb-chev { margin-left: 4px; }
details[open] > summary .aidb-chev { transform: rotate(180deg); }

/* Статьи (2-я ступень): содержимое раскрывашки уровня или подборки */
.aidb-topics {
  margin: 2px 0 6px;
  padding-left: 13px;
}

.aidb-topic-inner {
  border-left: 1px solid var(--aidb-line-soft);
  padding-left: 8px;
}

.aidb-articles {
  margin: 0;
  padding: 0 0 4px;
  list-style: none;
}

.aidb-articles .aidb-leaf {
  height: 34px;
  padding: 0 10px;
  font-weight: 400;
  font-size: var(--text-body-2);
}

.aidb-soon {
  display: block;
  padding: 4px 10px 8px;
  font-size: var(--text-caption);
  color: var(--aidb-faint);
}

/* ── Подвал сайдбара ───────────────────────────────────────────────── */

.aidb-side-foot {
  margin-top: auto;
  padding: 16px 8px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--aidb-line-soft);
}

.aidb-theme-label {
  font-size: var(--text-caption);
  color: var(--aidb-muted);
  user-select: none;
}

.aidb-side-foot .aidb-home-link {
  margin-left: auto;
  font-size: var(--text-caption);
  color: var(--aidb-faint);
}
.aidb-side-foot .aidb-home-link:hover { color: var(--aidb-ink); }

/* ── Верхняя панель контента ───────────────────────────────────────── */

.aidb-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 0 12px;
  background: linear-gradient(to bottom, var(--aidb-bg) 75%, transparent);
}

.aidb-burger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 1.5px solid var(--aidb-line);
  border-radius: 50%;
  background: none;
  color: var(--aidb-muted);
}
.aidb-burger svg { fill: currentColor; }

.aidb-crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
  font-size: var(--text-caption);
  color: var(--aidb-faint);
}

.aidb-crumbs a { color: var(--aidb-muted); }
.aidb-crumbs a:hover { color: var(--aidb-ink); }
.aidb-crumbs .sep { opacity: 0.5; }
.aidb-crumbs .here { color: var(--aidb-ink); font-weight: 500; }

.aidb-search-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  width: 240px;
  height: 44px;
  padding: 0 14px;
  flex-shrink: 0;
  border: 1.5px solid transparent;
  border-radius: var(--radius-button);
  background: var(--aidb-card);
  box-shadow: var(--aidb-shadow-card);
  font-family: inherit;
  font-size: var(--text-body-2);
  color: var(--aidb-muted);
  transition: border-color var(--transition-duration), color var(--transition-duration);
}

.aidb-search-btn:hover { border-color: var(--stroke-highlight); color: var(--aidb-ink); }
.aidb-search-btn svg { fill: currentColor; flex-shrink: 0; }
.aidb-search-btn .placeholder { overflow: hidden; white-space: nowrap; }

.aidb-kbd {
  margin-left: auto;
  padding: 3px 7px;
  border: 1px solid var(--aidb-line);
  border-radius: 6px;
  background: var(--backgrounds-highlight);
  font-family: var(--aidb-font-mono);
  font-size: 0.6875rem;
  color: var(--aidb-faint);
  white-space: nowrap;
}

/* ── Модалка поиска ────────────────────────────────────────────────── */

.aidb-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: 10dvh 16px 16px;
  background: color-mix(in srgb, var(--shade-04) 60%, transparent);
  backdrop-filter: none;
}

.aidb-search-overlay.open { display: flex; }

.aidb-search-panel {
  width: 100%;
  max-width: 640px;
  max-height: 72dvh;
  display: flex;
  flex-direction: column;
  background: var(--aidb-pop);
  border-radius: var(--aidb-radius-inner);
  box-shadow: var(--aidb-shadow-pop);
  overflow: hidden;
}

.aidb-search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--aidb-line-soft);
}

.aidb-search-box svg { fill: var(--aidb-faint); flex-shrink: 0; }

.aidb-search-box input {
  flex: 1;
  height: 52px;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: -0.015em;
  color: var(--aidb-ink);
  outline: none;
}

.aidb-search-box input::placeholder { color: var(--aidb-faint); }

.aidb-search-results {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
}

.aidb-hit-group {
  padding: 10px 14px 4px;
  font-size: var(--text-overline);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--aidb-faint);
}

.aidb-hit {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--aidb-radius-menu);
  text-decoration: none;
  color: var(--aidb-ink);
}

.aidb-hit .aidb-dot { margin-top: 7px; }

.aidb-hit.selected, .aidb-hit:hover {
  background: var(--backgrounds-highlight);
  color: var(--aidb-ink);
}

.aidb-hit-title { font-size: var(--text-body-2); font-weight: 600; line-height: 1.4; }
.aidb-hit-crumbs { font-size: var(--text-caption); color: var(--aidb-faint); }
.aidb-hit-snippet {
  display: block;
  margin-top: 2px;
  font-size: var(--text-caption);
  line-height: 1.5;
  color: var(--aidb-muted);
}

.aidb-hit mark, .aidb-hit-snippet mark {
  background: var(--aidb-accent-soft);
  color: var(--aidb-accent);
  border-radius: 3px;
  padding: 0 1px;
}

.aidb-search-empty {
  padding: 32px 20px;
  text-align: center;
  font-size: var(--text-body-2);
  color: var(--aidb-muted);
}

.aidb-search-hint {
  display: flex;
  gap: 14px;
  padding: 10px 20px;
  border-top: 1px solid var(--aidb-line-soft);
  font-size: var(--text-caption);
  color: var(--aidb-faint);
}

/* ── Статья ────────────────────────────────────────────────────────── */

.aidb-article {
  padding: clamp(24px, 5vw, 56px);
  border-radius: var(--aidb-radius-card);
  background: var(--aidb-card);
  box-shadow: var(--aidb-shadow-card);
}

[data-theme="dark"] .aidb-article { box-shadow: var(--card-shadow-inset), var(--aidb-shadow-card); }

.aidb-article > * { max-width: 72ch; }

.aidb-article h1 {
  margin: 0 0 8px;
  font-size: clamp(1.75rem, 3.5vw, 2.25rem);
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.aidb-article-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 28px;
  font-size: var(--text-caption);
  color: var(--aidb-faint);
}

.aidb-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--aidb-radius-chip);
  border: 1px solid var(--aidb-line);
  background: var(--backgrounds-highlight);
  font-size: var(--text-caption);
  font-weight: 500;
  color: var(--aidb-muted);
  text-decoration: none;
}

.aidb-chip .aidb-dot { width: 7px; height: 7px; }

.aidb-article h2 {
  margin: 44px 0 12px;
  font-size: 1.5rem;
  line-height: 1.35;
  letter-spacing: -0.015em;
  font-weight: 600;
}

.aidb-article h3 {
  margin: 32px 0 10px;
  font-size: 1.1875rem;
  line-height: 1.4;
  font-weight: 600;
}

.aidb-article p, .aidb-article li {
  font-size: 1rem;
  line-height: 1.7;
  letter-spacing: -0.011em;
}

.aidb-article p { margin: 0 0 16px; }

.aidb-article .lead {
  font-size: 1.125rem;
  line-height: 1.65;
  color: var(--aidb-muted);
  margin-bottom: 24px;
}

.aidb-article ul, .aidb-article ol { margin: 0 0 16px; padding-left: 24px; }
.aidb-article li { margin-bottom: 6px; }
.aidb-article li::marker { color: var(--aidb-faint); }

.aidb-article a { color: var(--aidb-accent); }
.aidb-article a:hover { opacity: 0.85; }

.aidb-article strong { font-weight: 600; }

.aidb-article hr {
  margin: 36px 0;
  border: 0;
  border-top: 1px solid var(--aidb-line-soft);
}

.aidb-article blockquote {
  margin: 24px 0;
  padding: 4px 0 4px 20px;
  border-left: 3px solid var(--aidb-accent);
  color: var(--aidb-muted);
  font-weight: 500;
}
.aidb-article blockquote p:last-child { margin-bottom: 0; }

.aidb-article img {
  max-width: 100%;
  border-radius: var(--aidb-radius-inner);
}

/* Код */
.aidb-article code {
  font-family: var(--aidb-font-mono);
  font-size: 0.875em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--aidb-well);
  border: 1px solid var(--aidb-line-soft);
}

.aidb-article pre {
  margin: 20px 0;
  padding: 20px 24px;
  border-radius: var(--aidb-radius-inner);
  background: var(--aidb-code-bg);
  color: var(--aidb-code-ink);
  overflow-x: auto;
}

.aidb-article pre code {
  padding: 0;
  border: 0;
  background: none;
  font-size: 0.8125rem;
  line-height: 1.6;
}

/* Таблицы */
.aidb-article .table-wrap { overflow-x: auto; margin: 20px 0; }

.aidb-article table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-body-2);
}

.aidb-article th {
  padding: 10px 16px 10px 0;
  text-align: left;
  font-size: var(--text-caption);
  font-weight: 500;
  color: var(--aidb-faint);
}

.aidb-article td {
  padding: 12px 16px 12px 0;
  border-top: 1px solid var(--aidb-line-soft);
  vertical-align: top;
}

/* Callout-блоки */
.callout {
  margin: 24px 0;
  padding: 18px 22px;
  border-radius: var(--aidb-radius-inner);
  background: var(--aidb-callout-info);
  color: var(--aidb-callout-ink);
}

.callout p, .callout li { color: inherit; }
.callout p:last-child { margin-bottom: 0; }
.callout .callout-title {
  display: block;
  margin-bottom: 6px;
  font-size: var(--text-sub-title-2);
  font-weight: 700;
}
.callout a { color: inherit; text-decoration: underline; }
.callout code { background: color-mix(in srgb, var(--aidb-callout-ink) 8%, transparent); border-color: transparent; }

.callout--tip { background: var(--aidb-callout-tip); }
.callout--warn { background: var(--aidb-callout-warn); }
.callout--danger { background: var(--aidb-callout-danger); }

/* Раскрывающийся блок «слоями»: тезис снаружи, детали внутри */
.aidb-details {
  margin: 20px 0;
  border: 1px solid var(--aidb-line-soft);
  border-radius: var(--aidb-radius-inner);
  background: var(--aidb-well);
}

.aidb-details summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 22px;
  cursor: pointer;
  user-select: none;
  font-size: var(--text-body-2);
  font-weight: 600;
  color: var(--aidb-muted);
  transition: color var(--transition-duration);
}
.aidb-details summary::-webkit-details-marker { display: none; }
.aidb-details summary:hover { color: var(--aidb-ink); }
.aidb-details summary .aidb-chev { margin-left: auto; }
.aidb-details[open] summary { color: var(--aidb-ink); }
.aidb-details .aidb-details-body { padding: 0 22px 18px; }

/* ── Статус статьи: Проверено (зелёный) / In progress (жёлтый) ─────── */
/* Источник статуса - поле status у статьи в nav.js; оболочка рисует
   чип в топбаре и списках разделов, мини-точку - в сайдбаре. */

.aidb-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  border: 1px solid var(--aidb-line-soft);
  font-size: var(--text-caption);
  font-weight: 600;
  color: var(--aidb-ink);
  white-space: nowrap;
}

.aidb-status .aidb-dot { width: 7px; height: 7px; }
.aidb-status--verified { background: color-mix(in srgb, var(--label-green) 10%, transparent); border-color: color-mix(in srgb, var(--label-green) 35%, transparent); }
.aidb-status--verified .aidb-dot { background: var(--label-green); }
.aidb-status--wip { background: color-mix(in srgb, var(--label-yellow) 12%, transparent); border-color: color-mix(in srgb, var(--label-yellow) 40%, transparent); }
.aidb-status--wip .aidb-dot { background: var(--label-yellow); }

/* В списках статей на страницах уровней чип прижат вправо и компактнее */
.aidb-topic-block li a .aidb-status { margin-left: auto; padding: 3px 10px; }

/* Мини-точка в сайдбаре */
.aidb-leaf .aidb-leaf-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aidb-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: auto;
}

/* ── Промпт-карта: Ctrl+C → Ctrl+V → в агента ──────────────────────── */
/* Разметка: <figure class="aidb-prompt"><figcaption class="aidb-prompt-head">
   <span class="aidb-prompt-label">Промпт</span>
   <button class="aidb-prompt-copy">Скопировать</button></figcaption>
   <pre>текст промпта</pre></figure>
   Кнопку оживляет app.js (делегированный обработчик). */

.aidb-prompt {
  margin: 20px 0;
  border-radius: var(--aidb-radius-inner);
  background: var(--aidb-code-bg);
  overflow: hidden;
}

.aidb-prompt-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 16px 0;
}

.aidb-prompt-label {
  font-family: var(--aidb-font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: color-mix(in srgb, var(--aidb-code-ink) 60%, transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aidb-prompt-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 5px 14px;
  flex-shrink: 0;
  border: 1px solid color-mix(in srgb, var(--aidb-code-ink) 30%, transparent);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--aidb-code-ink);
  font-family: inherit;
  font-size: var(--text-caption);
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition-duration), color var(--transition-duration);
}

.aidb-prompt-copy:hover { border-color: var(--aidb-code-ink); }
.aidb-prompt-copy.done { border-color: var(--label-green); color: var(--label-green); }

.aidb-prompt pre {
  margin: 0;
  padding: 12px 16px 16px;
  background: none;
  border: 0;
  color: var(--aidb-code-ink);
  font-family: var(--aidb-font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* ── Пейджер подборки: «← Назад · Дальше →» ────────────────────────── */
/* Рисует app.js внизу каждой страницы, входящей в подборку (secondary
   с articles) - порядок задаёт nav.js, руками ничего не синхронизируем. */

.aidb-pager {
  display: flex;
  gap: 12px;
  margin: 20px 0 8px;
}

.aidb-pager a {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 48%;
  min-width: 0;
  padding: 12px 18px;
  border-radius: var(--aidb-radius-card);
  background: var(--aidb-card);
  box-shadow: var(--aidb-shadow-card);
  border: 1.5px solid transparent;
  color: var(--aidb-ink);
  text-decoration: none;
  transition: border-color var(--transition-duration);
}

[data-theme="dark"] .aidb-pager a { box-shadow: var(--card-shadow-inset), var(--aidb-shadow-card); }
.aidb-pager a:hover { border-color: var(--stroke-highlight); color: var(--aidb-ink); }

.aidb-pager a.next {
  margin-left: auto;
  align-items: flex-end;
  text-align: right;
}

.aidb-pager .dir { font-size: var(--text-caption); color: var(--aidb-faint); }

.aidb-pager .name {
  font-size: var(--text-body-2);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ── Карточки разделов (главная и страницы уровней) ────────────────── */

.aidb-hero { padding: 24px 8px 28px; }

.aidb-hero h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 4.5vw, 3rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 500;
}

.aidb-hero p {
  margin: 0;
  max-width: 62ch;
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--aidb-muted);
}

.aidb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.aidb-card-link {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  border-radius: var(--aidb-radius-card);
  background: var(--aidb-card);
  box-shadow: var(--aidb-shadow-card);
  text-decoration: none;
  color: var(--aidb-ink);
  border: 1.5px solid transparent;
  transition: border-color var(--transition-duration);
}

[data-theme="dark"] .aidb-card-link { box-shadow: var(--card-shadow-inset), var(--aidb-shadow-card); }
.aidb-card-link:hover { border-color: var(--stroke-highlight); color: var(--aidb-ink); }

.aidb-card-link .head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-h6);
  font-weight: 600;
}

.aidb-card-link .head .aidb-dot { width: 10px; height: 10px; }

.aidb-card-link .desc {
  font-size: var(--text-body-2);
  line-height: 1.55;
  color: var(--aidb-muted);
}

.aidb-card-link .meta {
  margin-top: auto;
  font-size: var(--text-caption);
  color: var(--aidb-faint);
}

.aidb-section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 28px 8px 14px;
}

.aidb-section-head h2 {
  margin: 0;
  font-size: var(--text-h6);
  font-weight: 600;
}

.aidb-section-head .note { font-size: var(--text-caption); color: var(--aidb-faint); }

/* Карточка со списком статей на страницах уровней и подборок */
.aidb-topic-block {
  margin-bottom: 12px;
  padding: 20px 24px;
  border-radius: var(--aidb-radius-card);
  background: var(--aidb-card);
  box-shadow: var(--aidb-shadow-card);
}

[data-theme="dark"] .aidb-topic-block { box-shadow: var(--card-shadow-inset), var(--aidb-shadow-card); }

.aidb-topic-block h3 { margin: 0 0 6px; font-size: 1.0625rem; font-weight: 600; }

.aidb-topic-block ul { margin: 0; padding: 0; list-style: none; }

.aidb-topic-block li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  margin: 0 -10px;
  border-radius: var(--aidb-radius-chip);
  font-size: var(--text-body-2);
  color: var(--aidb-muted);
}

.aidb-topic-block li a:hover { color: var(--aidb-ink); background: var(--backgrounds-highlight); }

.aidb-topic-block .aidb-soon { padding: 4px 0; }

/* ── Мобильная версия ──────────────────────────────────────────────── */

.aidb-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  background: color-mix(in srgb, var(--shade-04) 50%, transparent);
}

@media (max-width: 1023px) {
  .aidb-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    width: min(320px, 86vw);
    background: var(--aidb-bg);
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: var(--aidb-shadow-pop);
  }
  .aidb-sidebar.open { transform: translateX(0); }
  .aidb-scrim.open { display: block; }
  .aidb-main { padding: 0 16px; }
  .aidb-search-btn { width: 44px; padding: 0; justify-content: center; border-radius: 50%; }
  .aidb-search-btn .placeholder, .aidb-search-btn .aidb-kbd { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}

/* ── Печать (для «подложить PDF») ──────────────────────────────────── */

@media print {
  .aidb-sidebar, .aidb-topbar, .aidb-footer, .aidb-scrim, .aidb-search-overlay, .aidb-pager, .aidb-prompt-copy { display: none !important; }
  .aidb-app { display: block; }
  .aidb-main { padding: 0; }
  body { background: #fff; }
  .aidb-article { box-shadow: none; border-radius: 0; padding: 0; }
  .aidb-details { page-break-inside: avoid; }
  .aidb-details[open] summary .aidb-chev { display: none; }
}
