html, body {
    margin: 0; 
    padding: 0; 
    width: 100%; 
    height: 100%; 
    overflow: hidden;
    background: #4a4a4a; 
    background-image: radial-gradient(circle, #6b6b6b, #3a3a3a);
    display: flex; 
    justify-content: center; 
    align-items: center;
}

#book-container { 
    position: relative; 
    max-width: 95vw;
    max-height: 95vh;
}

#flipbook {
    min-width: 300px;
    min-height: 400px;
    transition: margin-left 0.5s ease-in-out;
}

/* КРИТИЧНІ СТИЛІ ДЛЯ PDF-ВМІСТУ */
#flipbook .page {
    position: relative; 
    overflow: hidden; 
    background: #ffffff; 
    border: 1px solid #ccc; 
}

/* Контейнер вмісту з data-width/height */
#flipbook .page > div { 
    position: absolute;
    top: 0;
    left: 0;
    width: 100%; 
    height: 100%;
}

/* Стилі для текстових блоків */
.text-block {
    position: absolute; 
    z-index: 5;
    white-space: pre; 
    
    transform: scale(1); 
    transform-origin: 0 0; 

    /* ВИДАЛЕНО БАЗОВУ КОРЕКЦІЮ: margin-top та line-height тепер у класах шрифтів */
    /* margin-top: -0.1em; */
    /* line-height: 1; */ 
    
    display: block; 
    box-sizing: border-box; 
}

/* --- ВЕРТИКАЛЬНА КОРЕКЦІЯ ТА LINE-HEIGHT (КЛАСИ ШРИФТІВ) --- */

/* Коригування основного тексту (наприклад, Source Sans, Minion Pro) */
.font-TimesNewRomanPSMT, .font-T1_0, .font-T1_1, .font-T1_2, .font-T1_3, .font-TT0, .font-TT1, .font-C0_0, .font-C0_1 {
    /* Базова корекція для вирівнювання основного тексту */
    margin-top: -0.1em; 
    line-height: 1.1; 
}

/* НОВЕ ВИПРАВЛЕННЯ: Спускаємо заголовки помітно нижче */
.heading-text {
    /* Зміщує ВНИЗ для точного позиціонування заголовків */
    margin-top: 0.1em; 
    line-height: 0.9;
}

/* --- ТОЧКОВЕ ВИПРАВЛЕННЯ ДЛЯ ОБКЛАДИНКИ --- */

.p1 .heading-text {
    margin-top: -0.2em;
    margin-left: -15px;
    font-weight: 900 !important;
}

.p1 .heading-text + .heading-text {
    margin-top: -0.2em;
    margin-left: -15px;
    font-weight: 900 !important;
}

/* 3. Текст знизу */
.p1 .text-block:not(.heading-text) {
    margin-top: 1.2em;
}

/* Скасовуємо Impact для 4-ї сторінки і ставимо основний шрифт */
.p4 .font-Impact {
    font-family: 'Source Sans 3', sans-serif !important;
    font-weight: 900 !important;
    letter-spacing: normal;
}
.vertical-label {
    transform-origin: left top !important;
    white-space: nowrap !important;
    transform: rotate(270deg);
}

/* --- ГРАДАЦІЯ МАСШТАБУВАННЯ ДЛЯ АДАПТАЦІЇ --- */

/* Середні екрани (769px - 1200px) */
@media (min-width: 769px) and (max-width: 1199px) { 
    .text-block {
        transform: scale(0.80); /* Базове зменшення для ноутбуків */
    }
}

/* Великі екрани (1200px +) */
@media (min-width: 1200px) { 
    .text-block {
        transform: scale(1); /* Базове зменшення для великих моніторів */
    }

    /* Тонке налаштування основного тексту: робимо його трохи більшим */
    .font-TimesNewRomanPSMT, .font-T1_0, .font-T1_1 {
        transform: scale(0.75); 
    }
    
    /* Тонке налаштування заголовків (Impact) */
    .font-C2_0, .font-C2_1 {
        transform: scale(0.70); 
    }

    .vertical-label { transform: rotate(270deg) scale(0.8) !important; }
}

/* ДІАПАЗОН 1: МОБІЛЬНІ/МАЛІ ПЛАНШЕТИ (ДО 768px) */
@media (max-width: 768px) { 
    .text-block {
        /* Агресивне зменшення, щоб компенсувати велику висоту екрана (VH) */
        transform: scale(0.60); 
    }
    
    /* Тонке налаштування основного тексту на мобільному */
    .font-TimesNewRomanPSMT, .font-T1_0, .font-T1_1 {
        transform: scale(0.65); 
    }

    .vertical-label { transform: rotate(270deg) scale(0.6) !important; }
}

