/* Books catalogue layout — mirrors authors header, filters, and selection. */
#library-view { --ink: var(--color-text); --muted: var(--color-text-secondary); --line: var(--color-border); --soft: var(--color-background); --surface: var(--color-surface); color:var(--ink); background:var(--soft); font-family:var(--font-body); }
#library-view [hidden] { display:none !important; }
#library-view .books-shell { container-type:inline-size; container-name:books-page; min-width:0; padding-bottom:32px; }
#library-view h1 { margin:0 0 32px; font-family:var(--font-head); font-size:var(--type-page-size); line-height:var(--type-page-line); font-weight:var(--weight-bold); letter-spacing:var(--tracking-page); }
#library-view button, #library-view input, #library-view select { font-family:inherit; font-size:var(--type-body-size); line-height:var(--type-body-line); }
#library-view :is(.books-facet-chip, .books-facet-trigger, .books-sort, .books-sort select, select.ds-field, .catalog-select) {
  font-size: var(--type-caption-size);
  line-height: var(--type-caption-line);
}
#library-view button { cursor:pointer; }
#library-view :is(button,input,select):focus-visible { outline: var(--focus-ring); outline-offset:3px; }
#library-view :is(.books-facet-chip,.books-sort,select.ds-field):focus-visible,
#library-view .books-sort:focus-within,
#library-view .books-facet:has([aria-expanded="true"]) .books-facet-chip,
:is(#library-view, #authors-view, #series-view) .books-tab-search-input:focus-visible { outline:none; }
#library-view #library-count { color:var(--muted); white-space:nowrap; font-size:var(--type-lead-size); line-height:var(--type-lead-line); font-weight:var(--weight-regular); }
#library-view .books-clear { white-space:nowrap; }
#library-view .books-filters { display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin-bottom:24px; }
/* Soft filled filter pills — layout only; look in controls.css (dropdown). */
#library-view .books-facets { display:flex; align-items:center; flex-wrap:wrap; gap:10px; min-width:0; flex:0 1 auto; padding-left:0; border-left:0; }
#library-view .books-sort-wrap { display:flex; align-items:center; gap:10px; min-width:0; max-width:100%; margin-left:0; padding-left:0; border-left:0; order:2; }
#library-view .books-sort svg { width:16px; height:16px; flex-shrink:0; color:var(--color-icon-control, #454545); fill:currentColor; stroke:none; }
#library-view .books-facet { position:relative; min-width:0; max-width:100%; }
#library-view #library-all-filters {
  order:3;
  flex:0 0 auto;
  margin-left:0;
}
#library-view .books-all-filters svg {
  width:20px; height:20px; flex:0 0 20px;
  fill:currentColor; stroke:none;
}
:is(#library-view, #authors-view, #series-view) .books-tab-search { display:none; }
@media (max-width: 1199px) {
  :is(#library-view, #authors-view, #series-view) .books-tab-search {
    display:flex;
    align-items:center;
    gap:0;
    flex:0 0 auto;
    width:36px;
    max-width:36px;
    min-width:36px;
    height:36px;
    padding:0;
    overflow:hidden;
    border-radius:var(--radius-round);
    background:transparent;
    box-shadow:none;
    transition:
      width var(--motion-screen, 320ms) var(--motion-ease-dissolve, ease),
      max-width var(--motion-screen, 320ms) var(--motion-ease-dissolve, ease),
      min-width var(--motion-screen, 320ms) var(--motion-ease-dissolve, ease),
      flex-grow var(--motion-screen, 320ms) var(--motion-ease-dissolve, ease),
      gap var(--motion-tab, 180ms) var(--motion-ease-out, ease),
      padding var(--motion-tab, 180ms) var(--motion-ease-out, ease),
      border-radius var(--motion-tab, 180ms) var(--motion-ease-out, ease),
      background-color var(--motion-tab, 180ms) var(--motion-ease-out, ease),
      box-shadow var(--motion-tab, 180ms) var(--motion-ease-out, ease);
  }
  :is(#library-view, #authors-view, #series-view) .books-tab-search-toggle {
    flex:0 0 36px;
    width:36px;
    height:36px;
  }
  :is(#library-view, #authors-view, #series-view) .books-tab-search-toggle > :is([data-icon], svg) {
    width:20px; height:20px; flex:0 0 20px;
    fill:currentColor; stroke:none;
  }
  :is(#library-view, #authors-view, #series-view) .books-tab-search-input {
    display:block;
    flex:1 1 auto;
    width:auto;
    min-width:0;
    max-width:0;
    height:36px;
    margin:0;
    padding:0;
    border:0;
    outline:none;
    opacity:0;
    background:transparent;
    color:var(--ink);
    font:var(--type-body-size)/var(--type-body-line) var(--font-body);
    pointer-events:none;
    transition:
      opacity var(--motion-screen, 320ms) var(--motion-ease-dissolve, ease),
      max-width var(--motion-screen, 320ms) var(--motion-ease-dissolve, ease),
      padding var(--motion-tab, 180ms) var(--motion-ease-out, ease);
  }
  :is(#library-view, #authors-view, #series-view) .books-tab-search-input::-webkit-search-decoration,
  :is(#library-view, #authors-view, #series-view) .books-tab-search-input::-webkit-search-cancel-button,
  :is(#library-view, #authors-view, #series-view) .books-tab-search-input::-webkit-search-results-button,
  :is(#library-view, #authors-view, #series-view) .books-tab-search-input::-webkit-search-results-decoration {
    display:none;
    -webkit-appearance:none;
  }
  :is(#library-view, #authors-view, #series-view) .books-tab-search-clear {
    flex:0 0 24px;
    width:24px;
    height:24px;
    margin:0;
    color:var(--ink);
    opacity:0;
    pointer-events:none;
  }
  :is(#library-view, #authors-view, #series-view) .books-tab-search-clear svg {
    width:16px;
    height:16px;
    color:inherit;
    fill:currentColor;
    stroke:none;
  }
  :is(#library-view, #authors-view, #series-view) .books-tab-search.is-open {
    flex:1 1 auto;
    gap:8px;
    width:min(280px, 42vw);
    max-width:min(280px, 42vw);
    min-width:min(280px, 42vw);
    padding:0 12px 0 14px;
    border-radius:var(--radius-pill);
    background:var(--color-surface);
    box-shadow:var(--shadow-selected);
  }
  :is(#library-view, #authors-view, #series-view) .books-tab-search.is-open:focus-within {
    background:var(--color-surface);
    outline:none;
    box-shadow:var(--input-focus-ring);
  }
  :is(#library-view, #authors-view, #series-view) .books-tab-search.is-open .books-tab-search-input {
    max-width:100%;
    padding-left:0;
    opacity:1;
    pointer-events:auto;
  }
  :is(#library-view, #authors-view, #series-view) .books-tab-search.is-open .books-tab-search-clear:not([hidden]) {
    opacity:1;
    pointer-events:auto;
  }
  :is(#library-view, #authors-view, #series-view) .books-tab-search.is-open .books-tab-search-input:focus,
  :is(#library-view, #authors-view, #series-view) .books-tab-search.is-open .books-tab-search-input:focus-visible {
    outline:none;
    box-shadow:none;
  }
  @media (prefers-reduced-motion: reduce) {
    :is(#library-view, #authors-view, #series-view) .books-tab-search,
    :is(#library-view, #authors-view, #series-view) .books-tab-search-input { transition:none; }
  }
}
#library-view .books-badge { padding:0; border-radius:0; background:transparent; color:inherit; font-size:inherit; line-height:inherit; }
#library-view .books-facet-trigger { display:flex; align-items:center; gap:8px; white-space:nowrap; }
#library-view .books-facet-trigger svg { width:16px; height:16px; flex-shrink:0; margin-left:2px; color:var(--color-icon-control, #454545); fill:currentColor; stroke:none; }
#library-view .books-selected-chip svg { width:16px; height:16px; flex-shrink:0; fill:currentColor; stroke:none; }
#library-view .books-popover { position:absolute; right:0; top:calc(100% + 8px); z-index:25; width:min(400px,calc(100vw - 64px)); padding:16px; border:0; border-radius: var(--radius-layer); background:var(--surface); box-shadow: var(--ui-popup-shadow, var(--shadow-raised)); }
#library-view .books-option-search { width:100%;       }
#library-view .books-options { max-height:300px; overflow-y:auto; margin-top:8px; }
#library-view .books-option { display:grid; grid-template-columns:20px minmax(0,1fr) auto; align-items:start; gap:10px; padding:8px 0; color:var(--ink); font-size:var(--type-body-size); line-height:var(--type-body-line); cursor:pointer; }
#library-view .books-option input { width:18px; height:18px; margin:1px 0; accent-color:var(--ink); }
#library-view .books-option-count { color:var(--muted); }
#library-view .books-popover-footer { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:12px; padding-top:12px; border-top:1px solid var(--line); color:var(--muted); font-size:var(--type-caption-size); line-height:var(--type-caption-line); }
#library-view .books-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(210px, 1fr)); gap:24px 16px; align-items:start; padding-top:0; }
@media (min-width: 1200px) {
  #library-view .books-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}
#library-view .books-empty { padding:24px; border:1px solid var(--line); border-radius: var(--radius-panel); background:var(--surface); }
#library-view .books-more { display:block; width:100%; margin-top:24px;       }

@container books-page (max-width:903px) {
  #library-view .books-facets { padding-left:0; border-left:0; }
  #library-view .books-popover { left:0; right:auto; width:min(360px,calc(100vw - 64px)); }
}
html:has(#library-view.is-active), body:has(#library-view.is-active) { min-width:0; background: var(--color-background); }
.app-shell:has(#library-view.is-active) { height:auto; min-height:100dvh; overflow:visible; }

#library-view .books-header { display:flex; align-items:center; justify-content:space-between; gap:24px; margin-bottom:28px; }
#library-view .books-heading { display:flex; align-items:center; gap:28px; flex:1 1 auto; min-width:0; flex-wrap:wrap; }
#library-view .books-heading h1 { margin:0; flex:0 0 auto; }
#library-view #library-count {
  position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
}
/* Status tabs: канон в controls.css (Status tab). Здесь только раскладка в шапке. */
#library-view .books-statuses {
  flex:1 1 auto;
  margin-top:24px;
  margin-bottom:8px;
}
#library-view .books-filters { gap:10px; margin-bottom:24px; }

#library-view .books-facet-trigger { display:flex; align-items:center; gap:8px; white-space:nowrap; }
#library-view .books-facet-trigger svg { width:16px; height:16px; flex-shrink:0; margin-left:2px; color:var(--color-icon-control, #454545); fill:currentColor; stroke:none; }
#library-view .books-selected-chip svg { width:16px; height:16px; flex-shrink:0; fill:currentColor; stroke:none; }


#library-view .books-selection { display:flex; align-items:flex-start; gap:12px; margin-bottom:16px; color:var(--muted); font-size:var(--type-body-size); line-height:var(--type-body-line); }
#library-view .books-selection .ds-filter-reset { flex:0 0 auto; align-self:flex-start; }
#library-view .books-selected { display:flex; flex:1; flex-wrap:wrap; gap:8px; min-width:0; }
#library-view .books-selected-chip { display:flex; align-items:center; gap:10px;       text-align:left; }
#library-view .books-selected-chip svg { color:var(--muted); }
#library-view .books-selection > .books-clear { margin-left:auto; }
#library-view .books-popover { left:0; right:auto; width:min(380px,calc(100vw - 32px)); padding:16px; max-height:calc(100dvh - 160px); overflow:auto; }
#library-view .books-option-search-wrap { display:flex; align-items:center; gap:10px;    }
#library-view .books-option-search-wrap svg { width:20px; height:20px; flex-shrink:0; color:var(--muted); fill:currentColor; stroke:none; }
#library-view .books-option-search {      min-width:0; }

#library-view .books-options { max-height:360px; overscroll-behavior:contain; }
#library-view .books-option { align-items:center; padding:8px; border-radius: var(--radius-sm); gap:8px; }
#library-view .books-option.is-selected { background:var(--soft); }
#library-view .books-option:hover { background:var(--soft); }
#library-view .books-option-group + .books-option-group { border-top:1px solid var(--line); margin-top:12px; padding-top:12px; }
#library-view .books-option-group h3 { font-size:var(--type-body-size); line-height:var(--type-body-line); font-weight:var(--weight-semibold); margin:0 0 6px 8px; }
#library-view .books-heat-chips { display:flex; flex-wrap:wrap; gap:8px; }
#library-view .books-heat-chip { width:var(--control-height); min-width:var(--control-height); }

#library-view .books-options-empty { margin:8px 0 0; color:var(--muted); }
@container books-page (max-width:903px) {
  #library-view .books-header { flex-wrap:wrap; gap:20px; margin-bottom:24px; }
  #library-view .books-selection { flex-wrap:wrap; }
  #library-view .books-selected { flex-basis:calc(100% - 100px); }
}

/* Expanded local selection. Compact right drawer; long sets collapse, short sets stay visible. */
.books-advanced {
  position:fixed; inset:0 0 0 auto; margin:0; width:min(560px,100vw); max-width:100vw; height:100dvh; max-height:100dvh;
  padding:0; overflow:hidden; border:1px solid var(--line); border-right:0; border-radius:var(--radius-panel) 0 0 var(--radius-panel);
  background:var(--soft); color:var(--ink); box-shadow:var(--shadow-raised);
}
.books-advanced[open] { display:flex; flex-direction:column; animation:books-drawer-in .18s ease-out; }
.books-advanced::backdrop { background:rgba(0,0,0,.25); }
@keyframes books-drawer-in { from { transform:translateX(28px); opacity:.7; } to { transform:translateX(0); opacity:1; } }
.books-advanced-head,.books-advanced-footer {
  display:flex; align-items:center; justify-content:space-between; gap:16px; flex:0 0 auto; padding:18px 20px;
  background:var(--soft);
}
.books-advanced-head { border-bottom:0; }
.books-advanced-head h2 { margin:0; font-family:var(--font-head); font-size:var(--type-panel-size); line-height:var(--type-panel-line); font-weight:var(--weight-medium); letter-spacing:var(--tracking-panel); }
.books-advanced-head .ds-icon-btn svg { width:20px; height:20px; fill:currentColor; stroke:none; }
.books-advanced-body { min-height:0; padding:12px 20px 20px; overflow:auto; overscroll-behavior:contain; flex:1; background:var(--soft); }
.books-advanced-dropdowns-top .books-advanced-dropdown:first-child { margin-top:0; }
.books-advanced-block.books-advanced-dropdowns-top + .books-advanced-block { margin-top:24px; }
.books-advanced-block + .books-advanced-block,
.books-advanced-dropdown + .books-advanced-block,
.books-advanced-block + .books-advanced-dropdown { margin-top:24px; padding-top:0; border-top:0; }
.books-advanced-block h3 {
  margin:0;
  font-size:var(--type-lead-size);
  line-height:var(--type-lead-line);
  font-weight:var(--weight-semibold);
}
.books-advanced-block > h3 + * { margin-top:6px; }
.books-advanced-help { margin:0 0 12px; color:var(--muted); font-size:var(--type-caption-size); line-height:var(--type-caption-line); }
.books-advanced-pills { display:flex; flex-wrap:wrap; gap:8px; margin-top:0; }
.books-advanced-pills--secondary { margin-top:0; }
.books-advanced-pills--secondary::before { content:""; width:100%; height:0; }
.books-advanced-heat .ds-pill:not(:first-child) { min-width:38px; justify-content:center; }
.books-advanced-dropdowns-top { position:relative; z-index:0; }
.books-advanced-dropdown { position:relative; margin-top:6px; z-index:1; }
.books-advanced-dropdown[open] { z-index:20; }
.books-advanced-dropdown + .books-advanced-dropdown { margin-top:8px; }
.books-advanced-dropdown-trigger {
  box-sizing:border-box; display:flex; align-items:center; gap:8px;
  width:100%; min-height:var(--field-height, 36px); padding:0 12px 0 14px; list-style:none; border:0;
  border-radius:var(--ui-control-radius,var(--radius-pill)); background:var(--surface); color:var(--ink); box-shadow:var(--shadow-selected); cursor:pointer;
  font-size:var(--type-body-size); line-height:var(--type-body-line); font-weight:var(--weight-regular);
}
.books-advanced-dropdown-trigger > span:first-child { flex:1 1 auto; min-width:0; text-align:left; }
.books-advanced-dropdown-trigger::-webkit-details-marker { display:none; }
.books-advanced-dropdown-trigger:hover:not(:disabled) { background:var(--surface); box-shadow:var(--shadow-control-hover, var(--shadow-selected)); }
.books-advanced-dropdown-trigger:focus-visible { outline:2px solid transparent; outline-offset:2px; box-shadow:0 0 0 3px var(--ui-control-ring); }
.books-advanced-dropdown-trigger svg { flex:0 0 16px; width:16px; height:16px; margin-left:auto; color:var(--muted); fill:currentColor; stroke:none; transition:transform .15s; }
.books-advanced-dropdown[open] > .books-advanced-dropdown-trigger svg { transform:rotate(180deg); }
.books-advanced-dropdown-count { flex:0 0 auto; min-width:22px; padding:2px 6px; border-radius:var(--radius-pill); background:var(--surface); font-size:var(--type-caption-size); line-height:var(--type-caption-line); text-align:center; }
.books-advanced-dropdown-count[hidden] { display:none; }
.books-advanced-dropdown-panel {
  position:absolute; left:0; right:0; top:calc(100% + 8px); z-index:1;
  margin-top:0; padding:12px; border:0; border-radius:var(--radius-field);
  background:var(--surface); box-shadow:var(--ui-popup-shadow);
}
.books-advanced-dropdown:not([open]) > .books-advanced-dropdown-panel { display:none; }
.books-advanced-dropdown-tools { display:flex; align-items:center; gap:10px; }
.books-advanced-dropdown-tools .books-option-search-wrap {
  display:flex; align-items:center; gap:10px; flex:1; min-width:0;
}
.books-advanced-dropdown-tools .books-option-search-wrap :is(svg, .rm-icon) {
  width:20px; height:20px; flex-shrink:0; color:var(--muted); fill:currentColor; stroke:none;
}
.books-advanced-dropdown-tools .books-option-search {
  flex:1; min-width:0; width:100%; border:0; outline:none; background:transparent;
  font:inherit; color:inherit;
}
.books-advanced-options { max-height:260px; overflow:auto; overscroll-behavior:contain; margin-top:8px; }
.books-advanced-options .books-option {
  display:grid;
  grid-template-columns:20px minmax(0,1fr) auto;
  align-items:center;
  gap:8px;
  margin:0;
  padding:8px;
  border-radius:var(--radius-sm);
  color:var(--ink);
  font-size:var(--type-body-size);
  line-height:var(--type-body-line);
  cursor:pointer;
}
.books-advanced-options .books-option input {
  width:18px; height:18px; margin:0; accent-color:var(--ink);
}
.books-advanced-options .books-option.is-selected,
.books-advanced-options .books-option:hover { background:var(--soft); }
.books-advanced-options .books-option-count { color:var(--muted); }
.books-advanced-options .books-options-empty { grid-column:1/-1; margin:8px 0 0; color:var(--muted); }
.books-advanced-footer { border-top:0; justify-content:flex-end; align-items:flex-end; padding-top:12px; padding-bottom:20px; }
.books-advanced-footer-actions { display:flex; align-items:center; gap:14px; margin-left:auto; flex:0 0 auto; }
.books-advanced-footer-actions .books-advanced-apply {
  min-height:var(--control-height, 40px);
  padding:10px 22px;
  font-size:var(--type-lead-size);
  line-height:var(--type-lead-line);
}
.books-advanced-footer-actions .books-advanced-reset {
  min-height:var(--control-height, 40px);
  padding:10px 18px;
  white-space:nowrap;
}
.books-advanced-count { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
@media (prefers-reduced-motion:reduce) { .books-advanced[open] { animation:none; } .books-advanced-dropdown-trigger svg { transition:none; } }
@media (max-width:560px) {
  .books-advanced { border-width:0; border-radius:0; }
  .books-advanced-head,.books-advanced-footer { padding:16px; }
  .books-advanced-body { padding:16px; }
  .books-advanced-dropdown-tools { align-items:stretch; flex-direction:column; }
}
@media (max-width:420px) {
  .books-advanced-footer { flex-wrap:wrap; }
  .books-advanced-footer-actions { width:100%; justify-content:flex-end; }
  .books-advanced-footer-actions .books-advanced-apply { flex:1 1 auto; max-width:100%; }
}
