/**
 * 🧭 NAVIGATION CSS ДЛЯ TELEGRAM MINI APP (🔧 ИСПРАВЛЕН iOS FIXED)
 * Стили навигации: нижняя панель, верхнее меню, табы
 * ✅ ИСПРАВЛЕНО: iOS position fixed с поддержкой safe-area
 */

/* ============================================================================
   🧭 НИЖНЯЯ НАВИГАЦИЯ (BOTTOM NAV) - ИСПРАВЛЕНА ДЛЯ iOS
   ============================================================================ */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-card);
    border-top: 1px solid var(--bg-secondary);
    z-index: var(--z-index-nav);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: var(--spacing-xs) var(--spacing-sm);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    
    /* 🔧 iOS ФИКСЫ */
    -webkit-transform: translateZ(0); /* Аппаратное ускорение */
    transform: translateZ(0);
    will-change: transform;
    
    /* 🔧 iOS SAFE AREA: Добавляем НЕБОЛЬШОЙ отступ снизу для безопасной зоны */
    padding-bottom: calc(var(--spacing-xs) + env(safe-area-inset-bottom, 0px));
    
    /* 🔧 iOS WEBKIT: Принудительная фиксация */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    
    /* 🔧 FIX: Add smooth transition for keyboard hide/show */
    transition: transform 0.3s ease;
}

/* 🔧 FIX: Hide bottom-nav when keyboard is open (iOS/Telegram) */
body.keyboard-open .bottom-nav {
    transform: translateY(100%);
    pointer-events: none;
}

html.keyboard-open .bottom-nav {
    transform: translateY(100%);
    pointer-events: none;
}

/* 🔧 iOS ДОПОЛНИТЕЛЬНЫЕ ФИКСЫ - УБИРАЕМ БОЛЬШИЕ ОТСТУПЫ */
@supports (padding: max(0px)) {
    .bottom-nav {
        /* Используем max() для правильной работы safe-area - НО НЕ УВЕЛИЧИВАЕМ ВЫСОТУ! */
        padding-bottom: max(var(--spacing-xs), env(safe-area-inset-bottom));
        /* УБИРАЕМ лишнюю высоту */
        height: var(--bottom-nav-height);
    }
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-muted);
    transition: all var(--duration-normal) var(--ease-out);
    position: relative;
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.nav-item:hover {
    color: var(--primary-color);
    background: var(--bg-overlay);
    text-decoration: none;
}

.nav-item.active {
    color: var(--primary-color);
    background: var(--bg-overlay);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.nav-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    transition: transform var(--duration-normal) var(--ease-out);
}

.nav-item:active .nav-icon {
    transform: scale(0.9);
}

.nav-label {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    line-height: 1;
    text-align: center;
}

/* Бейдж для уведомлений */
.nav-badge {
    position: absolute;
    top: 2px;
    right: 8px;
    width: var(--badge-size);
    height: var(--badge-size);
    background: var(--error-color);
    color: var(--text-inverse);
    border-radius: var(--radius-round);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--badge-font-size);
    font-weight: var(--font-weight-bold);
    min-width: var(--badge-size);
    padding: 0 4px;
    box-shadow: 0 0 0 2px var(--bg-card);
}

.nav-badge.empty {
    display: none;
}

/* ============================================================================
   📋 ВЕРХНЕЕ МЕНЮ DRAWER - ДОПОЛНИТЕЛЬНЫЕ СТИЛИ
   ============================================================================ */

/* Стили для drawer content (дополняют modals.css) */
.drawer .drawer-header {
    padding: var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: var(--text-inverse);
    position: relative;
}

.drawer .drawer-close {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-inverse);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-normal) var(--ease-out);
    opacity: 0.8;
    position: absolute;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    z-index: 10;
}

.drawer .drawer-close:hover {
    background: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

.drawer .drawer-close svg {
    width: 18px;
    height: 18px;
}

.drawer .drawer-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    margin: 0;
}

