/* ==========================================================================
   Академия: общий каркас
   ========================================================================== */

:root {
    --academy-surface: var(--bg-elevated, var(--white));
    --academy-muted: var(--gray-500);
    --academy-border: color-mix(in srgb, var(--gray-400) 40%, transparent);
    --academy-shadow: 0 18px 35px color-mix(in srgb, var(--dark) 8%, transparent);
    --academy-gradient: var(--primary);
}

/* Critical: Override base dashboard-base.css for html element */
html:has(body[data-dashboard-theme="academy"]) {
    overflow: visible;
    height: auto;
}

body[data-dashboard-theme="academy"] {
    background: var(--bg-secondary);
    font-family: var(--font-sans);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: visible;
    height: auto;
    max-height: none;
}

/* Academy should also be a "one-screen" dashboard: inner panes scroll, footer stays visible */
@media (min-width: 901px) {
    /* Override base dashboard-base.css to prevent content clipping */
    html:has(body[data-dashboard-theme="academy"]),
    html body[data-dashboard-theme="academy"],
    body[data-dashboard-theme="academy"] {
        overflow: visible;
        height: auto;
        min-height: 100vh;
        max-height: none;
    }
    
    body[data-dashboard-theme="academy"] .dashboard-main {
        min-height: 0;
        overflow: hidden;
        height: calc(100vh - var(--header-height, 64px) - var(--footer-height, 50px));
        max-height: calc(100vh - var(--header-height, 64px) - var(--footer-height, 50px));
        flex: 1 1 auto;
        align-items: stretch;
    }

    body[data-dashboard-theme="academy"] .dashboard-sidebar {
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        max-height: 100%;
        align-self: stretch;
        display: flex;
        flex-direction: column;
    }
    
    body[data-dashboard-theme="academy"] .dashboard-sidebar-left,
    body[data-dashboard-theme="academy"] .dashboard-sidebar-right {
        max-height: 100%;
        overflow-y: auto;
        overflow-x: hidden;
    }

    body[data-dashboard-theme="academy"] .dashboard-content {
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        max-height: 100%;
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
    }
}

/* CRITICAL: Full header styling with maximum specificity - SINGLE DEFINITION (no duplicates) */
body[data-dashboard-theme="academy"] > .dashboard-header,
body[data-dashboard-theme="academy"] .dashboard-header,
body[data-dashboard-theme="academy"] header.dashboard-header {
    /* Positioning and visibility */
    position: sticky;
    top: 0;
    z-index: 1000;
    flex-shrink: 0;
    display: flex;
    visibility: visible;
    opacity: 1;
    
    /* Sizing */
    height: auto;
    min-height: 64px;
    max-height: none;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    
    /* Styling */
    background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    
    /* Layout */
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
}

/* CRITICAL: Исправление обрезания текста и кнопок в шапке Академии */
body[data-dashboard-theme="academy"] .dashboard-header .header-left,
body[data-dashboard-theme="academy"] header.dashboard-header .header-left {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    overflow: visible;
}

/* CRITICAL: Заголовок в шапке - полное отображение */
body[data-dashboard-theme="academy"] .dashboard-header .header-left h1,
body[data-dashboard-theme="academy"] header.dashboard-header .header-left h1,
body[data-dashboard-theme="academy"] .dashboard-header .header-left > h1 {
    font-size: 1.125rem;
    line-height: 1.4;
    letter-spacing: -0.01em;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-wrap: break-word;
    flex: 0 1 auto;
    max-width: 100%;
    margin: 0;
    font-weight: 600;
    display: block;
    visibility: visible;
}

/* CRITICAL: Название города в шапке - полное отображение */
body[data-dashboard-theme="academy"] .dashboard-header .city-name,
body[data-dashboard-theme="academy"] header.dashboard-header .city-name,
body[data-dashboard-theme="academy"] .dashboard-header .header-left .city-name {
    font-size: 0.875rem;
    color: var(--text-muted);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    flex: 0 0 auto;
    margin-left: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    border-radius: var(--radius);
    font-weight: 500;
    display: inline-block;
    visibility: visible;
    max-width: none;
}

/* ==========================================================================
   CRITICAL: ПРАВАЯ ЧАСТЬ ШАПКИ С КНОПКАМИ - ЕДИНОЕ ОПРЕДЕЛЕНИЕ (без дублирования)
   ========================================================================== */
body[data-dashboard-theme="academy"] .dashboard-header .header-right,
body[data-dashboard-theme="academy"] header.dashboard-header .header-right,
body[data-dashboard-theme="academy"] .dashboard-header .header-right .builder-header-actions,
body[data-dashboard-theme="academy"] header.dashboard-header .header-right .builder-header-actions {
    flex: 0 1 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    min-width: 0;
    margin-left: var(--spacing-md);
    overflow: visible;
    /* ✅ Убеждаемся, что кнопки не скрываются */
    max-width: none;
    width: auto;
    visibility: visible;
    opacity: 1;
}

body[data-dashboard-theme="academy"] .dashboard-header .header-right .btn,
body[data-dashboard-theme="academy"] header.dashboard-header .header-right .btn,
body[data-dashboard-theme="academy"] .dashboard-header .header-right button,
body[data-dashboard-theme="academy"] header.dashboard-header .header-right button,
body[data-dashboard-theme="academy"] .dashboard-header .header-right a,
body[data-dashboard-theme="academy"] header.dashboard-header .header-right a {
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    visibility: visible;
    opacity: 1;
    /* ✅ Убеждаемся, что кнопки не обрезаются */
    overflow: visible;
    text-overflow: clip;
    max-width: none;
    min-width: fit-content;
}

