/* index.html (the signed-in library) on the design tokens (DESIGN.md). Shared rules are in
   app-theme.css; these are the library's own components. Every value comes from tokens.css. */

/* Text */
#library-page :is(h2, #collection-open) {
  font-size: var(--bm-type-card) !important;
}
#library-page .filter-help,
#library-page :is(#result-count, #nav-count, #collection-count) {
  color: var(--bm-muted) !important;
}
#library-page
  :is(#sync-status, #collection-name, #status-tiles strong, #status-tiles span, .badge) {
  color: var(--bm-ink) !important;
}
#library-page #search-result-summary {
  color: var(--bm-success) !important;
}
:is(#library-page, #discover-page) .library-footer-brand strong {
  color: var(--bm-teal) !important;
}
:is(#library-page, #discover-page) :is(footer.library-footer p, .amazon-affiliate-notice) {
  color: var(--bm-muted) !important;
}

/* Welcome (prototype-1): copy, counts and actions, beside the growth illustration. */
#library-page .library-welcome {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 20rem);
  gap: var(--bm-space-section) 1.5rem;
  align-items: start;
  margin-bottom: var(--bm-space-group);
  color: var(--bm-ink);
}
#library-page .library-welcome h1 {
  margin: 0 0 var(--bm-space-line);
  color: var(--bm-teal) !important;
  font-size: calc(var(--bm-type-title) * 0.72);
  line-height: 1.1;
}
#library-page .welcome-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0 1.5rem;
  margin: var(--bm-space-group) 0;
  font-size: var(--bm-type-control);
}
#library-page .library-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  font-family: var(--bm-font);
}
/* Counts, as on the prototype: the number above its label, the selected count underlined. */
#library-page .library-stats button,
#library-page .library-stats button:hover {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  min-height: 2.75rem !important;
  padding: 0 0.125rem !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--bm-ink) !important;
  font-size: var(--bm-type-control) !important;
  font-weight: 700;
  white-space: nowrap;
}
#library-page .library-stats strong {
  color: var(--bm-ink);
  font-size: var(--bm-type-hint);
  line-height: 1.1;
}
#library-page .library-stats button[aria-pressed='true'] {
  text-decoration: underline;
  text-underline-offset: 0.25rem;
}
/* An empty library lists its counts in a small bordered box, one row each. */
#library-page .library-welcome.is-empty .library-stats {
  display: grid;
  gap: 0;
  width: min(100%, 10rem);
  padding: var(--bm-space-line) 0.625rem;
  border: 0.0625rem solid var(--bm-line);
  border-radius: var(--bm-radius-control);
  background: var(--bm-paper);
}
#library-page .library-welcome.is-empty .library-stats button {
  flex-direction: row;
  justify-content: flex-start;
  gap: 0.625rem;
  min-height: 2rem !important;
  font-size: var(--bm-type-small) !important;
}
#library-page .library-welcome.is-empty .library-stats button + button {
  border-top: 0.0625rem solid var(--bm-line) !important;
}
#library-page .library-welcome.is-empty .library-stats strong {
  min-width: 1.25rem;
  font-size: var(--bm-type-control);
}
#library-page .welcome-guidance {
  margin: 0;
  font-size: var(--bm-type-hint);
  line-height: 1.4;
}
#library-page #empty-heading {
  color: var(--bm-ink);
}
#library-page .library-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--bm-type-control);
}
/* Actions, as on the prototype: Browse books is the orange button; the others are white buttons.
   Find a book and Add a book open a row below; the open one gets a teal border. */
