
/* ============================================
   KB Home (макет CRM)
   ============================================ */

.kb-home {
  width: 100%;
  max-width: none;
}

.kb-home-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.kb-home .page-title {
  font-size: 28px;
  margin-bottom: 8px;
}

.kb-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.kb-stat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-soft);
  min-width: 0;
  box-shadow: var(--shadow-sm);
}

.kb-stat-icon {
  width: 40px; height: 40px; border-radius: var(--r-md);
  display: grid; place-items: center;
}

.kb-stat-blue .kb-stat-icon { background: var(--accent-soft); color: var(--accent-text); }
.kb-stat-green .kb-stat-icon { background: var(--tag-green-bg); color: var(--tag-green-text); }
.kb-stat-amber .kb-stat-icon { background: var(--tag-amber-bg); color: var(--tag-amber-text); }
.kb-stat-violet .kb-stat-icon { background: var(--tag-violet-bg); color: var(--tag-violet-text); }

.kb-stat-value { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.kb-stat-label { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.kb-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 300px);
  gap: 28px;
  align-items: start;
  width: 100%;
}

.kb-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.kb-tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.kb-tab.active { color: var(--accent-text); border-bottom-color: var(--accent); font-weight: 600; }

.kb-main { min-width: 0; }

.kb-list {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  width: 100%;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.kb-list-item {
  display: grid; grid-template-columns: 32px 1fr auto auto auto;
  align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft); cursor: pointer; transition: background 0.12s;
}
.kb-list-item:hover { background: var(--surface-hover); }
.kb-list-item:last-child { border-bottom: none; }

.kb-list-icon {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: var(--paper-2); display: grid; place-items: center; color: var(--text-3);
}

.kb-list-title { font-weight: 500; font-size: 14px; }
.kb-list-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.kb-list-stats { display: flex; gap: 10px; align-items: center; }
.kb-list-stat { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); }
.kb-list-author { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.kb-list-time { font-size: 11px; color: var(--text-3); font-family: var(--font-mono); }

.kb-badge { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: var(--r-full); text-transform: uppercase; letter-spacing: 0.04em; }
.kb-badge-new { background: var(--tag-green-bg); color: var(--tag-green-text); }

.kb-show-all {
  display: block; width: 100%; text-align: center; padding: 12px;
  font-size: 13px; color: var(--accent-text); margin-top: 8px;
}

.kb-section-block { margin-top: 32px; }
.kb-section-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }

.kb-aside {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.kb-widget {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--r-lg); padding: 16px;
  box-shadow: var(--shadow-sm);
}

.kb-widget-title { font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.kb-tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.kb-tag-cloud .tag { font-family: var(--font-ui); }
.kb-tag-cloud-btn {
  cursor: pointer;
  border: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.kb-tag-cloud-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.kb-tag-cloud-btn:active {
  transform: translateY(0);
}
.kb-tag-cloud-empty {
  margin: 0;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.45;
}
.kb-tag-count { opacity: 0.75; margin-left: 2px; font-size: 10px; }

.kb-widget-item {
  display: flex; align-items: flex-start; gap: 8px; width: 100%; text-align: left;
  padding: 8px 0; font-size: 13px; border-bottom: 1px solid var(--border-soft);
}
.kb-widget-item:last-of-type { border-bottom: none; }
.kb-widget-time, .kb-widget-reason { font-size: 11px; color: var(--text-3); margin-left: auto; white-space: nowrap; }
.kb-widget-rec { flex-direction: column; align-items: stretch; gap: 4px; }
.kb-widget-link { font-size: 12px; color: var(--accent-text); margin-top: 8px; }

/* Sidebar subnav */
.sb-item-wrap { display: flex; align-items: center; position: relative; }
.sb-item-wrap .sb-item { flex: 1; }
.sb-expand {
  position: absolute; right: 8px; width: 24px; height: 24px;
  display: grid; place-items: center; color: var(--text-3); border-radius: var(--r-xs);
}
.sb-expand:hover { background: var(--surface-hover); }

.sb-subnav { padding: 2px 0 6px 8px; margin-left: 8px; border-left: 1px solid var(--border-soft); }
.sb-subitem {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 10px; border-radius: var(--r-sm); font-size: 12.5px; color: var(--text-2);
  font-weight: 500;
}
.sb-subitem:hover { background: var(--surface-hover); color: var(--text); }
.sb-subitem.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }

/* Editor blocks */
.editor-blocks { display: flex; flex-direction: column; gap: 12px; }

.editor-block {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.editor-block.focused {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.editor-block-chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--border-soft);
}

.editor-block-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

.editor-block-btns { display: flex; gap: 2px; }

.editor-block-btn {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: var(--r-xs);
  color: var(--text-3);
}
.editor-block-btn:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.editor-block-btn:disabled { opacity: 0.25; }

.editor-block-body { padding: 14px 16px; }

.editor-block-h2 {
  width: 100%; border: none; background: transparent;
  font-size: 22px; font-weight: 600; font-family: var(--font-display);
  letter-spacing: -0.015em;
}
.editor-block-h1 {
  width: 100%; border: none; background: transparent;
  font-size: 28px; font-weight: 600; font-family: var(--font-display);
  letter-spacing: -0.02em;
}
.editor-block-h3 {
  width: 100%; border: none; background: transparent;
  font-size: 17px; font-weight: 600;
}
.editor-block-p {
  width: 100%; border: none; background: transparent;
  resize: vertical; line-height: 1.65; min-height: 72px;
}

/* Задачи */
.block-todo-editor { display: flex; flex-direction: column; gap: 4px; }
.block-todo-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: var(--r-sm);
}
.block-todo-row:hover { background: var(--surface-warm); }
.block-todo-row.done .block-todo-input { color: var(--text-3); text-decoration: line-through; }

