* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Хедер */
.header {
    background: #2c3e50;
    color: white;
    padding: 1rem 0;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: bold;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

/* На мобильных устройствах меню скрыто по умолчанию */
@media (max-width: 768px) {
    .nav-menu:not(.active) {
        display: none !important;
    }
}

.nav-menu a {
    color: white;
    text-decoration: none;
    transition: color 0.3s;
}

.nav-menu a:hover {
    color: #3498db;
}

/* Подменю */
.nav-menu li {
    position: relative;
}

/* Треугольник для всех меню (через ::after) - обернут в кнопку */
.nav-menu .has-children > a {
    position: relative;
    padding-right: 2.5rem; /* Место для кнопки с треугольником */
}

.nav-menu .has-children > a::after {
    content: ' ▶';
    font-size: 0.75em;
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    transition: all 0.2s ease;
    cursor: pointer;
    pointer-events: auto;
    line-height: 1;
}

/* Треугольник меняется на ▼ при развернутом состоянии в горизонтальном меню (только при active/open, не при hover) */
.nav:not(.menu-vertical) .nav-menu .has-children.active > a::after,
.nav:not(.menu-vertical) .nav-menu .has-children.open > a::after {
    content: ' ▼';
    background: rgba(255, 255, 255, 0.2);
}

/* Треугольник меняется на ▼ при развернутом состоянии в вертикальном меню (только при active/open, не при hover) */
.nav.menu-vertical .nav-menu .has-children.active > a::after,
.nav.menu-vertical .nav-menu .has-children.open > a::after {
    content: ' ▼';
    background: rgba(255, 255, 255, 0.2);
}

/* Hover эффект для кнопки треугольника в вертикальном меню */
.nav.menu-vertical .nav-menu .has-children > a::after:hover {
    background: rgba(255, 255, 255, 0.15);
}

.nav-menu .submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: rgba(44, 62, 80, 0.95);
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    min-width: 200px;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

@media (min-width: 769px) {
    .nav:not(.menu-vertical) .nav-menu .user-profile-link + .submenu {
        left: auto;
        right: 0.5rem;
    }
}

/* Для горизонтального меню подменю открывается только при активном состоянии (не при hover) */
.nav:not(.menu-vertical) .nav-menu .has-children.active .submenu,
.nav:not(.menu-vertical) .nav-menu .has-children.open .submenu {
    display: block;
}

/* Для вертикального меню подменю открывается только при активном состоянии (не при hover) */
.nav.menu-vertical .nav-menu .has-children.active .submenu,
.nav.menu-vertical .nav-menu .has-children.open .submenu {
    display: block;
}

.nav-menu .submenu li {
    width: 100%;
}

.nav-menu .submenu a {
    display: block;
    padding: 0.5rem 1rem;
    color: white;
    transition: background 0.3s;
}

.nav-menu .submenu a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #3498db;
}

