/* ===== Тёмная тема (по умолчанию) ===== */
body {
    background: #0d1117;
    color: #c9d1d9;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 18px;
    line-height: 1.6;
    padding: 20px;
    margin: 0;
    transition: background 0.3s, color 0.3s;
}

.markdown-body {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px;
    background: #0d1117;
    transition: background 0.3s;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    color: #fff;
    margin-top: 24px;
    margin-bottom: 16px;
}

.markdown-body h1 { font-size: 32px; border-bottom: 1px solid #30363d; padding-bottom: 8px; }
.markdown-body h2 { font-size: 24px; border-bottom: 1px solid #30363d; padding-bottom: 8px; }
.markdown-body h3 { font-size: 20px; }

.markdown-body p { margin: 0 0 16px 0; }

.markdown-body a { color: #58a6ff; text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }

.markdown-body img { max-width: 100%; height: auto; }

.markdown-body code {
    background: #161b22;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 16px;
}

.markdown-body pre {
    background: #161b22;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
}
.markdown-body pre code { background: transparent; padding: 0; }

.markdown-body ul,
.markdown-body ol {
    margin: 0 0 16px 0;
    padding-left: 24px;
}

.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 0 0 16px 0;
}
.markdown-body th,
.markdown-body td {
    border: 1px solid #30363d;
    padding: 8px 12px;
}
.markdown-body tr:nth-child(even) { background: #161b22; }

.markdown-body blockquote {
    border-left: 3px solid #30363d;
    padding-left: 16px;
    margin: 0 0 16px 0;
    color: #8b949e;
}

/* ===== Светлая тема ===== */
body.light-theme {
    background: #ffffff;
    color: #24292f;
}

body.light-theme .markdown-body {
    background: #ffffff;
}

body.light-theme .markdown-body h1,
body.light-theme .markdown-body h2,
body.light-theme .markdown-body h3 {
    color: #24292f;
}

body.light-theme .markdown-body h1,
body.light-theme .markdown-body h2 {
    border-bottom-color: #d0d7de;
}

body.light-theme .markdown-body a {
    color: #0969da;
}

body.light-theme .markdown-body code {
    background: #f6f8fa;
}

body.light-theme .markdown-body pre {
    background: #f6f8fa;
}

body.light-theme .markdown-body th,
body.light-theme .markdown-body td {
    border-color: #d0d7de;
}

body.light-theme .markdown-body tr:nth-child(even) {
    background: #f6f8fa;
}

body.light-theme .markdown-body blockquote {
    border-left-color: #d0d7de;
    color: #57606a;
}

/* ===== Переключатель тем ===== */
.theme-toggle {
    max-width: 900px;
    margin: 0 auto 20px auto;
    padding: 10px 20px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s, border-color 0.3s;
}

body.light-theme .theme-toggle {
    background: #f6f8fa;
    border-color: #d0d7de;
}

.theme-toggle-label {
    font-size: 14px;
    color: #8b949e;
}

body.light-theme .theme-toggle-label {
    color: #57606a;
}

.theme-toggle-btn {
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s, color 0.2s;
}

.theme-toggle-btn:hover {
    background: #30363d;
}

body.light-theme .theme-toggle-btn {
    background: #ffffff;
    color: #24292f;
    border-color: #d0d7de;
}

body.light-theme .theme-toggle-btn:hover {
    background: #f6f8fa;
}

/* ===== Статусы ===== */
#loading, #error {
    text-align: center;
    padding: 50px;
}
#loading { color: #8b949e; }
#error { color: #f85149; display: none; }

/* ===== Смартфон ===== */
@media (max-width: 768px) {
    body { font-size: 16px; padding: 10px; }
    .markdown-body { padding: 20px; }
    .theme-toggle { padding: 8px 12px; }
    .theme-toggle-label { font-size: 13px; }
    .theme-toggle-btn { font-size: 13px; padding: 5px 10px; }
}

/* ===== Печать ===== */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }
    body .markdown-body {
        background: #ffffff !important;
    }
    .theme-toggle {
        display: none !important;
    }
}
