@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap');

/* ==========================================================
   БАЗОВЫЕ НАСТРОЙКИ
   ========================================================== */
:root {
    --bg-color: #000000;
    --text-color: white;
    --accent-color: #ddcdb3;
    --accent-gold: #ddcdb3;
    --accent-blue: #cce2f5;
    --border-color: #333333;
    --font-main: "Roboto", sans-serif;
    font-weight: 300;
}

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

body {
    background-color: var(--bg-color);
    color: white;
    font-family: var(--font-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

a { text-decoration: none; color: var(--text-color); transition: 0.3s ease; }
a:hover { color: var(--accent-gold); }

.reading-screen a > img { margin: 10px auto; display: block; max-width: 80vw; height: auto; }
.reading-screen a { color: #cce2f5; }

p { margin: 1.4rem auto; word-break: break-word; }
h1, h2, h3, h4, h5, h6 { margin: 1.4rem auto; font-weight: 300; }
.contentDiv h1, .contentDiv h2, .contentDiv h3, .contentDiv h4, .contentDiv h5, .contentDiv h6 { color: #cce2f5; }

ol, ul { padding-left: 20px; }
h4, h5, h6 { text-align: center; }
h4 { font-size: 1.6rem; }
h5 { font-size: 1.6rem; }
h6 { font-size: 1.4rem; }
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { color: #d9a857 !important; }
hr { border-bottom-width: 0; }

blockquote { border-left: 2px solid #8080807d; padding: 0 15px; margin: 10px auto; }
blockquote blockquote { border: none; }
blockquote p { margin: 0.5rem auto; }

.reading-screen img { max-width: 100%; background: white; }
.aab-cover { display: none; }

/* --- ВЕРХНЕЕ МЕНЮ (3 ЗАЛА) --- */
.top-nav {
    display: flex;
    align-items: flex-end;
    width: 100%;
    max-width: 1000px;
    margin-bottom: 15px;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 15px;
}

.active-nav span { color: var(--accent-gold); }
.nav-img { width: 78px; object-fit: cover; transition: box-shadow 0.3s ease, transform 0.3s ease; }

/* ---------------------- */
/* --- ОБРАТНАЯ СВЯЗЬ --- */
.footer { margin-bottom: 30px; }
.feedback-link { display: flex; flex-direction: column; align-items: center; gap: 10px; }

/* --- МОДАЛЬНЫЕ ОКНА --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s ease;
}

.modal-overlay.active { display: flex; opacity: 1; visibility: visible; }

.modal-content {
    background-color: #111;
    border: 1px solid var(--accent-gold);
    padding: 20px;
    border-radius: 10px;
    position: relative;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.2);
    line-height: 1.6;
    color: #ddcdb3;
}

.text-center { text-align: center; }
.feedback-form { display: flex; flex-direction: column; gap: 15px; margin-top: 20px; }

.feedback-form input,
.feedback-form textarea {
    width: 100%;
    padding: 12px;
    background-color: #000;
    border: 1px solid var(--border-color);
    color: #fff;
    border-radius: 5px;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.feedback-form input:focus, .feedback-form textarea:focus { outline: none; border-color: var(--accent-blue); }

.submit-btn {
    padding: 15px;
    background-color: #d9a857;
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: 0.3s;
    -webkit-appearance: none;
    appearance: none;
}

.submit-btn:hover { background-color: #0088cc; }

.contentDiv {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 15px;
    margin-bottom: 8rem;
    max-width: 1000px;
    color: white;
}

.social-links { text-align: center; margin: 45px 0 55px 0; }
.social-icon { height: 50px; }
.social-item:nth-child(3) .social-icon { height: 55px; }
.social-item:nth-child(5) .social-icon { height: 60px; }
a.social-item { padding: 0 8px; }

h1.main-hero {
    font-size: 1rem;
    font-weight: 400;
    margin-bottom: 12px;
    width: 100%;
    max-width: 900px;
    text-align: center;
}

h1.main-hero:has(img) {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 10px;
    margin-bottom: 70px;
}

.header { padding: 20px 0px 7px 20px; width: 100%; }
.federation { width: 185px; margin: 0 20px; }
.federation-line { height: 35px; transform: translateY(2px); }
.separator { margin: 0 0 35px 0; }
.nav-img.icon_reading_room_icon { width: 145px; }
.nav-img.icon_tablschema { width: 145px; }
.shtangist { width: 500px; display: block; }
.krossovok { height: 80px; opacity: 0.75; display: flex; margin: auto; }

/* =========== СТИЛИ ЧИТАЛЬНОГО ЗАЛА =========== */
.books-container { font-size: 1.1rem; max-width: 1000px; width: 100%; }
.books-container a { color: #f0e6d8; }
.section-label { margin: 30px auto; }
.section-label span { letter-spacing: 4px; text-transform: uppercase; color: #a4a4a4; white-space: nowrap; }
.section-label::before, .section-label::after { content: ''; flex-grow: 1; height: 1px; background: #1a1a1a; }
.books-simple-list li { margin: 0.5rem 0; }

/* ==========================================================
   ОБЩИЕ СТИЛИ ДЛЯ ЧИТАЛОК (read.html & readAAB.php)
   ========================================================== */
.reading-screen,
#reading-screen {
    width: 900px;
    max-width: 100%;
    margin: 0 auto;
    padding: 40px 10px;
    display: flex;
    flex-direction: column;
    font-weight: 300;
    line-height: 1.7;
    font-size: 1.1rem;
    position: relative;
    color: #ddcdb3;
}

.chapter-block { margin-bottom: 60px; }

.chapter-source {
    font-size: 1.4rem;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    font-weight: 400;
    color: var(--accent-color);
}

.chapter-divider { border: none; border-top: 1px solid var(--border-color); margin: 60px 0 50px; opacity: 0.4; }
.content-area ul { padding-left: 25px; margin-bottom: 1.5rem; }
.content-area li { margin-bottom: 0.5rem; }

/* Унифицированное оглавление */
.toggleContents {
    position: fixed;
    right: 0px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 200;
    background: #0a0a0a;
    border: 1px solid var(--accent-color);
    border-right: none;
    color: var(--accent-color);
    cursor: pointer;
    writing-mode: vertical-rl;
    padding: 16px 10px;
    font-family: var(--font-main);
    font-size: 0.8rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    border-radius: 4px 0 0 4px;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s, color 0.2s;
}

.toggleContents:hover { background: var(--accent-color); color: #000; }
@media (min-width: 992px) { body.outline-open .toggleContents { right: 400px; } }

.doc-outline-sidebar {
    position: fixed;
    right: -110%;
    top: 0;
    height: 100vh;
    width: 100%;
    background: #050505;
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 60px 0 40px;
    z-index: 100;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
    -webkit-overflow-scrolling: touch;
}

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: #111; }
::-webkit-scrollbar-thumb { background: var(--accent-gold); border-radius: 5px; border: 2px solid #111; }
::-webkit-scrollbar-thumb:hover { background: #ffffff; }

@media (max-width: 991px) {
    .doc-outline-sidebar { transition: right 0.3s ease; }
    .doc-outline-sidebar.open { right: 0; }
    
    .toggleContents {
        writing-mode: horizontal-tb;
        top: auto;
        bottom: 24px;
        right: 16px;
        transform: none;
        border: 1px solid var(--accent-color);
        border-radius: 50px;
        padding: 10px 18px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
    }
    body.outline-open .toggleContents { opacity: 0; pointer-events: none; }
}

@media (min-width: 992px) {
    .doc-outline-sidebar {
        width: 400px;
        right: -420px;
        padding-top: 30px;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.6);
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .doc-outline-sidebar.open { right: 0; }
}

.book-spoiler { border-bottom: 1px solid #1a1a1a; }
.book-spoiler:first-child { border-top: 1px solid #1a1a1a; }

.book-spoiler summary {
    display: block;
    padding: 15px 20px;
    font-size: 0.95rem;
    color: #888;
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: color 0.15s, background 0.15s;
    list-style: none;
    user-select: none;
}

.book-spoiler summary::-webkit-details-marker { display: none; }
.book-spoiler summary:hover, .book-spoiler[open] summary { color: var(--text-color); background: #0d0d0d; border-left-color: var(--accent-color); }
.book-parts-list { display: flex; flex-direction: column; background: #000000; }

.outline-item {
    display: block;
    padding: 10px 20px 10px 35px;
    font-size: 0.85rem;
    color: #666;
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: color 0.15s, background 0.15s;
    width: 100%;
    box-sizing: border-box;
}

.outline-item:hover { color: var(--accent-color); background: #111; }
.outline-item.active { color: var(--accent-color); background: #1a1a1a; border-left-color: var(--accent-color); font-weight: bold; }

/* ==========================================================
   Стили для детального оглавления книг AAB (аккордеон)
   ========================================================== */
.accordion { width: 100%; background: #000; }

.accordion .tableHead {
    background-color: #0c0c0c;
    border-bottom: 1px solid #141414;
    border-top: 1px solid #141414;
    color: var(--accent-gold);
    text-transform: uppercase;
    font-weight: 500;
    font-size: 1rem;
    padding: 10px 20px;
    letter-spacing: 2px;
    cursor: default;
    user-select: none;
    display: flex;
    align-items: center;
    transition: background-color 0.15s, color 0.15s;
}

.accordion .tableHead.collapsible { cursor: pointer; }
.accordion .tableHead.collapsible:hover { background-color: #111; color: var(--text-color); }

.accordion .tableHead.collapsible::before {
    content: '▸';
    display: inline-block;
    margin-right: 10px;
    transition: transform 0.2s ease;
    font-size: 0.9rem;
    color: #666;
}

.accordion .tableHead.collapsible:not(.collapsed)::before { transform: rotate(90deg); color: var(--accent-gold); }
.accordion .spisok { background: #050505; }
.accordion .spisok ul { list-style: none; padding: 0; margin: 0; }

.accordion .spisok li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #0f0f0f;
    position: relative;
    width: 100%;
    margin: 0;
}

.accordion .spisok li:hover { background-color: #0d0d0d; }

.accordion .spisok li a {
    display: block;
    flex-grow: 1;
    padding: 8px 10px 8px 20px;
    font-size: 0.85rem;
    color: #888;
    text-decoration: none;
    transition: color 0.15s, background-color 0.15s, border-left-color 0.15s;
    border-left: 3px solid transparent;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.accordion .spisok li a:hover { color: var(--accent-gold); background-color: #111; }
.accordion .spisok li a.active { color: var(--accent-gold); background-color: rgba(212, 175, 55, 0.06); border-left-color: var(--accent-gold); font-weight: 500; }

.accordion .spisok li span {
    font-size: 0.75rem;
    color: #555;
    padding-right: 15px;
    flex-shrink: 0;
    user-select: none;
}

/* Обозначение уровней вложенности отступами */
.accordion .spisok li.x1 {
    text-align: center;
    display: block;
    opacity: 0.6;
    background: #ffffff2e;
    padding: 2px 0;
}

.accordion .spisok li.x1 a { padding-left: 20px; }

.accordion .spisok li.x2 a {
    padding-left: 20px;
    text-transform: uppercase;
    font-size: 0.8rem;
    color: #aaa;
    font-weight: 500;
}

.accordion .spisok li.x3 a { padding-left: 35px; color: #8c8c8c; }
.accordion .spisok li.x4 a { padding-left: 48px; color: #7c7c7c; }
.accordion .spisok li.x5 a { padding-left: 60px; color: #6c6c6c; font-style: italic; }
.accordion .spisok li.x6 a { padding-left: 35px; color: #a29bfe; font-weight: 400; }
.accordion .spisok li.x7 a { padding-left: 30px; }
.rays { padding-left: 10px; }

/* ==========================================================
   СПЕЦИФИЧЕСКИЕ СТИЛИ КНИЖНОЙ ВЕРСТКИ
   ========================================================== */
.accent { font-weight: bold; }

.page {
    text-align: center;
    position: relative;
    width: 3.5em;
    margin-left: -4.6em;
    margin-top: 0.3ex;
    float: left;
    display: inline;
    font-size: 0.9em;
    vertical-align: bottom;
}

.page a, .page a:visited { text-decoration: none; color: #999999; outline: none; }
table { width: 100%; max-width: 100%; margin-left: auto; margin-right: auto; }

.tablestyle table {
    border: 0;
    word-wrap: break-word;
    table-layout: fixed;
    width: 100%;
    text-align: left;
    border-top-style: none;
    border-left-style: none;
    margin: 0 auto 15px auto;
}

.tablestyle table, .tablestyle td, .tablestyle th { border: 1px dashed var(--border-color, #333333); width: auto; }
.tablestyle td, .tablestyle th { border-right-style: none; border-bottom-style: none; padding: 8px; }
.tablestyle th { font-weight: bold; text-align: left; }
a.tooltip { border-bottom: 1px dashed var(--accent-blue, #00a8ff); text-decoration: none; position: relative; }
a:hover.tooltip { padding: 0; text-decoration: none; }
.tooltip:hover span span { display: block; }
.tooltip span { position: absolute; text-decoration: none; }

.tooltip span span {
    display: none;
    position: absolute;
    background-color: #111111;
    border: 1px solid #ddcdb3;
    padding: 10px;
    color: var(--text-color, #ddcdb3);
    text-decoration: none;
    width: 250px;
    z-index: 100;
    top: 20px;
    left: -30px;
    font-family: var(--font-main, sans-serif);
    font-size: 0.9rem;
    font-style: normal;
    font-variant: normal;
    text-transform: none;
    text-align: left;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
}

/* --- Адаптивность только для специфичных книжных элементов --- */
@media (max-width: 1023px) {
    .page {
        font-size: 1.5ex;
        font-weight: bold;
        float: right;
        text-align: right;
        width: auto;
        margin-left: 3px;
        margin-top: 5px;
    }
    .tablestyle table { width: 100%; }
}

/* Адаптив базовых стилей (Включая iPad 5 Mini - 768px) */
@media (max-width: 768px) {
    :root { font-size: 13px; }
    .reading-screen, #reading-screen { padding: 15px 0; }
    .header { padding: 10px 10px 6px 30px; }
    .separator-text { font-size: 1rem; padding: 0 10px; }
    .modal-content { max-width: 79vw; }
    .federation { width: 119px; margin: 0 5px; }
    .federation-line { height: 26px; transform: translateY(0px); }
    .separator { margin: 0 0 20px 0; }
    .top-nav { margin-bottom: 18px; gap: 10px; }
    img.social-icon { height: 34px !important; }
    .nav-img { width: 48px; }
    .nav-img.icon_tablschema, .nav-img.icon_reading_room_icon { width: 78px; }
    .nav-item { gap: 10px; }
    .shtangist { max-width: 79vw; }
    .feedback-link { font-size: 0.9rem; gap: 5px; }
    .krossovok { height: 55px; transform: translateX(0px); }
    h1.main-hero:has(img) { margin-top: 0; margin-bottom: 25px; }
}

small:has(a) {
    border-bottom: 1px solid #ffffff5c;
    display: block;
    width: 100%;
    margin-bottom: 1rem;
    padding-bottom: 10px;
}