:root {
  --books-board-line: #dbe6f3;
  --books-rail-line: #e1eaf4;
}

.books-page {
  background:
    radial-gradient(circle at 18% -10%, rgba(17, 199, 213, 0.16), transparent 22rem),
    radial-gradient(circle at 86% 3%, rgba(47, 118, 246, 0.12), transparent 20rem),
    #f4f8fc;
  color: var(--ink);
}

.books-main {
  min-height: 0;
}

.books-hero {
  padding: 30px 0 18px;
}

.books-hero-inner {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
}

.books-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
}

.books-heading-icon {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  flex: 0 0 auto;
  color: var(--primary-dark);
}

.books-heading-icon svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.books-heading h1 {
  margin: 0;
  color: #111b2f;
  font-size: clamp(1.42rem, 2.5vw, 1.95rem);
  line-height: 1.15;
  white-space: nowrap;
}

.books-heading-divider {
  width: 1px;
  height: 27px;
  flex: 0 0 auto;
  background: #cfdbea;
}

.books-heading p {
  margin: 0;
  color: #62728a;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.35;
}

.books-home-link {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 0 16px;
  border: 1px solid rgba(8, 137, 155, 0.5);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--primary-dark);
  font-size: 0.88rem;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.books-home-link:hover,
.books-home-link:focus-visible {
  border-color: rgba(8, 137, 155, 0.76);
  background: rgba(17, 199, 213, 0.08);
}

.books-board-section {
  padding: 0 0 22px;
}

.books-board {
  padding: 18px 16px 12px;
  border: 1px solid var(--books-board-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
}

.books-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.book-card {
  position: relative;
  display: flex;
  min-width: 0;
  height: 292px;
  flex-direction: column;
  gap: 12px;
  padding: 14px 14px 16px;
  border-right: 1px solid var(--books-rail-line);
  border-bottom: 1px solid var(--books-rail-line);
  color: #13223a;
  outline-offset: -2px;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

.book-card:nth-child(6n) {
  border-right: 0;
}

.book-card:hover,
.book-card:focus-visible {
  z-index: 2;
  background: #ffffff;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.14);
  transform: scale(1.025);
}

.book-rank-badge {
  position: absolute;
  z-index: 2;
  top: 14px;
  left: 14px;
  display: inline-grid;
  min-width: 27px;
  height: 31px;
  place-items: center;
  padding: 0 7px 4px;
  background: #0f7f95;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 950;
  line-height: 1;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%);
}

.book-card:nth-child(1) .book-rank-badge {
  background: #d59a16;
  color: #ffffff;
}

.book-card:nth-child(2) .book-rank-badge {
  background: #8fa1b5;
  color: #ffffff;
}

.book-card:nth-child(3) .book-rank-badge {
  background: #c7772c;
  color: #ffffff;
}

.book-cover {
  position: relative;
  display: grid;
  width: 100%;
  height: 210px;
  place-items: center;
  flex: 0 0 210px;
  overflow: hidden;
  border: 1px solid #e4edf7;
  border-radius: 8px;
  background: #f8fbff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.book-cover img {
  position: absolute;
  inset: 6px;
  display: block;
  width: calc(100% - 12px);
  height: calc(100% - 12px);
  object-fit: contain;
}

.book-cover.is-fallback {
  background:
    radial-gradient(circle at 76% 16%, rgba(17, 199, 213, 0.16), transparent 34%),
    linear-gradient(145deg, #fbfdff, #edf5fb);
}

.book-cover-placeholder {
  position: relative;
  display: none;
  width: 72px;
  height: 96px;
  border: 1px solid rgba(8, 137, 155, 0.34);
  border-radius: 8px 5px 5px 8px;
  background:
    linear-gradient(90deg, rgba(13, 148, 164, 0.24), rgba(13, 148, 164, 0.08) 30%, transparent 31%),
    linear-gradient(180deg, #ffffff, #dff3f8);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.book-cover-placeholder::before {
  content: "";
  position: absolute;
  top: 22px;
  right: 12px;
  left: 24px;
  height: 2px;
  border-radius: 999px;
  background: rgba(8, 137, 155, 0.32);
  box-shadow:
    0 11px 0 rgba(8, 137, 155, 0.2),
    0 22px 0 rgba(8, 137, 155, 0.14);
}

.book-cover-placeholder::after {
  content: "이미지 준비중";
  position: absolute;
  right: -28px;
  bottom: -27px;
  left: -28px;
  color: #6b7d95;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.book-cover.is-fallback .book-cover-placeholder {
  display: block;
}

.book-title {
  display: -webkit-box;
  height: 3.12em;
  padding-bottom: 2px;
  overflow: hidden;
  color: #11213a;
  font-size: 0.88rem;
  font-weight: 900;
  line-height: 1.48;
  word-break: keep-all;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.books-empty {
  margin: 38px 0;
  color: #64748b;
  font-weight: 850;
  text-align: center;
}

.books-pagination {
  display: flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 22px 0 0;
}

.books-pagination:empty {
  display: none;
}

.books-pagination:empty + .books-bottom {
  margin-top: 10px;
}

.books-page-button,
.books-page-ellipsis {
  display: inline-grid;
  min-width: 31px;
  height: 31px;
  place-items: center;
  border: 1px solid #cfe0ef;
  border-radius: 8px;
  background: #ffffff;
  color: #40536d;
  font-size: 0.82rem;
  font-weight: 900;
}

.books-page-button:hover,
.books-page-button:focus-visible,
.books-page-button.is-active {
  border-color: rgba(17, 199, 213, 0.75);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #ffffff;
}

.books-page-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.books-page-ellipsis {
  border-color: transparent;
  background: transparent;
}

.books-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 12px 0 0;
}

.books-affiliate-notice {
  display: inline-flex;
  width: fit-content;
  max-width: min(100%, 620px);
  min-height: 34px;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  padding: 7px 14px;
  border: 1px solid rgba(8, 137, 155, 0.34);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #5d6d84;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
}

.books-actions {
  display: flex;
  flex: 0 0 auto;
  justify-content: flex-start;
}

.books-back-link {
  min-height: 40px;
  padding: 0 16px;
  border-color: rgba(17, 199, 213, 0.36);
  color: #0e6d80;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.06);
}

@media (max-width: 1060px) {
  .books-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .book-card:nth-child(6n) {
    border-right: 1px solid var(--books-rail-line);
  }

  .book-card:nth-child(4n) {
    border-right: 0;
  }
}

@media (max-width: 760px) {
  .books-hero-inner,
  .books-heading {
    align-items: flex-start;
  }

  .books-hero-inner {
    flex-direction: column;
  }

  .books-heading {
    flex-wrap: wrap;
  }

  .books-heading-divider {
    display: none;
  }

  .books-heading p {
    flex-basis: 100%;
  }

  .books-board {
    min-height: 0;
    padding: 14px 12px;
  }

  .books-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .book-card,
  .book-card:nth-child(4n),
  .book-card:nth-child(6n) {
    border-right: 1px solid var(--books-rail-line);
  }

  .book-card:nth-child(2n) {
    border-right: 0;
  }

  .books-affiliate-notice {
    margin-left: 0;
  }

  .books-bottom {
    align-items: flex-start;
    flex-direction: column-reverse;
  }

  .books-affiliate-notice {
    align-self: flex-end;
  }
}

@media (max-width: 430px) {
  .books-grid {
    grid-template-columns: 1fr;
  }

  .book-card,
  .book-card:nth-child(2n),
  .book-card:nth-child(4n),
  .book-card:nth-child(6n) {
    border-right: 0;
  }
}
