.knowledge-library-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.knowledge-library-summary article {
  display: grid;
  gap: 5px;
  padding: 16px;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: linear-gradient(145deg, #f8fbff, #eef5ff);
}

.knowledge-library-summary span,
.knowledge-library-summary small { color: var(--text-muted); }
.knowledge-library-summary strong { color: var(--brand-700); font-size: 26px; }

.knowledge-library-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 210px) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.knowledge-library-toolbar label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: #fff;
}

.knowledge-library-toolbar input,
.knowledge-library-toolbar select {
  width: 100%;
  min-height: 42px;
  border: 0;
  background: #fff;
}

.knowledge-library-toolbar select {
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 0 12px;
}

.knowledge-document-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.knowledge-document-card {
  display: flex;
  min-width: 0;
  min-height: 245px;
  flex-direction: column;
  gap: 13px;
  padding: 18px;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  background: #fff;
}

.knowledge-document-card header,
.knowledge-document-card footer,
.knowledge-document-card footer div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.knowledge-document-card h4 { margin: 0; font-size: 17px; line-height: 1.45; }
.knowledge-document-card p { flex: 1; margin: 0; color: var(--text-muted); line-height: 1.75; }
.knowledge-document-card footer { align-items: flex-end; border-top: 1px solid var(--border-soft); padding-top: 12px; }
.knowledge-document-card footer div { align-items: flex-start; flex-direction: column; gap: 2px; min-width: 0; }
.knowledge-document-card footer span { max-width: 150px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.knowledge-category { color: var(--brand-700); font-weight: 700; }
.knowledge-empty { grid-column: 1 / -1; }

.knowledge-detail-card { width: min(720px, calc(100vw - 28px)); }
.knowledge-detail-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.knowledge-detail-meta span { padding: 6px 9px; border-radius: 999px; background: var(--surface-muted); color: var(--text-muted); }
.knowledge-detail-content { max-height: 42vh; overflow: auto; padding: 16px; border: 1px solid var(--border-soft); border-radius: 14px; background: #f8fbff; white-space: pre-wrap; line-height: 1.8; }
.knowledge-detail-citation { padding: 12px 14px; border-left: 3px solid var(--brand-500); background: #eef5ff; color: var(--text-muted); }
.knowledge-editor-fields { display: grid; gap: 12px; }
.knowledge-editor-fields textarea { min-height: 180px; }

@media (max-width: 900px) {
  .knowledge-document-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .knowledge-library-summary,
  .knowledge-document-grid,
  .knowledge-library-toolbar { grid-template-columns: 1fr; }
  .knowledge-document-card { min-height: 0; }
}
