body:not(.home-page):not(.icloud-profile-page) {
    --paper: #171d35;
    --wash: #1c2340;
    --panel: #222740;
    --panel-light: #2c304e;
    --muted: #bebcd1;
    --line: #414361;
    color: #f5f4fa;
    background: linear-gradient(125deg, #302342 0%, #232541 38%, #14223b 75%, #171d35 100%);
    background-attachment: fixed;
}

body:not(.home-page):not(.icloud-profile-page) .site-header {
    background: rgba(25, 28, 51, .94);
}

body:not(.home-page):not(.icloud-profile-page) .site-footer {
    background: rgba(20, 27, 47, .7);
}

.account-auth-page .signup-topbar,
.account-auth-page .signup-stage {
    background: transparent;
}

.account-auth-page .signup-card.auth-card {
    background: rgba(28, 31, 55, .92);
    border-color: #454360;
    box-shadow: 0 24px 64px rgba(12, 12, 31, .2);
}

.account-auth-page .auth-card input {
    background: #171e35;
    border-color: #62617f;
}

.account-auth-page .signup-email > summary {
    border-color: #62617f;
}

.account-auth-page .signup-email > summary:hover {
    background: #2b2e4d;
}

.site-nav {
    position: static;
}

.catalog-dropdown {
    position: static;
}

.catalog-dropdown[open]::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 12px;
}

.catalog-dropdown > summary {
    background: transparent;
    border-color: transparent;
    border-radius: 8px;
}

.catalog-dropdown > summary:hover,
.catalog-dropdown[open] > summary {
    color: #fff;
    background: rgba(255, 255, 255, .07);
}

.catalog-panel.catalog-mega {
    top: calc(100% + 10px);
    right: 0;
    left: 0;
    z-index: 32;
    width: min(1000px, calc(100vw - 48px));
    margin-inline: auto;
    max-height: 560px;
    max-height: min(70svh, 560px);
    display: block;
    padding: 28px;
    overflow-y: auto;
    overscroll-behavior: contain;
    color: #f5f4fa;
    background: rgba(29, 31, 57, .76);
    border: 1px solid rgba(218, 213, 255, .16);
    border-radius: 18px;
    backdrop-filter: blur(22px) saturate(135%);
    -webkit-backdrop-filter: blur(22px) saturate(135%);
    box-shadow: 0 16px 40px rgba(8, 10, 24, .22);
    animation: catalog-reveal .16s ease-out;
}

.catalog-dropdown:not([open]) > .catalog-mega {
    display: none;
}

.catalog-mega-inner {
    display: grid;
    grid-template-columns: 145px minmax(0, 1fr);
    gap: 28px;
}

.catalog-mega h2 {
    margin: 0 0 10px;
    color: #b3b2c5;
    font-size: .7rem;
    font-weight: 500;
    line-height: 1.4;
}

.catalog-mega a {
    width: fit-content;
    max-width: 100%;
    padding: 6px 0;
    color: #f5f4fa;
    border-radius: 0;
    font-weight: 500;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.catalog-mega a:hover {
    color: #fff;
    background: transparent;
    text-decoration: underline;
    text-underline-offset: 5px;
}

.catalog-browse a {
    font-size: .9rem;
    letter-spacing: -.015em;
}

.catalog-genre-links {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px 20px;
    align-items: start;
}

.catalog-genre-links a {
    font-size: .88rem;
    font-weight: 450;
}

.catalog-genre-links p {
    margin: 0;
    color: #b3b2c5;
    font-size: .88rem;
}

.catalog-mega .catalog-view-all {
    margin-top: 12px;
    color: #c9c6e4;
    font-size: .75rem;
}

.library-section h2[id],
#chapters-title,
#illustrations-title,
#genre-filter {
    scroll-margin-top: 120px;
}

.book-row {
    --card-width: clamp(148px, 15vw, 182px);
    --card-gap: 22px;
    min-width: 0;
}

.book-row-track {
    display: flex;
    align-items: start;
    gap: var(--card-gap);
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 2px 18px;
    scrollbar-width: thin;
    scrollbar-color: #605a87 transparent;
    overscroll-behavior-x: contain;
}

