/* ─── Studio Knowledge Base ─────────────────────────────────────── */

/* Toggle button */
.knowledge-base-toggle {
  position: fixed;
  bottom: 20px;
  right: 80px; /* offset to avoid AI Chat button */
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #1a365d;
  color: white;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: background 0.2s, transform 0.2s;
}
.knowledge-base-toggle:hover {
  background: #2a4a7f;
  transform: translateY(-1px);
}
.knowledge-base-toggle-label {
  font-size: 12px;
}

/* Overlay */
.knowledge-base-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Panel */
.knowledge-base-panel {
  width: 95vw;
  height: 90vh;
  max-width: 1400px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.knowledge-base-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #1a365d;
  color: #fff;
}
.knowledge-base-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}
.knowledge-base-header-actions {
  display: flex; align-items: center; gap: 8px;
}
.knowledge-base-close,
.knowledge-base-settings-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.knowledge-base-close:hover,
.knowledge-base-settings-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* Settings Panel */
.kb-settings-panel {
  padding: 16px 24px; overflow-y: auto; flex: 1;
}
.kb-settings-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.kb-settings-header h4 {
  margin: 0; font-size: 15px; font-weight: 600; color: #1a365d;
}
.kb-settings-table {
  width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 20px;
}
.kb-settings-table th {
  text-align: left; padding: 8px 10px; background: #f1f5f9;
  color: #475569; font-weight: 600; border-bottom: 2px solid #e2e8f0;
}
.kb-settings-table td {
  padding: 8px 10px; border-bottom: 1px solid #e2e8f0; vertical-align: middle;
}
.kb-settings-table td code {
  background: #f1f5f9; padding: 2px 6px; border-radius: 3px; font-size: 11px;
}
.kb-settings-table tr:hover { background: #f8fafc; }
.kb-settings-actions { display: flex; gap: 4px; }
.kb-settings-body { display: flex; flex-direction: column; gap: 24px; }
.kb-settings-section h5 {
  font-size: 12px; font-weight: 600; color: #475569; margin: 0 0 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid #e2e8f0; padding-bottom: 6px;
}
.kb-azure-status { font-size: 12px; margin-bottom: 10px; min-height: 18px; }
.kb-btn-danger-sm {
  height: 28px;
  padding: 0 12px;
  border: 1px solid #ef4444; color: #dc2626; background: #fef2f2;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  line-height: 26px;
  box-sizing: border-box;
}
.kb-btn-danger-sm:hover { background: #fee2e2; }
.kb-container-form {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 16px; margin-top: 8px;
}
.kb-container-form h5 {
  margin: 0 0 10px; font-size: 13px; font-weight: 600; color: #374151;
}
.kb-container-form-row {
  display: flex; gap: 8px; align-items: center; margin-bottom: 8px;
}
.kb-container-form-row label {
  font-size: 12px; color: #4b5563; display: flex; align-items: center; gap: 4px;
}

/* Tabs */
.knowledge-base-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 24px;
  background: #f8f9fa;
}
.knowledge-base-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  transition: color 0.2s, border-color 0.2s;
}
.knowledge-base-tab:hover {
  color: #1a365d;
}
.knowledge-base-tab.active {
  color: #1a365d;
  border-bottom-color: #1a365d;
}

/* Tab content */
.knowledge-base-content {
  flex: 1;
  overflow-y: auto;
  position: relative;
}
.knowledge-base-tab-panel {
  display: none;
  height: 100%;
}
.knowledge-base-tab-panel.active {
  display: block;
}

/* ─── Assets Tab Layout ────────────────────────────────────────── */

.kb-assets-layout {
  display: flex;
  height: 100%;
}

/* Sidebar */
.kb-assets-sidebar {
  width: 200px;
  flex-shrink: 0;
  border-right: 1px solid #e2e8f0;
  padding: 16px;
  overflow-y: auto;
  background: #fafbfc;
}
.kb-sidebar-section { margin-bottom: 20px; }
.kb-sidebar-section h4 {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 8px;
}

