:root {
    --bg-color: #ffffff; --text-color: #000000;
    --link-color: #0055ff; --link-hover-color: #0033cc;
    --header-bg: #f4f4f4; --border-color: #e0e0e0;
    --card-bg: #ffffff; --secondary-text: #666666;
}
[data-theme="dark"] {
    --bg-color: #1a1a1a; --text-color: #ffffff;
    --link-color: #66a3ff; --link-hover-color: #99c2ff;
    --header-bg: #2d2d2d; --border-color: #444444;
    --card-bg: #2d2d2d; --secondary-text: #aaaaaa;
}

body { background-color: var(--bg-color); color: var(--text-color); font-family: 'Segoe UI', Roboto, sans-serif; margin: 0; padding: 0; display: flex; flex-direction: column; min-height: 100vh; transition: background-color 0.3s, color 0.3s; }
a { color: var(--link-color); text-decoration: none; transition: color 0.2s, text-decoration 0.2s; }
a:hover { color: var(--link-hover-color); text-decoration: underline; }

/* Шапка */
header { 
    background: var(--header-bg); 
    border-bottom: 1px solid var(--border-color); 
    position: sticky; 
    top: 0; 
    z-index: 1000; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.header-container { max-width: 1200px; margin: 0 auto; padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; box-sizing: border-box; width: 100%; }
.logo a { font-size: 1.5rem; font-weight: bold; text-decoration: none; text-transform: uppercase; }
.logo a:hover { opacity: 0.8; text-decoration: none; }
.header-right { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.category-links a { margin-left: 15px; font-weight: bold; color: var(--text-color); opacity: 0.8; text-transform: uppercase; }
.category-links a:hover { color: var(--link-color); opacity: 1; text-decoration: none; }
.controls { display: flex; align-items: center; gap: 15px; }
.controls button, .controls a.icon-btn { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-color); padding: 5px; transition: transform 0.2s; }
.controls button:hover, .controls a.icon-btn:hover { transform: scale(1.1); color: var(--link-color); text-decoration: none; }

/* Поиск */
.search-form { display: flex; }
.search-form input { padding: 6px 10px; border: 1px solid var(--border-color); border-radius: 4px 0 0 4px; background: var(--bg-color); color: var(--text-color); outline: none; }
.search-form button { padding: 6px 12px; border: 1px solid var(--border-color); border-left: none; border-radius: 0 4px 4px 0; background: var(--link-color); color: #fff; cursor: pointer; }
.search-form button:hover { background: var(--link-hover-color); }

/* Каркас - УМЕНЬШИЛИ margin с 30px до 20px */
.container { display: flex; flex: 1; max-width: 1200px; margin: 20px auto; width: 100%; gap: 30px; padding: 0 20px; box-sizing: border-box; }
main { flex: 3; }
aside { flex: 1; display: flex; flex-direction: column; gap: 30px; }
.text-secondary { color: var(--secondary-text); font-size: 0.9rem; }

/* Карточки статей (Сетка 2x2) */
.category-block { margin-bottom: 40px; }
/* Убираем отступ у последнего блока, чтобы не было дыры перед подвалом */
.category-block:last-child { margin-bottom: 0; }

.category-title { border-bottom: 2px solid var(--link-color); padding-bottom: 5px; margin-bottom: 20px; text-transform: uppercase; }
.articles-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }

@media (max-width: 768px) {
    .articles-grid { grid-template-columns: 1fr; }
    .container { flex-direction: column; }
}

.article-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; transition: box-shadow 0.3s; display: flex; flex-direction: column; }
.article-card:hover { box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.article-card-img-link { overflow: hidden; display: block; height: 220px; }
.article-card img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; }
.article-card:hover img { transform: scale(1.05); }

.article-card-content { padding: 15px; display: flex; flex-direction: column; flex-grow: 1; }
.article-card-title { font-size: 1.15rem; margin: 0 0 10px 0; line-height: 1.3; }
.article-card-title a { color: var(--text-color); transition: color 0.2s; }
.article-card:hover .article-card-title a { color: var(--link-hover-color); text-decoration: none; }
.article-card-excerpt { color: var(--secondary-text); font-size: 0.95rem; margin-bottom: 15px; flex-grow: 1; line-height: 1.4; }

.article-meta { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border-color); padding-top: 10px; font-size: 0.85rem; color: var(--secondary-text); }
.like-btn { cursor: pointer; font-size: 1.1rem; user-select: none; transition: transform 0.2s; }
.like-btn:hover { transform: scale(1.2); }

/* Сайдбар */
.widget { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; padding: 15px; margin-bottom: 20px; }
.widget:last-child { margin-bottom: 0; }
.widget h3 { margin-top: 0; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; font-size: 1.1rem; text-transform: uppercase; }
.widget-list { list-style: none; padding: 0; margin: 0; }
.widget-list li { margin-bottom: 10px; }
.widget-item { display: flex; gap: 10px; align-items: center; margin-bottom: 15px; }
.widget-item:last-child { margin-bottom: 0; }
.widget-item img { width: 60px; height: 60px; object-fit: cover; border-radius: 4px; }
.widget-item-title { font-size: 0.9rem; line-height: 1.2; }

