/* Knowledge Base design system */
:root {
  --kb-text: #172033;
  --kb-text-secondary: #66758D;
  --kb-text-muted: #8A98AD;
  --kb-accent: #1677FF;
  --kb-accent-soft: #EEF5FF;
  --kb-border: #E4EAF2;
  --kb-bg: #FFFFFF;
  --kb-bg-soft: #F8FAFC;
  --kb-danger: #c0392b;
  --kb-radius-sm: 8px;
  --kb-radius-md: 10px;
  --kb-radius-lg: 12px;
  --kb-radius-xl: 16px;
  --kb-shadow-menu: 0 12px 32px rgba(23, 32, 51, 0.12);
  --kb-shadow-modal: 0 24px 56px rgba(23, 32, 51, 0.18);
  --kb-header-h: 70px;
  --kb-sidebar-w: 328px;
  --kb-sidebar-collapsed-w: 68px;
  --kb-details-w: 312px;
  --text: var(--kb-text);
  --text-soft: var(--kb-text-secondary);
  --accent: var(--kb-accent);
  --panel: var(--kb-bg);
  --panel-strong: var(--kb-bg-soft);
  --line: var(--kb-border);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: Manrope, system-ui, -apple-system, sans-serif;
  background: var(--kb-bg);
  color: var(--kb-text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body.is-modal-open {
  overflow: hidden;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.primary,
.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--kb-radius-sm);
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.primary {
  border: 0;
  background: var(--kb-accent);
  color: #fff;
}

.primary:hover { background: #0f68e8; }
.primary:disabled { opacity: 0.55; cursor: not-allowed; }

.secondary {
  border: 1px solid var(--kb-border);
  background: var(--kb-bg);
  color: var(--kb-text);
}

.secondary:hover { background: var(--kb-bg-soft); }

.hub-boot {
  display: grid;
  place-items: center;
  min-height: 100vh;
  color: var(--kb-text-secondary);
}

.hub-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--kb-bg-soft);
}

.auth-panel {
  width: min(100%, 420px);
  background: var(--kb-bg);
  border: 1px solid var(--kb-border);
  border-radius: var(--kb-radius-lg);
  padding: 28px;
  box-shadow: var(--kb-shadow-menu);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-brand h1,
.hub-brand-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hub-subtitle {
  margin: 8px 0 20px;
  color: var(--kb-text-secondary);
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--kb-text-secondary);
}

.field input {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--kb-border);
  border-radius: var(--kb-radius-sm);
  background: var(--kb-bg);
}

.field input:focus {
  outline: none;
  border-color: #9ec1ff;
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
}

.error, .hub-banner-error {
  color: var(--kb-danger);
  font-size: 13px;
}

.hub-banner-error {
  padding: 8px 20px;
  border-bottom: 1px solid #f5c2c0;
  background: #fff5f5;
}

.hub-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: var(--kb-header-h) minmax(0, 1fr);
  background: var(--kb-bg);
}

.hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: var(--kb-header-h);
  padding: 0 20px;
  border-bottom: 1px solid var(--kb-border);
  background: var(--kb-bg);
  z-index: 20;
  position: relative;
}

.hub-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.hub-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--kb-accent);
  background: var(--kb-accent-soft);
  flex: 0 0 auto;
  overflow: hidden;
}

.hub-logo img {
  width: 22px;
  height: 22px;
  display: block;
  object-fit: contain;
}

.auth-brand .hub-logo img {
  width: 26px;
  height: 26px;
}

.hub-global-search {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 420px));
  max-width: 560px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px 0 14px;
  border: 1px solid var(--kb-border);
  border-radius: 999px;
  background: var(--kb-bg-soft);
}

.hub-global-search:focus-within {
  border-color: #9ec1ff;
  background: var(--kb-bg);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.1);
}

.hub-global-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--kb-text);
}

.hub-global-search input[type="search"]::-webkit-search-decoration,
.hub-global-search input[type="search"]::-webkit-search-cancel-button,
.hub-global-search input[type="search"]::-webkit-search-results-button,
.hub-global-search input[type="search"]::-webkit-search-results-decoration {
  display: none;
  -webkit-appearance: none;
}

.hub-global-search-kbd {
  flex: 0 0 auto;
  padding: 2px 7px;
  border: 1px solid var(--kb-border);
  border-radius: 6px;
  background: var(--kb-bg);
  color: var(--kb-text-muted);
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
}

.hub-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hub-icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--kb-radius-sm);
  background: transparent;
  color: var(--kb-text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hub-icon-btn:hover {
  background: var(--kb-bg-soft);
  color: var(--kb-text);
}

.hub-user-menu { position: relative; }

.hub-user-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 4px 8px 4px 4px;
  border: 0;
  border-radius: 999px;
  background: transparent;
}

.hub-user-trigger:hover { background: var(--kb-bg-soft); }

.hub-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dbeafe;
  color: var(--kb-accent);
  font-size: 12px;
  font-weight: 700;
  flex: 0 0 auto;
  object-fit: cover;
}

.hub-avatar--photo {
  padding: 0;
  background: var(--kb-bg-soft);
  display: block;
}

.hub-user-meta {
  display: grid;
  text-align: left;
  line-height: 1.2;
}

.hub-user-name {
  font-size: 13px;
  font-weight: 600;
}

.hub-user-role {
  font-size: 11px;
  color: var(--kb-text-muted);
}

.hub-user-chevron {
  color: var(--kb-text-muted);
  font-size: 11px;
}

.hub-user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  padding: 6px;
  border: 1px solid var(--kb-border);
  border-radius: var(--kb-radius-md);
  background: var(--kb-bg);
  box-shadow: var(--kb-shadow-menu);
  z-index: 50;
}

.hub-user-dropdown-item {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 7px;
  background: transparent;
  padding: 10px 12px;
  color: var(--kb-text);
}

.hub-user-dropdown-item:hover { background: var(--kb-bg-soft); }

