* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    display: flex;
    min-height: 100vh;
    background: #f8f9fa;
    color: #333;
    position: relative;
}

/* Сайдбар (дерево навигации) */
#sidebar {
    width: 300px;
    background: #2c3e50;
    color: #ecf0f1;
    padding: 20px 0;
    transition: transform 0.3s ease;
    overflow-y: auto;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0,0,0,0.2);
}

.sidebar-hidden {
    transform: translateX(-100%);
}

.sidebar-visible {
    transform: translateX(0);
}

/* Заголовок сайдбара */
.sidebar-header {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 15px 20px 15px;
    border-bottom: 1px solid #34495e;
    margin-bottom: 15px;
    position: relative;
}

.sidebar-header-content {
    width: calc(100% - 40px);
    margin-right: 40px;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #ecf0f1;
    line-height: 1.2;
    width: 100%;
}

.sidebar-header .subtitle {
    font-size: 0.9rem;
    color: #bdc3c7;
    font-weight: 400;
    margin-top: 5px;
    opacity: 0.8;
    width: 100%;
}

.sidebar-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: #ecf0f1;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 3px;
    transition: background-color 0.3s;
}

.sidebar-close-btn:hover {
    background-color: #34495e;
}

/* Меню постов */
.posts-menu {
    list-style: none;
    display: none;
}

.posts-menu li {
    margin: 5px 0;
}

.posts-menu a {
    display: block;
    padding: 10px 20px;
    color: #bdc3c7;
    text-decoration: none;
    transition: all 0.3s;
    border-left: 3px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.posts-menu a:hover {
    background: #34495e;
    color: #fff;
    border-left: 3px solid #3498db;
}

/* Стиль для активного пункта меню */
.posts-menu a.active {
    background: #3498db !important;
    color: white !important;
    border-left: 3px solid #e74c3c !important;
}

/* Стиль для ссылки на главную страницу */
.posts-menu a.main-page-link {
    background: #34495e;
    color: #fff;
    border-left: 3px solid #3498db;
    font-weight: 600;
}

.posts-menu a.main-page-link:hover,
.posts-menu a.main-page-link.active {
    background: #2c3e50;
    border-left: 3px solid #e74c3c;
}

.posts-menu a.main-page-link.active {
    background: #3498db !important;
}

/* Кнопка показа сайдбара */
.sidebar-toggle-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    background: #3498db;
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 20px;
    transition: opacity 0.3s ease;
}

/* На десктопе */
@media (min-width: 769px) {
    .sidebar-toggle-btn {
        opacity: 0;
        pointer-events: none;
    }
    
    .sidebar-hidden ~ .sidebar-toggle-btn {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Область контента */
#content {
    flex: 1;
    padding: 40px;
    margin-left: 300px;
    transition: margin-left 0.3s ease;
    max-width: 800px;
}

.content-fullwidth {
    margin-left: 0;
}

/* Посты */
.post {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.post h1 {
    color: #2c3e50;
    margin-bottom: 20px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
    font-size: 2rem;
}

.post h2 {
    color: #2c3e50;
    margin: 25px 0 15px 0;
    font-size: 1.5rem;
}

.post h3 {
    color: #2c3e50;
    margin: 20px 0 12px 0;
    font-size: 1.25rem;
}

.post p {
    line-height: 1.6;
    margin-bottom: 15px;
    color: #555;
    font-size: 1rem;
}

.post strong {
    color: #2c3e50;
    font-weight: 600;
}

.post em {
    color: #7f8c8d;
    font-style: italic;
}

.post ul, .post ol {
    margin: 15px 0;
    padding-left: 20px;
}

.post li {
    margin: 8px 0;
    line-height: 1.5;
    color: #555;
}

.post blockquote {
    border-left: 4px solid #3498db;
    padding-left: 20px;
    margin: 20px 0;
    color: #7f8c8d;
    font-style: italic;
}

.post code {
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #e74c3c;
    font-size: 0.9rem;
}

.post pre {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 20px 0;
}

.post pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: 0.9rem;
}

/* Индикаторы загрузки */
.loading {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
    font-size: 1.1rem;
}

.loading::after {
    content: '...';
    animation: loading 1.5s infinite;
}

.menu-loading {
    padding: 20px;
    text-align: center;
    color: #bdc3c7;
    font-size: 1rem;
}

.main-loading {
    text-align: center;
    padding: 60px 40px;
    color: #7f8c8d;
    font-size: 1.2rem;
}

@keyframes loading {
    0%, 33% { content: '.'; }
    34%, 66% { content: '..'; }
    67%, 100% { content: '...'; }
}

/* Затемнение фона */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.overlay-active {
    display: block;
}

/* Специальные стили для главной страницы */
.main-page .post {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.main-page .post h1,
.main-page .post h2,
.main-page .post h3 {
    color: white;
    border-bottom-color: rgba(255,255,255,0.3);
}

.main-page .post p {
    color: rgba(255,255,255,0.9);
}

/* Стили для изображений в постах */
.post img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 20px 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.post img:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

/* Выравнивание изображений */
.post img.center {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.post img.left {
    float: left;
    margin: 0 20px 10px 0;
    max-width: 50%;
}

.post img.right {
    float: right;
    margin: 0 0 10px 20px;
    max-width: 50%;
}

/* Очистка float */
.post:after {
    content: "";
    display: table;
    clear: both;
}

/* Подписи к изображениям */
.post .image-caption {
    text-align: center;
    font-style: italic;
    color: #7f8c8d;
    margin-top: -15px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin: 20px 0;
}

.image-grid img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 5px;
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    #sidebar {
        width: 280px;
        box-shadow: 2px 0 15px rgba(0,0,0,0.3);
    }
    
    .sidebar-header {
        padding: 10px 15px 10px;
    }
    
    .sidebar-header-content {
        width: calc(100% - 35px);
        margin-right: 35px;
    }
    
    .sidebar-header h2 {
        font-size: 1.3rem;
    }
    
    .sidebar-header .subtitle {
        font-size: 0.8rem;
    }
    
    .sidebar-close-btn {
        top: 10px;
        right: 10px;
        font-size: 18px;
    }
    
    #content {
        margin-left: 0;
        padding: 20px;
        padding-top: 80px;
    }
    
    .post {
        padding: 20px;
    }
    
    .post h1 {
        font-size: 1.5rem;
    }
    
    .post h2 {
        font-size: 1.25rem;
    }
    
    .post h3 {
        font-size: 1.1rem;
    }
    
    .post img.left,
    .post img.right {
        float: none;
        margin: 20px auto;
        max-width: 100%;
        display: block;
    }
}

/* Утилиты */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}