.ulitarnica-biblioteca {
    --ub-gold: #b8892d;
    --ub-paper: #f6f4ef;
    --ub-line: #ddd6ca;
    margin: 2rem 0;
}

.ub-nav {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 2rem;
}

.ub-nav a {
    padding: .65rem 1rem;
    border: 1px solid var(--ub-line);
    border-radius: 8px;
    color: var(--ub-gold);
    text-decoration: none;
}

.ub-nav a:hover {
    background: var(--ub-gold);
    color: #fff;
}

.ub-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem;
}

.ub-summary a,
.ub-summary div {
    display: flex;
    min-height: 120px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--ub-line);
    border-radius: 12px;
    background: var(--ub-paper);
    color: inherit;
    text-decoration: none;
}

.ub-summary strong {
    color: var(--ub-gold);
    font-size: 2rem;
}

.ub-index {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .75rem;
}

.ub-index a {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--ub-line);
    color: inherit;
    text-decoration: none;
}

.ub-index small {
    color: var(--ub-gold);
}

.ub-author-search {
    max-width: 680px;
    margin: 0 auto 22px;
}

.ub-author-search label {
    display: block;
    margin-bottom: 7px;
    color: #5e4b3a;
    font-weight: 700;
}

.ub-author-search > div {
    display: flex;
    gap: 8px;
}

.ub-author-search input {
    min-width: 0;
    flex: 1;
    padding: 11px 13px;
    border: 1px solid #c9b79e;
    border-radius: 5px;
    background: #fffdf9;
}

.ub-author-search button {
    padding: 10px 18px;
    border: 1px solid #8f6b45;
    border-radius: 5px;
    background: #8f6b45;
    color: #fff;
    cursor: pointer;
}

.ub-author-letters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 7px;
    margin: 0 0 28px;
}

.ub-author-letters a {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid #d8c9b5;
    border-radius: 50%;
    background: #fbf7ef;
    color: #5a3f2b;
    font-weight: 700;
    text-decoration: none;
}

.ub-author-letters a:hover,
.ub-author-letters a:focus {
    border-color: #b6812f;
    background: #f3e4c5;
}

.ub-author-group {
    margin: 0 0 30px;
    scroll-margin-top: 40px;
}

.ub-author-group h2 {
    margin: 0 0 12px;
    padding-bottom: 7px;
    border-bottom: 1px solid #d8c9b5;
    color: #6f4930;
    font-family: Georgia, serif;
}

