/* Базовые стили для статей. Tailwind через CDN, доп. правила здесь. */

.kb-article {
  font-size: 15px;
  line-height: 1.7;
  color: #1f2937;
}

.kb-article h1, .kb-article h2, .kb-article h3 {
  color: #fba026;
  font-weight: 600;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

.kb-article h1 { font-size: 1.6em; }
.kb-article h2 { font-size: 1.3em; }
.kb-article h3 { font-size: 1.1em; }

.kb-article p { margin: 0.6em 0; }

.kb-article a {
  color: #2563eb;
  text-decoration: underline;
}
.kb-article a:hover { color: #1d4ed8; }
/* Кросс-ссылка на другую статью БЗ (вики-стиль, открывается в новой вкладке) */
.kb-article a.kb-xref {
  color: #b45309;
  text-decoration: none;
  border-bottom: 1px dotted #d6a55a;
}
.kb-article a.kb-xref:hover { color: #92400e; border-bottom-style: solid; }

.kb-article ul, .kb-article ol {
  margin: 0.6em 0 0.6em 1.4em;
  padding-left: 0.5em;
}
.kb-article ul { list-style: disc; }
.kb-article ol { list-style: decimal; }
.kb-article li { margin: 0.2em 0; }

.kb-article table {
  border-collapse: collapse;
  margin: 1em 0;
  width: 100%;
}
.kb-article th, .kb-article td {
  border: 1px solid #e5e7eb;
  padding: 0.5em 0.75em;
  text-align: left;
  font-size: 0.95em;
}
.kb-article th { background: #f9fafb; font-weight: 600; }

.kb-article code {
  background: #f3f4f6;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.9em;
}

.kb-article pre {
  background: #1f2937;
  color: #f3f4f6;
  padding: 1em;
  border-radius: 6px;
  overflow-x: auto;
}
.kb-article pre code { background: transparent; padding: 0; color: inherit; }

.kb-article img {
  max-width: 100%;
  max-height: 480px;
  width: auto;
  height: auto;
  display: block;
  border-radius: 6px;
  margin: 0.75em 0;
  border: 1px solid #f0ede8;
  cursor: zoom-in;
}
.kb-article img:hover { border-color: #fba026; }

/* Размеры картинок: ![alt](url "sm|md|lg") */
.kb-article img.kb-img-sm { max-height: 140px; width: auto; }
.kb-article img.kb-img-md { max-height: 280px; width: auto; }
.kb-article img.kb-img-lg { max-height: none; }

/* --- Лайтбокс --- */
.kb-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.kb-lightbox.open { display: flex; }
.kb-lightbox-fig {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  max-width: 92vw;
  max-height: 92vh;
}
.kb-lightbox img {
  max-width: 90vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 8px;
  cursor: default;
  border: none;
}
.kb-lightbox-cap {
  color: #e7e5e4;
  font-size: 0.9rem;
  line-height: 1.4;
  text-align: center;
  max-width: 80vw;
}
.kb-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: none;
  width: 52px;
  height: 72px;
  font-size: 2.4rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}
.kb-lightbox-nav:hover { background: rgba(255, 255, 255, 0.25); }
.kb-lightbox-prev { left: 1.2rem; }
.kb-lightbox-next { right: 1.2rem; }
.kb-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  color: rgba(255, 255, 255, 0.7);
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0.2em 0.4em;
}
.kb-lightbox-close:hover { color: #fff; }

.kb-video {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  margin: 1em 0;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
}
.kb-video iframe,
.kb-video video {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}
.kb-video-local video { background: #000; }

.kb-video-link { margin: 1em 0; }
.kb-video-link a {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.5em 1em;
  background: #fba026;
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
}
.kb-video-link a:hover { background: #e8901c; }

/* FTS-сниппет: подсветка совпадений */
.kb-snippet b { color: #fba026; }

/* ====== Блоки оформления статей ====== */

/* --- Акцентные врезки (callout) --- */
.kb-callout {
  border-radius: 10px;
  padding: 12px 16px;
  margin: 1.1em 0;
  border: 1px solid transparent;
}
.kb-callout-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.kb-callout-body > :first-child { margin-top: 0; }
.kb-callout-body > :last-child { margin-bottom: 0; }
.kb-callout-body { font-size: 0.94em; }

.kb-callout-info    { background: #eff6ff; border-color: #bfdbfe; }
.kb-callout-info    .kb-callout-label { color: #1d4ed8; }
.kb-callout-warning { background: #fff8ee; border-color: #fcd9a0; }
.kb-callout-warning .kb-callout-label { color: #b45309; }
.kb-callout-tip     { background: #f0fdf4; border-color: #bbf7d0; }
.kb-callout-tip     .kb-callout-label { color: #15803d; }
.kb-callout-danger  { background: #fef2f2; border-color: #fecaca; }
.kb-callout-danger  .kb-callout-label { color: #b91c1c; }
.kb-callout-note    { background: #f8fafc; border-color: #e2e8f0; }
.kb-callout-note    .kb-callout-label { color: #475569; }

/* --- Карточки характеристик --- */
.kb-specs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 1.1em 0;
}
.kb-spec {
  background: #f8fafc;
  border: 1px solid #eef2f6;
  border-radius: 9px;
  padding: 11px 13px;
}
.kb-spec-label { font-size: 0.74rem; color: #94a3b8; margin-bottom: 3px; }
.kb-spec-value { font-size: 1rem; font-weight: 600; color: #1e293b; }

/* --- Галерея фото: ряд с фиксированной высотой, ширина по соотношению сторон --- */
.kb-gallery {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  margin: 1.1em 0;
}
.kb-gallery-item {
  display: block;
  flex: 0 0 auto;
  max-width: 100%;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #f0ede8;
  background: #f8fafc;
  line-height: 0;
}
.kb-gallery-item img {
  height: 230px !important;
  width: auto !important;
  max-width: 100% !important;
  max-height: 230px !important;
  object-fit: contain;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  display: block;
  cursor: zoom-in;
}
.kb-gallery-item:hover { border-color: #fba026; }

/* --- Аккордеон (детали) --- */
.kb-accordion {
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  margin: 1.1em 0;
  overflow: hidden;
}
.kb-accordion > summary {
  cursor: pointer;
  padding: 11px 15px;
  font-weight: 600;
  font-size: 0.92em;
  color: #334155;
  background: #f8fafc;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.kb-accordion > summary::-webkit-details-marker { display: none; }
.kb-accordion > summary::before {
  content: "›";
  color: #fba026;
  font-size: 1.2em;
  transition: transform 0.15s ease;
}
.kb-accordion[open] > summary::before { transform: rotate(90deg); }
.kb-accordion > summary:hover { background: #f1f5f9; }
.kb-accordion-body { padding: 4px 15px 12px; }
.kb-accordion-body > :first-child { margin-top: 0.4em; }

/* --- Оглавление (TOC) --- */
.kb-toc {
  background: #fbfaf8;
  border: 1px solid #eef0f2;
  border-left: 3px solid #fba026;
  border-radius: 0 9px 9px 0;
  padding: 12px 16px;
  margin: 0 0 1.4em;
}
.kb-toc-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
  margin-bottom: 6px;
}
.kb-toc ul { list-style: none; margin: 0; padding: 0; }
.kb-toc li { margin: 2px 0; }
.kb-toc-3 { padding-left: 16px; }
.kb-toc a { color: #475569; text-decoration: none; font-size: 0.88em; }
.kb-toc a:hover { color: #b45309; text-decoration: underline; }

/* плавный скролл к якорям + отступ под липкий хедер */
html { scroll-behavior: smooth; }
.kb-article h2[id], .kb-article h3[id] { scroll-margin-top: 80px; }

/* --- Amber Pro: акцент-бар на карточках --- */
.kb-card-accent {
  width: 28px;
  height: 3px;
  background: #fba026;
  border-radius: 2px;
  margin-bottom: 10px;
}

/* --- Amber Pro: акцент-бар на карточках --- */
.kb-card-accent {
  width: 28px;
  height: 3px;
  background: #fba026;
  border-radius: 2px;
  margin-bottom: 10px;
}

/* Баннер заголовка папки/раздела */
.kb-folder-banner {
  background: #fff8ee;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.kb-folder-banner-icon {
  width: 42px;
  height: 42px;
  min-width: 42px;
  background: #fba026;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  line-height: 1;
}
.kb-folder-banner h1 {
  font-size: 1.15rem;
  font-weight: 600;
  color: #1c1917;
  margin: 0;
}
.kb-folder-banner p {
  font-size: 0.78rem;
  color: #a8a29e;
  margin: 2px 0 0;
}

/* --- Amber Pro: сворачиваемое дерево папок (сайдбар) --- */
.kb-tree .kb-node { margin: 1px 0; }

.kb-tree summary.kb-summary {
  list-style: none;
  cursor: default;
  display: flex;
  align-items: center;
  border-radius: 6px;
  user-select: none;
  padding: 1px 2px 1px 0;
}
.kb-tree summary.kb-summary::-webkit-details-marker { display: none; }
.kb-tree summary.kb-summary:hover { background: #f1f5f9; }

/* Стрелка — только раскрыть/свернуть */
.kb-tree .kb-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.1em;
  min-width: 1.1em;
  height: 1.6em;
  color: #94a3b8;
  font-size: 1.05em;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  transition: transform 0.15s ease, color 0.1s;
}
.kb-tree .kb-arrow:hover { color: #475569; background: #e2e8f0; }
.kb-tree details[open] > summary .kb-arrow { transform: rotate(90deg); }

/* Название папки — кликабельная ссылка */
.kb-tree .kb-folder-name {
  display: flex;
  align-items: center;
  gap: 0.38em;
  flex: 1;
  min-width: 0;
  padding: 0.22em 0.4em 0.22em 0.1em;
  border-radius: 5px;
  color: #334155;
  font-weight: 500;
  font-size: 0.85rem;
  text-decoration: none;
}
.kb-tree .kb-folder-name:hover { color: #b45309; }
.kb-tree .kb-folder-name.kb-active { color: #b45309; background: #fff4e0; }
.kb-tree .kb-folder-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Иконка папки — плоская 2D SVG, инлайн */
.kb-tree .kb-folder-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.kb-fi-open { display: none; }
details[open] > summary .kb-fi-closed { display: none; }
details[open] > summary .kb-fi-open { display: inline-block; }
.kb-fi-doc { display: block; flex-shrink: 0; opacity: 0.85; }

/* Вложенный уровень */
.kb-tree .kb-children {
  margin-left: 1.1em;
  padding-left: 0.4em;
  border-left: 1.5px solid #f0d9a8;
}

/* Статьи внутри папки */
.kb-tree .kb-article-item {
  display: flex;
  align-items: center;
  border-radius: 5px;
}
.kb-tree .kb-article-item:hover,
.kb-tree .kb-article-item.kb-active-item { background: #f1f5f9; }
.kb-tree .kb-article-item.kb-active-item { background: #fff4e0; }

.kb-tree .kb-article-link {
  flex: 1;
  min-width: 0;
  padding: 0.18em 0.3em 0.18em 0.25em;
  color: #64748b;
  text-decoration: none;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kb-tree .kb-article-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.kb-tree .kb-article-link:hover { color: #1e293b; }
.kb-tree .kb-article-link.kb-active { color: #b45309; font-weight: 500; }
.kb-tree .kb-article-item.kb-active-item .kb-article-link { color: #b45309; font-weight: 500; }

/* Папка-лист (без детей) */
.kb-tree .kb-leaf-item {
  display: flex;
  align-items: center;
  border-radius: 6px;
}
.kb-tree .kb-leaf-item:hover { background: #f1f5f9; }

.kb-tree .kb-leaf {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.38em;
  padding: 0.22em 0.4em 0.22em 0.2em;
  color: #334155;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.85rem;
}
.kb-tree .kb-leaf:hover { color: #b45309; }
.kb-tree .kb-leaf.kb-active,
.kb-tree .kb-leaf-item:has(.kb-active) .kb-leaf { color: #b45309; background: #fff4e0; }

/* --- Drag & Drop: ручка перетаскивания --- */
.kb-drag-handle {
  flex-shrink: 0;
  width: 0.9em;
  min-width: 0.9em;
  text-align: center;
  cursor: grab;
  color: #94a3b8;
  font-size: 0.9em;
  opacity: 0;
  transition: opacity 0.12s;
  user-select: none;
  padding: 0 1px;
  line-height: 1;
}
.kb-sortable-item:hover > .kb-drag-handle,
summary:hover .kb-drag-handle { opacity: 1; }
.kb-drag-handle:active { cursor: grabbing; }
.kb-drag-ghost { opacity: 0.5; background: #fef3c7; border-radius: 6px; }

/* --- Кнопка-карандашик (переименование) --- */
.kb-edit-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.72em;
  color: #94a3b8;
  opacity: 0;
  transition: opacity 0.12s, color 0.1s, background 0.1s;
  line-height: 1;
  margin-right: 2px;
}
.kb-sortable-item:hover .kb-edit-btn,
summary:hover .kb-edit-btn { opacity: 1; }
.kb-edit-btn:hover { color: #fba026; background: #fff4e0; }

/* --- Поле инпута при переименовании --- */
.kb-rename-input {
  font-size: 0.82rem;
  font-family: inherit;
  border: 1.5px solid #fba026;
  border-radius: 4px;
  padding: 1px 5px;
  outline: none;
  background: #fff;
  color: #1e293b;
  flex: 1;
  min-width: 60px;
  max-width: 100%;
  box-shadow: 0 0 0 2px #fde68a55;
}
