:root {
    --bg-main: #f4f6f9;
    --bg-card: #ffffff;
    --text-main: #2d3748;
    --text-muted: #718096;
    --primary: #5a67d8;
    --primary-hover: #4c51bf;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
}

[data-theme="dark"] {
    --bg-main: #1a202c;
    --bg-card: #2d3748;
    --text-main: #f7fafc;
    --text-muted: #a0aec0;
    --border-color: #4a5568;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.2);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    margin: 0; 
    padding: 0;
    transition: background 0.3s, color 0.3s;
}

/* === ДВУХКОЛОНОЧНЫЙ КАРКАС (LAYOUT) === */
.app-layout {
    display: flex;
    max-width: 1440px;
    margin: 0 auto;
    position: relative;
}

/* ЛЕВЫЙ ВЕРТИКАЛЬНЫЙ САЙДБАР */
.sidebar {
    width: 300px;
    min-width: 300px;
    height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    padding: 25px 20px;
    box-sizing: border-box;
    overflow-y: auto;
    z-index: 200;
}

.close-sidebar { display: none; } /* Кнопка крестика для мобилок */
.mobile-navbar { display: none; } /* Верхняя плашка для mobile */

/* Логотип */
.logo { 
    font-size: 1.5rem; 
    font-weight: 800; 
    color: var(--text-main); 
    display: flex; 
    align-items: center; 
    gap: 4px; 
    letter-spacing: -0.5px;
}
.logo span { color: var(--primary); }
.domain-tag { 
    font-size: 0.85rem; 
    color: var(--text-muted); 
    font-weight: 400; 
    align-self: flex-end; 
    padding-bottom: 2px; 
}

/* Управление в сайдбаре */
.sidebar-controls { 
    margin: 25px 0; 
    display: flex; 
    flex-direction: column; 
    gap: 15px; 
}
.search-bar input {
    width: 100%; 
    padding: 10px 15px; 
    border-radius: 20px;
    border: 1px solid var(--border-color); 
    background: var(--bg-main);
    color: var(--text-main); 
    outline: none; 
    box-sizing: border-box;
}
.action-row { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    gap: 10px; 
}
.icon-btn { 
    background: none; 
    border: none; 
    font-size: 1.3rem; 
    cursor: pointer; 
}
.action-btn {
    background: var(--primary); 
    color: white; 
    border: none;
    padding: 10px 18px; 
    border-radius: 20px; 
    font-weight: 600; 
    cursor: pointer; 
    flex-grow: 1;
}
.action-btn:hover { background: var(--primary-hover); }

/* Дерево категорий (Аккордеон) */
.sidebar-menu { 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
}
.mega-group { 
    display: flex; 
    flex-direction: column; 
}

.mega-trigger, .mega-root {
    width: 100%; 
    text-align: left; 
    background: none; 
    border: none;
    padding: 12px 15px; 
    border-radius: 8px; 
    color: var(--text-main);
    font-size: 1rem; 
    font-weight: 600; 
    cursor: pointer;
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    transition: background 0.2s;
}
.mega-trigger:hover, .mega-root:hover, .mega-root.active { 
    background: var(--bg-main); 
}
.mega-root.active { color: var(--primary); }

.mega-trigger .arrow { 
    font-size: 0.75rem; 
    color: var(--text-muted); 
    transition: transform 0.2s; 
}
.mega-group.open .mega-trigger .arrow { transform: rotate(180deg); }

/* Список подкатегорий (скрыт по умолчанию) */
.sub-category-list {
    display: none;
    flex-direction: column;
    padding-left: 20px;
    margin-top: 4px;
    gap: 4px;
}
.mega-group.open .sub-category-list { display: flex; }

.filter-btn.sub-item {
    text-align: left; 
    background: none; 
    border: none;
    padding: 8px 12px; 
    border-radius: 6px; 
    color: var(--text-muted);
    font-size: 0.9rem; 
    font-weight: 500; 
    cursor: pointer; 
    transition: all 0.2s;
}
.filter-btn.sub-item:hover, .filter-btn.sub-item.active {
    color: var(--primary); 
    background: rgba(90, 103, 216, 0.05);
}

