.library-page,
.mobile-library {
  --library-bg: var(--app-canvas);
  --library-surface: var(--app-surface);
  --library-text: var(--app-ink);
  --library-muted: var(--app-muted);
  --library-border: var(--app-border);
  --scrolllit-red: #a51f27;
  color: var(--library-text);
}

.library-page {
  max-width: 1500px;
  margin-inline: auto;
  padding: 40px clamp(20px, 4vw, 56px) 80px;
}

.library-page-heading,
.mobile-library-heading {
  margin: 0;
  color: var(--library-text);
  font: 700 clamp(2rem, 3vw, 2.75rem)/1 Georgia, serif;
  letter-spacing: -.035em;
}

.library-search-shell {
  display: flex;
  width: min(680px, 100%);
  height: 52px;
  align-items: center;
  gap: .7rem;
  margin-top: 18px;
  padding: 0 .9rem;
  border: 1px solid var(--library-border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--app-raised) 58%, transparent);
  box-shadow: 0 2px 10px var(--app-shadow);
}

.library-search-shell:focus-within {
  border-color: var(--app-border);
  background: var(--app-raised);
  box-shadow: 0 4px 18px var(--app-shadow);
}

.library-search-shell svg { width: 1.15rem; height: 1.15rem; flex: 0 0 auto; color: var(--library-muted); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.library-search-shell input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--library-text); font: inherit; }
.library-search-shell input::placeholder { color: var(--library-muted); opacity: 1; }
.library-search-shell button { display: grid; width: 2rem; height: 2rem; flex: 0 0 auto; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--library-text); cursor: pointer; }
.library-search-shell button:hover { background: var(--app-hover); }

.library-content { margin-top: 48px; }
.library-shelf + .library-shelf { margin-top: 48px; }
.library-shelf-header { display: flex; min-height: 2rem; align-items: center; justify-content: space-between; gap: 1rem; }
.library-shelf-title,
.library-results-title { margin: 0; color: var(--library-text); font: 700 clamp(1.35rem, 2vw, 1.75rem)/1.15 Georgia, serif; letter-spacing: -.02em; }
.library-back-link { color: var(--library-text); font-size: .875rem; font-weight: 700; text-decoration: none; }
.library-back-link:hover { color: var(--scrolllit-red); }

.library-book-link:focus-visible,
.library-book-choice-trigger:focus-visible,
.library-request-book-action:focus-visible { outline: 3px solid var(--scrolllit-red); outline-offset: 3px; }

