/* Library-only page system. Loaded after css/styles.css and scoped to body.library-page. */

.library-page {
    --header-height: 72px;
    --library-cyan: #6ef3ff;
    --library-blue: #60a5fa;
    --library-violet: #a78bfa;
    --library-ink: rgba(13, 13, 15, 0.88);
    --library-panel: rgba(255, 255, 255, 0.035);
    --library-panel-strong: rgba(255, 255, 255, 0.06);
    --library-border: rgba(255, 255, 255, 0.11);
    --library-border-soft: rgba(255, 255, 255, 0.07);
    --library-muted: rgba(255, 255, 255, 0.62);
    --library-faint: rgba(255, 255, 255, 0.38);
    --library-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
    background:
        radial-gradient(42% 28% at 20% 14%, rgba(59, 130, 246, 0.12), transparent 70%),
        radial-gradient(32% 24% at 84% 20%, rgba(167, 139, 250, 0.09), transparent 72%),
        var(--bg-color);
}

.library-shell {
    width: min(100%, var(--container-width));
    margin: 0 auto;
    padding: calc(var(--header-height) + 4.4rem) 3rem 5rem;
    position: relative;
    isolation: isolate;
}

.library-shell::before {
    content: "";
    position: absolute;
    inset: var(--header-height) 0 auto;
    height: 34rem;
    z-index: -1;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 58%),
        radial-gradient(54% 42% at 50% 0%, rgba(96, 165, 250, 0.14), transparent 72%);
    filter: blur(18px);
    opacity: 0.82;
}

.library-breadcrumb,
.library-kicker,
.featured-label,
.sort-and-count label,
.search-wrapper label,
.filter-label,
.stat-label,
.drawer-category,
.drawer-cover-kicker,
.cover-kicker {
    color: var(--library-faint);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.library-breadcrumb {
    display: inline-flex;
    width: fit-content;
    margin-bottom: 2rem;
    color: rgba(255, 255, 255, 0.55);
    transition: color 0.2s ease;
}

.library-breadcrumb:hover {
    color: var(--text-primary);
}

.library-hero {
    min-height: 34rem;
    display: grid;
    grid-template-columns: minmax(0, 1.03fr) minmax(340px, 0.7fr);
    gap: 5rem;
    align-items: center;
    padding: 2.2rem 0 4rem;
    position: relative;
}

.library-hero::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(96, 165, 250, 0.48) 26%,
            rgba(255, 255, 255, 0.72) 50%,
            rgba(110, 243, 255, 0.4) 74%,
            transparent 100%);
    box-shadow: 0 0 24px rgba(96, 165, 250, 0.18);
}

.library-hero-copy {
    max-width: 780px;
}

.library-title {
    margin: 0.4rem 0 1.4rem;
    font-size: 4.5rem;
    line-height: 1.02;
    letter-spacing: 0;
    text-shadow: 0 24px 80px rgba(96, 165, 250, 0.14);
}

.library-title::after {
    content: "";
    display: inline-block;
    width: 0.16em;
    height: 0.16em;
    margin-left: 0.08em;
    border-radius: 50%;
    background: var(--library-blue);
    box-shadow: 0 0 14px rgba(96, 165, 250, 0.75);
    vertical-align: baseline;
}

.library-lede {
    max-width: 720px;
    color: rgba(255, 255, 255, 0.76);
    font-size: 1.22rem;
    line-height: 1.65;
}

.library-editorial-note {
    max-width: 620px;
    margin-top: 1.8rem;
    padding-left: 1rem;
    border-left: 2px solid var(--library-blue);
    color: var(--library-muted);
    font-family: Merriweather, serif;
    font-size: 1rem;
    font-style: italic;
    font-weight: 300;
    line-height: 1.7;
}

.featured-read {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 1.45rem;
    align-items: center;
    padding: 1.35rem;
    border: 1px solid var(--library-border);
    border-radius: 8px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025)),
        rgba(13, 13, 15, 0.48);
    box-shadow: var(--library-shadow);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    position: relative;
    overflow: hidden;
}

.featured-read::before {
    content: "";
    position: absolute;
    inset: 0;
    border-left: 2px solid rgba(110, 243, 255, 0.54);
    pointer-events: none;
}