.drawer .drawer-body {
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

/* Информация о пользователе в меню */
.menu-user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex: 1;
}

/* When user info is in drawer header */
.drawer-header .menu-user-info {
    border-bottom: none;
    padding: 0;
}

/* When user info is in drawer body (legacy) */
.drawer-body > .menu-user-info {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--bg-secondary);
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-round);
    background: linear-gradient(135deg,
        var(--primary-color, #D2452C),
        var(--primary-light, #E5674F)
    );
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

/* Menu user avatar image */
.menu-user-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
}

/* Menu user avatar fallback */
.user-avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg,
        var(--primary-color, #D2452C),
        var(--primary-light, #E5674F)
    );
    color: var(--text-inverse);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* Show fallback when avatar has fallback class or image is hidden */
.user-avatar.fallback .menu-user-avatar-img,
.user-avatar .menu-user-avatar-img[style*="display: none"] {
    display: none !important;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin: 0 0 var(--spacing-xs) 0;
    line-height: 1.2;
}

/* When user info is in header, use white text */
.drawer-header .user-name {
    color: var(--text-inverse);
}

.user-stats {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin: 0;
    line-height: 1.3;
}

/* When user stats is in header, use white text with opacity */
.drawer-header .user-stats {
    color: rgba(255, 255, 255, 0.85);
}

/* Пункты меню */
.menu-items {
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    margin: 0;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    font-family: inherit;
    font-size: var(--font-size-base);
    color: var(--text-primary);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
}

.menu-item:hover {
    background: var(--bg-secondary);
    color: var(--primary-color);
}

.menu-item:active {
    transform: scale(0.98);
}

.menu-icon {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    transition: color var(--duration-normal) var(--ease-out);
    flex-shrink: 0;
}

.menu-item:hover .menu-icon {
    color: var(--primary-color);
}

.menu-text {
    font-weight: var(--font-weight-medium);
    flex: 1;
}

.menu-divider {
    height: 1px;
    background: var(--bg-secondary);
    margin: 0 var(--spacing-lg);
}

/* Адаптация под темную тему */
@media (prefers-color-scheme: dark) {
    .drawer .drawer-header {
        background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
    }
    
    .menu-item:hover {
        background: var(--bg-overlay);
    }
}

/* Мобильная адаптация для drawer */
@media (max-width: 480px) {
    .drawer.drawer-right {
        width: 280px;
        max-width: 85vw;
    }
    
    .menu-user-info {
        padding: var(--spacing-md);
    }
    
    .user-avatar {
        width: 40px;
        height: 40px;
        font-size: var(--font-size-base);
    }
    
    .menu-item {
        padding: var(--spacing-sm) var(--spacing-md);
    }
}

.top-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--bg-secondary);
    z-index: var(--z-index-header);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-md);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    
    /* 🔧 iOS ФИКСЫ */
    -webkit-transform: translateZ(0); /* Аппаратное ускорение */
    transform: translateZ(0);
    will-change: transform;
    
    /* 🔧 iOS SAFE AREA: Добавляем отступ сверху для безопасной зоны */
    padding-top: env(safe-area-inset-top, 0px);
    
    /* 🔧 iOS WEBKIT: Принудительная фиксация */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.menu-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.menu-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.menu-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.menu-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin: 0;
    line-height: 1;
}

.menu-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin: 0;
    line-height: 1;
    margin-top: 2px;
}

.menu-btn {
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-normal) var(--ease-out);
    position: relative;
}

.menu-btn:hover {
    background: var(--bg-overlay);
    color: var(--primary-color);
}

.menu-btn .icon {
    width: 24px;
    height: 24px;
}

/* Кнопка назад */
.menu-back {
    color: var(--primary-color);
}

.menu-back .icon {
    transform: rotate(180deg);
}

/* Кнопка меню (три точки) */
.menu-more .icon {
    width: 20px;
    height: 20px;
}

/* ============================================================================
   📑 ТАБЫ (TABS)
   ============================================================================ */

