:root {
    --text-color: #333;
    --background-color: #fff;
    --primary-color: #0056b3;
    --header-bg: #f8f9fa;
    --section-bg-odd: #ffffff;
    --section-bg-even: #f1f1f1;
    --border-color: #ddd;
    --focus-outline: #0056b3;
    --focus-bg: #0056b3;
    --focus-text: #ffffff;
}

body[data-theme="high-contrast"] {
    --text-color: #000;
    --background-color: #fff;
    --primary-color: #000;
    --header-bg: #fff;
    --section-bg-odd: #fff;
    --section-bg-even: #fff;
    --border-color: #000;
    --focus-outline: #0000ff;
    --focus-bg: #0000ff;
    --focus-text: #ffff00;
}
body[data-theme="monochrome"] {
    --text-color: #000;
    --background-color: #fff;
    --primary-color: #000;
    --header-bg: #f0f0f0;
    --section-bg-odd: #fff;
    --section-bg-even: #f0f0f0;
    --border-color: #000;
    --focus-outline: #000;
    --focus-bg: #000;
    --focus-text: #fff;
}
body[data-theme="dark"] {
    --text-color: #eee;
    --background-color: #121212;
    --primary-color: #bb86fc;
    --header-bg: #1e1e1e;
    --section-bg-odd: #1e1e1e;
    --section-bg-even: #2a2a2a;
    --border-color: #555;
    --focus-outline: #03dac6;
    --focus-bg: #03dac6;
    --focus-text: #000;
}
body[data-theme="dark"] nav a {
    color: #e0e0e0;
}
body[data-theme="dark"] .panel-toggle-btn {
    background-color: var(--primary-color);
    color: #000;
}

/* POPRAWKA: Kolory panelu dostępności w trybie ciemnym */
body[data-theme="dark"] .panel-content,
body[data-theme="dark"] .panel-content h4,
body[data-theme="dark"] .panel-content button,
body[data-theme="dark"] .panel-content span {
    color: var(--text-color);
}
body[data-theme="dark"] .panel-content button {
    background-color: var(--section-bg-even);
    border-color: var(--border-color);
}

/* POPRAWKA: Filtr monochromatyczny tylko na treść, nie na panele */
body.monochrome > header,
body.monochrome > nav,
body.monochrome > main,
body.monochrome > footer {
    filter: grayscale(100%);
}

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; line-height: 1.6; margin: 0; padding: 0; background-color: var(--background-color); color: var(--text-color); transition: background-color 0.3s, color 0.3s; }
[hidden] { display: none !important; }
.container { max-width: 1000px; margin: 0 auto; padding: 0 1rem; }

/* POPRAWKA: Lepszy, uniwersalny styl fokusu */
*:focus-visible {
    outline: 3px solid var(--focus-outline) !important;
    outline-offset: 2px;
    background-color: var(--focus-bg) !important;
    color: var(--focus-text) !important;
    box-shadow: 0 0 5px var(--focus-outline);
}
*:focus-visible strong, *:focus-visible a { color: inherit !important; }

/* POPRAWKA: Mocniejszy styl fokusu dla nawigacji - widoczny we wszystkich trybach */
nav a:focus-visible {
    outline: 4px solid var(--focus-outline) !important;
    outline-offset: -2px;
    background-color: var(--focus-bg) !important;
    color: var(--focus-text) !important;
    box-shadow: inset 0 0 0 2px var(--focus-text), 0 0 8px var(--focus-outline) !important;
    border-radius: 2px;
}

/* POPRAWKA: Specjalne style dla trybu normalnego i monochromatycznego */
body[data-theme="normal"] nav a:focus-visible,
body[data-theme="monochrome"] nav a:focus-visible {
    outline: 4px solid #000 !important;
    background-color: #000 !important;
    color: #fff !important;
    box-shadow: inset 0 0 0 2px #fff, 0 0 8px #000 !important;
}

body[data-theme="high-contrast"] nav a:focus-visible {
    outline: 4px solid #0000ff !important;
    background-color: #0000ff !important;
    color: #ffff00 !important;
    box-shadow: inset 0 0 0 2px #ffff00, 0 0 8px #0000ff !important;
}

body[data-theme="dark"] nav a:focus-visible {
    outline: 4px solid #03dac6 !important;
    background-color: #03dac6 !important;
    color: #000 !important;
    box-shadow: inset 0 0 0 2px #000, 0 0 8px #03dac6 !important;
}

.skip-link { position: absolute; top: -1000px; left: 10px; background: var(--primary-color); color: white; padding: 10px; z-index: 9999; }
.skip-link:focus { top: 10px; }

