html, body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
}

/* === СЕТКА СТРАНИЦЫ === */
.page {
    position: relative;
    display: block;
    min-height: 100vh;
    width: 100%;
    margin: 0;
    padding: 0;
}

/* === БОКОВОЕ МЕНЮ (fixed, вне потока) === */
.sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
    transition: transform 0.3s ease;
    transform: translateX(0);
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0,0,0,0.5);
    overflow-y: auto;
    margin: 0 !important;
}

.sidebar-closed .sidebar {
    transform: translateX(-100%);
}

/* Подложка */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-open .sidebar-backdrop {
    display: block;
}

/* Основной контент — всегда на всю ширину */
main {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    margin: 0 !important;
    padding: 0 !important;
    margin-left: 0 !important;
}

.top-row {
    height: 3.5rem;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--bs-border-color);
}

.content {
    padding: 2rem;
    width: 100%;
    overflow-x: hidden;
}

        .nav-item .nav-link span {
            margin-right: 10px;
            font-size: 1.2rem;
            flex-shrink: 0;
        }

        .nav-item .nav-link:hover {
            background-color: rgba(255, 255, 255, 0.1);
            color: #ffffff !important;
        }

        .nav-item .nav-link.active {
            background-color: rgba(255, 255, 255, 0.2);
            color: #ffffff !important;
            font-weight: bold;
        }

/* === АДАПТИВ (только косметика) === */
@media (max-width: 770px) {
    .content {
        padding: 1rem 0.5rem;
    }

    .top-row {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    h2 {
        font-size: 1.3rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    .fs-5 {
        font-size: 1rem !important;
    }

    .card-body {
        padding: 1rem !important;
    }

    .result-section {
        padding: 10px;
    }

    .section-title {
        font-size: 0.9rem;
    }
}

/* === МАТЕМАТИЧЕСКИЕ СТИЛИ === */
.vec {
    text-decoration: overline;
    font-style: italic;
    font-family: "Times New Roman", Times, serif;
    font-weight: bold;
}

.frac {
    display: inline-flex;
    flex-direction: column;
    vertical-align: middle;
    text-align: center;
    margin: 0 6px;
}

    .frac .num {
        border-bottom: 1px solid currentColor;
        padding: 0 4px;
    }

    .frac .den {
        padding: 0 4px;
    }

.formula-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 8px;
    scrollbar-width: thin;
}

.result-section {
    border: 1px solid var(--bs-border-color);
    background-color: var(--bs-tertiary-bg);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    width: 100%;
    box-sizing: border-box;
}

    .result-section.highlight {
        border-color: var(--bs-primary);
        background-color: var(--bs-primary-bg-subtle);
    }

.section-title {
    color: var(--bs-secondary-color);
    border-bottom: 1px solid var(--bs-border-color);
    padding-bottom: 6px;
    margin-bottom: 12px;
    font-weight: bold;
}

/* === ТЕМНАЯ ТЕМА === */
[data-bs-theme="dark"] .sidebar {
    background-image: linear-gradient(180deg, #1f1f1f 0%, #0d0d0d 70%);
}

[data-bs-theme="dark"] .top-row {
    border-bottom: 1px solid #333;
}
