/* ===== Базовые стили ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.75;
    color: #e8e8f0;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(120, 119, 198, 0.25) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(255, 119, 198, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(76, 190, 243, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

.container {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== Кнопка смены темы ===== */
.theme-toggle {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 10px 16px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95em;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    transition: all 0.3s ease;
    margin-left: 12px;
}

.theme-toggle:hover {
    border-color: rgba(255, 255, 255, 0.35);
    color: white;
}

.lang-toggle {
    min-width: 54px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

/* ===== Верхняя панель страниц новелл ===== */
.topbar {
    background: linear-gradient(135deg, #1a1a2e 0%, #302b63 50%, #24243e 100%);
    color: white;
    padding: 18px 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.topbar-inner .site-name {
    order: 1;
    margin-right: auto;
}

.topbar-inner .back-link {
    order: 2;
}

.topbar-inner .lang-toggle {
    order: 3;
}

.topbar-inner .theme-toggle {
    order: 4;
    margin-left: 0;
}

.site-name {
    color: white;
    text-decoration: none;
    font-size: 0.95em;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: normal;
}

.site-name:hover {
    opacity: 0.85;
}

/* ===== Шапка страниц схем ===== */
.page-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #302b63 50%, #24243e 100%);
    color: white;
    padding: 18px 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.page-header .container {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 20px;
}

.page-header .container > h1 {
    order: 1;
}

.page-header .container > .subtitle {
    order: 2;
    margin-right: auto;
}

.page-header .container > .back-link {
    order: 3;
}

.page-header .container > .lang-toggle {
    order: 4;
}

.page-header .container > .theme-toggle {
    order: 5;
}

/* Кнопка «Назад» в шапке схем — как в topbar */
.page-header .back-link {
    margin-top: 0;
    padding: 8px 18px;
}

.page-header h1 {
    font-size: 1.08em;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.01em;
    white-space: nowrap;
    order: 1;
}

.page-header .subtitle {
    font-size: 0.92em;
    opacity: 0.82;
    font-weight: 400;
    margin: 0;
    display: block;
    order: 2;
    white-space: nowrap;
}

/* ===== Кнопка «Назад» ===== */
.back-link {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 10px 18px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.95em;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: inline-block;
}

.back-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 0;
    height: 100%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3), rgba(118, 75, 162, 0.3));
    transition: width 0.3s ease, left 0.3s ease;
    z-index: -1;
}

.back-link:hover::before {
    width: 100%;
    left: 0;
}

.back-link:hover {
    color: white;
    border-color: rgba(255, 255, 255, 0.25);
}

.topbar .back-link {
    margin-top: 0;
    padding: 8px 18px;
}

/* ===== Основной контейнер ===== */
main.container {
    flex: 1 0 auto;
    margin-top: 40px;
    margin-bottom: 60px;
}