/* CRITICAL: Мобильная версия - шапка должна быть видна */
@media (max-width: 900px) {
    body[data-dashboard-theme="academy"] .dashboard-header,
    body[data-dashboard-theme="academy"] header.dashboard-header {
        flex-wrap: wrap;
        min-height: 64px;
        padding: var(--spacing-sm) var(--spacing-md);
        display: flex;
        visibility: visible;
        opacity: 1;
    }
    
    body[data-dashboard-theme="academy"] .dashboard-header .header-left,
    body[data-dashboard-theme="academy"] header.dashboard-header .header-left {
        width: 100%;
        margin-bottom: var(--spacing-xs);
        display: flex;
    }
    
    body[data-dashboard-theme="academy"] .dashboard-header .header-right,
    body[data-dashboard-theme="academy"] header.dashboard-header .header-right {
        width: 100%;
        justify-content: flex-start;
        margin-left: 0;
        flex-wrap: wrap;
        display: flex;
    }
    
    /* На мобильных название города тоже должно быть видно */
    body[data-dashboard-theme="academy"] .dashboard-header .city-name,
    body[data-dashboard-theme="academy"] header.dashboard-header .city-name {
        display: inline-block;
        visibility: visible;
    }
}

body[data-dashboard-theme="academy"] .dashboard-main {
    display: grid;
    grid-template-columns: clamp(240px, 18vw, 320px) minmax(0, 1fr) clamp(240px, 18vw, 320px);
    gap: clamp(16px, 3vw, 32px);
    padding: clamp(16px, 4vw, 32px);
    width: 100%;
    max-width: 1680px;
    margin: 0 auto;
    align-items: flex-start;
    flex: 1 1 auto;
    min-height: 0;
    overflow: visible;
}

@media (max-width: 1400px) {
    body[data-dashboard-theme="academy"] .dashboard-main {
        grid-template-columns: clamp(200px, 17vw, 250px) minmax(0, 1fr) clamp(200px, 17vw, 250px);
    }
}

/* Ревизия 31.08 (замер на живом стенде, 1280×900): медиазапрос смотрит на
   ВЬЮПОРТ, а платформенный рельс слева уже съел ~240px. При 1280 главной
   области остаётся 1040px, боковины 280+280 + зазоры — и ЦЕНТРАЛЬНОЙ
   колонке доставалось 352px: hero схлопывался в 0px+240px, заголовок
   «Академия Горожан» рендерился по одной букве в строку, карточки метрик
   ложились поверх текста. Порог одной колонки поднят с 1100 до 1280. */
@media (max-width: 1280px) {
    body[data-dashboard-theme="academy"] .dashboard-main {
        grid-template-columns: minmax(0, 1fr);
        gap: clamp(14px, 3vw, 24px);
    }
}

body[data-dashboard-theme="academy"] .dashboard-sidebar {
    width: 100%;
    min-width: 0;
    background: var(--academy-surface);
    border: 1px solid var(--academy-border);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--academy-shadow);
}

body[data-dashboard-theme="academy"] .dashboard-sidebar-left,
body[data-dashboard-theme="academy"] .dashboard-sidebar-right {
    position: relative;
    /* ✅ ИСПРАВЛЕНО: Обеспечиваем скроллинг для боковой панели */
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 200px); /* Ограничиваем высоту для скроллинга */
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--gray-400) 50%, transparent) transparent;
}

body[data-dashboard-theme="academy"] .dashboard-sidebar-left::-webkit-scrollbar,
body[data-dashboard-theme="academy"] .dashboard-sidebar-right::-webkit-scrollbar {
    width: 6px;
}

body[data-dashboard-theme="academy"] .dashboard-sidebar-left::-webkit-scrollbar-track,
body[data-dashboard-theme="academy"] .dashboard-sidebar-right::-webkit-scrollbar-track {
    background: transparent;
}

body[data-dashboard-theme="academy"] .dashboard-sidebar-left::-webkit-scrollbar-thumb,
body[data-dashboard-theme="academy"] .dashboard-sidebar-right::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--gray-400) 50%, transparent);
    border-radius: 3px;
}

body[data-dashboard-theme="academy"] .dashboard-sidebar-left::-webkit-scrollbar-thumb:hover,
body[data-dashboard-theme="academy"] .dashboard-sidebar-right::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--gray-400) 70%, transparent);
}

@media (max-width: 1100px) {
    body[data-dashboard-theme="academy"] .dashboard-sidebar-left,
    body[data-dashboard-theme="academy"] .dashboard-sidebar-right {
        width: 100%;
    }
}

body[data-dashboard-theme="academy"] .academy-content {
    display: flex;
    flex-direction: column;
    gap: 32px;
    min-width: 0;
    flex: 1;
    min-height: 0;
    overflow: visible;
}

/* Исправление скроллинга для "Мои Курсы" */
body[data-dashboard-theme="academy"] .my-academy-container {
    display: flex;
    flex-direction: column;
    gap: 32px;
    min-width: 0;
    flex: 1;
    min-height: 0;
    overflow: visible;
}

/* Убеждаемся, что dashboard-content в "Мои Курсы" правильно скроллится */
body[data-dashboard-theme="academy"] .dashboard-content .my-academy-container {
    overflow: visible;
}

body[data-dashboard-theme="academy"] .dashboard-content .academy-learning-grid {
    overflow: visible;
    min-height: 0;
}

body[data-dashboard-theme="academy"] .academy-footer-rail {
    width: 100%;
    padding: 0 clamp(16px, 4vw, 32px) clamp(32px, 5vw, 64px);
}

body[data-dashboard-theme="academy"] .academy-footer-rail .dashboards-footer {
    max-width: 1680px;
    margin: 0 auto;
}

body[data-dashboard-theme="academy"] .dashboard-sidebar .sidebar-section + .sidebar-section {
    margin-top: 24px;
}

body[data-dashboard-theme="academy"] .dashboard-sidebar .sidebar-title {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--academy-muted);
    margin-bottom: 12px;
    line-height: 1.5;
}

body[data-dashboard-theme="academy"] .dashboard-content {
    flex: 1;
    min-width: 0;
    min-height: 0;
    border-radius: 28px;
    background: var(--academy-surface);
    border: 1px solid var(--academy-border);
    box-shadow: var(--academy-shadow);
    padding: clamp(20px, 3vw, 36px);
    display: flex;
    flex-direction: column;
    gap: 32px;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-padding-top: 0;
    margin-top: 0;
    position: relative;
}

/* Убеждаемся, что контент внутри dashboard-content может скроллиться */
body[data-dashboard-theme="academy"] .dashboard-content > .academy-content,
body[data-dashboard-theme="academy"] .dashboard-content > .my-academy-container {
    min-height: 0;
    flex: 1;
    overflow: visible;
}

