.catalog-shell {
  max-width: min(1480px, 100%);
}

.catalog-heading {
  margin-bottom: 1.35rem;
}

.catalog-layout {
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  align-items: start;
}

.filter-panel {
  position: sticky;
  top: 5.4rem;
  display: block;
  max-height: calc(100vh - 6.4rem);
  overflow-y: auto;
  padding: 1rem;
  overscroll-behavior: contain;
}

.filter-panel .catalog-toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  align-items: stretch;
  padding: 0 0 0.9rem;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.filter-panel .active-filters {
  min-height: 0;
  margin: 0 0 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
}

.tag-match-mode {
  display: grid;
  gap: 0.45rem;
  margin: 0 0 0.95rem;
  padding: 0 0 0.95rem;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.tag-match-mode legend {
  padding: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.25rem;
  padding: 0.22rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #eef5e8;
}

.segmented-control button {
  min-height: 2.15rem;
  border: 0;
  border-radius: calc(var(--r) - 2px);
  background: transparent;
  color: var(--dark);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

.segmented-control button[aria-pressed="true"] {
  background: var(--green);
  color: #fff;
  box-shadow: 0 8px 18px rgba(19, 108, 94, 0.18);
}

.search-control > span,
.sort-control > span,
.filter-search > span {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}

.lucide-icon {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.view-toggle {
  width: 100%;
}

.view-toggle button,
.compact-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
}

.view-toggle button {
  flex: 1 1 0;
  min-width: 0;
}

.filter-panel details + details {
  border-top: 1px solid var(--line);
}

.filter-panel summary {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.8rem;
  padding: 0.65rem 0.1rem;
  color: var(--dark);
  cursor: pointer;
  font-weight: 900;
  list-style: none;
}

.filter-panel summary::-webkit-details-marker {
  display: none;
}

.filter-panel summary .lucide-icon {
  transition: transform 0.16s ease;
}

.filter-panel details[open] > summary .lucide-icon {
  transform: rotate(90deg);
}

.filter-options {
  display: grid;
  gap: 0.45rem;
  padding: 0 0 0.95rem;
}

.filter-search {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.filter-search input {
  width: 100%;
  min-height: 2.35rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.filter-search input:focus,
.search-control input:focus,
.custom-select-button:focus {
  outline: 3px solid rgba(45, 111, 93, 0.16);
  outline-offset: 1px;
  border-color: var(--green);
}

.filter-more-button {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 0.35rem;
  min-height: 2.25rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #fff;
  color: var(--dark);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 900;
}

.filter-more-button:hover {
  border-color: var(--green);
  color: var(--green);
}

.results-panel {
  min-height: 32rem;
  max-height: none;
  overflow: visible;
  padding: 0.1rem;
}

.catalog-results.cover-view {
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 1.15rem;
}

.catalog-card {
  display: grid;
  align-content: start;
  overflow: visible;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.catalog-card-cover {
  position: relative;
  display: block;
  isolation: isolate;
  color: var(--ink);
  text-decoration: none;
  transform-origin: left center;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.catalog-card-cover::before {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 2;
  width: 10%;
  max-width: 1.1rem;
  content: "";
  border-radius: 7px 0 0 7px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.22), rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.08));
  pointer-events: none;
}

.catalog-card-cover::after {
  position: absolute;
  top: 0.45rem;
  right: -0.38rem;
  bottom: 0.45rem;
  z-index: -1;
  width: 0.55rem;
  content: "";
  border: 1px solid rgba(216, 226, 215, 0.95);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: repeating-linear-gradient(to bottom, #fff, #fff 4px, #eef5e8 5px);
  box-shadow: 0 12px 24px rgba(34, 48, 45, 0.14);
}

.catalog-card:hover .catalog-card-cover,
.catalog-card:focus-within .catalog-card-cover {
  filter: saturate(1.04);
  transform: perspective(900px) rotateY(-7deg) translateX(2px);
}

.book-cover {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border: 1px solid rgba(216, 226, 215, 0.95);
  border-radius: 7px 12px 12px 7px;
  background: #eef5e8;
  box-shadow: 0 16px 28px rgba(34, 48, 45, 0.14);
}

.catalog-card-body {
  display: grid;
  gap: 0.38rem;
  padding: 0.85rem 0.15rem 0;
}

.catalog-card-body p,
.catalog-row-main p {
  margin: 0;
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.35;
}

.fake-book-cover {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.8rem;
  overflow: hidden;
  padding: 0.85rem;
  color: #fff;
  background:
    radial-gradient(circle at 75% 14%, rgba(255, 255, 255, 0.32), transparent 24%),
    linear-gradient(145deg, hsl(var(--cover-hue) 58% 34%), hsl(calc(var(--cover-hue) + 36) 72% 52%));
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.24);
}

.fake-book-cover::after {
  position: absolute;
  inset: auto -18% 10% 22%;
  height: 35%;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 50%;
  transform: rotate(-12deg);
}

.fake-book-cover strong {
  position: relative;
  z-index: 1;
  display: -webkit-box;
  overflow: hidden;
  font-size: clamp(1.05rem, 7vw, 1.45rem);
  line-height: 1.05;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.fake-book-cover small,
.fake-cover-kicker {
  position: relative;
  z-index: 1;
  display: -webkit-box;
  overflow: hidden;
  line-height: 1.15;
  -webkit-box-orient: vertical;
}

.fake-cover-kicker {
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
  -webkit-line-clamp: 1;
}

.fake-book-cover small {
  font-weight: 800;
  opacity: 0.9;
  -webkit-line-clamp: 2;
}

.rating-row {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.14rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.25;
}

.rating-row .lucide-icon {
  width: 0.92rem;
  height: 0.92rem;
  color: #97a6a2;
}

.rating-row .lucide-icon.filled {
  color: var(--gold);
  fill: currentColor;
}

.rating-row span {
  margin-left: 0.25rem;
}

.catalog-row {
  align-items: center;
}

.catalog-row > .book-cover,
.book-detail-cover .book-cover {
  box-shadow: 0 12px 24px rgba(34, 48, 45, 0.12);
}

.catalog-row .rating-row {
  margin-top: 0.1rem;
}

.book-detail-copy .rating-row {
  font-size: 0.95rem;
}

.catalog-card-cover .catalog-indicators {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 4;
}

.catalog-indicators {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
}

.catalog-indicator {
  display: inline-grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  border: 1px solid rgba(216, 226, 215, 0.9);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 18px rgba(34, 48, 45, 0.12);
}

.catalog-indicator img {
  width: 1.18rem;
  height: 1.18rem;
  object-fit: contain;
}

.catalog-indicator.nyt {
  background: var(--gold);
  color: var(--dark);
  font-size: 0.95rem;
  font-weight: 900;
}

.skeleton-results {
  pointer-events: none;
}

.skeleton-block,
.skeleton-line {
  position: relative;
  overflow: hidden;
  background: #e9f0e7;
}

.skeleton-block::after,
.skeleton-line::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.75), transparent);
  animation: shelfpilot-skeleton 1.2s ease-in-out infinite;
  transform: translateX(-100%);
}

.skeleton-line {
  display: block;
  width: 72%;
  height: 0.8rem;
  border-radius: 999px;
}

.skeleton-line.wide {
  width: 92%;
}

.skeleton-line.short {
  width: 48%;
}

.skeleton-card .catalog-card-cover::before,
.skeleton-card .catalog-card-cover::after {
  display: none;
}

@keyframes shelfpilot-skeleton {
  to {
    transform: translateX(100%);
  }
}

.native-select-hidden,
.sort-control select.native-select-hidden {
  position: absolute;
  width: 1px;
  min-height: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.custom-select {
  position: relative;
  min-width: 0;
}

.custom-select-button {
  position: relative;
  width: 100%;
  justify-content: flex-start;
  min-height: 2.7rem;
  padding: 0.65rem 2.4rem 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #fff;
  color: var(--ink);
  text-align: left;
  white-space: normal;
}

.custom-select-button::after {
  position: absolute;
  top: 50%;
  right: 0.85rem;
  width: 0.5rem;
  height: 0.5rem;
  content: "";
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-65%) rotate(45deg);
}

.custom-select-button[aria-expanded="true"] {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(45, 111, 93, 0.16);
}

.custom-select-button[aria-expanded="true"]::after {
  transform: translateY(-35%) rotate(225deg);
}

.custom-select-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 0.25rem);
  right: 0;
  left: 0;
  max-height: min(18rem, 55vh);
  overflow-y: auto;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  box-shadow: var(--shadow);
}

.custom-select-option {
  width: 100%;
  justify-content: flex-start;
  min-height: 2.25rem;
  padding: 0.45rem 0.55rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  white-space: normal;
}

.custom-select-option:hover,
.custom-select-option[aria-selected="true"] {
  background: #eef5e8;
  color: var(--dark);
}

* {
  scrollbar-color: #9eb5a8 #eef5e8;
  scrollbar-width: thin;
}

*::-webkit-scrollbar {
  width: 0.7rem;
  height: 0.7rem;
}

*::-webkit-scrollbar-track {
  background: #eef5e8;
}

*::-webkit-scrollbar-thumb {
  background: #9eb5a8;
  border: 2px solid #eef5e8;
  border-radius: 999px;
}

@media (max-width: 980px) {
  .catalog-layout {
    grid-template-columns: 1fr;
  }

  .filter-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .filter-panel .catalog-toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(180px, 0.4fr);
  }

  .filter-panel .view-toggle,
  .filter-panel .compact-button {
    align-self: end;
  }
}

@media (max-width: 620px) {
  .catalog-heading {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .filter-panel .catalog-toolbar {
    grid-template-columns: 1fr;
  }

  .catalog-results.cover-view {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