#library-page .library-actions .action-tab,
#library-page .library-actions .action-tab:hover,
#library-page .library-actions #add.action-tab,
#library-page .library-actions #add.action-tab:hover {
  display: inline-flex;
  align-items: center;
  width: auto;
  min-height: 2.125rem !important;
  margin: 0 !important;
  padding: 0.3125rem 0.5rem !important;
  border: 0.0625rem solid var(--bm-line) !important;
  border-radius: var(--bm-radius-control) !important;
  background: var(--bm-paper) !important;
  color: var(--bm-ink) !important;
  font-size: var(--bm-type-control) !important;
  font-weight: 700;
  text-decoration: none;
}
#library-page .library-actions #browse-open.action-tab {
  padding: 0.4375rem 0.875rem !important;
  border-color: var(--bm-orange) !important;
  background: var(--bm-orange) !important;
}
#library-page .library-actions a.action-tab:is(:link, :visited) {
  color: var(--bm-ink) !important;
}
#library-page .library-actions .action-tab:hover {
  text-decoration: underline;
}
#library-page .library-actions :is(#add, #find-open).action-tab[aria-expanded='true'] {
  border-color: var(--bm-teal) !important;
  box-shadow: inset 0 0 0 0.0625rem var(--bm-teal);
}
#library-page .library-actions .action-tab:disabled,
#library-page .library-actions #add.action-tab:disabled {
  color: var(--bm-muted) !important;
}
#library-page .action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin: 0.75rem 0 0;
  font-size: var(--bm-type-control);
}
#library-page .action-row[hidden] {
  display: none;
  color: var(--bm-ink);
}
#library-page #add-row button,
#library-page #add-row button:hover {
  min-height: 2.75rem;
  padding: 0 0.5rem !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--bm-ink) !important;
  font-weight: 700;
}
#library-page #add-row button:hover {
  text-decoration: underline;
}
#library-page #find-text {
  flex: 1 1 18rem;
  min-height: 2.75rem;
  border: 0.125rem solid var(--bm-teal) !important;
  border-radius: var(--bm-radius-control) !important;
  font-size: var(--bm-type-control);
}
#library-page .library-explanation {
  margin-top: var(--bm-space-line);
  padding: var(--bm-space-line) 0;
  border: 0;
  font-size: var(--bm-type-small);
}
#library-page .library-explanation summary {
  color: var(--bm-teal);
  font-size: var(--bm-type-small);
  font-weight: 700;
}

/* Tight above and below the graphic; the sides keep 0.75rem so the picture stays the same size. */
#library-page .welcome-art {
  padding: 0.5rem 0.75rem;
  border-radius: var(--bm-radius-card);
  background: var(--bm-teal-dark);
  text-align: center;
}
#library-page .welcome-art .art-caption {
  margin: 0 0 var(--bm-space-line);
  color: var(--bm-paper) !important;
  font-size: var(--bm-type-body);
  font-weight: 700;
  line-height: 1.2;
}
#library-page .welcome-art img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--bm-radius-control);
}
/* Not in the prototype: library and collection switcher, status tiles and format chips.
   They stay in the page for app.js; the in-work page and the filters cover what they did. */
#library-page .library-views {
  display: none !important;
  color: var(--bm-ink);
}
@media (max-width: 750px) {
  #library-page .library-welcome {
    grid-template-columns: minmax(0, 1fr);
    color: var(--bm-ink);
  }
  #library-page .welcome-art {
    max-width: 20rem;
    color: var(--bm-ink);
  }
}
/* Phones keep full-size tap targets for the compact counts and tabs. */
@media (max-width: 750px) {
  #library-page .library-stats button,
  #library-page .library-actions .action-tab,
  #library-page .library-actions #add.action-tab {
    min-height: calc(var(--bm-space-section) * 2.75) !important;
  }
}
@media (max-width: 600px) {
  :is(#library-page, #discover-page) #starter-shelves .starter-shelf h3 {
    margin-left: 2.25rem;
    color: var(--bm-paper);
  }
  :is(#library-page, #discover-page) #starter-shelves .starter-row {
    padding: 0 2.25rem 1.25rem;
    color: var(--bm-paper);
  }
  :is(#library-page, #discover-page) #starter-shelves .starter-row::after {
    left: 2.25rem;
    right: 2.25rem;
    color: var(--bm-paper);
  }
  :is(#library-page, #discover-page) #starter-shelves .starter-arrow {
    width: 1.875rem;
    color: var(--bm-ink);
  }
}
#library-page #add-books-panel .add-way {
  border-color: var(--bm-muted) !important;
  border-radius: var(--bm-radius-card) !important;
}
#library-page #add-books-panel .add-way[aria-selected='true'] {
  background: var(--bm-teal) !important;
  border-color: var(--bm-teal) !important;
}
#library-page #add-books-panel .add-way[aria-selected='true'] :is(strong, small, svg) {
  color: var(--bm-paper) !important;
}
#library-page .add-way strong {
  color: var(--bm-ink) !important;
}