.block-todo-check {
  width: 20px; height: 20px; flex-shrink: 0;
  border: 1.5px solid var(--border-strong); border-radius: 5px;
  display: grid; place-items: center; color: white;
}
.block-todo-check.checked { background: var(--accent); border-color: var(--accent); }

.block-todo-input {
  flex: 1; border: none; background: transparent;
  font-size: 14.5px; padding: 4px 0; outline: none;
}

/* Списки */
.block-list-editor { display: flex; flex-direction: column; gap: 4px; }
.block-list-row {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px; border-radius: var(--r-sm);
}
.block-list-row:hover { background: var(--surface-warm); }
.block-list-marker {
  width: 20px; flex-shrink: 0; text-align: center;
  color: var(--text-3); font-weight: 600; font-size: 14px;
}
.block-list-editor.ordered .block-list-marker { font-family: var(--font-mono); font-size: 12px; }
.block-list-input {
  flex: 1; border: none; background: transparent;
  font-size: 14.5px; padding: 4px 0; outline: none;
}

/* Код */
.code-block {
  --code-bg: #0d1117;
  --code-header: #161b22;
  --code-border: #30363d;
  --code-text: #e6edf3;
  --code-muted: #7d8590;
  --code-accent: #58a6ff;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--code-border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.08);
  background: var(--code-bg);
}

.code-block-chrome {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--code-header);
  border-bottom: 1px solid var(--code-border);
  position: relative;
  z-index: 3;
}

.code-block-dots {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}
.code-block-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #484f58;
}
.code-block-dots span:nth-child(1) { background: #ff5f57; }
.code-block-dots span:nth-child(2) { background: #febc2e; }
.code-block-dots span:nth-child(3) { background: #28c840; }

.code-block-lang-wrap { position: relative; }
.code-block-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--code-text);
  font-size: 12px;
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}
.code-block-lang-btn:hover { background: rgba(255, 255, 255, 0.1); }
.code-block-lang-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--code-muted);
  text-transform: none;
  letter-spacing: 0;
}
.code-block-auto-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(88, 166, 255, 0.15);
  color: #79c0ff;
  text-transform: lowercase;
}

.code-block-lang-dropdown {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  width: 260px;
  max-height: 280px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 100;
}
.code-block-lang-search {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--border-soft, #eee);
  font-size: 13px;
  outline: none;
}
.code-block-lang-list { max-height: 220px; overflow-y: auto; padding: 4px; }
.code-block-lang-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
}
.code-block-lang-item:hover { background: var(--surface-warm); }
.code-block-lang-item.active { background: var(--accent-soft); color: var(--accent-text); }
.code-block-lang-empty { padding: 12px; font-size: 12px; color: var(--text-3); text-align: center; }

.code-block-copy-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--code-muted);
  font-size: 11px;
  font-family: var(--font-mono);
  transition: color 0.15s, background 0.15s;
}
.code-block-copy-btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--code-text); }
.code-block-copy-btn.copied { color: #3fb950; }

.code-block-body {
  position: relative;
  min-height: 148px;
  background: var(--code-bg);
}
.code-block-body--empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 120px;
  color: var(--code-muted);
  font-size: 13px;
}
.code-block-body--empty p { margin: 0; }

