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

body {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 20px;
    line-height: 1.8;
    color: #111;
    background: #f0ece3;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── HEADER ─────────────────────────────────────────── */

.site-header {
    background: #1a2e4a;
    padding: 1.25rem 2rem;
    flex-shrink: 0;
    text-align: center;
}

.site-logo {
    text-decoration: none;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.site-header h1 {
    font-size: 1.7rem;
    color: #e8d5a3;
    letter-spacing: 0.04em;
}

.site-header p {
    font-size: 0.85rem;
    color: #7a9bbf;
}

/* ── BANNER ─────────────────────────────────────────── */

.site-banner {
    margin-top: 1rem;
}

.site-banner__img {
    display: block;
    width: 100%;
    max-width: 1160px;
    height: 220px;
    margin: 0 auto;
    object-fit: cover;
    object-position: center 30%;
    border-radius: 4px;
    opacity: 0.9;
}

/* Пока баннера нет — скрываем блок */
.site-banner:not(:has(img[src])) { display: none; }

/* ── LAYOUT ─────────────────────────────────────────── */

.layout {
    display: flex;
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 1.5rem auto 2rem;
    padding: 0 1.5rem;
    gap: 1.5rem;
    align-items: flex-start;
}

/* ── SIDEBAR ─────────────────────────────────────────── */

.sidebar {
    flex: 0 0 230px;
    position: sticky;
    top: 1.5rem;
}

.sidebar-nav {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    overflow: hidden;
}

/* Секция (корневой раздел) */
.nav-section { border-bottom: 1px solid #e8e0d0; }
.nav-section:last-child { border-bottom: none; }

.nav-section-link {
    display: block;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #1a2e4a;
    text-decoration: none;
    font-weight: 600;
    line-height: 1.4;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.nav-section-link:hover {
    background: #f5f0e8;
    color: #c8a84b;
    border-left-color: #c8a84b;
}

.nav-section-link.active {
    background: #f5f0e8;
    color: #1a2e4a;
    border-left-color: #1a2e4a;
}

/* Дочерние страницы — скрыты по умолчанию */
.nav-children {
    list-style: none;
    background: #faf8f4;
    display: none;
    border-top: 1px solid #e8e0d0;
}

/* Показываем детей когда раздел открыт */
.nav-section.open .nav-children {
    display: block;
}

.nav-children li { border-bottom: 1px solid #ede8df; }
.nav-children li:last-child { border-bottom: none; }

.nav-children a {
    display: block;
    padding: 0.6rem 1rem 0.6rem 1.5rem;
    font-size: 0.92rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #444;
    text-decoration: none;
    line-height: 1.4;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
}

.nav-children a:hover {
    background: #f0ece3;
    color: #1a2e4a;
}

.nav-count {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.1rem 0.45rem;
    font-size: 0.75rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #fff;
    background: #7a9bbf;
    border-radius: 10px;
    vertical-align: middle;
    line-height: 1.4;
}

.nav-section-link.active .nav-count {
    background: #1a2e4a;
}

.nav-children a.active {
    color: #1a2e4a;
    font-weight: 600;
    border-left-color: #c8a84b;
    background: #f0ece3;
}

/* ── MAIN CONTENT ─────────────────────────────────────── */

.main-content {
    flex: 1;
    min-width: 0;
}

article {
    background: #fff;
    padding: 2rem 2.5rem;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

article h1 {
    font-size: 1.8rem;
    color: #1a2e4a;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e8d5a3;
    line-height: 1.35;
}

.annotation {
    font-style: italic;
    color: #555;
    margin-bottom: 1.5rem;
    font-size: 1.05rem;
}

/* ── CONTENT ──────────────────────────────────────────── */

.content { margin: 1.5rem 0; }

.content p         { margin-bottom: 1.25rem; }
.content h2        { font-size: 1.5rem; color: #1a2e4a; margin: 2rem 0 0.75rem; }
.content h3        { font-size: 1.25rem; margin: 1.5rem 0 0.5rem; }
.content h4        { font-size: 1.1rem; margin: 1.25rem 0 0.4rem; }
.content ul,
.content ol        { margin: 0 0 1.25rem 1.75rem; }
.content li        { margin-bottom: 0.4rem; }
.content img       { max-width: 100%; height: auto; margin: 1rem 0; border-radius: 3px; display: block; }
.content a         { color: #2a5298; }
.content a:hover   { text-decoration: underline; }
.content strong    { font-weight: 700; }
.content em        { font-style: italic; }
.text-center       { text-align: center; }
.text-right        { text-align: right; }

/* ── META ──────────────────────────────────────────────── */

.meta {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #e8e0d0;
    font-size: 0.82rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #999;
    display: flex;
    gap: 1.5rem;
}

/* ── FOOTER ──────────────────────────────────────────────── */

.site-footer {
    background: #1a2e4a;
    color: #7a9bbf;
    text-align: center;
    padding: 1.25rem 2rem;
    font-size: 0.82rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.9;
    flex-shrink: 0;
}

/* ── CHILDREN LIST ────────────────────────────────────────── */

.children-list {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 2px solid #e8d5a3;
}

.children-list h2 {
    font-size: 1.4rem;
    color: #1a2e4a;
    margin-bottom: 1.25rem;
}

.children-list ul {
    list-style: none;
}

.children-list li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e8e0d0;
}

.children-list li:last-child {
    border-bottom: none;
}

.children-list a {
    text-decoration: none;
    color: #1a2e4a;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.children-list a:hover .children-list__title {
    color: #c8a84b;
    text-decoration: underline;
}

.children-list__title {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.4;
}

.children-list__anno {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

.children-list__date {
    font-size: 0.85rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #999;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── RESPONSIVE ──────────────────────────────────────────── */

@media (max-width: 768px) {
    .layout {
        flex-direction: column;
        padding: 0 1rem;
        margin-top: 1rem;
    }

    .sidebar {
        flex: none;
        width: 100%;
        position: static;
    }

    /* На мобиле показываем всех детей сразу */
    .nav-children { display: block; }

    article { padding: 1.25rem; }

    article h1 { font-size: 1.4rem; }

    .children-list li { flex-direction: column; gap: 0.25rem; }
    .children-list__date { align-self: flex-start; }

    .site-header a { flex-direction: column; gap: 0.25rem; }
}