/* ==========================================================================
   My Academy (inline-style cleanup helpers)
   ========================================================================== */

.academy-hidden {
    display: none;
}

.academy-sidebar-title {
    margin: 16px 0 12px;
    font-size: 1.4rem;
}

.academy-loading-text {
    text-align: center;
    margin-top: 16px;
}

.academy-enrollments-skeleton {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.academy-enrollment-skeleton {
    height: 72px;
    border-radius: 14px;
    background: linear-gradient(90deg, var(--bg-secondary) 0%, var(--bg-tertiary) 45%, var(--bg-secondary) 100%);
    background-size: 200% 100%;
    animation: academy-shimmer 1.25s ease-in-out infinite;
    border: 1px solid var(--academy-border);
}

/* ------------------------------------------------------------------
   Academy catalog UX: skeleton + retry (TZ_dashboard_fixes_2026-01-01.md §5.2)
------------------------------------------------------------------- */
body[data-dashboard-theme="academy"] .course-card--skeleton {
    border: 1px solid var(--academy-border);
    background: var(--academy-surface);
    overflow: hidden;
}

body[data-dashboard-theme="academy"] .course-image--skeleton {
    height: 140px;
    background: linear-gradient(90deg, var(--bg-secondary) 0%, var(--bg-tertiary) 45%, var(--bg-secondary) 100%);
    background-size: 200% 100%;
    animation: academy-shimmer 1.25s ease-in-out infinite;
}

body[data-dashboard-theme="academy"] .skeleton-line {
    height: 12px;
    border-radius: var(--radius-md);
    margin: 10px 0;
    background: linear-gradient(90deg, var(--bg-secondary) 0%, var(--bg-tertiary) 45%, var(--bg-secondary) 100%);
    background-size: 200% 100%;
    animation: academy-shimmer 1.25s ease-in-out infinite;
}

body[data-dashboard-theme="academy"] .skeleton-line--title {
    height: 18px;
    margin-top: 6px;
}

body[data-dashboard-theme="academy"] .skeleton-line--short {
    width: 70%;
}

@keyframes academy-shimmer {
    0% { background-position: 0% 0%; }
    100% { background-position: -200% 0%; }
}

body[data-dashboard-theme="academy"] .academy-error-state {
    border: 1px solid var(--danger-lightest);
    background: color-mix(in srgb, var(--danger) 8%, var(--bg-primary));
    border-radius: 14px;
    padding: 1.25rem;
}

body[data-dashboard-theme="academy"] .academy-error-state__title {
    font-weight: 700;
    color: var(--danger);
    margin-bottom: 0.35rem;
}

body[data-dashboard-theme="academy"] .academy-error-state__message {
    color: var(--status-danger);
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

body[data-dashboard-theme="academy"] .academy-error-state__actions {
    display: flex;
    gap: 0.5rem;
}

body[data-dashboard-theme="academy"] .academy-empty-state {
    grid-column: 1 / -1;
    border: 1px dashed var(--academy-border);
    border-radius: 18px;
    padding: 32px 20px;
    text-align: center;
    background: var(--academy-surface);
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

body[data-dashboard-theme="academy"] .academy-empty-state__icon {
    font-size: 2.5rem;
}

body[data-dashboard-theme="academy"] .academy-empty-state__title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

body[data-dashboard-theme="academy"] .academy-empty-state__text {
    max-width: 460px;
}

.course-structure {
    margin-top: 24px;
}

/* ✅ ИСПРАВЛЕНО: Описание программы в боковой панели "Мои Курсы" с улучшенным скроллингом */
/* ✅ Используем более специфичный селектор для гарантированного применения стилей */
#active-course-description.active-course-description,
.course-structure .active-course-description,
body[data-dashboard-theme="academy"] .dashboard-sidebar-left .active-course-description {
    margin: 12px 0 16px 0;
    padding: 12px;
    background: color-mix(in srgb, var(--gray-400) 8%, transparent);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
    /* ✅ ИСПРАВЛЕНО: Увеличена максимальная высота для лучшей читаемости */
    max-height: 300px;
    min-height: 60px; /* Минимальная высота для видимости */
    height: auto;
    /* ✅ Принудительно включаем скроллинг с высокой специфичностью */
    overflow-y: auto;
    overflow-x: hidden;
    word-wrap: break-word;
    white-space: pre-wrap;
    /* ✅ Улучшенная стилизация скроллбара */
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--gray-400) 60%, transparent) color-mix(in srgb, var(--gray-400) 10%, transparent);
    /* ✅ Обеспечиваем видимость скроллбара */
    position: relative;
    display: block;
    /* ✅ Убеждаемся, что контент может переполняться */
    box-sizing: border-box;
}

/* ✅ Стилизация скроллбара с высокой специфичностью */
#active-course-description.active-course-description::-webkit-scrollbar,
.course-structure .active-course-description::-webkit-scrollbar,
body[data-dashboard-theme="academy"] .dashboard-sidebar-left .active-course-description::-webkit-scrollbar {
    width: 8px; /* ✅ Увеличен размер для лучшей видимости */
    display: block;
}

#active-course-description.active-course-description::-webkit-scrollbar-track,
.course-structure .active-course-description::-webkit-scrollbar-track,
body[data-dashboard-theme="academy"] .dashboard-sidebar-left .active-course-description::-webkit-scrollbar-track {
    background: color-mix(in srgb, var(--gray-400) 10%, transparent); /* ✅ Видимый трек */
    border-radius: var(--radius-sm);
}

#active-course-description.active-course-description::-webkit-scrollbar-thumb,
.course-structure .active-course-description::-webkit-scrollbar-thumb,
body[data-dashboard-theme="academy"] .dashboard-sidebar-left .active-course-description::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--gray-400) 60%, transparent); /* ✅ Более заметный скроллбар */
    border-radius: var(--radius-sm);
    border: 1px solid color-mix(in srgb, var(--gray-400) 20%, transparent);
}

#active-course-description.active-course-description::-webkit-scrollbar-thumb:hover,
.course-structure .active-course-description::-webkit-scrollbar-thumb:hover,
body[data-dashboard-theme="academy"] .dashboard-sidebar-left .active-course-description::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--gray-400) 80%, transparent); /* ✅ Более заметный при наведении */
}

