.page--books {
  position: relative;
}

.page--books .page__body {
  display: grid;
  gap: 1.35rem;
  padding: 1.2rem 0 1.8rem;
}

.page--books .site-footer {
  margin-top: 0;
}

.books-catalog {
  --books-section-gap: 1.5rem;
  --books-controls-gap: 1rem;
  display: grid;
  gap: 0;
}

.books-catalog__toolbar {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: var(--books-section-gap);
}

.books-search {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  width: min(100%, 44rem);
  padding: 0.12rem;
  border: 1px solid rgba(220, 239, 225, 0.95);
  border-radius: 1.35rem;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 24px rgba(84, 196, 94, 0.06);
}

.books-search__brand {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  padding: 0 0.9rem 0 0.95rem;
  border-right: 1px solid rgba(220, 239, 225, 0.95);
  color: var(--brand-peach-deep);
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
}

.books-search__field {
  min-width: 0;
}

.books-search__input {
  width: 100%;
  min-height: 40px;
  padding: 0.58rem 0.95rem 0.58rem 1rem;
  border: 0;
  border-radius: 1rem;
  background: transparent;
  color: var(--brand-ink);
  caret-color: var(--brand-ink);
  font-size: 0.98rem;
  line-height: 1.4;
}

.books-search__input::placeholder {
  color: rgba(31, 49, 39, 0.46);
}

.books-search__input:focus {
  outline: none;
}

.books-search:focus-within {
  border-color: rgba(84, 196, 94, 0.32);
  box-shadow:
    0 0 0 0.2rem rgba(114, 214, 146, 0.1),
    0 14px 28px rgba(84, 196, 94, 0.08);
}

.books-search__button.app-button {
  min-height: 40px;
  padding-inline: 1.05rem;
  border-radius: 1rem;
  box-shadow: 0 12px 24px rgba(84, 196, 94, 0.14);
}

.books-catalog__controls {
  display: grid;
  gap: var(--books-controls-gap);
  margin-bottom: 1rem;
}

.books-catalog__divider {
  height: 1px;
  margin-bottom: 0.9rem;
  background: linear-gradient(90deg, rgba(220, 239, 225, 0), rgba(220, 239, 225, 0.98) 12%, rgba(220, 239, 225, 0.98) 88%, rgba(220, 239, 225, 0));
}

.books-catalog__results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.books-filter-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.books-filter-row__label {
  margin: 0;
  color: var(--brand-muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.books-filter-row__track {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  gap: 0.8rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
  scrollbar-width: none;
}

.books-filter-row__track::-webkit-scrollbar {
  display: none;
}

.books-filter-chip {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0.65rem 1rem;
  border: 1px solid rgba(220, 239, 225, 0.95);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.9);
  color: var(--brand-muted);
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(84, 196, 94, 0.06);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease;
}

.books-filter-chip:hover {
  transform: translateY(-1px);
}

.books-filter-chip.is-active {
  border-color: rgba(84, 196, 94, 0.26);
  background: rgba(223, 245, 228, 0.92);
  color: var(--brand-green-deep);
  box-shadow: 0 14px 28px rgba(84, 196, 94, 0.12);
}

.books-filter-chip:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.books-catalog__summary {
  margin: 0;
  color: var(--brand-muted);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.7;
}

.books-sort {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.95rem;
}

.books-sort-chip {
  position: relative;
  min-height: auto;
  padding: 0.15rem 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--brand-muted);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  transition:
    color 180ms ease;
}

.books-sort-chip::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: -0.2rem;
  left: 0;
  height: 2px;
  border-radius: 999px;
  background: var(--brand-peach);
  opacity: 0;
  transform: scaleX(0.35);
  transform-origin: center;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.books-sort-chip:hover,
.books-sort-chip:focus-visible {
  color: var(--brand-ink);
}

.books-sort-chip:focus-visible {
  outline: none;
}

.books-sort-chip.is-active {
  color: var(--brand-ink);
}

.books-sort-chip.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

.books-catalog__grid.story-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.35rem 1.2rem;
}

.books-catalog__card {
  min-width: 0;
}

.books-catalog__card .story-card__surface {
  display: grid;
  height: 100%;
}

.books-catalog__card .story-card__media {
  aspect-ratio: 5 / 4;
}

.books-catalog__card .story-card__content {
  gap: 0.55rem;
  padding: 1rem 0.95rem 1.05rem;
}

.books-catalog__card .story-card__eyebrow {
  color: var(--brand-muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: none;
}

.books-catalog__card .story-card__title {
  font-size: 1.05rem;
  line-height: 1.38;
}

.books-catalog__empty {
  padding: 2.6rem 1rem;
  border: 1px dashed rgba(220, 239, 225, 0.95);
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.78);
  color: var(--brand-muted);
  text-align: center;
}

.books-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.9rem;
  margin-top: 0.2rem;
}

.books-pagination__button.app-button {
  min-height: 40px;
  padding: 0.6rem 1rem;
}

.books-pagination__button:disabled {
  opacity: 0.45;
  transform: none;
  box-shadow: none;
}

.books-pagination__status {
  margin: 0;
  min-width: 4rem;
  color: var(--brand-muted);
  font-weight: 700;
  text-align: center;
}

@media (max-width: 1199px) {
  .books-catalog__grid.story-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 959px) {
  .page--books .page__body {
    padding-top: 1rem;
  }

  .books-catalog__toolbar {
    justify-content: center;
  }

  .books-search {
    width: 100%;
  }

  .books-filter-row {
    align-items: flex-start;
  }

  .books-catalog__results-bar {
    align-items: flex-start;
  }

  .books-catalog__grid.story-grid {
    gap: 1.1rem 0.95rem;
  }
}

@media (max-width: 719px) {
  .books-catalog__results-bar {
    display: grid;
    gap: 0.85rem;
  }

  .books-sort {
    justify-content: flex-start;
  }

  .books-filter-row {
    display: grid;
    gap: 0.55rem;
  }

  .books-filter-row__track {
    width: 100%;
  }

  .books-catalog__grid.story-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 479px) {
  .books-search {
    grid-template-columns: 1fr;
  }

  .books-search__brand {
    justify-content: center;
    min-height: 40px;
    padding: 0.25rem 0.75rem 0;
    border-right: 0;
    border-bottom: 1px solid rgba(220, 239, 225, 0.95);
  }

  .books-search__button.app-button {
    width: 100%;
  }

  .books-catalog__grid.story-grid {
    grid-template-columns: 1fr;
  }

  .books-pagination {
    flex-wrap: wrap;
  }
}
