:root {
    /* Цветовая палитра */
    --bg-color: #0b0f19;
    --surface-color: rgba(22, 27, 34, 0.6);
    --surface-border: rgba(255, 255, 255, 0.08);
    
    /* Акценты: Синий и Пурпурный */
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    
    /* Текст */
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --text-heading: #ffffff;
    
    /* Шрифты */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    /* Размеры */
    --sidebar-width: 300px;
    --header-height: 60px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.08) 0%, transparent 50%);
    background-attachment: fixed;
}

/* Скроллбар */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar (Glassmorphism) */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--surface-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
}

.logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--surface-border);
    gap: 12px;
}

.logo h2 {
    font-size: 1.2rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
}

/* ToC Navigation */
.toc-nav ul {
    list-style: none;
}

.toc-nav li {
    margin-bottom: 8px;
}

.toc-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    display: block;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}

.toc-nav a:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.toc-nav a.active {
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.1);
    border-left-color: var(--accent-blue);
}

.toc-nav .toc-h3 {
    padding-left: 24px;
    font-size: 0.85rem;
}

/* Main Content */
.content-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--header-height);
    background: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.menu-btn {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    display: none;
    padding: 8px;
    border-radius: 6px;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.github-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--surface-border);
    transition: all 0.2s ease;
}

.github-link:hover {
    border-color: var(--accent-purple);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.2);
    color: #fff;
}

.content {
    padding: 40px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* Loader */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 50vh;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top-color: var(--accent-blue);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Markdown Styles */
.markdown-body {
    color: var(--text-main);
}

.markdown-body h1, 
.markdown-body h2, 
.markdown-body h3, 
.markdown-body h4 {
    color: var(--text-heading);
    margin-top: 2em;
    margin-bottom: 1em;
    font-weight: 600;
    line-height: 1.25;
}

.markdown-body h1 {
    font-size: 2.5rem;
    margin-top: 0;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.markdown-body h2 {
    font-size: 1.75rem;
    border-bottom: 1px solid var(--surface-border);
    padding-bottom: 0.3em;
}

.markdown-body h3 {
    font-size: 1.25rem;
}

.markdown-body p {
    margin-bottom: 1.2em;
}

.markdown-body a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: color 0.2s;
}

.markdown-body a:hover {
    color: var(--accent-purple);
    text-decoration: underline;
}

.markdown-body ul, 
.markdown-body ol {
    margin-bottom: 1.2em;
    padding-left: 2em;
}

.markdown-body li {
    margin-bottom: 0.5em;
}

/* Code blocks */
.markdown-body code {
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.85em;
    color: #e2e8f0;
}

.markdown-body pre {
    background: #0d1117;
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    padding: 16px;
    overflow: auto;
    margin-bottom: 1.5em;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.markdown-body pre:hover {
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.1);
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
    font-size: 0.9em;
    color: #c9d1d9;
}

/* Copy button for code blocks */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-muted);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    font-family: var(--font-sans);
}

.markdown-body pre:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.copy-btn.copied {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
}

/* Blockquotes */
.markdown-body blockquote {
    border-left: 4px solid var(--accent-purple);
    padding-left: 1em;
    color: var(--text-muted);
    margin-bottom: 1.5em;
    background: rgba(139, 92, 246, 0.05);
    padding: 1em;
    border-radius: 0 8px 8px 0;
}

/* Tables */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5em;
}

.markdown-body th, 
.markdown-body td {
    border: 1px solid var(--surface-border);
    padding: 8px 12px;
    text-align: left;
}

.markdown-body th {
    background: rgba(255, 255, 255, 0.03);
    font-weight: 600;
}

/* Images */
.markdown-body img {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid var(--surface-border);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
    }
    
    .content-wrapper {
        margin-left: 0;
    }
    
    .menu-btn {
        display: block;
    }
    
    .content {
        padding: 24px 16px;
    }
}

/* --- New Features --- */

/* Reading Progress Bar */
.progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    z-index: 1000;
}

.progress-bar {
    height: 100%;
    background: var(--accent-gradient);
    width: 0%;
    box-shadow: 0 0 10px var(--accent-blue), 0 0 5px var(--accent-purple);
    transition: width 0.1s ease-out;
}

/* Back to Top Button */
.back-to-top-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface-color);
    backdrop-filter: blur(8px);
    border: 1px solid var(--surface-border);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 90;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.back-to-top-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

/* Fade In Animation */
.fade-in-content {
    animation: fadeIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes fadeIn {
    0% {
        opacity: 0;
        transform: translateY(15px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* GitHub Markdown Alerts (Note, Warning, etc.) */
.markdown-body .markdown-alert {
    padding: 16px;
    margin-bottom: 16px;
    border-left: 4px solid;
    border-radius: 0 8px 8px 0;
    background: rgba(255, 255, 255, 0.02);
}

.markdown-body .markdown-alert p {
    margin-bottom: 0;
}

.markdown-body .markdown-alert p + p {
    margin-top: 8px;
}

.markdown-body .markdown-alert-title {
    display: flex;
    align-items: center;
    font-weight: 600;
    margin-bottom: 8px !important;
    font-size: 1.1em;
}

.markdown-body .markdown-alert-title svg {
    margin-right: 8px;
    fill: currentColor;
}

/* Colors for different alert types */
.markdown-body .markdown-alert-note {
    border-left-color: #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}
.markdown-body .markdown-alert-note .markdown-alert-title {
    color: #3b82f6;
}

.markdown-body .markdown-alert-tip {
    border-left-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}
.markdown-body .markdown-alert-tip .markdown-alert-title {
    color: #10b981;
}

.markdown-body .markdown-alert-important {
    border-left-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.05);
}
.markdown-body .markdown-alert-important .markdown-alert-title {
    color: #8b5cf6;
}

.markdown-body .markdown-alert-warning {
    border-left-color: #f59e0b;
    background: rgba(245, 158, 11, 0.05);
}
.markdown-body .markdown-alert-warning .markdown-alert-title {
    color: #f59e0b;
}

.markdown-body .markdown-alert-caution {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}
.markdown-body .markdown-alert-caution .markdown-alert-title {
    color: #ef4444;
}

/* --- Search Bar --- */
.search-container {
    position: relative;
    margin-bottom: 20px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--surface-border);
    color: var(--text-main);
    padding: 10px 10px 10px 38px;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s ease;
}

.search-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    background: rgba(0, 0, 0, 0.4);
}

.search-input::placeholder {
    color: var(--text-muted);
}

/* --- Lightbox --- */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox img {
    max-width: 90%;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lightbox.active img {
    transform: scale(1);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 40px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s, transform 0.2s;
    padding: 10px;
}

.lightbox-close:hover {
    color: #fff;
    transform: scale(1.1);
}

.markdown-body img {
    cursor: zoom-in;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.markdown-body img:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

/* --- Last Updated Badge --- */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

.last-updated {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--surface-border);
    animation: fadeIn 0.8s ease forwards;
}

@media (max-width: 600px) {
    .last-updated {
        display: none;
    }
}