/* Вертикальное меню для ПК - как в админке */
@media (min-width: 769px) {
    .nav.menu-vertical {
        position: relative;
    }
    
    .nav.menu-vertical .nav-menu {
        position: absolute;
        top: 100%;
        right: 0;
        background: #2c3e50;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        min-width: 250px;
        max-width: 350px;
        z-index: 1000;
        margin-top: 0.5rem;
        display: none;
        flex-direction: column;
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .nav.menu-vertical .nav-menu.vertical-menu-open {
        display: flex;
    }
    
    .nav.menu-vertical .nav-menu li {
        width: 100%;
    }
    
    .nav.menu-vertical .nav-menu a {
        display: block;
        padding: 0.75rem 1rem;
        padding-right: 2.5rem; /* Место для кнопки с треугольником */
        border-radius: 6px;
        background: rgba(255, 255, 255, 0.1);
        transition: all 0.3s ease;
        position: relative;
    }
    
    .nav.menu-vertical .nav-menu a:hover {
        background: rgba(255, 255, 255, 0.2);
    }
    
    .nav.menu-vertical .hamburger {
        display: flex !important;
        margin-left: auto;
    }
    
    /* Подменю в вертикальном меню */
    .nav.menu-vertical .nav-menu .submenu {
        position: static;
        display: none;
        background: rgba(255, 255, 255, 0.1);
        margin-left: 1rem;
        margin-top: 0.5rem;
        padding: 0.5rem 0;
        border-radius: 4px;
        box-shadow: none;
        min-width: auto;
    }
    
    .nav.menu-vertical .nav-menu .has-children.active .submenu {
        display: block;
    }
    
    /* Треугольник уже настроен выше, здесь не нужно менять */
}

.hamburger {
    /* НЕ устанавливаем display: none здесь, чтобы медиа-запрос мог перекрыть */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    padding: 0.5rem;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

/* Убеждаемся, что гамбургер скрыт на десктопе */
@media (min-width: 769px) {
    .hamburger {
        display: none !important;
    }
}

/* Показываем гамбургер на мобильных ДО основного медиа-запроса */
@media (max-width: 768px) {
    .hamburger {
        display: flex !important;
    }
}

.hamburger svg {
    width: 24px;
    height: 24px;
    display: block;
}

.hamburger svg line {
    stroke: white;
    stroke-width: 2;
    transition: all 0.3s ease;
    transform-origin: center;
}

.hamburger svg .menu-circle {
    stroke: white;
    stroke-width: 2;
    fill: none;
    opacity: 0;
    display: none;
    transition: opacity 0.3s ease;
}

.hamburger:hover {
    opacity: 0.8;
    background: transparent !important;
}

.hamburger:focus,
.hamburger:active {
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Анимация в виде круга при активации */
.hamburger.active svg .menu-line-1,
.hamburger.active svg .menu-line-2,
.hamburger.active svg .menu-line-3 {
    opacity: 0 !important;
    transform: scale(0) !important;
    transition: opacity 0.2s ease, transform 0.2s ease !important;
}

.hamburger.active svg .menu-circle {
    display: block !important;
    opacity: 1 !important;
    stroke-dasharray: 56.55;
    stroke-dashoffset: 0;
    animation: drawCircle 0.3s ease forwards;
}

/* Возврат к исходному состоянию при закрытии */
.hamburger:not(.active) svg .menu-line-1,
.hamburger:not(.active) svg .menu-line-2,
.hamburger:not(.active) svg .menu-line-3 {
    opacity: 1 !important;
    transform: scale(1) !important;
    transition: opacity 0.3s ease, transform 0.3s ease !important;
}

.hamburger:not(.active) svg .menu-circle {
    opacity: 0 !important;
    display: none !important;
}

@keyframes drawCircle {
    from {
        stroke-dashoffset: 56.55;
        opacity: 0;
    }
    to {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

/* Главный экран */
.hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0;
    text-align: center;
}

.hero > .container {
    min-height: 410px;
    display: flex;
    align-items: stretch;
}

.hero .hero-panel {
    position: relative;
    width: 100%;
    flex: 1 1 auto;
    min-height: inherit;
    display: flex;
    align-items: stretch;
}

.hero .hero-panel .hero-content {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    padding: 48px 20px 40px;
    display: grid;
    gap: 1rem;
    align-items: stretch;
    box-sizing: border-box;
}

.hero:not(.hero--content-width) .hero-panel .hero-content {
    padding-top: calc(var(--home-header-offset, 88px) + 16px);
}

.hero .hero-panel .hero-copy {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.hero .hero-panel .hero-copy h2 {
    margin-bottom: 0;
}

.hero .hero-panel .hero-copy p {
    margin-bottom: 0;
}

.hero .hero-panel .hero-actions {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.hero .hero-panel .hero-content.hero-content--button-hidden .hero-actions {
    display: none;
}

.hero .hero-panel .hero-content.hero-content--text-top.hero-content--button-top {
    grid-template-rows: auto auto 1fr;
}

.hero .hero-panel .hero-content.hero-content--text-top.hero-content--button-center {
    grid-template-rows: auto 1fr auto 1fr;
}

.hero .hero-panel .hero-content.hero-content--text-top.hero-content--button-bottom {
    grid-template-rows: auto 1fr auto;
}

.hero .hero-panel .hero-content.hero-content--text-center.hero-content--button-center {
    grid-template-rows: 1fr auto auto 1fr;
}

.hero .hero-panel .hero-content.hero-content--text-center.hero-content--button-bottom {
    grid-template-rows: 1fr auto 1fr auto;
}

.hero .hero-panel .hero-content.hero-content--text-bottom.hero-content--button-bottom {
    grid-template-rows: 1fr auto auto;
}

.hero .hero-panel .hero-content.hero-content--text-top.hero-content--button-hidden {
    grid-template-rows: auto 1fr;
}

.hero .hero-panel .hero-content.hero-content--text-center.hero-content--button-hidden {
    grid-template-rows: 1fr auto 1fr;
}

.hero .hero-panel .hero-content.hero-content--text-bottom.hero-content--button-hidden {
    grid-template-rows: 1fr auto;
}

.hero .hero-panel .hero-content.hero-content--text-top.hero-content--button-top .hero-copy,
.hero .hero-panel .hero-content.hero-content--text-top.hero-content--button-center .hero-copy,
.hero .hero-panel .hero-content.hero-content--text-top.hero-content--button-bottom .hero-copy {
    grid-row: 1;
}

.hero .hero-panel .hero-content.hero-content--text-top.hero-content--button-top .hero-actions {
    grid-row: 2;
}

.hero .hero-panel .hero-content.hero-content--text-top.hero-content--button-center .hero-actions {
    grid-row: 3;
}

.hero .hero-panel .hero-content.hero-content--text-top.hero-content--button-bottom .hero-actions {
    grid-row: 3;
}

.hero .hero-panel .hero-content.hero-content--text-center.hero-content--button-center .hero-copy,
.hero .hero-panel .hero-content.hero-content--text-center.hero-content--button-bottom .hero-copy {
    grid-row: 2;
}

.hero .hero-panel .hero-content.hero-content--text-center.hero-content--button-center .hero-actions {
    grid-row: 3;
}

.hero .hero-panel .hero-content.hero-content--text-center.hero-content--button-bottom .hero-actions {
    grid-row: 4;
}

.hero .hero-panel .hero-content.hero-content--text-bottom.hero-content--button-bottom .hero-copy {
    grid-row: 2;
}

.hero .hero-panel .hero-content.hero-content--text-bottom.hero-content--button-bottom .hero-actions {
    grid-row: 3;
}

.hero .hero-panel .hero-content.hero-content--text-top.hero-content--button-hidden .hero-copy {
    grid-row: 1;
}

.hero .hero-panel .hero-content.hero-content--text-center.hero-content--button-hidden .hero-copy {
    grid-row: 2;
}

.hero .hero-panel .hero-content.hero-content--text-bottom.hero-content--button-hidden .hero-copy {
    grid-row: 2;
}

/* Horizontal positioning — text */
.hero .hero-panel .hero-content.hero-content--text-h-left .hero-copy {
    text-align: left;
}

.hero .hero-panel .hero-content.hero-content--text-h-left .hero-copy h2,
.hero .hero-panel .hero-content.hero-content--text-h-left .hero-copy p {
    text-align: left;
}

.hero .hero-panel .hero-content.hero-content--text-h-left .hero-copy p {
    margin-left: 0;
    margin-right: 0;
}

.hero .hero-panel .hero-content.hero-content--text-h-right .hero-copy {
    text-align: right;
}

.hero .hero-panel .hero-content.hero-content--text-h-right .hero-copy h2,
.hero .hero-panel .hero-content.hero-content--text-h-right .hero-copy p {
    text-align: right;
}

.hero .hero-panel .hero-content.hero-content--text-h-right .hero-copy p {
    margin-left: 0;
    margin-right: 0;
}

/* Horizontal positioning — button */
.hero .hero-panel .hero-content.hero-content--button-h-left .hero-actions {
    justify-content: flex-start;
}

.hero .hero-panel .hero-content.hero-content--button-h-right .hero-actions {
    justify-content: flex-end;
}

.hero.hero--content-width {
    background: transparent;
    padding: calc(var(--home-header-offset, 88px) + 10px) 0 0;
}

.hero.hero--content-width > .container {
    min-height: 0;
}

.hero.hero--content-width .hero-panel {
    width: min(100%, 1160px);
    flex: 0 1 auto;
    margin: 0 auto;
    aspect-ratio: 1160 / 410;
    min-height: 0;
    border-radius: 26px;
    overflow: hidden;
    box-shadow: 0 22px 48px rgba(33, 52, 79, 0.14);
}

.hero.hero--content-width .hero-panel.hero-panel--wallpaper {
    background-image: var(--hero-wallpaper-desktop);
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
    background-color: #2c3e50;
}

.hero-content h2 {
    font-size: 3rem;
    margin-bottom: 1rem;
    /* font-family будет установлен в dynamic_styles.php */
}

.hero-content p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    margin-left: auto;
    margin-right: auto;
    max-width: 760px;
    /* font-family будет установлен в dynamic_styles.php */
}

/* Кнопки */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.message-body a.private-message-link,
.author-message-body a.private-message-link,
.private-message-media-text a.private-message-link,
.author-message-media-text a.private-message-link,
.author-message-media-modal-text a.private-message-link {
    color: inherit;
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.12em;
    overflow-wrap: anywhere;
}

.message-body a.private-message-link:hover,
.author-message-body a.private-message-link:hover,
.private-message-media-text a.private-message-link:hover,
.author-message-media-text a.private-message-link:hover,
.author-message-media-modal-text a.private-message-link:hover {
    opacity: 0.84;
}

body.private-message-external-modal-open {
    overflow: hidden;
}

.private-message-external-backdrop {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.55);
}

.private-message-external-backdrop[hidden] {
    display: none !important;
}

.private-message-external-dialog {
    width: min(100%, 460px);
    background: #fff;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 18px;
    box-shadow: 0 28px 60px rgba(15, 23, 42, 0.24);
    overflow: hidden;
}

.private-message-external-head {
    padding: 18px 20px 0;
}

.private-message-external-head h3 {
    margin: 0;
    color: #0f172a;
    font-size: 1.2rem;
    line-height: 1.25;
}

.private-message-external-body {
    padding: 14px 20px 0;
    color: #475569;
    font-size: 0.98rem;
    line-height: 1.6;
}

.private-message-external-body p {
    margin: 0;
}

.private-message-external-url {
    margin-top: 14px;
    padding: 11px 12px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #dbe3ee;
    color: #0f172a;
    font-size: 0.88rem;
    line-height: 1.45;
    word-break: break-word;
}

.private-message-external-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 18px 20px 20px;
}

.private-message-external-actions .btn {
    min-width: 124px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.private-message-external-cancel {
    background: #e2e8f0;
    color: #334155;
}

.private-message-external-cancel:hover {
    background: #cbd5e1;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

/* Блок книг */
.books-section {
    padding: 30px 0 80px;
}

.books-section h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: #2c3e50;
}

/* Блок фильтров */
.filters-section {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.home-main {
    --home-header-offset: 88px;
}

.home-main.hero-hidden {
    padding-top: var(--home-header-offset);
}

@media (max-width: 768px) {
    .home-main > section + section {
        margin-top: 15px;
    }

    .home-main.hero-hidden > section:first-child {
        margin-top: 10px;
    }

    .home-main .books-section {
        padding-top: 0;
    }

    .home-main .filters-section {
        margin-bottom: 15px;
    }
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-group {
    flex: 1;
    min-width: 150px;
    max-width: 250px;
}

.filter-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.85rem;
}

.filter-icon {
    flex-shrink: 0;
}

.filter-group select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    color: #333;
    cursor: pointer;
    transition: all 0.3s;
}

.filter-group select:hover {
    border-color: #3498db;
}

.filter-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.filter-actions {
    display: flex;
    gap: 1rem;
    flex-shrink: 0;
}

.btn-filter {
    background: #3498db;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-filter:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.btn-reset {
    background: #95a5a6;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-reset:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(149, 165, 166, 0.3);
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
}

.book-card {
    background: white;
    border-radius: 10px;
    overflow: visible;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    gap: 0;
    padding: 0;
    position: relative;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.book-cover-wrapper {
    position: relative;
    width: 189px;
    padding: 5px;
    overflow: visible; /* Чтобы тени 3D эффекта были видны */
}

.book-cover {
    width: 189px;
    height: 270px;
    overflow: visible; /* Изменено с hidden на visible, чтобы тени 3D эффекта были видны */
    perspective: 1000px;
    position: relative;
    cursor: pointer; /* Обложка кликабельна для перехода на страницу книги */
}

.book-likes,
.book-comments,
.book-library {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 6px;
    border-radius: 20px;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    cursor: pointer;
    transition: background-color 0.3s ease, box-shadow 0.3s ease, filter 0.3s ease;
    z-index: 10;
    min-width: fit-content;
    white-space: nowrap;
    height: auto;
    box-sizing: border-box;
}

.book-likes:hover,
.book-comments:hover,
.book-library:hover {
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.like-heart {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8rem;
    height: 1.8rem;
    cursor: pointer;
    flex-shrink: 0;
    overflow: hidden;
}

.like-heart:empty::before {
    content: '♡';
    color: #bbb;
    font-size: 1.2rem;
    line-height: 1;
}

.likes-count,
.comments-count,
.library-count {
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.9rem;
    line-height: 1.2rem;
    min-width: 1.2rem;
    text-align: center;
    display: inline-block;
    vertical-align: middle;
}

.comments-icon,
.library-icon {
    font-size: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8rem;
    height: 1.8rem;
    line-height: 1;
    flex-shrink: 0;
}

/* Меню библиотеки */
.library-menu {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 8px 0;
    min-width: 200px;
    z-index: 1000;
}

.library-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.library-menu-item:hover {
    background: #f5f5f5;
}

.library-menu-remove {
    border-top: 1px solid #eee;
    margin-top: 4px;
    padding-top: 12px;
}

.library-menu-remove:hover {
    background: #fee;
}

.library-menu-icon {
    font-size: 1.2rem;
    width: 1.5rem;
    height: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.library-menu-text {
    font-size: 0.95rem;
    color: #2c3e50;
    font-weight: 500;
}

.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    transform-style: preserve-3d;
    /* box-shadow будет задан через book_cover_3d_styles.php с настройками из админки */
}

.book-card:hover .book-cover img {
    transform: rotateY(-15deg) rotateX(5deg) scale(1.05);
    /* box-shadow будет задан через book_cover_3d_styles.php с настройками из админки */
}

/* Для страницы книги: применяем тот же 3D эффект при наведении на обложку */
/* Аналогично .book-card:hover .book-cover img в карточках */
.book-header .book-cover-wrapper:hover .book-cover img,
.book-header .book-cover-wrapper:hover .book-cover-large {
    transform: rotateY(-15deg) rotateX(5deg) scale(1.05);
    /* box-shadow будет задан через book_cover_3d_styles.php с настройками из админки */
}

.book-cover-large {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    transition: transform 0.3s ease;
    transform-style: preserve-3d;
    box-shadow: 10px 10px 30px rgba(0,0,0,0.2);
}

/* Стили для .book-cover-large:hover теперь задаются в book_cover_3d_styles.php */
/* Удалено, чтобы не конфликтовать с настройками из админки */

/* Стили для страницы книги */
.book-details {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.book-header {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: flex-start;
}

.book-header .book-cover-wrapper {
    position: relative;
    width: 210px;
    padding: 5px;
    overflow: visible;
    flex-shrink: 0;
}

.book-header .book-cover {
    width: 210px;
    height: 300px;
    overflow: visible;
    perspective: 1000px;
    position: relative;
    transform-style: preserve-3d;
}

.book-meta {
    flex: 1;
}

.book-meta h1 {
    font-size: 2rem;
    margin-bottom: 0.3rem;
    color: #2c3e50;
}

.book-price-list {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
    margin-bottom: 0.75rem;
}

.book-price {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0;
}

.book-price-icon {
    display: block;
    width: auto;
    height: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.book-price-text {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    min-width: 0;
}

.book-price-label,
.book-price-value {
    display: inline-flex;
    align-items: center;
    line-height: 1.4;
}

.book-price-link {
    color: inherit;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.book-price-link:hover {
    opacity: 0.88;
}

.book-price-value.is-free {
    color: #2f6db4;
}

.book-meta .genre {
    color: #7f8c8d;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.book-meta .publication-date {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    margin-top: 0.1rem;
}

.book-meta .description {
    margin-bottom: 1rem;
    line-height: 1.6;
}

/* Хештеги книги */
.book-hashtags {
    margin-top: 1rem;
    font-size: 0.85rem;
    line-height: 1.5;
}

.book-hashtags .hashtag {
    display: inline;
    background: none;
    color: #3498db;
    padding: 0;
    border-radius: 0;
    margin-right: 0;
}

/* Блок счетчиков для мобильной версии - скрыт на десктопе */
.book-counters-mobile {
    display: none;
}

.book-info {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-bottom: 6rem; /* Увеличенный отступ снизу для кнопки */
    min-height: 300px; /* Минимальная высота для стабильного отображения */
}

.book-work-info {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0;
}

/* Отступ для формы/объема на странице книги */
.book-meta .book-work-info {
    margin-top: 1.4rem;
}

.book-work-separator {
    color: #7f8c8d;
    font-size: 0.9rem;
}

.book-series-wrapper {
    margin-bottom: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
}

.book-series-label {
}

.book-series-title {
    text-decoration: none;
    transition: opacity 0.3s ease;
}

.book-series-title:hover {
    opacity: 0.7;
    text-decoration: underline;
}

.book-series-separator {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin: 0 0.3rem;
}

.book-series-position {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
}

.book-series-position-label {
}

.book-series-position-number {
}

.book-info h3 {
    margin-bottom: 0.5rem;
}

.book-genre {
    margin-bottom: 1rem;
}

.book-description {
    word-wrap: break-word;
}

.book-description strong,
.book-description b {
    font-weight: bold;
}

.book-description em,
.book-description i {
    font-style: italic;
}

.book-description u {
    text-decoration: underline;
}

.book-description del,
.book-description s,
.book-description strike {
    text-decoration: line-through;
}

.book-description span[style*="font-size"] {
    display: inline;
}

.book-description {
    margin-bottom: 0.5rem;
    line-height: 1.5;
    max-height: none;
    overflow: visible;
}

.show-full-text,
.collapse-text {
    color: #3498db;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s;
    display: inline;
    margin: 0;
    padding: 0;
}

.show-full-text:hover,
.collapse-text:hover {
    color: #2980b9;
}

.book-rating {
    margin-bottom: 1rem;
}

.stars {
    display: inline-block;
    margin-right: 10px;
}

.star {
    color: #ddd;
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.2s;
}

.star:hover,
.star.active {
    color: #f39c12;
}

.book-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    z-index: 10;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 20px;
    top: 15px;
}

.close:hover {
    color: black;
}

/* Блок комментариев */
.comments-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #eee;
}

.add-comment-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid #e0e0e0;
}

.add-comment-section h4 {
    margin-bottom: 1rem;
    color: #2c3e50;
    font-size: 1.3rem;
}

.comment-form {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.comment-form button:disabled,
.comment-form .btn:disabled,
.comment-form .btn-submit:disabled {
    opacity: 0.62;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.comment-input-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.comment-input-header label {
    margin-bottom: 0;
    margin-right: auto;
}

.comment-emoji-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 0.8rem;
    border: 1px solid #d8e3ee;
    border-radius: 999px;
    background: #ffffff;
    color: #34495e;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.comment-emoji-trigger:hover,
.comment-emoji-trigger:focus-visible {
    background: #eef4ff;
    border-color: #92b4f4;
    color: #1f5fa6;
    box-shadow: 0 0 0 3px rgba(83, 160, 253, 0.14);
    outline: none;
}

.comment-emoji-trigger-icon {
    font-size: 1.05rem;
    line-height: 1;
}

.comment-emoji-picker {
    margin-bottom: 0.75rem;
    padding: 0.9rem;
    border: 1px solid #d8e3ee;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 10px 28px rgba(31, 95, 166, 0.08);
}

.comment-emoji-sections {
    display: grid;
    gap: 0.6rem;
}

.comment-emoji-categories {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.comment-emoji-category-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid #d8e3ee;
    border-radius: 12px;
    background: #f7f9fc;
    color: #24384f;
    font-size: 1.22rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.comment-emoji-category-btn:hover,
.comment-emoji-category-btn:focus-visible {
    background: #eef4ff;
    border-color: #92b4f4;
    transform: translateY(-1px);
    outline: none;
}

.comment-emoji-category-btn.is-active {
    background: #e7f0ff;
    border-color: #53a0fd;
    box-shadow: 0 0 0 3px rgba(83, 160, 253, 0.14);
}

.comment-emoji-panel {
    padding: 0.85rem;
    border: 1px solid #d8e3ee;
    border-radius: 12px;
    background: #ffffff;
}

.comment-emoji-panel[hidden] {
    display: none !important;
}

.comment-emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
    gap: 0.45rem;
}

.comment-emoji-item {
    min-height: 42px;
    border: 1px solid #e3eaf3;
    border-radius: 10px;
    background: #ffffff;
    cursor: pointer;
    font-size: 1.35rem;
    line-height: 1;
    transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.comment-emoji-item:hover,
.comment-emoji-item:focus-visible {
    background: #eef4ff;
    border-color: #92b4f4;
    transform: translateY(-1px);
    outline: none;
}

.comment-sticker-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 0.8rem;
    border: 1px solid #d8e3ee;
    border-radius: 999px;
    background: #ffffff;
    color: #34495e;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.comment-sticker-trigger:hover,
.comment-sticker-trigger:focus-visible {
    background: #eef4ff;
    border-color: #92b4f4;
    color: #1f5fa6;
    box-shadow: 0 0 0 3px rgba(83, 160, 253, 0.14);
    outline: none;
}

.comment-sticker-trigger-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    line-height: 1;
    flex-shrink: 0;
}

.comment-sticker-trigger-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

.comment-sticker-picker {
    margin-bottom: 0.75rem;
    padding: 0.9rem;
    border: 1px solid #d8e3ee;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 10px 28px rgba(31, 95, 166, 0.08);
}

.comment-sticker-sections {
    display: grid;
    gap: 0.6rem;
}

.comment-sticker-search-row {
    display: flex;
}

.comment-sticker-search {
    flex: 1 1 auto;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d8e3ee;
    border-radius: 10px;
    background: #f7f9fc;
    color: #24384f;
    font-size: 0.92rem;
}

.comment-sticker-search:focus-visible {
    background: #ffffff;
    border-color: #92b4f4;
    box-shadow: 0 0 0 3px rgba(83, 160, 253, 0.14);
    outline: none;
}

.comment-sticker-categories {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.1rem 0 0.45rem;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.comment-sticker-category-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 144px;
    flex: 0 0 144px;
    padding: 0;
    border: none;
    border-radius: 14px;
    background: transparent;
    color: #24384f;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.15;
    cursor: pointer;
    scroll-snap-align: start;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.comment-sticker-category-btn:hover,
.comment-sticker-category-btn:focus-visible {
    transform: translateY(-1px);
    outline: none;
}

.comment-sticker-category-btn.is-active {
    background: transparent;
}

.comment-sticker-pack-headliner {
    display: block;
    width: 128px;
    height: 128px;
    object-fit: contain;
    filter: drop-shadow(0 8px 16px rgba(15, 23, 42, 0.12));
    transition: transform 0.2s ease;
}

.comment-sticker-category-btn:hover .comment-sticker-pack-headliner,
.comment-sticker-category-btn:focus-visible .comment-sticker-pack-headliner {
    transform: scale(1.04);
}

.comment-sticker-pack-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    min-height: 28px;
    padding: 0.35rem 0.75rem;
    border: 1px solid #d8e3ee;
    border-radius: 999px;
    background: #f7f9fc;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    text-align: center;
    word-break: break-word;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.comment-sticker-category-btn:hover .comment-sticker-pack-label,
.comment-sticker-category-btn:focus-visible .comment-sticker-pack-label {
    background: #eef4ff;
    border-color: #92b4f4;
}

.comment-sticker-category-btn.is-active .comment-sticker-pack-label {
    background: #e7f0ff;
    border-color: #53a0fd;
    box-shadow: 0 0 0 3px rgba(83, 160, 253, 0.14);
}

.comment-sticker-panel {
    padding: 0.85rem;
    border: 1px solid #d8e3ee;
    border-radius: 12px;
    background: #ffffff;
}

.comment-sticker-panel[hidden] {
    display: none !important;
}

.comment-sticker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
    gap: 0.5rem;
    max-height: 384px;
    overflow-y: auto;
}

.comment-sticker-item {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 128px;
    padding: 0.25rem;
    border: 1px solid #e3eaf3;
    border-radius: 10px;
    background: #ffffff;
    cursor: pointer;
    transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.comment-sticker-item:hover,
.comment-sticker-item:focus-visible {
    background: #eef4ff;
    border-color: #92b4f4;
    transform: translateY(-1px);
    outline: none;
}

.comment-sticker-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.comment-sticker-empty {
    margin: 0;
    padding: 0.5rem;
    color: #6c757d;
    font-size: 0.85rem;
    text-align: center;
}

.comment-sticker-img {
    display: inline-block;
    width: 192px;
    height: 192px;
    max-width: 100%;
    object-fit: contain;
    vertical-align: middle;
}

.comment-form-note {
    color: #6c757d;
    font-size: 0.85rem;
    margin-top: 0.25rem;
    display: block;
}

.comment-char-counter {
    display: block;
    margin-top: 0.45rem;
    text-align: right;
    color: #5f6f82;
    font-size: 0.85rem;
    font-weight: 600;
}

.comment-char-counter.is-warning {
    color: #b7791f;
}

.comment-char-counter.is-danger {
    color: #c53030;
}

.comment-form.sticker-picker-open textarea[name="comment_text"],
.comment-form.sticker-picker-open .comment-form-note,
.comment-form.sticker-picker-open .comment-char-counter,
.comment-form.sticker-picker-open > button[type="submit"] {
    display: none;
}

.admin-comment-toggle-group {
    margin-bottom: 1.25rem;
}

.comment-admin-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid #d8e3ee;
    border-radius: 10px;
    background: #ffffff;
}

.comment-admin-toggle-control {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.comment-admin-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.comment-admin-toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
    border-radius: 999px;
    background: #c9d2dc;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.comment-admin-toggle-text {
    color: #24384f;
    font-weight: 600;
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.comment-admin-toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
    transition: transform 0.2s ease;
}

.comment-admin-toggle input[type="checkbox"]:checked + .comment-admin-toggle-switch {
    background: #3498db;
}

.comment-admin-toggle input[type="checkbox"]:checked + .comment-admin-toggle-switch .comment-admin-toggle-slider {
    transform: translateX(24px);
}

.comment-admin-toggle-note {
    display: block;
    margin-top: 0.5rem;
    color: #6c757d;
    font-size: 0.85rem;
    line-height: 1.5;
}

.comment-admin-persona-fields {
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: #ffffff;
    border: 1px solid #dde5ee;
    border-radius: 8px;
}

.comment-admin-persona-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.comment-admin-persona-fields,
.comment-admin-persona-fields * {
    box-sizing: border-box;
    min-width: 0;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.form-group input,
.form-group textarea {
    width: 100%;
    max-width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    box-sizing: border-box;
}

/* Стили комментариев с новой системой */
.comments-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.comments-section h3 {
    margin-bottom: 0;
    color: #2c3e50;
}

.comments-sort-box {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.comments-sort-label {
    color: #2c3e50;
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
}

.comments-sort-select {
    min-width: 200px;
    padding: 8px 34px 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    color: #2c3e50;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.2;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, #6b7280 50%),
        linear-gradient(135deg, #6b7280 50%, transparent 50%);
    background-position:
        calc(100% - 16px) calc(50% - 2px),
        calc(100% - 11px) calc(50% - 2px);
    background-size:
        6px 6px,
        6px 6px;
    background-repeat: no-repeat;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.comments-sort-select:hover,
.comments-sort-select:focus {
    border-color: #3498db;
}

.comments-sort-select:focus {
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    outline: none;
}

.no-comments {
    text-align: center;
    color: #7f8c8d;
    padding: 2rem;
    font-style: italic;
}

.reply-info {
    background: #e3f2fd;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-cancel-reply {
    background: transparent;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-cancel-reply:hover {
    text-decoration: underline;
}

.comments-list {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.comment {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s;
}

.comment:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.comment-header {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.comment-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
    text-transform: uppercase;
    box-sizing: border-box;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.comment-avatar-admin {
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.85);
}

.comment-avatar-admin img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: contain;
    display: block;
    background: #ffffff;
}

.comment-meta {
    flex: 1;
    min-width: 0;
}

.comment-author {
    font-weight: bold;
    color: #2c3e50;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: normal;
}

.comment-date {
    color: #7f8c8d;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.comment-text {
    color: #333;
    line-height: 1.6;
    margin-bottom: 1rem;
    word-wrap: break-word;
    /* Поддержка эмодзи */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
    font-feature-settings: "liga" 1, "calt" 1;
    /* Улучшенное отображение эмодзи */
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    /* Размер эмодзи */
    font-size: 1rem;
    line-height: 1.7;
}

.comment-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.comment-action-btn {
    background: transparent;
    border: 1px solid #ddd;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.9rem;
    color: #555;
    transition: all 0.3s;
}

.comment-action-btn:hover {
    background: #f0f0f0;
    border-color: #3498db;
    color: #3498db;
}

.comment-action-btn.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.comment-action-btn .icon {
    font-size: 1rem;
}

.comment-action-btn .count {
    font-weight: bold;
    min-width: 20px;
}

.like-btn.active {
    background: #4CAF50;
    border-color: #4CAF50;
}

.dislike-btn.active {
    background: #f44336;
    border-color: #f44336;
}

.comment-reaction-menu {
    position: fixed;
    z-index: 3000;
    width: min(280px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1rem;
    border-radius: 16px;
    border: 1px solid rgba(52, 152, 219, 0.18);
    background: #fff;
    box-shadow: 0 18px 40px rgba(31, 45, 61, 0.18);
}

.comment-reaction-menu.comment-reaction-menu-mobile {
    left: 12px !important;
    right: 12px !important;
    top: auto !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12px) !important;
    width: auto !important;
    max-width: none;
    max-height: calc(100vh - 24px - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - 24px - env(safe-area-inset-bottom, 0px));
    border-radius: 20px;
    box-shadow: 0 22px 48px rgba(31, 45, 61, 0.22);
}

.comment-reaction-menu-title {
    margin: 0 0 0.85rem;
    font-size: 1rem;
    font-weight: 700;
    color: #2c3e50;
}

.comment-reaction-menu-btn {
    width: 100%;
    border: none;
    border-radius: 999px;
    padding: 0.7rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.comment-reaction-menu-btn:hover {
    transform: translateY(-1px);
}

.comment-reaction-menu-btn-primary {
    background: linear-gradient(135deg, #3498db 0%, #5dade2 100%);
    color: #fff;
    box-shadow: 0 10px 20px rgba(52, 152, 219, 0.2);
}

.comment-reaction-menu-btn-secondary {
    background: #f4f8fb;
    color: #2c3e50;
    border: 1px solid rgba(52, 152, 219, 0.25);
}

.comment-reaction-menu-bulk {
    margin-top: 0.9rem;
}

.comment-reaction-menu-label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #5b6b7a;
}

.comment-reaction-menu-bulk-controls {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.comment-reaction-menu-input {
    flex: 0 0 82px;
    width: 82px;
    min-width: 0;
    padding: 0.68rem 0.75rem;
    border: 1px solid #d6dee7;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
    background: #fff;
    text-align: center;
}

.comment-reaction-menu-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.comment-reaction-menu-note {
    display: block;
    margin-top: 0.55rem;
    font-size: 0.8rem;
    line-height: 1.4;
    color: #7f8c8d;
}

.front-plan-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    margin-left: 0.35rem;
    vertical-align: middle;
}

.front-plan-badge img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.comment-admin-toggle-text .front-plan-badge,
.comment-reaction-menu-label .front-plan-badge,
.comment-reaction-menu-btn .front-plan-badge {
    width: 28px;
    height: 28px;
}

.admin-comment-toggle-group.is-premium-locked {
    opacity: 0.86;
}

.admin-comment-toggle-group.is-premium-locked .comment-admin-toggle,
.admin-comment-toggle-group.is-premium-locked .comment-admin-toggle input,
.admin-comment-toggle-group.is-premium-locked .comment-admin-toggle-switch {
    cursor: not-allowed;
}

.admin-comment-toggle-group.is-premium-locked .comment-admin-toggle-switch {
    opacity: 0.62;
}

.comment-reaction-menu-bulk.is-premium-locked {
    padding: 0.75rem;
    border: 1px dashed rgba(137, 0, 161, 0.35);
    border-radius: 14px;
    background: rgba(137, 0, 161, 0.05);
}

.comment-reaction-menu-bulk.is-premium-locked .comment-reaction-menu-input,
.comment-reaction-menu-bulk.is-premium-locked .comment-reaction-menu-btn {
    opacity: 0.62;
    cursor: not-allowed;
}

/* Ответы на комментарии */
.comment-replies {
    margin-top: 1rem;
    margin-left: 3rem;
    border-left: 4px solid #667eea;
    padding-left: 1.5rem;
    background: linear-gradient(to right, rgba(102, 126, 234, 0.03) 0%, transparent 100%);
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    border-radius: 0 8px 8px 0;
}

.comment-reply {
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 1rem;
    background: white;
    position: relative;
}

.comment-reply::before {
    content: "↳";
    position: absolute;
    left: -2rem;
    top: 1.5rem;
    font-size: 1.5rem;
    color: #667eea;
    opacity: 0.5;
}

.comment-reply:last-child {
    margin-bottom: 0;
}

.reply-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin: -1rem -1rem 0.75rem -1rem;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-bottom: 1px solid rgba(102, 126, 234, 0.2);
    font-size: 0.85rem;
    color: #667eea;
    border-radius: 8px 8px 0 0;
}

.reply-indicator span {
    min-width: 0;
}

.reply-indicator svg {
    transform: rotate(-90deg);
    color: #667eea;
}

.reply-indicator strong {
    color: #764ba2;
    overflow-wrap: anywhere;
}

/* Модальное окно капчи */
.captcha-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s ease;
}

.captcha-modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.captcha-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 450px;
    width: 90%;
    animation: slideUp 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(50px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.captcha-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.captcha-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.3rem;
}

.captcha-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #95a5a6;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.captcha-close:hover {
    background: #ecf0f1;
    color: #2c3e50;
}

.captcha-instruction {
    color: #7f8c8d;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    text-align: center;
}

.captcha-container {
    position: relative;
    width: min(100%, 350px);
    margin-bottom: 1.5rem;
    margin-left: auto;
    margin-right: auto;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.captcha-background {
    width: 100%;
    height: auto;
    display: block;
}

.captcha-puzzle {
    position: absolute;
    top: 0;
    left: 0;
    cursor: move;
    transition: left 0.05s ease;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-sizing: border-box;
    border-radius: 2px;
}

.captcha-slider-container {
    position: relative;
    width: min(100%, 350px);
    height: 50px;
    background: #ecf0f1;
    border-radius: 25px;
    overflow: hidden;
    margin-bottom: 1rem;
    margin-left: auto;
    margin-right: auto;
    touch-action: none;
}

.captcha-slider-track {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    border-radius: 25px 0 0 25px;
    transition: width 0.05s ease;
}

.captcha-slider-button {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #3498db;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    transition: left 0.05s ease;
    box-sizing: border-box;
    margin: 0;
}

.captcha-slider-button:active {
    cursor: grabbing;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.captcha-slider-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 58px;
    color: #95a5a6;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    pointer-events: none;
    user-select: none;
    transition: opacity 0.2s ease;
}

.captcha-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.captcha-btn {
    flex: 0 1 180px;
    min-height: 46px;
    padding: 0.75rem 1.2rem;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.captcha-btn-refresh {
    background: #95a5a6;
    color: white;
}

.captcha-btn-refresh:hover {
    background: #7f8c8d;
}

.captcha-btn-verify {
    background: #3498db;
    color: white;
}

.captcha-btn-verify:hover {
    background: #2980b9;
}

.captcha-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.captcha-message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 6px;
    text-align: center;
    font-size: 0.9rem;
    animation: fadeIn 0.3s ease;
}

.captcha-message.success {
    background: #d5f4e6;
    color: #27ae60;
}

.captcha-message.error {
    background: #fadbd8;
    color: #e74c3c;
}

@media (max-width: 768px) {
    .captcha-actions {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }

    .captcha-btn {
        width: min(100%, 220px);
        flex: 0 0 auto;
        min-height: 44px;
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
        border-radius: 999px;
    }
}

/* Кнопка чтения */
.reading-button {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 30px;
    border-radius: 25px;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: bold;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    margin: 20px 0;
}

.reading-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
    color: white;
}

/* Буктрейлер */
.book-trailer {
    margin: 2rem 0;
}

.book-trailer-toggle h3 {
    text-align: center;
    margin: 0;
    font-size: 1.2rem;
}

#trailer-toggle-icon {
    display: inline-block;
    transition: transform 0.3s;
    font-size: 0.9em;
}

#trailer-toggle-icon.expanded {
    transform: rotate(90deg);
}

.trailer-content-container {
    margin-top: 1.5rem;
}

.trailer-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    overflow: hidden;
    border-radius: 8px;
}

.trailer-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Карусель материалов */
.materials-section {
    margin: 2rem 0;
}

.materials-toggle {
    cursor: pointer;
    user-select: none;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    transition: background 0.3s;
}

.materials-toggle:hover {
    background: #e9ecef;
}

.materials-toggle h3 {
    text-align: center;
    margin: 0;
    font-size: 1.2rem;
}

#materials-toggle-icon {
    display: inline-block;
    transition: transform 0.3s;
    font-size: 0.9em;
}

#materials-toggle-icon.expanded {
    transform: rotate(90deg);
}

.materials-carousel-container {
    margin-top: 1.5rem;
}

.carousel {
    position: relative;
    width: 80%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-images {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.carousel-slide {
    display: none;
    width: 100%;
}

.carousel-slide.active {
    display: block;
}

.carousel-slide img {
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
    border-radius: 8px;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    padding: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 4px;
    z-index: 10;
    transition: background 0.3s;
}

.carousel-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.carousel-prev {
    left: -60px;
}

.carousel-next {
    right: -60px;
}

.carousel-dots {
    text-align: center;
    margin-top: 1rem;
}

.carousel-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ccc;
    margin: 0 5px;
    cursor: pointer;
    transition: background 0.3s;
}

.carousel-dot.active,
.carousel-dot:hover {
    background: #3498db;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    /* Убираем все отступы у body и html на мобильных */
    body, html {
        margin: 0 !important;
        padding: 0 !important;
        overflow-x: hidden !important;
    }
    
    /* Убираем отступы у контейнера внутри хедера на мобильных */
    .header .container {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    /* Убираем отступы сверху и по бокам у хедера */
    .header {
        padding: 1rem 0 !important;
        margin: 0 !important;
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        position: fixed !important;
        top: 0 !important;
    }
    
    /* Настройки навигации на мобильных */
    .nav {
        padding: 0; /* Убираем padding, используем margin на элементах */
        justify-content: space-between; /* Логотип слева, гамбургер справа */
        align-items: flex-start !important; /* Выравнивание по верху */
        margin: 0 !important;
        gap: 0 !important; /* Убираем gap на мобильных */
    }
    
    .logo {
        margin-left: 6px !important; /* Отступ логотипа слева 6px */
        order: 1; /* Логотип слева */
        flex: 0 1 auto; /* Может сжиматься, но не растягивается */
        max-width: calc(100% - 60px); /* Оставляем место для гамбургера (30px + padding + margin) */
        min-width: 0; /* Позволяет сжиматься до 0 */
        align-self: flex-start; /* Выравнивание по верху */
        display: flex; /* Убеждаемся, что flex применяется */
        align-items: flex-start !important; /* Выравнивание элементов логотипа по верху */
    }
    
    /* Изображение логотипа выровнено по верху */
    .logo-img {
        flex-shrink: 0; /* Изображение не сжимается */
        align-self: flex-start; /* Изображение выровнено по верху */
    }
    
    /* Текст логотипа выровнен по верху относительно изображения */
    .logo-text {
        align-self: flex-start; /* Текст выровнен по верху */
        margin-top: 0; /* Убираем отступ сверху, чтобы текст был на уровне изображения */
        min-width: 0; /* Позволяет сжиматься */
        flex: 1; /* Занимает доступное пространство */
        max-width: 100%; /* Не превышает ширину родителя */
        display: flex; /* Убеждаемся, что flex применяется */
        flex-direction: column; /* Вертикальное расположение заголовка и подзаголовка */
        justify-content: flex-start; /* Выравнивание по верху */
    }
    
    .logo-subtitle {
        word-wrap: break-word; /* Перенос длинных слов */
        overflow-wrap: break-word; /* Современный стандарт переноса */
        hyphens: auto; /* Автоматическая расстановка переносов */
        max-width: 100%; /* Не превышает ширину родителя */
    }
    
    /* Скрываем меню на мобильных в обычном состоянии */
    .nav-menu {
        order: 3; /* Меню будет внизу при открытии */
        position: fixed;
        left: -100%;
        top: 0; /* Будет динамически установлено через JS */
        flex-direction: column;
        background-color: #2c3e50; /* Будет динамически установлено через JS */
        width: 100%;
        text-align: center;
        transition: 0.3s;
        padding: 1rem 0 !important; /* Уменьшаем padding, чтобы соответствовать хедеру */
        margin: 0 !important;
        z-index: 1000;
        display: none !important; /* Скрываем меню по умолчанию */
        gap: 0 !important; /* Убираем gap на мобильных */
    }

    .nav-menu.active {
        left: 0;
        display: flex !important; /* Показываем меню когда оно активно */
    }
    
    /* Убеждаемся, что стили ссылок меню одинаковые на мобильных */
    .nav-menu a,
    .nav-menu li a {
        color: white !important;
        text-decoration: none !important;
        padding: 0.75rem 1rem !important;
        display: block !important;
        font-size: inherit !important;
        font-family: inherit !important;
    }
    
    .nav-menu li {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    
    /* ВАЖНО: Показываем гамбургер на мобильных - максимальная специфичность и !important */
    .header .container .nav .hamburger,
    .container .nav .hamburger,
    .header .nav .hamburger,
    .nav .hamburger,
    .header .hamburger,
    body .hamburger,
    body .header .hamburger,
    body .nav .hamburger,
    .hamburger {
        display: flex !important;
        position: relative !important;
        z-index: 1001 !important;
        order: 2 !important; /* Гамбургер справа */
        visibility: visible !important;
        opacity: 1 !important;
        width: auto !important;
        height: auto !important;
        min-width: 30px !important; /* Минимальная ширина для видимости */
        min-height: 30px !important; /* Минимальная высота для видимости */
        margin: 0 !important;
        margin-left: auto !important; /* Прижимаем к правому краю */
        margin-right: 6px !important; /* Отступ справа 6px */
        padding: 0.5rem !important;
        flex-shrink: 0 !important; /* Не сжимается */
        align-self: flex-start !important; /* Выравнивание по верху, на уровне изображения логотипа */
        margin-top: 0 !important; /* Убираем верхний отступ */
    }
    
    /* Переопределяем инлайн-стили для показа гамбургера */
    .hamburger[style*="display: none"],
    .hamburger[style*="display:none"],
    .hamburger[style*="display: none;"],
    .hamburger[style*="display:none;"] {
        display: flex !important;
    }
    
    /* Убеждаемся, что линии гамбургера видны */
    .hamburger svg {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 24px !important;
        height: 24px !important;
    }
    
    .hamburger svg line {
        stroke: white !important;
        stroke-width: 2 !important;
        transition: all 0.3s ease !important;
        transform-origin: center !important;
    }
    
    .hamburger svg .menu-circle {
        stroke: white !important;
        stroke-width: 2 !important;
        fill: none !important;
        opacity: 0 !important;
        display: none !important;
        transition: opacity 0.3s ease !important;
    }
    
    /* Анимация в виде круга при активации на мобильных */
    .hamburger.active svg .menu-line-1,
    .hamburger.active svg .menu-line-2,
    .hamburger.active svg .menu-line-3 {
        opacity: 0 !important;
        transform: scale(0) !important;
    }
    
    .hamburger.active svg .menu-circle {
        display: block !important;
        opacity: 1 !important;
        stroke-dasharray: 56.55 !important;
        stroke-dashoffset: 0 !important;
        animation: drawCircle 0.3s ease forwards !important;
    }
    
    @keyframes drawCircle {
        from {
            stroke-dashoffset: 56.55;
            opacity: 0;
        }
        to {
            stroke-dashoffset: 0;
            opacity: 1;
        }
    }
    
    /* Возврат к исходному состоянию при закрытии на мобильных */
    .hamburger:not(.active) svg .menu-line-1,
    .hamburger:not(.active) svg .menu-line-2,
    .hamburger:not(.active) svg .menu-line-3 {
        opacity: 1 !important;
        transform: scale(1) !important;
        transition: opacity 0.3s ease, transform 0.3s ease !important;
    }
    
    .hamburger:not(.active) svg .menu-circle {
        opacity: 0 !important;
        display: none !important;
    }
    
    /* Подменю на мобильных */
    .nav-menu .submenu {
        position: static;
        display: none;
        background: rgba(255, 255, 255, 0.1);
        margin-left: 1rem;
        margin-top: 0.5rem;
        padding: 0.5rem 0;
        border-radius: 4px;
    }
    
    .nav-menu .has-children.active .submenu {
        display: block;
    }
    
    .nav-menu .has-children > a::after {
        content: ' ▶';
    }
    
    
    /* Скрываем меню на мобильных по умолчанию (когда не активно) */
    .nav-menu:not(.active) {
        display: none !important;
    }
    
    /* Показываем меню когда оно активно */
    .nav-menu.active {
        display: flex !important;
    }

    .hero-content h2 {
        font-size: 2rem;
    }

    .hero-content p {
        font-size: 1rem;
    }

    .btn {
        padding: 9px 14px;
        font-size: 0.9rem;
        line-height: 1.2;
    }

    .books-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .filters-row {
        flex-direction: column;
    }
    
    .filter-group {
        min-width: 100%;
    }
    
    .filter-actions {
        width: 100%;
        justify-content: stretch;
    }
    
    .btn-filter,
    .btn-reset {
        flex: 1;
    }
    
    .book-card {
        flex-direction: column;
        align-items: center; /* Центрируем все элементы карточки */
        padding: 16px 8px; /* Компактные отступы сверху и по бокам */
    }
    
    /* Убираем 3D эффект при наведении в мобильной версии */
    .book-card:hover {
        transform: none;
    }
    
    .book-card:hover .book-cover img {
        transform: none;
    }
    
    /* Автоматическое центрирование обложки в мобильной версии */
    .book-card .book-cover-wrapper {
        width: auto !important; /* Автоматическая ширина */
        max-width: 85% !important; /* Увеличиваем максимальную ширину */
        margin: 0 auto !important; /* Автоматическое центрирование */
        padding: 5px 5px 0 5px !important; /* Убираем padding-bottom, чтобы счетчики не накладывались */
        padding-bottom: 0 !important; /* Явно убираем padding-bottom из book_cover_3d_styles.php */
        display: block !important;
        position: static !important; /* Убираем position: relative, чтобы счетчики не позиционировались относительно wrapper */
        overflow: visible !important; /* Возвращаем visible для отображения 3D теней */
        height: auto !important; /* Автоматическая высота, без фиксированных значений */
    }
    
    .book-card .book-cover {
        width: 100% !important;
        max-width: 189px !important; /* Пропорции 7:10 (189px × 270px) */
        height: auto !important;
        aspect-ratio: 7/10;
        margin: 0 auto;
        overflow: visible !important; /* Для отображения 3D теней */
        position: relative !important; /* Для правильного отображения теней */
    }
    
    .book-card .book-cover img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .book-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0 !important; /* Убираем gap между обложкой и мета-информацией */
        margin-bottom: 0 !important; /* Убираем нижний отступ */
    }
    
    .book-header .book-cover-wrapper {
        width: 100%;
        padding: 5px 5px 0 5px !important; /* Убираем padding-bottom */
        margin: 0 auto 0 auto !important; /* Убираем нижний margin */
        margin-bottom: 0 !important; /* Явно убираем нижний margin */
        display: block !important;
        position: static !important;
        overflow: visible !important;
    }
    
    .book-header .book-cover {
        width: 80%;
        max-width: 210px;
        height: auto;
        aspect-ratio: 7/10;
        margin: 0 auto;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .book-header .book-cover img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .book-header .book-cover-wrapper > .book-likes,
    .book-header .book-cover-wrapper > .book-comments,
    .book-header .book-cover-wrapper > .book-library {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
        position: fixed !important;
        z-index: -9999 !important;
        top: -9999px !important;
        left: -9999px !important;
        right: auto !important;
        bottom: auto !important;
        width: 0 !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        transform: none !important;
    }
    
    /* Карусель материалов в мобильной версии */
    .carousel {
        width: 100%;
    }
    
    .carousel-btn {
        padding: 0.5rem;
        font-size: 1.2rem;
    }
    
    .carousel-prev {
        left: 5px;
    }
    
    .carousel-next {
        right: 5px;
    }
    
    /* Комментарии в мобильной версии */
    .comments-toolbar {
        align-items: stretch;
        gap: 0.65rem;
        margin-bottom: 1rem;
    }

    .comments-section {
        margin-top: 1.35rem;
        padding-top: 1.35rem;
    }

    .comments-section h3 {
        font-size: 1.08rem;
    }

    .comments-sort-box {
        width: 100%;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .comments-sort-select {
        min-width: 0;
        width: 100%;
        font-size: 0.92rem;
        padding: 7px 32px 7px 10px;
    }

    .comment-header {
        flex-direction: row;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .comment {
        padding: 0.9rem 0.8rem;
        margin-bottom: 0.75rem;
        border-radius: 11px;
    }
    
    .comment-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.88rem;
    }

    .comment-author {
        flex-wrap: wrap;
        font-size: 0.9rem;
        line-height: 1.35;
    }

    .comment-date {
        font-size: 0.74rem;
    }

    .comment-text {
        font-size: 0.9rem;
        line-height: 1.52;
        margin-bottom: 0.75rem;
    }

    .reply-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 0.75rem 0.85rem;
    }

    .add-comment-section {
        margin-top: 1.1rem;
        padding-top: 1.1rem;
        border-top-width: 1px;
    }

    .add-comment-section h4 {
        margin: 0 0 0.65rem;
        font-size: 1rem;
        line-height: 1.25;
    }

    .add-comment-section .comment-form {
        padding: 0.75rem;
        margin-bottom: 1rem;
        border-radius: 10px;
        font-size: 0.88rem;
    }

    .add-comment-section .form-group {
        margin-bottom: 0.62rem;
    }

    .add-comment-section .form-group label {
        margin-bottom: 0.38rem;
        font-size: 0.84rem;
        line-height: 1.25;
    }

    .add-comment-section .form-group input,
    .add-comment-section .form-group textarea {
        padding: 5px 8px;
        border-radius: 7px;
        font-size: 15px;
        line-height: 1.22;
        letter-spacing: -0.01em;
    }

    .add-comment-section .form-group input {
        min-height: 34px;
        height: 34px;
    }

    .add-comment-section .form-group input::placeholder,
    .add-comment-section .form-group textarea::placeholder {
        color: #8a96a3;
        font-size: 0.86em;
        line-height: 1.25;
        opacity: 1;
    }

    .add-comment-section .form-group textarea {
        min-height: 78px;
    }

    .comment-input-header {
        align-items: stretch;
        gap: 0.4rem;
        margin-bottom: 0.38rem;
    }

    .add-comment-section .comment-input-header {
        flex-wrap: nowrap;
        align-items: center;
    }

    .add-comment-section .comment-input-header label {
        flex: 1 1 auto;
        margin-right: auto;
        margin-bottom: 0;
    }

    .add-comment-section .comment-sticker-trigger {
        flex-shrink: 0;
        min-height: 34px;
        padding: 0.34rem 0.62rem;
        font-size: 0.82rem;
        gap: 0.32rem;
    }

    .add-comment-section .comment-sticker-trigger-icon {
        width: 16px;
        height: 16px;
    }

    .add-comment-section .comment-sticker-picker {
        padding: 0.65rem;
        margin-bottom: 0.55rem;
        border-radius: 10px;
    }

    .add-comment-section .comment-sticker-search {
        padding: 0.42rem 0.58rem;
        font-size: 0.84rem;
        border-radius: 8px;
    }

    .add-comment-section .comment-sticker-pack-label {
        min-height: 24px;
        padding: 0.26rem 0.55rem;
        font-size: 0.78rem;
    }

    .add-comment-section .comment-sticker-panel {
        padding: 0.6rem;
        border-radius: 10px;
    }

    .comment-emoji-trigger {
        display: none !important;
    }

    .comment-emoji-picker {
        display: none !important;
    }

    .comment-emoji-grid {
        grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    }

    .comment-sticker-grid {
        grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
    }

    .comment-sticker-img {
        width: 128px;
        height: 128px;
    }

    .add-comment-section .comment-form-note {
        margin-top: 0.18rem;
        margin-bottom: 0.45rem !important;
        font-size: 0.75rem;
        line-height: 1.35;
    }

    .add-comment-section .comment-char-counter {
        margin-top: 0.28rem;
        font-size: 0.75rem;
    }

    .add-comment-section .comment-form > .btn,
    .add-comment-section .comment-form > .btn-primary,
    .add-comment-section .comment-form > button[type="submit"] {
        min-height: 36px;
        padding: 0.48rem 0.8rem;
        font-size: 0.84rem;
        border-radius: 8px;
    }

    .comment-replies {
        margin-left: 0.55rem;
        padding: 0.3rem 0 0 0.55rem;
        border-left-width: 2px;
        background: none;
    }
    
    .comment-reply {
        padding: 0.78rem 0.68rem;
        margin-bottom: 0.6rem;
    }

    .comment-reply::before {
        content: none;
    }

    .comment-reply .comment-header {
        gap: 0.65rem;
    }

    .comment-reply .comment-avatar {
        width: 31px;
        height: 31px;
        font-size: 0.78rem;
    }

    .reply-indicator {
        margin: -0.75rem -0.65rem 0.65rem -0.65rem;
        padding: 0.45rem 0.65rem;
        gap: 0.4rem;
        font-size: 0.78rem;
        line-height: 1.35;
    }

    .reply-indicator svg {
        width: 14px;
        height: 14px;
        flex: 0 0 14px;
    }

    .comment-reply .comment-text {
        margin-bottom: 0.6rem;
        font-size: 0.86rem;
        line-height: 1.48;
    }
    
    .comment-actions {
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    .comment-admin-toggle {
        align-items: flex-start;
        gap: 0.52rem;
        padding: 0.58rem 0.65rem;
        border-radius: 8px;
    }

    .admin-comment-toggle-group {
        margin-bottom: 0.7rem;
    }

    .comment-admin-toggle-switch {
        width: 42px;
        height: 22px;
    }

    .comment-admin-toggle-slider {
        width: 16px;
        height: 16px;
    }

    .comment-admin-toggle input[type="checkbox"]:checked + .comment-admin-toggle-switch .comment-admin-toggle-slider {
        transform: translateX(20px);
    }

    .comment-admin-toggle-text {
        font-size: 0.82rem;
        line-height: 1.32;
    }

    .comment-admin-toggle-note {
        margin-top: 0.3rem;
        font-size: 0.74rem;
        line-height: 1.35;
    }

    .comment-admin-persona-fields {
        margin-bottom: 0.75rem;
        padding: 0.65rem;
        border-radius: 8px;
    }

    .comment-admin-persona-grid {
        grid-template-columns: 1fr;
        gap: 0.55rem;
    }

    .comment-admin-persona-grid .form-group {
        width: 100%;
    }

    .comment-admin-persona-grid input[type="date"],
    .comment-admin-persona-grid input[type="time"] {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        font-size: 16px;
    }
    
    .comment-action-btn {
        padding: 0.28rem 0.5rem;
        font-size: 0.8rem;
        gap: 0.22rem;
    }

    .comment-reply .comment-actions {
        gap: 0.4rem;
    }

    .comment-reply .comment-action-btn {
        padding: 0.25rem 0.45rem;
        font-size: 0.76rem;
    }

    .comment-reply .comment-action-btn .icon {
        font-size: 0.9rem;
    }

    .comment-reaction-menu {
        width: min(320px, calc(100vw - 24px));
        padding: 0.9rem;
    }

    .comment-reaction-menu-bulk-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .comment-reaction-menu-input {
        width: 100%;
        flex: 1 1 auto;
    }
    
    .book-header .book-cover-wrapper > .book-comments {
        margin-left: 0 !important;
    }
    
    .book-header .book-meta {
        width: 100%;
        text-align: left;
        margin-top: 0.25rem !important; /* Минимальный отступ после счетчиков */
        margin-bottom: 0 !important; /* Убираем нижний отступ */
        padding-top: 0 !important; /* Убираем верхний padding */
    }
    
    .book-header .book-meta h1 {
        margin-top: 0 !important; /* Убираем верхний отступ у заголовка */
        margin-bottom: 0.3rem !important;
    }
    
    .book-info {
        margin-left: 0 !important;
    }
    
    /* Полностью скрываем и убираем из потока счетчики внутри book-cover-wrapper в мобильной версии */
    .book-card .book-cover-wrapper > .book-likes,
    .book-card .book-cover-wrapper > .book-comments,
    .book-card .book-cover-wrapper > .book-library {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
        position: fixed !important; /* Используем fixed вместо absolute, чтобы полностью убрать из потока */
        z-index: -9999 !important; /* Убираем за пределы видимости */
        top: -9999px !important; /* Убираем за пределы экрана */
        left: -9999px !important;
        width: 0 !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Показываем блок счетчиков в мобильной версии под обложкой */
    /* Настройки позиционирования (margin-top, gap, justify-content) применяются из book_cover_3d_styles.php через админку */
    .book-counters-mobile {
        display: flex !important;
        align-items: center;
        width: 100% !important; /* Занимает всю ширину карточки для центрирования */
        max-width: 220px !important; /* Та же максимальная ширина, что и у обложки (220px) */
        margin-left: auto !important;
        margin-right: auto !important;
        margin-top: 15px !important; /* Базовый отступ сверху, может быть переопределен из админки */
        margin-bottom: 0 !important; /* Убираем нижний отступ */
        position: static !important; /* Убеждаемся, что счетчики в нормальном потоке документа */
        z-index: 1 !important; /* Убеждаемся, что счетчики поверх других элементов */
        clear: both !important; /* Убеждаемся, что блок начинается с новой строки */
        top: auto !important; /* Убираем любое абсолютное позиционирование */
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        /* justify-content и gap применяются из book_cover_3d_styles.php с !important */
    }
    
    .book-counters-mobile .book-likes,
    .book-counters-mobile .book-comments,
    .book-counters-mobile .book-library {
        position: relative !important; /* Убеждаемся, что счетчики в нормальном потоке */
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        margin: 0 !important;
        display: inline-flex !important;
        flex-shrink: 0;
        transform: none !important;
        padding: 6px 7px !important; /* Увеличен вертикальный padding на 3px для мобильной версии */
    }

    .book-counters-mobile .book-likes:hover,
    .book-counters-mobile .book-comments:hover,
    .book-counters-mobile .book-library:hover {
        transform: none !important;
        background: white;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    }

    .book-counters-mobile .book-likes:active,
    .book-counters-mobile .book-comments:active,
    .book-counters-mobile .book-library:active {
        transform: none !important;
    }

    /* Размер сердечка в мобильной версии - нормальный размер */
    .book-counters-mobile .like-heart {
        width: 1.2rem;
        height: 1.2rem;
    }

    /* Размер иконки комментариев в мобильной версии - нормальный размер */
    .book-counters-mobile .comments-icon {
        font-size: 1rem;
        width: 1.2rem;
        height: 1.2rem;
    }

    /* Размер иконки библиотеки в мобильной версии - нормальный размер */
    .book-counters-mobile .library-icon {
        font-size: 1rem;
        width: 1.2rem;
        height: 1.2rem;
    }

    .book-actions {
        position: static !important;
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        margin-top: 0.75rem;
        margin-bottom: 8px;
        padding: 0 0.5rem;
        gap: 0.45rem;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        bottom: auto !important;
        transform: none !important;
    }

    .book-actions .btn,
    .book-actions .btn-primary,
    .book-actions .btn-secondary,
    .book-actions button,
    .book-actions a {
        flex: 1;
        padding: 9px 12px !important;
        font-size: 0.86rem !important;
        text-align: center;
        min-height: 38px;
        height: auto;
        max-height: none;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-sizing: border-box !important;
        line-height: 1.2 !important;
    }

    .book-info {
        padding-bottom: 0 !important; /* Убираем большой отступ снизу, так как кнопка теперь не absolute */
    }

    .book-card .book-info {
        width: 100% !important;
        align-self: stretch !important;
        text-align: left !important;
    }

    .book-card .book-info h3,
    .book-card .book-description,
    .book-card .book-genre {
        text-align: left !important;
    }

    .book-card .book-work-info,
    .book-card .book-series-wrapper {
        width: 100% !important;
        justify-content: flex-start !important;
        text-align: left !important;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .hero > .container {
        min-height: 365px;
    }

    .hero .hero-panel .hero-content {
        padding: 36px 15px 30px;
    }

    .hero:not(.hero--content-width) .hero-panel .hero-content {
        padding-top: calc(var(--home-header-offset, 88px) + 16px);
    }

    .hero.hero--content-width {
        padding: calc(var(--home-header-offset, 88px) + 10px) 0 0;
    }

    .hero.hero--content-width .hero-panel {
        aspect-ratio: 1080 / 1010;
        min-height: 0;
        border-radius: 22px;
    }

    .hero.hero--content-width .hero-panel.hero-panel--wallpaper {
        background-image: var(--hero-wallpaper-mobile, var(--hero-wallpaper-desktop));
    }

    .books-section {
        padding: 0 0 40px;
    }

    .book-info {
        padding: 1rem;
    }

    .book-info h3 {
        margin-bottom: 0.35rem;
    }

    .book-description,
    .book-work-info,
    .book-series-wrapper,
    .book-genre {
        font-size: 0.86rem !important;
        line-height: 1.38;
    }

    .book-actions .btn,
    .book-actions .btn-primary,
    .book-actions .btn-secondary,
    .book-actions button,
    .book-actions a {
        padding: 8px 10px !important;
        font-size: 0.82rem !important;
        min-height: 36px;
    }

    .comment-form {
        padding: 0.85rem;
    }

    .comment {
        padding: 0.78rem 0.68rem;
    }

    .comment-text {
        font-size: 0.86rem;
        line-height: 1.48;
    }

    .comment-action-btn {
        padding: 0.25rem 0.42rem;
        font-size: 0.76rem;
    }
}
/* Кнопка чтения */
.reading-button {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 30px;
    border-radius: 25px;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: bold;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    margin: 20px 0;
}

.reading-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
    color: white;
}

/* Буктрейлер */
.book-trailer {
    margin: 2rem 0;
}

.book-trailer-toggle h3 {
    text-align: center;
    margin: 0;
    font-size: 1.2rem;
}

.trailer-content-container {
    margin-top: 1.5rem;
}

.trailer-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%;
    overflow: hidden;
    border-radius: 8px;
}

.trailer-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
/* Стили страницы серии */
.series-details {
    max-width: 100%;
}

.series-header {
    display: flex;
    gap: 2rem;
    margin-bottom: 3rem;
    align-items: flex-start;
}

.series-meta {
    flex: 1;
}

.series-type {
    color: #7f8c8d;
    font-size: 1.1rem;
    margin-bottom: 1rem;
    font-style: italic;
}

.hashtags {
    margin-top: 1rem;
}

.hashtag {
    display: inline-block;
    background: #3498db;
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.9rem;
    margin: 2px 5px 2px 0;
}

.series-books {
    margin-top: 3rem;
}

.series-books h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: #2c3e50;
    text-align: center;
}

.series-number {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(52, 152, 219, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
}

.no-books {
    text-align: center;
    padding: 3rem;
    color: #7f8c8d;
    font-size: 1.1rem;
}

@media (max-width: 768px) {
    .series-header {
        flex-direction: column;
        text-align: center;
    }
    
    .book-cover-large {
        margin: 0 auto;
    }
}
/* Стили форматирования текста */
.formatted-text {
    line-height: 1.6;
}

.formatted-text strong {
    font-weight: bold;
    color: #2c3e50;
}

.formatted-text em {
    font-style: italic;
    color: #34495e;
}

.formatted-text u {
    text-decoration: underline;
}

.formatted-text del {
    text-decoration: line-through;
    opacity: 0.7;
}

/* Подсказки форм */
.form-group small {
    display: block;
    margin-top: 5px;
    color: #7f8c8d;
    font-size: 0.85em;
    line-height: 1.4;
}

/* Текстовый редактор */
.text-editor-container {
    border: 1px solid #ddd;
    border-radius: 5px;
    overflow: hidden;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-top: 0;
    width: 100%;
    display: block;
}

.text-editor-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}

.text-editor-toolbar-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
}

.editor-btn {
    background: white;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 5px 9px;
    cursor: pointer;
    font-size: 0.84rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 30px;
}

.editor-btn-wide {
    min-width: auto;
    padding: 5px 11px;
}

.editor-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.editor-btn:active {
    background: #dee2e6;
}

.editor-btn.active {
    background: #3498db;
    color: white;
    border-color: #2980b9;
}

/* Стили для кнопок выравнивания в стиле Word */
.editor-btn.align-btn {
    padding: 4px 8px;
}

.editor-btn.align-btn svg {
    display: block;
    width: 16px;
    height: 16px;
}

.editor-btn.align-btn.active {
    background: #f0f0f0;
    color: #333;
    border: 2px solid #333;
    border-radius: 4px;
}

.editor-btn.align-btn:hover {
    background: #f5f5f5;
}

.editor-select {
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: white;
    font-size: 0.84rem;
    cursor: pointer;
    width: auto;
    min-width: 120px;
    max-width: 180px;
}

.editor-size-box {
    display: inline-flex;
    align-items: stretch;
    height: 32px;
}

.editor-size-input {
    width: 64px;
    min-width: 64px;
    max-width: 64px;
    height: 32px;
    padding: 4px 10px;
    border-radius: 10px 0 0 10px;
    border-right: 0;
    line-height: 22px;
    cursor: text;
    box-sizing: border-box;
}

.editor-size-stepper {
    display: inline-flex;
    flex-direction: column;
    width: 20px;
    height: 32px;
}

.editor-size-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 16px;
    padding: 0;
    border: 1px solid #ddd;
    background: #fff;
    color: #556270;
    cursor: pointer;
    font-size: 8px;
    line-height: 1;
}

.editor-size-step:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.editor-size-step-up {
    border-radius: 0 10px 0 0;
    border-bottom: 0;
}

.editor-size-step-down {
    border-radius: 0 0 10px 0;
}

.editor-select:hover {
    border-color: #adb5bd;
}

.editor-separator {
    width: 1px;
    height: 24px;
    background: #ddd;
    margin: 0 4px;
}

.text-editor-toolbar .editor-size-control {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    width: auto;
    max-width: max-content;
    color: #34495e;
    font-size: 0.84rem;
    font-weight: 600;
    white-space: nowrap;
    margin: 0;
}

.text-editor-toolbar .editor-size-control span {
    flex: 0 0 auto;
}

.text-editor-toolbar .editor-size-control .editor-size-box,
.text-editor-toolbar .editor-size-control .editor-size-stepper {
    flex: 0 0 auto;
}

.text-editor-toolbar .editor-size-control .editor-size-input {
    width: 64px !important;
    min-width: 64px !important;
    max-width: 64px !important;
    flex: 0 0 64px;
    border-radius: 10px 0 0 10px;
}

.text-editor-toolbar .editor-size-control .editor-size-stepper {
    width: 20px;
    flex: 0 0 20px;
}

.text-editor-toolbar-secondary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid #dbe4ee;
}

.text-editor-toolbar-secondary[hidden] {
    display: none !important;
}

.text-editor-toolbar .editor-font-control,
.text-editor-toolbar .editor-mini-control,
.text-editor-toolbar .editor-color-control {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
    white-space: nowrap;
    color: #34495e;
    font-size: 0.84rem;
    font-weight: 600;
}

.text-editor-toolbar .editor-font-control,
.text-editor-toolbar .editor-mini-control,
.text-editor-toolbar .editor-color-control {
    border: 1px solid #d7dee6;
    border-radius: 8px;
    background: #ffffff;
    padding: 4px 8px;
    min-height: 42px;
}

.text-editor-toolbar .editor-font-control .editor-select {
    min-width: 180px;
    max-width: 255px;
}

.text-editor-toolbar .editor-font-control {
    position: relative;
}

.text-editor-toolbar .editor-font-picker {
    position: relative;
    min-width: 210px;
    max-width: 260px;
}

.text-editor-toolbar .editor-font-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.25rem;
    width: 100%;
    min-width: 210px;
    max-width: 260px;
    box-sizing: border-box;
    overflow: hidden;
    text-align: left;
}

.text-editor-toolbar .editor-font-trigger-preview,
.text-editor-toolbar .editor-font-trigger-label,
.text-editor-toolbar .editor-font-option-preview,
.text-editor-toolbar .editor-font-option-label {
    line-height: 1.15;
}

.text-editor-toolbar .editor-font-trigger-preview,
.text-editor-toolbar .editor-font-option-preview {
    font-size: 0.86rem;
}

.text-editor-toolbar .editor-font-trigger-preview {
    flex: 0 0 auto;
}

.text-editor-toolbar .editor-font-trigger-label,
.text-editor-toolbar .editor-font-option-label {
    font-size: 0.82rem;
}

.text-editor-toolbar .editor-font-trigger-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-editor-toolbar .editor-font-trigger-dash {
    flex: 0 0 auto;
    color: #7a8795;
    font-size: 0.76rem;
}

.text-editor-toolbar .editor-font-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 35;
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: min(300px, 46vw);
    max-height: 300px;
    padding: 6px;
    overflow-y: auto;
    border: 1px solid #d7dee6;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 12px 30px rgba(52, 73, 94, 0.16);
}

.text-editor-toolbar .editor-font-dropdown[hidden] {
    display: none !important;
}

.text-editor-toolbar .editor-font-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 7px 9px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: #ffffff;
    color: #24313d;
    cursor: pointer;
    text-align: left;
}

.text-editor-toolbar .editor-font-option:hover {
    background: #f5f8fb;
    border-color: #d7dee6;
}

.text-editor-toolbar .editor-font-option.active {
    background: #eef5ff;
    border-color: #7fb1ff;
}

.text-editor-toolbar .editor-font-option-label {
    color: #5a6978;
}

.text-editor-toolbar .editor-mini-control .editor-select {
    min-width: 84px;
    max-width: 84px;
    height: 32px;
    min-height: 32px;
    padding-top: 0;
    padding-bottom: 0;
    line-height: 1.2;
}

.text-editor-toolbar .editor-color-control {
    position: relative;
    padding-right: 10px;
}

.text-editor-toolbar .editor-color-control input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.text-editor-toolbar .editor-color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid rgba(15, 23, 42, 0.75);
    background: #000000;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
    flex: 0 0 18px;
}

.editor-emoji-trigger[aria-expanded="true"] {
    background: #e7f0ff;
    border-color: #53a0fd;
    color: #1f5fa6;
}

.text-editor-toolbar .editor-emoji-picker {
    width: 100%;
    width: 100%;
    margin: 4px 0 0;
    box-sizing: border-box;
}

.text-editor-toolbar .editor-emoji-picker[hidden] {
    display: none !important;
}

.text-editor-toolbar .editor-emoji-picker:not([hidden]) {
    display: block !important;
}

.text-editor-toolbar .editor-emoji-picker .comment-emoji-grid {
    grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
}

@media (max-width: 768px) {
    .text-editor-toolbar .editor-emoji-trigger,
    .text-editor-toolbar .editor-separator:has(+ .editor-emoji-trigger),
    .text-editor-toolbar .editor-emoji-picker {
        display: none !important;
    }
}

.text-editor-image-panel {
    border-bottom: 1px solid #ddd;
    background: #f8fbff;
    padding: 0.75rem 0.85rem;
    min-width: 0;
}

.text-editor-image-panel[hidden] {
    display: none !important;
}

.text-editor-image-panel-head,
.text-editor-image-panel-row,
.text-editor-image-size-control,
.text-editor-image-align-control {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.text-editor-image-panel-head {
    justify-content: space-between;
    margin-bottom: 0.55rem;
    color: #2c3e50;
}

.text-editor-image-panel-close {
    border: 0;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 1.35rem;
    line-height: 1;
}

.text-editor-image-size-control {
    color: #334155;
    font-weight: 600;
    min-width: 0;
    flex: 1 1 auto;
    flex-wrap: nowrap;
}

.text-editor-image-size-control > span {
    flex: 0 0 auto;
}

.text-editor-image-size-control output {
    flex: 0 0 auto;
}

.text-editor-image-size-control input[type="range"] {
    flex: 1 1 auto;
    width: auto;
    min-width: 60px;
}

/* Поле "Название иллюстрации" в панели настройки изображения. */
.text-editor-image-caption-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1 1 auto;
    color: #334155;
    font-weight: 600;
    min-width: 0;
}

.text-editor-image-caption-control > span {
    flex: 0 0 auto;
}

.text-editor-image-caption-control input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
}

/* Подсказка при вставке: картинки из Word не переносятся вместе с текстом. */
.text-editor-paste-hint {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin: 0 0 0.45rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid #f0d48a;
    border-radius: 8px;
    background: #fff8e6;
    color: #6b5310;
    font-size: 0.86rem;
    line-height: 1.4;
}

.text-editor-paste-hint[hidden] {
    display: none;
}

.text-editor-paste-hint-close {
    flex: 0 0 auto;
    margin-left: auto;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

/* Кнопка удаления выбранного изображения/видео в панели настройки. */
.text-editor-image-panel .editor-btn.text-editor-image-delete {
    border-color: #f0b3ab;
    background: #fff5f4;
    color: #c0392b;
}

.text-editor-image-panel .editor-btn.text-editor-image-delete:hover {
    background: #fdecea;
}

.text-editor-selected-image {
    outline: 3px solid rgba(52, 152, 219, 0.7);
    outline-offset: 3px;
}

.text-editor-spoiler {
    position: relative;
    margin: 1rem 0;
    border: 1px solid #d8e3ee;
    border-radius: 16px;
    background: #f8fbff;
    overflow: hidden;
}

.text-editor-spoiler > summary {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    color: #1f2937;
    font-weight: 700;
    cursor: pointer;
    background: #eef4ff;
    list-style: none;
    border-radius: 14px 14px 0 0;
}

.text-editor-spoiler:not([open]) > summary {
    border-radius: 14px;
}

.text-editor-spoiler > summary::-webkit-details-marker {
    display: none;
}

.text-editor-spoiler > summary::before {
    content: none;
}

.text-editor-spoiler > summary::after {
    content: '▶';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    color: #4f46e5;
    font-size: 0.85em;
    margin-left: 0.35rem;
    transition: transform 0.2s ease;
}

.text-editor-spoiler[open] > summary::after {
    transform: rotate(90deg);
}

.text-editor-spoiler-content {
    padding: 1rem;
    background: #ffffff;
    border-top: 1px solid #d8e3ee;
    border-radius: 0 0 14px 14px;
}

.text-editor-spoiler-remove {
    flex: 0 0 auto;
    margin-left: auto;
    border: 1px solid #d8e3ee;
    border-radius: 999px;
    background: #ffffff;
    color: #b91c1c;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.38rem 0.65rem;
}

.text-editor-spoiler-remove:hover {
    background: #fff1f2;
    border-color: #fecdd3;
}

.text-editor-spoiler-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.58);
}

