:root {
    --bg-color: #ffffff;
    --text-color: #000000;
    --border-color: #000000;
    --hover-bg: #000000;
    --hover-text: #ffffff;
}

[data-theme="dark"] {
    --bg-color: #000000;
    --text-color: #ffffff;
    --border-color: #ffffff;
    --hover-bg: #ffffff;
    --hover-text: #000000;
}

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

body {
    font-family: Arial, sans-serif;
    max-width: 920px;
    margin: 0 auto;
    padding: 20px;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    line-height: 1.6;
}

h1 {
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
    font-size: 2.5em;
    font-weight: bold;
}

.date {
    color: var(--text-color);
    font-size: 0.9em;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.7;
}

.content {
    margin-top: 20px;
    font-size: 1.1em;
    line-height: 1.8;
}

.content img {
    max-width: 100%;
    height: auto;
    border: 2px solid var(--border-color);
    margin: 20px 0;
}

.blog-image-align-wrap {
    display: block;
    margin: 14px 0;
    width: 100%;
    clear: both;
    position: relative;
}
.blog-image-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    vertical-align: top;
    text-align: center;
}
.blog-image-wrap img {
    display: block;
    max-width: 100%;
    height: auto;
    vertical-align: middle;
    border-radius: 8px;
    margin: 0 !important;
    border: 2px solid var(--border-color) !important;
}
.blog-image-wrap .caption {
    display: block;
    text-align: center;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-color);
    opacity: 0.7;
    font-style: italic;
    line-height: 1.4;
}

.content h2 {
    margin-top: 30px;
    margin-bottom: 15px;
    color: var(--text-color);
    font-weight: bold;
}

.content p {
    margin-bottom: 0;
}

.content ul, .content ol {
    margin: 15px 0;
    padding-left: 30px;
}

.content li {
    margin-bottom: 8px;
}

.content table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    border: 2px solid var(--border-color);
}

.content table th,
.content table td {
    padding: 12px;
    text-align: left;
    border: 1px solid var(--border-color);
}

.content table th {
    background: var(--text-color);
    color: var(--bg-color);
    font-weight: 600;
}

.content table tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .content table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.content a {
    color: var(--text-color);
    text-decoration: none;
    border-bottom: 2px solid var(--border-color);
    transition: all 0.2s ease;
}

.content a:hover {
    background: var(--hover-bg);
    color: var(--hover-text);
}

.back-link {
    display: inline-block;
    margin-top: 40px;
    padding: 12px 24px;
    background: var(--bg-color);
    color: var(--text-color);
    text-decoration: none;
    border: 2px solid var(--border-color);
    border-radius: 0;
    transition: all 0.2s ease;
    font-weight: 500;
}

.back-link:hover {
    background: var(--hover-bg);
    color: var(--hover-text);
}

.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px 20px;
    background: var(--bg-color);
    color: var(--text-color);
    border: 2px solid var(--border-color);
    border-radius: 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    z-index: 100;
}

.theme-toggle:hover {
    background: var(--hover-bg);
    color: var(--hover-text);
}

.powered-by {
    position: fixed;
    bottom: 20px;
    left: 20px;
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.4;
    transition: opacity 0.2s ease;
    z-index: 50;
}

.powered-by:hover {
    opacity: 0.7;
}

/* Модальное окно для просмотра изображений */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.image-modal.show {
    display: flex;
}

.image-modal-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: grab;
}

.image-modal-container.dragging {
    cursor: grabbing;
}

.image-modal-content {
    position: absolute;
    max-width: none;
    max-height: none;
    object-fit: contain;
    transition: transform 0.3s ease;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: auto;
}

.image-modal-close {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: #fff;
    font-size: 28px;
    line-height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 1001;
    padding: 0;
}

.image-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.image-modal-toolbar {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50px;
    padding: 12px 20px;
    display: flex;
    gap: 8px;
    z-index: 1001;
    backdrop-filter: blur(10px);
}

