:root {
    --bg: #0D0D0D;
    --surface: #171717;
    --border: #262626;
    --text: #FFFFFF;
    --text-muted: #888888;
    --accent: #0066FF; /* Shimano Blue по умолчанию */
    --fallback-grad: linear-gradient(135deg, #1F1F1F, #0D0D0D);
    --pill-bg: rgba(255, 255, 255, 0.05);
    
    --font-heading: 'Bebas Neue', 'Oswald', Impact, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

/* Акцентные цвета */
[data-accent="orange"] { --accent: #FF5500; } /* Fox Racing */
[data-accent="red"] { --accent: #E3000F; }    /* RockShox */
[data-accent="green"] { --accent: #39FF14; }  /* DVO */
[data-accent="purple"] { --accent: #9D00FF; } /* Hope */

[data-theme="light"] {
    --bg: #F5F5F7;
    --surface: #FFFFFF;
    --border: #E5E5E5;
    --text: #0D0D0D;
    --text-muted: #666666;
    --fallback-grad: linear-gradient(135deg, #E5E5E5, #F5F5F7);
    --pill-bg: rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; transition: font-size 0.2s ease; scroll-behavior: smooth; }
body {
    background-color: var(--bg); color: var(--text);
    font-family: var(--font-body); line-height: 1.5;
    overflow-x: hidden; transition: background-color 0.3s, color 0.3s;
    display: flex; flex-direction: column; min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
main { flex-grow: 1; }

img, video, svg { max-width: 100%; height: auto; }
p, h1, h2, h3, a, span, code { overflow-wrap: break-word; word-break: break-word; }

h1, h2, h3, h4, h5, h6, .logo, .tab-btn, .card-title, .article-title, .card-category, .sidebar-header h3, .setting-btn {
    font-weight: 400; 
}

/* Умная плавающая шапка */
.header {
    position: sticky; top: 0; z-index: 900;
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--border); background: var(--bg);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.logo {
    display: flex; align-items: center; gap: 10px;
    font-family: var(--font-heading); font-size: 2.1rem; 
    color: var(--text); text-decoration: none; letter-spacing: 1px;
    transition: opacity 0.2s;
}
.logo:hover { opacity: 0.8; }
.header-controls { display: flex; align-items: center; gap: 16px; }

/* Иконки в шапке */
.icon-btn {
    background: none; border: none; cursor: pointer; color: var(--text);
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; transition: color 0.2s;
}
.icon-btn svg { width: 24px; height: 24px; transition: transform 0.4s ease; }
.icon-btn:hover { color: var(--accent); }

.icon-menu { display: none; }
.icon-gear { display: block; }
.icon-btn:hover .icon-gear { transform: rotate(90deg); }

/* Адаптив Шапки */
@media (max-width: 767px) {
    .header { padding: 12px 16px; }
    .logo { font-size: 1.5rem; gap: 8px; }
    .logo svg { width: 30px; height: 22px; }
    .icon-gear { display: none; }
    .icon-menu { display: block; }
}

/* Табы-Таблетки */
.desktop-tabs {
    display: flex; gap: 8px; padding: 15px 20px;
    overflow-x: auto; border-bottom: 1px solid var(--border);
}
.desktop-tabs::-webkit-scrollbar { display: none; }
.mobile-tabs-group { display: none; } 

@media (max-width: 767px) {
    .desktop-tabs { display: none; }
    .mobile-tabs-group { display: block; } 
}

.tab-btn {
    font-family: var(--font-heading); font-size: 1.1rem; letter-spacing: 1px;
    background: var(--pill-bg); color: var(--text-muted);
    border: none; padding: 8px 20px; border-radius: 30px;
    cursor: pointer; white-space: nowrap; transition: all 0.3s ease;
}
.tab-btn:hover { background: rgba(var(--accent-rgb), 0.1); color: var(--accent); }
.tab-btn.active { background: var(--accent); color: #FFF; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); }

/* Сетка постов (КЛАССИКА - БЛОКИ) */
.container { padding: 24px 20px; max-width: 1200px; margin: 0 auto; width: 100%; }
.grid { display: grid; grid-template-columns: 1fr; gap: 24px; }

@media (min-width: 768px) {
    .grid { grid-template-columns: repeat(2, 1fr); }
    .card.hero { grid-column: 1 / 2; grid-row: span 2; display: flex; flex-direction: column; }
    .card.hero .card-img-wrap { aspect-ratio: auto; flex-grow: 1; min-height: 200px; }
    .card.hero .card-title { font-size: 2.2rem; }
}

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; text-decoration: none; color: var(--text);
    display: flex; flex-direction: column; height: 100%;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2); border-color: var(--accent); }
[data-theme="light"] .card:hover { box-shadow: 0 12px 30px rgba(0, 0, 0, 0.05); }

.card-img-wrap {
    width: 100%; aspect-ratio: 2 / 1; overflow: hidden;
    border-radius: 8px 8px 0 0; border-bottom: 1px solid var(--border);
    background: var(--fallback-grad); display: flex; align-items: center; justify-content: center;
}
.card-img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.card:hover .card-img { transform: scale(1.04); }
.fallback-svg { opacity: 0.5; width: 88px; height: 64px; }

.card-content { padding: 16px 20px; display: flex; flex-direction: column; flex-grow: 1; }
.card-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.card-category { font-family: var(--font-heading); font-size: 1rem; letter-spacing: 1px; background: rgba(128, 128, 128, 0.15); color: var(--accent); padding: 4px 10px; border-radius: 4px; text-transform: uppercase; font-weight: 500; }
.card-meta .date-time { font-size: 0.85rem; color: var(--text-muted); }
.card-title { font-family: var(--font-heading); font-size: 1.8rem; line-height: 1.1; margin-bottom: 8px; letter-spacing: 0.5px; transition: color 0.2s ease; }
.card:hover .card-title { color: var(--accent); }
.card-excerpt { font-size: 0.95rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 0; }

/* РЕЖИМ КОМПАКТ (СПИСОК) */
.grid.list-view { display: flex; flex-direction: column; gap: 16px; }
.grid.list-view .card, .grid.list-view .card.hero { 
    flex-direction: row; align-items: stretch; min-height: 140px; 
    grid-column: auto; grid-row: auto; 
}
.grid.list-view .card-img-wrap, .grid.list-view .card.hero .card-img-wrap { 
    width: 250px; max-width: 30%; flex-shrink: 0; 
    border-right: 1px solid var(--border); border-bottom: none; border-radius: 8px 0 0 8px; 
    aspect-ratio: auto; min-height: auto;
}
.grid.list-view .card-title, .grid.list-view .card.hero .card-title { font-size: 1.5rem; }

@media (max-width: 767px) {
    .grid.list-view { gap: 8px; }
    .grid.list-view .card, .grid.list-view .card.hero { 
        flex-direction: row; padding: 6px; align-items: center; min-height: auto;
    }
    .grid.list-view .card-img-wrap, .grid.list-view .card.hero .card-img-wrap { 
        width: 70px; height: 70px; max-width: 70px; 
        border-radius: 6px; border-right: none; border-bottom: none; flex-shrink: 0;
    }
    .grid.list-view .card-content { padding: 0 0 0 10px; justify-content: center; }
    .grid.list-view .card-title, .grid.list-view .card.hero .card-title { 
        font-size: 1.1rem; margin-bottom: 2px; line-height: 1.15;
    }
    .grid.list-view .card-excerpt, .grid.list-view .card.hero .card-excerpt { display: none; }
    .grid.list-view .card-meta { margin-bottom: 4px; gap: 6px; }
    .grid.list-view .card-category { font-size: 0.75rem; padding: 2px 6px; }
    .grid.list-view .date-time { font-size: 0.75rem; }
}

/* Страница Статьи */
.progress-bar { position: fixed; top: 0; left: 0; height: 3px; background: var(--accent); width: 0%; z-index: 1000; transition: width 0.1s ease-out; }
.floating-back {
    position: fixed; top: 24px; left: 24px; z-index: 100; display: flex; align-items: center; gap: 8px;
    background: rgba(23, 23, 23, 0.7); backdrop-filter: blur(8px); border: 1px solid var(--border); color: var(--text);
    padding: 8px 16px; border-radius: 30px; text-decoration: none; font-weight: 500; font-size: 0.9rem; transition: all 0.2s;
}
[data-theme="light"] .floating-back { background: rgba(255, 255, 255, 0.8); }
.floating-back:hover { color: var(--accent); border-color: var(--accent); transform: translateX(-3px); }
.floating-back svg { width: 16px; height: 16px; }

.article-page .article-header { display: none; }
@media (max-width: 1000px) {
    .floating-back { position: static; display: inline-flex; margin: 20px 20px 0; background: transparent; border-color: transparent; padding: 0; }
    /* ИСПРАВЛЕННОЕ МЕСТО: добавлено space-between для выравнивания */
    .article-page .article-header { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border);}
}
.article-container { max-width: 720px; margin: 0 auto; padding: 40px 20px 80px; }
.article-title { font-family: var(--font-heading); font-size: 3.5rem; line-height: 1.05; margin-bottom: 16px; letter-spacing: 0px; }
.article-header-meta { margin-bottom: 32px; font-size: 0.95rem; color: var(--text-muted); display: flex; gap: 12px; align-items: center;}
.article-cover-wrap { width: 100%; border-radius: 8px; overflow: hidden; margin-bottom: 40px; background: var(--fallback-grad); display: flex; justify-content: center; align-items: center; }
.article-cover { width: 100%; max-height: 500px; object-fit: cover; display: block; }

.article-body { font-size: 1.15rem; line-height: 1.7; color: var(--text); }
.article-body p { margin-bottom: 1.2em; }
.article-body h2, .article-body h3 { font-family: var(--font-heading); margin: 1.5em 0 0.5em; letter-spacing: 0.5px; }
.article-body h2 { font-size: 2.2rem; }
.article-body ul, .article-body ol { margin-bottom: 1.2em; padding-left: 20px; }
.article-body li { margin-bottom: 0.5em; }

/* Читательский Сайдбар */
.sidebar {
    position: fixed; top: 0; right: -100%;
    width: 100%; max-width: 320px; height: 100vh; background: var(--surface); border-left: 1px solid var(--border);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1); z-index: 1000; padding: 24px;
    overflow-y: auto; font-family: var(--font-body); display: flex; flex-direction: column;
}
.sidebar.open { right: 0; box-shadow: -10px 0 40px rgba(0,0,0,0.3); }
.sidebar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.sidebar-header h3 { font-family: var(--font-heading); font-size: 1.8rem; letter-spacing: 1px; margin: 0; }
.overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.6); opacity: 0; pointer-events: none; transition: opacity 0.3s; z-index: 999; backdrop-filter: blur(3px);
}
.sidebar.open ~ .overlay { opacity: 1; pointer-events: auto; }

.setting-group { margin-bottom: 24px; }
.setting-group label { display: block; margin-bottom: 8px; font-size: 0.85rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 1px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.setting-btn {
    flex: 1; padding: 10px; background: var(--pill-bg); color: var(--text);
    border: 1px solid var(--border); border-radius: 6px; font-family: var(--font-heading);
    font-size: 1.2rem; cursor: pointer; transition: all 0.2s; letter-spacing: 1px; min-width: 60px;
}
.setting-btn:hover { border-color: var(--accent); }
.setting-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.mobile-tabs-layout { display: flex; flex-wrap: wrap; gap: 8px; }
.mobile-tabs-layout .tab-full-width { flex: 1 1 100%; }
.mobile-tabs-layout .tab-half-width { flex: 1 1 calc(50% - 4px); }
.mobile-tabs-layout .tab-btn { border-radius: 6px; padding: 10px; border: 1px solid var(--border); font-size: 1.2rem; }
.mobile-tabs-layout .tab-btn:hover { border-color: var(--accent); }
.mobile-tabs-layout .tab-btn.active { border-color: var(--accent); background: var(--accent); color: #FFF; }

/* Кнопка Telegram в сайдбаре */
.tg-sidebar-btn {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    background: #000; border: 2px solid var(--accent); border-radius: 8px;
    padding: 10px 16px; text-decoration: none; margin-bottom: 24px;
    transition: all 0.3s ease;
}
.tg-sidebar-btn:hover { background: #111; box-shadow: 0 4px 15px rgba(0,0,0,0.4); transform: translateY(-2px); }
.tg-icon-wrap { width: 28px; height: 28px; color: var(--accent); display: flex; }
.tg-icon-wrap svg { width: 100%; height: 100%; fill: currentColor; }
.tg-sidebar-btn .tg-text {
    font-family: var(--font-heading); font-size: 1.3rem; color: #FFF; letter-spacing: 1px; font-weight: 400;
}

/* Разделитель блоков сайдбара */
.sidebar-divider { border: none; border-top: 1px solid var(--border); margin: 0 0 24px 0; }

/* Выбор акцентного цвета */
.color-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.color-btn { 
    width: 32px; height: 32px; border-radius: 50%; background: var(--c); 
    border: 2px solid transparent; cursor: pointer; transition: transform 0.2s; 
}
.color-btn:hover { transform: scale(1.1); }
.color-btn.active { border-color: var(--bg); outline: 2px solid var(--c); transform: scale(1.1); }

/* Футер и Админка */
.site-footer {
    text-align: center; padding: 40px 20px; font-size: 0.85rem; color: var(--text-muted);
    border-top: 1px solid var(--border); margin-top: auto;
}
@media (max-width: 767px) { .site-footer { padding: 20px 10px; margin-top: 20px; } }

.sidebar-footer { margin-top: auto; padding-top: 30px; text-align: center; }
.admin-link { 
    display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); 
    text-decoration: none; font-size: 0.85rem; transition: color 0.2s; font-weight: 500; text-transform: uppercase; letter-spacing: 1px;
}
.admin-link:hover { color: var(--accent); }
.admin-link svg { width: 16px; height: 16px; }