#active-course-description.active-course-description:empty,
.course-structure .active-course-description:empty,
body[data-dashboard-theme="academy"] .dashboard-sidebar-left .active-course-description:empty {
    display: none;
}

/* Lesson prerequisites UX (locked lessons) */
body[data-dashboard-theme="academy"] .lesson-item.locked {
    opacity: 0.55;
    cursor: not-allowed;
}

body[data-dashboard-theme="academy"] .lesson-item.locked:hover {
    transform: none;
}

.academy-sidebar-subtitle {
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.academy-knowledge-graph-btn {
    margin-top: 12px;
}

.insight-card__head h3 {
    margin: 0;
}

#lesson-title {
    font-size: 2rem;
    margin: 0 0 20px;
    color: var(--text-primary);
}

#lesson-body {
    line-height: 1.6;
    color: var(--text-primary);
    font-size: 1.05rem;
    /* ✅ ИСПРАВЛЕНО: Обеспечиваем правильное отображение длинного контента */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ✅ ИСПРАВЛЕНО: Стилизация скроллбара для lesson-content-pane */
.lesson-content-pane::-webkit-scrollbar {
    width: 8px;
}

.lesson-content-pane::-webkit-scrollbar-track {
    background: color-mix(in srgb, var(--gray-400) 10%, transparent);
    border-radius: var(--radius-sm);
}

.lesson-content-pane::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--gray-400) 60%, transparent);
    border-radius: var(--radius-sm);
    border: 1px solid color-mix(in srgb, var(--gray-400) 20%, transparent);
}

.lesson-content-pane::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--gray-400) 80%, transparent);
}

.academy-task-section {
    margin-top: 40px;
    padding: 24px;
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--gray-300);
}

.academy-task-title {
    margin-top: 0;
    margin-bottom: 16px;
    color: var(--text-primary);
}

#task-description {
    color: var(--text-secondary);
}

.interactive-insights h4 {
    margin-bottom: 8px;
}

.academy-empty__icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.academy-empty h2 {
    color: var(--gray-300);
}

.knowledge-graph-head h3 {
    margin: 0;
}

/* Small utility helpers used in academy index/sidebar */
.academy-muted-compact {
    margin: 0;
}

.academy-muted-spaced {
    margin-top: 1rem;
}

/* ==========================================================================
   Общие элементы
   ========================================================================== */

/* CRITICAL: Надпись "Городская Академия" - полное отображение */
.academy-eyebrow {
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--academy-muted);
    margin-bottom: 0.5rem;
    /* ✅ Убеждаемся, что текст не обрезается */
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    display: block;
    visibility: visible;
}

.academy-hero {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr);
    gap: clamp(16px, 3vw, 40px);
    border-radius: 28px;
    padding: clamp(20px, 4vw, 48px);
    border: 1px solid var(--academy-border);
    background: linear-gradient(120deg, var(--primary-lightest), var(--gray-50));
    position: relative;
    overflow: visible; /* ✅ Исправлено: разрешаем видимость всего контента */
}

.academy-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 12%, transparent), color-mix(in srgb, var(--dark) 5%, transparent));
    pointer-events: none;
}

.academy-hero > * {
    position: relative;
    z-index: 1;
    /* ✅ Убеждаемся, что дочерние элементы не обрезаются */
    overflow: visible;
    min-height: 0;
    max-height: none;
}

/* CRITICAL: Заголовок в центральной панели - полное отображение */
.academy-hero h1 {
    font-size: clamp(2rem, 4vw, 2.75rem);
    margin: 0 0 0.75rem;
    /* ✅ Убеждаемся, что текст не обрезается */
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-wrap: break-word;
    line-height: 1.2;
    max-width: 100%;
    display: block;
    visibility: visible;
    /* ✅ Убираем любые ограничения высоты */
    min-height: auto;
    max-height: none;
    height: auto;
}

.academy-hero p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

.academy-insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}

.insight-card {
    border: 1px solid var(--academy-border);
    border-radius: var(--radius-2xl);
    background: var(--academy-surface);
    box-shadow: var(--academy-shadow);
    padding: clamp(20px, 3vw, 28px);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.insight-card__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.competency-graph {
    border: 1px dashed var(--academy-border);
    border-radius: 20px;
    background: var(--gray-50);
    min-height: 260px;
    height: clamp(260px, 32vh, 420px);
    max-height: 420px;
    padding: 12px;
    position: relative;
    overflow: hidden;
}

.competency-graph > div {
    height: 100%;
}

.insight-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    font-size: 0.95rem;
    text-align: center;
}

.academy-pill-row {
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.academy-pill {
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 500;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--primary-dark);
}

.academy-nav-buttons {
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.academy-nav-buttons .btn {
    border-radius: 999px;
    padding-inline: 18px;
}

.career-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.career-heading {
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--academy-muted);
    margin: 4px 0 8px;
}

.career-card {
    border: 1px solid var(--academy-border);
    border-radius: var(--radius-xl);
    padding: 14px;
    background: var(--gray-50);
    box-shadow: var(--shadow-sm);
}