.image-modal-btn {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.image-modal-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.image-modal-zoom-level {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 0 12px;
    display: flex;
    align-items: center;
    min-width: 60px;
    justify-content: center;
}

.content img {
    cursor: zoom-in;
    transition: opacity 0.2s;
}

.content img:hover {
    opacity: 0.9;
}

/* Стили для сворачиваемого блока (spoiler) */
.spoiler-block {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    margin: 15px 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.spoiler-title {
    display: block;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    background: rgba(0, 0, 0, 0.03);
    transition: background 0.2s ease;
    list-style: none;
}

.spoiler-title::-webkit-details-marker {
    display: none;
}

.spoiler-title::before {
    content: "▶";
    display: inline-block;
    margin-right: 8px;
    transition: transform 0.3s ease;
    font-size: 12px;
}

.spoiler-block[open] .spoiler-title::before {
    transform: rotate(90deg);
}

.spoiler-title:hover {
    background: rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .spoiler-title {
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .spoiler-title:hover {
    background: rgba(255, 255, 255, 0.06);
}

.spoiler-content {
    padding: 16px;
    line-height: 1.6;
    animation: spoilerFadeIn 0.3s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

@keyframes spoilerFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Стили для маркера (выделение текста) */
mark {
    padding: 2px 4px;
    background: var(--marker-color, rgba(255, 235, 59, 0.45));
    color: inherit;
    font-weight: inherit;
    position: relative;
    display: inline;
}

/* Ровное выделение */
mark[data-marker-style="straight"] {
    border-radius: 3px;
}

/* Кривое выделение (неровные края) */
mark[data-marker-style="rough"] {
    border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
    transform: rotate(-1deg);
}

/* Зигзагообразное выделение */
mark[data-marker-style="zigzag"] {
    border-radius: 15px 255px 15px 225px/225px 15px 255px 15px;
}

/* Волнистое выделение */
mark[data-marker-style="wavy"] {
    border-radius: 225px 255px 15px 225px/255px 15px 225px 15px;
}

mark[data-marker-color="yellow"] {
    --marker-color: rgba(255, 235, 59, 0.45);
}

mark[data-marker-color="green"] {
    --marker-color: rgba(76, 175, 80, 0.45);
}

mark[data-marker-color="blue"] {
    --marker-color: rgba(33, 150, 243, 0.45);
}

mark[data-marker-color="orange"] {
    --marker-color: rgba(255, 152, 0, 0.5);
}

mark[data-marker-color="pink"] {
    --marker-color: rgba(233, 30, 99, 0.45);
}

mark[data-marker-color="purple"] {
    --marker-color: rgba(156, 39, 176, 0.45);
}

/* Стили для кнопки файла в статье */
.blog-file-button {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin: 10px 0;
    background: var(--bg-color);
    border: 2px solid var(--text-color);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.2s ease;
    max-width: 400px;
}

.blog-file-button:hover {
    background: var(--hover-bg);
    color: var(--hover-text);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.blog-file-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.blog-file-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.blog-file-name {
    font-size: 14px;
    font-weight: 600;
    word-break: break-all;
}

.blog-file-size {
    font-size: 11px;
    opacity: 0.7;
}

/* Контейнер для фона статьи */
.content-wrapper {
    max-width: 920px;
    margin: -20px auto 0;
    padding: 40px 60px;
}

/* Обертка для подложки */
.overlay-wrapper {
    padding: 40px;
    border-radius: 12px;
}

@media (max-width: 768px) {
    body {
        padding: 15px;
    }
    
    h1 {
        font-size: 2em;
    }
    
    .theme-toggle {
        position: static;
        margin: 10px auto 20px;
        display: block;
        width: fit-content;
    }
    
    .content-wrapper {
        margin: -15px auto 0;
        padding: 20px 30px;
    }
    
    .overlay-wrapper {
        padding: 20px;
    }
}