.book-row.is-enhanced .book-row-track {
    scrollbar-width: none;
}

.book-row.is-enhanced .book-row-track::-webkit-scrollbar {
    display: none;
}

.shelf-book {
    flex: 0 0 var(--card-width);
    width: var(--card-width);
    min-width: 0;
    display: flex;
    flex-direction: column;
    color: #f5f4fa;
    border: 0;
    background: transparent;
}

.shelf-book .book-cover {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 5;
    border: 0;
    border-radius: 7px;
    background: rgba(255, 255, 255, .035);
    box-shadow: none;
    transition: transform .2s ease;
}

.shelf-book .book-cover img,
.catalog-grid .book-cover img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.shelf-book:hover .book-cover {
    transform: translateY(-3px);
}

.shelf-book-title,
.shelf-book-author {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}

.shelf-book-title {
    margin-top: 12px;
    font-size: .87rem;
    font-weight: 550;
    letter-spacing: -.015em;
}

.shelf-book-author {
    margin-top: 3px;
    color: #b8b4cd;
    font-size: .77rem;
    font-weight: 400;
}

.shelf-book .cover-title {
    font-size: 1.04rem;
}

.shelf-book .cover-author {
    font-size: .52rem;
}

.catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 32px 22px;
}

.catalog-grid .book-cover {
    aspect-ratio: 4 / 5;
    margin-bottom: 12px;
    background: rgba(255, 255, 255, .025);
    border: 0;
    box-shadow: none;
}

.catalog-grid .book-card-title,
.catalog-grid .book-card-author {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-pagination {
    display: grid;
    justify-items: center;
    gap: 14px;
    margin-top: 36px;
    color: #eeedf7;
}

.pagination-summary {
    color: #bebbd2;
    font-size: .75rem;
}

.pagination-controls,
.pagination-numbers {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.pagination-controls {
    gap: 14px;
}

.page-number,
.page-direction,
.page-ellipsis {
    min-width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 550;
    line-height: 1;
}

.page-number,
.page-direction {
    padding: 0 10px;
    color: #f5f4fa;
    border: 1px solid #595772;
    background: rgba(255, 255, 255, .025);
}

.page-direction {
    padding: 0 15px;
}

.page-number:hover,
.page-direction:hover:not(.is-disabled) {
    color: #fff;
    border-color: #b9b4d1;
    background: rgba(255, 255, 255, .08);
}

.page-number.is-current {
    color: #111;
    background: #fff;
    border-color: #fff;
}

.page-ellipsis {
    min-width: 24px;
    color: #bebbd2;
}

.page-direction.is-disabled {
    color: #85839c;
    border-color: #393b55;
}

@keyframes catalog-reveal {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 720px) {
    .site-nav {
        position: relative;
    }

    .catalog-dropdown {
        position: static;
    }

    .catalog-dropdown[open]::after {
        display: none;
    }

    .catalog-mega-inner {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .catalog-panel.catalog-mega {
        width: 100%;
        max-height: min(70svh, calc(100svh - var(--site-header-height, 180px) - 24px));
        padding: 18px;
    }

    .catalog-browse {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 20px;
    }

    .catalog-browse h2 {
        grid-column: 1 / -1;
        margin-bottom: 8px;
    }

    .catalog-browse a {
        font-size: .88rem;
    }

    .catalog-genre-links {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 3px 20px;
    }

    .catalog-genre-links a {
        font-size: .8rem;
    }

    .book-row {
        --card-width: 150px;
        --card-gap: 16px;
    }

    .catalog-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 28px 16px;
    }

    .pagination-controls {
        gap: 6px;
        flex-wrap: wrap;
    }

    .page-direction-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
    }

    .page-direction {
        width: 34px;
        min-width: 34px;
        padding: 0;
    }

    .page-number,
    .page-ellipsis {
        min-width: 30px;
        padding: 0 7px;
        font-size: .77rem;
    }

    .pagination-numbers {
        gap: 4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .catalog-panel.catalog-mega {
        animation: none;
    }

    .shelf-book .book-cover {
        transition: none;
    }
}