.career-card__meta {
    font-size: 0.85rem;
    color: var(--gray-500);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.career-card__actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.career-card__actions .ghost-btn {
    padding: 6px 12px;
}

.academy-nav-list .nav-empty {
    color: var(--gray-400);
    font-size: 0.9rem;
    padding: 6px 4px;
}

.ghost-btn {
    border: 1px dashed var(--academy-border);
    border-radius: 999px;
    padding: 8px 16px;
    background: transparent;
    color: var(--academy-muted);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.ghost-btn:hover {
    background: var(--primary-lightest);
    color: var(--primary-dark);
}

.hero-stat-card {
    background: var(--academy-surface);
    border: 1px solid var(--academy-border);
    border-radius: 18px;
    padding: 18px;
    box-shadow: var(--shadow-sm);
}

.hero-stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
}

.hero-stat-label {
    font-size: 0.9375rem;
    color: var(--academy-muted);
    line-height: 1.5;
}

.hero-note-card {
    border: 1px dashed var(--academy-border);
    border-radius: 18px;
    padding: 18px;
    background: var(--bg-secondary);
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.academy-values .value-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.value-card {
    border: 1px solid var(--academy-border);
    border-radius: var(--radius-xl);
    padding: 20px;
    background: var(--academy-surface);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.value-card h3 {
    margin: 0;
    font-size: 1rem;
}

.value-card p {
    margin: 0;
    color: var(--academy-muted);
    line-height: 1.45;
}

.courses-section {
    border: 1px solid var(--academy-border);
    border-radius: var(--radius-2xl);
    padding: clamp(20px, 3vw, 36px);
    background: var(--academy-surface);
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

.courses-header {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-start;
    justify-content: space-between;
}

.course-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.course-tag {
    border: 1px dashed var(--academy-border);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 0.85rem;
    color: var(--academy-muted);
}

.courses-grid {
    margin-top: 32px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    min-height: 0;
}

.course-card {
    border: 1px solid var(--academy-border);
    border-radius: 18px;
    background: var(--academy-surface);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.course-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.course-image {
    position: relative;
    aspect-ratio: 16 / 9;
    background-size: cover;
    background-position: center;
}

.course-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
    color: var(--primary-dark);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.4;
}

.course-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.course-title {
    margin: 0;
    font-size: 1.3rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.course-description {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Marketplace / NIOKR card inner elements (rendered by JS) */
.course-card-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.course-card-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.course-card-desc {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.course-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.9375rem;
    color: var(--academy-muted);
    line-height: 1.5;
}

.course-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--academy-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    min-height: 44px; /* Минимальная высота для футера */
}

.course-footer .text-muted {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.875rem;
    line-height: 1.5;
}

.course-footer .enroll-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    min-width: fit-content;
}

.market-stats {
    border-radius: var(--radius-lg);
    border: 1px solid var(--academy-border);
    padding: 10px 14px;
    font-size: 0.875rem;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    line-height: 1.5;
}

.market-stats__loading {
    font-size: 0.8rem;
    color: var(--gray-400);
}

/* ==========================================================================
   Селектор города для вакансий (ТЗ BUG-3)
   ========================================================================== */

.academy-city-selector {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.academy-city-label {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.academy-city-input {
    padding: 8px 12px;
    border: 1px solid var(--academy-border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    min-width: 160px;
    background: var(--academy-surface);
    color: var(--text-primary);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.academy-city-input:focus {
     border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}

/* ==========================================================================
   HH.ru vacancies widget (TZ v2)
   ========================================================================== */

.vacancies-widget-shell:empty {
    display: none;
}

.vacancies-widget {
    background: linear-gradient(135deg, rgba(214, 0, 28, 0.07), rgba(214, 0, 28, 0.03));
    border: 1px solid rgba(214, 0, 28, 0.14);
    border-radius: 14px;
    padding: 12px 14px;
}

.vacancies-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.hh-logo {
    height: 18px;
    width: auto;
}

.vacancies-count {
    font-size: 0.82rem;
    color: #d6001c;
    font-weight: 700;
}

.vacancies-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.vacancy-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 8px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--gray-400) 35%, transparent);
    text-decoration: none;
    color: inherit;
}

.vacancy-item:last-child {
    border-bottom: none;
}

.vacancy-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vacancy-company {
    font-size: 0.78rem;
    color: var(--gray-500);
}

.vacancy-meta {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.vacancy-snippet {
    font-size: 0.75rem;
    color: var(--gray-500);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.vacancy-salary {
    font-size: 0.85rem;
    color: var(--success);
    font-weight: 600;
    white-space: nowrap;
}

.vacancies-more {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-weight: 700;
    color: #d6001c;
    font-size: 0.85rem;
}

.vacancies-more:hover {
    text-decoration: underline;
}

/* Локальные возможности (менторские слоты продюсеров) FEAT-2 */
.local-opportunities-shell:empty {
    display: none;
}

.local-opportunities-widget {
    margin-top: 10px;
    padding: 10px 12px;
    background: color-mix(in srgb, var(--primary) 6%, transparent);
    border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
    border-radius: var(--radius-lg);
}

.local-opportunities-header {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.local-opportunities-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.local-opportunity-item {
    font-size: 0.82rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.local-opportunity-role {
    font-weight: 600;
    color: var(--text-primary);
}

.local-opportunity-project {
    color: var(--gray-500);
}

.local-opportunity-slots {
    font-size: 0.75rem;
    color: var(--success);
}

/* ==========================================================================
   Мой кабинет студента
   ========================================================================== */

.academy-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.stat-card {
    border: 1px solid var(--academy-border);
    border-radius: var(--radius-xl);
    padding: 18px;
    background: var(--academy-surface);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-card strong {
    font-size: 2rem;
}

.stat-card small {
    color: var(--academy-muted);
}

.stat-progress {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--primary-lightest);
    color: var(--primary-dark);
    font-weight: 600;
}

.academy-learning-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* --------------------------------------------------------------------------
   Sidebar controls (left/right panels)
   -------------------------------------------------------------------------- */
body[data-dashboard-theme="academy"] .academy-sidebar .back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid var(--academy-border);
    background: var(--gray-50);
    color: var(--text-primary);
    font-weight: 600;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
    margin-bottom: 18px;
}

body[data-dashboard-theme="academy"] .academy-sidebar .back-btn:hover {
    background: var(--primary-lightest);
    box-shadow: 0 8px 16px color-mix(in srgb, var(--primary) 12%, transparent);
}

body[data-dashboard-theme="academy"] .academy-sidebar .course-item {
    width: 100%;
    text-align: left;
    border: 1px solid var(--academy-border);
    border-radius: var(--radius-xl);
    padding: 16px;
    background: var(--gray-50);
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

body[data-dashboard-theme="academy"] .academy-sidebar .course-item.active {
    border-color: var(--primary);
    box-shadow: 0 10px 20px color-mix(in srgb, var(--primary) 15%, transparent);
    background: var(--primary-lightest);
}

body[data-dashboard-theme="academy"] .academy-sidebar .course-item__head,
body[data-dashboard-theme="academy"] .academy-sidebar .course-item__meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.9rem;
}

body[data-dashboard-theme="academy"] .academy-sidebar .remember-btn {
    width: 100%;
    padding: 12px 18px;
    border-radius: 14px;
    border: none;
    background: var(--primary);
    color: var(--text-inverse);
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: 0 12px 24px color-mix(in srgb, var(--primary) 25%, transparent);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

body[data-dashboard-theme="academy"] .academy-sidebar .remember-btn:disabled {
    opacity: 0.6;
    box-shadow: none;
}

body[data-dashboard-theme="academy"] .academy-sidebar .remember-btn:not(:disabled):hover {
    transform: translateY(-2px);
}

body[data-dashboard-theme="academy"] .dashboard-sidebar-right .action-step {
    border: 1px solid var(--academy-border);
    border-radius: var(--radius-xl);
    padding: 14px;
    margin-bottom: 12px;
    background: var(--gray-50);
    box-shadow: var(--shadow-sm);
}

body[data-dashboard-theme="academy"] .dashboard-sidebar-right .academy-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

body[data-dashboard-theme="academy"] .dashboard-sidebar-right .academy-nav-list a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    background: var(--primary-lightest);
    color: var(--primary-dark);
    font-weight: 600;
    border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
    transition: background 0.2s ease, transform 0.2s ease;
}

body[data-dashboard-theme="academy"] .dashboard-sidebar-right .academy-nav-list a:hover {
    background: color-mix(in srgb, var(--primary) 15%, var(--bg-primary));
    transform: translateX(2px);
}

.academy-nav-list .reminder-progress {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--primary-dark);
}

.lesson-viewer {
    border: 1px solid var(--academy-border);
    border-radius: var(--radius-2xl);
    display: flex;
    gap: 0;
    min-height: 420px;
    max-height: calc(100vh - 200px); /* ✅ Ограничиваем высоту для правильного скроллинга */
    overflow: visible; /* ✅ ИСПРАВЛЕНО: Разрешаем видимость для скроллинга дочерних элементов */
    background: var(--academy-surface);
    height: auto; /* ✅ Автоматическая высота */
}

.lesson-content-pane {
    flex: 1;
    padding: clamp(20px, 3vw, 40px);
    border-right: 1px solid var(--academy-border);
    min-width: 320px;
    /* ✅ ИСПРАВЛЕНО: Добавляем скроллинг для длинного контента */
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 200px);
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--gray-400) 50%, transparent) transparent;
}

.lesson-media {
    border: 1px solid var(--academy-border);
    border-radius: var(--radius-xl);
    padding: 18px;
    background: var(--gray-50);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.lesson-media[hidden] {
    display: none;
}

.lesson-media-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.lesson-media-popout {
    border: none;
    background: transparent;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 6px 8px;
    border-radius: var(--radius-md);
    transition: background 0.2s ease;
}

.lesson-media-popout:hover {
    background: color-mix(in srgb, var(--dark) 8%, transparent);
}

.lesson-media-popout[hidden] {
    display: none;
}

.lesson-media-player {
    border-radius: 14px;
    overflow: hidden;
    background: var(--dark);
    position: relative;
}

.lesson-video-player,
.lesson-video-embed {
    width: 100%;
    min-height: 280px;
    border: none;
    display: block;
}

.lesson-video-player {
    background: var(--dark);
}

.lesson-video-player[hidden],
.lesson-video-embed[hidden] {
    display: none;
}

.lesson-video-error {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--warning-dark);
    background: color-mix(in srgb, var(--warning) 8%, var(--bg-primary));
    border: 1px solid var(--warning-lightest);
    border-radius: 10px;
    padding: 10px 12px;
}

.lesson-video-error[hidden] {
    display: none;
}

.action-step-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.insight-card .action-step-list {
    max-height: 360px;
    overflow-y: auto;
    padding-right: 6px;
}

.action-step--empty {
    opacity: 0.75;
}

.action-step__title {
    display: block;
    font-size: 1rem;
    font-weight: 600;
}

.action-step__meta {
    display: block;
    font-size: 0.85rem;
    color: var(--gray-500);
}

.action-step__cta {
    display: block;
    font-size: 0.85rem;
    color: var(--primary-dark);
    font-weight: 600;
}

.lesson-sandbox-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-tertiary);
    min-height: 0; /* ✅ Важно для правильного растягивания iframe */
    overflow: hidden; /* ✅ Предотвращаем выход контента за границы */
}

.sandbox-header {
    background: var(--dark);
    color: var(--text-inverse);
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    flex-shrink: 0; /* ✅ Заголовок не сжимается */
    gap: 12px;
}

.sandbox-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sandbox-fullscreen-btn {
    background: color-mix(in srgb, var(--bg-primary) 15%, transparent);
    border: 1px solid color-mix(in srgb, var(--bg-primary) 30%, transparent);
    color: var(--text-inverse);
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.sandbox-fullscreen-btn:hover {
    background: color-mix(in srgb, var(--bg-primary) 25%, transparent);
    border-color: color-mix(in srgb, var(--bg-primary) 50%, transparent);
    transform: translateY(-1px);
}

.sandbox-fullscreen-btn:active {
    transform: translateY(0);
}

.sandbox-frame {
    flex: 1; /* ✅ Iframe занимает всю доступную высоту */
    width: 100%;
    border: none;
    background: var(--bg-elevated);
    min-height: 0; /* ✅ Важно для правильного растягивания */
    display: block;
}

.interactive-case {
    display: none;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
}

.interactive-case.active {
    display: flex;
}

.interactive-video {
    width: 100%;
    border-radius: var(--radius-lg);
    background: var(--dark);
    min-height: 240px;
}

.interactive-insights {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.transcript-panel,
.actions-panel,
.action-output-panel {
    background: var(--academy-surface);
    border: 1px solid var(--academy-border);
    border-radius: var(--radius-lg);
    padding: 14px;
    max-height: 360px;
    overflow-y: auto;
}

.action-output {
    font-family: "JetBrains Mono", "Source Code Pro", monospace;
    font-size: 0.85rem;
    background: var(--bg-code);
    color: var(--text-code);
    padding: 12px;
    border-radius: var(--radius-md);
    min-height: 120px;
}

.action-output.error {
    background: var(--bg-code);
    color: var(--danger-lightest);
}

.remember-btn,
.complete-btn,
.enroll-btn,
.back-btn,
.action-step {
    border-radius: 999px;
    border: 1px solid var(--academy-border);
    background: var(--bg-elevated);
    padding: 10px 18px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.remember-btn:hover,
.complete-btn:hover,
.enroll-btn:hover,
.action-step:hover {
    background: var(--primary-lightest);
    transform: translateY(-1px);
}

.enroll-btn {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-inverse);
}

.enroll-btn:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.complete-btn {
    width: 100%;
    background: var(--success);
    border-color: var(--success);
    color: var(--text-inverse);
}

.complete-btn:disabled {
    background: var(--border);
    border-color: var(--border-color, var(--gray-300));
    cursor: not-allowed;
}

.academy-empty {
    border: 1px dashed var(--academy-border);
    border-radius: var(--radius-2xl);
    padding: 80px 20px;
    text-align: center;
    color: var(--gray-400);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.knowledge-library {
    border-top: 1px solid var(--academy-border);
    padding-top: 18px;
}

.knowledge-entry {
    border: 1px solid var(--academy-border);
    border-radius: var(--radius-lg);
    padding: 12px;
    margin-bottom: 10px;
    background: var(--bg-elevated);
}

.knowledge-entry[data-empty="true"] {
    border-style: dashed;
    text-align: center;
    color: var(--academy-muted);
}

.knowledge-graph-modal {
    position: fixed;
    inset: 0;
    background: color-mix(in srgb, var(--dark) 80%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.knowledge-graph-modal.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.knowledge-graph-content {
    background: var(--bg-elevated);
    border-radius: 20px;
    padding: 24px;
    width: min(760px, 92vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: var(--shadow-xl);
}

.knowledge-graph-surface {
    border: 1px solid var(--academy-border);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    height: 420px;
}

.close-graph-btn {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
}

/* ==========================================================================
   Карта таланта (профиль)
   ========================================================================== */

.talent-card {
    border: 1px solid var(--academy-border);
    border-radius: 28px;
    padding: clamp(20px, 3vw, 36px);
    box-shadow: var(--academy-shadow);
    background: var(--academy-surface);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.talent-header {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: space-between;
}

.talent-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.talent-chart-shell {
    position: relative;
    border: 1px solid var(--academy-border);
    border-radius: 20px;
    padding: 20px;
    background: var(--bg-code);
    min-height: 240px;
    color: var(--text-code);
}

.talent-chart-shell canvas {
    width: 100%;
    max-height: 280px;
}

.talent-chart-meta {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 0.9rem;
}

.talent-phase-card {
    border: 1px solid var(--academy-border);
    border-radius: 20px;
    padding: 20px;
    background: var(--bg-secondary);
}

.talent-phase-progress {
    background: var(--bg-hover);
    border-radius: 999px;
    padding: 6px;
    margin: 14px 0;
}

.talent-phase-progress span {
    display: block;
    background: var(--academy-gradient);
    color: var(--text-inverse);
    border-radius: 999px;
    padding: 6px 12px;
    font-weight: 600;
    width: var(--progress, 0%);
    text-align: center;
    /* QA 2026-08-12: при --progress:0% контентный бокс схлопывался до нуля —
       бейдж резался краем трека, а «0%» вылезал белым по светлому.
       min-width держит пилюлю читаемой на любом проценте. */
    box-sizing: border-box;
    min-width: 3.25rem;
}

.talent-branches {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.talent-branch {
    border: 1px solid var(--academy-border);
    border-radius: 14px;
    padding: 14px;
    background: var(--academy-surface);
}

.talent-recommendations ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.talent-recommendations li {
    border: 1px solid var(--academy-border);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    background: var(--bg-secondary);
}

.talent-status {
    font-size: 0.9rem;
    color: var(--academy-muted);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.talent-status.visible {
    opacity: 1;
}

/* ==========================================================================
   Sidebar helpers
   ========================================================================== */

.academy-nav-list,
.academy-filter-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.academy-nav-list a,
.academy-filter-list button {
    /* display:flex ОБЯЗАТЕЛЕН: инлайновая ссылка с вертикальным padding
       не раздвигает line-box, и рамки пунктов ложились друг на друга
       (левый сайдбар Академии, скриншот 24.08 — правый сайдбар был цел,
       потому что у него свой отдельный display:flex ниже). */
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--academy-border);
    border-radius: var(--radius-lg);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--academy-surface);
    transition: background 0.2s ease, border-color 0.2s ease;
}

.academy-nav-list a:hover,
.academy-filter-list button:hover {
    border-color: var(--primary);
    background: var(--primary-lightest);
}

.academy-filter-list button {
    width: 100%;
    background: transparent;
}

.academy-kpi {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.academy-kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.academy-kpi-label {
    font-size: 0.9rem;
    color: var(--academy-muted);
}

/* ==========================================================================
   Responsive tweaks
   ========================================================================== */

@media (max-width: 960px) {
    .academy-hero {
        grid-template-columns: 1fr;
    }

    .lesson-viewer {
        flex-direction: column;
    }

    .lesson-content-pane {
        border-right: none;
        border-bottom: 1px solid var(--academy-border);
    }

    body[data-dashboard-theme="academy"] .dashboard-sidebar {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .academy-nav-buttons {
        flex-direction: column;
    }

    .courses-section {
        padding: 20px;
    }
}

/* ==========================================================================
   ДОПОЛНИТЕЛЬНЫЕ ПРАВИЛА ДЛЯ "МОИ КУРСЫ" И МЕТОДИСТА
   ========================================================================== */

/* ==========================================================================
   ДОПОЛНИТЕЛЬНЫЕ ПРАВИЛА ДЛЯ "МОИ КУРСЫ" И МЕТОДИСТА
   ========================================================================== */

/* ✅ УДАЛЕНО ДУБЛИРОВАНИЕ: Правила для h1 уже определены выше (строки 125-141) */

/* CRITICAL: Убеждаемся, что шапка не обрезается на разных разрешениях */
@media (min-width: 901px) {
    body[data-dashboard-theme="academy"] .dashboard-header .header-right,
    body[data-dashboard-theme="academy"] header.dashboard-header .header-right {
        flex-wrap: wrap;
        /* Разрешаем перенос кнопок на всех экранах для видимости */
    }
}

@media (max-width: 1200px) and (min-width: 901px) {
    body[data-dashboard-theme="academy"] .dashboard-header .header-right,
    body[data-dashboard-theme="academy"] header.dashboard-header .header-right {
        flex-wrap: wrap;
        gap: var(--spacing-xs);
        /* На средних экранах уменьшаем отступы для лучшей видимости */
    }
}

/* ==========================================================================
   NOTE: Header styles are defined above (lines 79-198) with maximum specificity.
   Additional rules for "Мои Курсы" are defined above (lines 1834-1880).
   ========================================================================== */


/* ───────────────────────────────────────────────────────────────────
   B7: Hero Resume Banner — "Продолжить с..." в Мои Курсы.
   (docs/TZ/11_academy_methodist_profile.md §B7)
   Отображается между .academy-hero контентом и .hero-meta статистикой,
   если у пользователя есть активный (0 < progress < 100) или
   ненажатый (progress = 0) курс. При отсутствии таких курсов
   баннер удаляется из DOM.
   ─────────────────────────────────────────────────────────────────── */
.hero-resume-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    margin: 16px 0;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--accent-primary, var(--color-primary)) 10%, var(--bg-card, var(--white))),
        color-mix(in srgb, var(--accent-primary, var(--color-primary)) 4%, var(--bg-card, var(--white)))
    );
    border-left: 3px solid var(--accent-primary, var(--color-primary));
    box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 8%, transparent);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hero-resume-banner:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 15%, transparent);
}
.hero-resume-icon {
    font-size: 1.6rem;
    line-height: 1;
    flex-shrink: 0;
}
.hero-resume-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}
.hero-resume-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary, var(--dark));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.hero-resume-hint {
    font-size: 0.8rem;
    color: var(--text-muted, var(--gray-500));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.hero-resume-cta {
    padding: 8px 18px;
    background: var(--accent-primary, var(--color-primary));
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
    flex-shrink: 0;
}
.hero-resume-cta:hover {
    background: color-mix(in srgb, var(--accent-primary, var(--color-primary)) 85%, var(--dark));
}
.hero-resume-cta:focus-visible {
    outline: 2px solid var(--accent-primary, var(--color-primary));
    outline-offset: 2px;
}

@media (max-width: 768px) {
    .hero-resume-banner {
        flex-wrap: wrap;
        gap: 10px;
        padding: 10px 12px;
    }
    .hero-resume-cta {
        width: 100%;
    }
    .hero-resume-label {
        white-space: normal;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hero-resume-banner,
    .hero-resume-cta {
        transition: none;
    }
    .hero-resume-banner:hover {
        transform: none;
    }
}

/* ───────────────────────────────────────────────────────────────────
   B12: Skeleton-сетки для Академии (catalog + marketplace + НИОКР).
   Раньше все три секции использовали один loading-spinner, из-за чего
   при старте страница «прыгала» (spinner → grid). Теперь skeleton
   имеет тот же aspect ratio что курс-карточка, min-height фиксирован.
   (docs/TZ/11_academy_methodist_profile.md §B12)
   ─────────────────────────────────────────────────────────────────── */

.academy-section-spaced {
    margin-top: 2rem;
}

.courses-grid--min-load {
    /* Минимальная высота предотвращает "прыжок" при скеллетон → карточки */
    min-height: 240px;
}

.academy-skeleton-card {
    background: var(--bg-card, var(--white));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 220px;
}

.academy-skeleton-card__cover {
    height: 120px;
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--bg-secondary) 100%, transparent) 0%,
        color-mix(in srgb, var(--bg-secondary) 70%, transparent) 50%,
        color-mix(in srgb, var(--bg-secondary) 100%, transparent) 100%
    );
    background-size: 200% 100%;
    animation: academy-skeleton-shimmer 1.8s ease-in-out infinite;
}

.academy-skeleton-card__body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.academy-skeleton-card__title,
.academy-skeleton-card__line {
    height: 12px;
    border-radius: var(--radius);
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--bg-secondary) 100%, transparent) 0%,
        color-mix(in srgb, var(--bg-secondary) 70%, transparent) 50%,
        color-mix(in srgb, var(--bg-secondary) 100%, transparent) 100%
    );
    background-size: 200% 100%;
    animation: academy-skeleton-shimmer 1.8s ease-in-out infinite;
}