.hub-main {
  min-height: 0;
  overflow: hidden;
}

/* Layout */
.knowledge-layout {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-columns: var(--kb-sidebar-w) minmax(0, 1fr) var(--kb-details-w);
  transition: grid-template-columns 0.22s ease;
  background: var(--kb-bg);
  overflow: hidden;
}

.knowledge-layout.is-resizing {
  transition: none;
  user-select: none;
}

.knowledge-layout.is-resizing .knowledge-panel-toggle {
  transition: none;
}

body.is-kb-resizing {
  cursor: col-resize;
  user-select: none;
}

.knowledge-resize-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  z-index: 11;
  cursor: col-resize;
  touch-action: none;
}

.knowledge-resize-handle::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: transparent;
  transition: background 0.15s ease;
}

.knowledge-resize-handle:hover::after,
.knowledge-resize-handle.is-active::after {
  background: var(--kb-accent);
}

.knowledge-resize-handle--left {
  left: calc(var(--kb-sidebar-w) - 4px);
}

.knowledge-resize-handle--right {
  right: calc(var(--kb-details-w) - 4px);
}

.knowledge-panel-toggle {
  position: absolute;
  top: 18px;
  z-index: 12;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--kb-border);
  border-radius: 50%;
  background: var(--kb-bg);
  color: var(--kb-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(23, 32, 51, 0.1);
  transition:
    left 0.22s ease,
    right 0.22s ease,
    color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
}

.knowledge-panel-toggle:hover {
  color: var(--kb-text);
  background: var(--kb-bg);
  box-shadow: 0 4px 12px rgba(23, 32, 51, 0.14);
}

/* Overlap the sidebar | content divider */
.knowledge-panel-toggle--left {
  left: calc(var(--kb-sidebar-w) - 13px);
}

.knowledge-layout.is-sidebar-collapsed .knowledge-panel-toggle--left {
  left: calc(var(--kb-sidebar-collapsed-w) - 13px);
}

/* Overlap the content | details divider */
.knowledge-panel-toggle--right {
  right: calc(var(--kb-details-w) - 13px);
}

.knowledge-layout.is-details-collapsed .knowledge-content {
  border-right: 1px solid var(--kb-border);
}

.knowledge-panel-toggle--right.is-collapsed,
.knowledge-layout.is-details-collapsed .knowledge-panel-toggle--right {
  /* Keep fully visible on the right edge when the panel is closed */
  right: 13px;
}

.knowledge-layout.is-sidebar-collapsed {
  grid-template-columns: var(--kb-sidebar-collapsed-w) minmax(0, 1fr) var(--kb-details-w);
}

.knowledge-layout.is-details-collapsed {
  grid-template-columns: var(--kb-sidebar-w) minmax(0, 1fr);
}

.knowledge-layout.is-sidebar-collapsed.is-details-collapsed {
  grid-template-columns: var(--kb-sidebar-collapsed-w) minmax(0, 1fr);
}

.knowledge-sidebar,
.knowledge-content,
.knowledge-details {
  min-width: 0;
  min-height: 0;
  background: var(--kb-bg);
}

.knowledge-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--kb-border);
  padding: 14px 12px;
  overflow: hidden;
  transition: padding 0.22s ease;
}

.knowledge-layout.is-sidebar-collapsed .knowledge-sidebar {
  padding: 12px 8px;
  align-items: center;
}

.knowledge-sidebar-top {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  flex: 0 0 auto;
}

.knowledge-sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.knowledge-layout.is-sidebar-collapsed .knowledge-sidebar-actions {
  grid-template-columns: 1fr;
}

.knowledge-create-wrap { position: relative; }

.knowledge-create-toggle,
.knowledge-upload-btn {
  width: 100%;
  min-height: 38px;
  border-radius: var(--kb-radius-sm);
  font-weight: 600;
  font-size: 13px;
}

.knowledge-create-toggle {
  border: 0;
  background: var(--kb-accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.knowledge-upload-btn {
  border: 1px solid var(--kb-border);
  background: var(--kb-bg);
  color: var(--kb-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

.knowledge-upload-btn input { display: none; }
.knowledge-upload-btn.is-busy { opacity: 0.6; pointer-events: none; }

.knowledge-layout.is-sidebar-collapsed .knowledge-sidebar-footer-text,
.knowledge-layout.is-sidebar-collapsed .knowledge-sidebar-label,
.knowledge-layout.is-sidebar-collapsed .knowledge-create-label,
.knowledge-layout.is-sidebar-collapsed .knowledge-tree-label,
.knowledge-layout.is-sidebar-collapsed .knowledge-item-menu,
.knowledge-layout.is-sidebar-collapsed .knowledge-storage-link {
  display: none;
}

.knowledge-create-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--kb-border);
  border-radius: var(--kb-radius-md);
  background: var(--kb-bg);
  box-shadow: var(--kb-shadow-menu);
  display: grid;
  gap: 2px;
  z-index: 40;
}

.knowledge-create-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}

.knowledge-create-menu-item:hover { background: var(--kb-accent-soft); }
.knowledge-create-menu-icon { width: 18px; height: 18px; color: var(--kb-text-muted); }

.knowledge-tree-shell {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 2px 0 8px;
}

.knowledge-tree-node { margin-bottom: 2px; }

.knowledge-tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  margin-left: calc(var(--kb-depth, 0) * 14px);
  border-radius: var(--kb-radius-sm);
}

.knowledge-tree-row:hover { background: var(--kb-bg-soft); }

.knowledge-tree-folder,
.knowledge-tree-document {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--kb-radius-sm);
  background: transparent;
  text-align: left;
  color: var(--kb-text);
}

.knowledge-tree-folder.active,
.knowledge-tree-document.active {
  background: var(--kb-accent-soft);
  color: var(--kb-accent);
}

.knowledge-tree-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
}

.knowledge-tree-toggle {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--kb-text-secondary);
  flex: 0 0 auto;
}