main.container {
    background: rgba(30, 28, 60, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 28px;
    box-shadow: 
        0 30px 80px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    max-width: 1120px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* ===== Двухколоночный макет страницы новеллы ===== */
.novel-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 56px;
    padding: 52px;
}

.novel-sidebar {
    position: sticky;
    top: 24px;
    align-self: start;
}

.novel-poster {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    display: block;
    border-radius: 20px;
    background: linear-gradient(135deg, #1a1a2e, #302b63);
    box-shadow: 
        0 24px 60px rgba(0, 0, 0, 0.35),
        0 0 40px rgba(102, 126, 234, 0.2);
    transition: transform 0.4s ease;
}

.novel-poster:hover {
    transform: scale(1.02);
}

.poster-credit {
    margin-top: 10px;
    text-align: center;
    font-size: 0.78em;
    letter-spacing: 0.03em;
    color: #98a2b3;
}

.novel-content {
    min-width: 0;
}

.novel-content h1 {
    font-size: 2.6em;
    line-height: 1.12;
    color: #e8e8f0;
    margin-bottom: 10px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.novel-subtitle {
    color: #b8b8d0;
    font-size: 1.02em;
    margin-bottom: 30px;
}

/* ===== Заголовки разделов ===== */
h2 {
    color: #e8e8f0;
    font-size: 1.4em;
    line-height: 1.25;
    margin-bottom: 22px;
    padding-left: 16px;
    border-left: 5px solid;
    border-image: linear-gradient(180deg, #667eea, #f093fb) 1;
    font-weight: 700;
}

h3 {
    color: #b8c8ff;
    font-size: 1.12em;
    margin-bottom: 10px;
}

section {
    margin-bottom: 34px;
}

section:last-child {
    margin-bottom: 0;
}

/* ===== Общая информация ===== */
.novel-info {
    background: rgba(40, 38, 70, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 30px 32px;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.novel-info p {
    margin-bottom: 12px;
    font-size: 1em;
    line-height: 1.8;
}

.novel-info p:last-child {
    margin-bottom: 0;
}

.novel-info strong {
    color: #a8b8ff;
}

.novel-info ul {
    margin: 0 0 14px 22px;
    line-height: 1.8;
}

.novel-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.novel-meta-item {
    background: rgba(50, 48, 80, 0.95);
    padding: 7px 15px;
    border-radius: 20px;
    font-size: 0.86em;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #b8b8d0;
}

.novel-meta-item strong {
    color: #a8b8ff;
    margin-right: 5px;
}

/* ===== Список схем ===== */
.schemas-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    margin-top: 26px;
}

.schema-block {
    background: rgba(40, 38, 70, 0.95);
    backdrop-filter: blur(10px);
    padding: 26px 28px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-decoration: none;
    color: inherit;
    display: block;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.schema-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(240, 147, 251, 0.05));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.schema-block:hover {
    border-color: rgba(102, 126, 234, 0.4);
    transform: translateY(-8px) scale(1.02);
    box-shadow: 
        0 20px 50px rgba(0, 0, 0, 0.15),
        0 0 30px rgba(102, 126, 234, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.schema-block:hover::before {
    opacity: 1;
}

.schema-block h3 {
    color: #b8c8ff;
    margin-bottom: 10px;
    font-size: 1.12em;
}

.schema-info {
    font-size: 0.9em;
    color: #b8b8d0;
    line-height: 1.6;
}

.schema-info p {
    margin-bottom: 5px;
}

.schema-info strong {
    color: #a8b8ff;
}

/* ===== Страница схемы ===== */
.schema-page {
    padding: 52px 56px 56px;
}

.schema-page section {
    margin-bottom: 44px;
}

.schema-page .novel-info {
    margin-bottom: 34px;
}

.schema-page section:last-child {
    margin-bottom: 0;
}

/* Информация о схеме — табличная карта */
.schema-page .novel-info h2 {
    margin-bottom: 22px;
    border-left-width: 5px;
}

.schema-page .novel-info p {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 14px;
    line-height: 1.55;
    font-size: 1.04em;
    padding: 10px 14px;
    background: rgba(50, 48, 80, 0.95);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #b8b8d0;
}

.schema-page .novel-info p:last-child {
    margin-bottom: 0;
}

.schema-page .novel-info strong {
    display: inline-block;
    min-width: 86px;
    color: #a8b8ff;
    font-weight: 600;
    letter-spacing: 0.01em;
    font-size: 0.94em;
    text-transform: uppercase;
    opacity: 0.82;
}

.schema-page .novel-info p.author-line {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15), rgba(118, 75, 162, 0.12));
    border-color: rgba(102, 126, 234, 0.3);
    padding: 14px 18px;
}

.schema-page .novel-info p.author-line strong {
    color: #b8c8ff;
    font-size: 1.10em;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: none;
    opacity: 1;
    min-width: 0;
}

/* Блок-схема */
.schema-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 42px;
    border-radius: 24px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
}

.schema-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.08) 0%, transparent 60%);
    animation: schemaGlow 6s ease-in-out infinite;
}

@keyframes schemaGlow {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(180deg); }
}