.kb-discipline-icons { display: flex; flex-direction: column; gap: 6px; }
.kb-disc-icon-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px; border-radius: 4px; transition: background 0.1s;
}
.kb-disc-icon-row:hover { background: #f8fafc; }
.kb-disc-icon-row .kb-btn-sm { margin-left: auto; padding: 2px 8px; font-size: 10px; }
.kb-disc-icon-row .kb-disc-icon-clear {
  background: transparent; border: none; color: #ef4444; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 2px 4px;
}

.kb-type-filters { display: flex; flex-direction: column; gap: 2px; }
.kb-type-btn {
  text-align: left;
  padding: 6px 10px;
  border: none;
  background: none;
  border-radius: 4px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
}
.kb-type-btn:hover { background: #f3f4f6; }
.kb-type-btn.active { background: #e0e7ff; color: #1a365d; font-weight: 500; }

.kb-select, .kb-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  background: white;
}

/* Main content */
.kb-assets-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.kb-assets-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  height: 56px;
  min-height: 56px;
  border-bottom: 1px solid #f3f4f6;
}
.kb-search {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
}
.kb-toolbar-actions { display: flex; gap: 6px; }
.kb-btn-icon {
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}
.kb-btn,
.kb-btn-primary {
  padding: 6px 16px;
  background: #1a365d;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.kb-btn:hover,
.kb-btn-primary:hover { background: #2a4a7f; }
.kb-btn-sm {
  height: 28px;
  padding: 0 12px;
  background: #1a365d;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  line-height: 28px;
  box-sizing: border-box;
  text-decoration: none;
}
.kb-btn-sm:hover { background: #2a4a7f; color: white; }

/* Anchors styled as buttons (e.g. "Open in Studio", JSON/Excel exports,
   Source-bundle downloads) need explicit overrides on every link
   pseudo-class, otherwise the CMS's own `a:hover { color: ...; }` wins
   the specificity tie and the text goes blue on blue at hover. */
a.kb-btn-sm,
a.kb-btn-sm:link,
a.kb-btn-sm:visited,
a.kb-btn-sm:hover,
a.kb-btn-sm:active,
a.kb-btn-sm:focus {
  color: #fff;
  text-decoration: none;
}
.kb-btn-small {
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}
.kb-btn-danger {
  padding: 6px 16px;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.kb-btn-danger:hover { background: #dc2626; }

/* Upload progress */
.kb-upload-progress {
  padding: 8px 16px;
  background: #f0f4ff;
  display: flex;
  align-items: center;
  gap: 12px;
}
.kb-upload-progress-bar {
  height: 4px;
  background: #1a365d;
  border-radius: 2px;
  transition: width 0.3s;
  width: 0%;
  flex: 1;
}

/* Grid view */
.kb-assets-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  align-content: start;
}
.kb-asset-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.kb-asset-card:hover { border-color: #93c5fd; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.kb-asset-card.selected { border-color: #1a365d; box-shadow: 0 0 0 2px rgba(26,54,93,0.2); }
/* Distinct from .selected (detail-panel) so a card can be in both states
   simultaneously without visual conflict. Multi-select uses a teal tint
   plus a check-style ring; .selected keeps its darker outline. */
.kb-asset-card.kb-multi-selected {
  border-color: #0d9488;
  box-shadow: 0 0 0 2px rgba(13,148,136,0.25);
  background: #f0fdfa;
}
.kb-asset-card.kb-multi-selected.selected {
  /* Both states active — merge the outlines so neither is hidden. */
  box-shadow: 0 0 0 2px rgba(26,54,93,0.2), 0 0 0 4px rgba(13,148,136,0.25);
}
.kb-asset-thumb {
  width: 100%;
  height: 100px;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.kb-asset-thumb img { width: 100%; height: 100%; object-fit: cover; }
.kb-thumb-icon { font-size: 32px; }
.kb-asset-info { padding: 8px 10px; }
.kb-asset-name {
  font-size: 12px;
  font-weight: 500;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kb-asset-meta { font-size: 11px; color: #9ca3af; margin-top: 2px; }

/* List view */
.kb-assets-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kb-asset-row {
  display: grid;
  grid-template-columns: 36px 2fr 80px 80px 1fr 100px;
  gap: 10px;
  align-items: center;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.kb-row-thumb {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  overflow: hidden;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.kb-row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.kb-row-thumb .kb-thumb-icon {
  font-size: 18px;
  line-height: 1;
}
.kb-asset-row:hover { background: #f9fafb; }
.kb-asset-row.selected { background: #e0e7ff; }
.kb-asset-row.kb-multi-selected { background: #ccfbf1; }
.kb-asset-row.kb-multi-selected.selected { background: #b2ebe2; }

/* Floating action bar shown when 1+ assets are multi-selected. Sits at
   the bottom of the assets pane in its own row so it doesn't cover
   content. Mirrors the .kb-modal-footer button styling. */
.kb-bulk-action-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-top: 8px;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
  font-size: 13px;
  z-index: 5;
}
.kb-bulk-action-bar .kb-bulk-count {
  font-weight: 500;
  color: #1a365d;
  margin-right: auto;
}
.kb-btn-danger-sm {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  background: #dc2626;
  color: #ffffff;
  cursor: pointer;
  font-size: 12px;
}
.kb-btn-danger-sm:hover { background: #b91c1c; }

.kb-assets-count {
  padding: 8px 16px;
  font-size: 11px;
  color: #9ca3af;
  border-top: 1px solid #f3f4f6;
}

.kb-empty {
  padding: 3rem;
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
}
.kb-assets-grid .kb-empty {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 4rem 1rem;
}

/* Badges */
.kb-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
.kb-badge-image { background: #dbeafe; color: #1e40af; }
.kb-badge-video { background: #fce7f3; color: #9d174d; }
.kb-badge-audio { background: #d1fae5; color: #065f46; }
.kb-badge-document { background: #fef3c7; color: #92400e; }
.kb-badge-webgl { background: #ede9fe; color: #5b21b6; }
.kb-badge-other { background: #f3f4f6; color: #6b7280; }

/* Detail panel */
.kb-asset-detail {
  width: 400px;
  flex-shrink: 0;
  border-left: 1px solid #e2e8f0;
  overflow-y: auto;
  background: #fafbfc;
}
.kb-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  min-height: 56px;
  border-bottom: 1px solid #e2e8f0;
}
.kb-detail-header h4 {
  font-size: 14px;
  margin: 0;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.kb-detail-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: #9ca3af;
  padding: 0 4px;
}
.kb-detail-preview {
  padding: 12px 16px;
  background: #f3f4f6;
  text-align: center;
}
.kb-detail-preview-img { max-width: 100%; max-height: 200px; border-radius: 4px; }
.kb-detail-preview-video { max-width: 100%; max-height: 200px; border-radius: 4px; }
.kb-detail-preview-pdf { width: 100%; height: 280px; border: none; border-radius: 4px; }
.kb-detail-preview-icon {
  font-size: 48px;
  padding: 24px;
  color: #9ca3af;
}
.kb-detail-body { padding: 16px; }
.kb-detail-body h5 {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  margin: 12px 0 8px;
}
.kb-detail-body hr { border: none; border-top: 1px solid #e2e8f0; margin: 12px 0; }
.kb-detail-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}
.kb-detail-field label {
  font-weight: 500;
  color: #6b7280;
  min-width: 90px;
  font-size: 12px;
}
.kb-detail-field .kb-input { flex: 1; font-size: 12px; }
.kb-url-input { font-size: 10px !important; }
.kb-detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* ─── Upload Metadata Panel ─────────────────────────────────────── */
.kb-upload-meta-form {}
.kb-upload-meta-filename {
  font-size: 12px;
  color: #6b7280;
  padding: 0 0 10px;
  word-break: break-all;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 12px;
}
.kb-select-full { width: 100%; }
.kb-detail-field-inline {
  align-items: center;
}
.kb-detail-field-inline input[type="checkbox"] {
  margin: 0;
  width: 16px;
  height: 16px;
}
.kb-meta-custom-section {
  flex-direction: column;
  align-items: flex-start;
}
.kb-meta-custom-section > label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: unset;
  margin-bottom: 6px;
}
.kb-kv-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.kb-kv-row .kb-kv-key { flex: 1; }
.kb-kv-row .kb-kv-value { flex: 2; }
.kb-btn-remove {
  padding: 2px 7px;
  background: #fee2e2;
  color: #b91c1c;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.kb-btn-remove:hover { background: #fca5a5; }
.kb-upload-meta-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}
.kb-btn-link {
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 13px;
  text-decoration: underline;
  padding: 0;
}
.kb-btn-link:hover { color: #374151; }

/* Toast notifications */
.kb-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: white;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 10001;
  animation: kbToastIn 0.3s ease, kbToastOut 0.3s ease 2.5s forwards;
}
.kb-toast-error { background: #ef4444; }

/* ─── Documents Tab ────────────────────────────────────────────── */

.kb-docs-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.kb-docs-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
}

.kb-docs-scope { display: flex; gap: 2px; }
.kb-scope-btn {
  padding: 5px 12px;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.kb-scope-btn.active { background: #1a365d; color: white; border-color: #1a365d; }

.kb-docs-add {
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #fafbfc;
}

.kb-docs-add-tabs { display: flex; gap: 2px; margin-bottom: 10px; }
.kb-doc-add-tab {
  padding: 5px 14px;
  border: 1px solid #d1d5db;
  background: white;
  border-radius: 4px 4px 0 0;
  font-size: 12px;
  cursor: pointer;
}
.kb-doc-add-tab.active { background: #f8f9fa; border-bottom-color: #f8f9fa; font-weight: 500; }

.kb-doc-add-panel { display: none; }
.kb-doc-add-panel.active { display: block; }

.kb-textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  resize: vertical;
  margin: 6px 0;
  font-family: inherit;
}

.kb-doc-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.kb-doc-add-row label { font-size: 12px; display: flex; align-items: center; gap: 4px; }

.kb-doc-file-drop {
  border: 2px dashed #d1d5db;
  border-radius: 6px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  color: #6b7280;
  transition: border-color 0.2s;
}
.kb-doc-file-drop:hover { border-color: #93c5fd; }

.kb-docs-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
}

.kb-doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
}
.kb-doc-item:hover { background: #f9fafb; }

.kb-doc-item-main { flex: 1; min-width: 0; }
.kb-doc-item-title {
  font-size: 13px;
  font-weight: 500;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kb-doc-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.kb-doc-delete {
  background: none;
  border: none;
  font-size: 18px;
  color: #d1d5db;
  cursor: pointer;
  padding: 0 4px;
}
.kb-doc-delete:hover { color: #ef4444; }

/* ─── Curriculum Tab ───────────────────────────────────────────── */

.kb-curriculum-layout { display: flex; flex-direction: column; height: 100%; }

.kb-curriculum-subtabs {
  display: flex; gap: 2px; padding: 0 16px;
  border-bottom: 1px solid #e2e8f0;
}
.kb-subtab {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: #6b7280; cursor: pointer;
  padding: 8px 14px; font-size: 12px; font-weight: 500;
  letter-spacing: 0.2px;
}
.kb-subtab:hover { color: #1a365d; background: #f1f5f9; }
.kb-subtab.active {
  color: #1a365d; border-bottom-color: #1a365d;
  background: #fff; font-weight: 600;
}

.kb-cur-panel { display: none; flex: 1; overflow-y: auto; }
.kb-cur-panel.active { display: flex; flex-direction: column; }

.kb-ae-toolbar {
  display: flex; gap: 8px; padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
}
.kb-ae-list { padding: 0 16px; }

.kb-ae-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.kb-ae-table th {
  text-align: left; padding: 8px 10px; background: #f8f9fa;
  border-bottom: 2px solid #e2e8f0; font-weight: 600; color: #374151;
  position: sticky; top: 0;
}
.kb-ae-table td { padding: 6px 10px; border-bottom: 1px solid #f3f4f6; color: #374151; }
.kb-ae-table tr:hover { background: #f9fafb; }
.kb-ae-code { font-weight: 600; color: #1a365d; white-space: nowrap; }

/* AE row selection + split layout (mirrors .kb-sb-split / .kb-sa-detail). */
.kb-ae-row { cursor: pointer; }
.kb-ae-row.selected { background: #e0e7ff; }
.kb-ae-row.selected .kb-ae-code { color: #1a365d; }
.kb-ae-row-desc {
  max-width: 360px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.kb-ae-split {
  display: flex; gap: 0; flex: 1; min-height: 0;
}
.kb-ae-list-col {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  overflow-y: auto; border-right: 1px solid #e2e8f0;
}
.kb-ae-detail {
  width: 340px; flex-shrink: 0;
  overflow-y: auto;
  padding: 16px 16px 16px;
}
.kb-ae-detail .kb-empty { color: #9ca3af; font-size: 12px; padding-top: 20px; }
.kb-ae-detail-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid #f3f4f6;
}
.kb-ae-detail-code {
  margin: 0; font-size: 15px; font-weight: 700; color: #1a365d;
}
.kb-ae-chip {
  display: inline-block;
  padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 500;
  background: #eef2ff; color: #1a365d; border: 1px solid #c7d2fe;
}
.kb-ae-section { margin-bottom: 12px; }
.kb-ae-section h6 {
  margin: 0 0 6px; font-size: 11px; font-weight: 600;
  color: #6b7280; text-transform: uppercase; letter-spacing: 0.3px;
}
.kb-ae-section p { font-size: 12px; color: #374151; margin: 0; line-height: 1.5; }
.kb-ae-readonly-tag {
  font-size: 10px; color: #9ca3af; font-weight: 500;
  text-transform: none; letter-spacing: 0; margin-left: 4px;
}
.kb-ae-dl {
  margin: 0; display: grid;
  grid-template-columns: 140px 1fr; gap: 4px 12px;
  font-size: 12px;
}
.kb-ae-dl dt { color: #6b7280; }
.kb-ae-dl dd { margin: 0; color: #374151; }
.kb-ae-edit-form {
  display: flex; flex-direction: column; gap: 10px; margin-top: 8px;
}
.kb-ae-edit-form .kb-field {
  display: flex; flex-direction: column; gap: 3px;
}
.kb-ae-edit-form .kb-field > span {
  font-size: 11px; font-weight: 600; color: #475569;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.kb-ae-edit-form input,
.kb-ae-edit-form select,
.kb-ae-edit-form textarea {
  padding: 6px 8px; font-size: 12px; color: #1f2937;
  border: 1px solid #e2e8f0; border-radius: 4px; background: #fff;
  width: 100%; box-sizing: border-box; font-family: inherit;
}
.kb-ae-edit-form textarea { resize: vertical; }

/* Classification dl also stacks on the narrow right column. */
.kb-ae-dl { grid-template-columns: 1fr; gap: 4px 0; }
.kb-ae-dl dt {
  font-size: 11px; font-weight: 600; color: #475569;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.kb-ae-dl dd { margin: 0 0 6px; color: #374151; }

/* SLSA Models */
.kb-slsa-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px; padding: 16px;
}
.kb-slsa-card {
  border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px;
  background: white;
}
.kb-slsa-header { font-size: 14px; font-weight: 600; color: #1a365d; margin-bottom: 8px; }
.kb-slsa-code {
  display: inline-block; background: #ede9fe; color: #5b21b6;
  padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700;
  margin-right: 6px;
}
.kb-slsa-desc { font-size: 12px; color: #6b7280; margin-bottom: 10px; }
.kb-slsa-steps { font-size: 12px; color: #374151; padding-left: 20px; margin-bottom: 10px; }
.kb-slsa-steps li { margin-bottom: 3px; }
.kb-slsa-when { font-size: 11px; color: #6b7280; }
.kb-slsa-when ul { padding-left: 16px; margin-top: 4px; }
.kb-slsa-when li { margin-bottom: 2px; }

/* ─── Storyboards Tab ──────────────────────────────────────────── */

.kb-sb-layout { display: flex; height: 100%; }

.kb-sb-sidebar {
  width: 320px; flex-shrink: 0; border-right: 1px solid #e2e8f0;
  display: flex; flex-direction: column; overflow: hidden;
}
.kb-sb-filters { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid #f3f4f6; }
.kb-sb-list { flex: 1; overflow-y: auto; }

.kb-sb-item {
  padding: 10px 12px; border-bottom: 1px solid #f3f4f6; cursor: pointer;
}
.kb-sb-item:hover { background: #f9fafb; }
.kb-sb-item.selected { background: #e0e7ff; border-left: 3px solid #1a365d; }
.kb-sb-item-title {
  font-size: 13px; font-weight: 500; color: #1f2937;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kb-sb-item-meta { display: flex; gap: 6px; margin-top: 4px; font-size: 11px; color: #9ca3af; align-items: center; }

.kb-sb-detail { flex: 1; overflow: hidden; padding: 20px; display: flex; flex-direction: column; }

/* Split layout: structure tree + SA detail */
.kb-sb-split { display: flex; gap: 0; margin-top: 12px; flex: 1; min-height: 0; }
.kb-sb-tree {
  flex: 1; overflow-y: auto; padding-right: 16px;
  border-right: 1px solid #e2e8f0; min-width: 0;
}
.kb-sa-detail {
  width: 340px; flex-shrink: 0; overflow-y: auto; padding-left: 16px;
}
.kb-sa-detail .kb-empty { color: #9ca3af; font-size: 12px; padding-top: 20px; }

.kb-sa-detail-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.kb-sa-detail-header h4 {
  font-size: 14px; font-weight: 600; color: #1a365d; margin: 0;
}
.kb-sa-edit-form {
  display: flex; flex-direction: column; gap: 10px; margin-top: 8px;
}
.kb-sa-edit-form .kb-field {
  display: flex; flex-direction: column; gap: 3px;
}
.kb-sa-edit-form .kb-field > span {
  font-size: 11px; font-weight: 600; color: #475569;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.kb-sa-edit-form input[type="text"],
.kb-sa-edit-form input[type="number"],
.kb-sa-edit-form select,
.kb-sa-edit-form textarea {
  width: 100%; box-sizing: border-box;
  padding: 6px 8px; font-size: 12px; color: #1f2937;
  border: 1px solid #d1d5db; border-radius: 4px; background: #fff;
  font-family: inherit;
}
.kb-sa-edit-form textarea { resize: vertical; min-height: 60px; }
.kb-sa-edit-form input:focus,
.kb-sa-edit-form select:focus,
.kb-sa-edit-form textarea:focus {
  outline: none; border-color: #1a365d; box-shadow: 0 0 0 2px rgba(26,54,93,0.12);
}
.kb-sa-edit-form .kb-field-row {
  display: flex; gap: 8px;
}
.kb-sa-edit-form .kb-field-row .kb-field { flex: 1; }
.kb-sa-detail-meta {
  display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; color: #6b7280;
  margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid #f3f4f6;
}
.kb-sa-ae-badge {
  background: #e0f2fe; color: #0369a1; padding: 1px 6px; border-radius: 3px; font-weight: 500;
}
.kb-sa-section { margin-bottom: 12px; }
.kb-sa-section h5 {
  font-size: 11px; font-weight: 600; color: #475569; margin: 0 0 4px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.kb-sa-section p { font-size: 12px; color: #374151; margin: 0; line-height: 1.5; }
.kb-sa-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.kb-sa-chip {
  font-size: 10px; padding: 2px 8px; border-radius: 10px;
  background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0;
}
.kb-sa-chip-concept { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.kb-sa-typologies {
  font-size: 12px; color: #374151; margin: 0; padding-left: 18px; line-height: 1.6;
}
.kb-sa-typologies li { margin-bottom: 2px; }

/* SA Intro Screen review panel ─────────────────────────────────── */
.kb-sa-intro-section { border-top: 1px dashed #e5e7eb; padding-top: 12px; }
.kb-sa-intro-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-bottom: 6px;
}
.kb-sa-intro-head h5 { margin: 0; }
.kb-sa-intro-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.kb-sa-intro-meta { font-size: 11px; color: #6b7280; margin-bottom: 6px; }
.kb-sa-intro-lang { display: flex; gap: 4px; margin-bottom: 8px; }
.kb-sa-intro-lang-btn {
  font-size: 11px; padding: 2px 10px; border-radius: 12px;
  border: 1px solid #d1d5db; background: #fff; color: #4b5563; cursor: pointer;
}
.kb-sa-intro-lang-btn.kb-active {
  background: #1d4ed8; color: #fff; border-color: #1d4ed8;
}
.kb-sa-intro-preview-host {
  border: 1px solid #e5e7eb; border-radius: 6px;
  background: #fff; padding: 8px; min-height: 200px;
  overflow: auto;
}

/* Storyboard Content tab — bulk action toolbar */
.kb-sb-content-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px; margin-bottom: 12px;
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px;
}
.kb-sb-gen-intros-status {
  font-size: 11px; color: #475569; font-family: ui-monospace, monospace;
}

/* SA item clickable state */
.kb-sb-sa-item { cursor: pointer; transition: background 0.1s; }
.kb-sb-sa-item:hover { background: #f0f4ff; }
.kb-sb-sa-item.selected { background: #e0e7ff; border-left: 2px solid #3b82f6; padding-left: 6px; }

/* Activity Header (per storyboard) */
.kb-sb-header-preview {
  border: 1px dashed #cbd5e1; border-radius: 6px;
  padding: 12px; background: #fafbfc;
  overflow: auto; max-height: 220px;
}
.kb-sb-header-textarea {
  width: 100%; box-sizing: border-box;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 11px; line-height: 1.4;
  border: 1px solid #d1d5db; border-radius: 4px;
  padding: 8px 10px; background: #ffffff; color: #1f2937;
  resize: vertical;
}
.kb-stale-hint {
  font-size: 11px; color: #92400e; background: #fef3c7;
  border: 1px solid #fde68a; border-radius: 10px;
  padding: 1px 8px; margin-left: 6px; font-weight: 500;
  text-transform: none; letter-spacing: 0; display: inline-block;
}

/* Storyboard ↔ Asset association */
.kb-sb-assets-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;
}
.kb-sb-assets-header h4 { font-size: 13px; font-weight: 600; color: #1a365d; margin: 0; }

/* Storyboard detail tabs — persistent header above, swappable body below. */
.kb-sb-tabs {
  display: flex; gap: 2px; margin: 12px 0 0;
  border-bottom: 1px solid #e2e8f0;
}
.kb-sb-tab {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: #6b7280; cursor: pointer;
  padding: 8px 14px; font-size: 12px; font-weight: 500;
  letter-spacing: 0.2px;
}
.kb-sb-tab:hover { color: #1a365d; background: #f1f5f9; }
.kb-sb-tab.active {
  color: #1a365d; border-bottom-color: #1a365d;
  background: #fff; font-weight: 600;
}
/* Tab body fills the remaining detail-panel height and scrolls on its
   own, so the header + lifecycle bar + tab nav stay pinned. min-height:0
   is the classic unlock for a flex child to respect overflow:auto. */
.kb-sb-tabbody {
  padding-top: 14px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Fixed-height scrollable asset grid — ~2 rows × 2 columns (≈4 cards)
   visible at a time. Scrolling drives infinite render of the rest. */
.kb-sb-assets-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
  max-height: 160px; overflow-y: auto;
  padding: 4px; border: 1px solid #e2e8f0; border-radius: 6px;
  background: #f8fafc;
}
.kb-sb-assets-sentinel { display: none; }  /* legacy; kept to avoid id-lookup crash */
.kb-sb-assets-sentinel-in { height: 1px; width: 100%; flex-basis: 100%; }
.kb-asset-clickable { cursor: zoom-in; }

/* Lightbox — full-screen overlay for enlarged image preview. */
.kb-asset-lightbox {
  position: fixed; inset: 0; z-index: 10100;
  background: rgba(15, 23, 42, 0.85);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px; cursor: zoom-out;
}
.kb-asset-lightbox img {
  max-width: 90vw; max-height: 80vh; object-fit: contain;
  border-radius: 4px; background: #fff;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.kb-asset-lightbox-caption {
  color: #e5e7eb; font-size: 13px; margin-top: 12px; max-width: 90vw;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kb-asset-lightbox-close {
  position: absolute; top: 16px; right: 20px;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.3);
  color: #fff; width: 36px; height: 36px; border-radius: 50%;
  font-size: 22px; line-height: 1; cursor: pointer;
}
.kb-asset-lightbox-close:hover { background: rgba(255,255,255,0.2); }
.kb-sb-asset-card {
  position: relative; display: flex; gap: 8px; align-items: center;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 6px;
  padding: 6px 8px; width: calc(50% - 4px); min-width: 0; box-sizing: border-box;
}
.kb-sb-asset-card:hover { border-color: #93c5fd; }
.kb-sb-asset-thumb {
  width: 40px; height: 40px; object-fit: cover; border-radius: 4px; flex-shrink: 0;
}
.kb-sb-asset-icon {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  background: #f1f5f9; border-radius: 4px; font-size: 18px; flex-shrink: 0;
}
.kb-sb-asset-info { flex: 1; min-width: 0; overflow: hidden; }
.kb-sb-asset-name {
  font-size: 11px; font-weight: 500; color: #1f2937;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kb-sb-asset-notes { font-size: 10px; color: #9ca3af; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-sb-asset-unlink {
  position: absolute; top: 2px; right: 4px;
  background: none; border: none; color: #d1d5db; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 2px;
}
.kb-sb-asset-unlink:hover { color: #dc2626; }

/* Add-assets modal — aligned with KB design language */
.kb-modal-backdrop {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.5); z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.kb-modal {
  background: #fff; border-radius: 8px; width: 560px; max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}
.kb-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: #1a365d; color: #fff;
}
.kb-modal-header h4 {
  margin: 0; font-size: 14px; font-weight: 600; color: #fff;
  letter-spacing: 0.2px;
}
.kb-modal-close {
  background: transparent; border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px; padding: 0; cursor: pointer;
  width: 24px; height: 24px; font-size: 16px; line-height: 1;
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
}
.kb-modal-close:hover { background: rgba(255,255,255,0.15); }
.kb-modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; background: #fafbfc; }
.kb-modal-body .kb-field { margin-bottom: 10px; }
.kb-modal-body .kb-field > span {
  display: block; font-size: 11px; font-weight: 600; color: #475569;
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px;
}
.kb-modal-body .kb-field input[type="text"],
.kb-modal-body .kb-field select,
.kb-modal-body .kb-field textarea {
  width: 100%; box-sizing: border-box; padding: 7px 10px; font-size: 12px;
  color: #1f2937; border: 1px solid #d1d5db; border-radius: 4px; background: #fff;
  font-family: inherit;
}
.kb-modal-body .kb-field input:focus,
.kb-modal-body .kb-field select:focus,
.kb-modal-body .kb-field textarea:focus {
  outline: none; border-color: #1a365d; box-shadow: 0 0 0 2px rgba(26,54,93,0.12);
}
.kb-modal-footer {
  padding: 12px 20px; border-top: 1px solid #e2e8f0; background: #fff;
  display: flex; gap: 8px; justify-content: flex-end;
}

.kb-pick-results-label {
  font-size: 11px; font-weight: 600; color: #475569;
  text-transform: uppercase; letter-spacing: 0.5px; margin: 14px 0 6px;
  display: flex; justify-content: space-between; align-items: center;
}
.kb-pick-results-label .kb-pick-count { color: #9ca3af; font-weight: 500; text-transform: none; letter-spacing: 0; }

.kb-pick-results {
  max-height: 280px; overflow-y: auto; background: #fff;
  border: 1px solid #e2e8f0; border-radius: 6px;
}
.kb-pick-results .kb-empty { padding: 16px; display: block; text-align: center; }
.kb-pick-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  cursor: pointer; font-size: 12px;
  border-bottom: 1px solid #f1f5f9;
}
.kb-pick-row:last-child { border-bottom: none; }
.kb-pick-row:hover { background: #f0f4ff; }
.kb-pick-row input[type="checkbox"] { flex-shrink: 0; margin: 0; accent-color: #1a365d; }
.kb-pick-thumb {
  width: 36px; height: 36px; object-fit: cover; border-radius: 4px;
  flex-shrink: 0; border: 1px solid #e2e8f0;
}
.kb-pick-thumb-icon {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: 4px; flex-shrink: 0; font-size: 16px;
  border: 1px solid #e2e8f0;
}
.kb-pick-thumb-icon[data-type="image"]    { background: #eff6ff; color: #2563eb; }
.kb-pick-thumb-icon[data-type="audio"]    { background: #ecfdf5; color: #059669; }
.kb-pick-thumb-icon[data-type="video"]    { background: #fef3c7; color: #d97706; }
.kb-pick-thumb-icon[data-type="document"] { background: #fef2f2; color: #dc2626; }
.kb-pick-thumb-icon[data-type="webgl"]    { background: #f3e8ff; color: #7c3aed; }
.kb-pick-thumb-icon[data-type="other"]    { background: #f1f5f9; color: #64748b; }
.kb-pick-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #1f2937; font-weight: 500;
}
.kb-pick-type-badge {
  font-size: 10px; font-weight: 500; color: #64748b; background: #f1f5f9;
  padding: 2px 7px; border-radius: 10px; text-transform: uppercase; letter-spacing: 0.3px;
}
.kb-pick-selected {
  margin-top: 10px; padding: 8px 12px; background: #eff6ff;
  border: 1px solid #bfdbfe; border-radius: 4px;
  font-size: 11px; color: #1a365d;
}
.kb-pick-selected strong { color: #1a365d; }

/* Confirmation modal — uses the same .kb-modal-* styles as the asset picker */
.kb-modal-body.kb-confirm-body {
  padding: 18px 20px; font-size: 13px; line-height: 1.55;
  color: #1f2937; background: #ffffff;
}

/* Asset detail — storyboard association chips */
.kb-asset-sb-header {
  display: flex; align-items: center; justify-content: space-between; margin: 6px 0 4px;
}
.kb-asset-sb-header h5 { margin: 0; }
.kb-asset-sb-links { display: flex; flex-wrap: wrap; gap: 6px; }
.kb-asset-sb-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 4px;
  padding: 3px 8px; font-size: 11px;
}
.kb-asset-sb-unlink {
  background: none; border: none; color: #d1d5db; cursor: pointer;
  font-size: 13px; line-height: 1; padding: 0 2px;
}
.kb-asset-sb-unlink:hover { color: #dc2626; }

.kb-sb-detail-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 12px;
}
.kb-sb-detail-header h3 { font-size: 18px; color: #1a365d; margin: 0; line-height: 28px; }
.kb-sb-export-btns { display: flex; gap: 6px; margin-left: auto; align-items: flex-start; }

/* Dropdown */
.kb-dropdown { position: relative; line-height: 0 !important; }
.kb-dropdown-toggle { cursor: pointer; }
.kb-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  min-width: 160px;
  z-index: 20;
  overflow: hidden;
  padding: 4px 0;
}
.kb-dropdown-menu.open { display: block; }
.kb-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: none;
  text-align: left;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1;
}
.kb-dropdown-item svg { color: #6b7280; flex-shrink: 0; }
.kb-dropdown-item:hover { background: #f0f4ff; color: #1a365d; }
.kb-dropdown-item:hover svg { color: #1a365d; }
.kb-sb-actions {
  padding: 8px 10px;
  border-top: 1px solid #f3f4f6;
  flex-shrink: 0;
}
.kb-btn-provision {
  height: 28px;
  padding: 0 12px;
  border: 1px solid #059669; color: #047857; background: #ecfdf5;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  line-height: 26px;
  box-sizing: border-box;
}
.kb-btn-provision:hover { background: #d1fae5; }
.kb-course-link {
  display: inline-flex; align-items: center; margin-left: 6px;
  color: #3b82f6; vertical-align: middle;
}
.kb-course-link:hover { color: #1d4ed8; }
.kb-clear-provision {
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 4px; padding: 2px; border: none; background: transparent;
  color: #9ca3af; cursor: pointer; border-radius: 4px; vertical-align: middle;
}
.kb-clear-provision:hover { color: #dc2626; background: #fee2e2; }
.kb-edit-subtopic,
.kb-edit-storyboard {
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 4px; padding: 2px; border: none; background: transparent;
  color: #9ca3af; cursor: pointer; border-radius: 4px; vertical-align: middle;
}
.kb-edit-subtopic:hover,
.kb-edit-storyboard:hover { color: #1a365d; background: #eff6ff; }

.kb-regenerate-sa,
.kb-regenerate-activity {
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 4px; padding: 2px; border: none; background: transparent;
  color: #9ca3af; cursor: pointer; border-radius: 4px; vertical-align: middle;
}
.kb-regenerate-sa:hover,
.kb-regenerate-activity:hover { color: #2563eb; background: #dbeafe; }

.kb-sa-activities {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.kb-sa-activities li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 8px; border: 1px solid #e2e8f0; border-radius: 4px;
  font-size: 12px; color: #374151; background: #fff;
}
.kb-sa-activities li:hover { background: #f8fafc; }

/* Provision dialog */
.kb-provision-dialog {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 16px; margin-bottom: 16px;
}
.kb-provision-header {
  font-size: 14px; font-weight: 600; color: #1a365d; margin-bottom: 4px;
}
.kb-provision-option {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: #374151; margin: 8px 0 0;
}
.kb-prov-subtopics-section { margin-top: 10px; }
.kb-prov-subtopics-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.kb-prov-subtopics-header a { color: #3b82f6; text-decoration: none; }
.kb-prov-subtopics-header a:hover { text-decoration: underline; }
.kb-prov-subtopics {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  padding: 4px 0;
}
.kb-prov-st-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: #374151;
  padding: 5px 10px;
  cursor: pointer;
}
.kb-prov-st-label:hover { background: #f3f4f6; }
.kb-prov-st-label.disabled {
  color: #9ca3af; cursor: default;
}
.kb-prov-st-label.disabled:hover { background: transparent; }
.kb-prov-st-label input[type="checkbox"] { margin: 0; flex-shrink: 0; }
.kb-provision-actions {
  display: flex; gap: 6px; margin-top: 12px;
}
.kb-progress-bar {
  height: 8px; background: #e2e8f0; border-radius: 4px;
  overflow: hidden; margin-top: 10px;
}
.kb-progress-fill {
  height: 100%; background: #059669; border-radius: 4px;
  width: 0; transition: width 0.3s ease;
}
.kb-progress-label {
  font-size: 11px; color: #6b7280; margin-top: 4px;
}
.kb-sb-detail-meta {
  display: flex; gap: 16px; font-size: 12px; color: #6b7280;
  margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid #e2e8f0;
}

.kb-sb-section { margin-bottom: 20px; }
.kb-sb-section h4 {
  font-size: 13px; font-weight: 600; color: #1a365d;
  margin: 0 0 10px; padding-bottom: 4px; border-bottom: 1px solid #e2e8f0;
}

.kb-sb-subtopic {
  border: 1px solid #e2e8f0; border-radius: 6px; padding: 12px;
  margin-bottom: 10px; background: #fafbfc;
}
.kb-sb-subtopic-header { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 8px; }

/* Production status badges */
.kb-status {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  vertical-align: middle;
}
.kb-status-provisioned { background: #d1fae5; color: #065f46; }
.kb-status-pending { background: #f3f4f6; color: #6b7280; }
.kb-status-ai { background: #dbeafe; color: #1e40af; }
.kb-status-structure { background: #fef3c7; color: #92400e; }

.kb-sb-sa-list { padding-left: 12px; }
.kb-sb-sa-item {
  display: flex; align-items: center; gap: 8px; padding: 4px 0;
  font-size: 12px; color: #374151; border-bottom: 1px solid #f3f4f6;
}
.kb-sb-sa-title { font-weight: 500; }

.kb-sb-ae-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.kb-sb-ae-chip {
  display: inline-block; background: #dbeafe; color: #1e40af;
  padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 500;
  cursor: help;
}

/* Dismissible import-report panel (errors + image-ingest warnings). */
.kb-import-report {
  position: fixed; bottom: 16px; right: 16px; z-index: 10050;
  width: 420px; max-width: calc(100vw - 32px);
  background: #fff; border-radius: 6px;
  border-left: 4px solid #ef4444;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
  padding: 12px 14px; font-size: 12px; color: #1f2937;
}
.kb-import-report-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.kb-import-report-head strong { font-size: 13px; }
.kb-import-report-actions { display: flex; gap: 6px; }
.kb-import-report-summary {
  margin: 4px 0 8px; color: #374151; line-height: 1.4;
}
.kb-import-report-details {
  width: 100%; box-sizing: border-box;
  padding: 6px 8px; font-family: monospace; font-size: 11px;
  border: 1px solid #e2e8f0; border-radius: 4px;
  background: #f8fafc; color: #374151; resize: vertical;
}

/* Fill-in-the-blanks: each blank in the review card renders as an
   inline green chip with the canonical accepted answer; alternates
   are surfaced via the chip's hover-title and an "+N" badge. */
.kb-fitb-blank {
  display: inline-block;
  margin: 0 2px;
  padding: 1px 6px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  border-radius: 4px;
  font-weight: 600;
  font-size: 11px;
}
.kb-fitb-blank em {
  font-style: normal;
  color: #047857;
  font-size: 10px;
  font-weight: 500;
}

/* "+ Add question" row inside each SA accordion in the review UI. */
.kb-sb-assess-add-row {
  display: flex; justify-content: flex-end;
  padding: 8px 12px 4px; margin-top: 4px;
}
.kb-sb-assess-add-q {
  background: transparent !important;
  color: #1a365d !important;
  border: 1px dashed #1a365d !important;
}
.kb-sb-assess-add-q:hover {
  background: #eef2ff !important;
  color: #1a365d !important;
}

/* Kebab (⋮) trigger on the assessment-set row — same height as
   .kb-btn-sm so it lines up with Open, but square + slightly larger
   glyph so the three dots read as a menu affordance. */
.kb-kebab-toggle {
  width: 28px;
  padding: 0;
  font-size: 18px;
  line-height: 26px;
  text-align: center;
}

/* Generic confirm-dialog body (Re-publish, Re-provision, …). */
.kb-confirm-body p {
  margin: 0 0 8px; font-size: 12px; line-height: 1.5; color: #374151;
}
.kb-confirm-body p:last-child { margin-bottom: 0; }
.kb-confirm-code {
  display: inline-block;
  font-family: monospace; font-size: 11px;
  background: #f1f5f9; color: #1f2937;
  padding: 2px 6px; border-radius: 3px;
  word-break: break-all;
}

/* Subtopic picker (Generate Summative / Copy Summative Prompt). */
.kb-subtopic-picker-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 340px; overflow-y: auto;
}
.kb-subtopic-picker-item {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 12px;
  border: 1px solid #e2e8f0; border-radius: 6px;
  background: #fff; text-align: left;
  font-size: 13px; color: #374151; cursor: pointer;
}
.kb-subtopic-picker-item:hover { background: #f0f4ff; border-color: #1a365d; }
.kb-subtopic-picker-item strong {
  color: #1a365d; font-weight: 600; font-size: 12px; min-width: 44px;
}

/* External-LLM prompt modal (Copy Diagnostic / Summative Prompt). */
.kb-external-prompt-modal {
  position: fixed; inset: 0; z-index: 10060;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.kb-external-prompt-card {
  background: #fff; border-radius: 8px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.3);
  width: 780px; max-width: 100%;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  padding: 16px 18px; font-size: 12px; color: #1f2937;
}
.kb-external-prompt-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.kb-external-prompt-head strong { font-size: 14px; }
.kb-external-prompt-hint {
  margin: 4px 0 10px; color: #374151; line-height: 1.4;
}
.kb-external-prompt-hint code {
  background: #f1f5f9; padding: 1px 4px; border-radius: 3px; font-size: 11px;
}
.kb-external-prompt-textarea {
  flex: 1 1 auto; min-height: 280px;
  width: 100%; box-sizing: border-box;
  padding: 8px 10px; font-family: monospace; font-size: 11px;
  border: 1px solid #e2e8f0; border-radius: 4px;
  background: #f8fafc; color: #374151; resize: vertical;
}
.kb-external-prompt-actions {
  display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px;
}

/* Link-existing-course typeahead */
.kb-typeahead {
  list-style: none; margin: 4px 0 0; padding: 0;
  max-height: 240px; overflow-y: auto;
  border: 1px solid #e2e8f0; border-radius: 4px; background: #fff;
}
.kb-typeahead:empty { display: none; }
.kb-typeahead-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 6px 10px; cursor: pointer; border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
}
.kb-typeahead-item:last-child { border-bottom: none; }
.kb-typeahead-item:hover { background: #eff6ff; }
.kb-typeahead-name { color: #1f2937; font-weight: 500; }
.kb-typeahead-key  { color: #6b7280; font-size: 11px; font-family: monospace; }
.kb-typeahead-empty { padding: 8px 10px; color: #9ca3af; font-size: 12px; font-style: italic; }
.kb-link-selected { margin-top: 8px; color: #0369a1; font-size: 11px; min-height: 15px; }

/* Gap Analysis table */
.kb-sb-gap-body { font-size: 12px; }
.kb-sb-gap-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.kb-sb-gap-table th, .kb-sb-gap-table td {
  padding: 5px 8px; border-bottom: 1px solid #f1f5f9; text-align: left;
}
.kb-sb-gap-table th {
  font-weight: 600; color: #475569; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.4px;
  background: #f8fafc;
}
.kb-sb-gap-table td { color: #374151; }
.kb-sb-gap-uncovered summary {
  cursor: pointer; color: #991b1b; font-weight: 500; font-size: 12px;
  padding: 4px 0;
}

/* Formative Assessments panel */
.kb-sb-assessments-list { font-size: 12px; }
.kb-sb-assess-rows { display: flex; flex-direction: column; gap: 6px; }
.kb-sb-assess-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border: 1px solid #e2e8f0; border-radius: 6px;
  background: #f9fafb;
}
.kb-sb-assess-scope { flex: 1; color: #374151; font-weight: 500; }

.kb-sb-assess-review-header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: #1a365d; color: #fff;
  border-radius: 6px 6px 0 0; margin-bottom: 8px;
}
.kb-sb-assess-review-header strong { color: #fff; font-size: 13px; }
.kb-sb-assess-review-progress {
  color: rgba(255, 255, 255, 0.85);
  font-size: 11px;
}

/* Push the action cluster (Back + Publish) to the right edge by
   giving only the first of them `margin-left: auto`. With the flex
   gap on the header, the rest sit flush next to it. */
.kb-sb-assess-review-header #kb-assess-close-review { margin-left: auto; }

/* Dedicated colour scheme for the two header buttons — the default
   .kb-btn-sm uses #1a365d which is the header's own background, so
   they'd blend in. Back = ghost white; Publish = EA yellow accent. */
.kb-sb-assess-review-header #kb-assess-close-review {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.6);
}
.kb-sb-assess-review-header #kb-assess-close-review:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: #fff;
}
.kb-sb-assess-review-header #kb-assess-publish {
  background: #EDC94B;
  color: #021C51;
  border: none;
  font-weight: 600;
}
.kb-sb-assess-review-header #kb-assess-publish:hover { background: #F0D775; }
.kb-sb-assess-review-header #kb-assess-publish:disabled {
  background: rgba(237, 201, 75, 0.35);
  color: rgba(2, 28, 81, 0.5);
  cursor: not-allowed;
}

.kb-sb-assess-sa {
  border: 1px solid #e2e8f0; border-radius: 6px; margin-bottom: 8px;
  background: #fff;
}
.kb-sb-assess-sa summary {
  padding: 8px 10px; cursor: pointer; font-weight: 500; color: #1f2937;
  background: #f8fafc; border-radius: 6px;
}
.kb-sb-assess-sa[open] summary { border-bottom: 1px solid #e2e8f0; border-radius: 6px 6px 0 0; }
.kb-sb-assess-slots {
  display: grid; grid-template-columns: 1fr; gap: 10px; padding: 10px;
}
.kb-sb-assess-slot { border: 1px solid #f1f5f9; border-radius: 4px; padding: 8px; background: #fafbfc; }
.kb-sb-assess-slot-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 11px; color: #475569; margin-bottom: 8px;
}
.kb-sb-assess-slot-head .kb-btn-sm { margin-left: auto; }
.kb-sb-assess-source-ae {
  font-size: 11px; color: #475569; line-height: 1.45;
  background: #f8fafc; border-left: 3px solid #94a3b8;
  padding: 4px 8px; margin: -4px 0 8px;
}
.kb-sb-assess-source-ae strong { color: #1e293b; }

.kb-sb-assess-card {
  border: 1px solid #e5e7eb; border-radius: 4px; padding: 6px 8px;
  background: #fff; margin-bottom: 6px; font-size: 11px;
}
.kb-sb-assess-card.kb-selected { border-color: #10b981; background: #f0fdf4; }
.kb-lang-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: #374151;
}
.kb-lang-select {
  font-size: 11px; padding: 2px 6px; border: 1px solid #d1d5db;
  border-radius: 3px; background: #fff;
}

/* Provision progress bar (bottom-right persistent panel). */
.kb-provision-bar-wrap {
  width: 100%; height: 8px; background: #e2e8f0; border-radius: 4px;
  overflow: hidden; margin: 6px 0 0;
}
.kb-provision-bar {
  height: 100%; background: #034AD8; transition: width 0.3s ease;
}
.kb-sb-assess-stem { color: #111827; font-weight: 500; margin-bottom: 4px; }
.kb-sb-assess-options { margin: 4px 0 4px 16px; padding: 0; color: #374151; }
.kb-sb-assess-feedback { color: #6b7280; font-style: italic; margin: 4px 0; font-size: 11px; }
.kb-sb-assess-actions { display: flex; gap: 6px; margin-top: 6px; }

.kb-sb-source-list { display: flex; flex-direction: column; gap: 6px; }
.kb-sb-source-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border: 1px solid #e2e8f0; border-radius: 6px;
  font-size: 12px; background: #f9fafb;
}
.kb-sb-source-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: #374151; }
.kb-sb-source-meta { color: #6b7280; font-size: 11px; white-space: nowrap; }

.kb-sb-opinion {
  border: 1px solid #e2e8f0; border-radius: 6px; padding: 12px;
  margin-bottom: 10px;
}
.kb-sb-opinion-header {
  display: flex; gap: 10px; align-items: center; margin-bottom: 8px;
  font-size: 13px; font-weight: 500;
}

.kb-sb-criteria-table { width: 100%; font-size: 12px; }
.kb-sb-criteria-table td { padding: 3px 8px; border-bottom: 1px solid #f3f4f6; }
.kb-sb-criteria-table td:last-child { text-align: right; white-space: nowrap; }
@keyframes kbToastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes kbToastOut { to { opacity: 0; } }

/* ── PR 2: assessment review UI — rich editor + per-feedback bands ── */
.kb-modal-wide { width: 900px; max-width: 95vw; }

/* One-line summary view for each question card (closed by default
   on CANDIDATEs, open on APPROVED). Removes the default disclosure
   triangle so the row reads as a clickable status bar. */
.kb-sb-assess-details { margin-bottom: 8px; }
.kb-sb-assess-details > summary { cursor: pointer; }
/* `display:flex` on <summary> wipes the native disclosure triangle
   in WebKit. Render a chevron via `::before` so flex layout still
   works while keeping the visual open/closed cue identical to the
   ST/SA header below. */
.kb-sb-assess-summary {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #f9fafb;
  font-size: 12px;
  line-height: 1.4;
}
.kb-sb-assess-summary::before {
  content: '▶';
  display: inline-block;
  font-size: 9px;
  color: #6b7280;
  transition: transform 0.12s ease;
  flex: 0 0 auto;
}
.kb-sb-assess-details[open] > .kb-sb-assess-summary::before {
  transform: rotate(90deg);
}
.kb-sb-assess-details[open] > .kb-sb-assess-summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: 0;
}
.kb-sb-assess-summary:hover { background: #f3f4f6; }
.kb-sb-assess-summary-stem {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #1f2937;
}
/* SA-header (ST·SA collapsible row) now carries the per-SA action
   buttons on the right so reviewers can Add / Upload without
   expanding the SA first. `display:flex` on <summary> would wipe
   the native disclosure triangle, so we render a chevron via
   ::before instead. */
.kb-sb-assess-sa > summary {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
}
.kb-sb-assess-sa > summary::before {
  content: '▶';
  display: inline-block;
  font-size: 10px;
  color: #6b7280;
  transition: transform 0.12s ease;
  flex: 0 0 auto;
}
.kb-sb-assess-sa[open] > summary::before {
  transform: rotate(90deg);
}
.kb-sb-assess-sa-title { flex: 1; min-width: 0; }
.kb-sb-assess-sa-actions {
  display: inline-flex; gap: 6px;
}
.kb-sb-assess-sa-actions .kb-btn-sm { white-space: nowrap; }
.kb-field-row { display: flex; gap: 10px; }
.kb-field-row .kb-field { flex: 1; }
.kb-field-inline { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.kb-field-inline > span { min-width: 240px; font-size: 11px; }
.kb-field-inline > input { flex: 1; }
.kb-options-grid { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.kb-option-row { display: flex; gap: 8px; align-items: center; }
.kb-option-correct-toggle { display: flex; gap: 4px; align-items: center; font-size: 12px; min-width: 44px; }
.kb-option-correct-toggle input { margin: 0; }
.kb-fb-correct {
  border-left: 3px solid #10b981; padding-left: 8px; margin-top: 6px;
  background: #ecfdf5; border-radius: 4px; padding: 6px 8px;
}
.kb-fb-incorrect {
  border-left: 3px solid #ef4444; padding-left: 8px; margin-top: 6px;
  background: #fef2f2; border-radius: 4px; padding: 6px 8px;
}
.kb-sb-assess-add-row { display: flex; gap: 8px; }

/* ── Guia Pedagógico subtab ───────────────────────────────────────
   Reuses .kb-sb-section / .kb-sb-subtopic / .kb-sb-sa-item from the
   Content tab so the visual rhythm matches; just adds layout for the
   per-row status pill + the right-aligned action button group, and a
   small "label spacer" cell for the toolbar's action button so it
   sits aligned with the form controls beside it.
*/
/* Label-above-field layout for the toolbar's selects, matching the
   canonical `.kb-sa-edit-form .kb-field` pattern (line ~1000). */
.kb-sb-guia-toolbar .kb-field {
  display: flex; flex-direction: column; gap: 3px;
}
.kb-sb-guia-toolbar .kb-field > span {
  font-size: 11px; font-weight: 600; color: #475569;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.kb-sb-guia-toolbar select {
  font-family: inherit; font-size: 12px; padding: 6px 8px;
  border: 1px solid #d1d5db; border-radius: 4px; background: #fff;
  color: #1f2937;
}
.kb-sb-guia-toolbar select:focus {
  outline: none; border-color: #1a365d;
  box-shadow: 0 0 0 2px rgba(26,54,93,0.12);
}
/* AI-fill toggle in the Guia generation toolbar. Sized to its label
   so the dropdowns to its left still get the natural flex share. */
.kb-field-row .kb-sb-guia-toolbar-aifill { flex: 0 0 auto; }
.kb-guia-aifill-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; font-size: 12px; color: #1f2937; cursor: pointer;
  white-space: nowrap;
}
.kb-guia-aifill-toggle input[type="checkbox"] { margin: 0; }

/* The action column hugs its button instead of taking equal share
   of the toolbar row — the format/language/audience selects already
   fill the natural width. Specificity bump (`.kb-field-row`) is
   needed to beat the generic `.kb-field-row .kb-field { flex: 1 }`. */
/* Action column hugs its button and bottom-aligns with the selects.
   The action div has no label `<span>` (its siblings do), so the
   button is pushed to the column's end with `justify-content` —
   children of `.kb-field-row` stretch by default, so the column is
   the row's full height and the button lands on the selects' bottom. */
.kb-field-row .kb-sb-guia-toolbar-actions {
  display: flex; flex-direction: column;
  flex: 0 0 auto;
  justify-content: flex-end;
}
.kb-sb-guia-toolbar-actions .kb-btn-sm {
  height: 32px; padding: 0 12px;
  display: inline-flex; align-items: center; white-space: nowrap;
  align-self: flex-start;
}

.kb-sb-guia-row { padding: 6px 0; }
.kb-sb-guia-row .kb-sb-sa-title { flex: 1 1 auto; min-width: 0; }
/* Storyboard-wide ("Storyboard completa") row sits above the per-SA
   list. A subtle tinted background + border anchors it visually so
   the reader sees it's a distinct, broader action than the per-SA
   rows underneath. */
.kb-sb-guia-wholebook-row {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 6px;
  padding: 10px 12px !important;
  margin-bottom: 10px;
}
.kb-sb-guia-wholebook-row .kb-sb-sa-title strong { color: #1a365d; }
.kb-sb-guia-status {
  flex: 0 0 auto; min-width: 200px;
  font-size: 11px; color: #6b7280; text-align: right;
}
.kb-sb-guia-status a {
  color: #1a365d; text-decoration: none; font-weight: 500;
}
.kb-sb-guia-status a:hover { text-decoration: underline; }
.kb-sb-guia-actions {
  flex: 0 0 auto; display: inline-flex; gap: 6px; margin-left: 8px;
}
.kb-sb-guia-actions .kb-btn-sm { white-space: nowrap; }

/* Tabs inside the org-block / storyboard-override modal. Same
   visual language as .kb-sb-tabs but scoped inside the modal so
   they don't pick up the storyboard-detail tab's chrome. */
.kb-tabs.kb-guia-blocks-tabs {
  display: flex; gap: 2px; padding: 0;
  border-bottom: 1px solid #e2e8f0; margin: 0 0 14px;
}
.kb-tabs.kb-guia-blocks-tabs .kb-tab {
  background: transparent; border: none; cursor: pointer;
  padding: 8px 14px; font-size: 12px; font-weight: 600;
  color: #6b7280; border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.kb-tabs.kb-guia-blocks-tabs .kb-tab:hover { color: #1a365d; }
.kb-tabs.kb-guia-blocks-tabs .kb-tab.active {
  color: #1a365d; border-bottom-color: #1a365d;
}

/* The block list table inside the editor — alternating-row hover,
   compact spacing. Matches .vc-dashboard-table's general feel. */
.kb-sb-guia-blocks-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.kb-sb-guia-blocks-table th {
  text-align: left; padding: 8px 10px; font-weight: 600;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: #6b7280; border-bottom: 1px solid #e2e8f0;
}
.kb-sb-guia-blocks-table td {
  padding: 8px 10px; border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.kb-sb-guia-blocks-table tr:hover td { background: #f9fafb; }
.kb-sb-guia-blocks-table tr:last-child td { border-bottom: none; }
.kb-sb-guia-blocks-table .kb-btn-sm { white-space: nowrap; }
/* Action column wraps Editar/Sobrepor + optional Limpar — flex
   gives consistent spacing whether one or two buttons render, and
   wraps cleanly on narrow modals instead of overlapping. */
.kb-sb-guia-blocks-table td:last-child {
  display: flex; flex-wrap: wrap; gap: 6px 8px;
}
/* History uses the same base table class for visual consistency but
   its last column is a single download link, not a button cluster —
   undo the flex layout so the cell hugs the link. */
.kb-sb-guia-history-table td:last-child { display: table-cell; }
.kb-sb-guia-history-table td:nth-child(2) { text-align: left; }
.kb-sb-guia-history-table td:nth-child(5) { text-align: center; }
.kb-sb-guia-history-table th,
.kb-sb-guia-history-table td { vertical-align: middle; }
.kb-sb-guia-history-table .kb-btn-sm {
  display: inline-flex; align-items: center; padding: 3px 10px;
}

/* Generic small pill — reused by the override / inherited badge in
   the storyboard pane. */
.kb-sb-guia-blocks-table .kb-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
  text-align: center;
}
/* The status column carries one badge per row; centring the cell
   keeps the pill aligned under the column header rather than
   hard-left next to the row text. */
.kb-sb-guia-blocks-table td:nth-child(2) { text-align: center; }

/* Compact intro line used at the top of the storyboard / org panes
   ("Alterações afetam apenas esta storyboard…"). The default
   .kb-empty has generous vertical padding meant for empty-state
   panels — looks heavy when it's actually an inline subtitle. */
.kb-modal-body .kb-empty.kb-tight,
#kb-guia-blocks-pane > .kb-empty:first-child {
  padding: 0; margin: 0 0 10px;
  font-size: 11px; line-height: 1.4; color: #6b7280;
}

/* Per-row "card" structure inside the blocks table.
   Layout: bold block_id on top, tight muted subtitle (the bloco's
   human title), then an inline Markdown preview of the
   currently-resolved content. Lets reviewers see what's rendered
   today without leaving the table. */
.kb-sb-guia-blocks-table .kb-guia-row-id {
  font-weight: 600; font-size: 12px; color: #1f2937;
  line-height: 1.3;
}
.kb-sb-guia-blocks-table .kb-guia-row-title {
  font-size: 11px; color: #6b7280; line-height: 1.3;
  margin: 0 0 6px;
}
.kb-sb-guia-blocks-table .kb-guia-row-preview {
  background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 4px;
  padding: 6px 8px; margin: 0;
  font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
  font-size: 11px; line-height: 1.4; color: #374151;
  white-space: pre-wrap; word-wrap: break-word;
  max-height: 120px; overflow-y: auto;
}

/* ── Block editor: split textarea + live preview ─────────────────
   Each editable Markdown column (PT-PT, EN-US) sits on the left of
   a two-column grid; the rendered HTML preview sits on the right.
   The header carries the label and the "Melhorar com IA" button. */
.kb-guia-edit-field { margin-bottom: 14px; }
.kb-guia-edit-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 4px;
}
.kb-guia-edit-header > span {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: #475569;
}
.kb-guia-improve-btn {
  background: #ede9fe; color: #5b21b6; border: 1px solid #ddd6fe;
}
.kb-guia-improve-btn:hover:not(:disabled) {
  background: #ddd6fe; border-color: #c4b5fd;
}
.kb-guia-improve-btn:disabled { opacity: 0.6; cursor: progress; }

/* Markdown toolbar — sits between the editor header and the
   textarea/preview split. Buttons mutate the textarea selection
   directly; no external editor library. */
.kb-guia-md-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: 4px;
}
.kb-guia-md-btn {
  background: #f9fafb; color: #1f2937;
  border: 1px solid #d1d5db; border-radius: 4px;
  padding: 3px 8px; min-width: 28px;
  font-size: 12px; line-height: 1.2; cursor: pointer;
  font-family: inherit;
}
.kb-guia-md-btn:hover { background: #e5e7eb; border-color: #9ca3af; }
.kb-guia-md-btn:active { background: #d1d5db; }

.kb-guia-edit-split {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  align-items: stretch;
}
.kb-guia-edit-textarea {
  width: 100%; min-height: 220px; box-sizing: border-box;
  font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
  font-size: 13px; line-height: 1.5;
  padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 4px;
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
/* Brief flash applied when the Improve-with-AI call replaces the
   textarea contents — gives a visible cue even if the user's eyes
   were on the preview pane. */
.kb-guia-edit-textarea.kb-guia-improved-flash {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}
.kb-guia-edit-preview {
  background: #ffffff; border: 1px solid #e5e7eb; border-radius: 4px;
  padding: 10px 12px; overflow-y: auto;
  font-size: 13px; line-height: 1.5; color: #1f2937;
  max-height: 360px;
}
.kb-guia-edit-preview h1,
.kb-guia-edit-preview h2,
.kb-guia-edit-preview h3,
.kb-guia-edit-preview h4 { margin: 8px 0 4px; line-height: 1.3; }
.kb-guia-edit-preview h3 { font-size: 14px; color: #1a365d; }
.kb-guia-edit-preview p { margin: 0 0 8px; }
.kb-guia-edit-preview ul,
.kb-guia-edit-preview ol { margin: 0 0 8px; padding-left: 22px; }
.kb-guia-edit-preview li { margin: 2px 0; }
.kb-guia-edit-preview code {
  background: #f3f4f6; padding: 1px 4px; border-radius: 3px;
  font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}
.kb-guia-edit-preview .kb-empty { margin: 0; }

/* Narrow viewports / smaller modals: stack the textarea and the
   preview rather than squeezing both into half the width. */
@media (max-width: 900px) {
  .kb-guia-edit-split { grid-template-columns: 1fr; }
}

/* ─── Help icons next to field labels ──────────────────────────────
   Tiny inline "?" that opens a small popover with a short
   explanation plus an optional jump-link to the relevant tab /
   sub-tab. First user: the SLSA model field in the SA edit form,
   which links over to Curriculum → SLSA Models. Designed to match
   the KB's existing chrome — same border / radius / hover idiom as
   `.kb-btn-sm` and `.kb-input`. */
.kb-help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  padding: 0;
  border: 1px solid #d1d5db;
  border-radius: 50%;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
  font-family: inherit;
  flex-shrink: 0;
}
.kb-help-icon:hover,
.kb-help-icon:focus-visible {
  background: #e5e7eb;
  color: #374151;
  outline: none;
}

/* Keep label text + help icon on the same line. Narrow columns
   (e.g. SLSA model inside a 3-up kb-field-row) otherwise push the
   icon onto the next line, looking like a stray bullet. */
.kb-field > span:has(.kb-help-icon),
.kb-field-label-help {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.kb-help-popover {
  position: fixed;
  z-index: 9999;
  width: 320px;
  max-width: calc(100vw - 16px);
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  font-size: 12px;
  line-height: 1.45;
  color: #374151;
}
.kb-help-popover-body {
  margin: 0 0 10px;
}
.kb-help-popover-body p { margin: 0 0 6px; }
.kb-help-popover-body p:last-child { margin-bottom: 0; }
.kb-help-popover-body strong { color: #1f2937; }
.kb-help-popover-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid #2563eb;
  border-radius: 4px;
  background: transparent;
  color: #2563eb;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}
.kb-help-popover-link:hover {
  background: #eff6ff;
}
