/* v2-knowledge.css — «Что знает бот» (docs/47 W3, макет docs/design-v2/workspace47/Knowledge.dc.html).
   Только токены дизайна v2 (tokens.css). Коралл — одна главная кнопка «Опубликовать изменения».
   Телефон: одна колонка, как MobileList/MobileClient (назад 40×40, заголовок 28, карточки-списки);
   десктоп ≥ 900: разделы слева, «Как бот ответит» + покрытие справа. */

.bk { display: flex; flex-direction: column; gap: var(--space-5); padding-top: var(--space-2); min-width: 0; }
.bk *, .bk *::before, .bk *::after { box-sizing: border-box; }
.bk-muted { margin: 0; font-size: var(--text-footnote); line-height: var(--leading-snug); color: var(--text-muted); }

/* ── шапка ── */
.bk-head { display: flex; flex-direction: column; gap: var(--space-3); }
.bk-crumbs { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.bk-back {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 var(--space-2) 0 0;
  border: 0; background: transparent; color: var(--link); font: inherit; font-size: var(--text-callout);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.bk-back .icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bk-crumbs__sep { color: var(--border-strong); font-size: var(--text-callout); }
.bk-crumbs__link {
  min-height: 32px; padding: 0 4px; border: 0; background: transparent; font: inherit;
  font-size: var(--text-callout); color: var(--text-muted); cursor: pointer;
}
.bk-head__row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-4); }
.bk-head__text { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.bk-h1 {
  margin: 0; font-size: var(--text-display); line-height: 34px; font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-title); color: var(--text);
}
.bk-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); font-size: var(--text-callout); color: var(--text-muted); }
.bk-meta__txt + .bk-meta__txt::before, .bk-chan + .bk-meta__txt::before, .bk-botname + .bk-meta__txt::before,
.bk-botsel-wrap + .bk-meta__txt::before { content: "·"; margin-right: var(--space-2); color: var(--text-faint); }
.bk-botname { font-weight: var(--weight-semibold); color: var(--text); }
.bk-botsel-wrap { position: relative; display: inline-flex; align-items: center; }
.bk-botsel {
  appearance: none; -webkit-appearance: none; height: 36px; max-width: 260px; padding: 0 32px 0 12px;
  border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface);
  font: inherit; font-size: var(--text-callout); font-weight: var(--weight-semibold); color: var(--text);
  text-overflow: ellipsis; cursor: pointer;
}
.bk-botsel:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.bk-botsel__chev {
  position: absolute; right: 10px; width: 14px; height: 14px; transform: rotate(90deg); pointer-events: none;
  fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.bk-chan {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: var(--radius-pill);
  font-size: var(--text-caption); font-weight: var(--weight-semibold); background: var(--surface-sunken); color: var(--text);
}
.bk-chan--telegram { background: var(--info-soft); color: var(--info); }
.bk-chan--form { background: var(--warn-soft); color: var(--warn); }

.bk-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.bk-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ── кнопки ── */
.bk-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 14px;
  border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface);
  font: inherit; font-size: var(--text-callout); color: var(--text); text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  transition: background-color var(--dur-fast) var(--ease-out), transform var(--dur-instant) var(--ease-out);
}
.bk-btn .icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bk-btn:active { transform: scale(0.98); }
.bk-btn:focus-visible, .bk-link:focus-visible, .bk-row__edit:focus-visible, .bk-more:focus-visible, .bk-back:focus-visible {
  outline: none; box-shadow: var(--shadow-focus);
}
.bk-btn[disabled] { opacity: .6; cursor: default; }
.bk-btn--primary { border: 0; background: var(--accent); color: var(--text-on-accent); font-weight: var(--weight-semibold); padding: 0 16px; }
.bk-btn--dark { border: 0; background: var(--accent-strong); color: var(--accent-text); font-weight: var(--weight-semibold); }
.bk-btn--sm { height: 36px; padding: 0 12px; font-size: var(--text-footnote); }
.bk-btn.is-loading { opacity: .7; }
@media (hover: hover) and (pointer: fine) {
  .bk-btn:not(.bk-btn--primary):not(.bk-btn--dark):hover { background: var(--surface-hover); }
  .bk-btn--primary:hover { background: var(--accent-hover); }
  .bk-sec__head:hover { background: var(--surface-hover); }
  .bk-row__edit:hover { background: var(--surface-sunken); }
  .bk-link:hover { color: var(--accent-hover); }
}
.bk-link {
  display: inline-flex; align-items: center; min-height: 32px; color: var(--link); font-size: var(--text-footnote);
  font-weight: var(--weight-semibold); text-decoration: none;
}