.tabs {
    display: flex;
    background: var(--bg-card);
    border-bottom: 1px solid var(--bg-secondary);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    flex: 1;
    min-width: 0;
    padding: var(--spacing-md);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab:hover {
    color: var(--primary-color);
    background: var(--bg-overlay);
}

.tab.active {
    color: var(--primary-color);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-color);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

/* Табы с иконками */
.tab-icon {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    justify-content: center;
}

.tab-icon .icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Вертикальные табы */
.tabs-vertical {
    flex-direction: column;
    border-bottom: none;
    border-right: 1px solid var(--bg-secondary);
    width: 200px;
    max-width: 200px;
}

.tabs-vertical .tab {
    text-align: left;
    justify-content: flex-start;
}

.tabs-vertical .tab.active::after {
    top: 0;
    bottom: 0;
    left: auto;
    right: 0;
    width: 3px;
    height: auto;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

/* ============================================================================
   🍞 BREADCRUMB (ХЛЕБНЫЕ КРОШКИ)
   ============================================================================ */

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) 0;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    white-space: nowrap;
}

.breadcrumb-link {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--duration-normal) var(--ease-out);
}

.breadcrumb-link:hover {
    color: var(--primary-color);
    text-decoration: none;
}

.breadcrumb-separator {
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    opacity: 0.6;
}

.breadcrumb-current {
    color: var(--text-primary);
    font-weight: var(--font-weight-medium);
}

/* ============================================================================
   📱 МОБИЛЬНАЯ АДАПТАЦИЯ С iOS ФИКСАМИ
   ============================================================================ */

@media (max-width: 480px) {
    .bottom-nav {
        height: 60px;
        padding: var(--spacing-xs);
        /* 🔧 МОБИЛЬНЫЕ iOS ФИКСЫ - УБИРАЕМ БОЛЬШИЕ ОТСТУПЫ */
        padding-bottom: calc(var(--spacing-xs) + env(safe-area-inset-bottom, 0px));
    }
    
    .nav-item {
        padding: var(--spacing-xs) 2px;
        gap: 2px;
    }
    
    .nav-icon {
        width: 22px;
        height: 22px;
    }
    
    .nav-label {
        font-size: 10px;
    }
    
    .top-menu {
        height: 50px;
        padding: 0 var(--spacing-sm);
        /* 🔧 МОБИЛЬНЫЕ iOS ФИКСЫ */
        padding-top: env(safe-area-inset-top, 0px);
    }
    
    .menu-title {
        font-size: var(--font-size-base);
    }
    
    .menu-btn {
        width: 36px;
        height: 36px;
    }
    
    .menu-btn .icon {
        width: 20px;
        height: 20px;
    }
    
    .tabs {
        padding: 0;
    }
    
    .tab {
        padding: var(--spacing-sm);
        font-size: var(--font-size-sm);
    }
    
    .breadcrumb {
        padding: var(--spacing-xs) 0;
        font-size: var(--font-size-xs);
    }
}

/* ============================================================================
   🎭 АНИМАЦИИ И ЭФФЕКТЫ
   ============================================================================ */

/* Анимация появления нижней навигации */
.bottom-nav {
    animation: navSlideUp var(--duration-normal) var(--ease-out);
}

@keyframes navSlideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Анимация переключения табов */
.tab-content {
    animation: tabFadeIn var(--duration-normal) var(--ease-out);
}

@keyframes tabFadeIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Рипл эффект для кнопок навигации */
.nav-item,
.menu-btn,
.tab {
    position: relative;
    overflow: hidden;
}

