* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-hover: #e0e0e0;
    --text-primary: #333;
    --text-secondary: #666;
    --text-heading: #2c3e50;
    --border-color: #ddd;
    --link-color: #3498db;
    --link-hover: #2980b9;
    --button-bg: #3498db;
    --button-hover: #2980b9;
    --viewer-bg: #000;
}

body.dark-mode {
    --bg-primary: #1e1e1e;
    --bg-secondary: #2d2d2d;
    --bg-hover: #3d3d3d;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-heading: #ffffff;
    --border-color: #444;
    --link-color: #5dade2;
    --link-hover: #85c1e9;
    --button-bg: #5dade2;
    --button-hover: #85c1e9;
    --viewer-bg: #000;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: background 0.3s, color 0.3s;
}

.container {
    display: flex;
    height: 100vh;
    position: relative;
}

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 20px;
    align-items: center;
    justify-content: space-between;
    z-index: 1000;
    transition: background 0.3s, border-color 0.3s;
}

.mobile-header h1 {
    font-size: 20px;
    color: var(--text-heading);
}

.hamburger {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    padding: 5px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar {
    width: 300px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 20px;
    transition: background 0.3s, border-color 0.3s, transform 0.3s;
    position: relative;
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.sidebar h1 {
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--text-heading);
    transition: color 0.3s;
    flex-shrink: 0;
}

.sidebar nav {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 15px;
    padding-bottom: 10px;
}

.theme-toggle-container {
    flex-shrink: 0;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--bg-secondary);
    transition: background 0.3s, border-color 0.3s;
}

.theme-toggle-label {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.theme-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.theme-switch input:checked + .theme-slider {
    background-color: var(--button-bg);
}

.theme-switch input:checked + .theme-slider:before {
    transform: translateX(24px);
}

.theme-slider:hover {
    opacity: 0.9;
}

.content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    transition: margin-left 0.3s;
}

nav ul {
    list-style: none;
}

nav li {
    margin: 3px 0;
}

nav a {
    color: var(--link-color);
    text-decoration: none;
    display: inline-block;
    padding: 6px 10px;
    border-radius: 4px;
    transition: background 0.2s, color 0.3s;
}

nav a:hover {
    background: var(--bg-hover);
}

nav .folder {
    font-weight: 600;
    color: var(--text-heading);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 4px;
    transition: background 0.2s, color 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

nav .folder:hover {
    background: var(--bg-hover);
}

nav .folder-with-content {
    display: flex;
    align-items: center;
    gap: 5px;
}

nav .folder-with-content a {
    flex: 1;
}

nav .toggle-icon {
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px;
    transition: transform 0.2s, color 0.3s;
}

nav .toggle-icon:hover {
    color: var(--text-primary);
}

nav .nested {
    margin-left: 20px;
    padding-left: 10px;
    border-left: 2px solid var(--border-color);
    transition: border-color 0.3s;
}

/* Poziomy wcięć - każdy kolejny poziom ma mniejszą czcionkę */
nav li.level-0 {
    font-size: 16px;
}

nav li.level-1 {
    font-size: 15px;
}

nav li.level-2 {
    font-size: 14px;
}

nav li.level-3 {
    font-size: 13px;
}

nav li.level-4 {
    font-size: 12px;
}

nav li.level-5,
nav li.level-6,
nav li.level-7 {
    font-size: 11px;
}

#content-area {
    max-width: 900px;
}

#content-area h1 {
    color: var(--text-heading);
    margin-bottom: 20px;
    transition: color 0.3s;
}

#content-area h2 {
    color: var(--text-heading);
    margin-top: 30px;
    margin-bottom: 15px;
    transition: color 0.3s;
}

#content-area h3,
#content-area h4,
#content-area h5,
#content-area h6 {
    color: var(--text-heading);
    transition: color 0.3s;
}

#content-area p {
    margin-bottom: 15px;
    color: var(--text-primary);
}

#content-area strong {
    color: var(--text-heading);
}

#content-area ul,
#content-area ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

/* Figure z obrazkiem i podpisem */
#content-area .image-figure,
#content-area .image-wrapper {
    margin: 40px auto;
    max-width: 90%;
    text-align: center;
    background: rgba(0, 0, 0, 0.03);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

body.dark-mode #content-area .image-figure,
body.dark-mode #content-area .image-wrapper {
    background: rgba(0, 0, 0, 0.2);
}

#content-area .image-figure img,
#content-area .image-wrapper img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 0 auto;
    display: block;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: white;
    padding: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

body.dark-mode #content-area .image-figure img,
body.dark-mode #content-area .image-wrapper img {
    background: #2a2a2a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#content-area .image-figure img:hover,
#content-area .image-wrapper img:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

body.dark-mode #content-area .image-figure img:hover,
body.dark-mode #content-area .image-wrapper img:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
}

#content-area figcaption {
    display: block;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    font-style: italic;
    margin-top: 15px;
    padding: 0 20px;
    line-height: 1.5;
}

/* Obrazki poza figure (jeśli jakieś zostały) */
#content-area p > img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 20px auto;
    display: block;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: white;
    padding: 8px;
}

.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.image-gallery img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    cursor: pointer;
    border-radius: 4px;
    transition: transform 0.2s;
    border: 1px solid var(--border-color);
}

.image-gallery img:hover {
    transform: scale(1.05);
}

#viewer {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.viewer-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    gap: 15px;
    flex-wrap: wrap;
}

.viewer-navigation {
    display: flex;
    align-items: center;
    gap: 15px;
}

.viewer-btn {
    padding: 8px 16px;
    background: var(--button-bg);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s, opacity 0.3s;
    white-space: nowrap;
}

.viewer-btn:hover:not(:disabled) {
    background: var(--button-hover);
}

.viewer-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.nav-btn {
    min-width: 120px;
}

.image-counter {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    min-width: 60px;
    text-align: center;
}

.viewer-container {
    flex: 1;
    background: var(--viewer-bg);
    position: relative;
}

.back-button {
    display: inline-block;
    margin-bottom: 20px;
    padding: 10px 20px;
    background: var(--button-bg);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    cursor: pointer;
    border: none;
    font-size: 14px;
    transition: background 0.3s;
}

.back-button:hover {
    background: var(--button-hover);
}

.copy-url-btn {
    padding: 8px 16px;
    background: var(--button-bg);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.copy-url-btn:hover {
    background: var(--button-hover);
}