/* ── «Клиенты спрашивали — бот не знал» ── */
.bk-gaps {
  display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; border-radius: var(--radius-lg);
  background: var(--why-bg); border: 1px solid var(--why-border);
}
.bk-gaps__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bk-gaps__ic { width: 18px; height: 18px; fill: none; stroke: var(--warn); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.bk-gaps__sub { font-size: var(--text-footnote); color: var(--text-muted); }
.bk-gaps__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.bk-gap {
  display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: var(--radius-md);
  background: var(--surface); border: 1px solid var(--border); min-width: 0;
}
.bk-gap__q { margin: 0; font-size: var(--text-body); font-weight: var(--weight-semibold); line-height: var(--leading-snug); overflow-wrap: anywhere; }
.bk-gap__meta { margin: 0; font-size: var(--text-caption); color: var(--text-faint); }
.bk-gap__add { align-self: flex-start; gap: 4px; }

/* ── сетка: разделы · проверка ── */
.bk-grid { display: flex; flex-wrap: wrap; gap: var(--space-5); align-items: flex-start; }
.bk-main { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.bk-aside { flex: 1 1 320px; max-width: 420px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }

.bk-h2 { margin: 0; font-size: var(--text-headline); font-weight: var(--weight-semibold); line-height: var(--leading-headline); color: var(--text); }
.bk-h3 { margin: 0; font-size: var(--text-headline); font-weight: var(--weight-semibold); line-height: var(--leading-headline); color: var(--text); }

/* ── раздел ── */
.bk-sec { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.bk-sec__head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; transition: background-color var(--dur-fast) var(--ease-out); }
.bk-tile {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: var(--radius-md);
  background: var(--surface-sunken); color: var(--text);
}
.bk-tile .icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bk-sec__text { flex: 1; min-width: 0; }
.bk-sec__sub { margin: 2px 0 0; font-size: var(--text-footnote); color: var(--text-muted); line-height: var(--leading-snug); }
.bk-badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: var(--radius-pill); flex: none;
  font-size: var(--text-caption); font-weight: var(--weight-semibold); white-space: nowrap;
  background: var(--success-soft); color: var(--success);
}
.bk-badge--warn { background: var(--warn-soft); color: var(--warn); }
.bk-sec__act { flex: none; }

.bk-rows { border-top: 1px solid var(--border-subtle); }
.bk-rows:empty { display: none; }
.bk-rows__empty { margin: 0; padding: 12px 16px 14px 64px; font-size: var(--text-footnote); color: var(--text-muted); }
.bk-row {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 6px 12px 6px 64px;
  border-bottom: 1px solid var(--surface-2);
}
.bk-row:last-child { border-bottom: 0; }
.bk-row__k { width: 150px; flex: none; font-size: var(--text-footnote); color: var(--text-faint); overflow-wrap: anywhere; }
.bk-row__v {
  flex: 1; min-width: 0; font-size: var(--text-callout); color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bk-row__v.is-missing { color: var(--warn); font-style: italic; white-space: normal; }
.bk-row__v.is-booked { color: var(--text-muted); }
.bk-row__src { font-size: var(--text-caption); color: var(--text-faint); white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.bk-row__edit {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.bk-row__edit .icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bk-more {
  display: block; width: 100%; min-height: 40px; border: 0; border-top: 1px solid var(--border-subtle);
  background: transparent; font: inherit; font-size: var(--text-footnote); font-weight: var(--weight-semibold);
  color: var(--link); cursor: pointer;
}

/* ── карточки справа ── */
.bk-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.bk-ask { display: flex; flex-direction: column; gap: 6px; }
.bk-label { font-size: var(--text-footnote); color: var(--text-muted); }
.bk-ask__row { display: flex; gap: var(--space-2); }
.bk-input {
  flex: 1; min-width: 0; height: 42px; padding: 0 12px; border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--surface-sunken); font: inherit; font-size: var(--text-input); color: var(--text);
}
.bk-input:focus { outline: none; border-color: var(--border-strong); box-shadow: var(--shadow-focus); background: var(--surface); }
.bk-ask__row .bk-btn { height: 42px; flex: none; }
.bk-answer { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--radius-lg); background: var(--bg); }
.bk-bubble {
  align-self: flex-start; max-width: 92%; padding: 10px 14px; border-radius: var(--radius-lg); border-bottom-left-radius: 6px;
  background: var(--accent-strong); color: var(--accent-text); font-size: var(--text-callout); line-height: 20px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.bk-bubble--wait { background: var(--surface-sunken); color: var(--text-muted); }
.bk-src { margin: 0; font-size: var(--text-caption); color: var(--text-faint); line-height: var(--leading-snug); }
.bk-src__item { color: var(--text-muted); font-weight: var(--weight-medium); }
.bk-answer__acts { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.bk-cov__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.bk-cov__n { font-size: var(--text-footnote); color: var(--text-muted); white-space: nowrap; }
.bk-cov__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.bk-cov__row { display: flex; align-items: center; gap: 10px; min-height: 32px; font-size: var(--text-callout); }
.bk-cov__q { flex: 1; min-width: 0; }
.bk-cov__ic { width: 18px; height: 18px; flex: none; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.bk-cov__ic--ok { stroke: var(--success); }
.bk-cov__ic--no { stroke: var(--warn); }
.bk-cov__add { padding: 0 4px; }

/* ── пусто / загрузка ── */
.bk-empty { align-items: flex-start; }
.bk-empty__title { margin: 0; font-size: var(--text-headline); font-weight: var(--weight-semibold); }
.bk-skel { border-radius: var(--radius-lg); background: var(--surface-sunken); }
.bk-skel--title { height: 34px; width: 55%; }
.bk-skel--block { height: 140px; }
@media (prefers-reduced-motion: no-preference) {
  .bk-skel { animation: bk-pulse 1.2s var(--ease-in-out) infinite alternate; }
  @keyframes bk-pulse { from { opacity: 1; } to { opacity: .55; } }
}

/* ── телефон: одна колонка, строки «подпись над значением» (MobileList / MobileClient) ── */
@media (max-width: 699px) {
  .bk { gap: var(--space-4); }
  .bk-back { width: 44px; height: 44px; justify-content: center; padding: 0; margin-left: -10px; color: var(--text); }
  .bk-back__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .bk-head__row { flex-direction: column; align-items: stretch; gap: var(--space-3); }
  .bk-head__text { flex-basis: auto; }
  .bk-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); }
  .bk-actions .bk-btn { height: 44px; padding: 0 10px; white-space: nowrap; }
  .bk-actions .bk-btn .icon { display: none; }
  .bk-gaps { padding: 14px; }
  .bk-gaps__list { grid-template-columns: minmax(0, 1fr); }
  .bk-aside { max-width: none; }
  .bk-sec__head {
    display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; grid-template-areas: "tile text badge" ". act act";
    align-items: start; row-gap: 10px; padding: 12px 14px;
  }
  .bk-tile { grid-area: tile; }
  .bk-sec__text { grid-area: text; }
  .bk-badge { grid-area: badge; }
  /* docs/50b S8: «Изменить» — цель нажатия ≥44 px на телефоне. */
  .bk-sec__act { grid-area: act; justify-self: start; height: 44px; }
  .bk-row {
    display: grid; grid-template-columns: minmax(0, 1fr) 44px; grid-template-areas: "k edit" "v edit" "src edit";
    column-gap: 4px; row-gap: 2px; padding: 10px 4px 10px 14px; align-items: center;
  }
  .bk-row__k { width: auto; grid-area: k; font-size: var(--text-caption); }
  .bk-row__v { grid-area: v; white-space: normal; overflow-wrap: anywhere; }
  .bk-row__src { grid-area: src; max-width: none; }
  .bk-row__src:empty { display: none; }
  .bk-row__edit { grid-area: edit; width: 44px; height: 44px; }
  .bk-rows__empty { padding: 12px 14px 14px; }
}

/* L3 (2026-10-06): документ знаний противоречит каталогу */
.bk-warn {
  display: flex; gap: 10px; align-items: flex-start; margin: 0 0 12px; padding: 10px 12px;
  border-radius: var(--radius-md); background: var(--warn-soft); color: var(--text);
}
.bk-warn__ic { flex: none; color: var(--warn); display: inline-flex; }
.bk-warn__ic .icon { width: 18px; height: 18px; }
.bk-warn__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bk-warn__title { font-size: var(--text-footnote); font-weight: var(--weight-semibold); overflow-wrap: anywhere; }
.bk-warn__text { font-size: var(--text-footnote); line-height: var(--leading-snug); color: var(--text-muted); overflow-wrap: anywhere; }
