/* Стили страниц kb и kb_editor (KB_TICKETS_DESIGN.md §6.3, §6.4). Общие компоненты — в css/panel.css. */

/* ── Список ── */
.kb-tabs { margin-bottom: 24px; }
.kb-view { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.dtable td.kb-title { max-width: 420px; }
.dtable td.kb-title .cell2__b { overflow-wrap: anywhere; }
.kb-upd { align-items: flex-end; white-space: nowrap; }
.kb-sections .card__head { flex-wrap: wrap; }
.kb-modal { display: flex; flex-direction: column; gap: 16px; }

/* ── Редактор: шапка ── */
.kbe-head .page-head__title { min-width: 0; }
.kbe-head h1 { overflow-wrap: anywhere; }
.kbe-tools { flex-wrap: wrap; justify-content: flex-end; }
.kbe-tools .dirty { margin-right: 8px; }

/* Тело: 1fr + 320, правая колонка липкая. */
.kbe { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; min-width: 0; }
.kbe-main { padding: 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.kbe-side { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.kbe-side-card .card__head { padding: 16px 16px 0; border: 0; min-height: 0; }
.kbe-side-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.kbe-mute { color: var(--color-text-2); }

/* Блок текста: рамка control, радиус 8. */
.kbe-box { border: 1px solid var(--color-border-control); border-radius: var(--radius-xs); overflow: hidden; background: var(--color-surface); min-width: 0; }
.kbe-box:focus-within { border-color: var(--color-accent); }
.kbe-tools-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 48px; padding: 4px 8px; border-bottom: 1px solid var(--color-border); }
.kbe-tools-grp { display: flex; align-items: center; gap: 4px; }
.kbe-tools-grp .ibtn { position: relative; }
.kbe-tools-grp .ibtn::after { content: ""; position: absolute; inset: -6px -2px; }
.kbe-sep { width: 1px; height: 24px; background: var(--color-border); }
.kbe-view { margin-left: auto; }

.kbe-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 452px; height: calc(100vh - 360px); max-height: 900px; }
.kbe-split[data-view="text"], .kbe-split[data-view="preview"] { grid-template-columns: minmax(0, 1fr); }
.kbe-src {
  display: block; width: 100%; min-height: 452px; height: 100%; resize: none; border: 0; margin: 0;
  padding: 16px; font: 400 14px/22px var(--font-mono); color: var(--color-text); background: var(--color-surface);
  overflow-wrap: anywhere;
}
.kbe-src:focus { outline: none; }
.kbe-src:focus-visible { box-shadow: inset 0 0 0 2px var(--color-focus); }
.kbe-src.is-drop { background: var(--color-accent-soft); }
.kbe-split[data-view="split"] .kbe-src { border-right: 1px solid var(--color-border); }
.kbe-pv { background: var(--color-bg); padding: 16px 20px; overflow-y: auto; min-height: 452px; font-size: 16px; line-height: 24px; }
.kbe-split[data-view="preview"] .kbe-pv { display: flex; flex-direction: column; align-items: center; }
.kbe-split[data-view="preview"] .kbe-pv > * { width: 100%; max-width: 420px; }
.kbe-pv__cap { display: flex; align-items: center; gap: 8px; color: var(--color-text-2); font-size: 14px; line-height: 20px; }
.kbe-pv__cap .icon { flex: none; }
.kbe-pv__h1 { font: 700 24px/32px var(--font-display); margin-top: 12px; overflow-wrap: anywhere; }

/* Тело статьи — те же правила, что .md в мини-аппе (§3.5.1). */
.md { margin-top: 12px; max-width: 680px; overflow-wrap: anywhere; }
.md p { margin: 0 0 16px; }
.md h2 { font: 700 20px/26px var(--font-display); margin: 32px 0 12px; }
.md h3 { font: 600 17px/24px var(--font-text); margin: 24px 0 8px; }
.md ul { padding-left: 24px; margin: 0 0 16px; }
.md ul li { margin-bottom: 8px; }
.md ul li::marker { color: var(--color-accent-ink); }
.md ol { list-style: none; padding: 0; margin: 0 0 16px; counter-reset: step; }
.md ol li { counter-increment: step; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; margin-bottom: 12px; }
.md ol li::before {
  content: counter(step); width: 24px; height: 24px; border-radius: 50%;
  background: var(--color-accent-soft); color: var(--color-accent-ink); font: 600 14px/24px var(--font-display); text-align: center;
}
.md strong { font-weight: 600; }
.md code { font: .875em/1 var(--font-mono); background: var(--color-surface-2); border-radius: 4px; padding: 0 4px; }
.md a { color: var(--color-accent-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
/* Ссылка на статью без цели (черновик, удалена, не номер): сотрудник увидит текст. */
.md .md-kb-off { text-decoration: underline wavy var(--color-warn); text-decoration-thickness: 1px; text-underline-offset: 3px; cursor: help; }
.md figure { margin: 24px 0; }
.md img { display: block; width: 100%; height: auto; border-radius: var(--radius-sm); background: var(--color-surface-2); }
.md video { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius-sm); background: #141019; }
.md figcaption { font-size: 14px; line-height: 20px; color: var(--color-text-2); margin-top: 8px; }
.md .md-pending, .md .md-missing {
  display: grid; place-items: center; aspect-ratio: 16 / 9; border-radius: var(--radius-sm);
  font-size: 14px; line-height: 20px; padding: 16px; text-align: center;
}
.md .md-pending { background: var(--color-warn-soft); color: var(--color-warn); }
.md .md-missing { background: var(--color-err-soft); color: var(--color-err); }
.md .md-note { margin: 0 0 16px; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--color-info-soft); color: var(--color-text); }
.md .md-note p { margin: 0; }
.md hr { border: 0; border-top: 1px solid var(--color-border); margin: 24px 0; }
.md .md-table { overflow-x: auto; margin: 0 0 16px; }
.md table { border-collapse: collapse; font-size: 14px; line-height: 20px; }
.md th, .md td { padding: 8px 12px; border: 1px solid var(--color-border); text-align: left; }

/* Кому показывать: списки чекбоксов. */
.kbe-aud { display: flex; flex-direction: column; gap: 4px; }
.kbe-some { display: flex; flex-direction: column; gap: 4px; padding-left: 32px; }
.kbe-checks { display: flex; flex-direction: column; max-height: 264px; overflow-y: auto; padding: 4px; margin: -4px; }
.kbe-check { min-height: 36px; padding: 6px 0; }
.kbe-check-search { margin-bottom: 4px; }

/* Файлы: зона загрузки и список. */
.kbe-drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px; text-align: center;
  border-radius: var(--radius-xs); background: var(--color-surface-2); color: var(--color-text-2); cursor: pointer;
  border: 1px dashed transparent;
}
.kbe-drop b { color: var(--color-accent-ink); }
.kbe-drop:hover { border-color: var(--color-border-control); }
.kbe-drop:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.kbe-files { list-style: none; margin: 0; padding: 0; }
.kbe-file { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 0; }
.kbe-file + .kbe-file { border-top: 1px solid var(--color-border); }
.kbe-file__thumb { display: grid; place-items: center; width: 48px; height: 48px; border-radius: var(--radius-xs); overflow: hidden; background: var(--color-surface-2); color: var(--color-text-2); }
.kbe-file__thumb img { width: 100%; height: 100%; object-fit: cover; }
.kbe-file__text { display: flex; flex-direction: column; min-width: 0; }
.kbe-file__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kbe-file__acts { display: flex; gap: 4px; }
.kbe-file.is-uploading { background: var(--color-warn-soft); border-radius: var(--radius-xs); padding: 8px; }
.kbe-prog { height: 4px; border-radius: var(--radius-pill); background: var(--color-surface-2); margin-top: 6px; overflow: hidden; }
.kbe-prog i { display: block; height: 100%; background: var(--color-accent); transform: scaleX(0); transform-origin: left; transition: transform var(--dur-2) linear; }

/* Ширины (§6.6). */
@media (max-width: 1279px) {
  .kbe-view { margin-left: 0; flex-basis: 100%; }
}
@media (max-width: 1023px) {
  .kbe { grid-template-columns: minmax(0, 1fr); }
  .kbe-side { position: static; }
}
@media (max-width: 767px) {
  .kbe-main { padding: 16px; }
  .kbe-split { height: auto; }
  .kbe-tools { justify-content: flex-start; }
}
@media (forced-colors: active) {
  .kbe-box, .kbe-drop { border: 1px solid CanvasText; }
  .kbe-prog i { background: Highlight; }
}

/* «Ссылка на статью» — выбор статьи в окне */
.kbe-pick { list-style: none; margin: 12px 0 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.kbe-pick li + li { border-top: 1px solid var(--color-border); }
.kbe-pick__row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; min-height: 44px; padding: 8px 4px; text-align: left; background: none; border: 0; cursor: pointer; border-radius: var(--radius-xs, 6px); }
.kbe-pick__row:hover { background: var(--color-surface-2); }
.kbe-pick__t { font-weight: 600; }
