.library-page {
  min-height: calc(100vh - 44px);
  padding: 34px clamp(22px, 5vw, 80px) 78px;
  background:
    radial-gradient(circle at 88% 18%, rgba(70, 130, 188, .25), transparent 34%),
    linear-gradient(135deg, #07345e, #03172d 58%);
}

.library-heading {
  text-align: center;
}

.return-home {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 195, 66, .78);
  background: rgba(3, 23, 45, .6);
  color: var(--gold);
  font-size: 12px;
  font-weight: bold;
  letter-spacing: .1em;
  transition: background .2s ease, color .2s ease;
}

.return-home:hover,
.return-home:focus-visible {
  background: var(--gold);
  color: var(--navy);
}

.return-home:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.library-heading h1 {
  margin: 8px 0 0;
  font: clamp(38px, 4vw, 62px)/1 var(--serif);
}

.library-heading > p:last-child {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .2em;
}

.collection-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-width: 900px;
  margin: 28px auto 34px;
}

.collection-tabs button {
  min-height: 50px;
  border: 1px solid #91abc3;
  background: rgba(3, 23, 45, .35);
  color: var(--white);
  font-weight: bold;
  letter-spacing: .07em;
  cursor: pointer;
}

.collection-tabs button strong {
  margin-left: 12px;
  color: var(--gold);
}

.collection-tabs button.active {
  border-color: var(--gold);
  background: var(--gold);
  color: var(--navy);
}

.collection-tabs button.active strong {
  color: var(--navy);
}

.collection-tabs button:focus-visible,
.collection-actions a:focus-visible,
.back-to-top:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.genre-panel {
  max-width: 1400px;
  margin: 0 auto;
}

.collection-sequence {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: .18em;
}

.collection-sequence i {
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 195, 66, .18), var(--gold));
}

.scitech-shelf {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: clamp(8px, 1vw, 15px);
  align-items: stretch;
}

.book-tile {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
  padding: 9px;
  border: 1px solid rgba(214, 230, 245, .34);
  background: linear-gradient(155deg, rgba(16, 61, 98, .94), rgba(3, 23, 45, .98));
  color: var(--white);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(0, 0, 0, .24);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.book-tile:hover,
.book-tile:focus-visible,
.book-tile.active {
  border-color: var(--gold);
  transform: translateY(-5px);
  box-shadow: 0 18px 34px rgba(0, 0, 0, .38), 0 0 0 1px rgba(255, 195, 66, .25);
}

.book-tile:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.book-tile img,
.pending-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  margin-bottom: 10px;
}

.book-tile img {
  object-fit: cover;
  object-position: center;
  box-shadow: 6px 8px 12px rgba(0, 0, 0, .42);
}

.book-tile > strong {
  min-height: 31px;
  color: #fff;
  font-size: 12.5px;
  line-height: 1.2;
  letter-spacing: .04em;
}

.book-tile > small {
  flex: 1;
  margin-top: 5px;
  color: var(--muted);
  font: 12px/1.28 var(--serif);
}

.click-cue {
  align-self: flex-start;
  margin-top: 10px;
  padding: 5px 7px;
  border: 1px solid #aebdcb;
  color: #dce5ed;
  font-size: 11.5px;
  font-weight: bold;
  letter-spacing: .08em;
}

.click-cue span {
  margin-right: 3px;
  font-size: 15px;
}

.book-tile.pending {
  opacity: .74;
  cursor: default;
}

.book-tile.pending:hover {
  border-color: rgba(214, 230, 245, .34);
  transform: none;
  box-shadow: 0 12px 26px rgba(0, 0, 0, .24);
}