/* Filters: status tiles, format chips, view toggle */
#library-page #status-tiles > button,
#library-page #status-tiles > button:hover {
  border-color: var(--bm-line) !important;
  border-radius: var(--bm-radius-control) !important;
}
#library-page #status-tiles > button[aria-pressed='true'],
#library-page #status-tiles > button[aria-pressed='true']:is(:hover, :focus) {
  background: var(--bm-surface-warm) !important;
  border-color: var(--bm-teal) !important;
}
#library-page #format-chips button {
  border-color: var(--bm-muted) !important;
  color: var(--bm-ink) !important;
  border-radius: var(--bm-radius-control) !important;
}
#library-page #format-chips button[aria-pressed='true'],
#library-page #format-chips button[aria-pressed='true']:is(:hover, :focus) {
  background: var(--bm-teal) !important;
  border-color: var(--bm-teal) !important;
  color: var(--bm-paper) !important;
}
#library-page :is(#status-tiles button, #format-chips button, #collection-open):focus-visible {
  outline-color: var(--bm-teal) !important;
}
#library-page .view-toggle {
  background: var(--bm-surface-warm) !important;
  border-color: var(--bm-line) !important;
}
#library-page .view-toggle button.selected {
  background: var(--bm-teal) !important;
  color: var(--bm-paper) !important;
}

/* No left column (prototype-1): the sidebar's controls stay in the page for app.js, out of sight. */
#library-page aside.sidebar {
  display: none !important;
  color: var(--bm-ink);
}
#library-page main {
  margin-left: 0 !important;
  margin-inline: auto;
  color: var(--bm-ink);
}
/* Search, sort and the Covers/List view sit on one row above Filter your books. */
#library-page .catalog-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1.5rem;
  margin: 0.75rem 0;
  font-size: var(--bm-type-control);
}
#library-page .catalog-tools label {
  display: grid;
  gap: 0.25rem;
  color: var(--bm-ink);
  font-weight: 700;
}
#library-page .catalog-tools label[for='search'] {
  flex: 1 1 18rem;
  font-family: var(--bm-font);
}
#library-page .catalog-tools :is(input, select) {
  min-height: 2.75rem;
  border: 0.0625rem solid var(--bm-muted) !important;
  border-radius: var(--bm-radius-control) !important;
  font-size: var(--bm-type-control);
}
#library-page .filter-panel {
  margin: 0 0 1rem;
  font-size: var(--bm-type-control);
}
#library-page .filter-panel > summary {
  color: var(--bm-teal);
  font-weight: 700;
  cursor: pointer;
}
#library-page .filter-panel .sidebar-filters {
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  align-items: start;
  margin: 0.75rem 0 0;
  color: var(--bm-ink);
}
#library-page .filter-panel #nav-count {
  grid-column: 1 / -1;
  color: var(--bm-muted) !important;
}
#library-page .view-toggle button {
  min-width: 4.5rem;
  font-size: var(--bm-type-control) !important;
}

/* Covers view, as on the prototype: covers stand on a wooden shelf inside a white card. Titles stay for
   screen readers (each cover's button is named "View <title>"); the details open on click. */
#library-page :is(#books, #wish-books):has(> article.book) {
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)) !important;
  column-gap: 0 !important;
  row-gap: 1.75rem !important;
  padding: 0.5rem 0 0;
  background: transparent;
  color: var(--bm-ink);
}
#library-page :is(#books, #wish-books) > article.book {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: visible;
  padding: 0 0.5rem;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--bm-paper);
}
#library-page :is(#books, #wish-books) > article.book::after {
  content: '';
  order: 1;
  align-self: stretch;
  height: 1.1rem;
  margin: -0.3rem -0.5rem 0;
  background: linear-gradient(
    var(--bm-shelf-top) 0 30%,
    var(--bm-shelf-face-light) 30%,
    var(--bm-shelf-face-dark) 85%,
    var(--bm-shelf-bottom)
  );
}
#library-page :is(#books, #wish-books) > article.book > :not(.book-open, .book-check) {
  order: 2;
  margin-top: 0.5rem;
  font-size: var(--bm-type-small) !important;
}
#library-page :is(#books, #wish-books) > article.book .book-open {
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--bm-paper);
}
#library-page :is(#books, #wish-books) > article.book .cover-stage {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 11rem;
  padding: 0 !important;
  background: transparent !important;
  color: var(--bm-paper);
}
#library-page :is(#books, #wish-books) > article.book .cover-stage :is(img, .cover) {
  max-height: 11rem;
  box-shadow: 0 0.25rem 0.6rem color-mix(in srgb, var(--bm-ink) 45%, transparent);
}
#library-page :is(#books, #wish-books) > article.book .book-info {
  position: absolute;
  width: 0.0625rem;
  height: 0.0625rem;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  color: var(--bm-ink);
}
/* A book without artwork shows its title on a lighter teal, so it stands out from the band. */
#library-page :is(#books, #wish-books) > article.book .cover {
  background: var(--bm-teal) !important;
  border-color: var(--bm-paper) !important;
}
#library-page :is(#books, #wish-books) > article.book .book-check {
  top: 0.25rem;
  left: 0.75rem;
  z-index: 1;
  color: var(--bm-ink);
}