.code-block-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  color: var(--code-muted);
  text-align: center;
  pointer-events: none;
  z-index: 0;
}
.code-block-empty p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  max-width: 280px;
}

.code-block-highlight,
.code-block-view {
  margin: 0;
  padding: 16px 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  tab-size: 2;
  background: var(--code-bg) !important;
  color: var(--code-text);
  overflow: auto;
}
.code-block-highlight {
  position: absolute;
  inset: 0;
  pointer-events: none;
  white-space: pre-wrap;
  word-break: break-word;
  z-index: 1;
}
.code-block-highlight code,
.code-block-view code {
  background: none !important;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

.code-block-input {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  min-height: 148px;
  padding: 16px 18px;
  border: none;
  resize: vertical;
  outline: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  tab-size: 2;
  color: var(--code-text);
  caret-color: var(--code-accent);
}
.code-block-input.has-content {
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.code-block-input::selection {
  background: rgba(56, 139, 253, 0.35);
}

.code-block--view { margin: 14px 0; }
.code-block--view .code-block-view { border: none; }

.article-body .code-block { margin: 24px 0; }
.article-body .code-block pre.code-block-view {
  margin: 0;
  border-radius: 0;
  background: var(--code-bg) !important;
  color: var(--code-text);
}

/* Подсветка синтаксиса внутри блока кода */
.code-block .hljs-keyword,
.code-block .hljs-selector-tag,
.code-block .hljs-built_in { color: #ff7b72; }
.code-block .hljs-string,
.code-block .hljs-attr { color: #a5d6ff; }
.code-block .hljs-number,
.code-block .hljs-literal { color: #79c0ff; }
.code-block .hljs-comment,
.code-block .hljs-quote { color: #8b949e; font-style: italic; }
.code-block .hljs-title,
.code-block .hljs-title.function_ { color: #d2a8ff; }
.code-block .hljs-variable,
.code-block .hljs-template-variable { color: #ffa657; }
.code-block .hljs-type,
.code-block .hljs-class .hljs-title { color: #ffa657; }
.code-block .hljs-meta,
.code-block .hljs-tag { color: #7ee787; }
.code-block .hljs-regexp { color: #a5d6ff; }
.code-block .hljs-symbol,
.code-block .hljs-bullet { color: #ffa657; }
.code-block .hljs-section,
.code-block .hljs-name { color: #7ee787; }
.code-block .hljs-attribute { color: #79c0ff; }
.code-block .hljs-params { color: var(--code-text); }
.code-block .hljs-subst { color: var(--code-text); }
.code-block .hljs-emphasis { font-style: italic; }
.code-block .hljs-strong { font-weight: 600; }

/* Цитата */
.block-quote-editor {
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 4px 0;
}
.block-quote-input {
  width: 100%; border: none; background: transparent;
  font-style: italic; font-size: 15px; line-height: 1.55;
  padding: 10px 16px; resize: vertical; outline: none;
}

/* Заметка */
.block-callout-editor {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; background: var(--accent-soft);
  border-radius: var(--r-md); border: 1px solid oklch(0.90 0.04 265);
}
.block-callout-icon { flex-shrink: 0; color: var(--accent-text); margin-top: 2px; }
.block-callout-input {
  flex: 1; border: none; background: transparent;
  font-size: 14.5px; line-height: 1.55; resize: vertical; outline: none;
}

/* Таблица */
.block-table-editor { overflow-x: auto; }
.block-table-editor table { width: 100%; border-collapse: collapse; font-size: 13px; }
.block-table-editor th, .block-table-editor td {
  border: 1px solid var(--border); padding: 0;
}
.block-table-editor th { background: var(--paper-2); }
.block-table-editor input {
  width: 100%; border: none; background: transparent;
  padding: 8px 10px; font-size: 13px; outline: none;
}
.block-table-editor input:focus { background: var(--accent-soft); }
.block-table-actions { display: flex; gap: 8px; margin-top: 8px; }

/* Общие кнопки строк */
.block-line-remove {
  width: 22px; height: 22px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: var(--r-xs); color: var(--text-4); opacity: 0;
}
.block-todo-row:hover .block-line-remove,
.block-list-row:hover .block-line-remove { opacity: 1; }
.block-line-remove:hover { background: var(--paper-2); color: var(--coral); }

.block-add-line {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 6px; padding: 6px 10px;
  font-size: 12.5px; color: var(--text-3); border-radius: var(--r-sm);
}
.block-add-line:hover { background: var(--paper-2); color: var(--text); }

.block-img-caption {
  width: 100%; margin-top: 8px; border: none; background: transparent;
  font-size: 13px; color: var(--text-2); outline: none;
  border-top: 1px solid var(--border-soft); padding-top: 8px;
}

.editor-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; margin-left: 8px; cursor: pointer; }

.editor-picker-wrap { position: relative; display: inline-block; z-index: 10; }

.editor-meta-value .editor-picker-dropdown {
  top: auto;
  bottom: calc(100% + 6px);
}

.editor-picker-dropdown {
  position: absolute;
  left: 0;
  z-index: 400;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 240px;
  max-width: 320px;
  max-height: 260px;
  overflow-y: auto;
}

.editor-picker-item {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  border: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
}

.editor-picker-item:hover { background: var(--surface-2); }
.editor-picker-item.selected { background: var(--surface-hover); }

.editor-img-block { display: flex; flex-direction: column; gap: 10px; width: 100%; }

.img-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px;
  border: 2px dashed var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--text-3);
  background: var(--surface-warm);
}

.img-upload-zone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.editor-img-preview-wrap { width: 100%; }
.editor-img-preview, .article-img { max-width: 100%; border-radius: var(--r-md); display: block; }
.article-figure { margin: 16px 0; }
.article-figure figcaption { font-size: 13px; color: var(--text-3); margin-top: 8px; text-align: center; }
.article-h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin: 20px 0 12px; }

/* Видео */
.block-video-editor { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.block-video-url-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-warm);
}
.block-video-icon { color: var(--text-3); flex-shrink: 0; }
.block-video-url {
  flex: 1; border: none; background: transparent; font-size: 13.5px; outline: none;
}
.block-video-preview, .article-video-wrap {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border-radius: var(--r-md); overflow: hidden; background: #111;
}
.block-video-preview iframe, .block-video-preview video,
.article-video-wrap iframe, .article-video-wrap video {
  position: absolute; inset: 0; width: 100%; height: 100%; border: none;
}
.block-video-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 40px; border: 2px dashed var(--border); border-radius: var(--r-md);
  color: var(--text-3); background: var(--surface-warm);
}
.block-video-hint {
  font-size: 12.5px; color: var(--coral, #e85d4c); padding: 8px 12px;
  background: #fff5f4; border-radius: var(--r-sm);
}
.video-placeholder {
  padding: 24px; background: var(--surface-2); border-radius: var(--r-md);
  color: var(--text-3); font-size: 13px;
}
.editor-img-actions { display: flex; gap: 8px; margin-top: 8px; }
.editor-cover-thumb { width: 48px; height: 32px; border-radius: 5px; overflow: hidden; cursor: pointer; border: 2px solid var(--text); flex-shrink: 0; }
.editor-cover-thumb img { width: 100%; height: 100%; object-fit: cover; }
.editor-cover-row { align-items: flex-start !important; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.article-quote {
  margin: 14px 0; padding: 12px 18px; background: var(--surface-2);
  border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; font-style: italic;
}
.article-table-inline { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 13px; }
.article-table-inline th, .article-table-inline td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.article-table-inline th { background: var(--paper-2); font-weight: 600; }
.article-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.article-toc-meta { font-size: 13px; display: flex; flex-direction: column; gap: 8px; }
.article-toc-meta .text-3 { display: block; font-size: 11px; margin-bottom: 2px; }

@media (max-width: 1100px) {
  .kb-layout { grid-template-columns: 1fr; }
  .kb-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .kb-stats { grid-template-columns: 1fr; }
  .kb-list-item { grid-template-columns: 32px 1fr; }
  .kb-list-stats, .kb-list-author, .kb-list-time { display: none; }
}

/* ============================================
   Sections — tree list
   ============================================ */

.sections-page .page-title {
  font-size: 28px;
}

.sections-tree-panel {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.sections-tree-group + .sections-tree-group {
  border-top: 1px solid var(--border-soft);
}

.sections-tree-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0 16px;
  min-height: 44px;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}

.sections-tree-row:hover {
  background: var(--paper-2);
}

.sections-tree-row.is-open {
  background: var(--paper);
}

.sections-tree-row--root {
  min-height: 48px;
  font-weight: 600;
}

.sections-tree-row--sub {
  padding-left: 36px;
  font-weight: 500;
  font-size: 14px;
}

.sections-tree-row--article {
  padding-left: 62px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-2);
  cursor: pointer;
}

.sections-tree-row--article:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.sections-tree-chevron {
  width: 16px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: var(--text-3);
}

.sections-tree-chevron--empty {
  visibility: hidden;
}

.sections-tree-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--paper-2);
  display: grid;
  place-items: center;
  color: var(--text-2);
  flex-shrink: 0;
}

.sections-tree-icon--sub {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border-soft);
}

.sections-tree-icon--article {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background: transparent;
  color: var(--text-3);
}

.sections-tree-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sections-tree-count {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-3);
  background: var(--paper-2);
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.sections-tree-status {
  font-size: 10px;
  flex-shrink: 0;
}

.sections-tree-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s;
  flex-shrink: 0;
}

.sections-tree-row:hover .sections-tree-actions,
.sections-tree-row.is-open .sections-tree-actions {
  opacity: 1;
}

.sections-tree-action {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.sections-tree-action:hover {
  background: var(--surface);
  color: var(--text);
}

.sections-tree-children {
  border-top: 1px solid var(--border-soft);
  background: var(--paper);
  padding-bottom: 4px;
}

.sections-tree-articles {
  padding-bottom: 4px;
}

.sections-tree-articles--root {
  border-top: 1px dashed var(--border-soft);
  margin-top: 2px;
  padding-top: 2px;
}

.sections-tree-articles-heading {
  padding: 8px 16px 4px 62px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.sections-tree-empty,
.sections-tree-empty-sub {
  padding: 14px 16px 14px 62px;
  font-size: 13px;
  color: var(--text-3);
}

.sections-tree-empty {
  text-align: center;
  padding: 32px 16px;
}

.sections-tree-link {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--accent-text);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sections-tree-form-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-warm);
}

.sections-tree-form-row--sub {
  padding-left: 36px;
}

.sections-tree-form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sections-inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.sections-form-input {
  flex: 1;
  min-width: 160px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font: inherit;
  font-size: 14px;
  background: var(--surface);
}

.sections-form-input:focus {
  outline: none;
  border-color: var(--accent);
}

.sections-icon-strip {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.sections-icon-strip-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.sections-icon-strip-btn.selected {
  border-color: var(--ink);
  background: var(--paper-2);
  color: var(--text);
}

.filter-pill--sub {
  font-size: 12px;
  opacity: 0.85;
}

/* ============================================
   Modal — tags management
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 19, 24, 0.45);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  width: min(480px, 100%);
  max-height: min(80vh, 640px);
  background: var(--surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--border-soft);
}

.modal-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.modal-sub {
  margin: 0;
  font-size: 13px;
  color: var(--text-3);
}

.tags-modal-add {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tags-modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font: inherit;
  font-size: 14px;
  background: var(--surface);
}

.tags-modal-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tags-modal-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tags-modal-color {
  border: 2px solid transparent;
  border-radius: var(--r-full);
  padding: 0;
  background: none;
  cursor: pointer;
}

.tags-modal-color.selected {
  border-color: var(--accent);
}

.tags-modal-color .tag {
  cursor: pointer;
  font-size: 11px;
}

.tags-modal-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 16px;
}

.tags-modal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: var(--r-md);
  transition: background 0.12s;
}

.tags-modal-row:hover {
  background: var(--surface-hover);
}

.tags-modal-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}

.tags-modal-delete {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.tags-modal-delete:hover {
  background: var(--coral-soft);
  color: var(--coral);
}

.tags-modal-empty {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-3);
  font-size: 13px;
  margin: 0;
}

/* ============================================
   UI Dialog — confirm / alert
   ============================================ */

.ui-dialog-overlay {
  z-index: 1100;
}

.ui-dialog {
  width: min(400px, 100%);
  background: var(--surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-lg);
  padding: 24px 24px 20px;
  text-align: center;
}

.ui-dialog-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
}
.ui-dialog-icon--danger {
  background: var(--coral-soft);
  color: var(--coral);
}
.ui-dialog-icon--info {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.ui-dialog-title {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text);
}

.ui-dialog-message {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-2);
}

.ui-dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.ui-dialog-actions .btn {
  min-width: 100px;
  justify-content: center;
}

.ui-dialog-btn-danger {
  background: var(--coral);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 8px 16px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, transform 0.1s;
}
.ui-dialog-btn-danger:hover {
  background: #dc3d4a;
}
.ui-dialog-btn-danger:active {
  transform: scale(0.98);
}

.ui-dialog--pick {
  width: min(440px, 100%);
  text-align: left;
}

.ui-dialog--pick .ui-dialog-icon,
.ui-dialog--pick .ui-dialog-title,
.ui-dialog--pick .ui-dialog-message {
  text-align: center;
}

.ui-dialog-search {
  width: 100%;
  margin-bottom: 12px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font: inherit;
  font-size: 14px;
  background: var(--surface);
}

.ui-dialog-pick-list {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
  text-align: left;
}

.ui-dialog-pick-empty {
  margin: 0;
  padding: 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}

.ui-dialog-pick-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color 0.12s, background 0.12s;
}

.ui-dialog-pick-item:hover {
  border-color: var(--border);
  background: var(--paper-2);
}

.ui-dialog-pick-item.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ui-dialog-pick-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.ui-dialog-pick-hint {
  font-size: 12px;
  color: var(--text-3);
}

/* ============================================
   KB Structure — 3-column WYSH layout
   ============================================ */

.kb-layout-page {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 280px;
  height: 100%;
  min-height: calc(100vh - 0px);
  background: var(--bg);
  border-top: 1px solid var(--border-soft);
}

/* ── Left: tree ── */
.kb-layout-tree {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  min-height: 0;
  overflow: hidden;
}

.kb-layout-tree-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 12px 12px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.kb-layout-tree-title {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.kb-layout-tree-actions {
  display: flex;
  gap: 2px;
}

.kb-icon-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.kb-icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.kb-layout-tree-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 16px;
}

.kb-tree-item {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 34px;
  padding-right: 8px;
  position: relative;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font: inherit;
  cursor: default;
}

.kb-tree-item--special {
  cursor: pointer;
  padding-left: 8px;
}

.kb-tree-item.is-selected {
  background: #EFF6FF;
}
.kb-tree-item.is-selected::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: #2563EB;
}

.kb-tree-chevron {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  padding: 0;
}

.kb-tree-item-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  padding: 4px 0;
}

.kb-tree-item.is-selected .kb-tree-item-btn {
  color: #1D4ED8;
  font-weight: 600;
}

.kb-tree-folder-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 6px;
}
.kb-tree-folder-icon.folder-blue { color: #3B82F6; }
.kb-tree-folder-icon.folder-amber { color: #D97706; }
.kb-tree-folder-icon.folder-violet { color: #7C3AED; }
.kb-tree-folder-icon.folder-green { color: #16A34A; }

.kb-tree-item-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kb-tree-count {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-3);
  min-width: 18px;
  text-align: right;
  flex-shrink: 0;
}

.kb-tree-drag {
  color: var(--text-4);
  opacity: 0;
  transition: opacity 0.12s;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  cursor: grab;
}
.kb-tree-item:hover .kb-tree-drag {
  opacity: 1;
}

.kb-tree-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 10px 12px;
}

.kb-tree-form {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 4px 8px 4px 0;
}

.kb-tree-input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font: inherit;
  font-size: 13px;
  background: var(--surface);
}
.kb-tree-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Center: article gallery ── */
.kb-layout-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px 32px;
  background: var(--bg);
}