/* === ПРАВАЯ ОСНОВНАЯ ЗОНА КОНТЕНТА === */
.main-content {
    flex-grow: 1;
    padding: 30px;
    box-sizing: border-box;
    max-width: 1140px;
}

/* Шутка дня */
.joke-of-the-day {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white; 
    padding: 30px; 
    border-radius: 16px; 
    margin-bottom: 30px;
    position: relative; 
    box-shadow: 0 10px 20px rgba(118, 75, 162, 0.2); 
    cursor: pointer;
}
.jotd-badge {
    position: absolute; 
    top: -12px; 
    left: 20px; 
    background: #ecc94b;
    color: #1a202c; 
    padding: 4px 12px; 
    border-radius: 12px; 
    font-weight: bold; 
    font-size: 0.85rem;
}
#jotd-text { font-size: 1.3rem; line-height: 1.6; white-space: pre-line; margin-bottom: 20px; }
.jotd-footer { display: flex; justify-content: space-between; align-items: center; }

/* Плиточная сетка анекдотов (Masonry эффект) */
.masonry-grid { column-count: 3; column-gap: 20px; }
@media (max-width: 1100px) { .masonry-grid { column-count: 2; } }
@media (max-width: 750px) { .masonry-grid { column-count: 1; } }

/* Карточка анекдота */
.joke-card {
    background: var(--bg-card); 
    border: 1px solid var(--border-color);
    border-radius: 12px; 
    padding: 20px; 
    margin-bottom: 20px;
    break-inside: avoid; 
    box-shadow: var(--shadow); 
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.joke-card:hover { box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12); border-color: var(--primary); }
.card-header { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 12px; }
.card-text { font-size: 1.05rem; line-height: 1.5; white-space: pre-line; margin: 0 0 15px 0; }
.card-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border-color); padding-top: 12px; }
.card-actions { display: flex; gap: 10px; }
.card-action-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.9rem; }
.card-action-btn:hover { color: var(--primary); }