.pending-cover {
  display: grid;
  place-content: center;
  gap: 7px;
  padding: 8px;
  border: 1px solid #7da7ca;
  background:
    radial-gradient(circle at 50% 34%, rgba(109, 184, 228, .42), transparent 28%),
    linear-gradient(155deg, #0f5f91, #031a34 72%);
  color: #fff;
  text-align: center;
  box-shadow: 6px 8px 12px rgba(0, 0, 0, .42);
}

.pending-cover b {
  font: clamp(12px, 1.05vw, 17px)/1.1 var(--serif);
}

.pending-cover small {
  color: var(--gold);
  font-size: 9px;
  font-weight: bold;
  letter-spacing: .08em;
}

.shelf-instruction {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.book-details {
  margin-top: 26px;
  scroll-margin-top: 18px;
}

.book-detail[hidden] {
  display: none !important;
}

.books-stack {
  display: grid;
  gap: 34px;
}

.collection-book {
  display: grid;
  grid-template-columns: minmax(260px, 35%) 1fr;
  gap: clamp(34px, 5vw, 78px);
  padding: 30px;
  scroll-margin-top: 24px;
  border: 1px solid rgba(214, 230, 245, .34);
  background: linear-gradient(120deg, rgba(11, 47, 77, .96), rgba(4, 26, 49, .96));
  box-shadow: 0 24px 55px rgba(0, 0, 0, .3);
}

.books-stack .collection-book:nth-child(even) {
  background: linear-gradient(120deg, rgba(5, 30, 56, .97), rgba(12, 53, 87, .94));
}

.collection-cover-wrap {
  display: grid;
  place-items: center;
}

.collection-cover-wrap img {
  width: auto;
  max-width: 100%;
  height: min(590px, 68vh);
  object-fit: contain;
  filter: drop-shadow(15px 20px 16px rgba(0, 0, 0, .48));
}

.collection-book-copy {
  align-self: center;
  min-width: 0;
}

.collection-book-copy h2 {
  margin: 10px 0 5px;
  font: clamp(40px, 5vw, 72px)/.95 var(--serif);
  overflow-wrap: anywhere;
}

.book-subtitle {
  margin: 0 0 25px;
  color: var(--gold);
  font-weight: bold;
  letter-spacing: .18em;
}

.book-blurb {
  max-width: 710px;
  color: #e8eef5;
  font: 17px/1.55 var(--serif);
}

.book-blurb p {
  margin: 0 0 13px;
}

.collection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.collection-actions .button {
  min-height: 44px;
}

.collection-actions .outline {
  gap: 8px;
}

.collection-actions .outline span {
  font-size: 20px;
}

.next-titles {
  margin-top: 34px;
  padding: 22px clamp(18px, 3vw, 32px);
  border: 1px solid var(--line);
  background: rgba(3, 23, 45, .52);
  text-align: center;
}

.next-titles p:last-child {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: bold;
  line-height: 1.7;
  letter-spacing: .1em;
}

.pending-collection {
  min-height: 360px;
  display: grid;
  place-content: center;
  padding: 30px;
  border: 1px solid var(--line);
  background: rgba(6, 40, 73, .7);
  text-align: center;
}

.pending-collection strong {
  font: 30px var(--serif);
}

.pending-collection p {
  color: var(--muted);
}

.archive-intro {
  max-width: 820px;
  margin: 0 auto 26px;
  text-align: center;
}

.archive-intro h2 {
  margin: 8px 0 10px;
  font: clamp(35px, 4vw, 54px)/1 var(--serif);
}

.archive-intro > p:last-child {
  margin: 0;
  color: var(--muted);
  font: 16px/1.5 var(--serif);
}

.archive-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(16px, 2vw, 28px);
  align-items: stretch;
}

.archive-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: clamp(16px, 2vw, 24px);
  border: 1px solid rgba(214, 230, 245, .36);
  background: linear-gradient(150deg, rgba(13, 55, 91, .96), rgba(3, 23, 45, .99));
  box-shadow: 0 20px 42px rgba(0, 0, 0, .3);
}

.archive-cover-frame {
  display: grid;
  place-items: center;
  min-height: 470px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(1, 15, 30, .5);
}

.archive-cover-frame img {
  width: 100%;
  height: 445px;
  object-fit: contain;
  filter: drop-shadow(12px 16px 12px rgba(0, 0, 0, .48));
}

.archive-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding-top: 20px;
}