.kb-main-crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 14px;
}
.kb-main-crumbs button {
  border: none;
  background: none;
  font: inherit;
  font-size: 12px;
  color: var(--text-3);
  cursor: pointer;
  padding: 0;
}
.kb-main-crumbs button:hover {
  color: var(--accent-text);
}

.kb-main-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.kb-main-title {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.025em;
  margin: 0 0 6px;
}

.kb-main-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-3);
  max-width: 520px;
  line-height: 1.5;
}

.kb-main-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.kb-main-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 180px;
  max-width: 280px;
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  color: var(--text-3);
}
.kb-main-search input {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  outline: none;
  color: var(--text);
}

.kb-main-select {
  padding: 7px 28px 7px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  background: var(--surface);
  font: inherit;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.kb-main-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 24px;
  color: var(--text-3);
  font-size: 14px;
}

.kb-main-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.kb-grid-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 14px 16px 12px;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 148px;
}
.kb-grid-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.kb-grid-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kb-grid-card-file {
  color: #3B82F6;
  display: grid;
  place-items: center;
}

.kb-grid-card-status {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-full);
  letter-spacing: 0.02em;
}
.kb-status--pub { background: #DCFCE7; color: #15803D; }
.kb-status--draft { background: #FEF3C7; color: #B45309; }
.kb-status--review { background: #E0E7FF; color: #4338CA; }
.kb-status--trash { background: #FEE2E2; color: #B91C1C; }

.kb-trash-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--r-md);
  font-size: 13px;
  line-height: 1.5;
  color: #991B1B;
}
.kb-trash-banner svg {
  flex-shrink: 0;
  margin-top: 1px;
}

.kb-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  animation: kb-toast-in 0.2s ease-out;
}
.kb-toast svg {
  color: #16A34A;
  flex-shrink: 0;
}
@keyframes kb-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.kb-grid-card-more {
  margin-left: auto;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.kb-grid-card-more:hover {
  background: var(--surface-hover);
}

.kb-grid-card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kb-grid-card-section {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-3);
  min-width: 0;
  max-width: 100%;
}
.kb-grid-card-section span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kb-grid-card-section svg {
  flex-shrink: 0;
  color: #3B82F6;
  opacity: 0.85;
}

.kb-grid-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.kb-grid-card-tag {
  font-size: 10px !important;
  padding: 2px 7px !important;
}

.kb-grid-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}

