.kb-library, .kb-form { display: grid; gap: 15px; padding: 17px 21px 21px; }
.kb-library-toolbar, .kb-selection-head, .kb-inline-actions { display:flex; gap:14px; align-items:center; justify-content:space-between; }
.kb-library-toolbar { flex-wrap:wrap; }
.kb-library-toolbar > .button { margin-left:auto; }
.kb-search { flex:1; min-width:min(190px, 100%); }
.kb-search input { width:100%; }
.kb-group h3 { color:var(--green-dark); margin:10px 0 6px; font-size:14px; font-weight:650; }
.kb-group h3 span { font-weight:400; color:var(--muted); margin-left:4px; }
.kb-group ul,.kb-pick-list,.kb-selection-list ul { margin:0; padding:0; list-style:none; }
.kb-group li,.kb-pick-list li,.kb-selection-list li { border-top:1px solid var(--line); }
.kb-read > summary { cursor:pointer; font-size:14px; padding:11px 0; overflow-wrap:anywhere; }
.kb-read > summary strong { font-weight:620; }
.kb-origin { font-size:12px; color:var(--muted); overflow-wrap:anywhere; display:block; line-height:1.55; font-weight:460; }
.kb-read > summary .kb-origin { padding-left:15px; margin-top:2px; }
.kb-text,.kb-excerpt { white-space:pre-wrap; overflow-wrap:anywhere; font-size:14px; line-height:1.65; }
.kb-text { padding:12px 14px; margin:0 0 10px; background:#f4f3ed; border-left:2px solid #c5cfc3; }
.kb-inline-actions { justify-content:flex-start; padding-bottom:12px; }
.kb-import { padding:12px 14px; background:#f4f3ed; display:grid; gap:6px; font-size:14px; }
.kb-import small,.kb-picker-lead,.kb-file-status,.kb-empty { color:var(--muted); font-size:13px; line-height:1.65; }
.kb-import input { max-width:100%; }
.kb-file-status:empty { display:none; }
.kb-form .form-actions { padding:8px 0 0; }
.kb-danger { color:white; background:#85452f; border-color:#85452f; }
.kb-check { cursor:pointer; display:flex; align-items:flex-start; gap:10px; padding:11px 0 3px; }
.kb-check input { margin-top:4px; flex:none; accent-color:var(--green); }
.kb-check strong { font-size:14px; overflow-wrap:anywhere; }
.kb-pick-preview { margin:0 0 8px 23px; }
.kb-pick-preview summary,.kb-selection-list > summary { font-size:12px; color:var(--green-dark); cursor:pointer; padding:4px 0; }
.kb-selection { min-width:0; margin-bottom:18px; border:1px solid var(--line); border-left:3px solid #9eaf9c; background:#f6f7f1; padding:12px 16px; border-radius:4px; }
.kb-selection-head > div { min-width:0; overflow-wrap:anywhere; }
.kb-selection-head span { font-size:12px; color:var(--muted); }
.kb-selection-head p { margin:2px 0 0; font-size:14px; line-height:1.4; font-weight:560; }
.kb-selection-head .button { white-space:nowrap; }
.kb-selection-list { margin-top:6px; }
.kb-selection-list li { margin-top:8px; padding-top:8px; }
.kb-selection-list li > strong { font-size:14px; overflow-wrap:anywhere; }
.kb-excerpt { margin:6px 0; }
.workspace:has(> #budget-form) > .kb-selection { grid-column:1 / -1; }
@media (max-width:640px) {
  .kb-form,.kb-library { padding:14px; }
  .kb-selection { padding:10px 12px; }
  .kb-form .field-input,.kb-search .field-input { font-size:16px; }
}
@media print { .kb-selection { display:none !important; } }
.kb-unassigned { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px 16px; color:var(--muted); border-bottom:1px solid var(--line); padding:0 0 12px; margin-bottom:15px; font-size:13px; }
.kb-picker-add { margin:0 21px 20px; }
@media screen and (min-width:1190px) {
  .workspace:has(> :is(.kb-selection,.kb-unassigned)) { --kb-strip-rows:1; }
  .workspace:has(> .quote-stale) { --kb-stale-rows:1; }
  .workspace:has(> [data-workspace-storage-warning]:not([hidden])) { --kb-warning-rows:1; }
  .workspace:has(> #budget-form) > :is(.kb-selection,.kb-unassigned,[data-workspace-storage-warning]) { grid-column:1 / -1; margin-bottom:0; }
  .workspace:has(> #budget-form) > #budget-form + .proposal { grid-row-start:calc(2 + var(--kb-strip-rows, 0) + var(--kb-stale-rows, 0) + var(--kb-warning-rows, 0)); }
}
@media print { .kb-unassigned { display:none !important; } }

.kb-collections { display:flex; align-items:center; flex-wrap:wrap; gap:7px 15px; border:0; margin:0; padding:0; }
.kb-collections legend { float:left; margin:0 6px 0 0; padding:7px 0; font-size:13px; font-weight:600; }
.kb-collections label { display:flex; align-items:center; gap:5px; padding:7px 0; font-size:14px; cursor:pointer; }
.kb-collections input { margin:0; accent-color:var(--green-dark); }
.kb-field-note,.kb-notes small { margin:0; color:var(--muted); font-size:12px; line-height:1.55; }
.kb-collections + .kb-field-note,.kb-field-note { margin-top:-7px; }
.kb-form [hidden] { display:none !important; }
.kb-form .kb-import { display:flex; flex-wrap:wrap; align-items:center; gap:6px 12px; padding:0; color:var(--muted); background:transparent; font-size:12px; }
.kb-import input::file-selector-button { cursor:pointer; padding:4px 9px; border:1px solid var(--line); background:#fff; color:var(--green-dark); border-radius:2px; }
.kb-notes { border-top:1px solid var(--line); }
.kb-notes > summary { padding:11px 0 3px; cursor:pointer; font-weight:600; font-size:14px; }
.kb-notes > summary span { margin-left:8px; font-size:12px; font-weight:400; color:var(--muted); }
.kb-notes > div { display:grid; justify-items:start; gap:5px; padding-top:9px; }
.kb-notes .field { width:100%; }
.kb-detail-label { margin:0 0 5px; font-size:12px; color:var(--green-dark); }
.kb-read .kb-excerpt { margin:4px 0 14px; }
.kb-selection-empty { padding:0 0 10px; border:0; border-bottom:1px solid var(--line); border-radius:0; background:transparent; }
.kb-selection-empty .button { min-height:32px; padding:5px 12px; }
.kb-selection-list .kb-pick-preview { margin-left:0; }

@media screen {
  .standalone-shell .kb-selection {
    padding: 9px 14px;
    margin: 0 0 16px;
    border: 0;
    border-left: 2px solid #aab69d;
    border-radius: 0;
    background: #eef1e8;
  }
  .standalone-shell .kb-selection-empty {
    background: transparent;
    border: 0;
    border-top: 1px solid var(--line);
    padding: 5px 0 0;
  }
  .standalone-shell .kb-selection-empty .kb-selection-head {
    justify-content: flex-start;
    gap: 14px;
  }
  .standalone-shell .kb-selection-head .button {
    background: transparent;
    min-height: 32px;
    padding: 3px 2px;
    border: 0;
    color: #38533c;
    text-decoration: underline;
    text-underline-offset: 3px;
  }
  .standalone-shell .kb-selection-head .button:hover { color: #873f2c; }
  #knowledge-material-form .kb-collections { gap: 0; }
  #knowledge-material-form .kb-collections legend { padding-right: 10px; color: #465345; }
  #knowledge-material-form .kb-collections label {
    padding: 6px 11px;
    border: 1px solid #bfc6b6;
    color: #485347;
    background: #fffefa;
  }
  #knowledge-material-form .kb-collections label + label { border-left: 0; }
  #knowledge-material-form .kb-collections label:has(:checked) {
    background: #e9eee3;
    color: #243e2b;
    font-weight: 650;
  }
  #knowledge-material-form .kb-collections label:focus-within { outline: 2px solid #855138; outline-offset: 2px; }
  #knowledge-material-form .kb-import input::file-selector-button { padding: 5px 10px; background: #f4f3ec; }
  #knowledge-material-form .kb-notes > summary { min-height: 36px; }
}
@media screen and (min-width: 1190px) {
  .standalone-shell .workspace:has(> #budget-form) > .kb-selection { margin-bottom: 0; }
}
