/* Existing book panels, catalog chips and DS controls remain the visual reference. */
.author-detail-layout { grid-template-areas: "profile books" "filters books"; grid-template-rows: minmax(0, 1fr) auto; }
.author-detail-side { grid-area: profile; }
#author-quick-filters { grid-area: filters; }
.author-series-panel { grid-area: books; }
.author-filter-quick { display: none; }
.author-filter-desktop { display: flex; flex-wrap: wrap; gap: 16px; }
.author-filter-sheet { box-sizing: border-box; width: min(620px, 100%); max-width: 100%; max-height: 85dvh; margin: auto auto 0; padding: 0; border: 0; border-radius: var(--radius-panel) var(--radius-panel) 0 0; background: var(--surface); color: var(--ink); font-family: var(--font-body); box-shadow: var(--shadow-raised); }
.author-filter-sheet::backdrop { background: rgba(0, 0, 0, .28); }
.author-filter-sheet[open] { display: flex; flex-direction: column; }
.author-filter-sheet-head, .author-filter-sheet-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px; flex: 0 0 auto; }
.author-filter-sheet-head h2 { margin: 0; font-size: var(--type-panel-size); line-height: var(--type-panel-line); }
.author-filter-sheet-body.col-detail-filters { display: flex; flex-direction: column; align-items: stretch; gap: 20px; padding: 0 24px 24px; overflow-y: auto; min-height: 0; }
.author-filter-sheet-body .col-detail-filter { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.author-filter-sheet-body .col-detail-filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.author-filter-sheet-footer { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
.author-filter-sheet-footer .ds-btn { flex: 1; }
/* Shared tablet/detail layout for catalog entity pages and add-from-catalog sheet. */
.entity-detail-compact .author-detail-layout {
  grid-template-areas: "profile" "books";
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto;
  height: auto;
  overflow: visible;
}
.entity-detail-compact .author-filters-fold #author-quick-filters,
.entity-detail-compact .author-filters-fold .author-filters {
  grid-area: auto;
  width: 100%;
}
.entity-detail-compact .author-detail-side,
.entity-detail-compact .author-profile,
.entity-detail-compact .author-series-panel {
  height: auto;
  overflow: visible;
  min-width: 0;
}
.entity-detail-compact .author-series-panel {
  margin-top: 0;
}
.entity-detail-compact .author-series-toolbar {
  flex-wrap: wrap;
  align-items: flex-start;
}
/* 36px select sits below tab label/count; lift to optical center. */
.entity-detail-compact #author-series-sort-wrap {
  margin-top: -6px;
}
.entity-detail-compact .series-card {
  --series-card-pad: 14px;
  grid-template-columns: minmax(0, 1fr);
  padding: var(--series-card-pad);
}
.entity-detail-compact .series-card .series-rail {
  /* Negative margin lets the rail scroll to the card edges; matching
     padding keeps the resting books aligned with the series title. */
  margin-inline: calc(-1 * var(--series-card-pad));
  padding-inline: var(--series-card-pad);
  padding-block: 2px 4px;
  width: auto;
  max-width: none;
}
.entity-detail-compact .series-book-card {
  flex-basis: 160px;
  width: 160px;
  min-width: 160px;
}
.entity-detail-compact .series-book-copy small {
  display: none;
}
.entity-detail-compact .ser-detail-layout {
  grid-template-columns: minmax(0, 1fr);
}
.entity-detail-compact .ser-detail-profile,
.entity-detail-compact .ser-detail-side,
.entity-detail-compact .col-detail-side,
.entity-detail-compact .ser-detail-books {
  width: 100%;
  min-width: 0;
}
.entity-detail-compact .ser-detail-profile {
  padding: 12px;
  gap: 10px;
}
.entity-detail-compact .ser-detail-books-stack {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.entity-detail-compact .ser-detail-books-stack .ser-overview-book {
  width: auto;
}
.entity-detail-compact .ser-detail-meta-row {
  align-items: flex-start;
}
.entity-detail-compact .ser-detail-scores {
  flex: 1 1 auto;
  min-width: 0;
}
.entity-detail-compact .author-profile-head h1 {
  font-size: var(--type-panel-size);
  line-height: var(--type-panel-line);
}
.entity-detail-compact.ds-book-detail .book-detail-layout,
.entity-detail-compact .book-detail-layout {
  grid-template-columns: minmax(0, 1fr);
  height: auto;
  overflow: visible;
}
.entity-detail-compact.ds-book-detail .bd-main,
.entity-detail-compact .bd-main {
  height: auto;
  overflow: visible;
  min-width: 0;
}
.entity-detail-compact.ds-book-detail .bd-left-body {
  /* Column matches the 126px cover, so the text sits one short gap away. */
  grid-template-columns: 126px minmax(0, 1fr);
  gap: 20px;
}
.entity-detail-compact.ds-book-detail .bd-cover-column {
  width: 126px;
}
@media (max-width: 640px) {
  .entity-detail-compact.ds-book-detail .bd-left-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .entity-detail-compact.ds-book-detail .bd-cover-column {
    width: min(180px, 100%);
  }
}
.entity-detail-compact .author-filters .col-detail-filters {
  gap: 10px 14px;
  padding: 14px 18px;
}
.entity-detail-compact .author-filters-fold .author-filters,
.entity-detail-compact .ser-detail-filters-fold .author-filters {
  padding: 10px 0 0;
  background: transparent;
}
.entity-detail-compact .author-filters-fold .col-detail-filters,
.entity-detail-compact .ser-detail-filters-fold .col-detail-filters {
  padding: 0;
  gap: 16px;
}
@media (max-width: 1199px) {
  .entity-detail-compact .author-filters-fold .author-filters,
  .entity-detail-compact .ser-detail-filters-fold .author-filters {
    padding: 12px 0 0;
  }
  .entity-detail-compact .author-filters-fold .col-detail-filters,
  .entity-detail-compact .ser-detail-filters-fold .col-detail-filters {
    padding: 0;
    gap: 12px;
  }
  .entity-detail-compact .author-filters-fold .col-detail-filter-label,
  .entity-detail-compact .ser-detail-filters-fold .col-detail-filter-label {
    padding-top: 0;
  }
}
@media (max-width: 700px) {
  .entity-detail-compact .ser-detail-books-stack {
    grid-template-columns: minmax(0, 1fr);
  }
  .entity-detail-compact .ser-detail-books-stack .ser-overview-book {
    --ser-cover-h: 134px;
    width: auto;
  }
  .entity-detail-compact .ser-detail-books-stack .ser-overview-book-button {
    grid-template-columns: 90px minmax(0, 1fr);
    gap: 12px;
    height: auto;
  }
  .entity-detail-compact .ser-detail-books-stack .ser-overview-cover {
    width: 90px;
    height: var(--ser-cover-h);
  }
  .entity-detail-compact .ser-detail-books-stack .ser-overview-book-copy {
    height: auto;
    min-height: 0;
  }
}
@media (max-width: 1199px) {
  html.catalog-responsive .author-detail-shell,
  html.catalog-responsive .book-detail-shell { height: auto; min-height: 0; display: grid; }
  html.catalog-responsive .author-detail-top,
  html.catalog-responsive .book-detail-top { margin-bottom: 0; }
  /* Same empty space above the profile card as the page side gutter. */
  html.catalog-responsive #author-view.entity-detail-compact .author-detail-layout {
    margin-top: var(--edge-bleed-inset, 24px);
  }
  html.catalog-responsive #book-view.entity-detail-compact .book-detail-layout {
    margin-top: var(--edge-bleed-inset, 24px);
  }
  html.catalog-responsive .book-detail-layout { grid-template-columns: minmax(0, 1fr); height: auto; overflow: visible; }
  html.catalog-responsive .book-detail-layout .bd-main,
  html.catalog-responsive .book-detail-layout .bd-right { height: auto; overflow: visible; min-width: 0; }
  html.catalog-responsive .ds-book-detail .bd-left-body { grid-template-columns: 126px minmax(0, 1fr); gap: 20px; }
  html.catalog-responsive .ds-book-detail .bd-cover-column { width: 126px; }
  .author-filter-quick, .author-filter-read { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .author-filter-desktop { display: none; }
  .author-profile-about, .bd-description, .bd-review, .author-profile-head h1 { overflow-wrap: anywhere; }
}
@media (max-width: 640px) {
  html.catalog-responsive .ds-book-detail .bd-left-body { grid-template-columns: minmax(0, 1fr); }
  html.catalog-responsive .ds-book-detail .bd-cover-column { width: min(180px, 100%); }
  .author-filter-sheet-head, .author-filter-sheet-footer { padding-left: 16px; padding-right: 16px; }
  .author-filter-sheet-body.col-detail-filters { padding-left: 16px; padding-right: 16px; }
}

html:has(.author-filter-sheet[open]) { overflow: hidden; }
/* The host HTML owns more specific drawer rules; override them at the same scope. */
@media (max-width: 1199px) {
  #capture-drawer .q-book-layout { grid-template-columns: minmax(0, 1fr); }
  #capture-drawer .q-book-layout > aside { width: 160px; max-width: 100%; }
}
@media (max-width: 640px) {
  #capture-drawer .q-book-identity .q-field-row,
  #capture-drawer .q-book-identity .q-field-row--meta,
  #capture-drawer .q-book-identity .q-field-row--translation { grid-template-columns: minmax(0, 1fr); }
}

/* One filter component and surface for author, series and collection books. */
.author-filters { min-width: 0; padding: 14px 18px; border-radius: var(--radius-panel); background: var(--surface); }
.author-filters > .author-filter-desktop { padding: 0; border: 0; background: transparent; }

/* Entity nav layout: design-system/entity-nav.css. Empty profile heads after identity moves.
   Also hide heads that only keep [hidden] slots — otherwise flex gap adds false top inset. */
@media (max-width: 1199px) {
  .author-profile-head:empty,
  .bd-left-head:empty,
  .ser-detail-profile-head:empty,
  .author-profile-head:not(:has(:not([hidden]))),
  .bd-left-head:not(:has(:not([hidden]))),
  .ser-detail-profile-head:not(:has(:not([hidden]))) {
    display: none;
  }
}

@media (max-width: 1199px) {
  .compact-entity-header .author-profile-menu { margin-top: 0; }
  /* Match history-back / close: white surface + dark icon, not primary black. */
  :is(#book-view, #series-view, #collections-view) .compact-entity-header :is(.bd-more > summary, .ser-detail-menu) {
    color: var(--color-text);
    background: var(--color-surface);
    box-shadow: var(--shadow-selected);
  }
  :is(#book-view, #series-view, #collections-view) .compact-entity-header :is(.bd-more > summary, .ser-detail-menu):hover:not(:disabled) {
    background: var(--color-surface);
    box-shadow: var(--shadow-control-hover);
    color: var(--color-text);
  }
  #author-view .compact-entity-header .author-profile-menu {
    color: var(--surface, var(--color-surface));
    background: var(--ink, var(--color-text));
    box-shadow: var(--shadow-selected);
  }
  #author-view .compact-entity-header .author-profile-menu:hover:not(:disabled) {
    background: #303030;
    box-shadow: var(--shadow-control-hover);
    color: var(--surface, var(--color-surface));
  }
  #book-view .compact-entity-header .bd-more > summary img,
  #author-view .compact-entity-header .author-profile-menu img {
    filter: none;
  }
}


/* Desktop panels with a title and an action menu. */
@media (min-width: 1200px) {
  .ds-book-detail .bd-left:has(.bd-left-head .bd-more > summary),
  .author-profile:has(.author-profile-head .author-profile-menu),
  .ser-detail-profile:has(.ser-detail-profile-head .ser-detail-actions > summary.ser-detail-menu) {
    padding-block-start: 16px;
  }

  :is(.bd-left-head .bd-more > summary, .author-profile-head .author-profile-menu) {
    margin-block-start: 6px;
  }

  .ser-detail-profile-head .ser-detail-actions > summary.ser-detail-menu {
    margin-block-start: 4px;
  }
}
