html {
    scroll-behavior: smooth;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

::selection {
    background-color: rgba(255, 174, 115, 0.28);
    color: #ffffff;
}

::-moz-selection {
    background-color: rgba(255, 174, 115, 0.28);
    color: #ffffff;
}

body.library-page {
    background-color: #0d1117;
    background-image: radial-gradient(ellipse 70% 500px at 50% 0%, rgb(255 255 255 / 12%), #c4c4c405);
    background-repeat: no-repeat;
    color: #d5dbd2;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 18px;
    line-height: 1.8;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-lang-switch {
    position: absolute;
    top: 24px;
    right: 32px;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: rgb(51 60 71 / 70%); 
    border: 1px solid rgba(212, 176, 150, 0.25);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgb(0 0 0 / 69%);
}

.lang-btn {
    color: #8b949e;
    text-decoration: none;
    transition: color 0.15s ease;
}

.lang-btn:hover {
    color: #f0f6fc;
}

.lang-btn.active {
    color: #f0f6fc;
    cursor: default;
}

.lang-divider {
    color: #30363d;
    user-select: none;
}

.library-header {
    text-align: center;
    padding: 90px 20px 40px;
    max-width: 900px;
    margin: 0 auto;
}

.library-brand {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.25em;
    color: #8b6a52;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.library-title {
    font-size: 3.2rem;
    letter-spacing: 0.04em;
    color: #ffffff;
    text-transform: uppercase;
    margin-bottom: 18px;
}

.library-subtitle {
    font-size: 18px;
    color: #8e98a3;
    max-width: 650px;
    margin: 0 auto;
    line-height: 1.6;
}

.catalog-container {
    max-width: 1100px;
    margin: 20px auto 80px;
    padding: 0 30px;
    width: 100%;
    flex: 1;
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 40px;
}

.book-card {
    background: rgba(22, 27, 34, 0.4);
    border: 1px solid rgba(212, 176, 150, 0.2);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.book-card:hover {
    transform: translateY(-6px);
    border-color: #d4b096;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.7), 0 0 20px rgba(255, 174, 115, 0.15);
}

.book-cover-wrap {
    width: 100%;
    aspect-ratio: 3 / 4.2;
    background: #090d13;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(212, 176, 150, 0.15);
}

.book-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.book-card:hover .book-cover-img {
    transform: scale(1.03);
}

.book-cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    background: linear-gradient(135deg, rgba(22, 27, 34, 0.8) 0%, rgba(13, 17, 23, 0.95) 100%);
    border: 2px dashed rgba(212, 176, 150, 0.25);
}

.placeholder-badge {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: #ffae73;
    text-transform: uppercase;
    background: rgba(255, 174, 115, 0.08);
    border: 1px solid rgba(255, 174, 115, 0.3);
    padding: 6px 12px;
    border-radius: 20px;
    margin-bottom: 14px;
}

.placeholder-title {
    font-size: 1.3rem;
    color: #f0f6fc;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.book-info {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.book-series-tag {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #8b6a52;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.book-name {
    font-size: 1.3rem;
    color: #f0f6fc;
    margin-bottom: 8px;
    line-height: 1.3;
}

.book-desc {
    font-size: 14px;
    color: #8e98a3;
    line-height: 1.5;
}

.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #0d1117;
    border: 1px solid rgba(212, 176, 150, 0.3);
    border-radius: 16px;
    width: 100%;
    max-width: 860px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9), 0 0 30px rgba(255, 174, 115, 0.1);
    display: grid;
    grid-template-columns: 290px 1fr;
    position: relative;
    transform: scale(0.96);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-close-btn {
    position: absolute;
    top: 16px; right: 18px;
    background: none;
    border: none;
    color: #8b949e;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    z-index: 10;
    transition: color 0.15s ease;
}

.modal-close-btn:hover {
    color: #ffae73;
}

.modal-cover {
    background: #090d13;
    border-right: 1px solid rgba(212, 176, 150, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.modal-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-content {
    padding: 36px 32px;
    display: flex;
    flex-direction: column;
}

.modal-series {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: #8b6a52;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.modal-title {
    font-size: 2rem;
    color: #f0f6fc;
    margin-bottom: 12px;
    line-height: 1.2;
}

.modal-desc {
    font-size: 15px;
    color: #8e98a3;
    line-height: 1.6;
    margin-bottom: 24px;
}

.read-main-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #ffae73;
    color: #0d1117;
    padding: 13px 26px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: all 0.2s ease;
    box-shadow: 0 4px 20px rgba(255, 174, 115, 0.35);
    margin-bottom: 28px;
}

.read-main-btn:hover {
    background: #ffffff;
    color: #0d1117;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 174, 115, 0.5);
}

.modal-parts-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #8b6a52;
    text-transform: uppercase;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(212, 176, 150, 0.15);
}

.modal-parts-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.part-item-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(22, 27, 34, 0.6);
    border: 1px solid rgba(212, 176, 150, 0.18);
    border-radius: 8px;
    text-decoration: none;
    color: #f0f6fc;
    transition: all 0.2s ease;
}

.part-item-link:hover {
    background: rgba(255, 174, 115, 0.08);
    border-color: #ffae73;
    transform: translateX(4px);
}

.part-item-link.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    border-style: dashed;
    pointer-events: none;
}

.part-item-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.part-logo-icon {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    object-fit: contain;
}

.part-item-name {
    font-size: 14px;
    font-weight: 600;
}

.part-item-sub {
    font-size: 11px;
    color: #8e98a3;
}

.part-item-arrow {
    color: #ffae73;
    font-size: 15px;
    transition: transform 0.2s ease;
}

.part-item-link:hover .part-item-arrow {
    transform: translateX(3px);
}

.site-footer {
    max-width: 1100px;
    width: calc(100% - 60px);
    margin: 40px auto 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    background-color: rgba(22, 27, 34, 0.6);
    border: 1px solid rgba(212, 176, 150, 0.2);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.footer-tg {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #f0f6fc;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: color 0.2s ease, transform 0.2s ease;
}

.footer-tg svg {
    color: #24A1DE;
    transition: transform 0.2s ease;
}

.footer-tg:hover {
    color: #ffae73;
}

.footer-tg:hover svg {
    transform: scale(1.1);
}

.back-to-top {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #8b949e;
    text-decoration: none;
    font-size: 15px;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.back-to-top:hover {
    color: #f0f6fc;
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.back-to-top .arrow {
    transition: transform 0.2s ease;
}

.back-to-top:hover .arrow {
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    .modal-card {
        grid-template-columns: 1fr;
    }
    .modal-cover {
        display: none;
    }
    .library-title {
        font-size: 2.2rem;
    }
    .site-footer {
        width: calc(100% - 40px);
        padding: 16px 20px;
    }
}