/* Пагинация */
.pagination { display: flex; justify-content: center; gap: 10px; margin-top: 40px; flex-wrap: wrap; }
.pagination a, .pagination span { 
    padding: 8px 15px; 
    border: 1px solid var(--border-color); 
    border-radius: 4px; 
    color: var(--text-color); 
    text-decoration: none; 
    background: var(--card-bg); 
    transition: background 0.2s, color 0.2s; 
}
.pagination a:hover { background: var(--link-hover-color); color: #fff; border-color: var(--link-hover-color); text-decoration: none; }
.pagination .active { background: var(--link-color); color: #fff; border-color: var(--link-color); font-weight: bold; }

/* Полная статья (article.php) */
.single-article { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; padding: 30px; margin-bottom: 40px; }
.single-article .article-title { margin-top: 0; font-size: 2.2rem; line-height: 1.2; margin-bottom: 15px; }
.article-meta-info { margin-bottom: 25px; font-size: 0.95rem; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; display: flex; gap: 20px; flex-wrap: wrap; }
.article-main-image { margin-bottom: 30px; border-radius: 8px; overflow: hidden; text-align: center; }
.article-main-image img { max-width: 100%; height: auto; border-radius: 8px; }
.article-content { line-height: 1.7; font-size: 1.1rem; }
.article-content img { max-width: 100%; height: auto; border-radius: 5px; margin: 20px 0; }
.article-content h2, .article-content h3 { margin-top: 35px; margin-bottom: 15px; }

/* Блок действий: лайки и шеринг */
.article-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border-color); flex-wrap: wrap; gap: 20px; }
.article-like-big .like-btn { font-size: 1.3rem; padding: 8px 15px; border: 1px solid var(--border-color); border-radius: 8px; display: inline-block; background: var(--bg-color); }
.article-share { display: flex; gap: 10px; align-items: center; font-weight: bold; }
.share-btn { padding: 8px 12px; border-radius: 6px; color: #fff; text-decoration: none; font-size: 0.9rem; transition: opacity 0.2s; }
.share-btn:hover { opacity: 0.8; color: #fff; text-decoration: none; }
.share-vk { background: #0077FF; }
.share-max { background: #FF5722; } /* Цвет для кнопки MAX */
.share-tg { background: #229ED9; }
.share-wa { background: #25D366; }

/* Похожие статьи (Сетка из 3 колонок) */
.related-articles { margin-top: 40px; }
.related-articles h3 { border-bottom: 2px solid var(--link-color); padding-bottom: 5px; margin-bottom: 20px; text-transform: uppercase; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }

/* Страница контактов */
.contacts-wrapper { max-width: 600px; margin: 0 auto; background: var(--card-bg); padding: 30px; border-radius: 8px; border: 1px solid var(--border-color); box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
.contacts-title { text-align: center; margin-top: 0; text-transform: uppercase; border-bottom: 2px solid var(--link-color); padding-bottom: 10px; margin-bottom: 20px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: bold; font-size: 0.95rem; }
.form-control { width: 100%; padding: 10px 15px; border: 1px solid var(--border-color); border-radius: 5px; background: var(--bg-color); color: var(--text-color); font-family: inherit; font-size: 1rem; box-sizing: border-box; }
.form-control:focus { outline: none; border-color: var(--link-color); }
textarea.form-control { resize: vertical; min-height: 120px; }
.submit-btn { width: 100%; padding: 12px; background: var(--link-color); color: #fff; border: none; border-radius: 5px; font-size: 1.1rem; cursor: pointer; transition: background 0.3s; text-transform: uppercase; font-weight: bold; }
.submit-btn:hover { background: var(--link-hover-color); }
.alert { padding: 15px; border-radius: 5px; margin-bottom: 20px; text-align: center; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* Гамбургер-меню и адаптивность шапки */
.hamburger { display: none; background: none; border: none; font-size: 2rem; cursor: pointer; color: var(--text-color); padding: 0; line-height: 1; }
@media (max-width: 768px) {
    .hamburger { display: block; }
    .header-right { display: none; width: 100%; flex-direction: column; align-items: flex-start; padding-top: 15px; }
    .header-right.active { display: flex; }
    .category-links { display: flex; flex-direction: column; width: 100%; gap: 10px; margin-bottom: 15px; }
    .category-links a { margin-left: 0; display: block; padding: 5px 0; border-bottom: 1px solid var(--border-color); }
    .header-container { flex-wrap: wrap; }
    .controls { width: 100%; justify-content: space-between; margin-top: 10px; }
    .search-form { flex-grow: 1; margin-right: 15px; }
}

/* Хлебные крошки */
.breadcrumbs { margin-bottom: 20px; font-size: 0.9rem; color: var(--secondary-text); }
.breadcrumbs a { color: var(--link-color); font-weight: bold; }
.breadcrumbs a:hover { text-decoration: underline; }

/* Кнопка Наверх */
#scrollTopBtn { display: none; position: fixed; bottom: 30px; right: 30px; z-index: 999; font-size: 1.5rem; background: var(--link-color); color: white; border: none; cursor: pointer; width: 50px; height: 50px; border-radius: 50%; box-shadow: 0 4px 10px rgba(0,0,0,0.3); transition: background 0.3s, transform 0.3s; }
#scrollTopBtn:hover { background: var(--link-hover-color); transform: translateY(-5px); }