.schema-container:hover {
    transform: translateY(-8px);
    border-color: rgba(102, 126, 234, 0.4);
    box-shadow: 
        0 30px 80px rgba(0, 0, 0, 0.2),
        0 0 50px rgba(102, 126, 234, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.schema-link {
    display: inline-block;
    max-width: 100%;
    color: inherit;
    text-decoration: none;
}

.schema-image {
    max-width: 100%;
    height: auto;
    border-radius: 14px;
    box-shadow: 0 16px 44px rgba(30, 40, 80, 0.18);
    cursor: zoom-in;
    transition: transform 0.25s;
}

.schema-image:hover {
    transform: scale(1.012);
}

/* Заглушка на месте изображения схемы, если файл ещё не загружен */
.schema-image-missing {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 36px 24px;
    border: 2px dashed rgba(139, 94, 60, 0.35);
    border-radius: 14px;
    background: rgba(139, 94, 60, 0.07);
    color: #a08a6a;
    font-size: 0.95em;
    line-height: 1.7;
    text-align: center;
}

html.light-theme .schema-image-missing {
    border-color: rgba(212, 117, 10, 0.45);
    background: rgba(212, 117, 10, 0.08);
    color: #8b5e3c;
}

.schema-note {
    margin-top: 16px;
    color: #b8b8d0;
    font-size: 0.92em;
    font-style: italic;
}

/* ===== Комментарий автора ===== */
.author-comment {
    position: relative;
    background: rgba(60, 55, 40, 0.95);
    backdrop-filter: blur(10px);
    padding: 30px 32px;
    border-radius: 20px;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

/* Золотая полоса слева — псевдоэлементом, чтобы шла по скруглённому углу */
.author-comment::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 6px;
    background: linear-gradient(180deg, #f0a92e 0%, #ff6b6b 100%);
    border-radius: 20px 0 0 20px;
}

.author-comment h2 {
    border-left: none;
    padding-left: 0;
    color: #f0c060;
}

.author-comment p {
    font-style: italic;
    color: #ded0ae;
    line-height: 1.8;
}

/* Ссылки в комментарии автора — в палитре темы (цвет букв комментария не меняем) */
.author-comment a {
    color: #a8b8ff;
    text-decoration: underline;
    transition: color 0.25s;
}

.author-comment a:hover {
    color: #d8e0ff;
}

/* ===== Примечания ===== */
.notes {
    background: rgba(40, 38, 70, 0.95);
    padding: 26px 28px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.notes ul {
    list-style: none;
    padding-left: 0;
}

.notes li {
    padding: 10px 0 10px 26px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.97em;
    position: relative;
    color: #b8b8d0;
}

.notes li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #667eea;
    font-weight: bold;
}

.notes li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* ===== Цитата (blockquote) ===== */
blockquote {
    display: inline;
    margin: 0;
    padding: 0 8px;
    border-left: 2px solid #667eea;
    color: #b8b8d0;
    font-style: italic;
}

/* ===== Спойлер (inline) ===== */
.spoiler-toggle {
    display: inline;
    cursor: pointer;
    color: #a8b8ff;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
    font-weight: 500;
}

.spoiler-toggle:hover {
    color: #c8d8ff;
}

.spoiler-content {
    display: none;
    color: #e8e8f0;
}

.spoiler-content.visible {
    display: inline;
}

.spoiler-toggle.hidden {
    display: none;
}

/* ===== Подвал ===== */
footer {
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    color: rgba(255, 255, 255, 0.8);
    padding: 36px 0;
    text-align: center;
    font-size: 0.94em;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
}

footer p {
    margin-bottom: 6px;
}

footer a {
    color: #aeb8ff;
    text-decoration: none;
    transition: color 0.25s;
}

footer a:hover {
    color: white;
    text-decoration: underline;
}

footer .back-link {
    margin-top: 8px;
}

/* ===== Адаптивность ===== */
@media (max-width: 900px) {
    .novel-layout {
        grid-template-columns: 1fr;
        gap: 32px;
        padding: 36px;
    }

    .novel-sidebar {
        position: static;
        max-width: 240px;
    }

    .schema-page {
        padding: 34px 36px 38px;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 0 16px;
    }

    .topbar {
        padding: 12px 0;
    }

    .topbar-inner {
        flex-wrap: wrap;
        gap: 10px;
    }

    .topbar-inner .site-name {
        flex: 1 1 100%;
        white-space: normal;
    }

    .topbar-inner .lang-toggle {
        margin-left: auto;
    }

    .topbar-inner .theme-toggle,
    .page-header .theme-toggle {
        margin-left: 0;
    }

    .site-name {
        font-size: 0.9em;
    }

    .page-header {
        padding: 12px 0;
    }

    .page-header .container {
        flex-wrap: wrap;
        gap: 10px;
    }

    .page-header h1 {
        font-size: 0.94em;
        white-space: normal;
    }

    .page-header .subtitle {
        white-space: normal;
    }

    /* Кнопка «Назад» компактнее, чтобы кнопки языка и темы остались в одном ряду */
    .topbar .back-link,
    .page-header .back-link {
        padding: 8px 12px;
        font-size: 0.88em;
    }

    main.container {
        margin-top: 22px;
        margin-bottom: 34px;
        border-radius: 16px;
    }

    .novel-layout {
        padding: 24px 22px 30px;
        gap: 24px;
    }

    .novel-sidebar {
        max-width: 190px;
    }

    .novel-content h1 {
        font-size: 1.7em;
    }

    .novel-info {
        padding: 20px;
    }

    h2 {
        font-size: 1.18em;
    }

    .schemas-list {
        grid-template-columns: 1fr;
    }

    .schema-page {
        padding: 28px 22px 32px;
    }

    .schema-container {
        padding: 20px;
    }

    .schema-note {
        font-size: 0.86em;
    }

    .schema-page .novel-info p {
        flex-direction: column;
        gap: 4px;
        padding: 8px 10px;
    }

    .schema-page .novel-info p.author-line strong {
        font-size: 1.02em;
    }
}

/* ===== Анимация появления ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.novel-layout,
.schema-page {
    animation: fadeInUp 0.45s ease-out;
}

/* ===== Светлая тема: солнечная ===== */
html.light-theme body {
    background:
        radial-gradient(ellipse at 12% 8%, rgba(255, 236, 150, 0.85) 0%, transparent 45%),
        radial-gradient(ellipse at 88% 92%, rgba(249, 175, 60, 0.45) 0%, transparent 50%),
        linear-gradient(135deg, #fffaec 0%, #fff1c4 38%, #ffe0a0 72%, #fdcb6e 100%);
    color: #5d4e37;
}

html.light-theme body::before {
    background:
        radial-gradient(circle at 18% 14%, rgba(255, 247, 200, 0.95) 0%, transparent 38%),
        radial-gradient(circle at 78% 26%, rgba(255, 226, 140, 0.55) 0%, transparent 42%),
        radial-gradient(ellipse at 85% 88%, rgba(240, 160, 50, 0.35) 0%, transparent 50%),
        radial-gradient(ellipse at 35% 95%, rgba(255, 214, 102, 0.45) 0%, transparent 48%);
}

html.light-theme .topbar,
html.light-theme .page-header {
    background:
        radial-gradient(ellipse at 12% 0%, rgba(255, 226, 150, 0.5) 0%, transparent 55%),
        linear-gradient(135deg, #f79c1e 0%, #e07d09 42%, #c26a08 78%, #a85a09 100%);
    box-shadow: 0 6px 26px rgba(184, 94, 10, 0.28);
}

html.light-theme .site-name,
html.light-theme .page-header h1 {
    color: #ffffff;
}

html.light-theme .page-header .subtitle {
    color: rgba(255, 255, 255, 0.9);
}

html.light-theme .topbar .theme-toggle,
html.light-theme .page-header .theme-toggle {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.4);
    color: #ffffff;
}

html.light-theme .topbar .theme-toggle:hover,
html.light-theme .page-header .theme-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.75);
    color: #ffffff;
}

html.light-theme .topbar .back-link,
html.light-theme .page-header .back-link {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.35);
    color: rgba(255, 255, 255, 0.92);
}

html.light-theme .topbar .back-link::before,
html.light-theme .page-header .back-link::before {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.08));
}

