.spine,
.spine::before,
.spine::after,
.plank {
    forced-color-adjust: none;
}

.shelf-page {
    max-width: 980px;
    height: 100vh;
    height: 100dvh;
    margin: 0 auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color-scheme: light;
}

.shelf-page .topbar {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.25rem;
    margin-bottom: 0;
    padding: 1.25rem clamp(1rem, 4vw, 2rem) 1rem;
    border-bottom: 1px solid var(--stroke);
    background: var(--bg-deep);
    font-size: 0.875rem;
}

.shelf-page .topbar a {
    color: var(--accent);
    text-decoration: none;
}

.shelf-page .topbar a:hover {
    text-decoration: underline;
}

.shelf-main {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    margin: 0;
    padding: 1.25rem clamp(1rem, 4vw, 2rem) 2.5rem;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.shelf-main::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.library {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.shelf-row {
    position: relative;
}

.books {
    min-height: 280px;
    padding: 0 1.25rem 0 0.35rem;
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 0.55rem;
}

.spine {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 210px;
    text-decoration: none;
    border-radius: 2px 4px 3px 2px;
    box-shadow:
        inset 3px 0 0 rgba(255, 248, 236, 0.22),
        inset -7px 0 10px rgba(0, 0, 0, 0.2),
        3px 8px 14px rgba(15, 23, 42, 0.16);
    transform-origin: bottom center;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.spine::before,
.spine::after {
    content: "";
    position: absolute;
    left: 5px;
    right: 5px;
    height: 3px;
    border-radius: 1px;
}

.spine::before {
    top: 10px;
    background: rgba(255, 236, 204, 0.72);
}

.spine::after {
    bottom: 10px;
    background: rgba(0, 0, 0, 0.28);
}

.spine:hover {
    transform: translateY(-12px);
    box-shadow:
        inset 3px 0 0 rgba(255, 248, 236, 0.28),
        inset -7px 0 10px rgba(0, 0, 0, 0.2),
        4px 16px 22px rgba(15, 23, 42, 0.2);
}

.spine:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.spine-title {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: "Songti SC", "STSong", "SimSun", "Noto Serif SC", "Source Han Serif SC", serif;
    font-weight: 600;
    letter-spacing: 0.14em;
    line-height: 1.2;
    color: rgba(255, 248, 236, 0.94);
    max-height: calc(100% - 36px);
    overflow: hidden;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}

.plank {
    height: 16px;
    margin-top: -1px;
    border-radius: 2px 2px 8px 8px;
    background:
        linear-gradient(180deg, #f3e2c4 0%, #d7b07a 32%, #b8884e 72%, #8d6434 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.7),
        0 14px 18px rgba(62, 40, 16, 0.14);
}

@media (max-width: 640px) {
    .books {
        gap: 0.45rem;
        padding: 0 0.35rem;
        min-height: 200px;
    }

    .spine-title {
        letter-spacing: 0.08em;
    }
}

@media (prefers-color-scheme: dark) {
    body.shelf-page {
        background: #16130f;
        color: #f4efe6;
        color-scheme: dark;
    }

    .shelf-page .topbar {
        background: #16130f;
        border-bottom: 1px solid #fff;
    }

    .shelf-page .topbar a {
        color: #6ee7b7;
    }

    .spine {
        box-shadow:
            inset 3px 0 0 rgba(255, 248, 236, 0.38),
            inset -7px 0 10px rgba(0, 0, 0, 0.35),
            0 0 0 1px rgba(255, 248, 236, 0.22),
            3px 8px 14px rgba(0, 0, 0, 0.5);
    }

    .plank {
        background:
            linear-gradient(180deg, #c4a574 0%, #8d6434 42%, #5c3e22 100%);
        box-shadow:
            inset 0 1px 0 rgba(255, 236, 204, 0.45),
            0 14px 18px rgba(0, 0, 0, 0.45);
    }
}
