#knowledge-base-modal { z-index: 1600; padding: 20px; }
.kb-shell { width: min(900px, 100%); height: min(860px, 94dvh); display: flex; flex-direction: column; padding: 28px; background: var(--card); border: 1px solid var(--border); border-radius: 20px; box-sizing: border-box; box-shadow: 0 16px 70px #1c1b1a26; }
.kb-header { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.kb-header h2 { margin: 0; font-family: var(--serif); font-size: 27px; }
.kb-header-main { flex: 1; min-width: 0; }
.kb-header p { margin: 4px 0 0; color: var(--ink-soft); font-size: 13px; }
.kb-scroll { overflow-y: auto; min-height: 0; padding: 0 3px 15px; }
.kb-scroll [hidden], .kb-shell [hidden] { display: none !important; }
.kb-intro { line-height: 1.75; color: var(--ink-soft); margin-top: 0; }
.kb-toolbar, .kb-search, .kb-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.kb-toolbar { justify-content: space-between; }
.kb-search input { flex: 1; min-width: 140px; }
.kb-document { display: flex; flex-direction: column; text-align: left; width: 100%; padding: 20px; margin: 12px 0; gap: 9px; border-radius: 14px; border: 1px solid var(--border); background: var(--card); color: var(--ink); cursor: pointer; overflow-wrap: anywhere; }
.kb-document:hover { border-color: var(--pine-300); background: var(--pine-50); }
.kb-document-title { font-size: 17px; font-weight: 600; }
.kb-meta { color: var(--ink-soft); font-size: 13px; line-height: 1.8; }
.kb-state { display: inline-block; padding: 0 7px; border-radius: 8px; background: var(--bg-2); }
.kb-state.on { background: var(--pine-50); color: var(--pine-700); }
.kb-summary { color: var(--ink-soft); font-size: 14px; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.kb-empty { padding: 36px 20px; text-align: center; line-height: 1.9; color: var(--ink-soft); border: 1px dashed var(--border); border-radius: 14px; }
.kb-shell label { display: block; margin: 15px 0; color: var(--ink-soft); font-size: 14px; }
.kb-shell input, .kb-shell textarea, .kb-shell select { box-sizing: border-box; max-width: 100%; }
.kb-shell label > input:not([type=checkbox]), .kb-shell label > select, .kb-shell label > textarea { display: block; width: 100%; margin-top: 7px; }
.kb-shell .kb-check { display: flex; align-items: center; gap: 10px; }
.kb-check input { width: 20px; height: 20px; margin: 0; }
.kb-shell pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 15px/1.9 var(--sans); background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.kb-hit { font-size: 14px; line-height: 1.7; white-space: pre-wrap; max-height: 210px; overflow-y: auto; }
#kb-status { min-height: 22px; padding-top: 10px; color: var(--accent-dark); font-size: 14px; overflow-wrap: anywhere; }
#kb-read-summary { white-space: pre-wrap; line-height: 1.8; }
#kb-read-title { overflow-wrap: anywhere; }
@media (max-width: 600px) {
  #knowledge-base-modal { padding: 0; align-items: stretch; }
  .kb-shell { width: 100%; height: 100dvh; border: 0; border-radius: 0; padding: max(18px, env(safe-area-inset-top)) 18px max(12px, env(safe-area-inset-bottom)); }
  .kb-header h2 { font-size: 24px; }
  .kb-document { padding: 16px; }
  .kb-search { gap: 8px; }
  .kb-search button { padding-inline: 12px; }
  .kb-shell pre { padding: 14px; }
}