.featured-cover,
.book-cover,
.drawer-cover {
    border-radius: 6px 10px 10px 6px;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0 1px, transparent 1px 9px, rgba(0, 0, 0, 0.22) 9px 16px, transparent 16px),
        radial-gradient(82% 54% at 74% 16%, rgba(255, 255, 255, 0.2), transparent 70%),
        linear-gradient(145deg, var(--cover-a, #1d4ed8), var(--cover-b, #0f172a) 62%, #050507);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow:
        inset 14px 0 30px rgba(0, 0, 0, 0.24),
        inset -1px 0 0 rgba(255, 255, 255, 0.08),
        0 18px 44px rgba(0, 0, 0, 0.36);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.featured-cover {
    width: 160px;
    min-height: 222px;
    padding: 1rem 1rem 0.9rem 1.3rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    --cover-a: #1d4ed8;
    --cover-b: #312e81;
}

.cover-title {
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.12;
    max-width: 11ch;
}

.cover-mark,
.drawer-cover-mark {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.featured-copy {
    position: relative;
    z-index: 1;
}

.featured-title {
    margin: 0.35rem 0 0.35rem;
    font-size: 1.4rem;
    line-height: 1.12;
}

.featured-author,
.featured-note {
    color: var(--library-muted);
}

.featured-author {
    margin-bottom: 1rem;
}

.featured-note {
    line-height: 1.58;
}

.library-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    margin: 2.6rem 0;
    border: 1px solid var(--library-border-soft);
    border-radius: 8px;
    overflow: hidden;
    background: var(--library-border-soft);
}

.library-stat {
    min-height: 8.3rem;
    padding: 1.25rem;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.016)),
        rgba(13, 13, 15, 0.74);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-value {
    color: var(--text-primary);
    font-size: 2.25rem;
    font-weight: 600;
    line-height: 1;
}

.stat-label {
    color: var(--library-muted);
}

.library-controls {
    margin: 3rem 0 3.2rem;
}

.controls-intro {
    max-width: 520px;
    margin-bottom: 1.2rem;
}

.controls-intro h2,
.results-heading h2 {
    margin: 0.25rem 0 0.55rem;
    font-size: 1.6rem;
    line-height: 1.14;
}

.controls-intro p {
    color: var(--library-muted);
    line-height: 1.6;
}

.controls-grid {
    display: grid;
    grid-template-columns: minmax(250px, 0.85fr) minmax(0, 1.6fr) minmax(170px, 0.45fr);
    gap: 1.5rem;
    align-items: stretch;
    padding: 1.35rem;
    border: 1px solid var(--library-border);
    border-radius: 8px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.052), rgba(255, 255, 255, 0.018)),
        rgba(13, 13, 15, 0.58);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.search-wrapper,
.filter-section,
.sort-and-count {
    min-width: 0;
}

.search-wrapper,
.sort-and-count {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.filter-section {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.lib-input,
.lib-select {
    min-height: 2.95rem;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.035);
    color: var(--text-primary);
    padding: 0.72rem 0.85rem;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.lib-input::placeholder {
    color: rgba(255, 255, 255, 0.38);
}

.lib-input:focus,
.lib-select:focus {
    border-color: rgba(96, 165, 250, 0.72);
    background: rgba(255, 255, 255, 0.055);
    box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.12);
    outline: none;
}

.lib-select option {
    background: #111114;
    color: #f4f4f5;
}

.tag-filters {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.filter-chip {
    min-height: 2.25rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.025);
    color: rgba(255, 255, 255, 0.72);
    padding: 0.46rem 0.78rem;
    font-size: 0.78rem;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.filter-chip::before {
    content: "";
    width: 0.36rem;
    height: 0.36rem;
    border-radius: 50%;
    background: var(--chip-accent, var(--library-blue));
    box-shadow: 0 0 10px color-mix(in srgb, var(--chip-accent, var(--library-blue)) 60%, transparent);
    opacity: 0.65;
}

.filter-chip:hover,
.filter-chip.active {
    border-color: color-mix(in srgb, var(--chip-accent, var(--library-blue)) 70%, rgba(255, 255, 255, 0.2));
    background: color-mix(in srgb, var(--chip-accent, var(--library-blue)) 14%, transparent);
    color: var(--text-primary);
}

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

.library-text-button {
    border: 0;
    background: none;
    color: var(--library-blue);
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: none;
}

.library-text-button:hover {
    color: var(--text-primary);
}

.library-text-button.hidden {
    display: none;
}

.result-count {
    color: var(--library-muted);
    font-size: 0.88rem;
}

.library-results {
    margin-top: 1rem;
}

.results-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.shelf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 1.35rem;
    padding-bottom: 4rem;
    content-visibility: visible;
    contain-intrinsic-size: auto;
    background: none;
}

.shelf-item.book-card {
    min-height: 15.5rem;
    display: grid;
    grid-template-columns: 104px 1fr;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--library-border-soft);
    border-radius: 8px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.018)),
        rgba(19, 19, 22, 0.76);
    color: inherit;
    text-align: left;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    opacity: 0;
    translate: 0 12px;
    animation: libraryCardReveal 0.48s ease forwards;
    animation-delay: calc(var(--reveal-index, 0) * 45ms);
    transition: transform 0.24s ease, border-color 0.24s ease, box-shadow 0.24s ease, background 0.24s ease;
}

