body { margin: 0; font-family: Arial, sans-serif; background: #f4f4f9; transition: background 0.3s, color 0.3s; }

/* --- STYLE DLA TRYBU CIEMNEGO (DARK THEME) --- */
[data-theme="dark"] {
    background: #121212 !important;
    color: #e0e0e0 !important;
}
[data-theme="dark"] body {
    background: #121212;
    color: #e0e0e0;
}
[data-theme="dark"] .mobile-header {
    background: #1e1e1e !important;
    border-bottom-color: #333 !important;
    color: #fff;
}
[data-theme="dark"] .mobile-header span {
    color: #fff !important;
}
[data-theme="dark"] .sidebar {
    background: #1e1e1e !important;
    border-right-color: #333 !important;
    color: #e0e0e0;
}
[data-theme="dark"] .sidebar-fixed-header {
    background: #1e1e1e !important;
    border-bottom-color: #333 !important;
}
[data-theme="dark"] .sidebar details summary {
    color: #e0e0e0;
}
[data-theme="dark"] .sidebar li a {
    color: #b0b0b0;
}
[data-theme="dark"] .sidebar li a:hover {
    background-color: #2a2a2a !important;
    color: #fff;
}
[data-theme="dark"] .sidebar li a.active {
    background-color: #0056b3 !important;
    color: #fff;
}
[data-theme="dark"] .content {
    background: #121212 !important;
    color: #e0e0e0 !important;
}
[data-theme="dark"] .lang-switcher {
    background: #2a2a2a !important;
    border-color: #444 !important;
}
[data-theme="dark"] .lang-btn {
    color: #b0b0b0;
}
[data-theme="dark"] .lang-btn.active {
    background: #0056b3 !important;
    color: #fff;
}
[data-theme="dark"] .toggle-all-btn {
    background: #4a5568 !important;
}
[data-theme="dark"] .toggle-all-btn:hover {
    background: #2d3748 !important;
}
[data-theme="dark"] .source-btn, [data-theme="dark"] .theme-toggle-btn {
    background: #2b6cb0 !important;
    color: #fff !important;
    border: none;
}
[data-theme="dark"] .source-btn:hover, [data-theme="dark"] .theme-toggle-btn:hover {
    background: #2c5282 !important;
}
[data-theme="dark"] .back-link {
    color: #a0aec0 !important;
}
[data-theme="dark"] h2, [data-theme="dark"] h3 {
    color: #f7fafc !important;
}
[data-theme="dark"] hr {
    border-color: #333 !important;
}

/* Górny pasek mobilny */
.mobile-header {
    display: none;
    background: #fff;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid #ddd;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1001;
}
.menu-toggle-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 0.5rem 0.8rem;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
}

.wrapper { display: flex; height: 100vh; overflow: hidden; position: relative; }

/* Lewa kolumna (sidebar) */
.sidebar { 
    width: 300px; 
    min-width: 300px;
    background: #fff; 
    border-right: 1px solid #ddd; 
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box; 
    transition: transform 0.3s ease;
    z-index: 1000;
}

/* Zakotwiczony panel sterowania */
.sidebar-fixed-header {
    padding: 1rem 1rem 0.5rem 1rem;
    background: #fff;
    border-bottom: 2px solid #eaeaea;
    z-index: 10;
}