/* The welcome above already says "Your library needs books.", so the genre shelves skip their own intro. */
:is(#library-page, #discover-page) #starter-shelves .starter-intro {
  display: none;
  color: var(--bm-ink);
}
#library-page .shelf-key {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  margin: 0 0 0.5rem;
  color: var(--bm-ink);
  font-size: var(--bm-type-control);
}
#library-page .shelf-key[hidden] {
  display: none;
  color: var(--bm-ink);
}
/* The legend's + matches the orange ribbon on the genre shelves. */
#library-page .legend-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.5rem;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
  background: var(--bm-orange);
  color: var(--bm-ink);
  font-weight: 700;
}

/* Genre shelves (prototype-1): one color band per genre stacked into a bookcase, covers on a
   wooden plank, an orange ribbon to save, gold square arrows. */
:is(#library-page, #discover-page) #starter-shelves {
  margin-bottom: 1.5rem;
  background: transparent;
  color: var(--bm-ink);
}
:is(#library-page, #discover-page) #starter-shelves .starter-shelf {
  margin: 0;
  padding: 1rem 0.75rem 1.125rem;
  border-radius: 0;
  background: var(--genre-band, var(--bm-teal-dark));
  color: var(--bm-paper);
}
:is(#library-page, #discover-page) #starter-shelves .starter-shelf:first-of-type {
  border-radius: var(--bm-radius-card) var(--bm-radius-card) 0 0;
  color: var(--bm-paper);
}
:is(#library-page, #discover-page) #starter-shelves .starter-shelf:last-of-type {
  border-radius: 0 0 var(--bm-radius-card) var(--bm-radius-card);
  color: var(--bm-paper);
}
:is(#library-page, #discover-page) #starter-shelves .starter-shelf:nth-of-type(6n + 2) {
  --genre-band: color-mix(in srgb, var(--bm-danger) 45%, var(--bm-ink));
  color: var(--bm-paper);
}
:is(#library-page, #discover-page) #starter-shelves .starter-shelf:nth-of-type(6n + 3) {
  --genre-band: color-mix(in srgb, var(--bm-teal) 25%, var(--bm-ink));
  color: var(--bm-paper);
}
:is(#library-page, #discover-page) #starter-shelves .starter-shelf:nth-of-type(6n + 4) {
  --genre-band: color-mix(in srgb, var(--bm-success) 75%, var(--bm-ink));
  color: var(--bm-paper);
}
:is(#library-page, #discover-page) #starter-shelves .starter-shelf:nth-of-type(6n + 5) {
  --genre-band: color-mix(in srgb, var(--bm-danger) 30%, var(--bm-teal-dark));
  color: var(--bm-paper);
}
:is(#library-page, #discover-page) #starter-shelves .starter-shelf:nth-of-type(6n) {
  --genre-band: color-mix(in srgb, var(--bm-gold) 25%, var(--bm-ink));
  color: var(--bm-paper);
}
:is(#library-page, #discover-page) #starter-shelves .starter-shelf h3 {
  margin: 0 0 0.75rem 2.75rem;
  color: var(--bm-paper);
  font-size: var(--bm-type-body);
}
:is(#library-page, #discover-page) #starter-shelves .starter-row {
  padding: 0 2.75rem 1.25rem;
  color: var(--bm-paper);
}
/* The plank the covers stand on. */
:is(#library-page, #discover-page) #starter-shelves .starter-row::after {
  content: '';
  position: absolute;
  left: 2.75rem;
  right: 2.75rem;
  bottom: 0;
  height: 1.25rem;
  border-radius: 0 0 var(--bm-radius-control) var(--bm-radius-control);
  background: linear-gradient(
    var(--bm-shelf-top) 0 25%,
    var(--bm-shelf-face-light) 25%,
    var(--bm-shelf-face-dark) 80%,
    var(--bm-shelf-bottom)
  );
  box-shadow: 0 0.5rem 0.5rem -0.25rem color-mix(in srgb, var(--bm-ink) 70%, transparent);
}
:is(#library-page, #discover-page) #starter-shelves .starter-stream {
  align-items: flex-end;
  gap: 0.5rem;
  scrollbar-width: none;
  color: var(--bm-paper);
}
:is(#library-page, #discover-page) #starter-shelves .starter-book {
  flex-basis: 6.75rem;
  border-radius: 0;
  background: var(--bm-teal-dark);
}
:is(#library-page, #discover-page) #starter-shelves .starter-save {
  right: 0.25rem;
  min-width: 1.75rem;
  min-height: 2.25rem;
  padding: 0 0 0.375rem !important;
  border-radius: 0 !important;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
  background-color: var(--bm-orange) !important;
  color: var(--bm-ink) !important;
  font-size: var(--bm-type-body);
}
/* The ribbon clip would hide the focus ring, so a focused button shows as a full rectangle. */
:is(#library-page, #discover-page) #starter-shelves .starter-save:focus-visible {
  clip-path: none;
  outline-color: var(--bm-paper) !important;
}
:is(#library-page, #discover-page) #starter-shelves .starter-save:disabled {
  min-width: 0;
  padding: 0.125rem 0.375rem 0.5rem !important;
  background-color: var(--bm-success) !important;
  color: var(--bm-paper) !important;
  font-size: var(--bm-type-small);
}
:is(#library-page, #discover-page) #starter-shelves .starter-arrow {
  top: calc(50% - 0.625rem);
  width: 2.25rem;
  height: 2.75rem;
  border: 0.0625rem solid var(--bm-shelf-top) !important;
  border-radius: var(--bm-radius-control);
  background-color: var(--bm-gold) !important;
  color: var(--bm-ink) !important;
}
#library-page :is(#starter-shelves, #browse-shelves) .starter-arrow svg {
  width: 1.125rem;
  height: 1.5rem;
  fill: var(--bm-ink);
}
:is(#library-page, #discover-page) #starter-shelves .starter-prev {
  left: 0;
  color: var(--bm-ink);
}
:is(#library-page, #discover-page) #starter-shelves .starter-next {
  right: 0;
  color: var(--bm-ink);
}