.nav-item::before,
.menu-btn::before,
.tab::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: var(--radius-round);
    background: rgba(210, 69, 44, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.nav-item:active::before,
.menu-btn:active::before,
.tab:active::before {
    width: 100px;
    height: 100px;
}

/* ============================================================================
   🎯 СПЕЦИАЛЬНАЯ НАВИГАЦИЯ ДЛЯ MINI APP
   ============================================================================ */

/* Навигация для дневника с фильтрами */
.diary-nav {
    background: var(--bg-card);
    border-bottom: 1px solid var(--bg-secondary);
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    gap: var(--spacing-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.diary-filter {
    background: var(--bg-secondary);
    color: var(--text-muted);
    border: none;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
}

.diary-filter:hover {
    background: var(--bg-overlay);
    color: var(--text-primary);
}

.diary-filter.active {
    background: var(--primary-color);
    color: var(--text-inverse);
}

/* 🔧 ПЛАВАЮЩАЯ КНОПКА ДОБАВЛЕНИЯ - ИСПРАВЛЕНА ДЛЯ iOS */
.fab-nav {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--spacing-md));
    right: var(--spacing-md);
    width: 56px;
    height: 56px;
    background: var(--primary-color);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-round);
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: calc(var(--z-index-nav) + 1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-normal) var(--ease-out);
    
    /* 🔧 iOS ФИКСЫ ДЛЯ FAB */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.fab-nav:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-xl);
}

.fab-nav:active {
    transform: scale(0.95);
}

.fab-nav .icon {
    width: 24px;
    height: 24px;
}

/* ============================================================================
   🔧 УТИЛИТАРНЫЕ КЛАССЫ
   ============================================================================ */

/* Скрытие навигации - ИСПРАВЛЕНО: Поддержка обоих контекстов */
html.nav-hidden .bottom-nav,
body.nav-hidden .bottom-nav,
.nav-hidden .bottom-nav {
    transform: translateY(100%);
}

html.nav-hidden .top-menu,
body.nav-hidden .top-menu,
.nav-hidden .top-menu {
    transform: translateY(-100%);
}

/* Компактная навигация */
.nav-compact .bottom-nav {
    height: 50px;
    padding: var(--spacing-xs);
}

.nav-compact .nav-label {
    display: none;
}

.nav-compact .nav-icon {
    width: 20px;
    height: 20px;
}

/* Полупрозрачная навигация */
.nav-transparent .bottom-nav,
.nav-transparent .top-menu {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Навигация без границ */
.nav-borderless .bottom-nav {
    border-top: none;
}

.nav-borderless .top-menu {
    border-bottom: none;
}

/* Индикатор загрузки в навигации */
.nav-loading .menu-title::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--bg-secondary);
    border-top-color: var(--primary-color);
    border-radius: var(--radius-round);
    margin-left: var(--spacing-xs);
    animation: navSpin 1s linear infinite;
}

@keyframes navSpin {
    to { transform: rotate(360deg); }
}

/* ============================================================================
   🎨 ИНТЕГРАЦИЯ С TELEGRAM ТЕМАМИ
   ============================================================================ */

/* Адаптация под Telegram цвета */
body[data-theme="telegram"] .bottom-nav {
    background: var(--tg-theme-bg-color, var(--bg-card));
    border-top-color: var(--tg-theme-hint-color, var(--bg-secondary));
}

body[data-theme="telegram"] .top-menu {
    background: var(--tg-theme-bg-color, var(--bg-card));
    border-bottom-color: var(--tg-theme-hint-color, var(--bg-secondary));
}

body[data-theme="telegram"] .nav-item {
    color: var(--tg-theme-hint-color, var(--text-muted));
}

body[data-theme="telegram"] .nav-item.active {
    color: var(--tg-theme-link-color, var(--primary-color));
}

body[data-theme="telegram"] .menu-title {
    color: var(--tg-theme-text-color, var(--text-primary));
}

/* ============================================================================
   🍎 КРИТИЧЕСКИЕ iOS ФИКСЫ ДЛЯ NAVIGATION (ИСПРАВЛЕНО - УБРАЛИ БОЛЬШИЕ РАЗМЕРЫ)
   ============================================================================ */