.panel-toggles { position: fixed; bottom: 1rem; left: 1rem; right: 1rem; display: flex; justify-content: space-between; z-index: 1998; pointer-events: none; }
.panel-toggle-btn { background: var(--primary-color); color: white; border: 2px solid white; border-radius: 50%; width: 60px; height: 60px; cursor: pointer; display: flex; flex-direction: column; justify-content: center; align-items: center; box-shadow: 0 4px 12px rgba(0,0,0,0.3); pointer-events: auto; }
.panel-toggle-btn svg { width: 28px; height: 28px; }
.panel-toggle-btn span { font-size: 0.8em; }

.side-panel { position: fixed; top: 0; width: 320px; max-width: 90vw; height: 100%; background: var(--background-color); box-shadow: 0 0 20px rgba(0,0,0,0.3); z-index: 2000; display: flex; flex-direction: column; transition: transform 0.3s ease-in-out; border: 1px solid var(--border-color); }
.side-panel.left { left: 0; transform: translateX(-100%); }
.side-panel.right { right: 0; transform: translateX(100%); }
.side-panel:not([hidden]) { transform: translateX(0); }
.panel-header { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 1rem; border-bottom: 1px solid var(--border-color); background-color: var(--header-bg); }
.panel-header h3 { margin: 0; }
.close-panel-btn { font-size: 1.5rem; background: transparent; border: none; cursor: pointer; padding: 0.5rem; color: var(--text-color); }
.panel-content, #nav-panel-list { padding: 1rem; overflow-y: auto; }
#nav-panel-list { list-style: none; margin: 0; }
#nav-panel-list a { display: block; padding: 0.75rem; text-decoration: none; color: var(--text-color); border-bottom: 1px solid var(--border-color); }

.control-group { margin-bottom: 1.5rem; }
.control-group h4 { margin: 0 0 0.75rem; color: var(--primary-color); }
.font-controls { display: flex; align-items: center; justify-content: space-between; }
/* POPRAWKA: Lepsze stylowanie przycisków A- i A+ */
.font-controls button { 
    font-size: 1rem; 
    width: 45px; 
    height: 40px; 
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border-radius: 4px;
}
#font-size-value {
    font-weight: bold;
    text-align: center;
    min-width: 50px;
}
.theme-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
#reset-settings, #reading-toggle { width: 100%; }
button { padding: 0.5em 1em; cursor: pointer; border: 1px solid var(--border-color); background: var(--section-bg-even); color: var(--text-color); }
.theme-controls button.active { border-color: var(--primary-color); border-width: 2px; }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 2500; display: flex; justify-content: center; align-items: center; }
.modal-content { background: var(--background-color); padding: 2rem; border-radius: 8px; max-width: 600px; width: 90%; }
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 1rem; margin-bottom: 1rem; }
.close-modal-btn { font-size: 2rem; background: none; border: none; cursor: pointer; color: var(--text-color); }

header, footer { text-align: center; padding: 1.5rem 0; background-color: var(--header-bg); }
.logos { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2rem; margin-bottom: 1.5rem; }
/* POPRAWKA: Naprawienie skalowania obrazów w bannerze */
.logos img { 
    max-height: 80px; 
    height: auto; 
    max-width: 180px; 
    object-fit: contain; 
}

/* POPRAWKA: Logo główne - szerokość jak 4 logo + gaps z responsywnością */
.centered-logo img { 
    max-height: 100px; 
    height: auto; 
    /* 4 logo po 180px + 3 gaps po 2rem = 720px + 6rem ≈ 816px */
    max-width: min(816px, 95vw); 
    width: 100%;
    object-fit: contain; 
}

/* Responsywność dla mniejszych ekranów */
@media (max-width: 768px) {
    .logos img {
        max-width: 140px;
        max-height: 60px;
    }
    
    .centered-logo img {
        /* 4 logo po 140px + gaps = 560px + gaps ≈ 650px */
        max-width: min(650px, 95vw);
        max-height: 80px;
    }
}

@media (max-width: 480px) {
    .logos img {
        max-width: 120px;
        max-height: 50px;
    }
    
    .centered-logo img {
        /* Na małych ekranach logo może być mniejsze */
        max-width: 95vw;
        max-height: 70px;
    }
}

nav { background-color: var(--primary-color); }
nav ul { display: flex; justify-content: center; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
nav a { color: white; text-decoration: none; padding: 1rem; display: block; }
main { padding: 2rem 0; }
section { padding: 2rem 1.5rem; border-bottom: 1px solid var(--border-color); }
section:nth-of-type(even) { background-color: var(--section-bg-even); }
h2 { border-bottom: 2px solid var(--primary-color); padding-bottom: 0.5rem; margin-top: 0; }
.document-link-wrapper { margin-bottom: 1rem; }
.file-info { font-size: 0.9rem; color: var(--text-color); opacity: 0.8; }