@keyframes libraryCardReveal {
    from {
        opacity: 0;
        translate: 0 12px;
    }

    to {
        opacity: 1;
        translate: 0 0;
    }
}

.shelf-item.book-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-left: 2px solid var(--book-accent, var(--library-blue));
    opacity: 0.9;
    pointer-events: none;
}

.shelf-item.book-card::after {
    content: "";
    position: absolute;
    inset: -40% -20% auto 24%;
    height: 11rem;
    pointer-events: none;
    background: radial-gradient(circle, color-mix(in srgb, var(--book-accent, var(--library-blue)) 18%, transparent), transparent 68%);
    opacity: 0;
    transition: opacity 0.24s ease;
}

.shelf-item.book-card:hover {
    transform: translateY(-5px);
    border-color: color-mix(in srgb, var(--book-accent, var(--library-blue)) 42%, rgba(255, 255, 255, 0.16));
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.32);
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.026)),
        rgba(19, 19, 22, 0.82);
}

.shelf-item.book-card:hover::after {
    opacity: 1;
}

.shelf-item.book-card:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 4px;
    transform: translateY(-3px);
}

.book-cover {
    min-height: 150px;
    padding: 0.78rem 0.7rem 0.72rem 0.92rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 1;
}

.book-cover.has-image {
    padding: 0;
    background: #111114;
}

.book-cover img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.cover-initials {
    align-self: flex-start;
    color: rgba(255, 255, 255, 0.74);
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1;
}

.book-cover-title {
    max-width: 8ch;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.16;
}

.book-cover-meta {
    color: rgba(255, 255, 255, 0.42);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.book-card-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.82rem;
    z-index: 1;
}

.book-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.8rem;
}

.book-category {
    color: var(--book-accent, var(--library-blue));
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.favorite-marker {
    display: inline-flex;
    align-items: center;
    min-height: 1.55rem;
    border: 1px solid color-mix(in srgb, var(--book-accent, var(--library-blue)) 36%, rgba(255, 255, 255, 0.12));
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.75);
    padding: 0.15rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 600;
    white-space: nowrap;
}

.book-title {
    color: rgba(255, 255, 255, 0.92);
    font-size: 1.24rem;
    line-height: 1.12;
    font-weight: 600;
    margin: 0;
}

.book-author {
    color: var(--library-muted);
    font-size: 0.92rem;
    margin: 0.35rem 0 0;
}

.book-note {
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.92rem;
    line-height: 1.5;
}

.book-footer {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
    align-items: start;
    margin-top: auto;
    padding-top: 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    color: inherit;
    font-family: var(--font-main);
    font-size: 1rem;
    text-align: left;
}

.rating-system {
    min-width: 0;
}

.rating-line {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    margin-bottom: 0.42rem;
}

.rating-score {
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 600;
}

.rating-label {
    color: var(--library-muted);
    font-size: 0.76rem;
}

.rating-track {
    width: 100%;
    height: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.rating-fill {
    display: block;
    height: 100%;
    width: var(--rating-width, 0%);
    border-radius: inherit;
    background: linear-gradient(90deg, var(--book-accent, var(--library-blue)), rgba(255, 255, 255, 0.78));
}

.book-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.38rem;
}

.book-tag {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.56);
    padding: 0.2rem 0.5rem;
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.library-empty-state {
    padding: 3rem 1.5rem;
    border: 1px dashed rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.025);
    text-align: center;
    color: var(--library-muted);
}

.empty-title {
    margin-bottom: 0.4rem;
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
}

.library-home-return {
    margin-top: 1rem;
    padding: 2rem 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.library-return-link {
    color: var(--text-primary);
    font-weight: 600;
}

.library-return-link::before {
    content: "<-";
    margin-right: 0.5rem;
    color: var(--library-blue);
}

.library-home-return p {
    color: var(--library-faint);
}

.library-drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
}

.library-drawer-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.library-book-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(520px, 94vw);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(56% 30% at 20% 0%, rgba(96, 165, 250, 0.16), transparent 72%),
        #101013;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: -28px 0 80px rgba(0, 0, 0, 0.46);
    transform: translateX(100%);
    transition: transform 0.34s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
}

.library-book-drawer.active {
    transform: translateX(0);
}

.library-drawer-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 2;
    width: 2.65rem;
    height: 2.65rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.library-drawer-close:hover {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.08);
}

.library-drawer-content {
    padding: 4rem 2rem 2rem;
}

