.library-form { margin-bottom: 24px; }
.library-query-heading { font-size: 14px; margin: 0 0 18px; color: var(--muted); }
.library-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 170px auto auto; gap: 12px; align-items: center; }
.library-search { position: relative; min-width: 0; }
.library-search input { width: 100%; padding-right: 48px; height: 44px; }
.library-search button { position: absolute; inset: 0 4px 0 auto; width: 38px; display: grid; place-items: center; color: var(--muted); background: transparent; border: 0; border-radius: 6px; }
.library-search button:hover { color: var(--text); }
.library-search svg, .library-filter-toggle svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.library-sort { height: 44px; width: 100%; font-size: 13px; }
.library-order, .library-filter-toggle { height: 44px; display: flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); border-radius: 7px; padding: 0 13px; color: var(--muted); font-size: 12px; white-space: nowrap; background: var(--panel); }
.library-order { position: relative; cursor: pointer; }
.library-order input { position: absolute; opacity: 0; width: 1px; height: 1px; padding: 0; }
.library-order:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.library-order .order-asc, .library-order input:checked ~ .order-desc { display: none; }
.library-order input:checked ~ .order-asc { display: inline; color: var(--text); }
.library-filter-toggle[aria-expanded="true"] { border-color: var(--muted); color: var(--text); background: var(--soft); }
.filter-count { display: grid; place-items: center; min-width: 18px; height: 18px; border-radius: 9px; background: var(--soft); color: var(--text); font-size: 10px; }
.library-filter-panel { padding: 22px; margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.library-more-filters { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.library-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.library-fields > label { display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: 12px; min-width: 0; }
.library-fields select, .library-fields input { width: 100%; height: 40px; font-size: 12px; }
.library-fields .library-author { grid-column: span 2; }
.library-tag-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; margin-top: 24px; padding-top: 21px; border-top: 1px solid var(--line); }
.library-tag-picker { min-width: 0; }
.tag-picker-heading { min-height: 30px; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); }
.tag-picker-heading select { height: 30px; padding-top: 3px; padding-bottom: 3px; font-size: 11px; }
.tag-picker-search { position: relative; }
.tag-picker-search input { width: 100%; height: 40px; font-size: 12px; }
.tag-suggestions { position: absolute; top: calc(100% + 5px); left: 0; right: 0; max-height: 240px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 25px #0002; padding: 5px; z-index: 25; }
.tag-suggestions button { display: block; width: 100%; padding: 9px; text-align: left; border-radius: 4px; font-size: 12px; }
.tag-suggestions button:hover, .tag-suggestions button[aria-selected="true"] { background: var(--soft); }
.tag-suggestions p { padding: 9px; font-size: 12px; color: var(--muted); margin: 0; }
.tag-selected { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.tag-selected button, .library-filter-summary > span { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 5px; padding: 4px 8px; background: var(--soft); color: var(--muted); font-size: 11px; }
.tag-selected button span:last-child { font-size: 14px; line-height: 1; }
.tag-picker-status { color: var(--muted); font-size: 11px; margin-top: 5px; }
.tag-picker-status:empty { display: none; }
.library-filter-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 20px; margin-top: 20px; border-top: 1px solid var(--line); }
.library-author-note { font-size: 12px; color: var(--muted); margin-top: 16px; }
.library-filter-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.library-filter-summary > a { color: var(--muted); font-size: 11px; padding: 4px; }
@media (max-width: 850px) { .library-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) {
  .library-form { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
  .library-toolbar { grid-template-columns: minmax(0, 1fr) auto auto; gap: 9px; }
  .library-search { grid-column: 1 / -1; }
  .library-filter-panel { padding: 0; border: 0; }
  .library-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 12px; }
  .has-collapsible-filters:not(.filters-expanded) #library-common-filters > label:not([data-primary-filter]),
  .has-collapsible-filters:not(.filters-expanded) .library-filter-actions { display: none; }
  .library-tag-columns { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .library-order, .library-filter-toggle { padding: 0 11px; }
}