/* Recommend is in each book's details; on the shelf it would sit under every cover. */
#library-page :is(#books, #wish-books) > article.book > .book-share-action {
  display: none !important;
  color: var(--bm-ink);
}
/* List view headings read as headings; each one is a sort button. */
#library-page #books th button,
#library-page #books th button:hover {
  min-height: 2.75rem;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--bm-teal) !important;
  font-size: var(--bm-type-control) !important;
  font-weight: 700;
}
#library-page #books th[aria-sort='ascending'] button::after {
  content: ' ▲';
  color: var(--bm-teal);
}
#library-page #books th[aria-sort='descending'] button::after {
  content: ' ▼';
  color: var(--bm-teal);
}

/* Surfaces */
#library-page
  :is(
    .library-views,
    .active-search,
    .library-footer,
    .library-footer-company,
    .local,
    .add-hint,
    .add-pane,
    .book-actions
  ) {
  border-color: var(--bm-line) !important;
}
#library-page .library-views {
  border-radius: var(--bm-radius-card) !important;
}
#library-page :is(.active-search, .cover-stage, .badge, th) {
  background: var(--bm-surface-warm) !important;
}
#library-page article.book {
  border-color: var(--bm-line) !important;
  border-radius: var(--bm-radius-card) !important;
}
/* Fallback cover when a book has no image. */
#library-page .cover {
  background: var(--bm-teal-dark) !important;
  border-color: var(--bm-teal-dark) !important;
  color: var(--bm-paper) !important;
}
#library-page .cover :is(small, span) {
  color: var(--bm-paper) !important;
}

/* Library picker sheet */
#library-page #collection-sheet {
  border-color: var(--bm-line);
  border-radius: var(--bm-radius-card);
}
#library-page #collection-sheet .collection-row[aria-current='true'] {
  background: var(--bm-surface-warm) !important;
}
#library-page #collection-sheet :is(.collection-check, .collection-new, .collection-new *) {
  color: var(--bm-teal) !important;
}

/* Book details on phones: the actions become a divided text row. */
@media (max-width: 750px) {
  #library-page
    #detail
    .book-actions.book-actions
    > :is(button, a):not(.book-open):not(.rating-star) {
    border-left-color: var(--bm-line) !important;
    color: var(--bm-teal) !important;
  }
  #library-page
    #detail
    .book-actions.book-actions
    > [data-book-action='delete']:not(.book-open):not(.rating-star) {
    color: var(--bm-danger) !important;
  }
}

