/* Моя база знаний */
.mykb-wrap { max-width: none; margin: 0; padding: 0; }
.mykb-headbox { margin-bottom: 8px; }
.mykb-headbox .box-header { flex-wrap:wrap; gap:12px; }
/* шапка-карточка без body → убираем нижнюю разделительную линию */
.mykb-headbox .box-header { border-bottom:0; }
.mykb-headbox .box-header::after { display:none; }
/* подложка-карточка со списком документов */
.mykb-listbox { margin-bottom:0; }
.mykb-listbody { padding:12px 14px; }
.mykb-head-act { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.mykb-upload-lbl { cursor:pointer; }

.mykb-docs { display:flex; flex-direction:column; gap:0; }
.mykb-doc { display:flex; align-items:center; justify-content:space-between;
  gap:12px; padding:12px 6px; border:0;
  border-bottom:1px solid var(--color-border-subtle); background:transparent;
  border-radius:10px; }
.mykb-doc:last-child { border-bottom:0; }
.mykb-doc:hover { background:rgba(255,255,255,.03); }
.mykb-doc-main { display:flex; align-items:center; gap:12px; min-width:0; }
.mykb-doc-name { font-weight:600; overflow:hidden; text-overflow:ellipsis;
  white-space:nowrap; max-width:840px; }
.mykb-doc-status { font-size:.72rem; padding:2px 8px; border-radius:999px;
  background:#2a3142; text-transform:uppercase; letter-spacing:.04em; }
.mykb-st-done { background:#16361f; color:#7ee0a0; }
.mykb-st-error, .mykb-st-failed { background:#3a1a1a; color:#ff9b9b; }
.mykb-st-running, .mykb-st-pending { background:#2a2f4a; color:#9fb4ff; }
.mykb-doc-meta { font-size:.8rem; opacity:.65; }
.mykb-doc-act { display:flex; gap:6px; flex-shrink:0; }
.mykb-doc-act { gap:6px; }
.mykb-doc-rename { margin-right:-6px; flex-shrink:0; color:#9fb4ff; }

.mykb-empty { padding:24px; text-align:center; opacity:.6; }
.mykb-err { color:#ff9b9b; opacity:.9; }

.mykb-modal { position:fixed; inset:0; z-index:var(--z-modal);
  background:rgba(5,8,18,.7); backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px);
  display:flex; align-items:center;
  justify-content:center; padding:20px; animation:modalOverlayIn .2s ease; }
.mykb-modal[hidden] { display:none; }
.mykb-modal-box { width:min(720px,100%); max-height:82vh; display:flex;
  flex-direction:column;
  background:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(139,92,246,.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 90% 80%, rgba(56,139,253,.05) 0%, transparent 50%),
    rgba(16,20,35,.92);
  backdrop-filter:blur(28px) saturate(1.5); -webkit-backdrop-filter:blur(28px) saturate(1.5);
  border:1px solid rgba(139,92,246,.12); border-radius:16px;
  box-shadow:0 16px 56px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.03), inset 0 1px 0 rgba(255,255,255,.04);
  animation:modalSlideIn .25s cubic-bezier(0.16,1,0.3,1);
  overflow:hidden; }
.mykb-modal-head { display:flex; align-items:center; justify-content:space-between;
  padding:6px 14px; border-bottom:1px solid rgba(139,92,246,.12);
  font-weight:600; }
.mykb-modal-close { position:relative; background:none; border:none; color:#8b949e;
  top:1px; font-size:18px; line-height:1; cursor:pointer;
  width:28px; height:28px; display:flex; align-items:center;
  justify-content:center; padding:0; transition:color .2s; }
.mykb-modal-close::before { content:""; position:absolute; left:0; top:0px;
  width:28px; height:28px; border-radius:8px; background:transparent;
  transition:background .2s; z-index:0; }
.mykb-modal-close:hover { color:#f85149; }
.mykb-modal-close:hover::before { background:rgba(248,81,73,.12); }
.mykb-modal-body { padding:16px 18px; overflow:auto; }
#mykbShareModal .mykb-modal-body { overflow:visible; }

/* Открытый custom-select не должен клипиться границами модалки */
.mykb-modal-box:has(.cs-wrap.is-open) { overflow:visible; }
.mykb-modal-body:has(.cs-wrap.is-open) { overflow:visible; }
.mykb-share-form:has(.cs-wrap.is-open) { position:relative; z-index:var(--z-dropdown); }

.mykb-chunk { padding:10px 0; border-bottom:1px dashed var(--border, #2a3142); }
#mykbChunksModal .mykb-modal-box { width:min(1100px,100%); height:82vh; }
.mykb-chunks-split { display:flex; gap:0; padding:0; overflow:hidden;
  flex:1 1 auto; min-height:0; }
.mykb-chunk-side {
  flex:0 0 320px; width:320px; max-width:320px; min-width:320px;
  display:flex; flex-direction:column; min-height:0; overflow:hidden;
  border-right:1px solid var(--border, #2a3142);
}
.mykb-chunk-list {
  flex:1 1 auto; overflow-y:auto; padding:6px 0; min-height:0;
}
.mykb-add-chunk-btn {
  flex: 0 0 auto; 
  align-self: stretch; 
  box-sizing: border-box;
  margin: 8px 10px; 
  min-width: 0; 
  height: auto;
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis;
  
  /* === Добавьте эти строки === */
  display: flex;
  justify-content: center; /* Центрирование по горизонтали */
  align-items: center;     /* Центрирование по вертикали */
  text-align: center;      /* Дополнительная страховка для текста */
}
.mykb-chunk-item {
  display:flex; gap:6px; align-items:baseline; padding:7px 12px; cursor:pointer;
  border-bottom:1px solid var(--border, #2a3142); font-size:.8rem;
}
.mykb-chunk-item:hover { background:var(--hover, rgba(255,255,255,.04)); }
.mykb-chunk-item.is-active { background:var(--accent, #3b82f6); color:#fff; }
.mykb-chunk-item-idx { opacity:.6; flex:0 0 auto; }
.mykb-chunk-item.is-active .mykb-chunk-item-idx { opacity:.85; }
.mykb-chunk-item-txt {
  flex:1 1 auto; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.mykb-chunk-detail { flex:1 1 auto; overflow-y:auto; padding:14px 18px;
  min-height:0; display:flex; flex-direction:column; scrollbar-gutter:stable; }
.mykb-chunk-bar { display:flex; align-items:center; justify-content:space-between;
  gap:12px; margin-bottom:10px; position:sticky; top:-14px; z-index:3;
  background:#141a28; padding:2px 18px 2px; margin:-14px -18px 10px; }
.mykb-chunk-bar-act { display:flex; gap:6px; flex-shrink:0; }
.mykb-chunk-bar-act button { font-size:.8rem; padding:4px 12px; border-radius:8px;
  border:1px solid var(--border, #2a3142); background:transparent; color:inherit;
  cursor:pointer; }
.mykb-chunk-bar-act button:hover { background:#222a3d; }
.mykb-chunk-bar-act .mykb-chunk-del-btn { background:rgba(248,81,73,0.06); border-color:rgba(248,81,73,0.2); color:#f85149; }
.mykb-chunk-bar-act .mykb-chunk-del-btn:hover { background:rgba(248,81,73,0.12); border-color:rgba(248,81,73,0.4); color:#f85149; box-shadow:0 0 12px rgba(248,81,73,0.1); }
.mykb-chunk-save-btn { background:#1b2a4a !important; }
.mykb-chunk-save-btn:hover { background:#22386a !important; }
.mykb-chunk-save-btn:disabled { opacity:.5; cursor:default; }
.mykb-chunk-view { flex:1 1 auto; }
.mykb-chunk-edit { flex:1 1 auto; min-height:240px; max-height:60vh; width:100%;
  padding:10px 12px; border-radius:8px; border:1px solid var(--border, #2a3142);
  background:#0e1422; color:inherit; font-size:.88rem; line-height:1.5;
  font-family:inherit; white-space:pre-wrap; overflow:auto; outline:none; }
.mykb-chunk-edit:focus { border-color:var(--accent, #4a90d9); }
.mykb-chunk-edit img.mykb-chunk-img { display:block; max-width:100%;
  max-height:320px; margin:8px 0; border-radius:6px; cursor:default; }
.mykb-chunk-img-lbl { display:inline-block; margin-top:8px; cursor:pointer; }
.mykb-chunk-hint { font-size:.72rem; opacity:.5; margin-top:6px; }
.mykb-chunk:last-child { border-bottom:none; }
.mykb-chunk-idx { font-size:.72rem; opacity:.5; margin-bottom:4px; }
.mykb-chunk-text { white-space:pre-wrap; font-size:.88rem; line-height:1.5; }
.mykb-chunk-view a {
  color: #22d3ee;
  text-decoration: none;
  transition: color .15s;
}
.mykb-chunk-view a:hover {
  color: #67e8f9;
  text-decoration: underline;
}
.mykb-share-form { display:flex; gap:8px; margin-bottom:14px; flex-wrap:wrap; }
.mykb-share-form select, .mykb-share-form input { padding:6px 10px;
  border-radius:8px; border:1px solid rgba(139,92,246,.18);
  background:rgba(10,14,26,.6); color:inherit; transition:.15s; }
.mykb-share-form select:focus, .mykb-share-form input:focus {
  outline:none; border-color:rgba(139,92,246,.5);
  box-shadow:0 0 0 3px rgba(139,92,246,.12); }
.mykb-share-list { display:flex; flex-direction:column; gap:6px; }
.mykb-grant { display:flex; align-items:center; justify-content:space-between;
  padding:6px 12px; border:1px solid var(--border, #2a3142);
  border-radius:8px; font-size:.85rem; }
.mykb-grant-del { background:none; border:none; color:#8b949e;
  width:22px; height:22px; min-width:22px; min-height:22px;
  border-radius:6px; display:flex; align-items:center; justify-content:center;
  padding:0; font-size:18px; line-height:1; cursor:pointer; opacity:.4;
  transition:all var(--t-fast) var(--ease-out); }
.mykb-grant-del:hover { opacity:1; background:rgba(248,81,73,.1); color:#f85149; }

.mykb-split-modes { display:flex; gap:18px; margin-bottom:14px; }
.mykb-split-modes label { display:flex; align-items:center; gap:6px;
  font-size:.9rem; cursor:pointer; }
.mykb-split-lvls { display:flex; gap:14px; flex-wrap:wrap; margin-bottom:14px;
  transition:opacity .15s; }
.mykb-split-lvl { display:flex; align-items:center; gap:5px; font-size:.85rem; }
.mykb-split-row { display:flex; gap:16px; margin-bottom:14px; }
.mykb-split-row label { display:flex; flex-direction:column; gap:4px;
  font-size:.8rem; opacity:.85; }
.mykb-split-row input { padding:6px 10px; border-radius:8px;
  border:1px solid rgba(139,92,246,.18); background:rgba(10,14,26,.6);
  color:inherit; width:120px; transition:.15s; }
.mykb-split-row input:focus { outline:none; border-color:rgba(139,92,246,.5);
  box-shadow:0 0 0 3px rgba(139,92,246,.12); }
.mykb-split-tree { max-height:200px; overflow:auto; margin-bottom:14px;
  padding:8px 10px; border:1px solid var(--border, #2a3142);
  border-radius:8px; }
.mykb-split-tnode { font-size:.82rem; padding:2px 0; opacity:.85; }
.mykb-split-foot { display:flex; justify-content:flex-end; }
.mykb-split-foot button { padding:7px 18px; border-radius:8px;
  border:1px solid var(--border, #2a3142); background:#1b2a4a;
  color:inherit; cursor:pointer; font-size:.9rem; }
.mykb-split-foot button:hover { background:#22386a; }
.mykb-split-foot button:disabled { opacity:.5; cursor:default; }
.mykb-chunk-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 8px 0;
  border-radius: 6px;
  cursor: zoom-in;
}
/* подвкладки «Моя база / Доступные мне» */
.mykb-subtabs { display: flex; gap: 6px; margin: 0; }
.mykb-subtab {
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
  color: #b8b8d0; padding: 6px 16px; border-radius: 8px; cursor: pointer;
  font-size: 13px; transition: .15s;
}
.mykb-subtab:hover { background: rgba(255,255,255,.08); color: #fff; }
.mykb-subtab.is-active {
  background: rgba(124,92,246,.18); border-color: rgba(124,92,246,.5);
  color: #fff;
}

/* ── Модалка «Создать документ» + ручные чанки ── */
.mykb-newdoc-box { display:flex; flex-direction:column; gap:10px; }
.mykb-field-lbl { font-size:.8rem; opacity:.8; display:flex;
  flex-direction:column; gap:5px; }
.mykb-field-input { padding:8px 12px; border-radius:8px;
  border:1px solid var(--border, #2a3142); background:#0e1422;
  color:inherit; font-size:.9rem; font-family:inherit; }
.mykb-field-input:focus { outline:none; border-color:rgba(124,92,246,.6); }
.mykb-newdoc-hint { font-size:.74rem; opacity:.5; }
.mykb-newdoc-act { display:flex; justify-content:flex-end; gap:8px;
  margin-top:6px; }
.mykb-newdoc-act button { padding:7px 18px; border-radius:8px;
  border:1px solid var(--border, #2a3142); background:#1b2a4a;
  color:inherit; cursor:pointer; font-size:.9rem; }
.mykb-newdoc-act button:hover { background:#22386a; }
.mykb-newdoc-act button:disabled { opacity:.5; cursor:default; }

/* кнопка «Добавить картинку» в режиме редактирования чанка */
.mykb-chunk-img-lbl { align-self:flex-start; margin-top:8px; cursor:pointer;
  display:inline-block; padding:5px 14px; border-radius:8px;
  border:1px solid var(--border, #2a3142); background:transparent;
  color:inherit; font-size:.8rem; }
.mykb-chunk-img-lbl:hover { background:#222a3d; }
#mykbNewDocTitle {
    width: 100%;
    max-width: 685px;
    box-sizing: border-box;
}
.mykb-chunk-search-wrap {
  flex:0 0 auto; margin:8px 10px 4px;
}
.mykb-chunk-search {
  width:100%; box-sizing:border-box;
  padding:6px 28px 6px 10px; border-radius:8px;
  border:1px solid var(--border, #2a3142);
  background:var(--bg-input, #1a1f2e); color:inherit;
  font-size:13px; outline:none;
}
.mykb-chunk-search:focus { border-color:var(--accent, #7c5cff); }
/* --- KB: анимация статуса "в работе" --- */
@keyframes mykbPulseBorder {
  0%   { box-shadow: 0 0 0 0 rgba(159,180,255,.55); }
  70%  { box-shadow: 0 0 0 6px rgba(159,180,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(159,180,255,0); }
}
.mykb-doc-status.mykb-st-pending,
.mykb-doc-status.mykb-st-running,
.mykb-doc-status.mykb-st-parsing {
  position: relative;
  border: 1px solid rgba(159,180,255,.6);
  animation: mykbPulseBorder 1.6s ease-out infinite;
}
.mykb-doc-status.mykb-st-pending::before,
.mykb-doc-status.mykb-st-running::before,
.mykb-doc-status.mykb-st-parsing::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 5px;
  border: 2px solid rgba(159,180,255,.4);
  border-top-color: #9fb4ff;
  border-radius: 50%;
  vertical-align: -1px;
  animation: mykbSpin .7s linear infinite;
}
@keyframes mykbSpin { to { transform: rotate(360deg); } }

.mykb-split-hint { font-size: 13px; color: #9aa6c2; margin: 0 0 8px; }
.mykb-split-note { font-size: 12px; color: #9aa6c2; opacity: .8; }
/* KbHelp в заголовке вкладки «Моя база знаний» */
.box-header > span > .kb-help-btn { margin-left: 6px; vertical-align: middle; }

/* KbHelp popover (mykb) */
.mykb-modal-head { display: flex; align-items: center; gap: 8px; }
.mykb-modal-head .mykb-modal-close { margin-left: auto; }
.kb-help-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0; margin: 0;
  border: none; background: transparent; cursor: pointer;
  color: #9fb4ff; border-radius: 50%;


}
.kb-help-btn:hover { color: #fff; background: rgba(255,255,255,.08); }
.kb-help-pop {
  position: absolute; z-index: 10000;
  width: 340px; max-width: 90vw;
  background: #2a3142; color: #d7dde6;
  border: 1px solid var(--color-border-subtle, rgba(255,255,255,.12));
  border-radius: 10px;
  padding: 14px 16px; font-size: 13px; line-height: 1.5;
  box-shadow: 0 12px 32px rgba(0,0,0,.45);
}
.kb-help-pop b { color: #fff; }
.kb-help-pop p { margin: 8px 0; }
.kb-help-pop ul { margin: 6px 0; padding-left: 18px; }
.kb-help-pop li { margin: 3px 0; }
.kb-help-pop i { color: #9fb4ff; font-style: normal; }
.kb-help-pop .kbhelp-note {
  margin-top: 10px; padding-top: 8px;
  border-top: 1px solid var(--color-border-subtle, rgba(255,255,255,.1));
  color: #9aa4b2; font-size: 12px;
}
/* B2.2: поиск + бейдж ограничений */
.mykb-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.mykb-filters .input-clearable { flex: 1 1 240px; min-width: 200px; }
.mykb-filters .au-select { flex: 0 0 auto; min-width: 160px; }
.mykb-lock {
  display: inline-flex;
  vertical-align: middle;
  margin-left: 6px;
  color: var(--warning, #b8860b);
}
.mykb-lock svg { width: 14px; height: 14px; }

/* ═══ ФОРСИРОВАННЫЕ СТИЛИ ЭКСПОРТ/ИМПОРТ ═══ */
.mykb-ei-modal {
  width: 420px !important;
  max-height: 55vh !important;
}
.mykb-ei-body {
  padding: 14px !important;
}
.mykb-ei-options {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
}
.mykb-ei-card {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  padding: 12px 14px !important;
  min-height: 110px !important;
  background: rgba(139, 92, 246, 0.06) !important;
  border: 1px solid rgba(139, 92, 246, 0.15) !important;
  border-radius: 10px !important;
  cursor: pointer !important;
  text-align: center !important;
}
.mykb-ei-card:hover {
  background: rgba(139, 92, 246, 0.12) !important;
  border-color: rgba(139, 92, 246, 0.35) !important;
}
.mykb-ei-icon {
  width: 32px !important;
  height: 32px !important;
  color: #8b949e !important;
  flex-shrink: 0 !important;
  stroke: currentColor !important;
  fill: none !important;
  display: block !important;
}
.mykb-ei-card:hover .mykb-ei-icon {
  color: #9fb4ff !important;
}
.mykb-ei-title {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: #e6edf3 !important;
  margin: 0 !important;
  line-height: 1.3 !important;
}
.mykb-ei-desc {
  font-size: 11px !important;
  color: #8b949e !important;
  line-height: 1.4 !important;
  margin: 0 !important;
  max-width: 160px !important;
}
.mykb-ei-import-card {
  position: relative !important;
}
.mykb-ei-import-card input[type="file"] {
  position: absolute !important;
  inset: 0 !important;
  opacity: 0 !important;
  cursor: pointer !important;
  width: 100% !important;
  height: 100% !important;
}
.mykb-ei-status {
  margin-top: 10px !important;
  font-size: 12px !important;
  text-align: center !important;
}
.mykb-ei-status.success {
  color: #3fb950 !important;
}
.mykb-ei-status.error {
  color: #f85149 !important;
}

/* ═══ Модалка выбора документов для экспорта ═══ */
.mykb-export-doc-modal {
  width: 520px !important;
  max-height: 70vh !important;
}
.mykb-export-doc-body {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  padding: 16px !important;
}
.mykb-export-doc-controls {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding-bottom: 8px !important;
  border-bottom: 1px solid rgba(139,92,246,0.12) !important;
}
.mykb-export-doc-checkall {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  font-size: 13px !important;
  color: #c9d1d9 !important;
  cursor: pointer !important;
}
.mykb-export-doc-checkall input[type="checkbox"] {
  width: 16px !important;
  height: 16px !important;
  accent-color: #7c5cff !important;
  cursor: pointer !important;
}
.mykb-export-doc-count {
  font-size: 12px !important;
  color: #8b949e !important;
}
.mykb-export-doc-list {
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
  max-height: 320px !important;
  overflow-y: auto !important;
  padding: 4px !important;
}
.mykb-export-doc-item {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 8px 10px !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  transition: background 0.15s !important;
}
.mykb-export-doc-item:hover {
  background: rgba(139,92,246,0.08) !important;
}
.mykb-export-doc-item input[type="checkbox"] {
  width: 16px !important;
  height: 16px !important;
  accent-color: #7c5cff !important;
  cursor: pointer !important;
  flex-shrink: 0 !important;
}
.mykb-export-doc-item-label {
  flex: 1 !important;
  min-width: 0 !important;
  font-size: 13px !important;
  color: #e6edf3 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}
.mykb-export-doc-item-meta {
  font-size: 11px !important;
  color: #8b949e !important;
  flex-shrink: 0 !important;
}
.mykb-export-doc-actions {
  display: flex !important;
  justify-content: flex-end !important;
  gap: 8px !important;
  padding-top: 8px !important;
  border-top: 1px solid rgba(139,92,246,0.12) !important;
}
.mykb-export-doc-actions button:disabled {
  opacity: 0.5 !important;
  cursor: default !important;
}
.mykb-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.9em;
}

.mykb-table th,
.mykb-table td {
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}

.mykb-table th {
  background: rgba(138, 43, 226, 0.2);
  font-weight: 600;
  color: #fff;
}

.mykb-table tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.mykb-table tr:hover td {
  background: rgba(255, 255, 255, 0.05);
}

/* ═══ Двухпанельный вид: папки (слева) + документы (справа) ═══ */
.mykb-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
    gap: 14px;
    align-items: start;
}
@media (max-width: 900px) { .mykb-split { grid-template-columns: 1fr; } }

.mykb-folders { display: flex; flex-direction: column; gap: 8px; }
.mykb-folder {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 12px 14px; border: 1px solid var(--border, #2a3142);
    border-radius: 10px; background: rgba(255,255,255,.02);
    cursor: pointer; transition: .15s;
}
.mykb-folder:hover { background: rgba(255,255,255,.04); }
.mykb-folder.is-active { border-color: #3d6ad6; box-shadow: 0 0 0 1px #3d6ad6; }
.mykb-folder-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mykb-folder-name { font-weight: 600; display: flex; align-items: center; gap: 6px; min-width: 0; }
.mykb-folder-name .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mykb-folder-meta { font-size: .78rem; opacity: .6; }

.mykb-docpanel {
    border: 1px solid var(--border, #2a3142); border-radius: 10px;
    background: rgba(255,255,255,.02); overflow: hidden;
}
.mykb-docpanel-head {
    display: flex; align-items: center; gap: 8px; padding: 12px 14px;
    border-bottom: 1px solid var(--border, #2a3142);
}
.mykb-docpanel-title { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mykb-docpanel-act { display: flex; gap: 8px; margin-left: auto; flex-shrink: 0; }


/* меню ⋮ у папки */
.mykb-fmenu { position: relative; flex-shrink: 0; }
.mykb-fmenu-btn {
    background: none; border: none; color: #8b949e; cursor: pointer;
    font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.mykb-fmenu-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.mykb-fmenu-pop {
    display: none; position: absolute; right: 0; top: 100%;
    z-index: var(--z-dropdown, 900); min-width: 175px; margin-top: 4px;
    background: #161b2c; border: 1px solid var(--border, #2a3142);
    border-radius: 10px; overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.mykb-fmenu.open .mykb-fmenu-pop { display: block; }
.mykb-fmenu-item {
    display: block; width: 100%; text-align: left; background: none; border: none;
    border-bottom: 1px solid rgba(255,255,255,.05); color: #e6edf3;
    padding: 9px 12px; font-size: .85rem; cursor: pointer;
}
.mykb-fmenu-item:last-child { border-bottom: 0; }
.mykb-fmenu-item:hover { background: rgba(255,255,255,.06); }
.mykb-fmenu-item.danger { color: #ff7b6b; }
.mykb-fmenu-item.danger:hover { background: rgba(248,81,73,.1); }

/* T3: выпадающее меню ⋮ не должно обрезаться панелью */
.mykb-docpanel { overflow: visible; }
.mykb-split, .mykb-folders, .mykb-listbody { overflow: visible; }
.mykb-doc-act { position: relative; }
.mykb-doc .mykb-fmenu-btn { font-size: 18px; }

/* Плавающее меню ⋮ — живёт в body, не обрезается панелями и подложкой */
.mykb-float-menu {
    position: fixed; z-index: 10000; min-width: 185px;
    background: #161b2c; border: 1px solid var(--border, #2a3142);
    border-radius: 10px; overflow: hidden;
    box-shadow: 0 10px 28px rgba(0,0,0,.55);
}
.mykb-float-menu[hidden] { display: none; }
/* исходные pop-блоки внутри строк больше не показываем — только как шаблон */
.mykb-fmenu-pop { display: none !important; }

/* ═══ Markdown-тулбар редактора чанка ═══ */
.mykb-md-toolbar {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 6px 8px;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border, #2a3142);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}
.mykb-md-btn {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  color: #b8b8d0;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: .15s;
  min-width: 32px;
}
.mykb-md-btn:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  border-color: rgba(255,255,255,.15);
}
.mykb-md-toggle {
  background: rgba(124,92,246,.12);
  border: 1px solid rgba(124,92,246,.3);
  color: #c4b5fd;
  padding: 4px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: .15s;
}
.mykb-md-toggle:hover {
  background: rgba(124,92,246,.18);
  border-color: rgba(124,92,246,.5);
}

/* Undo/Redo кнопки */
.mykb-md-btn[data-action="undo"],
.mykb-md-btn[data-action="redo"] {
  opacity: .4;
  pointer-events: none;
}
.mykb-md-btn[data-action="undo"].active,
.mykb-md-btn[data-action="redo"].active {
  opacity: 1;
  pointer-events: auto;
}

/* Table picker dropdown */
.mykb-table-wrap {
  position: relative;
}
.mykb-table-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 999;
  background: #1a1f2e;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  min-width: 180px;
}
.mykb-table-dropdown.open { display: block; }
.mykb-table-grid {
  display: grid;
  grid-template-columns: repeat(8, 20px);
  gap: 3px;
  margin-bottom: 8px;
}
.mykb-table-cell {
  width: 20px;
  height: 20px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 3px;
  cursor: pointer;
  background: rgba(255,255,255,.03);
  transition: .1s;
}
.mykb-table-cell.hover {
  background: rgba(124,92,246,.4);
  border-color: rgba(124,92,246,.7);
}
.mykb-table-label {
  font-size: 11px;
  color: #8888aa;
  text-align: center;
}
.mykb-doc-warn { color:#d97706; cursor:help; }
.mykb-chunk-edit {
  border-radius: 0 0 8px 8px;
  border-top: none;
  resize: vertical;
  min-height: 320px;
  font-family: 'IBM Plex Mono', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
}
.mykb-chunk-preview {
  min-height: 320px;
  max-height: 60vh;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border, #2a3142);
  border-radius: 0 0 8px 8px;
  background: #0e1422;
  font-size: .88rem;
  line-height: 1.5;
}
/* Ссылки в превью — cyan вместо синего */
.mykb-chunk-preview a {
  color: #22d3ee;
  text-decoration: none;
  transition: color .15s;
}
.mykb-chunk-preview a:hover {
  color: #67e8f9;
  text-decoration: underline;
}
/* Картинки в превью — как в чате */
.mykb-chunk-preview img.chat-msg-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 8px 0;
  border-radius: 6px;
  cursor: zoom-in;
}
.mykb-chunk-preview img.chat-msg-image.rag-inline-image {
  display: inline-block;
  vertical-align: text-bottom;
  max-height: 1.8em;
  width: auto;
  margin: 0 2px;
}
/* ═══ Таблицы в просмотре и превью чанков ═══ */
.mykb-chunk-view .md-table,
.mykb-chunk-preview .md-table {
  width: auto;
  max-width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.9rem;
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  overflow: hidden;
}

.mykb-chunk-view .md-table-cell,
.mykb-chunk-preview .md-table-cell {
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.08);
  vertical-align: top;
}

.mykb-chunk-view .md-table th,
.mykb-chunk-preview .md-table th {
  background: rgba(124,92,246,.15);
  color: #e9d5ff;
  font-weight: 600;
  text-align: left;
  border-bottom: 2px solid rgba(124,92,246,.4);
}

.mykb-chunk-view .md-table-row-even,
.mykb-chunk-preview .md-table-row-even {
  background: rgba(255,255,255,.01);
}

.mykb-chunk-view .md-table-row-odd,
.mykb-chunk-preview .md-table-row-odd {
  background: rgba(255,255,255,.03);
}

.mykb-chunk-view .md-table tr:hover,
.mykb-chunk-preview .md-table tr:hover {
  background: rgba(124,92,246,.08);
}

/* Bold/italic внутри таблиц */
.mykb-chunk-view .md-table strong,
.mykb-chunk-preview .md-table strong {
  color: #f8fafc;
  font-weight: 600;
}

.mykb-chunk-view .md-table em,
.mykb-chunk-preview .md-table em {
  font-style: italic;
  color: #e2e8f0;
}

.mykb-chunk-view .md-table code,
.mykb-chunk-preview .md-table code {
  background: rgba(0,0,0,.3);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85em;
}
/* Массовый выбор документов */
.mykb-select-btn {
  padding: 0.35rem 0.55rem;
  border: 1px solid rgba(255,255,255,0.12);
  background: transparent;
  color: inherit;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  /* сбрасываем то, что даёт .btn */
  box-shadow: none;
}
.mykb-select-btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.22);
}
.mykb-select-btn svg {
  display: block;
  fill: currentColor;
}
.mykb-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.mykb-select-menu,
.mykb-actions-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--c-surface-raised, #1e2329);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  z-index: 200;
  min-width: 190px;
  overflow: hidden;
}
.mykb-select-menu-item,
.mykb-actions-menu-item {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background 0.12s;
  white-space: nowrap;
}
.mykb-select-menu-item:hover:not(:disabled),
.mykb-actions-menu-item:hover {
  background: rgba(255,255,255,0.07);
}
.mykb-select-menu-item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.mykb-doc-selected {
  outline: 2px solid var(--primary, #0066cc);
  outline-offset: -2px;
  background: var(--selected-bg, rgba(0, 102, 204, 0.05));
}