.kb-grid-card-author {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-2);
}

.kb-grid-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
}

.kb-grid-card-stats {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.kb-stat-count {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
}

.kb-stat-count--views {
  color: var(--text-3);
}

.kb-stat-count--up {
  color: #059669;
}

.kb-stat-count--down {
  color: #DC2626;
}

.kb-main-list-row .kb-grid-card-stats {
  margin-left: 4px;
  flex-shrink: 0;
}

.kb-main-list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.kb-main-list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: none;
  border-bottom: 1px solid var(--border-soft);
  background: transparent;
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  width: 100%;
  color: var(--text);
}
.kb-main-list-row:last-child { border-bottom: none; }
.kb-main-list-row:hover { background: var(--surface-hover); }
.kb-main-list-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}
.kb-main-list-title { font-weight: 500; }
.kb-main-list-section {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kb-main-list-section svg {
  flex-shrink: 0;
  color: #3B82F6;
  opacity: 0.85;
}

/* ── Right: section info ── */
.kb-layout-aside {
  background: var(--surface);
  border-left: 1px solid var(--border-soft);
  padding: 20px 18px 24px;
  overflow-y: auto;
  min-height: 0;
}

.kb-aside-title {
  font-size: 14px;
  font-weight: 650;
  margin: 0 0 16px;
}

.kb-aside-folder {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.kb-aside-folder-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #EFF6FF;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.kb-aside-folder-icon.folder-blue { color: #3B82F6; background: #EFF6FF; }
.kb-aside-folder-icon.folder-amber { color: #D97706; background: #FFFBEB; }
.kb-aside-folder-icon.folder-violet { color: #7C3AED; background: #F5F3FF; }
.kb-aside-folder-icon.folder-green { color: #16A34A; background: #F0FDF4; }

.kb-aside-folder-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.kb-aside-folder-path {
  font-size: 11px;
  color: var(--text-3);
}

.kb-aside-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.55;
  margin: 0 0 16px;
}

.kb-aside-meta {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}
.kb-aside-meta > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
}
.kb-aside-meta dt { color: var(--text-3); font-weight: 500; margin: 0; }
.kb-aside-meta dd { margin: 0; font-weight: 600; color: var(--text); }

.kb-aside-responsible {
  margin-bottom: 16px;
}
.kb-aside-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.kb-aside-person {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.kb-aside-edit {
  width: 100%;
  justify-content: center;
  margin-bottom: 20px;
}

.kb-aside-access {
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

.kb-aside-subtitle {
  font-size: 13px;
  font-weight: 650;
  margin: 0 0 6px;
}

.kb-aside-access-note {
  font-size: 12px;
  color: var(--text-3);
  margin: 0 0 12px;
}

.kb-aside-roles {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kb-aside-roles li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
}

.kb-aside-role-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--paper-2);
  color: var(--text-2);
}
.kb-aside-role-badge--write {
  background: #EFF6FF;
  color: #1D4ED8;
}

.kb-aside-access-btn {
  width: 100%;
  justify-content: center;
}

/* Add menu (shared) */
.kb-add-menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.kb-add-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: 4px;
  z-index: 20;
}

.kb-add-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}

.kb-add-menu button:hover {
  background: var(--surface-hover);
}

@media (max-width: 1200px) {
  .kb-layout-page {
    grid-template-columns: 240px minmax(0, 1fr);
  }
  .kb-layout-aside {
    display: none;
  }
}

.kb-tags-btn {
  padding: 4px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  background: var(--surface);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
}
.kb-tags-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.kb-tree-item.is-drop-target {
  background: #EFF6FF;
  outline: 1px dashed #2563EB;
  outline-offset: -1px;
}
.kb-tree-drop-line {
  height: 6px;
  margin: 1px 8px 1px 0;
  border-radius: 2px;
  transition: background 0.1s;
}
.kb-tree-drop-line.is-active {
  background: #2563EB;
  box-shadow: 0 0 0 1px #2563EB;
}
.kb-tree-item.is-dragging {
  opacity: 0.45;
}

.kb-articles-group-label {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-4);
  padding: 4px 2px 8px;
}
.kb-articles-group-label--list {
  grid-column: auto;
  padding: 12px 4px 6px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.kb-main-list > .kb-articles-group-label--list:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 4px;
}

