.library-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 20px 0 55px;
    flex-wrap: wrap;
}

.decorate {
    position: relative;
}

.decorate>div {
    position: absolute;
    top: 55px;
    right: 0;
    width: 260px;
    padding: 1rem;
    z-index: 4;
}

.decorate button {
    display: block;
}

.bookshelf {
    position: relative;
    max-width: 1080px;
    padding: 30px 42px 0;
    margin: 0 auto;
    border: 12px solid var(--wood-edge);
    border-image: url("../images/shelf-beam-fb_iwC9.png") 8 stretch;
    background: var(--wood) url("../images/shelf-back-blGoy2k.png") repeat;
    box-shadow: 0 8px 18px var(--shadow-strong);
}

.bookshelf-title {
    position: absolute;
    top: -49px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 25px;
    white-space: nowrap;
    border: 4px solid var(--wood);
    background: var(--wood-edge) url("../images/shelf-label-pQnJS1W.png") center/auto 100%;
    color: var(--spine-ink);
    font-weight: bold;
    font-size: 1.2rem;
}

.bookshelf-flowers {
    position: absolute;
    top: -40px;
    left: 0;
    width: 227px;
    height: 66px;
    object-fit: contain;
    z-index: 1;
}

.bookshelf-row {
    display: flex;
    justify-content: center;
    gap: 5px;
    align-items: flex-end;
    height: 164px;
    padding: 0 14px 22px;
    position: relative;
    margin: 0 -23px;
    background: url("../images/shelf-edge-kIlDdkt.png") bottom left/100% 22px no-repeat;
}

.book-spine {
    display: flex;
    flex-direction: column;
    flex: 1;
    align-items: center;
    justify-content: space-between;
    max-width: 74px;
    min-width: 0;
    height: 137px;
    padding: 8px 4px;
    background: url("../images/spine-cream-AKL5wfL.png") center/100% 100%;
    border: 1px solid var(--wood);
    color: var(--spine-ink);
    border-radius: 2px 4px 0 0;
    box-shadow: 3px 0 3px var(--shadow-strong);
    transition: transform .18s;
    position: relative;
}

.book-spine>span {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: .88rem;
    max-height: 112px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-spine>small {
    font-size: .6rem;
    color: inherit;
    line-height: 1;
}

.book-spine:nth-child(3n) {
    height: 128px;
}

.book-spine:nth-child(4n) {
    height: 142px;
}

.book-spine:hover,.book-spine:focus-visible {
    transform: translateY(-10px);
    z-index: 2;
    color: var(--spine-ink);
    box-shadow: 4px 8px 12px var(--shadow-strong);
}

.book-spine--sage {
    background-image: url("../images/spine-sage-ogWfHeR.png");
    color: var(--spine-light);
}

.book-spine--blue {
    background-image: url("../images/spine-blue-fWVu-Pf.png");
    color: var(--spine-light);
}

.book-spine--plum {
    background-image: url("../images/spine-plum-dhi8B6t.png");
    color: var(--spine-light);
}

.book-spine--red {
    background-image: url("../images/spine-red-aR1aVbr.png");
    color: var(--spine-light);
}

.book-spine--sage:hover,.book-spine--blue:hover,.book-spine--plum:hover,.book-spine--red:hover {
    color: var(--spine-light);
}

.bookshelf-cat {
    position: absolute;
    right: -20px;
    bottom: 20px;
    width: 48px;
    height: 55px;
    object-fit: contain;
}

.bookshelf[data-decoration=none] .bookshelf-flowers {
    visibility: hidden;
}

.shelf-pagination {
    max-width: 1000px;
    margin: 16px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 25px;
    text-align: center;
    padding: 15px 25px;
}

.shelf-pagination p {
    margin-top: .3rem;
}

.shelf-pagination form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.shelf-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    font-size: .8rem;
    color: var(--muted);
    margin-top: 16px;
}

@media(max-width:1250px) {
    .bookshelf {
        padding: 26px 22px 0;
    }
    .bookshelf-flowers {
        width: 170px;
    }
    .bookshelf-row {
        margin: 0 -16px;
        padding-left: 6px;
        padding-right: 6px;
    }
    .book-spine {
        max-width: 60px;
    }
    .shelf-pagination {
        flex-wrap: wrap;
    }
}

@media(max-width:760px) {
    .library-controls {
        gap: 16px;
        margin-bottom: 55px;
    }
    .bookshelf {
        padding: 20px 14px 0;
        border-width: 8px;
    }
    .bookshelf-title {
        font-size: .88rem;
        padding: 6px 12px;
        top: -38px;
    }
    .bookshelf-flowers {
        width: 105px;
        top: -39px;
        left: -13px;
    }
    .bookshelf-row {
        gap: 2px;
        height: 156px;
        padding: 0 2px 18px;
        margin: 0 -10px;
        background-size: 100% 18px;
    }
    .book-spine {
        padding: 6px 1px;
        min-width: 0;
        height: 130px;
    }
    .book-spine>span {
        font-size: .62rem;
    }
    .book-spine:nth-child(4n) {
        height: 134px;
    }
    .bookshelf-cat {
        width: 28px;
        right: -12px;
        bottom: 12px;
    }
    .shelf-pagination {
        padding: 15px 8px;
        gap: 10px;
    }
    .shelf-pagination form {
        width: 100%;
    }
    .shelf-legend {
        gap: 8px 15px;
    }
}

@media(min-width:1251px) {
    .library-page {
        display:grid;
        grid-template-columns:minmax(0,1fr) 375px;
        column-gap:20px;
    }
    .library-page>* {
        grid-column:1/-1;
    }
    .library-controls {
        margin-bottom:55px;
    }
    .library-page>.search-form {
        grid-row:2;
        grid-column:2;
        align-self:start;
        margin:20px 0 0;
        gap:8px;
    }
    .library-controls {
        grid-row:2;
        grid-column:1;
        flex-wrap:nowrap;
    }
    .library-controls .actions {
        flex-wrap:nowrap;
        gap:8px;
    }
    .library-controls a,.library-controls summary {
        padding:10px 12px;
        font-size:.9rem;
    }
    .library-page>.search-form {
        display:grid;
        grid-template-columns:minmax(0,1fr) auto;
    }
    .library-page>.search-form input {
        grid-column:1/-1;
    }
    .library-page>.search-form select {
        width:100%;
        font-size:.9rem;
    }
    .library-page>.search-form .button {
        font-size:.9rem;
        padding:10px;
    }
    .bookshelf {
        width:100%;
        margin-top:40px;
    }
}

.shelf-pagination form {
    flex:0 0 auto;
}

.shelf-pagination button {
    white-space:nowrap;
}

@media(max-width:760px) {
    .bookshelf-row {
        display:grid;
        grid-template-columns:repeat(6,minmax(0,1fr));
        row-gap:24px;
        column-gap:4px;
        height:auto;
        padding:0 3px 22px;
        background-repeat:repeat-y;
        background-size:100% 158px;
        background-position:left 136px;
    }
    .book-spine {
        width:100%;
        max-width:none;
        min-height:130px;
    }
    .book-spine>span {
        font-size:.78rem;
    }
}

@media(min-width:1251px) {
    .library-page>.page-heading {
        margin:0;
    }
    .bookshelf {
        margin-top:0;
    }
}