.archive-meta {
  margin: 0;
  color: var(--gold);
  font-size: 12px;
  font-weight: bold;
  letter-spacing: .13em;
}

.archive-copy h3 {
  margin: 9px 0 5px;
  font: clamp(27px, 2.4vw, 39px)/1.03 var(--serif);
}

.archive-subtitle {
  margin: 0 0 17px;
  color: #b9cee0;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: .13em;
}

.archive-copy > p:not(.archive-meta):not(.archive-subtitle) {
  margin: 0 0 20px;
  color: #e8eef5;
  font: 16px/1.52 var(--serif);
}

.archive-publication {
  line-height: 1.7 !important;
}

.archive-status {
  display: inline-flex;
  align-self: flex-start;
  margin-top: auto;
  padding: 7px 9px;
  border: 1px solid rgba(255, 195, 66, .62);
  color: var(--gold);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: .09em;
}

.back-to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 5;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid rgba(255, 195, 66, .72);
  background: rgba(3, 23, 45, .9);
  color: var(--gold);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: .1em;
  box-shadow: 0 7px 24px rgba(0, 0, 0, .28);
}

@media (min-width: 761px) and (max-width: 1100px) {
  .scitech-shelf {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 152px;
    padding: 4px 2px 18px;
    overflow-x: auto;
    scroll-snap-type: inline mandatory;
    scrollbar-color: var(--gold) rgba(3, 23, 45, .55);
  }

  .book-tile {
    scroll-snap-align: start;
  }
}

@media (max-width: 760px) {
  .library-page {
    min-height: calc(100vh - 58px);
    padding: 26px 18px 64px;
  }

  .library-heading > p:last-child {
    font-size: 11px;
    line-height: 1.6;
  }

  .return-home {
    width: 100%;
    justify-content: center;
    margin-bottom: 24px;
  }

  .collection-tabs {
    grid-template-columns: 1fr;
    margin: 22px auto;
  }

  .collection-tabs button {
    min-height: 46px;
  }

  .collection-sequence {
    gap: 10px;
    font-size: 10px;
    letter-spacing: .1em;
  }

  .scitech-shelf {
    display: grid;
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(148px, 46vw);
    gap: 12px;
    padding: 4px 2px 18px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline mandatory;
    scrollbar-color: var(--gold) rgba(3, 23, 45, .55);
  }

  .book-tile {
    scroll-snap-align: start;
  }

  .book-tile:hover,
  .book-tile:focus-visible,
  .book-tile.active {
    transform: none;
  }

  .book-tile > strong {
    font-size: 13px;
  }

  .book-tile > small {
    font-size: 12.5px;
  }

  .shelf-instruction {
    margin-top: 6px;
    font-size: 12px;
  }

  .book-details {
    margin-top: 20px;
  }

  .books-stack {
    gap: 24px;
  }

  .collection-book {
    grid-template-columns: 1fr;
    gap: 28px;
    padding: 22px;
  }

  .collection-cover-wrap img {
    width: 100%;
    height: auto;
    max-height: 560px;
  }

  .collection-book-copy {
    text-align: left;
  }

  .collection-book-copy h2 {
    font-size: clamp(38px, 12vw, 50px);
  }

  .book-blurb {
    font-size: 16px;
  }

  .collection-actions {
    display: grid;
  }

  .collection-actions .button {
    width: 100%;
  }

  .next-titles {
    margin-top: 24px;
  }

  .archive-grid {
    grid-template-columns: 1fr;
  }

  .archive-cover-frame {
    min-height: 0;
  }

  .archive-cover-frame img {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 560px;
  }

  .archive-copy h3 {
    font-size: clamp(31px, 9vw, 40px);
  }

  .back-to-top {
    right: 12px;
    bottom: 12px;
    width: 42px;
    padding: 0;
    justify-content: center;
  }

  .back-to-top span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .archive-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .archive-card:last-child {
    grid-column: 1 / -1;
    max-width: calc(50% - 14px);
    width: 100%;
    justify-self: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