/* 🔧 ОСНОВНОЙ ФИКС: Стабилизация position fixed на iOS */
.ios-device .bottom-nav {
    position: fixed !important;
    /* Принудительная фиксация для iOS WebView */
    -webkit-transform: translate3d(0, 0, 0) !important;
    transform: translate3d(0, 0, 0) !important;
    /* Аппаратное ускорение */
    will-change: transform !important;
    /* Предотвращение flicker */
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    /* Принудительный z-index */
    z-index: 9999 !important;
    /* Отключение bounce эффекта */
    -webkit-overflow-scrolling: auto !important;
    
    /* 🔧 ИСПРАВЛЕНО: НЕ увеличиваем высоту навигации! */
    height: var(--bottom-nav-height) !important;
    /* Добавляем ТОЛЬКО небольшой отступ снизу для Safe Area */
    padding-bottom: calc(var(--spacing-xs) + env(safe-area-inset-bottom, 0px)) !important;
}

/* 🔧 КОНТЕНТ ФИКС: Правильное позиционирование БЕЗ огромных отступов */
.ios-device .page-content {
    /* НОРМАЛЬНЫЙ отступ снизу */
    padding-bottom: calc(var(--bottom-nav-height) + 16px + env(safe-area-inset-bottom, 0px));
    /* Минимальная высота для обеспечения скролла */
    min-height: calc(100vh - var(--bottom-nav-height));
    min-height: calc(100dvh - var(--bottom-nav-height));
}

/* 🔧 FAB ФИКС: Убираем большие отступы */
.ios-device .fab-nav {
    /* НОРМАЛЬНОЕ позиционирование FAB */
    bottom: calc(var(--bottom-nav-height) + var(--spacing-md) + env(safe-area-inset-bottom, 0px));
    -webkit-transform: translate3d(0, 0, 0) !important;
    transform: translate3d(0, 0, 0) !important;
    will-change: transform !important;
    position: fixed !important;
}

/* 🔧 ИСПРАВЛЕНИЕ СКРОЛЛА: Обеспечиваем корректную прокрутку */
.ios-device html {
    /* Принудительно делаем документ прокручиваемым */
    height: calc(100% + 1px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 🔧 ФИКС ДЛЯ МОДАЛЬНЫХ ОКОН: Стабилизация при открытии */
.ios-device .modal-overlay {
    height: 100vh;
    height: 100dvh;
    /* Фиксируем модальные окна */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
}

/* ============================================================================
   🏠 HOME HEADER REDESIGN - PATCH
   Larger avatar (desktop 80px, mobile 64px) with name and username
   ============================================================================ */

.home-header {
    display: flex;
    align-items: center;
    padding: var(--spacing-md);
    gap: var(--spacing-md);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-lg);
    border: 1px solid var(--bg-secondary);
    box-shadow: var(--shadow-sm);
}

.home-header-avatar-large {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-round);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: var(--text-inverse);
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-xl);
    border: none;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    flex-shrink: 0;
    position: relative;
    /* Ensure minimum touch target */
    min-width: 44px;
    min-height: 44px;
}

.home-header-avatar-large:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb, 210, 69, 44), 0.3);
}

.home-header-avatar-large:active {
    transform: scale(0.95);
}

.home-header-avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.home-header-avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-xl);
    text-transform: uppercase;
    position: relative;
}

.home-header-info {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    min-width: 0;
    flex: 1;
}

.home-header-name {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.home-header-username {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.home-header-menu-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-primary);
    transition: all var(--duration-normal) var(--ease-out);
    flex-shrink: 0;
}

.home-header-menu-btn:hover {
    background: var(--bg-overlay);
}

.home-header-menu-btn:active {
    transform: scale(0.95);
}

.home-header-spacer {
    flex: 1;
}

/* Desktop: Larger avatar (80px) */
@media (min-width: 768px) {
    .home-header-avatar-large {
        width: 80px;
        height: 80px;
        font-size: var(--font-size-2xl);
    }
    
    .home-header-name {
        font-size: var(--font-size-xl);
    }
    
    .home-header-username {
        font-size: var(--font-size-base);
    }
}