.academy-skeleton-card__title {
    height: 16px;
    width: 80%;
    margin-bottom: 4px;
}

.academy-skeleton-card__line {
    width: 100%;
}

.academy-skeleton-card__line--short {
    width: 60%;
}

@keyframes academy-skeleton-shimmer {
    0%, 100% { background-position: 200% 0; }
    50% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .academy-skeleton-card__cover,
    .academy-skeleton-card__title,
    .academy-skeleton-card__line {
        animation: none;
        /* Fallback-цвет без анимации */
        background: var(--bg-secondary);
    }
}

/* ───────────────────────────────────────────────────────────────────
   B14: Персонализированный hero — resume-карточка (docs/TZ/11_*.md §B14).
   Показывается ТОЛЬКО авторизованным + при наличии enrollments.
   Для анонимных контейнер не рендерится в template.
   ─────────────────────────────────────────────────────────────────── */
.academy-hero-resume {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    margin: 14px 0;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--accent-primary, var(--color-primary)) 12%, var(--bg-card, var(--white))),
        color-mix(in srgb, var(--accent-primary, var(--color-primary)) 5%, var(--bg-card, var(--white)))
    );
    border-left: 3px solid var(--accent-primary, var(--color-primary));
    box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 8%, transparent);
    flex-wrap: wrap;
}

.academy-hero-resume[hidden] {
    display: none;
}

.academy-hero-resume__icon {
    font-size: 1.8rem;
    line-height: 1;
    flex-shrink: 0;
}

.academy-hero-resume__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
}

.academy-hero-resume__title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary, var(--dark));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.academy-hero-resume__meta {
    font-size: 0.78rem;
    color: var(--text-muted, var(--gray-500));
}

.academy-hero-resume__cta {
    flex-shrink: 0;
    text-decoration: none;
}

@media (max-width: 768px) {
    .academy-hero-resume {
        gap: 10px;
        padding: 10px 12px;
    }
    .academy-hero-resume__cta {
        width: 100%;
        text-align: center;
    }
}
