/* Reference: Anna's catalog screenshot. Components and tokens: current app DS.
   Compact book geometry follows Search; desktop catalog is unchanged. */
.library-tabs, .library-search { display: none; }
.catalog-toolbar-tools--tablet .library-tabs :is(a, .library-tab, .ds-nav-item),
.reader-local-tabs .reader-local-tab,
.hist-view-tabs .hist-period-tab {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  flex: 0 0 auto;
  position: relative;
  min-height: 0;
  cursor: pointer;
  padding: 0 0 6px;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--muted, var(--color-text-secondary));
  box-shadow: none;
  text-decoration: none;
  font-family: var(--font-head);
  font-size: 24px;
  line-height: 32px;
  font-weight: var(--weight-regular, 400);
  letter-spacing: var(--tracking-page, 0);
}
.catalog-toolbar-tools--tablet .library-tabs :is(a, .library-tab, .ds-nav-item) {
  gap: 4px;
}
.catalog-toolbar-tools--tablet .library-tabs .library-tab-count {
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--color-icon-muted, var(--muted));
  font-size: 12px;
  line-height: 16px;
  font-weight: var(--weight-regular, 400);
  font-variant-numeric: tabular-nums;
}
.catalog-toolbar-tools--tablet .library-tabs :is(a, .library-tab, .ds-nav-item)[aria-current],
.reader-local-tabs .reader-local-tab[aria-pressed="true"],
.hist-view-tabs .hist-period-tab[aria-selected="true"] {
  color: var(--ink, var(--color-text));
  font-weight: var(--weight-bold, 700);
}
.catalog-toolbar-tools--tablet .library-tabs :is(a, .library-tab, .ds-nav-item)[aria-current]::after,
.reader-local-tabs .reader-local-tab[aria-pressed="true"]::after,
.hist-view-tabs .hist-period-tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 20px;
  height: 2px;
  background: var(--ink, var(--color-text));
  transform: translateX(-50%);
}
/* Open filter row: books desktop shows Автор · Среда · Жанры.
   Series: only Автор. Tablet/mobile: open facets hidden — inside «Все фильтры». */