.knowledge-tree-toggle svg,
.knowledge-tree-icon svg { width: 18px; height: 18px; display: block; }

.knowledge-tree-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--kb-text-secondary);
  flex: 0 0 auto;
}
.knowledge-tree-folder.active + .knowledge-item-menu .knowledge-item-menu-btn,
.knowledge-tree-row:has(.active) .knowledge-tree-toggle { color: var(--kb-accent); }

.knowledge-tree-rename-input {
  flex: 1;
  min-width: 0;
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid #9ec1ff;
  border-radius: 7px;
  outline: none;
}

.knowledge-tree-row.kb-drop-before { box-shadow: inset 0 2px 0 var(--kb-accent); }
.knowledge-tree-row.kb-drop-after { box-shadow: inset 0 -2px 0 var(--kb-accent); }
.knowledge-tree-row.kb-drop-inside .knowledge-tree-folder {
  background: var(--kb-accent-soft);
  color: var(--kb-accent);
}
.knowledge-tree-folder.kb-dragging { opacity: 0.45; }
.knowledge-tree-folder[draggable="true"] { cursor: grab; }

.knowledge-sidebar-footer {
  flex: 0 0 auto;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--kb-border);
}

.knowledge-storage-card {
  padding: 10px;
  border: 1px solid var(--kb-border);
  border-radius: var(--kb-radius-md);
  background: var(--kb-bg-soft);
}

.knowledge-storage-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--kb-text-secondary);
  margin-bottom: 6px;
}

.knowledge-storage-meta {
  font-size: 12px;
  color: var(--kb-text-muted);
  margin-bottom: 8px;
}

.knowledge-storage-bar {
  height: 4px;
  border-radius: 999px;
  background: #e8eef6;
  overflow: hidden;
  margin-bottom: 8px;
}

.knowledge-storage-bar > span {
  display: block;
  height: 100%;
  background: var(--kb-accent);
  border-radius: inherit;
}

.knowledge-storage-link {
  border: 0;
  background: transparent;
  color: var(--kb-accent);
  font-size: 12px;
  font-weight: 600;
  padding: 0;
}

.knowledge-storage-hint {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--kb-text-muted);
}

.knowledge-search-results { display: grid; gap: 4px; }
.knowledge-search-result {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--kb-radius-sm);
  background: transparent;
  text-align: left;
}
.knowledge-search-result:hover { background: var(--kb-accent-soft); }
.knowledge-search-result-icon { width: 18px; height: 18px; color: var(--kb-accent); }
.knowledge-search-result-icon svg,
.knowledge-obj-icon svg { width: 100%; height: 100%; display: block; }
.knowledge-search-empty,
.support-empty,
.support-loading {
  padding: 16px 8px;
  color: var(--kb-text-muted);
  font-size: 13px;
}

/* Content */
.knowledge-content {
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding: 18px 22px 28px;
  position: relative;
}

.knowledge-workspace { display: grid; gap: 14px; }

.knowledge-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--kb-text-muted);
}

.knowledge-breadcrumb {
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  font: inherit;
}

.knowledge-breadcrumb--link { color: var(--kb-text-secondary); }
.knowledge-breadcrumb--link:hover { color: var(--kb-accent); }
.knowledge-breadcrumb--current { color: var(--kb-text-muted); }
.knowledge-breadcrumb-separator { color: #c0cad8; }

.knowledge-workspace-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.knowledge-workspace-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.knowledge-workspace-title-row h2,
.knowledge-workspace-title-row h3 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.knowledge-icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--kb-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.knowledge-icon-btn:hover { background: var(--kb-bg-soft); color: var(--kb-text); }
.knowledge-icon-btn.is-active { color: #f5a524; }

.knowledge-workspace-meta {
  margin-top: 6px;
  color: var(--kb-text-secondary);
  font-size: 13px;
}

.knowledge-workspace-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.knowledge-view-toggle {
  display: inline-flex;
  border: 1px solid var(--kb-border);
  border-radius: var(--kb-radius-sm);
  overflow: hidden;
}

.knowledge-view-toggle button {
  width: 34px;
  height: 32px;
  border: 0;
  background: var(--kb-bg);
  color: var(--kb-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.knowledge-view-toggle button.is-active {
  background: var(--kb-accent-soft);
  color: var(--kb-accent);
}

.knowledge-doc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: var(--kb-text-secondary);
  font-size: 13px;
}

.knowledge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--kb-accent-soft);
  color: var(--kb-accent);
  font-size: 12px;
  font-weight: 600;
}

.knowledge-author {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.knowledge-author-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  background: #e0e7ff;
  color: #4338ca;
}

/* Object table */
.knowledge-table-wrap {
  border: 1px solid var(--kb-border);
  border-radius: var(--kb-radius-lg);
  overflow: auto;
  background: var(--kb-bg);
}

.knowledge-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.knowledge-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--kb-text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--kb-border);
  background: var(--kb-bg);
  white-space: nowrap;
}

.knowledge-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--kb-border);
  vertical-align: middle;
  font-size: 13px;
  color: var(--kb-text);
}

.knowledge-table tr:last-child td { border-bottom: 0; }
.knowledge-table tbody tr:hover td { background: #f5f8fc; }
.knowledge-table tbody tr.is-selected td { background: var(--kb-accent-soft); }

.knowledge-table-check { width: 36px; }
.knowledge-table-actions { width: 44px; text-align: right; }

.knowledge-obj-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.knowledge-obj-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: var(--kb-accent);
  background: var(--kb-accent-soft);
}