/* Przewijana część ze spisem treści */
.sidebar-scrollable-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* Przełącznik językowy */
.lang-switcher {
    display: flex;
    background: #e9ecef;
    border-radius: 6px;
    padding: 3px;
    margin-bottom: 0.8rem;
    border: 1px solid #ced4da;
}
.lang-btn {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0.2rem;
    font-size: 0.8rem;
    font-weight: bold;
    color: #495057;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: Arial, sans-serif;
}
.lang-btn:hover { background: rgba(255, 255, 255, 0.6); }
.lang-btn.active {
    background: #007bff;
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Prawa kolumna (treść) */
.content { 
    flex: 1; 
    background: #fff; 
    overflow-y: auto; 
    padding: 3rem; 
    box-sizing: border-box; 
    font-family: "Times New Roman", Times, serif; 
    font-size: 1.1rem; 
    line-height: 1.6; 
}

.sidebar details { margin-bottom: 0.4rem; }
.sidebar summary { font-weight: bold; cursor: pointer; padding: 0.3rem; }
.sidebar ul { list-style-type: none; padding-left: 1.2rem; margin: 0.2rem 0; }
.sidebar li a { text-decoration: none; color: #444; display: block; padding: 0.2rem; cursor: pointer; border-radius: 3px; }
.sidebar li a:hover { background-color: #f0f0f5; }
.sidebar li a.active { background-color: #007bff; color: #fff; }

.full-text-btn {
    display: block;
    background: #28a745;
    color: white;
    text-align: center;
    padding: 0.6rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: bold;
    margin-bottom: 0.8rem;
    font-family: Arial, sans-serif;
    font-size: 0.95rem;
    cursor: pointer;
}
.full-text-btn:hover { background: #218838; }

.btn-row {
    display: flex;
    gap: 8px;
    margin-bottom: 0.8rem;
}

.toggle-all-btn, .theme-toggle-btn {
    flex: 1;
    background: #6c757d;
    color: white;
    text-align: center;
    padding: 0.5rem 0.3rem;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    font-family: Arial, sans-serif;
    font-size: 0.8rem;
}
.toggle-all-btn:hover { background: #5a6268; }
.theme-toggle-btn { background: #17a2b8; }
.theme-toggle-btn:hover { background: #138496; }

.source-row { margin-bottom: 0.5rem; }

.source-btn {
    display: block;
    width: 100%;
    background: #6c757d;
    color: white;
    text-align: center;
    padding: 0.4rem 0.3rem;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    font-family: Arial, sans-serif;
    font-size: 0.85rem;
    box-sizing: border-box;
}
.source-btn:hover { background: #5a6268; }

.back-link { display: inline-block; margin-bottom: 1rem; color: #666; text-decoration: none; font-family: Arial; font-size: 0.9rem; }

.content b, .content strong { font-weight: bold; }
.section-block { margin-bottom: 3rem; }
.loading { color: #666; font-family: Arial; font-style: italic; }

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

@media (max-width: 768px) {
    .mobile-header { display: flex; }
    .wrapper { flex-direction: column; height: calc(100vh - 53px); }
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .content { width: 100%; padding: 1.5rem; }
}

/* Styl dla linku całego tekstu umieszczonego nad spisem treści */
.sidebar-scrollable-content .full-text-link {
    display: block;
    color: #007bff;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eaeaea;
    cursor: pointer;
}
.sidebar-scrollable-content .full-text-link:hover {
    text-decoration: underline;
}
[data-theme="dark"] .sidebar-scrollable-content .full-text-link {
    color: #4dabf7;
    border-bottom-color: #333;
}
/* --- POPRAWKI DLA WIDOKU MOBILNEGO (SMARTFONY) --- */
@media (max-width: 768px) {
    /* 1. Pokazujemy górny pasek mobilny */
    .mobile-header { 
        display: flex; 
    }
    
    /* 2. Układ strony na telefonie */
    .wrapper { 
        flex-direction: column; 
        height: calc(100vh - 53px); 
    }
    
    /* 3. Menu boczne wysuwa się POD górnym paskiem (top: 53px), a nie od samej góry ekranu */
    .sidebar {
        position: fixed;
        top: 53px; 
        left: 0; 
        bottom: 0;
        height: calc(100vh - 53px);
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        padding-top: 0;
    }
    
    .sidebar.open { 
        transform: translateX(0); 
    }
    
    .sidebar-overlay.open { 
        display: block; 
    }
    
    .content { 
        width: 100%; 
        padding: 1.5rem; 
    }
    
    /* 4. Ukrywamy zbędny link powrotu w menu mobilnym, bo jest już wygodny pasek wyżej */
    .sidebar-fixed-header .back-link {
        display: none !important;
    }
    
    /* 5. Porządkujemy odstępy w nagłówku menu mobilnego */
    .sidebar-fixed-header {
        padding: 0.8rem 1rem 0.4rem 1rem !important;
        background: transparent !important;
        border-bottom: none !important;
    }
}

/* Domyślnie mobilny przełącznik języka na komputerze jest ukryty */
.mobile-lang-switcher {
    display: none;
    margin-bottom: 0 !important;
    padding: 2px !important;
    width: 90px;
}

/* Styl dla trybu ciemnego w mobilnym przełączniku */
[data-theme="dark"] .mobile-lang-switcher {
    background: #2a2a2a !important;
    border-color: #444 !important;
}

/* Reguły dla widoku mobilnego (smartfony) */
@media (max-width: 768px) {
    /* Ukrywamy pełny przełącznik wewnątrz wysuwanego menu bocznym */
    .desktop-lang-switcher {
        display: none !important;
    }
    
    /* Pokazujemy kompaktowy przełącznik na górnym pasku mobilnym */
    .mobile-lang-switcher {
        display: flex !important;
    }
    
    /* Skracamy napis w tytule mobilnym, żeby zmieścił się obok przycisków */
    .mobile-title {
        display: none; /* Ukrywamy długi napis na bardzo małych ekranach, zostawiając sam przycisk menu i język */
    }
    
    .mobile-header {
        padding: 0.5rem 0.8rem;
    }
}

/* Styl dla mobilnego przycisku strony głównej w pasku */
.mobile-home-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #6c757d;
    color: white;
    text-decoration: none;
    padding: 0.5rem 0.6rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
.mobile-home-btn:hover {
    background: #5a6268;
}

/* Dostosowanie trybu ciemnego dla przycisku domku */
[data-theme="dark"] .mobile-home-btn {
    background: #4a5568;
    color: #fff;
}
[data-theme="dark"] .mobile-home-btn:hover {
    background: #2d3748;
}