/* Shelf badges, the Support local booksellers band and the used-book finder: on My Library and Discover, as on the prototype. */
:is(#library-page, #discover-page) .starter-badge {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  padding: 0.125rem 0.375rem;
  border-radius: calc(var(--bm-radius-control) / 2);
  color: var(--bm-paper);
  background: var(--bm-teal-dark);
  font-size: calc(var(--bm-type-small) * 0.8);
  font-weight: 700;
}
/* Gold is a fill with ink text (DESIGN.md contrast pairs). */
:is(#library-page, #discover-page) .starter-badge-best {
  color: var(--bm-ink);
  background: var(--bm-gold);
}
:is(#library-page, #discover-page) .starter-badge-pick {
  background: var(--bm-plum);
}
:is(#library-page, #discover-page) .local-bookshop-ad {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: calc(var(--bm-space-section) * 1.25);
  align-items: center;
  margin-top: calc(var(--bm-space-section) * 1.5);
  padding: 1.25rem 1.5rem;
  border: 0.0625rem solid var(--bm-line);
  border-radius: var(--bm-radius-card);
  background: var(--bm-surface-warm);
}
:is(#library-page, #discover-page) .local-bookshop-ad img {
  width: 100%;
  height: auto;
  border-radius: var(--bm-radius-control);
}
:is(#library-page, #discover-page) .local-bookshop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--bm-space-group);
}
:is(#library-page, #discover-page) #used-books {
  width: min(32rem, calc(100vw - 2rem));
  padding: 1.25rem;
  border: 0.0625rem solid var(--bm-line);
  border-radius: var(--bm-radius-card);
  color: var(--bm-ink);
}
:is(#library-page, #discover-page) .used-books-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--bm-space-group);
}
:is(#library-page, #discover-page) #used-books-form {
  display: grid;
  gap: var(--bm-space-group);
}
:is(#library-page, #discover-page) .used-books-shop {
  margin-top: var(--bm-space-group);
  padding: var(--bm-space-group) 0;
  border-top: 0.0625rem solid var(--bm-line);
}
:is(#library-page, #discover-page) .used-books-shop h3 {
  margin: 0;
  font-size: var(--bm-type-card);
}
:is(#library-page, #discover-page) .used-books-shop a {
  display: inline-block;
  margin-right: var(--bm-space-section);
}
:is(#library-page, #discover-page) .used-books-flag {
  font-weight: 700;
}
@media (max-width: 750px) {
  :is(#library-page, #discover-page) .local-bookshop-ad {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--bm-space-section);
  }
}