/* --- КІНЕЦЬ ГРАДАЦІЇ --- */


/* Стилі для зображень та векторів */
.page-asset {
    position: absolute;
    display: block; 
    min-width: 0; 
    min-height: 0;
}

.page-background {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-size: 100% 100%; 
    z-index: 1; /* Найнижчий шар */
}
/* --- КІНЕЦЬ КРИТИЧНИХ СТИЛІВ --- */

.page-background {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-size: 100% 100%; 
    z-index: 1; /* 1. ФОН (найнижчий) */
}

.page-asset {
    position: absolute;
    display: block; 
    min-width: 0; 
    min-height: 0;
    /* 2. ЗОБРАЖЕННЯ + ВЕКТОРНІ РАМКИ (z-index: 2-4 задається з Python) */
}

.text-block {
    position: absolute; 
    white-space: pre; 
    transform-origin: 0 0; 
    z-index: 5; /* 3. ТЕКСТ (найвищий) */
    /* ...інші ваші стилі для .text-block... */
}


/* --- НАВІГАЦІЯ ТА МЕНЮ (Ваші оригінальні стилі) --- */

.nav-button {
    position: fixed; top: 50%; transform: translateY(-50%); width: 44px; height: 44px;
    background-color: rgba(0,0,0,0.3); border: none; border-radius: 50%; cursor: pointer;
    z-index: 100; transition: all 0.2s ease-in-out;
}