/* ЦВЕТНЫЕ ФОНЫ ДЛЯ КАТЕГОРИЙ (Светлая Тема) */
.joke-card.cat-classic { background: #fffcf4; border-color: #f3e5be; }
.joke-card.cat-it { background: #f0f7f4; border-color: #cce3d8; }
.joke-card.cat-stories { background: #f4f6fb; border-color: #d1daf2; }
.joke-card.cat-auto { background: #fff5f0; border-color: #fbdad0; }
.joke-card.cat-work { background: #fbf5ff; border-color: #edd5fb; }
.joke-card.cat-animal { background: #f7fbf0; border-color: #e5f0cc; }

/* ЦВЕТНЫЕ ФОНЫ ДЛЯ КАТЕГОРИЙ (Темная Тема) */
[data-theme="dark"] .joke-card.cat-classic { background: #3a3428; border-color: #5c4f39; }
[data-theme="dark"] .joke-card.cat-it { background: #23322e; border-color: #354f48; }
[data-theme="dark"] .joke-card.cat-stories { background: #252e3d; border-color: #3b485c; }
[data-theme="dark"] .joke-card.cat-auto { background: #3c2a22; border-color: #5c3e32; }
[data-theme="dark"] .joke-card.cat-work { background: #2e243a; border-color: #4a385c; }
[data-theme="dark"] .joke-card.cat-animal { background: #293322; border-color: #3f4f34; }

.joke-card.cat-classic .badge { background: rgba(217, 162, 11, 0.15); color: #b7860b; }
.joke-card.cat-it .badge { background: rgba(40, 167, 69, 0.15); color: #28a745; }
.joke-card.cat-stories .badge { background: rgba(0, 123, 255, 0.15); color: #007bff; }
.joke-card.cat-auto .badge { background: rgba(230, 92, 0, 0.15); color: #e65c00; }
.joke-card.cat-work .badge { background: rgba(128, 0, 255, 0.15); color: #8000ff; }
.joke-card.cat-animal .badge { background: rgba(102, 153, 0, 0.15); color: #669900; }
[data-theme="dark"] .joke-card .badge { filter: brightness(1.3); }

/* Рекламная карточка (Promo) */
.joke-card.promo-card { background: #fff5f5; border: 2px dashed #feb2b2; cursor: default; }
[data-theme="dark"] .joke-card.promo-card { background: #2d2222; border-color: #742a2a; }
.joke-card.promo-card .badge.promo-badge { background: #e53e3e; color: white; }
.promo-title { font-weight: bold; font-size: 1.1rem; margin-bottom: 8px; color: #c53030; }
[data-theme="dark"] .promo-title { color: #feb2b2; }
.promo-btn {
    display: inline-block; width: 100%; text-align: center; background: #e53e3e;
    color: white; text-decoration: none; padding: 8px 0; border-radius: 6px;
    font-weight: bold; font-size: 0.9rem; margin-top: 10px; transition: background 0.2s;
}
.promo-btn:hover { background: #c53030; }

/* Бэйджи общее */
.badge { padding: 3px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: bold; }

/* СКЕЛЕТОНЫ */
.skeleton-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; padding: 20px; margin-bottom: 20px; break-inside: avoid; box-shadow: var(--shadow); }
.skeleton-pulse { background: linear-gradient(90deg, var(--bg-main) 25%, var(--border-color) 50%, var(--bg-main) 75%); background-size: 200% 100%; animation: skeleton-loading 1.5s infinite linear; border-radius: 4px; }
@keyframes skeleton-loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-badge { width: 80px; height: 16px; margin-bottom: 15px; }
.skeleton-line { height: 14px; margin-bottom: 10px; width: 100%; }
.skeleton-line.short { width: 60%; margin-bottom: 20px; }
.skeleton-footer { border-top: 1px solid var(--border-color); padding-top: 12px; width: 50px; height: 16px; }

/* МОДАЛЬНЫЕ ОКНА */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: none; justify-content: center; align-items: center; z-index: 1000; }
.modal-overlay.active { display: flex; }
.modal-content { background: var(--bg-card); width: 90%; max-width: 600px; border-radius: 16px; position: relative; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); max-height: 85vh; overflow-y: auto; }
.close-modal { position: absolute; top: 15px; right: 20px; background: none; border: none; font-size: 2rem; color: var(--text-muted); cursor: pointer; }
.modal-body { padding: 30px; }
#modal-text { font-size: 1.25rem; line-height: 1.6; white-space: pre-line; margin: 20px 0; }
.modal-stats { display: flex; gap: 15px; margin-bottom: 25px; }
.vote-btn { border: none; padding: 10px 20px; border-radius: 8px; font-weight: bold; cursor: pointer; }
.vote-btn.like { background: #ebf8ff; color: #2b6cb0; }
.vote-btn.dislike { background: #fff5f5; color: #c53030; }

.comments-section { border-top: 1px solid var(--border-color); padding-top: 20px; }
.comments-list { max-height: 200px; overflow-y: auto; margin-bottom: 15px; }
.comment-item { background: var(--bg-main); padding: 10px 15px; border-radius: 8px; margin-bottom: 8px; font-size: 0.95rem; }
.comment-form { display: flex; gap: 10px; }
.comment-form input { flex-grow: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-main); color: var(--text-main); }
.comment-form button { background: var(--primary); color: white; border: none; padding: 10px 15px; border-radius: 8px; cursor: pointer; }

.form-group { margin-bottom: 15px; text-align: left; }
.form-group label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 0.95rem; }
.form-group textarea, .form-group select { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-main); color: var(--text-main); font-family: inherit; font-size: 1rem; box-sizing: border-box; outline: none; }
.form-group textarea { resize: vertical; }

/* === АДАПТИВНОСТЬ ДЛЯ МОБИЛЬНЫХ ЭКРАНОВ === */
@media (max-width: 950px) {
    .mobile-navbar {
        display: flex; 
        justify-content: space-between; 
        align-items: center;
        background: var(--bg-card); 
        padding: 15px 20px; 
        border-bottom: 1px solid var(--border-color);
        position: sticky; 
        top: 0; 
        z-index: 150; 
        box-shadow: var(--shadow);
    }
    .burger-btn { background: none; border: none; font-size: 1.6rem; color: var(--text-main); cursor: pointer; }
    
    .app-layout { flex-direction: column; }
    
    /* Скрытый выезжающий сайдбар */
    .sidebar {
        position: fixed; 
        top: 0; 
        left: -320px; 
        width: 300px; 
        height: 100vh;
        transition: left 0.3s ease; 
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
    }
    .sidebar.mobile-open { left: 0; }
    
    .close-sidebar {
        display: block; 
        position: absolute; 
        top: 15px; 
        right: 20px;
        background: none; 
        border: none; 
        font-size: 2rem; 
        color: var(--text-muted); 
        cursor: pointer;
    }
    .sidebar-header { display: block; margin-top: 20px; }
    .main-content { padding: 15px; }
}

/* === ТИПОГРАФИКА ДЛЯ ДЛИННЫХ СТАТЕЙ (ПУНКТ 3) === */
.article-full-view {
    text-align: left;
    padding: 10px 5px;
}

.article-modal-title {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.3;
    color: var(--text-main);
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 15px;
}

.article-modal-body {
    font-size: 1.15rem;
    line-height: 1.75; /* Увеличили межстрочный интервал для легкого чтения */
    color: var(--text-main);
    white-space: pre-line;
    letter-spacing: -0.1px;
}

/* Эффект красивой буквицы (первой буквы абзаца) */
.article-modal-body::first-letter {
    font-size: 2.8rem;
    font-weight: 800;
    float: left;
    color: var(--primary);
    line-height: 1;
    margin-right: 8px;
    margin-top: 4px;
}

/* === СТИЛИ ДЛЯ КВИЗ-ИГРЫ === */
.game-container {
    max-width: 650px;
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 30px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    text-align: left;
    
    /* ДОБАВИЛИ: Растягивает карточку поверх всех колонок, запрещая её резать */
    column-span: all; 
    -webkit-column-span: all; /* Поддержка для браузеров Safari/Chrome */
}


.game-progress {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: bold;
    margin-bottom: 10px;
}

.game-question {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 25px;
}

.game-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.game-opt-btn {
    width: 100%;
    text-align: left;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    padding: 15px 20px;
    border-radius: 10px;
    font-size: 1.05rem;
    color: var(--text-main);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.game-opt-btn:hover:not(:disabled) {
    background: var(--border-color);
    border-color: var(--text-muted);
}

/* Стили для проверки ответов */
.game-opt-btn.correct {
    background: #def7ec;
    border-color: #31c48d;
    color: #03543f;
}

.game-opt-btn.incorrect {
    background: #fde8e8;
    border-color: #f05252;
    color: #9b1c1c;
}

/* Кнопка дальше */
.game-next-btn {
    margin-top: 25px;
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
.game-next-btn:hover { background: var(--primary-hover); }

/* Результаты */
.game-results { text-align: center; padding: 20px 0; }
.game-results h2 { font-size: 2rem; color: var(--primary); margin-bottom: 10px; }
.game-results p { font-size: 1.2rem; margin-bottom: 25px; }

/* Дополнительные стили для расширения игры */
.game-timer {
    font-size: 1.1rem;
    font-weight: bold;
    color: #e53e3e;
    text-align: right;
    margin-bottom: 10px;
}
.difficulty-box {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}
.diff-btn {
    flex-grow: 1;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-main);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}
.diff-btn:hover { background: var(--border-color); }