/* My Library below the welcome, as on the prototype. */
#library-page .welcome-guidance {
  font-size: var(--bm-type-control);
  line-height: 1.6;
}
#library-page .welcome-stats {
  align-items: center;
  color: var(--bm-ink);
}
#library-page .welcome-link,
#library-page .welcome-link:hover {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 0.25rem !important;
  border: 0 !important;
  background: transparent !important;
  color: var(--bm-ink) !important;
  font-size: var(--bm-type-control);
  font-weight: 700;
  text-decoration: none;
}
#library-page button.welcome-link {
  color: var(--bm-teal) !important;
  text-decoration: underline;
  text-underline-offset: 0.25rem;
}
#library-page .library-action-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  color: var(--bm-ink);
}
#library-page .library-action-line .library-explanation {
  margin: 0;
  padding: 0;
  color: var(--bm-ink);
}
#library-page .library-action-line .library-explanation[open] {
  flex-basis: 100%;
  color: var(--bm-ink);
}
#library-page .library-action-line .library-explanation summary {
  font-size: var(--bm-type-control);
}
#library-page #library-details {
  width: min(32rem, calc(100vw - 2rem));
  padding: 1.25rem;
  border: 0.0625rem solid var(--bm-line);
  border-radius: var(--bm-radius-panel);
  box-shadow: 0.5rem 0.5rem 0 var(--bm-shelf-highlight);
  background: var(--bm-paper);
  color: var(--bm-ink);
}
#library-page #library-details .modal-head h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--bm-teal-dark);
  font-size: var(--bm-type-card);
}
#library-page #library-details h3 {
  margin: 1rem 0 0.5rem;
  color: var(--bm-teal-dark);
  font-size: var(--bm-type-hint);
}
#library-page #library-details .details-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0 1.5rem;
  color: var(--bm-ink);
}
#library-page #library-details dl {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  color: var(--bm-ink);
}
#library-page #library-details dl > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 0.0625rem solid var(--bm-line);
}
#library-page #library-details dt {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
}
#library-page #library-details .format-icon {
  flex: none;
  color: var(--bm-teal);
}
#library-page #library-details dd {
  margin: 0;
  font-weight: 700;
  white-space: nowrap;
}
#library-page #library-details .details-shelves {
  display: grid;
  gap: 0.75rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  color: var(--bm-ink);
}
#library-page #library-details .details-shelves li {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--bm-ink);
}
/* Seven spines on a wooden shelf. */
#library-page #library-details .mini-shelf {
  display: flex;
  flex: none;
  align-items: flex-end;
  gap: 0.1875rem;
  width: 5rem;
  height: 2.75rem;
  padding: 0.375rem 0.375rem 0;
  border-bottom: 0.4375rem solid var(--bm-shelf-bottom);
  border-radius: var(--bm-radius-control);
  background: var(--bm-shelf-top);
}
#library-page #library-details .mini-shelf i {
  flex: 1;
  height: 1.5rem;
  background: var(--bm-teal);
}
#library-page #library-details .mini-shelf i:nth-child(2n) {
  height: 1.75rem;
  background: var(--bm-coral);
}
#library-page #library-details .mini-shelf i:nth-child(3n) {
  height: 1.375rem;
  background: var(--bm-gold);
}
#library-page #library-details .mini-shelf i:nth-child(4n) {
  background: var(--bm-success);
}
/* One row: the large All books heading, then search, sort and view. */
#library-page .catalog-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  color: var(--bm-ink);
}
#library-page .catalog-head .collection-title {
  margin: 0;
  color: var(--bm-ink);
}
#library-page .catalog-head #section-title {
  margin: 0;
  color: var(--bm-teal) !important;
  font-size: var(--bm-type-section) !important;
  line-height: 1.1;
}
#library-page .catalog-head .view-toggle {
  display: none !important;
  color: var(--bm-ink);
}
#library-page .catalog-head .catalog-tools {
  flex: 1 1 30rem;
  align-items: center;
  gap: 0.5rem 1rem;
  margin: 0;
  color: var(--bm-ink);
}
#library-page .catalog-head .catalog-tools label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  color: var(--bm-ink);
}
#library-page .catalog-head .catalog-tools label[for='search'] {
  flex: 1 1 16rem;
  color: var(--bm-ink);
}
#library-page .catalog-head .catalog-tools input {
  flex: 1;
  min-width: 0;
  color: var(--bm-ink);
}
#library-page .filter-panel {
  margin: 0;
  padding: 0.25rem 0;
  border: 0 !important;
  color: var(--bm-ink);
}
/* Covers fill their column so the shelf edges line up under books of different heights. */
#library-page :is(#books, #wish-books) > article.book .cover-stage {
  flex: 1;
  min-height: 0;
  color: var(--bm-ink);
}
#library-page .filter-panel > summary,
#library-page .result-count {
  font-size: var(--bm-type-small);
}
#library-page .result-count {
  margin: 0.25rem 0 0.5rem;
  color: var(--bm-ink) !important;
}
/* Selection checkboxes and the editing tools show only with Filter your books open. */
#library-page #library-catalog:not(:has(#filter-panel[open])) .book-check {
  display: none;
  color: var(--bm-ink);
}
#library-page .library-shelf {
  margin: 0 0 1rem;
  padding: 0.75rem 1.25rem 1rem;
  border: 0.0625rem solid var(--bm-line);
  border-top: 0.1875rem solid var(--bm-orange);
  border-radius: var(--bm-radius-card);
  background: var(--bm-paper);
}
#library-page .library-shelf > h3 {
  margin: 0 0 0.5rem;
  color: var(--bm-ink) !important;
  font-size: var(--bm-type-hint);
}
#library-page .starter-title {
  margin: var(--bm-space-section) 0 var(--bm-space-group);
  color: var(--bm-ink) !important;
  font-size: var(--bm-type-hint);
}
#library-page .library-shelf[hidden] {
  display: none;
  color: var(--bm-ink);
}
#library-page .sparse-library-prompt {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.5rem;
  padding: 1rem;
  color: var(--bm-ink);
  font-size: var(--bm-type-control);
}
#library-page #books:has(> article.book) > .sparse-library-prompt {
  grid-column: -3 / -1;
  justify-self: end;
  color: var(--bm-ink);
}
#library-page .sparse-library-prompt p {
  margin: 0;
  color: var(--bm-ink);
}
#library-page #starter-shelves {
  margin-top: 1.5rem;
  color: var(--bm-ink);
}
#library-page a.welcome-link:is(:link, :visited) {
  color: var(--bm-ink) !important;
}
#library-page
  #library-catalog.is-empty
  :is(.catalog-head, .filter-panel, .result-count, #library-shelf-title) {
  display: none;
  color: var(--bm-ink);
}
#library-page #library-catalog.is-empty .library-shelf {
  padding: 0.75rem 1.25rem;
  color: var(--bm-ink);
}
#library-page #library-catalog.is-empty .sparse-library-prompt {
  display: flex;
  grid-column: 1 / -1;
  justify-content: space-between;
  padding: 0;
  color: var(--bm-ink);
}
/* Beta layout: Want to Read first (one shelf that scrolls sideways), then the library limited to four shelf rows
   with Show all / Show fewer, then the collapsible Search, sort and filter row, then Browse books. */