.arrow-svg { width: 100%; height: 100%; overflow: visible; transform: scale(1.35); }
.arrowhead { transform-origin: center center; }
.ring-arc { fill: none; stroke: white; stroke-width: 2; stroke-dasharray: 66; stroke-dashoffset: 66; }
.nav-button.is-animating .arrowhead { animation: animate-arrowhead 1.2s ease-in-out forwards; }
#prev-page.is-animating .arrowhead { animation-name: animate-arrowhead-prev; }
.nav-button.is-animating .ring-arc { animation: animate-ring 1.2s ease-in-out forwards; }
@keyframes animate-ring { 0%, 25% { stroke-dashoffset: 66; } 75% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -66; } }
@keyframes animate-arrowhead { 0% { opacity: 1; transform: translateX(0) scaleY(1); } 25% { opacity: 0; transform: translateX(10px) scaleY(0.1); } 74% { opacity: 0; transform: translateX(-10px) scaleY(0.1); } 75% { opacity: 0; transform: translateX(-10px) scaleY(0.1); } 100% { opacity: 1; transform: translateX(0) scaleY(1); } }
@keyframes animate-arrowhead-prev { 0% { opacity: 1; transform: translateX(0) scaleY(1); } 25% { opacity: 0; transform: translateX(-10px) scaleY(0.1); } 74% { opacity: 0; transform: translateX(10px) scaleY(0.1); } 75% { opacity: 0; transform: translateX(10px) scaleY(0.1); } 100% { opacity: 1; transform: translateX(0) scaleY(1); } }
.nav-button:active { transform: translateY(-50%) scale(0.95); transition-duration: 0.1s; }
.nav-button.disabled { opacity: 0.2; cursor: not-allowed; pointer-events: none; }
#prev-page { left: 20px; }
#next-page { right: 20px; }
#menu-button { position: fixed; top: 20px; left: 20px; transform: none; width: 44px; height: 44px; background-color: rgba(0,0,0,0.3); border: none; border-radius: 50%; cursor: pointer; z-index: 101; transition: transform 0.2s ease, background-color 0.2s ease; display: flex; align-items: center; justify-content: center; }
#menu-button:hover { background-color: rgba(0,0,0,0.5); transform: scale(1.1); }
#menu-button .line { transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1); }
#menu-button:hover .top { transform: translateX(-4px); }
#menu-button:hover .bottom { transform: translateX(4px); }
#menu-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 200; display: flex; justify-content: center; align-items: center; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.3s ease, visibility 0s 0.3s; background-color: rgba(0, 0, 0, 0.7); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#menu-overlay.open { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 0.3s ease; }
#menu-content { position: relative; background-color: #FDFDF5; max-height: 85vh; width: 80vw; max-width: 900px; color: #333; padding: 40px 50px; border-radius: 3px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); border: 1px solid #ddd; overflow-y: auto; }
#menu-content h2 { margin-top: 0; margin-bottom: 30px; text-align: center; font-family: Georgia, 'Times New Roman', serif; font-weight: normal; font-size: 2.5em; color: #333; border-bottom: 1px solid #ccc; padding-bottom: 15px; }
#menu-content::-webkit-scrollbar { display: none; }
#toc-list { list-style: none; padding: 0; margin: 0; column-count: 2; column-gap: 40px; column-rule: 1px solid #eee; }
#toc-list li { margin-bottom: 12px; break-inside: avoid; page-break-inside: avoid; }
#toc-list a { display: flex; align-items: baseline; text-decoration: none; color: #444; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 1em; position: relative; overflow: hidden; transition: transform 0.1s ease; }
#toc-list a:hover, #toc-list a:hover .toc-title { color: #000; }
#toc-list a::after { content: ''; flex-grow: 1; border-bottom: 1px dotted #999; margin: 0 0.5em 0.3em; order: 2; }
#toc-list a:active { transform: scale(0.98); }
.toc-title { order: 1; background-color: #FDFDF5; padding-right: 5px; display: inline-block; transition: transform 0.3s ease-out; }
.toc-title::before { content: '➤'; margin-right: 8px; transition: color 0.2s ease; }
.toc-page-num { order: 3; font-weight: bold; background-color: #FDFDF5; padding-left: 5px; }
#close-menu { position: fixed; top: 20px; right: 30px; background: none; border: none; color: white; font-size: 40px; font-weight: 300; line-height: 1; cursor: pointer; opacity: 0.8; transition: opacity 0.2s ease, transform 0.2s ease; z-index: 210; }
#close-menu:hover { opacity: 1; transform: scale(1.2) rotate(90deg); }
#toc-list a:hover .toc-title { transform: translateX(20px); color: #000; }
@media (max-width: 768px) { #menu-content { width: 90vw; max-width: 400px; max-height: 85vh; padding: 30px 25px; } #menu-content h2 { font-size: 2em; margin-bottom: 20px; padding-bottom: 10px; } #toc-list { column-count: 1; column-rule: none; } .nav-button, #menu-button { width: 38px; height: 38px; } #prev-page { left: 5px; } #next-page { right: 5px; } #menu-button { top: 10px; left: 10px; } }


/* ====================================================== */
/* ========== РЕЖИМ ПРЕМІУМ-ЛУПИ ТА КУРСОРУ ============ */
/* ====================================================== */

/* 1. ВЕЛИКЕ ВІКНО ЗУМУ (Magnifier Window) */
.magnifier {
    position: fixed;
    width: 1000px;
    height: 250px;
    border: none;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    box-shadow: 0 25px 80px rgba(0,0,0,0.35);
    z-index: 10000;
    pointer-events: none;
    overflow: hidden;
    display: none;
    border-radius: 20px;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.magnifier.active {
    display: block;
    opacity: 1;
    transform: scale(1);
}

.magnifier-content {
    position: absolute;
    transform-origin: 0 0;
    will-change: left, top;
}

/* 2. ПРИХОВУВАННЯ СТАНДАРТНОГО КУРСОРУ */
#flipbook .page {
    cursor: none !important;
}

/* Повертаємо долоньку turn.js у кутах */
#flipbook .page.on-corner {
    cursor: pointer !important;
}

/* 3. КАСТОМНИЙ КУРСОР-ЛІНЗА */
.custom-cursor {
    position: fixed;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 10001;
    display: none;
    
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05));
    border: 1.5px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15), 0 10px 25px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    
    overflow: visible; 
    transition: transform 0.15s cubic-bezier(0.23, 1, 0.32, 1);
}

/* РУЧКА ЛУПИ */
.custom-cursor::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 5px;
    background: rgba(255, 255, 255, 0.95);
    bottom: -3px;
    right: -6px;
    transform: rotate(45deg);
    border-radius: 4px;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.4);
    transition: opacity 0.2s ease;
    z-index: 1;
}

/* ЕФЕКТ БЛИСКУ (SHINE) */
/* Використовуємо окремий div всередині курсору для блиску */
.cursor-shine {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    border-radius: 50%;
    overflow: hidden; /* Обмежуємо блиск колом */
    pointer-events: none;
    z-index: 2;
}

.cursor-shine::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -150%;
    width: 60%;
    height: 200%;
    background: linear-gradient(
        90deg, 
        transparent, 
        rgba(255, 255, 255, 0.6), 
        transparent
    );
    transform: rotate(35deg);
    animation: premium-shine 10s infinite;
}