.knowledge-obj-icon--folder { background: #e8f1ff; }
.knowledge-obj-icon--file { background: #eef2ff; color: #4f46e5; }

.knowledge-obj-main { min-width: 0; }
.knowledge-obj-title {
  display: block;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.knowledge-obj-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  color: var(--kb-text-muted);
  font-size: 12px;
}

.knowledge-obj-link {
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  color: inherit;
  width: 100%;
}

.knowledge-obj-link:hover .knowledge-obj-title { color: var(--kb-accent); }

.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.knowledge-grid-card {
  border: 1px solid var(--kb-border);
  border-radius: var(--kb-radius-lg);
  padding: 14px;
  background: var(--kb-bg);
  text-align: left;
  display: grid;
  gap: 10px;
}

.knowledge-grid-card:hover { background: var(--kb-bg-soft); }
.knowledge-grid-card.is-selected { border-color: #9ec1ff; background: var(--kb-accent-soft); }

.knowledge-empty-state {
  padding: 36px 20px;
  text-align: center;
  color: var(--kb-text-muted);
  border: 1px dashed var(--kb-border);
  border-radius: var(--kb-radius-lg);
  background: var(--kb-bg-soft);
}

/* Document */
.knowledge-document-title-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--kb-border);
  border-radius: var(--kb-radius-sm);
  padding: 0 12px;
  font-size: 24px;
  font-weight: 700;
}

.knowledge-document-body {
  border: 1px solid var(--kb-border);
  border-radius: var(--kb-radius-lg);
  background: var(--kb-bg);
  overflow: hidden;
}

.knowledge-document-content,
.knowledge-editor-shell {
  min-height: 420px;
  background: var(--kb-bg);
  color: var(--kb-text);
}

.knowledge-document-content {
  padding: 28px 32px;
  line-height: 1.7;
  max-width: 920px;
}

.knowledge-editor-textarea {
  min-height: 420px;
  width: 100%;
  padding: 16px;
  border: 0;
  background: transparent;
}

.knowledge-editor-shell .tox-tinymce {
  border: 0;
  border-radius: var(--kb-radius-lg);
}

.knowledge-editor-shell .tox .tox-editor-header {
  position: sticky !important;
  top: 0;
  z-index: 120;
  background: var(--kb-bg-soft);
  box-shadow: 0 4px 12px rgba(23, 32, 51, 0.06);
}

.knowledge-document-content p,
.knowledge-editor-shell p { margin: 0 0 16px; }
.knowledge-document-content h2,
.knowledge-editor-shell h2 { margin: 20px 0 12px; font-size: 24px; line-height: 1.2; }
.knowledge-document-content h3,
.knowledge-editor-shell h3 { margin: 18px 0 10px; font-size: 19px; line-height: 1.3; }
.knowledge-document-content ul,
.knowledge-document-content ol,
.knowledge-editor-shell ul,
.knowledge-editor-shell ol { margin: 0 0 12px 20px; }
.knowledge-document-content a,
.knowledge-editor-shell a { color: var(--kb-accent); text-underline-offset: 2px; }
.knowledge-document-content table {
  width: 100%;
  margin: 0 0 16px;
  border-collapse: collapse;
}
.knowledge-document-content th,
.knowledge-document-content td {
  border: 1px solid var(--kb-border);
  padding: 8px 10px;
  vertical-align: top;
}
.knowledge-document-content th {
  background: var(--kb-bg-soft);
  font-weight: 600;
}
.knowledge-document-content img,
.knowledge-document-content video,
.knowledge-document-content iframe {
  max-width: 100%;
  height: auto;
}

.knowledge-inline-document-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  text-decoration: none;
  color: inherit;
}

.knowledge-document-attachments {
  margin-top: 8px;
}

/* Details */
.knowledge-details {
  border-left: 1px solid var(--kb-border);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: width 0.22s ease, opacity 0.22s ease;
}

.knowledge-details-inner {
  height: 100%;
  overflow: auto;
  padding: 18px 16px 20px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.knowledge-details-head {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.knowledge-details-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--kb-accent-soft);
  color: var(--kb-accent);
}

.knowledge-details-icon svg { width: 26px; height: 26px; }

.knowledge-details-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
}

.knowledge-details-sub {
  margin-top: 4px;
  color: var(--kb-text-muted);
  font-size: 12px;
}

.knowledge-details-section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--kb-text-muted);
  margin-bottom: 8px;
}

.knowledge-details-list {
  display: grid;
  gap: 10px;
}

.knowledge-details-row {
  display: grid;
  gap: 2px;
}

.knowledge-details-label {
  font-size: 12px;
  color: var(--kb-text-muted);
}

.knowledge-details-value {
  font-size: 13px;
  color: var(--kb-text);
}

.knowledge-details-placeholder {
  color: var(--kb-text-muted);
  font-size: 13px;
}

.knowledge-details-empty {
  color: var(--kb-text-muted);
  font-size: 13px;
  padding: 24px 8px;
}

/* Menus */
.knowledge-item-menu {
  position: relative;
  flex: 0 0 auto;
}

.knowledge-item-menu-btn {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--kb-text-secondary);
  opacity: 1;
  transition: background 0.15s ease, color 0.15s ease;
}

.knowledge-item-menu.open .knowledge-item-menu-btn,
.knowledge-item-menu-btn:hover {
  background: var(--kb-bg-soft);
  color: var(--kb-text);
}

.knowledge-item-menu-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  padding: 6px;
  border: 1px solid var(--kb-border);
  border-radius: var(--kb-radius-md);
  background: var(--kb-bg);
  box-shadow: var(--kb-shadow-menu);
  z-index: 60;
  display: grid;
  gap: 2px;
}

/* Escape overflow:auto parents (folder/file tables, side panels). */
.knowledge-item-menu-dropdown.is-fixed {
  position: fixed;
  right: auto;
  z-index: 420;
}

.knowledge-item-menu-item {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 7px;
  background: transparent;
  padding: 9px 10px;
  font-size: 13px;
}

.knowledge-item-menu-item:hover { background: var(--kb-bg-soft); }
.knowledge-item-menu-item.danger { color: var(--kb-danger); }

/* Access modal — Google Docs-like share dialog */
.knowledge-access-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 330;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(32, 33, 36, 0.48);
}