.kb-tree-delete {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text-4);
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  flex-shrink: 0;
}
.kb-tree-item:hover .kb-tree-delete {
  opacity: 1;
}
.kb-tree-delete:hover {
  background: var(--coral-soft);
  color: var(--coral);
}

.kb-grid-card-pin {
  color: var(--accent-text);
  display: grid;
  place-items: center;
}

.kb-article-markers {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 2px;
}

.kb-marker {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}

.kb-marker--star {
  color: #EAB308;
}
.kb-marker--star svg {
  fill: #FDE047;
  stroke: #CA8A04;
  stroke-width: 1.25;
  width: 1.15em;
  height: 1.15em;
}

.kb-marker--mandatory {
  padding: 0 1px;
}

.kb-mandatory-dot {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #EF4444;
  animation: kb-mandatory-blink 1.1s ease-in-out infinite;
}

@keyframes kb-mandatory-blink {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55);
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    box-shadow: 0 0 0 5px rgba(239, 68, 68, 0);
    transform: scale(0.92);
  }
}

.kb-grid-card--mandatory {
  border-color: rgba(239, 68, 68, 0.22);
}
.kb-grid-card--mandatory:hover {
  border-color: rgba(239, 68, 68, 0.35);
}

.kb-main-list-row .kb-article-markers {
  margin-left: auto;
  margin-right: 4px;
}

