.shelf-nav, .shelf-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.shelf-nav { justify-content: flex-end; padding: 14px 0; }
.catalog-summary .shelf-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--summary-gap);
  padding: 0;
}
.shelf-controls { margin-top: 10px; align-items: center; }
.shelf-controls:empty { display: none; }
.shelf-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
}
.shelf-button:hover { border-color: var(--green); }
.shelf-button:focus-visible, .shelf-book-title:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 3px;
}
.shelf-button[aria-pressed="true"] {
  color: var(--green);
  border-color: var(--green);
  background: #edf4ef;
}
.shelf-button[data-shelf-toggle="cart"] { border-color: var(--green); color: var(--green); }
[data-shelf-count] {
  min-width: 23px;
  padding: 2px 5px;
  border-radius: 12px;
  background: #eee7db;
  text-align: center;
}
.grid .shelf-controls { margin-top: auto; padding-top: 10px; }
.grid .shelf-button:not(.shelf-favorite), .related-card .shelf-button:not(.shelf-favorite) { width: 100%; }
.related-card > .shelf-controls { padding: 0 12px 12px; }
.shelf-heart {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.shelf-button.shelf-favorite {
  --shelf-heart-active: #d63b3b;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 253, 248, 0.9);
  color: var(--muted);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.shelf-button.shelf-favorite:hover {
  background: var(--paper);
  color: var(--shelf-heart-active);
  transform: scale(1.05);
}
.shelf-button.shelf-favorite:active { transform: scale(0.94); }
.shelf-button.shelf-favorite[aria-pressed="true"] { color: var(--shelf-heart-active); }
.shelf-favorite[aria-pressed="true"] .shelf-heart { fill: currentColor; stroke: none; }
/* Keep cover overlays below the sticky catalog controls. */
.cover, .related-cover-wrap { isolation: isolate; }
.cover > .shelf-favorite, .related-cover-wrap > .shelf-favorite {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(38, 35, 31, 0.12);
}
.related-cover-wrap { position: relative; }
.shelf-row .shelf-favorite { background: #f5efe6; }
@media (prefers-reduced-motion: reduce) {
  .shelf-button.shelf-favorite { transition: none; }
}
.shelf-dialog {
  width: min(720px, calc(100% - 24px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0 24px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  overscroll-behavior: contain;
}
.shelf-dialog::backdrop { background: rgba(38, 35, 31, 0.5); }
.shelf-dialog-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.shelf-dialog h2 { margin: 0; font: bold 25px Georgia, serif; }
.shelf-dialog h3 { margin: 20px 0 6px; font-size: 17px; }
.shelf-note, .shelf-storage-note, .shelf-empty { color: var(--muted); font-size: 14px; line-height: 1.6; }
.shelf-storage-note { border-top: 1px solid var(--line); padding-top: 14px; font-size: 12px; }
.shelf-feedback { color: var(--green); font-size: 13px; }
.shelf-feedback:empty { display: none; }
.shelf-empty { padding: 28px 0; }
.shelf-list { list-style: none; margin: 0; padding: 0; }
.shelf-row { display: flex; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.shelf-cover {
  display: grid;
  place-items: center;
  align-self: flex-start;
  flex: 0 0 64px;
  width: 64px;
  min-height: 88px;
  background: #eee7db;
  color: var(--muted);
  font: 12px Georgia, serif;
}
.shelf-cover img { display: block; width: 64px; height: 88px; object-fit: contain; }
.shelf-row-body { min-width: 0; flex: 1; }
.shelf-book-title { color: var(--ink); font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; text-decoration: none; }
.shelf-book-title:hover { text-decoration: underline; }
.shelf-author, .shelf-availability { margin: 5px 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.shelf-waitlist { color: var(--blue); font-size: 13px; }
.shelf-location {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid #d8b873;
  border-radius: 8px;
  background: #fff8e8;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
.shelf-location p { margin: 0; }
.shelf-checkout { padding: 14px 0 4px; }
.shelf-primary { flex-direction: column; gap: 0; background: var(--green); border-color: var(--green); color: white; }
.shelf-floating-cart {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 50px;
  padding: 10px 14px;
  border: 1px solid #24584b;
  border-radius: 999px;
  background: var(--green);
  color: white;
  box-shadow: 0 10px 28px rgba(38, 35, 31, 0.24);
  font: inherit;
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.shelf-floating-cart.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.shelf-floating-cart:hover { box-shadow: 0 12px 32px rgba(38, 35, 31, 0.32); }
.shelf-floating-cart:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.shelf-floating-cart-icon { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.shelf-floating-cart [data-shelf-floating-count] {
  min-width: 23px;
  padding: 2px 5px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  text-align: center;
}
.shelf-status {
  position: fixed;
  bottom: 16px;
  left: 50%;
  z-index: 100;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 12px 18px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 14px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transition: bottom 0.2s ease, opacity 0.2s ease;
}
.shelf-status.is-visible { opacity: 1; }
.has-floating-cart .shelf-status { bottom: 82px; }
@media (max-width: 560px) {
  .shelf-nav { justify-content: stretch; }
  .shelf-nav > button { flex: 1; }
  .shelf-dialog { padding: 0 14px 14px; }
  .shelf-dialog h2 { font-size: 22px; }
  .shelf-row { gap: 12px; }
  .shelf-primary { width: 100%; }
  .shelf-floating-cart {
    right: auto;
    left: 50%;
    bottom: max(14px, env(safe-area-inset-bottom));
    transform: translate(-50%, 12px) scale(0.96);
  }
  .shelf-floating-cart.is-visible { transform: translate(-50%, 0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .shelf-floating-cart, .shelf-status { transition: none; }
}