#library-view .books-facet[data-facet="translation"],
#library-view .books-facet[data-facet="genre"],
#library-view .books-facet[data-facet="environment"],
#library-view .books-facet[data-facet="trope"],
#library-view .books-facet[data-facet="vibe"],
#library-view .books-facet[data-facet="author"],
#authors-view .authors-facet[data-facet="genre"],
#authors-view .authors-facet[data-facet="trope"],
#authors-view .authors-facet[data-facet="heat"],
#series-view .series-facet[data-facet="genre"],
#series-view .series-facet[data-facet="trope"],
#series-view .series-facet[data-facet="heat"],
#series-view .series-facet[data-facet="environment"],
#series-view .series-facet[data-facet="vibe"] {
  display: none;
}
/* Series: Автор always in the open row. */
#series-view .series-facet[data-facet="author"] {
  display: block;
}
/* Desktop books: Автор · Среда · Жанры before sort (tablet/phone → «Фильтры»). */
@media (min-width: 1200px) {
  #library-view .books-facet:is(
    [data-facet="author"], [data-facet="environment"], [data-facet="genre"]
  ) {
    display: block;
  }
  html.public-catalog-browse #library-view .books-facet[data-facet="translation"] {
    display: block;
  }
  #library-view .books-facet[data-facet="author"] { order: 1; }
  #library-view .books-facet[data-facet="environment"] { order: 2; }
  #library-view .books-facet[data-facet="genre"] { order: 3; }
  #library-view .books-facet[data-facet="translation"] { order: 4; }
  #library-view .books-filters {
    --books-filters-gap: 10px;
    gap: var(--books-filters-gap);
    justify-content: flex-end;
    /* Keep search + facets + sort as one right-hand group opposite «Книги». */
    margin-left: auto;
    flex: 0 1 auto;
    width: auto;
    max-width: 100%;
  }
  #library-view .books-facets {
    flex: 0 1 auto;
    /* Must stay 0: auto recreates the empty mid-row between search and Автор. */
    margin-left: 0;
    gap: var(--books-filters-gap);
    /* Parent gap already adds one unit; +one more → 2× before Goodreads. */
    margin-inline-end: var(--books-filters-gap);
  }
  #library-view .books-sort-wrap,
  html.catalog-responsive #library-view .catalog-toolbar-tools .books-sort-wrap {
    margin-left: 0;
  }
  /* Desktop collections: search only in the header field. */
  #collections-view .books-tab-search {
    display: none !important;
  }
}
html.shared-catalog #library-view .books-facet[data-facet="genre"],
html.shared-catalog #library-view .books-facet[data-facet="environment"],
html.shared-catalog #library-view .books-facet[data-facet="author"],
html.shared-catalog #library-view .books-facet[data-facet="trope"],
html.shared-catalog #authors-view .authors-facet[data-facet="genre"],
html.shared-catalog #authors-view .authors-facet[data-facet="trope"],
html.shared-catalog #authors-view .authors-facet[data-facet="heat"] {
  display: block;
}
html.shared-catalog #library-view .books-facets,
html.shared-catalog #authors-view .authors-facets {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
}
html.shared-catalog #library-view .books-facet[data-facet="author"] { order: 1; }
html.shared-catalog #library-view .books-facet[data-facet="environment"] { order: 2; }
html.shared-catalog #library-view .books-facet[data-facet="genre"] { order: 3; }
html.shared-catalog #library-view .books-facet[data-facet="trope"] { order: 4; }
html.shared-catalog #library-view .books-facet[data-facet="vibe"] { order: 5; }
html.shared-catalog #authors-view .authors-facet[data-facet="genre"] { order: 1; }
html.shared-catalog #authors-view .authors-facet[data-facet="environment"] { order: 2; }
html.shared-catalog #authors-view .authors-facet[data-facet="trope"] { order: 3; }
html.shared-catalog #authors-view .authors-facet[data-facet="vibe"] { order: 4; }
html.shared-catalog #authors-view .authors-facet[data-facet="heat"] { order: 5; }
html.shared-catalog #authors-view #authors-all-filters {
  display: none;
}
@media (max-width: 1199px) {
  /* Internal catalog: no local search on series / collections (tablet + phone). */
  html.catalog-responsive:not(.public-catalog-browse)
    :is(#series-view, #collections-view) .books-tab-search {
    display: none !important;
  }
  /* The open search uses the same leading glyph treatment as the header field. */
  :is(#library-view, #authors-view, #series-view)
    .books-tab-search.is-open > .books-tab-search-toggle {
    flex: 0 0 18px;
    width: 18px;
    min-width: 18px;
    height: 18px;
    min-height: 18px;
    background: transparent;
    box-shadow: none;
    color: var(--color-icon-control, #454545);
    pointer-events: none;
  }
  :is(#library-view, #authors-view, #series-view)
    .books-tab-search.is-open > .books-tab-search-toggle svg {
    width: 18px;
    height: 18px;
    flex-basis: 18px;
  }
  /* Match search-page.css shell padding-inline (24 tablet / 12 mobile). */
  html.catalog-responsive .app-shell {
    --edge-bleed-inset: 24px;
  }
  .main-content > .library-tabs:not([hidden]) {
    display: flex;
    gap: 20px;
    margin: 0 0 20px;
    border-bottom: 0;
    overflow-x: auto;
  }
  .compact-library-panel .library-tabs:not([hidden]) {
    display: flex;
    gap: 20px;
    margin: 0;
    border-bottom: 0;
    justify-content: flex-start;
  }
  body:has(.library-tabs:not([hidden])) .header-search-wrap { display: none; }
  #library-view .books-heading h1,
  #authors-view .authors-heading h1,
  #series-view .series-heading h1,
  #collections-view .collections-heading h1 { display: none; }
  #library-view .library-search { display: flex; align-items: center; gap: 12px; width: 100%; margin-bottom: 16px; }
  #library-search { flex: 1; width: 100%; min-width: 0; padding: 0; border: 0; outline: none; background: transparent; color: var(--color-text); }
  #library-view .library-search .search-icon,
  #library-view .library-search > svg.rm-icon { flex: 0 0 16px; width: 16px; height: 16px; box-sizing: border-box; }
  #library-view .books-header,
  #authors-view .authors-header,
  #series-view .series-header { margin-bottom: 8px; }
  #series-view .series-header { margin-bottom: 4px; }
  #collections-view .collections-header { margin-bottom: 16px; }
  :is(#library-view, #authors-view, #series-view, #collections-view)
    :is(.books-heading, .authors-heading, .series-heading, .collections-heading)
    :is(.books-statuses, .authors-statuses, .series-statuses, .collections-statuses) {
    flex: 1 1 100%;
    min-width: 0;
  }
  /* Edge-bleed rows must outgrow content width so scroll clips at the screen edge. */
  :is(#library-view, #authors-view, #series-view, #collections-view)
    :is(.books-statuses, .authors-statuses, .series-statuses, .collections-statuses).edge-bleed-scroll {
    width: calc(100% + 2 * var(--edge-bleed-inset, 24px));
    max-width: none;
  }
  #library-view .books-statuses,
  #authors-view .authors-statuses,
  #series-view .series-statuses,
  #collections-view .collections-statuses,
  .home-favorite-filters {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 16px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-top: 24px;
    margin-bottom: 8px;
    padding-bottom: 0;
  }
  #series-view .series-statuses {
    margin-bottom: 4px;
  }
  #library-view .books-statuses::-webkit-scrollbar,
  #authors-view .authors-statuses::-webkit-scrollbar,
  #series-view .series-statuses::-webkit-scrollbar,
  #collections-view .collections-statuses::-webkit-scrollbar,
  .home-favorite-filters::-webkit-scrollbar {
    display: none;
  }
  :is(#library-view, #authors-view, #series-view, #collections-view)
    :is(.books-statuses, .authors-statuses, .series-statuses, .collections-statuses)
    > :is(.books-chip, .authors-chip, .collections-chip, .ds-segment-bar-item),
  .home-favorite-filters > .home-favorite-filter {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  #library-view .books-filters,
  #authors-view .authors-filters,
  #series-view .series-filters {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  /* Compact books toolbar: search + facets left; sort → all-filters (rightmost). */
  #library-view .books-tab-search {
    order: 0;
    flex: 0 0 auto;
    margin-left: 0;
    margin-right: 0;
  }
  #library-view .books-facets,
  #authors-view .authors-facets,
  #series-view .series-facets {
    flex-wrap: nowrap;
    flex: 0 1 auto;
    min-width: 0;
    order: 1;
  }
  #library-view .books-sort-wrap {
    order: 2;
    flex: 0 0 auto;
    margin-left: auto;
  }
  #library-view #library-all-filters {
    order: 3;
    flex: 0 0 auto;
    margin-left: 0;
  }
  /* Authors/series: sort + all-filters at the right edge. */
  #authors-view .authors-sort-wrap,
  #series-view .series-sort-wrap {
    order: 0;
    flex: 0 0 auto;
    margin-left: auto;
  }
  #authors-view #authors-all-filters,
  #series-view #series-all-filters {
    order: 2;
    flex: 0 0 auto;
    margin-left: 0;
  }
  #library-view .books-sort,
  #authors-view .authors-sort,
  #series-view .series-sort {
    width: auto;
    max-width: min(100%, 320px);
    flex: 0 0 auto;
  }
  #library-view .books-sort select,
  #authors-view .authors-sort select,
  #series-view .series-sort select {
    min-width: 0;
    width: auto;
    max-width: 100%;
  }
  #authors-view .authors-grid,
  #series-view .ser-results,
  #collections-view .col-results { padding-top: 0; }
  #library-view .books-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px 16px; }
  #library-view .medium-card.section-compact.four-up { display: flex; flex-direction: column; height: auto; min-width: 0; gap: 0; padding: 0; border: 0; background: var(--color-surface); border-radius: var(--radius-field); }
  #library-view .medium-card.section-compact.four-up .cover {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
    border-radius: var(--radius-field) var(--radius-field) 0 0;
    overflow: hidden;
  }
  #library-view .medium-card.section-compact.four-up .cover > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
  }
  #library-view .medium-card.section-compact.four-up .card-copy { min-width: 0; padding: 10px 10px 12px; }
  #library-view .medium-card.section-compact.four-up .title { margin: 0; font-size: var(--type-body-size); line-height: var(--type-body-line); }
  #library-view .medium-card.section-compact.four-up .author { font-size: var(--type-caption-size); }
  #library-view .medium-card .ds-book-facts { flex-wrap: wrap; white-space: normal; }
}
@media (min-width: 768px) and (max-width: 1199px) {
  /* Tablet open row: no Среда/Атмосфера — only inside «Все фильтры». */
  #library-view .books-facet[data-facet="environment"],
  #library-view .books-facet[data-facet="vibe"],
  #authors-view .authors-facet[data-facet="environment"],
  #authors-view .authors-facet[data-facet="vibe"],
  #series-view .series-facet[data-facet="environment"],
  #series-view .series-facet[data-facet="vibe"] {
    display: none;
  }
  #library-view .books-statuses,
  #authors-view .authors-statuses,
  #series-view .series-statuses,
  #collections-view .collections-statuses {
    margin-top: 22px;
  }
  /* Top row: tabs left · fixed-width search right. */
  .catalog-toolbar-tools--tablet {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    margin: 0 0 20px;
    min-width: 0;
    overflow: hidden;
  }
  .catalog-toolbar-tools--tablet .library-tabs:not([hidden]) {
    display: flex;
    flex: 1 1 auto;
    align-items: baseline;
    gap: 20px;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    border: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  /* Tabs sit in page padding already — cancel edge-bleed inset. */
  .catalog-toolbar-tools--tablet .library-tabs.edge-bleed-scroll {
    width: auto;
    max-width: 100%;
    margin-inline: 0;
    padding-inline: 0;
    scroll-padding-inline: 0;
  }
  .catalog-toolbar-tools--tablet .library-tabs:not([hidden])::-webkit-scrollbar {
    display: none;
  }
  /* Search: always-open field, compact width so all catalog tabs fit. */
  :is(#library-view, #authors-view, #series-view)
    .catalog-toolbar-tools--tablet
    .books-tab-search,
  :is(#library-view, #authors-view, #series-view)
    .catalog-toolbar-tools--tablet
    .books-tab-search.is-open {
    display: flex;
    flex: 0 0 240px;
    align-items: center;
    order: 1;
    width: 240px;
    max-width: 240px;
    min-width: 240px;
    height: 36px;
    margin: 0 0 0 auto;
    overflow: hidden;
    border-radius: var(--radius-pill);
    background: var(--color-surface);
    box-shadow: var(--shadow-selected);
  }
  :is(#library-view, #authors-view, #series-view)
    .catalog-toolbar-tools--tablet .books-tab-search,
  html.public-catalog-browse
    :is(#library-view, #authors-view, #series-view) .books-tab-search.is-open {
    gap: 10px;
    padding: 0 12px 0 14px;
  }
  html.public-catalog-browse
    :is(#library-view, #authors-view, #series-view) .books-tab-search.is-open .books-tab-search-input,
  :is(#library-view, #authors-view, #series-view)
    .catalog-toolbar-tools--tablet
    .books-tab-search-input {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: none;
    opacity: 1;
    pointer-events: auto;
    padding-left: 0;
  }
  :is(#library-view, #authors-view, #series-view)
    .catalog-toolbar-tools--tablet
    .books-tab-search-clear:not([hidden]) {
    opacity: 1;
    pointer-events: auto;
  }
  /* Second row: statuses left · sort → filters right. */
  :is(#library-view, #authors-view, #series-view, #collections-view)
    .catalog-status-bar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    margin: 0 0 16px;
  }
  :is(#library-view, #authors-view, #series-view, #collections-view)
    .catalog-status-bar
    :is(
      .books-statuses,
      .authors-statuses,
      .series-statuses,
      .collections-statuses
    ),
  :is(#library-view, #authors-view, #series-view, #collections-view)
    .catalog-status-bar
    :is(
      .books-statuses,
      .authors-statuses,
      .series-statuses,
      .collections-statuses
    ).edge-bleed-scroll {
    flex: 1 1 auto;
    min-width: 0;
    /* Beat edge-bleed 100%+width so pills don't paint over sort/filters. */
    width: auto;
    max-width: none;
    margin: 0;
    margin-inline: 0;
    padding-inline: 0;
    scroll-padding-inline: 0;
    order: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  :is(#library-view, #authors-view, #series-view, #collections-view)
    .catalog-status-bar
    :is(
      .books-statuses,
      .authors-statuses,
      .series-statuses,
      .collections-statuses
    )::-webkit-scrollbar {
    display: none;
  }
  :is(#library-view, #authors-view, #series-view)
    .catalog-status-bar
    :is(.books-sort-wrap, .authors-sort-wrap, .series-sort-wrap) {
    flex: 0 0 auto;
    min-width: auto;
    margin-left: auto;
    order: 1;
  }
  :is(#library-view, #authors-view, #series-view)
    .catalog-status-bar
    :is(#library-all-filters, #authors-all-filters, #series-all-filters) {
    flex: 0 0 auto;
    margin-left: 0;
    order: 2;
  }
  :is(#library-view, #authors-view, #series-view)
    .catalog-status-bar
    :is(.books-sort, .authors-sort, .series-sort) {
    flex: 0 0 auto;
    max-width: none;
    white-space: nowrap;
  }
  :is(#library-view, #authors-view, #series-view)
    .catalog-status-bar
    :is(.books-sort, .authors-sort, .series-sort)
    select {
    max-width: none;
    white-space: nowrap;
  }
  /* Facets row stays in DOM for restore; nothing visible on tablet open chrome.
     Collections too — empty .collections-filters still had margin-bottom: 24px. */
  :is(#library-view, #authors-view, #series-view, #collections-view)
    :is(.books-shell, .authors-shell, .series-shell, .collections-shell):has(> .catalog-status-bar)
    :is(.books-filters, .authors-filters, .series-filters, .collections-filters) {
    display: none;
  }
  /* Series desktop sort-wrap uses --type-page-line (52px); pills must stay 36px row. */
  #series-view .catalog-status-bar .series-sort-wrap {
    min-height: 36px;
    height: 36px;
  }
  :is(#library-view, #authors-view, #series-view, #collections-view)
    :is(
      .books-shell,
      .authors-shell,
      .series-shell,
      .collections-shell
    ):has(> .catalog-status-bar)
    :is(
      .books-header,
      .authors-header,
      .series-header,
      .collections-header
    ) {
    display: none;
  }
  #series-view .series-selection {
    margin-bottom: 0;
  }
}
@media (max-width: 767px) {
  html.catalog-responsive .app-shell {
    --edge-bleed-inset: 12px;
  }
  /* Mobile: no open facets — only sort + «Все фильтры». */
  #library-view .books-facet[data-facet="environment"],
  #library-view .books-facet[data-facet="vibe"],
  #authors-view .authors-facet[data-facet="environment"],
  #authors-view .authors-facet[data-facet="vibe"],
  #series-view .series-facet[data-facet="environment"],
  #series-view .series-facet[data-facet="vibe"] { display: none; }
  #library-view .books-filters,
  #authors-view .authors-filters,
  #series-view .series-filters {
    justify-content: flex-start;
  }
  /* Phone: search starts as a round button; expand fills leftover width and
     collapses sort to a round icon control. */
  :is(#library-view, #authors-view, #series-view) .books-tab-search {
    flex: 0 0 36px;
    gap: 0;
    width: 36px;
    max-width: 36px;
    min-width: 36px;
    height: 36px;
    padding: 0;
    overflow: hidden;
    border-radius: var(--radius-round);
    background: transparent;
    box-shadow: none;
  }
  :is(#library-view, #authors-view, #series-view)
    .books-tab-search:not(.is-open)
    > .books-tab-search-toggle {
    flex: 0 0 36px;
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    pointer-events: auto;
    background: var(--color-surface);
    box-shadow: var(--shadow-selected);
    color: var(--color-icon-control, #454545);
  }
  :is(#library-view, #authors-view, #series-view)
    .books-tab-search:not(.is-open)
    .books-tab-search-input,
  :is(#library-view, #authors-view, #series-view)
    .books-tab-search:not(.is-open)
    .books-tab-search-clear {
    max-width: 0;
    opacity: 0;
    pointer-events: none;
    padding: 0;
  }
  :is(#library-view, #authors-view, #series-view) .books-tab-search.is-open {
    flex: 1 1 auto;
    gap: 8px;
    width: auto;
    max-width: none;
    min-width: 0;
    height: 36px;
    /* Match soft-search canon: icon inset from the left edge. */
    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
    .books-tab-search-input {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: none;
    opacity: 1;
    pointer-events: auto;
    padding-left: 0;
  }
  :is(#library-view, #authors-view, #series-view)
    .books-tab-search.is-open
    .books-tab-search-clear:not([hidden]) {
    opacity: 1;
    pointer-events: auto;
  }
  /* Collapsed search: sort grows across leftover row width. */
  :is(#library-view, #authors-view, #series-view)
    .books-filters:not(.is-search-expanded)
    :is(.books-sort-wrap, .authors-sort-wrap, .series-sort-wrap) {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    width: auto;
  }
  :is(#library-view, #authors-view, #series-view)
    .books-filters:not(.is-search-expanded)
    :is(.books-sort, .authors-sort, .series-sort) {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: none;
  }
  :is(#library-view, #authors-view, #series-view)
    .books-filters:not(.is-search-expanded)
    :is(.books-sort, .authors-sort, .series-sort)
    select {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
  }
  :is(#library-view, #authors-view, #series-view)
    .books-filters.is-search-expanded
    :is(.books-sort, .authors-sort, .series-sort) {
    position: relative;
    box-sizing: border-box;
    flex: 0 0 36px;
    width: 36px;
    min-width: 36px;
    max-width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-round);
    background: var(--color-surface);
    box-shadow: var(--shadow-selected);
    overflow: hidden;
  }
  :is(#library-view, #authors-view, #series-view)
    .books-filters.is-search-expanded
    :is(.books-sort-wrap, .authors-sort-wrap, .series-sort-wrap) {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    max-width: none;
  }
  :is(#library-view, #authors-view, #series-view)
    .books-filters.is-search-expanded
    :is(.books-sort, .authors-sort, .series-sort)
    select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
  }
  #library-view .books-sort-wrap,
  #authors-view .authors-sort-wrap,
  #series-view .series-sort-wrap {
    order: 2;
    margin-left: 0;
  }
  #library-view #library-all-filters,
  #authors-view #authors-all-filters {
    order: 3;
    margin-left: 0;
  }
  #library-view .books-filters,
  #library-view .books-facets,
  #library-view .books-sort-wrap,
  #authors-view .authors-filters,
  #authors-view .authors-facets,
  #authors-view .authors-sort-wrap,
  #series-view .series-filters,
  #series-view .series-facets,
  #series-view .series-sort-wrap { gap: 6px; }
  #library-view .books-facet-chip,
  #authors-view .authors-facet-chip,
  #series-view .series-facet-chip { padding-inline: 10px; }
  #library-view .books-facet-trigger,
  #authors-view .authors-facet-trigger,
  #series-view .series-facet-trigger { gap: 4px; font-size: var(--type-caption-size); }

  /* Mobile: section switcher stays Nav tabs; status/kind filters → pills. */
  .library-tabs:not([hidden]) { gap: 16px; }
  #library-view .books-statuses,
  #authors-view .authors-statuses,
  #series-view .series-statuses,
  #collections-view .collections-statuses {
    gap: 8px;
    flex-wrap: nowrap;
  }
  /* Bottom gap under kind pills = half of the top gap above them (24 → 12). */
  #collections-view .collections-statuses {
    margin-bottom: 12px;
  }
  #collections-view .collections-header {
    margin-bottom: 0;
  }
  :is(#library-view, #authors-view, #series-view, #collections-view)
    :is(.books-statuses, .authors-statuses, .series-statuses, .collections-statuses)
    :is(.books-chip, .authors-chip, .ds-segment-bar-item, .series-status-tab) {
    min-height: var(--control-height-compact, 32px);
    height: auto;
    padding: 6px 12px;
    gap: 6px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    box-shadow: var(--shadow-selected);
    font-size: var(--type-caption-size);
    line-height: var(--type-caption-line);
    font-weight: var(--weight-regular, 400);
  }
  :is(#library-view, #authors-view, #series-view, #collections-view)
    :is(.books-statuses, .authors-statuses, .series-statuses, .collections-statuses)
    :is(.books-chip, .authors-chip, .ds-segment-bar-item, .series-status-tab):is([aria-pressed="true"], .is-selected, .is-active) {
    background: var(--color-text);
    color: var(--color-surface);
    box-shadow: none;
    font-weight: var(--weight-medium, 500);
  }
  :is(#library-view, #authors-view, #series-view, #collections-view)
    :is(.books-statuses, .authors-statuses, .series-statuses, .collections-statuses)
    :is(.books-chip, .authors-chip, .ds-segment-bar-item, .series-status-tab)::after,
  :is(#library-view, #authors-view, #series-view, #collections-view)
    :is(.books-statuses, .authors-statuses, .series-statuses, .collections-statuses)
    :is(.books-chip, .authors-chip, .ds-segment-bar-item, .series-status-tab)
    > span:first-child::after {
    content: none !important;
    display: none !important;
  }
  :is(#library-view, #authors-view, #series-view, #collections-view)
    :is(.books-statuses, .authors-statuses, .series-statuses, .collections-statuses)
    :is(.books-badge, .authors-badge, .ds-segment-bar-badge) {
    color: inherit;
  }
  /* Mobile books: vertical cover cards, three per row (tablet layout, denser gap). */
  #library-view .books-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px 8px;
  }
}

/* Desktop catalog description uses the cover's existing clipping and click target. */
.catalog-cover-description {
  display: none;
}

@media (min-width: 1200px) and (hover: hover) and (pointer: fine) {
  .catalog-cover-description {
    position: absolute;
    inset: 0;
    z-index: 1;
    box-sizing: border-box;
    display: grid;
    grid-template-rows: 2px minmax(0, 1fr);
    gap: 12px;
    border-radius: inherit;
    padding: 18px;
    overflow: hidden;
    pointer-events: none;
    background: var(--color-surface);
    color: var(--ds-color-text);
    font-size: var(--type-body-size);
    line-height: var(--type-body-line);
    opacity: 0;
    visibility: hidden;
    transition: opacity 200ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s 200ms;
  }

  @supports ((backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px))) {
    .catalog-cover-description {
      background: color-mix(in srgb, var(--color-surface) 90%, transparent);
      -webkit-backdrop-filter: blur(8px);
      backdrop-filter: blur(8px);
    }
  }

  .catalog-cover-description::before {
    content: "";
    width: 24px;
    border-radius: 0.5px;
    background: var(--color-text-secondary);
    opacity: 0.6;
  }

  .catalog-cover-description > span {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: var(--description-lines, 1);
    overflow: hidden;
    overflow-wrap: anywhere;
    transform: translateY(4px);
    transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .catalog-cover-description.is-visible {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
  }

  .catalog-cover-description.is-visible > span {
    transform: translateY(0);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .catalog-cover-description {
    background: var(--color-surface);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .catalog-cover-description,
  .catalog-cover-description > span {
    transition: none;
    transform: none;
  }
}