.text-editor-spoiler-dialog-overlay[hidden] {
    display: none !important;
}

.text-editor-spoiler-dialog {
    width: min(100%, 440px);
    max-height: min(calc(100dvh - 1.5rem), 760px);
    box-sizing: border-box;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1.35rem;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.text-editor-spoiler-dialog h3 {
    margin: 0 0 0.45rem;
    color: #172033;
    font-size: 1.25rem;
}

.text-editor-spoiler-dialog p {
    margin: 0 0 1rem;
    color: #64748b;
    line-height: 1.55;
}

.text-editor-spoiler-dialog input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 0.75rem 0.85rem;
    font-size: 1rem;
}

.text-editor-spoiler-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1rem;
}

.text-editor-link-dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.58);
}

.text-editor-link-dialog-overlay[hidden] {
    display: none !important;
}

.text-editor-link-dialog {
    width: min(100%, 460px);
    max-height: min(calc(100dvh - 1.5rem), 760px);
    min-width: 0;
    box-sizing: border-box;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1.35rem;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.text-editor-media-dialog {
    width: min(100%, 540px);
}

.text-editor-link-dialog.builder-button-dialog {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.text-editor-link-dialog.builder-button-dialog .builder-dialog-form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.text-editor-link-dialog.builder-button-dialog .builder-dialog-body {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.text-editor-link-dialog.builder-button-dialog .builder-dialog-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0;
    padding-top: 1rem;
    border-top: 1px solid #e7edf4;
    flex: 0 0 auto;
}

.text-editor-link-dialog.builder-button-dialog .builder-dialog-footer .btn {
    min-height: 44px;
}

.text-editor-link-dialog.builder-button-dialog .builder-button-dialog-preview-inner,
.text-editor-link-dialog.builder-button-dialog .builder-button-dialog-preview-inner > p {
    min-width: 0;
}

.text-editor-link-dialog h3 {
    margin: 0 0 0.45rem;
    color: #172033;
    font-size: 1.25rem;
}

.text-editor-link-dialog p {
    margin: 0 0 1rem;
    color: #64748b;
    line-height: 1.55;
}

.text-editor-link-dialog-field {
    display: grid;
    gap: 0.45rem;
    margin-bottom: 0.95rem;
    min-width: 0;
}

/* Класс-селекторы выше перебивают UA-правило [hidden]{display:none};
   возвращаем работу атрибута hidden для полей диалога и кнопок редактора. */
.text-editor-link-dialog-field[hidden],
.text-editor-image-panel .editor-btn[hidden],
.text-editor-media-align-buttons .editor-btn[hidden] {
    display: none !important;
}

.text-editor-link-dialog-field label,
.text-editor-link-dialog-label {
    color: #24384f;
    font-weight: 700;
    line-height: 1.4;
}

.text-editor-link-dialog input[type="text"],
.text-editor-link-dialog input[type="url"],
.text-editor-link-dialog input[type="file"],
.text-editor-link-dialog select {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 0.75rem 0.85rem;
    font-size: 1rem;
}

.text-editor-link-dialog .comment-admin-toggle {
    width: 100%;
    min-width: 0;
}

.text-editor-link-dialog input[type="file"] {
    padding: 0.7rem 0.85rem;
    background: #f8fafc;
    max-width: 100%;
}

.text-editor-link-dialog select {
    background: #ffffff;
}

.text-editor-link-dialog-error {
    margin-top: 0.25rem;
    color: #c0392b;
    font-size: 0.92rem;
    line-height: 1.45;
}

.text-editor-link-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1rem;
}

@media (max-width: 768px) {
    .text-editor-link-dialog-overlay {
        align-items: flex-start;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .text-editor-toolbar {
        gap: 0.65rem;
        padding: 0.7rem;
    }

    .text-editor-toolbar-main,
    .text-editor-toolbar-secondary {
        gap: 0.4rem;
        align-items: stretch;
    }

    .text-editor-toolbar-main > *,
    .text-editor-toolbar-secondary > * {
        min-width: 0;
    }

    .text-editor-toolbar .editor-font-control,
    .text-editor-toolbar .editor-font-picker,
    .text-editor-toolbar .editor-mini-control,
    .text-editor-toolbar .editor-color-control,
    .text-editor-toolbar .editor-size-control {
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    .text-editor-toolbar .editor-font-picker,
    .text-editor-toolbar .editor-font-trigger,
    .text-editor-toolbar .editor-font-control .editor-select,
    .text-editor-toolbar .editor-font-dropdown {
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    .text-editor-toolbar .editor-font-dropdown {
        max-height: min(44dvh, 280px);
    }

    .text-editor-toolbar .editor-size-control,
    .text-editor-toolbar .editor-mini-control,
    .text-editor-toolbar .editor-color-control {
        justify-content: space-between;
        white-space: normal;
        flex-wrap: wrap;
    }

    .text-editor-toolbar .editor-size-control {
        align-items: stretch;
    }

    .text-editor-toolbar .editor-size-control .editor-size-box {
        margin-left: auto;
    }

    .text-editor-image-panel {
        padding: 0.7rem;
    }

    .text-editor-image-panel-head {
        align-items: flex-start;
    }

    .text-editor-image-panel-row {
        flex-direction: column;
        align-items: stretch;
    }

    .text-editor-image-size-control {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
        min-width: 0;
    }

    .text-editor-image-size-control input[type="range"] {
        width: 100%;
    }

    .text-editor-image-align-control {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
        min-width: 0;
    }

    .text-editor-image-align-control .editor-btn,
    .text-editor-image-panel-row > .editor-btn {
        width: 100%;
        min-width: 0;
    }

    .text-editor-spoiler-dialog {
        width: 100%;
        max-height: calc(100dvh - 1rem);
        padding: 0.95rem;
        border-radius: 14px;
    }

    .text-editor-link-dialog {
        width: 100%;
        max-height: calc(100dvh - 1rem);
        padding: 0.95rem;
        border-radius: 14px;
    }

    .text-editor-link-dialog.builder-button-dialog {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .text-editor-link-dialog.builder-button-dialog .builder-dialog-form {
        height: auto;
        overflow: visible;
    }

    .text-editor-link-dialog.builder-button-dialog .builder-dialog-body {
        flex: 0 0 auto;
        overflow: visible;
    }

    .text-editor-spoiler-dialog-actions,
    .text-editor-link-dialog-actions {
        flex-direction: column;
    }

    .text-editor-spoiler-dialog-actions .btn,
    .text-editor-link-dialog-actions .btn {
        width: 100%;
    }

    .text-editor-link-dialog .comment-admin-toggle {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .text-editor-link-dialog.builder-button-dialog .builder-dialog-footer .btn {
        width: 100%;
        flex: 1 1 100%;
        justify-content: center;
    }

    .text-editor-content {
        max-height: min(52dvh, 420px);
    }
}

@media (max-width: 560px) {
    .text-editor-toolbar .editor-size-control {
        display: grid;
        grid-template-columns: 1fr;
        justify-content: stretch;
    }

    .text-editor-toolbar .editor-size-control .editor-size-box {
        width: 100%;
        margin-left: 0;
    }

    .text-editor-toolbar .editor-size-control .editor-size-input {
        width: calc(100% - 20px) !important;
        min-width: 0 !important;
        max-width: none !important;
        flex: 1 1 auto;
    }

    .text-editor-image-align-control {
        grid-template-columns: 1fr;
    }

    .text-editor-spoiler-dialog-overlay,
    .text-editor-link-dialog-overlay {
        padding: 0.5rem;
    }

    .text-editor-spoiler-dialog,
    .text-editor-link-dialog {
        padding: 0.85rem;
        border-radius: 12px;
    }

    .text-editor-link-dialog.builder-button-dialog {
        height: auto;
        max-height: none;
    }
}

.text-editor-content {
    min-height: 150px;
    padding: 12px;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.6;
    outline: none;
    overflow-y: auto;
    max-height: 500px;
    border: none;
    background: white;
}

.text-editor-content:focus {
    outline: 2px solid #3498db;
    outline-offset: -2px;
}

.text-editor-content p,
.text-editor-content div {
    margin: 0.5em 0;
}

.text-editor-content p:first-child,
.text-editor-content div:first-child {
    margin-top: 0;
}

.text-editor-content p:last-child,
.text-editor-content div:last-child {
    margin-bottom: 0;
}

.text-editor-content a {
    color: #2563eb;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.14em;
    word-break: break-word;
}

.text-editor-content a:hover {
    color: #1d4ed8;
}

.text-editor-content .page-builder-media-wrap {
    position: relative;
    display: block;
    width: var(--cpb-media-width, 100%);
    max-width: 100% !important;
    margin: 1rem 0;
    box-sizing: border-box;
    text-indent: 0 !important;
    clear: both;
}

.text-editor-content .page-builder-media-wrap.align-left {
    margin-left: 0;
    margin-right: auto;
}

.text-editor-content .page-builder-media-wrap.align-center {
    margin-left: auto;
    margin-right: auto;
}

.text-editor-content .page-builder-media-wrap.align-right {
    margin-left: auto;
    margin-right: 0;
}

.text-editor-content .page-builder-media-wrap.align-full {
    width: 100% !important;
    margin-left: 0;
    margin-right: 0;
}

.text-editor-content .page-builder-media-wrap img,
.text-editor-content .page-builder-media-wrap iframe {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    margin: 0;
    box-sizing: border-box;
    border-radius: 12px;
}

.text-editor-content .page-builder-media-link {
    display: block;
    max-width: 100%;
}

.text-editor-content .builder-media-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 3;
    width: 12px;
    cursor: ew-resize;
    background: rgba(37, 99, 235, 0.18);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.text-editor-content .builder-media-handle[data-resize-side="left"] {
    left: -6px;
}

.text-editor-content .builder-media-handle[data-resize-side="right"] {
    right: -6px;
}

.text-editor-content .page-builder-media-wrap:hover .builder-media-handle,
.text-editor-content .page-builder-media-wrap:focus .builder-media-handle {
    opacity: 1;
}

.text-editor-content blockquote {
    margin: 1rem 0;
    padding: 0.85rem 1rem;
    border-left: 4px solid #6366f1;
    border-radius: 0 12px 12px 0;
    background: #f5f7ff;
    color: #344256;
}

.text-editor-content blockquote > :first-child {
    margin-top: 0;
}

.text-editor-content blockquote > :last-child {
    margin-bottom: 0;
}

.text-editor-content ul,
.text-editor-content ol {
    margin: 0.9rem 0;
    padding-left: 1.65rem;
    list-style-position: outside;
}

.text-editor-content ul {
    list-style-type: disc;
}

.text-editor-content ol {
    list-style-type: decimal;
}

.text-editor-content :is(ul, ol) :is(ul, ol) {
    margin: 0.35rem 0 0.35rem 0.45rem;
}

.text-editor-content li {
    margin: 0.35rem 0;
    padding-left: 0.15rem;
}

.text-editor-content li::marker {
    color: #475569;
}

.text-editor-content li > :first-child {
    margin-top: 0;
}

.text-editor-content li > :last-child {
    margin-bottom: 0;
}

.text-editor-content li > p,
.text-editor-content li > div {
    margin: 0;
}

.text-editor-content li > p:only-child,
.text-editor-content li > div:only-child {
    display: inline;
}

@media (max-width: 768px) {
    .text-editor-content .page-builder-media-wrap,
    .text-editor-content .page-builder-media-wrap.align-full {
        width: var(--cpb-media-width-mobile, var(--cpb-media-width, 100%)) !important;
        max-width: 100% !important;
    }

    .text-editor-content .builder-media-handle {
        display: none;
    }
}

/* Автоотступ абзацев для редактора (красная строка) */
.text-editor-content.paragraph-indent :is(p, div):not(.text-editor-media):not(.text-editor-image):not(.text-editor-video):not(.text-editor-spoiler-content):not(.page-builder-media-wrap):not(.page-builder-video):not([align="center" i]):not([align="right" i]):not([style*="text-align:center" i]):not([style*="text-align: center" i]):not([style*="text-align:right" i]):not([style*="text-align: right" i]):not(:has(> .text-editor-media)):not(:has(> .text-editor-image)):not(:has(> .text-editor-video)):not(:has(> .text-editor-spoiler)):not(:has(> .page-builder-media-wrap)):not(:has(> .page-builder-video)) {
    text-indent: 1.5em !important;
}

.text-editor-content.paragraph-indent .text-editor-media,
.text-editor-content.paragraph-indent .text-editor-image,
.text-editor-content.paragraph-indent .text-editor-video,
.text-editor-content.paragraph-indent .page-builder-media-wrap,
.text-editor-content.paragraph-indent .page-builder-video,
.text-editor-content.paragraph-indent .text-editor-spoiler,
.text-editor-content.paragraph-indent .text-editor-spoiler-content,
.text-editor-content.paragraph-indent div:has(> .text-editor-media),
.text-editor-content.paragraph-indent div:has(> .text-editor-image),
.text-editor-content.paragraph-indent div:has(> .text-editor-video),
.text-editor-content.paragraph-indent div:has(> .page-builder-media-wrap),
.text-editor-content.paragraph-indent div:has(> .page-builder-video),
.text-editor-content.paragraph-indent div:has(> .text-editor-spoiler),
.text-editor-content.paragraph-indent [align="center" i] :is(p, div),
.text-editor-content.paragraph-indent [align="right" i] :is(p, div),
.text-editor-content.paragraph-indent [style*="text-align:center" i] :is(p, div),
.text-editor-content.paragraph-indent [style*="text-align: center" i] :is(p, div),
.text-editor-content.paragraph-indent [style*="text-align:right" i] :is(p, div),
.text-editor-content.paragraph-indent [style*="text-align: right" i] :is(p, div),
.text-editor-content.paragraph-indent blockquote,
.text-editor-content.paragraph-indent blockquote :is(p, div),
.text-editor-content.paragraph-indent :is(ul, ol, li),
.text-editor-content.paragraph-indent :is(ul, ol, li) :is(p, div) {
    text-indent: 0 !important;
}

/* Форматирование комментариев */
.comment-text {
    line-height: 1.7;
    /* Поддержка эмодзи */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

.comment-text.comment-text-emoji-only-single {
    font-size: 3rem;
    line-height: 1.08;
}

.comment-text.comment-text-emoji-only-few {
    font-size: 2rem;
    line-height: 1.12;
}

@media (max-width: 768px) {
    .comment-text.comment-text-emoji-only-single {
        font-size: 2.7rem;
    }

    .comment-text.comment-text-emoji-only-few {
        font-size: 1.8rem;
    }
}

/* Стили для текста книги - только для .book-text .text-content, не для описаний карточек */
.book-text h3 {
    text-align: center;
    margin-bottom: 2rem;
}

.book-text .text-content {
    line-height: 1.8;
    word-wrap: break-word;
}

/* Автоотступ абзацев (красная строка) - только для текста книги */
.book-text .text-content.paragraph-indent :is(p, div):not(.text-editor-media):not(.text-editor-image):not(.text-editor-video):not(.text-editor-spoiler-content):not([align="center" i]):not([align="right" i]):not([style*="text-align:center" i]):not([style*="text-align: center" i]):not([style*="text-align:right" i]):not([style*="text-align: right" i]):not(:has(> .text-editor-media)):not(:has(> .text-editor-image)):not(:has(> .text-editor-video)):not(:has(> .text-editor-spoiler)) {
    text-indent: 1.5em;
}

.book-text .text-content.paragraph-indent .text-editor-media,
.book-text .text-content.paragraph-indent .text-editor-image,
.book-text .text-content.paragraph-indent .text-editor-video,
.book-text .text-content.paragraph-indent .text-editor-spoiler,
.book-text .text-content.paragraph-indent .text-editor-spoiler-content,
.book-text .text-content.paragraph-indent div:has(> .text-editor-media),
.book-text .text-content.paragraph-indent div:has(> .text-editor-image),
.book-text .text-content.paragraph-indent div:has(> .text-editor-video),
.book-text .text-content.paragraph-indent div:has(> .text-editor-spoiler),
.book-text .text-content.paragraph-indent [align="center" i] :is(p, div),
.book-text .text-content.paragraph-indent [align="right" i] :is(p, div),
.book-text .text-content.paragraph-indent [style*="text-align:center" i] :is(p, div),
.book-text .text-content.paragraph-indent [style*="text-align: center" i] :is(p, div),
.book-text .text-content.paragraph-indent [style*="text-align:right" i] :is(p, div),
.book-text .text-content.paragraph-indent [style*="text-align: right" i] :is(p, div) {
    text-indent: 0;
}

/* Стили для текста книги - только для .book-text .text-content, не для описаний карточек */
.book-text .text-content strong,
.book-text .text-content b {
    font-weight: bold;
}

.book-text .text-content em,
.book-text .text-content i {
    font-style: italic;
}

.book-text .text-content u {
    text-decoration: underline;
}

.book-text .text-content del,
.book-text .text-content s,
.book-text .text-content strike {
    text-decoration: line-through;
}

.book-text .text-content span[style*="font-size"] {
    display: inline;
}

/* Стили для выравнивания текста - только для текста книги, не для описаний карточек */
.book-text .text-content div[style*="text-align"] {
    margin: 0.5em 0;
}

.book-text .text-content div[style*="text-align: center"] {
    text-align: center;
}

.book-text .text-content div[style*="text-align: right"] {
    text-align: right;
}

.book-text .text-content div[style*="text-align: justify"] {
    text-align: justify;
}

.description {
    line-height: 1.6;
    word-wrap: break-word;
}

.description strong,
.description b {
    font-weight: bold;
}

.description em,
.description i {
    font-style: italic;
}

.description u {
    text-decoration: underline;
}

.description del,
.description s,
.description strike {
    text-decoration: line-through;
}

.description span[style*="font-size"] {
    display: inline;
}

.description div[style*="text-align"] {
    margin: 0.5em 0;
}

.description div[style*="text-align: center"] {
    text-align: center;
}

.description div[style*="text-align: right"] {
    text-align: right;
}

.description div[style*="text-align: justify"] {
    text-align: justify;
}
/* Стили текущей обложки */
.current-cover-container {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid #dee2e6;
}

.current-cover {
    max-width: 200px;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    display: block;
    margin: 10px 0;
}

.current-cover-container p {
    margin: 0 0 10px 0;
    font-weight: bold;
    color: #495057;
}
/* Стили страницы циклов */
.cycles-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.cycles-page > main {
    flex: 1 0 auto;
}

.series-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.series-page > main {
    flex: 1 0 auto;
}

.payment-status-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.payment-status-page > main {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 120px 20px 48px;
}

.payment-status-page .footer {
    margin-top: auto;
}

.payment-status-card {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.cycles-section {
    padding: 40px 0;
}

.cycles-section h1 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: #2c3e50;
}

.cycles-list {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.cycle-item {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.cycle-header {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: flex-start;
}

.cycle-cover {
    flex-shrink: 0;
}

.cycle-cover img {
    width: auto;
    height: 225px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.cycle-info {
    flex: 1;
}

.cycle-info h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.8rem;
    color: #2c3e50;
}

.cycle-info h2 a {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s;
}

.cycle-info h2 a:hover {
    color: #3498db;
}

.cycle-type {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    font-style: italic;
}

.cycle-description {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.book-count {
    color: #3498db;
    font-weight: bold;
    margin: 0;
}

.cycle-books {
    border-top: 1px solid #eee;
    padding-top: 1.5rem;
}

.cycle-books h4 {
    margin: 0 0 1rem 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

.books-mini-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

.book-mini {
    text-align: center;
}

.book-mini a {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s;
}

.book-mini a:hover {
    transform: translateY(-3px);
}

.book-mini img {
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: contain;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 0.5rem;
}

.book-title {
    display: block;
    font-size: 0.85rem;
    line-height: 1.3;
    color: #2c3e50;
    margin-bottom: 0.25rem;
}

.book-number {
    display: block;
    font-size: 0.75rem;
    color: #3498db;
    font-weight: bold;
}

.no-cycles {
    text-align: center;
    padding: 3rem;
    color: #7f8c8d;
}

.no-cycles p {
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .cycle-header {
        flex-direction: column;
        text-align: center;
        align-items: center;
    }
    
    .cycle-cover {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        width: 100% !important;
        margin-bottom: 1rem;
        flex-shrink: 1 !important;
        text-align: center;
    }
    
    .cycle-cover img {
        width: auto !important;
        height: 180px;
        margin: 0 auto !important;
        display: block !important;
    }
    
    .cycles-section h1 {
        font-size: 2rem;
    }
    
    .books-mini-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .book-mini img {
        height: auto;
        max-height: 150px;
    }
}
/* Стили логотипа */
.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-img {
    height: 50px;
    width: auto;
    object-fit: contain;
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.logo-title {
    font-weight: bold;
    /* Динамические размер, цвет и шрифт задаются в dynamic_styles.php */
}

.logo-subtitle {
    opacity: 0.9;
    /* Динамические размер, цвет и шрифт задаются в dynamic_styles.php */
}

@media (max-width: 768px) {
    .logo-img {
        height: 40px;
    }
    
    .logo-title {
        font-size: 1.2rem;
    }
    
    .logo-subtitle {
        font-size: 0.75rem;
        word-wrap: break-word; /* Перенос длинных слов */
        overflow-wrap: break-word; /* Современный стандарт переноса */
        hyphens: auto; /* Автоматическая расстановка переносов */
        max-width: 100%; /* Не превышает ширину родителя */
    }
    
    /* Финальное правило для гарантии видимости гамбургера - должно быть последним */
    .hamburger,
    .header .hamburger,
    .nav .hamburger,
    .header .nav .hamburger,
    .container .nav .hamburger,
    .header .container .nav .hamburger {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Юридическая информация в футере на мобильных */
    .footer-legal-text {
        font-size: 0.8rem !important;
        margin-top: 0.8rem !important;
        line-height: 1.4 !important;
    }

    .private-message-external-backdrop {
        padding: 16px;
    }

    .private-message-external-dialog {
        width: 100%;
        border-radius: 16px;
    }

    .private-message-external-head {
        padding: 16px 16px 0;
    }

    .private-message-external-head h3 {
        font-size: 1.06rem;
    }

    .private-message-external-body {
        padding: 12px 16px 0;
        font-size: 0.93rem;
    }

    .private-message-external-url {
        margin-top: 12px;
        padding: 10px 11px;
        font-size: 0.83rem;
    }

    .private-message-external-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 16px;
    }

    .private-message-external-actions .btn {
        width: 100%;
        min-width: 0;
        font-size: 0.94rem;
    }
}