.knowledge-access-modal {
  width: min(100%, 512px);
  max-height: 88vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 0;
  border-radius: 8px;
  background: var(--kb-bg);
  box-shadow: 0 24px 38px rgba(0, 0, 0, 0.14), 0 9px 46px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.knowledge-access-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 8px;
}

.knowledge-access-modal-header h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: #202124;
}

.knowledge-access-modal-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #5f6368;
  font-size: 24px;
  line-height: 1;
}

.knowledge-access-modal-close:hover {
  background: #f1f3f4;
}

.knowledge-access-modal-body {
  min-height: 0;
  overflow: auto;
  padding: 8px 22px 8px;
}

.knowledge-access-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px 18px;
}

.knowledge-access-box {
  display: grid;
  gap: 22px;
}

.knowledge-access-search-wrap {
  position: relative;
}

.knowledge-access-search {
  display: grid;
  gap: 0;
  position: relative;
  min-height: 56px;
  padding: 18px 14px 8px;
  border: 1px solid #dadce0;
  border-radius: 4px;
  background: var(--kb-bg);
}

.knowledge-access-search:focus-within {
  border-color: var(--kb-accent);
  box-shadow: inset 0 0 0 1px var(--kb-accent);
}

.knowledge-access-search-label {
  position: absolute;
  left: 12px;
  top: -8px;
  padding: 0 4px;
  background: var(--kb-bg);
  color: var(--kb-accent);
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.knowledge-access-search:focus-within .knowledge-access-search-label,
.knowledge-access-search.is-filled .knowledge-access-search-label {
  opacity: 1;
}

.knowledge-access-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
  color: #202124;
}

.knowledge-access-search input[type="search"]::-webkit-search-decoration,
.knowledge-access-search input[type="search"]::-webkit-search-cancel-button {
  display: none;
  -webkit-appearance: none;
}

.knowledge-access-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 5;
  max-height: 240px;
  overflow: auto;
  padding: 6px 0;
  border: 1px solid #dadce0;
  border-radius: 8px;
  background: var(--kb-bg);
  box-shadow: 0 8px 24px rgba(60, 64, 67, 0.18);
}

.knowledge-access-suggestions--empty {
  padding: 14px 16px;
  color: #5f6368;
  font-size: 13px;
}

.knowledge-access-suggestion {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  text-align: left;
}

.knowledge-access-suggestion:hover {
  background: #f1f3f4;
}

.knowledge-access-suggestion.is-group .knowledge-access-user-name {
  font-weight: 600;
}

.knowledge-access-avatar.is-group {
  font-size: 16px;
}

.knowledge-access-section {
  display: grid;
  gap: 10px;
}

.knowledge-access-section-title {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: #202124;
}

.knowledge-access-people {
  display: grid;
  gap: 2px;
}

.knowledge-access-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 8px 2px;
  border-radius: 8px;
}

.knowledge-access-row:hover {
  background: #f8f9fa;
}

.knowledge-access-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

.knowledge-access-user {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.knowledge-access-user-name {
  font-size: 14px;
  font-weight: 500;
  color: #202124;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.knowledge-access-user-email {
  font-size: 12px;
  color: #5f6368;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.knowledge-access-owner-badge {
  color: #5f6368;
  font-size: 14px;
  padding-right: 4px;
}

.knowledge-access-role {
  min-height: 36px;
  min-width: 128px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #3c4043;
  font-size: 14px;
  text-align: right;
}

.knowledge-access-role:hover {
  background: #e8f0fe;
}

.knowledge-access-note {
  padding: 10px 4px 4px;
  color: #5f6368;
  font-size: 13px;
  line-height: 1.4;
}

.knowledge-access-general {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 4px 2px;
}

.knowledge-access-general-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e8f0fe;
  color: #1967d2;
  font-size: 18px;
}

.knowledge-access-general-icon.is-open {
  background: #e6f4ea;
  color: #137333;
}

.knowledge-access-general-main {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding-top: 2px;
}

.knowledge-access-general-select {
  width: fit-content;
  max-width: 100%;
  min-height: 28px;
  padding: 0 22px 0 0;
  border: 0;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235f6368' d='M1.4.6 6 5.2 10.6.6 12 2 6 8 0 2z'/%3E%3C/svg%3E") no-repeat right center;
  color: #202124;
  font-size: 14px;
  font-weight: 500;
  appearance: none;
}

.knowledge-access-general-hint {
  margin: 0;
  color: #5f6368;
  font-size: 12px;
  line-height: 1.4;
}

.knowledge-access-general-role {
  color: #5f6368;
  font-size: 14px;
  padding-top: 6px;
  padding-right: 4px;
}

.knowledge-access-general-role-select {
  min-height: 36px;
  min-width: 120px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #3c4043;
  font-size: 14px;
  text-align: right;
}

.knowledge-access-general-role-select:hover {
  background: #e8f0fe;
}

.knowledge-public-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--kb-bg, #fff);
}

.knowledge-public-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid #e8eaed;
  background: #f8f9fa;
  color: #5f6368;
  font-size: 13px;
}

.knowledge-public-login {
  color: #1967d2;
  font-weight: 500;
  text-decoration: none;
}

.knowledge-public-main {
  min-height: 0;
  overflow: auto;
  padding: 20px 24px 40px;
}

.knowledge-access-copy-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid #dadce0;
  border-radius: 999px;
  background: transparent;
  color: #1967d2;
  font-size: 14px;
  font-weight: 500;
}

.knowledge-access-copy-link:hover {
  background: #f6fafe;
  border-color: #c6dafc;
}

.knowledge-access-done {
  min-height: 40px;
  min-width: 96px;
  padding: 0 24px;
  border-radius: 999px;
  font-weight: 500;
}

.knowledge-inline-error {
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid #f5c2c0;
  border-radius: 8px;
  background: #fff5f5;
  color: var(--kb-danger);
  font-size: 13px;
}

/* Numeric dialog */
.knowledge-numeric-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 320;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(4px);
}