#library-page #wish-books:has(> article.book) {
  grid-template-columns: none !important;
  grid-auto-flow: column;
  grid-auto-columns: 8.5rem;
  overflow-x: auto;
  color: var(--bm-ink);
}
#library-page #books > article.book[hidden] {
  display: none;
  color: var(--bm-ink);
}
#library-page .library-more {
  display: block;
  margin: 0.5rem auto 0;
  color: var(--bm-teal);
  font-weight: 700;
}
/* The triangle points right while the shelf is folded and down while it is open. */
#library-page .library-more::before {
  content: '';
  display: inline-block;
  margin-right: 0.5rem;
  border: 0.375rem solid transparent;
  border-right-width: 0;
  border-left: 0.5rem solid var(--bm-teal);
  vertical-align: middle;
  color: var(--bm-teal);
}
#library-page .library-more[aria-expanded='true']::before {
  transform: rotate(90deg);
  color: var(--bm-teal);
}
#library-page .library-more[hidden] {
  display: none;
  color: var(--bm-ink);
}
#library-page .browse-row {
  margin: 0 0 1rem;
  color: var(--bm-ink);
}
#library-page .browse-row > summary {
  padding: 0.5rem 0;
  color: var(--bm-teal);
  font-size: var(--bm-type-control);
  font-weight: 700;
  cursor: pointer;
}
/* Covers on the shelves look the same however the cover arrives. book-cover.js fetches the artwork after the
   page draws, per book and per network, so each cover is first a placeholder and then (or never) a picture
   of any shape. The shelf therefore sizes by the picture, not by the placeholder's fixed 110 x 150 box and
   the viewport-sized stage, and a picture that has not arrived or has failed leaves a placeholder of the
   same height. */
#library-page :is(#books, #wish-books) > article.book .cover-stage {
  height: auto;
  color: var(--bm-ink);
}
#library-page :is(#books, #wish-books) > article.book .cover {
  width: 7.5rem;
  height: 11rem;
  color: var(--bm-ink);
}
#library-page
  :is(#books, #wish-books)
  > article.book
  .cover:has(> .cover-image.loaded:not([hidden])) {
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  background: transparent !important;
  color: var(--bm-ink);
}
#library-page
  :is(#books, #wish-books)
  > article.book
  .cover:has(> .cover-image.loaded:not([hidden]))
  > :not(.cover-image),
#library-page
  :is(#books, #wish-books)
  > article.book
  .cover:has(> .cover-image.loaded:not([hidden]))::before {
  display: none;
  color: var(--bm-ink);
}
#library-page :is(#books, #wish-books) > article.book .cover > .cover-image.loaded:not([hidden]) {
  position: static;
  display: block;
  width: auto;
  height: auto;
  max-width: 7.5rem;
  max-height: 11rem;
  background: transparent;
  color: var(--bm-ink);
  object-fit: contain;
}
/* The folding triangle beside each genre under Browse books. */
#library-page #starter-shelves .shelf-toggle {
  min-height: 2.75rem;
  padding: 0.25rem 0;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--bm-paper) !important;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
#library-page #starter-shelves .shelf-toggle::before {
  content: '';
  display: inline-block;
  margin-right: 0.5rem;
  border: 0.375rem solid transparent;
  border-right-width: 0;
  border-left: 0.5rem solid var(--bm-paper);
  vertical-align: middle;
  color: var(--bm-paper);
}
#library-page #starter-shelves .shelf-toggle[aria-expanded='true']::before {
  transform: rotate(90deg);
  color: var(--bm-paper);
}
#library-page #starter-shelves .starter-row[hidden] {
  display: none;
  color: var(--bm-paper);
}