@keyframes premium-shine {
    0%   { left: -150%; }
    8%   { left: 150%; }
    100% { left: 150%; }
}

/* СТАН ХРЕСТИКА */
.custom-cursor.active .cursor-shine::before {
    animation: none; /* Вимикаємо блиск, коли активна лупа */
    display: none;
}

.custom-cursor.active::after {
    opacity: 0; /* Ховаємо ручку */
}

/* Сам хрестик */
.custom-cursor.active::before {
    content: '+';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    transform: rotate(45deg);
    z-index: 3;
}


.no-zoom {
    cursor: pointer !important;
    pointer-events: auto !important;
    position: relative;
    z-index: 100;
}

.ignore-zoom {
    cursor: pointer !important;
}
/* ====================================================== */
/* ========== ФІНАЛЬНЕ ОНОВЛЕНЕ МЕНЮ (TOC) ============== */
/* ====================================================== */

#toc-list {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    column-count: 2;
    column-gap: 40px;
}

/* Кожен пункт меню */
.toc-item {
    position: relative;
    margin-bottom: 12px;
    padding: 8px 12px !important;
    border-left: 5px solid var(--accent-color) !important; /* Колір з JS */
    background: rgba(255, 255, 255, 0.4);
    transition: all 0.2s ease-in-out;
    break-inside: avoid;
    display: block !important;
}

.toc-item:hover {
    background: #ffffff !important;
    transform: translateX(8px);
    box-shadow: 4px 4px 15px rgba(0,0,0,0.1);
}

/* --- ВІДСТУПИ МІЖ ГРУПАМИ --- */
.toc-group-info + .toc-group-product {
    margin-top: 35px !important;
}

.toc-group-product + .toc-group-contact {
    margin-top: 35px !important;
}

/* --- ТЕКСТ ТА ПРИБИРАННЯ СТАРИХ СТИЛІВ --- */
.toc-item a {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center;
    text-decoration: none !important;
}

/* Прибираємо старі стрілки ➤ та цятки */
.toc-title::before, .toc-item a::after {
    display: none !important;
}

.toc-title {
    color: #333 !important;
    font-family: 'Source Sans 3', sans-serif !important;
    font-size: 1.05em;
    background: none !important;
    padding: 0 !important;
}

.toc-page-num {
    color: var(--accent-color) !important; /* Номер у колір лінії */
    font-weight: 900 !important;
    font-size: 1.1em;
    background: none !important;
}

/* Мобільна версія меню (TOC) */
@media (max-width: 768px) {
    /* 1. Позиціонування хрестика (опустили ще нижче) */
    #close-menu {
        top: 70px !important; 
        right: 25px !important;
        font-size: 45px !important; /* Трохи збільшили для зручності */
        opacity: 0.6;
    }

    #menu-content { 
        width: 92vw; 
        padding: 35px 20px !important; 
        margin-top: 40px; 
    }

    #menu-content h2 { 
        font-size: 1.6em !important; 
        margin-bottom: 25px !important; 
    }

    #toc-list { 
        column-count: 1; 
    }

    .toc-item {
        margin-bottom: 10px !important;
        padding: 10px 14px !important;
    }

    /* 3. Шрифти (залишили як було, вони тепер збалансовані) */
    .toc-title {
        font-size: 0.9em !important;
    }

    .toc-page-num {
        font-size: 0.95em !important;
        font-weight: 700 !important;
    }

    /* 2. Логічні відступи (тільки "повітря", без ліній) */
    .toc-group-info + .toc-group-product,
    .toc-group-product + .toc-group-contact {
        margin-top: 45px !important; /* Збільшили відступ для чіткого поділу */
        border-top: none !important; /* Прибрали лінію */
        padding-top: 0 !important;
    }
}
/* Ультра-компактний режим для маленьких телефонів (iPhone SE та подібні) */
@media (max-width: 390px) {
    /* 1. Позиція хрестика - піднімаємо трохи вище, бо екран дуже короткий */
    #close-menu {
        top: 25px !important;
        right: 15px !important;
        font-size: 32px !important;
    }

    #menu-content { 
        width: 95vw; 
        padding: 15px 10px !important; 
        margin-top: 15px; 
        max-height: 90vh; /* Обмежуємо висоту, щоб з'явився внутрішній скрол, якщо треба */
    }

    #menu-content h2 { 
        font-size: 1.3em !important; 
        margin-bottom: 12px !important; 
        padding-bottom: 8px !important;
    }

    /* Ущільнюємо кожен рядок */
    .toc-item {
        margin-bottom: 4px !important;
        padding: 5px 10px !important;
    }

    /* 3. Шрифти - ще трохи менші для стабільності */
    .toc-title {
        font-size: 0.85em !important;
    }

    .toc-page-num {
        font-size: 0.9em !important;
    }

    /* 2. Логічні відступи - зменшуємо, щоб все влізло без скролу */
    .toc-group-info + .toc-group-product,
    .toc-group-product + .toc-group-contact {
        margin-top: 20px !important; 
    }
}

