/* ── App Shell ── */
.app-body {
    display: flex;
    min-height: calc(100vh - var(--header-height));
    margin-top: var(--header-height);
}

/* ── Header ── */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    z-index: 200;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -.5px;
    user-select: none;
    text-decoration: none;
}

.logo-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 11px 10px;
}

.header-search {
    display: none;
}

.btn-search-trigger {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition);
}

.btn-search-trigger:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.btn-header {
    padding: 7px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background var(--transition), color var(--transition);
}

.btn-header-outline {
    background: transparent;
    border: 1.5px solid var(--accent);
    color: var(--accent);
}

.btn-header-outline:hover {
    background: var(--accent-light);
}

.btn-header-filled {
    background: var(--accent);
    color: #fff;
}

.btn-header-filled:hover {
    background: var(--accent-hover);
}

/* ── Search Modal ── */
.search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
    animation: fadeIn .15s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.search-modal {
    background: var(--bg-white);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
    width: 100%;
    max-width: 600px;
    padding: 8px 8px 16px;
    animation: slideDown .18s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-modal-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.search-modal-icon {
    font-size: 18px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-modal-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 18px;
    color: var(--text-primary);
    background: transparent;
    padding: 6px 0;
}

.search-modal-input::placeholder {
    color: var(--text-muted);
}

.search-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--transition);
}

.search-modal-close:hover {
    background: var(--border);
}

.search-hint {
    padding: 10px 20px 4px;
    font-size: 13px;
    color: var(--text-muted);
}

.search-hint kbd {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 12px;
    font-family: inherit;
}

/* ── Search results ── */
.search-results {
    display: flex;
    flex-direction: column;
    max-height: 420px;
    overflow-y: auto;
    padding: 4px 0;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--text-primary);
    transition: background var(--transition);
    border-radius: 8px;
    margin: 0 4px;
}

.search-result-item:hover {
    background: var(--bg);
}

.search-result-img {
    width: 52px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.search-result-body {
    flex: 1;
    min-width: 0;
}

.search-result-title {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Left Sidebar ── */
.sidebar-left-wrap {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    flex-shrink: 0;
}

.sidebar-right-wrap {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    flex-shrink: 0;
}

.sidebar-visible {
    animation: sidebar-in .2s ease;
}

@keyframes sidebar-in {
    from {
        opacity: 0;
        transform: translateX(-12px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sidebar-right-wrap {
    animation: sidebar-in-right .2s ease;
}

@keyframes sidebar-in-right {
    from {
        opacity: 0;
        transform: translateX(12px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Кнопка скрытия (внутри сайдбара) */
.sidebar-toggle {
    width: 20px;
    flex-shrink: 0;
    border: none;
    background: var(--border);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition);
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
}

.sidebar-toggle:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.sidebar-toggle-right {
    order: -1;
}

/* Кнопка показа (когда сайдбар скрыт) */
.sidebar-show {
    width: 20px;
    flex-shrink: 0;
    border: none;
    background: var(--bg);
    border-right: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition);
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    animation: sidebar-in .2s ease;
}

.sidebar-show-right {
    border-right: none;
    border-left: 1px solid var(--border);
    animation: sidebar-in-right .2s ease;
}

.sidebar-show:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.app-sidebar-left {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-section {
    margin-bottom: 4px;
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    padding: 8px 20px 4px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    border-radius: 0 24px 24px 0;
    margin-right: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    user-select: none;
}

.sidebar-item:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.sidebar-item.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

.sidebar-item .item-icon {
    font-size: 18px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-item .item-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 20px;
}

/* ── Main Content ── */
.app-main {
    flex: 1;
    padding: 24px;
    min-width: 0;
}

/* ── Right Sidebar ── */
.app-sidebar-right {
    width: var(--right-sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border);
    padding: 20px 16px;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
}

.toc-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.toc-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.toc-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1.4;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-item:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.toc-h1 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.toc-h2 {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    padding-left: 14px;
    border-left: 2px solid var(--border);
    margin-left: 6px;
}

.toc-h3 {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    padding-left: 22px;
    border-left: 2px solid var(--border);
    margin-left: 6px;
}

/* ── Footer ── */
.app-footer {
    background: #1a1a2e;
    color: #ccc;
    padding: 40px 48px 24px;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 32px;
    margin-bottom: 32px;
}

.footer-brand .footer-logo {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -.5px;
    margin-bottom: 10px;
}

.footer-brand p {
    font-size: 13px;
    line-height: 1.7;
    color: #9aa0a6;
    max-width: 260px;
}

.footer-col-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: #fff;
    margin-bottom: 14px;
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-links a {
    font-size: 13px;
    color: #9aa0a6;
    transition: color var(--transition);
}

.footer-links a:hover {
    color: #fff;
}

.footer-socials {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.social-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #ccc;
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
}

.social-btn:hover {
    background: var(--accent);
    color: #fff;
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, .08);
    padding-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #5f6368;
}

.footer-bottom a {
    color: #5f6368;
    transition: color var(--transition);
}

.footer-bottom a:hover {
    color: #fff;
}

.footer-edu {
    text-align: center;
    padding-top: 12px;
    font-size: 11px;
    color: #3d4147;
}

.footer-lang-col {
    position: relative;
}

.footer-lang-menu {
    position: relative;
}

.footer-lang-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .06);
    color: #e8eaed;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

.footer-lang-trigger:hover {
    background: rgba(255, 255, 255, .1);
    border-color: rgba(255, 255, 255, .2);
}

.footer-lang-trigger .bi-globe2 {
    color: #8ab4f8;
    font-size: 15px;
}

.footer-lang-trigger .bi-chevron-down,
.footer-lang-trigger .bi-chevron-up {
    margin-left: auto;
    font-size: 12px;
    opacity: .7;
}

.footer-lang-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 8px);
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: #252538;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .35);
}

.footer-lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #e8eaed;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition);
}

.footer-lang-option:hover {
    background: rgba(255, 255, 255, .08);
}

.footer-lang-option.active {
    background: rgba(26, 115, 232, .25);
    color: #fff;
}

.footer-lang-option .bi-check2 {
    margin-left: auto;
    color: #8ab4f8;
    font-size: 14px;
}

.footer-lang-code {
    min-width: 28px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    color: #9aa0a6;
}

.footer-lang-option.active .footer-lang-code {
    color: #8ab4f8;
}

.footer-lang-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    border: none;
    background: transparent;
    cursor: default;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
    .app-sidebar-right {
        display: none;
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 720px) {
    .app-sidebar-left {
        display: none;
    }

    .app-main {
        padding: 16px;
    }

    .footer-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Dev mode banner (только Development) ── */
.dev-mode-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    padding: 10px 16px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: #f59e0b;
    color: #1f2937;
    border-top: 1px solid #d97706;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.12);
}

body:has(.dev-mode-banner) {
    padding-bottom: 42px;
}