.ub-books {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.ub-book {
    position: relative;
    padding: 1.1rem;
    border: 1px solid var(--ub-line);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .04);
    cursor: pointer;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.ub-read-stamp {
    position: absolute;
    bottom: .55rem;
    right: .65rem;
    z-index: 2;
    padding: .18rem .42rem;
    border: 2px solid rgba(132, 52, 38, .68);
    border-radius: 3px;
    color: rgba(132, 52, 38, .78);
    font-family: Georgia, serif;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .12em;
    line-height: 1;
    text-transform: uppercase;
    transform: rotate(-5deg);
}

.ub-book:hover,
.ub-book:focus {
    border-color: #c9aa6c;
    box-shadow: 0 7px 18px rgba(91, 62, 30, .13);
    outline: none;
    transform: translateY(-2px);
}

.ub-book.has-cover {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 1rem;
}

.ub-book-cover {
    display: block;
    width: 78px;
    height: 118px;
    object-fit: cover;
    border-radius: 3px;
    box-shadow: 0 3px 9px rgba(55, 37, 19, .18);
}

.ub-book h4 {
    margin: 0 0 .6rem !important;
    padding: 0 !important;
    background: none !important;
    font-size: 1.05rem;
}

.ub-book h4 span {
    color: inherit;
}

.ub-review-source[hidden],
.ub-chatgpt-source[hidden],
.ub-modal[hidden] {
    display: none !important;
}

body.ub-modal-open {
    overflow: hidden;
}

.ub-modal {
    position: fixed;
    z-index: 100000;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(38, 30, 23, .62);
}

.ub-modal-panel {
    position: relative;
    width: min(860px, 100%);
    max-height: min(84vh, 860px);
    padding: 34px 38px 30px;
    border: 1px solid #d9c9ae;
    border-radius: 14px;
    background: #fffdf9;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
    overflow-y: auto;
}

.ub-modal-header {
    position: sticky;
    z-index: 2;
    top: -34px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin: -34px -38px 14px;
    padding: 28px 28px 14px 38px;
    border-bottom: 1px solid #eee4d5;
    background: #fffdf9;
}

.ub-modal-close {
    flex: 0 0 auto;
    padding: 0 5px;
    border: 0;
    background: transparent;
    color: #8a6545;
    font: 400 30px/1 Georgia, serif;
    cursor: pointer;
}

.ub-modal-title {
    color: #2d2925;
    font-family: Georgia, serif;
    font-size: 1.55rem;
    font-weight: 600;
    line-height: 1.25;
}

.ub-modal-author {
    margin: 0 0 .4rem;
    color: #555;
}

.ub-modal-rating {
    margin: .3rem 0;
    color: var(--ub-gold);
    letter-spacing: .08em;
}

.ub-modal-date {
    margin: .3rem 0 1.25rem;
    color: #777;
    font-size: .92rem;
}

.ub-modal-review {
    line-height: 1.7;
}

.ub-modal-chatgpt[hidden] {
    display: none !important;
}

.ub-modal-chatgpt-text {
    line-height: 1.7;
}

.ub-modal-chatgpt-title {
    margin: 1.25rem 0 1rem !important;
    padding: .65rem .9rem !important;
    border-left: 3px solid #9b6a52;
    border-radius: 5px;
    background: #f5ece7 !important;
    color: #7f4f3d !important;
    font-size: 1rem;
    letter-spacing: .03em;
}

.ub-modal-review-title {
    margin: 1.25rem 0 1rem !important;
    padding: .65rem .9rem !important;
    border-left: 3px solid var(--ub-gold);
    border-radius: 5px;
    background: #f6f1e7 !important;
    color: #9a6d1f !important;
    font-size: 1rem;
    letter-spacing: .03em;
}

.ub-no-review {
    color: #777;
    font-style: italic;
}

.ub-modal-actions {
    margin: 1.5rem 0 0;
}

.ub-modal-actions a {
    display: inline-block;
    padding: .65rem 1rem;
    border: 1px solid var(--ub-gold);
    border-radius: 8px;
    color: var(--ub-gold);
    text-decoration: none;
}

.ub-modal-actions a:hover {
    background: var(--ub-gold);
    color: #fff;
}

.ub-author,
.ub-rating,
.ub-date {
    margin: .35rem 0;
}

.ub-rating {
    color: var(--ub-gold);
    letter-spacing: .08em;
}

.ub-date {
    color: #777;
    font-size: .9rem;
}

.ub-journey-title {
    margin: 0 0 1.5rem;
    text-align: center;
}

.ub-shelf-description {
    max-width: 720px;
    margin: -0.65rem auto 1.8rem;
    color: #67594d;
    font-family: Georgia, serif;
    font-size: 1rem;
    line-height: 1.7;
    text-align: center;
}

.ub-shelf-description p:last-child {
    margin-bottom: 0;
}

.ub-world-group {
    margin: 0 0 2.25rem;
}

.ub-labeled-shelf {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.ub-world-label {
    display: table;
    margin: -26px auto 0 !important;
    padding: .48rem 1.15rem !important;
    position: relative;
    z-index: 2;
    border: 1px solid #765037;
    border-radius: 4px;
    background: #f6efe2 !important;
    box-shadow: 0 3px 7px rgba(53, 34, 20, .12);
    color: #3b2a1e !important;
    font-family: Georgia, serif;
    font-size: 1.18rem;
    font-weight: 600;
    letter-spacing: .025em;
    text-align: center;
}

.ub-world-group .ub-bookshelf {
    padding-top: 0;
}

.ub-back {
    margin: 0 0 1rem;
}

.ub-back a,
.ub-unclassified a {
    color: var(--ub-gold);
    text-decoration: none;
}

.ub-bookshelf {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    padding: 6px 0 18px;
}

.ub-shelf-row {
    display: flex;
    width: 100%;
    min-height: 235px;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 5px;
    padding: 28px 24px 0;
    border: 0;
    border-right: 7px solid #765037;
    border-bottom: 21px solid #765037;
    border-left: 7px solid #765037;
    border-radius: 0 0 3px 3px;
    background:
        radial-gradient(ellipse at 50% 35%, #fff 0, #fbf8f1 62%, #f1e8da 100%);
    box-shadow:
        inset 9px 0 11px rgba(75, 43, 21, .07),
        inset -9px 0 11px rgba(75, 43, 21, .07),
        0 8px 11px rgba(53, 34, 20, .15);
    box-sizing: border-box;
    overflow-x: auto;
}

.ub-spine {
    position: relative;
    display: flex;
    width: 54px;
    height: 205px;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 12px 7px 9px;
    border: 1px solid rgba(49, 31, 18, .5);
    border-radius: 5px 8px 3px 3px;
    background: linear-gradient(90deg, #9b6d1f, #c89634 18%, #b47f27 76%, #815617);
    box-shadow: inset 4px 0 6px rgba(255,255,255,.1), inset -5px 0 7px rgba(0,0,0,.18), 2px 2px 4px rgba(49,30,17,.28);
    color: #2d2925 !important;
    text-decoration: none;
    transition: transform .18s ease, filter .18s ease;
    transform-origin: bottom center;
    overflow: hidden;
}

.ub-spine::before {
    position: absolute;
    inset: 8px 0 auto;
    height: 5px;
    border-top: 1px solid rgba(255,235,174,.42);
    border-bottom: 1px solid rgba(45,25,12,.32);
    box-shadow: 0 174px 0 -1px rgba(255,235,174,.3), 0 177px 0 -1px rgba(45,25,12,.28);
    content: "";
}

.ub-spine::after {
    position: absolute;
    inset: 0 auto 0 7px;
    width: 3px;
    background: linear-gradient(rgba(255,255,255,.05), rgba(255,255,255,.19), rgba(255,255,255,.03));
    content: "";
}

.ub-spine span {
    position: relative;
    z-index: 1;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-family: Georgia, serif;
    line-height: 1.05;
    letter-spacing: .02em;
}

.ub-spine small {
    position: relative;
    z-index: 1;
    min-width: 22px;
    padding: 2px 4px;
    border: 1px solid rgba(255,232,161,.25);
    border-radius: 999px;
    background: rgba(53,31,15,.18);
    color: #2d2925 !important;
    font-size: .72rem;
    line-height: 1.2;
    text-align: center;
}

.ub-spine:hover,
.ub-spine:focus {
    color: #111 !important;
    filter: brightness(1.08);
    transform: translateY(-6px);
}

.ub-spine-2 { width: 59px; height: 218px; background: linear-gradient(90deg, #5f493b, #89705d 20%, #74604f 78%, #4f3b30); }
.ub-spine-3 { width: 49px; height: 194px; background: linear-gradient(90deg, #783b2c, #a85842 20%, #954936 78%, #653023); transform: rotate(-1deg); }
.ub-spine-4 { width: 61px; height: 224px; background: linear-gradient(90deg, #46574f, #718077 20%, #607067 78%, #3c4a44); }
.ub-spine-5 { width: 52px; height: 201px; background: linear-gradient(90deg, #85601f, #b38635 20%, #a1762b 78%, #704e17); }
.ub-spine-6 { width: 46px; height: 211px; background: linear-gradient(90deg, #5b3e34, #846455 20%, #725446 78%, #4d322a); transform: rotate(1deg); }
.ub-spine-7 { width: 57px; height: 198px; background: linear-gradient(90deg, #665b3a, #91825a 20%, #7c704a 78%, #544a2f); }
.ub-spine-8 { width: 63px; height: 221px; background: linear-gradient(90deg, #6b3b2d, #9b5c47 20%, #874b39 78%, #582f24); }

@media (max-width: 780px) {
    .ub-book.has-cover {
        grid-template-columns: 64px minmax(0, 1fr);
    }

    .ub-book-cover {
        height: 96px;
        width: 64px;
    }
    .ub-summary,
    .ub-index,
    .ub-books {
        grid-template-columns: 1fr;
    }

    .ub-bookshelf {
        align-items: stretch;
        gap: 20px;
    }

    .ub-shelf-row {
        width: 100%;
        min-height: 190px;
        gap: 4px;
        padding: 18px 14px 0;
    }

    .ub-spine {
        width: 45px;
        height: 168px;
        padding: 9px 5px 7px;
        font-size: .86rem;
    }

    .ub-spine::before {
        box-shadow: 0 137px 0 -1px rgba(255,235,174,.3), 0 140px 0 -1px rgba(45,25,12,.28);
    }

    .ub-spine-2 { width: 48px; height: 178px; }
    .ub-spine-3 { width: 41px; height: 160px; }
    .ub-spine-4 { width: 49px; height: 184px; }
    .ub-spine-5 { width: 43px; height: 165px; }
    .ub-spine-6 { width: 39px; height: 173px; }
    .ub-spine-7 { width: 47px; height: 162px; }
    .ub-spine-8 { width: 51px; height: 181px; }

    .ub-modal {
        padding: 12px;
    }

    .ub-modal-panel {
        max-height: 88vh;
        padding: 30px 22px 24px;
    }

    .ub-modal-header {
        top: -30px;
        margin: -30px -22px 14px;
        padding: 24px 14px 12px 22px;
    }

    .ub-modal-title {
        font-size: 1.3rem;
    }
}