/* ====================================================== */
/* ============== Закладка - Контакти =================== */
/* ====================================================== */
#ascania-wide-tab {
    position: absolute;
    top: -19px; 
    width: 95px;
    height: 180px; 
    z-index: 5;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    
    /* Плавність: margin для ховеру, left для зміни сторінок */
    transition: margin-left 0.8s cubic-bezier(0.25, 0.1, 0.25, 1), 
                left 0.4s ease-in-out;
    margin-left: 0;
    will-change: margin-left, left;
}

/* --- ВЕРХНЯ ЧАСТИНА (ШАПКА) --- */
.tab-visible-part {
    position: relative;
    width: 100%;
    height: 25px; 
    background: #e30613; /* Фірмовий червоний */
    border-radius: 4px 4px 0 0;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #b3050f;
    border-bottom: none;
    box-shadow: 0 -1px 4px rgba(0,0,0,0.2);
    overflow: hidden; /* Контейнер для відблиску */
}

.tab-visible-part span {
    color: #ffffff;
    font-family: 'Source Sans 3', sans-serif;
    font-weight: bold;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    z-index: 2;
}

/* --- ЕФЕКТ ШОВКОВОГО БЛИСКУ --- */
.tab-glare {
    position: absolute;
    top: 0;
    left: -150%;
    width: 60%;
    height: 100%;
    background: linear-gradient(
        90deg, 
        transparent, 
        rgba(255, 255, 255, 0.4), 
        transparent
    );
    transform: skewX(-20deg);
    z-index: 1;
}

/* --- ТІЛО ЗАКЛАДКИ (ГРАДІЄНТ ТА ХВІСТ) --- */
.tab-hidden-body {
    width: 100%;
    flex-grow: 1;
    background: linear-gradient(to bottom, #e30613, #9e040d);
    border: 1px solid #b3050f;
    border-top: none;
    position: relative;
    /* Форма ластівчиного хвоста */
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 50% 92%, 0% 100%);
}

/* Декоративна біла прострочка */
.tab-stitch {
    position: absolute;
    top: 5px; left: 5px; right: 5px; bottom: 20px;
    border: 1px dashed rgba(255, 255, 255, 0.3);
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 50% 92%, 0% 100%);
}

/* Декоративний текст всередині */
.tab-decorative-text {
    position: absolute;
    top: 50px;
    width: 100%;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 8px;
    font-weight: bold;
    letter-spacing: 1.5px;
    font-family: sans-serif;
}

/* --- ЕФЕКТИ ПРИ НАВЕДЕННІ (HOVER) --- */
#ascania-wide-tab:hover {
    margin-left: 10px; /* Плавний зсув вправо */
    filter: brightness(1.1);
}

#ascania-wide-tab:hover .tab-glare {
    left: 150%;
    transition: left 0.8s ease-in-out;
}

/* Плавність для закладки */
#bookmark {
    transition: opacity 0.5s ease, visibility 0.5s ease;
    opacity: 1;
    visibility: visible;
}

/* Клас для ховання */
#bookmark.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* Щоб на неї не можна було клікнути, коли вона прозора */
}

/* --- МОБІЛЬНА ВЕРСІЯ --- */
@media (max-width: 768px) {
    #ascania-wide-tab { 
        width: 85px; 
        top: -30px; /* Піднімаємо вище у вільне місце */
        height: 160px; 
        transition: margin-left 0.6s ease-in-out;
    }

    #ascania-wide-tab:hover {
        margin-left: 6px;
    }

    .tab-visible-part {
        height: 38px; /* Робимо червону зону вищою */
        align-items: flex-start; /* Текст піднімаємо до краю */
        padding-top: 6px;
    }

    .tab-visible-part span {
        font-size: 9px;
    }

    .tab-decorative-text {
        top: 60px;
        font-size: 7px;
    }
}