.library-drawer-header {
    display: grid;
    grid-template-columns: 132px 1fr;
    gap: 1.2rem;
    align-items: center;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.drawer-cover {
    min-height: 188px;
    padding: 0.95rem 0.85rem 0.8rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.drawer-cover-title {
    max-width: 10ch;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.14;
}

.drawer-category {
    color: var(--book-accent, var(--library-blue));
}

.library-drawer-title {
    margin: 0.45rem 0 0.45rem;
    color: var(--text-primary);
    font-size: 1.8rem;
    line-height: 1.12;
}

.drawer-author {
    color: var(--library-muted);
    margin-bottom: 1rem;
}

.drawer-rating-system {
    max-width: 220px;
}

.library-drawer-body {
    padding-top: 1.5rem;
}

.drawer-review {
    color: rgba(255, 255, 255, 0.76);
    line-height: 1.68;
    margin-bottom: 1.5rem;
}

.drawer-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
}

.drawer-details div {
    padding: 0.9rem;
    background: rgba(255, 255, 255, 0.025);
}

.drawer-details dt {
    color: var(--library-faint);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.drawer-details dd {
    margin-top: 0.35rem;
    color: rgba(255, 255, 255, 0.78);
}

.drawer-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.drawer-tags .book-tag {
    color: rgba(255, 255, 255, 0.68);
    padding: 0.28rem 0.62rem;
}

body.drawer-open {
    overflow: hidden;
}

@media (max-width: 1020px) {
    .library-shell {
        padding-inline: 2rem;
    }

    .library-hero {
        grid-template-columns: 1fr;
        gap: 2.2rem;
    }

    .featured-read {
        max-width: 700px;
    }

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

    .filter-section {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .sort-and-count {
        grid-column: 2;
        grid-row: 1;
    }
}

@media (max-width: 768px) {
    .library-shell {
        padding: calc(var(--header-height) + 2.6rem) 1.15rem 3.5rem;
    }

    .library-hero {
        min-height: 0;
        padding: 1.2rem 0 2.6rem;
    }

    .library-title {
        font-size: 3.4rem;
    }

    .library-lede {
        font-size: 1.02rem;
        line-height: 1.62;
    }

    .library-editorial-note {
        font-size: 0.95rem;
    }

    .featured-read {
        grid-template-columns: 104px 1fr;
        gap: 1rem;
        padding: 1rem;
    }

    .featured-cover {
        width: 104px;
        min-height: 150px;
        padding: 0.8rem;
    }

    .cover-title {
        font-size: 0.72rem;
    }

    .featured-title {
        font-size: 1.05rem;
    }

    .featured-note {
        font-size: 0.88rem;
    }

    .library-stats {
        grid-template-columns: 1fr 1fr;
        margin: 2rem 0;
    }

    .library-stat {
        min-height: 7rem;
    }

    .controls-grid {
        display: flex;
        flex-direction: column;
        gap: 1.1rem;
        padding: 1rem;
    }

    .tag-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        margin-inline: -0.15rem;
        padding: 0.1rem 0.15rem 0.55rem;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }

    .filter-chip {
        min-height: 2.55rem;
        font-size: 0.78rem;
    }

    .shelf-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .shelf-item.book-card {
        min-height: 0;
        grid-template-columns: 86px 1fr;
        padding: 0.9rem;
    }

    .book-cover {
        min-height: 132px;
    }

    .book-title {
        font-size: 1.08rem;
    }

    .book-note {
        font-size: 0.86rem;
    }

    .library-home-return {
        flex-direction: column;
        align-items: flex-start;
    }

    .library-book-drawer {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 88vh;
        border-left: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
        border-radius: 12px 12px 0 0;
        transform: translateY(105%);
    }

    .library-book-drawer.active {
        transform: translateY(0);
    }

    .library-drawer-content {
        padding: 3.8rem 1rem 1.5rem;
    }

    .library-drawer-header {
        grid-template-columns: 1fr;
    }

    .drawer-cover {
        display: none;
    }

    .library-drawer-title {
        font-size: 1.35rem;
    }

    .drawer-details {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .library-title {
        font-size: 3.05rem;
    }

    .library-stats {
        grid-template-columns: 1fr;
    }

    .controls-intro h2,
    .results-heading h2 {
        font-size: 1.35rem;
    }

    .shelf-item.book-card {
        grid-template-columns: 74px 1fr;
        gap: 0.82rem;
    }

    .book-cover {
        min-height: 118px;
        padding: 0.65rem;
    }

    .book-cover-title {
        display: none;
    }

    .favorite-marker {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .library-shell::before,
    .shelf-item.book-card,
    .shelf-item.book-card::after,
    .filter-chip,
    .library-book-drawer,
    .library-drawer-overlay {
        animation: none !important;
        transition: none !important;
    }

    .shelf-item.book-card:hover,
    .filter-chip:hover {
        transform: none;
    }

    .shelf-item.book-card {
        opacity: 1;
        translate: 0 0;
    }
}