.kb-card-menu {
  position: fixed;
  z-index: 500;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
}

.kb-card-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.kb-card-menu-item:hover {
  background: var(--surface-hover);
}
.kb-card-menu-item--danger {
  color: var(--coral);
}
.kb-card-menu-item--danger:hover {
  background: var(--coral-soft);
}

.kb-main-list-row-wrap {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-soft);
}
.kb-main-list-row-wrap:last-child {
  border-bottom: none;
}
.kb-main-list-row-wrap .kb-main-list-row {
  border-bottom: none;
  flex: 1;
}
.kb-main-list-more {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-right: 8px;
  border-radius: var(--r-sm);
}
.kb-main-list-more:hover {
  background: var(--surface-hover);
}

.kb-access-modal {
  width: min(520px, 100%);
}
.kb-access-tabs {
  display: flex;
  gap: 4px;
  padding: 0 20px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.kb-access-tabs button {
  padding: 6px 12px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
}
.kb-access-tabs button.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.kb-access-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px 12px;
}
.kb-access-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: var(--r-md);
  cursor: pointer;
}
.kb-access-row:hover {
  background: var(--surface-hover);
}
.kb-access-row input {
  flex-shrink: 0;
}
.kb-access-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.kb-access-row-sub {
  font-size: 11px;
  color: var(--text-3);
}
.kb-access-dept-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--paper-2);
  display: grid;
  place-items: center;
  color: var(--text-3);
  flex-shrink: 0;
}
.kb-access-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border-soft);
}

.kb-access-picker-hint {
  margin: 0 0 10px;
  padding: 0 4px;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.45;
}

.kb-access-picker--compact .kb-access-list {
  max-height: 160px;
}

.kb-access-list--compact {
  max-height: 160px;
}

.kb-tree-folder-create {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 8px 12px;
  margin: 4px 8px 8px 0;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

.kb-tree-form-actions {
  display: flex;
  gap: 6px;
}

.kb-aside-access-summary {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
}
.kb-aside-access-summary li {
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 768px) {
  .kb-layout-page {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .kb-layout-tree {
    max-height: 220px;
    border-right: none;
    border-bottom: 1px solid var(--border-soft);
  }
}
