:root {
    --bg-color: #f8f9fa;
    --text-color: #212529;
    --card-bg: #ffffff;
    --card-border: #dee2e6;
    --primary-color: #0d6efd;
    --primary-hover: #0b5ed7;
    --header-bg: transparent;
    --header-border: none;
    --modal-bg: rgba(0, 0, 0, 0.5);
    --modal-content-bg: #ffffff;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

html.dark-theme, body.dark-theme {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --card-bg: #1e1e1e;
    --card-border: #333333;
    --primary-color: #bb86fc;
    --primary-hover: #3700b3;
    --header-bg: transparent;
    --header-border: none;
    --modal-bg: rgba(0, 0, 0, 0.8);
    --modal-content-bg: #1e1e1e;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

html {
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Шлюз выбора языка */
.gateway-body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.gateway-container {
    text-align: center;
    padding: 2.5rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-width: 400px;
    width: 90%;
}

.gateway-container h1 {
    font-size: 1.5rem;
    margin-bottom: 2rem;
}

.gateway-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.lang-btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid var(--primary-color);
    background-color: transparent;
    color: var(--primary-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lang-btn:hover {
    background-color: var(--primary-color);
    color: #fff;
}

/* Шапка сайта */
.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: transparent;
    border-bottom: none;
    flex-shrink: 0;
    width: 100%;
}

.site-title {
    font-size: 1.2rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--text-color);
}

.header-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.icon-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 0.4rem 0.9rem;
    border-radius: 50px;
    cursor: pointer;
    color: var(--text-color);
    font-size: 0.85rem;
    box-shadow: var(--shadow);
}

.icon-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Сетка глав */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.5rem 1rem 2rem 1rem;
    flex: 1;
    width: 100%;
}

.section-title {
    margin-bottom: 1.5rem;
    font-size: 1.75rem;
}

.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.chapter-card {
    background-color: transparent;
    border: none;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    color: var(--text-color);
    box-shadow: none;
    transition: transform 0.2s ease;
    display: flex;
    flex-direction: column;
}

.chapter-card:hover {
    transform: translateY(-4px);
}

.chapter-cover-wrapper {
    position: relative;
    width: 100%;
    height: 350px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    background-color: var(--card-border);
}

.chapter-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chapter-cover-wrapper::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 45%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
    pointer-events: none;
}

.chapter-info {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1rem;
    z-index: 2;
}

.chapter-info h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* Экран читалки */
.reader-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0.75rem 0.75rem 0.75rem;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    height: calc(100vh - 65px);
    box-sizing: border-box;
    overflow: hidden;
    width: 100%;
}

.comic-view {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    cursor: pointer;
    overflow: hidden;
    min-height: 0;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* Стили изображения и защита от тач-подсветки */
.comic-image {
    border-radius: 4px;
    box-shadow: var(--shadow);
    transition: max-width 0.2s ease, max-height 0.2s ease, width 0.2s ease;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.comic-image.mode-full {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.comic-image.mode-classic {
    max-width: 95%;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Нижняя панель управления */
.reader-nav-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 900px;
    padding: 0.6rem 1.25rem;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    flex-shrink: 0;
    margin-top: 0.5rem;
}

.nav-btn {
    background-color: transparent;
    border: 1px solid var(--card-border);
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    color: var(--text-color);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
}

.nav-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.nav-btn.hidden {
    display: none !important;
}

.progress-btn {
    background: none;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
}

.progress-btn:hover {
    background-color: var(--card-border);
}

/* Модальное окно быстрого перехода по страницам */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--modal-content-bg);
    padding: 1.5rem;
    border-radius: 16px;
    max-width: 450px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

.pages-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: center;
}

.page-jump-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--card-border);
    background-color: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0.9rem;
    box-shadow: var(--shadow);
}

.page-jump-btn:hover, .page-jump-btn.active {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* Мобильные медиа-запросы (смартфоны) */
@media (max-width: 768px) {
    .site-header {
        padding: 0.75rem 0.75rem;
    }

    .header-controls {
        gap: 0.35rem;
    }

    .icon-btn {
        padding: 0.35rem 0.75rem;
        font-size: 0.78rem;
    }

    .site-title {
        font-size: 1.1rem;
    }

    .reader-container {
        padding: 0.25rem 0.5rem 0.5rem 0.5rem;
        height: calc(100vh - 55px);
    }

    .reader-nav-panel {
        width: 100%;
        max-width: 100%;
        padding: 0.5rem 0.75rem;
        margin-top: 0.4rem;
    }

    .nav-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.82rem;
    }

    .progress-btn {
        font-size: 0.88rem;
        padding: 0.4rem 0.5rem;
    }
}