.knowledge-numeric-dialog {
  width: min(100%, 420px);
  border: 1px solid var(--kb-border);
  border-radius: var(--kb-radius-lg);
  background: var(--kb-bg);
  box-shadow: var(--kb-shadow-modal);
  padding: 18px;
}

.knowledge-numeric-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.knowledge-numeric-dialog-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.knowledge-numeric-dialog-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: var(--kb-bg-soft);
  color: var(--kb-text-muted);
  font-size: 22px;
}

.knowledge-numeric-dialog-form { display: grid; gap: 14px; }
.knowledge-numeric-dialog-message { color: var(--kb-text-secondary); font-size: 14px; }
.knowledge-numeric-dialog-field { display: grid; gap: 7px; }
.knowledge-numeric-dialog-field span { color: var(--kb-text-secondary); font-size: 13px; font-weight: 600; }
.knowledge-numeric-dialog-field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--kb-border);
  border-radius: var(--kb-radius-sm);
  padding: 0 12px;
  outline: none;
}
.knowledge-numeric-dialog-error { color: var(--kb-danger); font-size: 13px; }
.knowledge-numeric-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* Files leftover helpers */
.knowledge-files-rename-input {
  width: 100%;
  min-height: 34px;
  border: 1px solid #9ec1ff;
  border-radius: 7px;
  padding: 0 8px;
}

.knowledge-files-hint {
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff8e8;
  color: #8a6d1d;
  font-size: 12px;
}

.knowledge-callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid #dfe9f5;
  background: #eaf5ff;
}

.knowledge-callout__icon {
  width: 24px;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border: 1.5px solid currentColor;
}