.library-book {
  position: relative;
  min-width: 0;
  list-style: none;
}
.library-book-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 14px;
  background: #e8e0d2;
  box-shadow: 0 5px 16px rgb(0 0 0 / 10%), 0 1px 2px rgb(0 0 0 / 8%);
  transition: transform .18s ease, box-shadow .18s ease;
}
.library-book-cover .generated-image,
.library-book-cover img,
.library-book-cover > .library-book-placeholder { display: grid; width: 100%; height: 100%; place-items: center; }
.library-book-cover img { object-fit: cover; }
.library-book-placeholder { background: linear-gradient(145deg, #e6dbca, #f8f4eb); color: #95765d; font: 600 3.25rem/1 Georgia, serif; }
.library-book:hover .library-book-cover,
.library-book:focus-within .library-book-cover { transform: translateY(-4px) scale(1.015); box-shadow: 0 10px 28px rgb(0 0 0 / 14%); }
.library-book-title { display: block; margin: 10px 0 0; overflow-wrap: anywhere; color: var(--library-text); font: 700 1rem/1.08 Georgia, serif; }
.library-book-author { display: block; margin-top: 4px; overflow-wrap: anywhere; color: var(--library-muted); font-size: .76rem; line-height: 1.25; }
.library-book-link,
.library-book-choice-trigger { position: absolute; z-index: 10; inset: 0; border: 0; border-radius: 14px; background: transparent; cursor: pointer; }
.library-book-link { color: inherit; text-decoration: none; }
.library-book-choice-trigger { width: 100%; padding: 0; }
.library-book-status { position: absolute; top: .55rem; left: .55rem; z-index: 20; padding: .25rem .45rem; border-radius: 999px; background: rgb(255 255 255 / 90%); color: #4338ca; font-size: .62rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; pointer-events: none; }
.library-book-ribbon { position: absolute; top: 0; right: .55rem; z-index: 20; display: block; box-sizing: border-box; width: 25px; height: 76px; padding: 2px 2px 7px; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 91%, 0 100%); pointer-events: none; }
.library-book-ribbon--preview { background: #fffdf8; }
.library-book-ribbon--trial,
.library-book-ribbon--owned { background: #e31b23; }
.library-book-ribbon--expired { background: #9ca3af; }
.library-alert-bubbles { position: absolute; top: .55rem; right: 2.35rem; z-index: 25; display: flex; gap: .3rem; pointer-events: none; }
.library-alert-bubble { display: grid; width: 1.75rem; height: 1.75rem; place-items: center; border: 2px solid white; border-radius: 999px; box-shadow: 0 2px 5px rgb(0 0 0 / 24%); color: white; font-size: .58rem; font-weight: 900; line-height: 1; }
.library-alert-bubble--review { background: #2563eb; }
.library-alert-bubble--active { background: #dc2626; }
.library-book-model-chip { position: absolute; right: .45rem; bottom: .45rem; z-index: 20; max-width: calc(100% - .9rem); overflow: hidden; padding: .28rem .42rem; border: 1px solid rgb(23 23 23 / 28%); border-radius: 999px; background: rgb(255 255 255 / 92%); color: #171717; font-size: .62rem; font-weight: 700; line-height: 1; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
.library-book-menu-button { position: absolute; top: .45rem; left: .45rem; z-index: 30; display: grid; width: 2rem; height: 2rem; place-items: center; border: 0; border-radius: 999px; background: rgb(23 23 23 / 68%); color: white; opacity: 0; transition: opacity .18s ease; }
.library-book:hover .library-book-menu-button,
.library-book:focus-within .library-book-menu-button { opacity: 1; }
.library-book-menu-button svg { width: 1.1rem; height: 1.1rem; }

.library-book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 225px)); gap: 28px 16px; margin: 22px 0 0; padding: 0; list-style: none; }
.library-empty-state { max-width: 28rem; padding: 2.5rem 0; color: var(--library-muted); }
.library-empty-state h2 { margin: 0; color: var(--library-text); font: 700 1.4rem/1.2 Georgia, serif; }
.library-empty-state p { margin: .5rem 0 0; line-height: 1.5; }
.library-request-book-grid { margin-top: 22px; }
.library-request-book-cover { background: linear-gradient(145deg, #e0f2fe 0%, #bfdbfe 48%, #dbeafe 100%); box-shadow: inset 0 0 0 1px rgb(37 99 235 / .2), 0 5px 16px rgb(37 99 235 / .17), 0 1px 2px rgb(30 64 175 / .12); }
.library-request-book-cover::before { position: absolute; inset: 0 auto 0 50%; width: 2px; background: rgb(30 64 175 / .2); content: ""; transform: translateX(-1px); }
.library-request-book-cover svg { position: relative; z-index: 1; width: 62%; height: 62%; fill: rgb(239 246 255 / .5); stroke: #2563eb; stroke-linecap: round; stroke-linejoin: round; stroke-width: 4; filter: drop-shadow(0 4px 4px rgb(30 64 175 / .18)); }
.library-request-book-action { position: absolute; z-index: 10; inset: 0; width: 100%; border: 0; border-radius: 14px; background: transparent; cursor: pointer; }
.library-request-book:hover .library-request-book-cover,
.library-request-book:focus-within .library-request-book-cover { transform: translateY(-4px) scale(1.015); box-shadow: inset 0 0 0 1px rgb(37 99 235 / .3), 0 10px 28px rgb(37 99 235 / .24); }
.library-hidden-texts { margin-top: 3rem; }
.library-hidden-texts summary { color: var(--library-text); cursor: pointer; font-size: .9rem; font-weight: 700; }
.library-hidden-texts summary span { color: var(--library-muted); }
.library-hidden-show { position: absolute; top: .5rem; right: .5rem; z-index: 20; }
.library-hidden-show button { border: 0; border-radius: 999px; padding: .4rem .65rem; background: rgb(23 23 23 / 80%); color: white; font-size: .72rem; font-weight: 700; cursor: pointer; }

.library-new-book-glow { animation: library-new-book-glow 2.8s ease-in-out infinite alternate; }
.library-initial-pipeline-glow { animation: library-initial-pipeline-glow 2.6s ease-in-out infinite alternate; }
@keyframes library-new-book-glow { from { filter: drop-shadow(0 0 6px rgb(59 130 246 / .25)); } to { filter: drop-shadow(0 0 18px rgb(59 130 246 / .55)); } }
@keyframes library-initial-pipeline-glow { from { filter: drop-shadow(0 0 6px rgb(59 130 246 / .34)); } to { filter: drop-shadow(0 0 18px rgb(59 130 246 / .72)); } }

@media (max-width: 767px) {
  .mobile-library { padding: 22px 14px 50px; }
  .mobile-library-heading { font-size: 2rem; }
  .mobile-library .library-search-shell { width: 100%; height: 48px; margin-top: 14px; }
  .mobile-library .library-content { margin-top: 34px; }
  .mobile-library .library-shelf + .library-shelf { margin-top: 34px; }
  .mobile-library .library-shelf-title,
  .mobile-library .library-results-title { font-size: 1.28rem; }
  .mobile-library .library-book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 11px; }
  .mobile-library .library-book-grid .library-book { width: 100%; min-width: 0; }
  .mobile-library .library-book-title { font-size: .96rem; }
  .mobile-library .library-book-author { font-size: .73rem; }
  .mobile-library .library-book-menu-button { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .library-book-cover { transition: none; }
  .library-new-book-glow,
  .library-initial-pipeline-glow { animation: none; outline: 3px solid rgb(59 130 246 / .5); outline-offset: 3px; }
}