html.light-theme .topbar .back-link:hover,
html.light-theme .page-header .back-link:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.7);
    color: #ffffff;
}

html.light-theme main.container {
    background: linear-gradient(160deg, #fffdf7 0%, #fff5e0 100%);
    box-shadow: 0 15px 50px rgba(139, 94, 60, 0.16);
    border-color: rgba(139, 94, 60, 0.22);
}

html.light-theme .novel-content h1 {
    color: #4a3728;
}

html.light-theme .novel-subtitle {
    color: #6d5c4a;
}

html.light-theme h2 {
    color: #4a3728;
}

html.light-theme h3 {
    color: #8b5e3c;
}

html.light-theme .novel-info {
    background: linear-gradient(160deg, #fffdf8 0%, #fff4de 100%);
    border-color: rgba(139, 94, 60, 0.22);
    box-shadow: 0 8px 30px rgba(139, 94, 60, 0.1);
}

html.light-theme .novel-info strong,
html.light-theme .novel-info p strong {
    color: #8b5e3c;
}

/* Список других названий — каждое на своей строке */
.alt-titles p {
    position: relative;
    padding-left: 18px;
    margin-bottom: 8px;
    color: #6d5c4a;
}

.alt-titles p::before {
    content: '•';
    position: absolute;
    left: 4px;
    color: rgba(212, 117, 10, 0.75);
}

.alt-titles p:last-child {
    margin-bottom: 0;
}

.alt-titles p.no-alternatives {
    color: #8a7a66;
    font-style: italic;
}

.alt-titles p.no-alternatives::before {
    content: none;
}

html.light-theme .alt-titles p {
    color: #5d4e37;
}

html.light-theme .alt-titles p.no-alternatives {
    color: #8a7a66;
}

html.light-theme .novel-info p a {
    color: #b8650a;
}

html.light-theme .novel-meta-item {
    background: linear-gradient(135deg, #fffaf0 0%, #ffeecb 100%);
    border-color: rgba(139, 94, 60, 0.22);
    color: #6d5c4a;
}

html.light-theme .novel-meta-item strong {
    color: #8b5e3c;
}

html.light-theme .schema-block {
    background: linear-gradient(160deg, #fffdf7 0%, #fff3da 100%);
    border-color: rgba(139, 94, 60, 0.22);
    box-shadow: 0 6px 24px rgba(139, 94, 60, 0.12);
}

html.light-theme .schema-block:hover {
    background: linear-gradient(160deg, #fffdf4 0%, #ffeec2 100%);
    border-color: rgba(184, 101, 10, 0.55);
    box-shadow: 0 16px 40px rgba(184, 94, 10, 0.22);
}

html.light-theme .schema-block h3 {
    color: #8b5e3c;
}

html.light-theme .schema-info {
    color: #6d5c4a;
}

html.light-theme .schema-info strong {
    color: #8b5e3c;
}

html.light-theme .schema-page .novel-info p {
    background: linear-gradient(135deg, #fffdf7 0%, #fff4de 100%);
    border-color: rgba(139, 94, 60, 0.22);
    color: #6d5c4a;
}

html.light-theme .schema-page .novel-info strong {
    color: #8b5e3c;
}

html.light-theme .schema-page .novel-info p.author-line {
    background: linear-gradient(135deg, rgba(247, 156, 30, 0.22) 0%, rgba(212, 117, 10, 0.10) 60%, rgba(184, 94, 10, 0.06) 100%);
    border-color: rgba(139, 94, 60, 0.28);
}

html.light-theme .schema-note {
    color: #6d5c4a;
}

html.light-theme .author-comment {
    background: linear-gradient(160deg, #fff7de 0%, #fce9ba 100%);
    border: 1px solid rgba(212, 117, 10, 0.35);
    box-shadow:
        0 14px 40px rgba(139, 94, 60, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

html.light-theme .author-comment h2 {
    color: #9a6a12;
}

html.light-theme .author-comment p {
    color: #6b5b3e;
}

html.light-theme .notes {
    background: linear-gradient(160deg, #fffdf7 0%, #fff4de 100%);
    border-color: rgba(139, 94, 60, 0.22);
}

html.light-theme .notes li {
    border-bottom-color: rgba(139, 94, 60, 0.2);
    color: #6d5c4a;
}

html.light-theme blockquote {
    border-left-color: #8b5e3c;
    color: #6d5c4a;
}

html.light-theme .spoiler-toggle {
    color: #b8650a;
}

html.light-theme .spoiler-toggle:hover {
    color: #8b3e0a;
}

html.light-theme .spoiler-content {
    color: #4a3728;
}

html.light-theme .schema-container {
    background: linear-gradient(160deg, #fffdf8 0%, #fff4e2 100%);
    border-color: rgba(139, 94, 60, 0.22);
    box-shadow: 0 15px 50px rgba(139, 94, 60, 0.14);
}

html.light-theme .schema-container:hover {
    background: linear-gradient(160deg, #fffdf4 0%, #ffeec8 100%);
    border-color: rgba(184, 101, 10, 0.55);
    box-shadow: 0 24px 60px rgba(184, 94, 10, 0.24);
}

html.light-theme .schema-image {
    box-shadow: 0 12px 36px rgba(139, 94, 60, 0.18);
}

html.light-theme footer {
    background:
        radial-gradient(ellipse at 20% 0%, rgba(255, 214, 150, 0.25) 0%, transparent 60%),
        linear-gradient(135deg, #a97142 0%, #8b5e3c 45%, #5d4030 100%);
}

html.light-theme footer a {
    color: #ffd28a;
}

html.light-theme footer a:hover {
    color: #ffffff;
}

html.light-theme footer .back-link {
    background: transparent;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.35);
}

html.light-theme footer .back-link:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.7);
}

html.light-theme footer .back-link::before {
    background: linear-gradient(135deg, rgba(255, 214, 150, 0.2), rgba(255, 255, 255, 0.06));
}

html.light-theme .author-comment a {
    color: #b8650a;
}

html.light-theme .author-comment a:hover {
    color: #8b3e0a;
}

html.light-theme .schema-container::before {
    background: radial-gradient(circle, rgba(247, 156, 30, 0.14) 0%, transparent 60%);
}

/* ===== Просмотрщик блок-схем ===== */
.sv-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.sv-modal.sv-is-open {
    opacity: 1;
    visibility: visible;
}

/* Затемнение фона */
.sv-modal .sv-backdrop {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(12, 10, 34, 0.94) 0%, rgba(4, 3, 14, 0.985) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: zoom-out;
}

/* Рабочая область */
.sv-modal .sv-stage {
    position: absolute;
    inset: 0;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
}

.sv-modal .sv-stage.sv-dragging {
    cursor: grabbing;
}

.sv-modal .sv-canvas {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform;
}

.sv-modal .sv-picture {
    display: block;
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    user-select: none;
    -webkit-user-drag: none;
    border-radius: 6px;
    box-shadow: 0 24px 90px rgba(0, 0, 0, 0.7);
    background: #fff;
}

/* Индикатор загрузки */
.sv-modal .sv-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    color: #b8c8ff;
    font-size: 0.92em;
    letter-spacing: 0.02em;
    pointer-events: none;
    z-index: 2;
}

.sv-modal .sv-loader[hidden] {
    display: none;
}

.sv-modal .sv-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(184, 200, 255, 0.2);
    border-top-color: #b8c8ff;
    border-radius: 50%;
    animation: sv-spin 0.85s linear infinite;
}

@keyframes sv-spin {
    to { transform: rotate(360deg); }
}

/* Счётчик / заголовок сверху */
.sv-modal .sv-topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: 14px 16px;
    pointer-events: none;
    z-index: 3;
    background: linear-gradient(to bottom, rgba(5, 4, 16, 0.55) 0%, transparent 100%);
}

.sv-modal .sv-counter {
    padding: 7px 16px;
    background: rgba(15, 12, 41, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(102, 126, 234, 0.28);
    border-radius: 20px;
    color: #cdd6ff;
    font-size: 0.85em;
    font-weight: 600;
    letter-spacing: 0.03em;
    max-width: min(70vw, 560px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Панель управления */
.sv-modal .sv-toolbar {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 7px 12px;
    background: rgba(15, 12, 41, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 42px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    z-index: 4;
    max-width: calc(100vw - 24px);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sv-modal .sv-toolbar::-webkit-scrollbar {
    display: none;
}

.sv-modal .sv-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: #cfd6f5;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.sv-modal .sv-btn:hover {
    background: rgba(102, 126, 234, 0.26);
    border-color: rgba(102, 126, 234, 0.55);
    color: #ffffff;
}

.sv-modal .sv-btn:active {
    transform: scale(0.92);
}

.sv-modal .sv-btn[hidden] {
    display: none;
}

.sv-modal .sv-btn svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sv-modal .sv-btn-text {
    font-size: 0.78em;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.sv-modal .sv-btn.sv-active {
    background: rgba(102, 126, 234, 0.22);
    border-color: rgba(102, 126, 234, 0.5);
    color: #b8c8ff;
}

.sv-modal .sv-close {
    color: #ff9d9d;
}

.sv-modal .sv-close:hover {
    background: rgba(255, 80, 80, 0.2);
    border-color: rgba(255, 100, 100, 0.6);
    color: #ffc2c2;
}

.sv-modal .sv-sep {
    width: 1px;
    height: 22px;
    background: rgba(184, 200, 255, 0.18);
    margin: 0 4px;
    flex-shrink: 0;
}

.sv-modal .sv-scale {
    min-width: 56px;
    text-align: center;
    color: #b8c8ff;
    font-size: 0.83em;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

/* Мини-карта */
.sv-modal .sv-minimap {
    position: absolute;
    right: 18px;
    bottom: 74px;
    width: 168px;
    height: 210px;
    background: rgba(10, 8, 28, 0.82);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    z-index: 3;
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
}

.sv-modal .sv-minimap[hidden] {
    display: none;
}

.sv-modal .sv-minimap-img {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    opacity: 0.75;
    pointer-events: none;
}

.sv-modal .sv-minimap-window {
    position: absolute;
    top: 0;
    left: 0;
    border: 2px solid #b8c8ff;
    background: rgba(184, 200, 255, 0.12);
    border-radius: 3px;
    pointer-events: none;
    box-shadow: 0 0 0 9999px rgba(4, 3, 14, 0.42);
}

/* Панель горячих клавиш */
.sv-modal .sv-hint {
    position: absolute;
    top: 14px;
    right: 16px;
    z-index: 4;
}

.sv-modal .sv-hint-btn {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(184, 200, 255, 0.3);
    border-radius: 50%;
    background: rgba(15, 12, 41, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #b8c8ff;
    font-size: 0.95em;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.16s ease, border-color 0.16s ease;
}

.sv-modal .sv-hint-btn:hover {
    background: rgba(102, 126, 234, 0.24);
    border-color: rgba(102, 126, 234, 0.6);
}

.sv-modal .sv-hint-panel {
    position: absolute;
    right: 0;
    top: 44px;
    width: 240px;
    padding: 12px 14px;
    background: rgba(15, 12, 41, 0.93);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 14px;
    box-shadow: 0 14px 44px rgba(0, 0, 0, 0.55);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.sv-modal .sv-hint.sv-hint-open .sv-hint-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.sv-modal .sv-hint-row {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 0;
}

.sv-modal .sv-hint-row kbd {
    min-width: 24px;
    padding: 3px 6px;
    background: rgba(184, 200, 255, 0.1);
    border: 1px solid rgba(184, 200, 255, 0.24);
    border-radius: 5px;
    color: #cdd6ff;
    font-family: inherit;
    font-size: 0.72em;
    font-weight: 600;
    text-align: center;
    flex-shrink: 0;
}

.sv-modal .sv-hint-key {
    margin-left: 6px;
    color: #9aa4cc;
    font-size: 0.78em;
}

/* ===== Светлая тема ===== */
html.light-theme .sv-modal .sv-backdrop {
    background: radial-gradient(ellipse at center, rgba(253, 246, 232, 0.96) 0%, rgba(240, 228, 208, 0.99) 100%);
}

html.light-theme .sv-modal .sv-loader {
    color: #8b5e3c;
}

html.light-theme .sv-modal .sv-spinner {
    border-color: rgba(139, 94, 60, 0.2);
    border-top-color: #d4750a;
}

html.light-theme .sv-modal .sv-topbar {
    background: linear-gradient(to bottom, rgba(240, 228, 208, 0.6) 0%, transparent 100%);
}

html.light-theme .sv-modal .sv-counter {
    background: rgba(255, 252, 245, 0.9);
    border-color: rgba(139, 94, 60, 0.25);
    color: #6b543c;
}

html.light-theme .sv-modal .sv-toolbar {
    background: rgba(255, 252, 245, 0.92);
    border-color: rgba(139, 94, 60, 0.28);
    box-shadow: 0 12px 40px rgba(120, 90, 50, 0.22);
}

html.light-theme .sv-modal .sv-btn {
    color: #4a3f36;
}

html.light-theme .sv-modal .sv-btn:hover {
    background: rgba(212, 117, 10, 0.16);
    border-color: rgba(212, 117, 10, 0.5);
    color: #8b3e0a;
}

html.light-theme .sv-modal .sv-btn.sv-active {
    background: rgba(212, 117, 10, 0.14);
    border-color: rgba(212, 117, 10, 0.45);
    color: #8b5e3c;
}

html.light-theme .sv-modal .sv-close {
    color: #c0392b;
}

html.light-theme .sv-modal .sv-close:hover {
    background: rgba(180, 60, 60, 0.14);
    border-color: rgba(180, 60, 60, 0.5);
    color: #a03024;
}

html.light-theme .sv-modal .sv-sep {
    background: rgba(139, 94, 60, 0.2);
}

html.light-theme .sv-modal .sv-scale {
    color: #8b5e3c;
}

html.light-theme .sv-modal .sv-minimap {
    background: rgba(255, 250, 240, 0.9);
    border-color: rgba(139, 94, 60, 0.3);
    box-shadow: 0 10px 34px rgba(120, 90, 50, 0.18);
}

html.light-theme .sv-modal .sv-minimap-window {
    border-color: #d4750a;
    background: rgba(212, 117, 10, 0.12);
    box-shadow: 0 0 0 9999px rgba(120, 90, 50, 0.16);
}

html.light-theme .sv-modal .sv-hint-btn {
    background: rgba(255, 252, 245, 0.9);
    border-color: rgba(139, 94, 60, 0.3);
    color: #8b5e3c;
}

html.light-theme .sv-modal .sv-hint-btn:hover {
    background: rgba(212, 117, 10, 0.14);
    border-color: rgba(212, 117, 10, 0.5);
}

html.light-theme .sv-modal .sv-hint-panel {
    background: rgba(255, 252, 245, 0.95);
    border-color: rgba(139, 94, 60, 0.28);
    box-shadow: 0 14px 44px rgba(120, 90, 50, 0.22);
}

html.light-theme .sv-modal .sv-hint-row kbd {
    background: rgba(139, 94, 60, 0.08);
    border-color: rgba(139, 94, 60, 0.22);
    color: #6b543c;
}

html.light-theme .sv-modal .sv-hint-key {
    color: #8a7a66;
}

/* ===== Мобильная адаптация ===== */
@media (max-width: 720px) {
    .sv-modal .sv-toolbar {
        bottom: 10px;
        padding: 6px 10px;
        gap: 2px;
        border-radius: 36px;
        max-width: calc(100vw - 16px);
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        justify-content: flex-start;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .sv-modal .sv-toolbar::-webkit-scrollbar {
        display: none;
    }

    .sv-modal .sv-btn {
        width: 32px;
        height: 32px;
    }

    .sv-modal .sv-btn svg {
        width: 17px;
        height: 17px;
    }

    .sv-modal .sv-scale {
        min-width: 46px;
        font-size: 0.78em;
    }

    .sv-modal .sv-sep {
        height: 18px;
        margin: 0 2px;
    }

    .sv-modal .sv-minimap {
        right: 10px;
        bottom: 62px;
        width: 88px;
        height: 112px;
    }

    .sv-modal .sv-hint {
        top: 10px;
        right: 12px;
    }

    .sv-modal .sv-hint-panel {
        width: 210px;
        padding: 10px 12px;
    }

    .sv-modal .sv-topbar {
        padding: 10px 12px;
    }

    .sv-modal .sv-counter {
        font-size: 0.78em;
        padding: 6px 13px;
    }
}

@media (max-width: 420px) {
    .sv-modal .sv-minimap {
        display: none;
    }
}