.knowledge-callout--info { background: #eaf5ff; border-color: #d7e9ff; }
.knowledge-callout--info .knowledge-callout__icon { color: #1677ff; }
.knowledge-callout--success { background: #dcf9ec; border-color: #bcefd8; }
.knowledge-callout--success .knowledge-callout__icon { color: #2ba86f; }
.knowledge-callout--danger { background: #fde9ec; border-color: #f6ccd5; }
.knowledge-callout--danger .knowledge-callout__icon { color: #e05a73; }
.knowledge-callout--warning { background: #fff4cf; border-color: #f7e5a6; }
.knowledge-callout--warning .knowledge-callout__icon { color: #d3a126; }

.knowledge-toggle-block {
  margin: 0 0 12px;
  border: 1px solid var(--kb-border);
  border-radius: 8px;
  background: var(--kb-bg-soft);
  overflow: hidden;
}

.knowledge-toggle-block summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 600;
}

.knowledge-toggle-block > div { padding: 0 12px 12px; }

@media (max-width: 1100px) {
  .knowledge-layout,
  .knowledge-layout.is-sidebar-collapsed {
    grid-template-columns: var(--kb-sidebar-collapsed-w) minmax(0, 1fr);
  }
  .knowledge-layout.is-details-collapsed,
  .knowledge-layout.is-sidebar-collapsed.is-details-collapsed {
    grid-template-columns: var(--kb-sidebar-collapsed-w) minmax(0, 1fr);
  }
  .knowledge-details { display: none; }
  .knowledge-layout .knowledge-content {
    border-right: 1px solid var(--kb-border);
  }
  .knowledge-panel-toggle--right,
  .knowledge-panel-toggle--right.is-collapsed,
  .knowledge-layout.is-details-collapsed .knowledge-panel-toggle--right {
    right: 13px;
  }
  .knowledge-resize-handle {
    display: none;
  }
  .hub-user-meta { display: none; }
}

@media (max-width: 768px) {
  .hub-header {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 12px;
    gap: 10px;
  }
  .hub-global-search {
    position: static;
    transform: none;
    order: 3;
    width: 100%;
    max-width: none;
    flex: 1 1 100%;
  }
  .hub-global-search-kbd { display: none; }
  .knowledge-content { padding: 14px 12px 20px; }
  .knowledge-workspace-title-row h2 { font-size: 22px; }
  .knowledge-access-modal { width: 100%; max-height: 94vh; border-radius: 12px; }
  .knowledge-access-row,
  .knowledge-access-general {
    grid-template-columns: 40px minmax(0, 1fr);
  }
  .knowledge-access-role,
  .knowledge-access-owner-badge,
  .knowledge-access-general-role,
  .knowledge-access-general-role-select {
    grid-column: 2;
    justify-self: start;
    text-align: left;
  }
  .knowledge-access-modal-actions {
    flex-wrap: wrap;
  }
}

/* File preview (preserved) */
.knowledge-file-preview {
  margin: 0 0 12px;
  display: grid;
  gap: 10px;
}

.knowledge-file-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.knowledge-file-preview-heading {
  min-width: 0;
  flex: 1;
}

.knowledge-file-preview-heading .knowledge-section-title {
  margin-bottom: 2px;
}

.knowledge-file-preview-title {
  font-size: 14px;
  font-weight: 600;
  color: #1f2a37;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.knowledge-file-preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.knowledge-file-preview-toolbar .secondary,
.knowledge-file-preview-toolbar a.secondary {
  min-height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 13px;
}

.knowledge-file-preview-stage {
  min-height: 280px;
  max-height: min(62vh, 720px);
  border: 1px solid var(--kb-border);
  border-radius: 10px;
  background: #0f1720;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
}

.knowledge-file-preview-stage:fullscreen,
.knowledge-file-preview-stage:-webkit-full-screen {
  max-height: none;
  min-height: 100%;
  border-radius: 0;
  background: #000;
}

.knowledge-file-preview-media,
.knowledge-file-preview-image,
.knowledge-file-preview-frame {
  width: 100%;
  height: 100%;
  min-height: 280px;
  max-height: min(62vh, 720px);
  border: 0;
  background: #000;
  object-fit: contain;
}

.knowledge-file-preview-stage:fullscreen .knowledge-file-preview-media,
.knowledge-file-preview-stage:fullscreen .knowledge-file-preview-image,
.knowledge-file-preview-stage:fullscreen .knowledge-file-preview-frame,
.knowledge-file-preview-stage:-webkit-full-screen .knowledge-file-preview-media,
.knowledge-file-preview-stage:-webkit-full-screen .knowledge-file-preview-image,
.knowledge-file-preview-stage:-webkit-full-screen .knowledge-file-preview-frame {
  max-height: none;
  min-height: 100vh;
}

.knowledge-file-preview-image {
  background: #111827;
}

.knowledge-file-preview-pdf {
  width: 100%;
  height: 100%;
  min-height: 280px;
  max-height: min(62vh, 720px);
  overflow: auto;
  background: #525659;
  padding: 12px;
  box-sizing: border-box;
}

.knowledge-file-preview-stage:fullscreen .knowledge-file-preview-pdf,
.knowledge-file-preview-stage:-webkit-full-screen .knowledge-file-preview-pdf {
  max-height: none;
  min-height: 100vh;
}

.knowledge-file-preview-pdf-page {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0 auto 12px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.knowledge-file-preview.is-window .knowledge-file-preview-pdf {
  max-height: min(48vh, 480px);
  min-height: 220px;
}

.knowledge-file-preview-audio {
  padding: 24px;
  background: #111827;
}

.knowledge-file-preview-empty {
  padding: 28px 20px;
  text-align: center;
  color: #d7e0ea;
  font-size: 14px;
  line-height: 1.45;
}

.knowledge-file-preview-actions-inline {
  margin-top: 12px;
}

.knowledge-file-preview-note {
  padding: 8px 12px;
  background: #f7f9fc;
  color: #5f7388;
  font-size: 12px;
  border-top: 1px solid var(--kb-border);
}

.knowledge-file-preview-note a {
  color: var(--kb-accent);
}

.knowledge-file-preview.is-window {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  width: min(720px, calc(100vw - 48px));
  margin: 0;
  box-shadow: 0 18px 48px rgba(15, 23, 32, 0.22);
  border: 1px solid #d7e6fb;
}

.knowledge-file-preview.is-window .knowledge-file-preview-stage {
  max-height: min(48vh, 480px);
}

.knowledge-file-preview.is-window .knowledge-file-preview-media,
.knowledge-file-preview.is-window .knowledge-file-preview-image,
.knowledge-file-preview.is-window .knowledge-file-preview-frame {
  max-height: min(48vh, 480px);
  min-height: 220px;
}

@media (max-width: 860px) {
  .knowledge-file-preview.is-window {
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
  }

  .knowledge-file-preview-toolbar {
    width: 100%;
  }
}

.knowledge-files-title {
  font-weight: 600;
  color: #1f2a37;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.knowledge-files-meta {
  font-size: 12px;
  color: #7c8ea3;
}

.knowledge-files-delete {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #9aa8b8;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.knowledge-files-delete:hover {
  background: #fdecea;
  color: #c0392b;
}

.knowledge-files-empty {
  padding: 12px;
  border-radius: 8px;
  background: #f7f9fc;
  color: #7c8ea3;
  font-size: 13px;
}

.knowledge-document-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.knowledge-document-header h3 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.knowledge-editor-shell,
.knowledge-document-content {
  min-height: 420px;
  border: 1px solid var(--kb-border);
  border-radius: 9px;
  background: var(--kb-bg);
  color: var(--kb-text);
  overflow: visible;
  box-shadow: 0 8px 24px rgba(33, 74, 118, 0.05);
}

.knowledge-document-content {
  padding: 16px;
  line-height: 1.7;
}

.knowledge-editor-textarea {
  min-height: 420px;
  width: 100%;
  padding: 16px;
  border: 0;
  background: transparent;
  color: var(--text);
}

.knowledge-editor-shell .tox-tinymce {
  border: 0;
  border-radius: 9px;
  overflow: visible;
}

.knowledge-editor-shell .tox .tox-editor-container,
.knowledge-editor-shell .tox .tox-sidebar-wrap,
.knowledge-editor-shell .tox .tox-edit-area {
  overflow: visible;
}

.knowledge-editor-shell .tox .tox-toolbar,
.knowledge-editor-shell .tox .tox-toolbar__primary,
.knowledge-editor-shell .tox .tox-editor-header {
  background: linear-gradient(180deg, #fdfefe 0%, #f5f9ff 100%);
}

.knowledge-editor-shell .tox .tox-editor-header {
  position: sticky !important;
  top: 0;
  z-index: 120;
  border-radius: 9px 9px 0 0;
  box-shadow: 0 8px 18px rgba(33, 74, 118, 0.08);
}

.knowledge-editor-shell .tox .tox-edit-area__iframe {
  background: var(--kb-bg);
}

.knowledge-document-content p,
.tox-edit-area iframe,
.knowledge-editor-shell p {
  margin: 0 0 16px;
}

.knowledge-document-content h2,
.knowledge-editor-shell h2 {
  margin: 20px 0 12px;
  font-size: 24px;
  line-height: 1.2;
}

.knowledge-document-content h3,
.knowledge-editor-shell h3 {
  margin: 18px 0 10px;
  font-size: 19px;
  line-height: 1.3;
}

.knowledge-document-content ul,
.knowledge-document-content ol,
.knowledge-editor-shell ul,
.knowledge-editor-shell ol {
  margin: 0 0 12px 20px;
}

.knowledge-document-content blockquote,
.knowledge-editor-shell blockquote {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  border-radius: 0 5px 5px 0;
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  color: var(--text-soft);
}

.knowledge-document-content a,
.knowledge-editor-shell a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.knowledge-document-content .knowledge-inline-document-link,
.knowledge-editor-shell .knowledge-inline-document-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}

.knowledge-inline-document-link::before {
  content: "";
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #97a6b6;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' aria-hidden='true'%3E%3Cpath d='M7 3.5h7l4 4V19a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 6 19V5A1.5 1.5 0 0 1 7.5 3.5Z' fill='none' stroke='%2397a6b6' stroke-width='1.7' stroke-linejoin='round'/%3E%3Cpath d='M14 3.8V8h4.1' stroke='%2397a6b6' stroke-width='1.7' stroke-linejoin='round'/%3E%3Cpath d='M8.5 11.2h7M8.5 14.2h7M8.5 17.2h5.2' stroke='%2397a6b6' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 18px 18px;
}

.knowledge-document-content img,
.knowledge-document-content video,
.knowledge-document-content iframe,
.knowledge-document-content audio {
  max-width: 100%;
  height: auto;
}

.knowledge-panel-card {
  border: 1px solid var(--kb-border);
  border-radius: 9px;
  background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
  padding: 16px;
  box-shadow: 0 8px 24px rgba(33, 74, 118, 0.04);
}

.knowledge-section-title {
  font-weight: 600;
  margin-bottom: 10px;
  color: #42566b;
}

.knowledge-document-content mark,
.knowledge-editor-shell mark {
  background: #fff3a1;
  color: inherit;
  padding: 0 2px;
  border-radius: 1.5px;
}

.knowledge-document-content table,
.knowledge-document-content table.knowledge-table {
  width: 100%;
  margin: 0 0 16px;
  border-collapse: collapse;
  table-layout: auto;
}

.knowledge-document-content th,
.knowledge-document-content td {
  border: 1px solid #d7dbd8;
  padding: 8px 10px;
  vertical-align: top;
  text-align: left;
}

.knowledge-document-content th {
  background: #f3f6f4;
  font-weight: 600;
}

.knowledge-document-content figure.table,
.knowledge-document-content .table-wrap {
  margin: 0 0 16px;
  overflow-x: auto;
  max-width: 100%;
}

html[data-theme="dark"] .knowledge-document-content th,
html[data-theme="dark"] .knowledge-document-content td,
body.theme-dark .knowledge-document-content th,
body.theme-dark .knowledge-document-content td {
  border-color: #415148;
}

html[data-theme="dark"] .knowledge-document-content th,
body.theme-dark .knowledge-document-content th {
  background: #24312b;
}

.knowledge-toggle-block {
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: color-mix(in srgb, var(--panel-strong) 88%, var(--accent) 12%);
  overflow: hidden;
}

.knowledge-toggle-block summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 600;
  user-select: none;
}

.knowledge-toggle-block > div {
  padding: 0 12px 12px;
}

.knowledge-callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: 7px;
  border: 1px solid #dfe9f5;
  background: #eaf5ff;
}

.knowledge-callout__icon {
  width: 24px;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  font-weight: 700;
  border: 1.5px solid currentColor;
}

.knowledge-callout__body {
  flex: 1;
  min-width: 0;
}

.knowledge-callout__body > :last-child {
  margin-bottom: 0;
}

.knowledge-callout--info {
  background: #eaf5ff;
  border-color: #d7e9ff;
}

.knowledge-callout--info .knowledge-callout__icon {
  color: #1677ff;
}

.knowledge-callout--success {
  background: #dcf9ec;
  border-color: #bcefd8;
}

.knowledge-callout--success .knowledge-callout__icon {
  color: #2ba86f;
}

.knowledge-callout--danger {
  background: #fde9ec;
  border-color: #f6ccd5;
}

.knowledge-callout--danger .knowledge-callout__icon {
  color: #e05a73;
}

.knowledge-callout--warning {
  background: #fff4cf;
  border-color: #f7e5a6;
}

.knowledge-callout--warning .knowledge-callout__icon {
  color: #d3a126;
}


/* Profile modal */
.hub-profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 340;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(5px);
}

.hub-profile-modal {
  width: min(100%, 560px);
  max-height: 90vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--kb-border);
  border-radius: var(--kb-radius-xl);
  background: var(--kb-bg);
  box-shadow: var(--kb-shadow-modal);
  overflow: hidden;
}

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

.hub-profile-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.hub-profile-subtitle {
  margin: 6px 0 0;
  color: var(--kb-text-secondary);
  font-size: 13px;
}

.hub-profile-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: var(--kb-bg-soft);
  color: var(--kb-text-muted);
  font-size: 22px;
  line-height: 1;
}

.hub-profile-body {
  min-height: 0;
  overflow: auto;
  padding: 18px 22px 22px;
  display: grid;
  gap: 18px;
}

.hub-profile-section {
  display: grid;
  gap: 12px;
  padding-bottom: 4px;
}

.hub-profile-section h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--kb-text-muted);
}

.hub-profile-section--danger {
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid #f5c2c0;
}

.hub-profile-photo-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hub-profile-photo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  border: 1px solid var(--kb-border);
  background: var(--kb-accent-soft);
}

.hub-profile-photo--placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--kb-accent);
  font-size: 22px;
  font-weight: 700;
}

.hub-profile-photo-actions {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.hub-profile-upload {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.hub-profile-upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.hub-profile-hint {
  margin: 0;
  color: var(--kb-text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.hub-profile-password-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hub-profile-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.hub-profile-alert {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
}

.hub-profile-alert--error {
  background: #fff5f5;
  border: 1px solid #f5c2c0;
  color: var(--kb-danger);
}

.hub-profile-alert--ok {
  background: #ecfdf3;
  border: 1px solid #bcefd8;
  color: #167a45;
}

.hub-profile-danger-btn {
  border: 1px solid #f5c2c0;
  border-radius: var(--kb-radius-sm);
  background: #fff5f5;
  color: var(--kb-danger);
  min-height: 36px;
  padding: 0 14px;
  font-weight: 600;
  font-size: 14px;
}

.hub-profile-danger-btn:hover {
  background: #ffe8e8;
}

.hub-profile-section .field {
  margin-bottom: 0;
}

@media (max-width: 640px) {
  .hub-profile-password-grid {
    grid-template-columns: 1fr;
  }

  .hub-profile-photo-row {
    flex-direction: column;
    align-items: flex-start;
  }
}
