/* ============================================
   CSS Variables (Общие переменные)
   ============================================ */
:root {
    /* Цвета */
    --color-primary: #6A2CFF;
    --color-primary-light: #B565D8;
    --color-primary-dark: #3A1CFF;
    --color-accent: #00C8FF;
    --color-background: #090b13; /* Unified background */
    --color-surface: #0B0B12;
    --color-surface-light: #1a1a2e;
    --color-text-primary: #F5F7FA;
    --color-text-secondary: #8A8FA3;
    --color-text-muted: #5A5A6A;
    --color-border: #2a2a3e;

    /* Gradient */
    --gradient-primary: linear-gradient(135deg, #6A2CFF 0%, #00C8FF 100%);
    --gradient-animated: linear-gradient(90deg, #3A1CFF 0%, #6A2CFF 20%, #B565D8 40%, #00C8FF 60%, #6A2CFF 80%, #3A1CFF 100%);

    /* Shadows */
    --shadow-glow: 0 0 40px rgba(106, 44, 255, 0.6);
    --shadow-button: 0 4px 20px rgba(106, 44, 255, 0.3);

    /* Typography */
    --font-ui: -apple-system, BlinkMacSystemFont,
               "SF Pro Text", "SF Pro Display",
               "Segoe UI", Roboto,
               "Helvetica Neue", Arial,
               system-ui, sans-serif;
    --font-family: var(--font-ui); /* Alias для обратной совместимости */

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 40px;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 50%;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

    /* ============================================
       Layout System Variables
       ============================================ */
    /* Header */
    --header-height: 64px;
    --header-gap: 8px;

    /* Bottom Navigation */
    --bottom-nav-height: 50px;
    --bottom-nav-gap: 12px; /* Closer to bottom */

    /* Container Padding */
    --container-padding-x: 16px; /* Normal horizontal padding for interactive elements */
    --container-padding-top: calc(var(--header-height) + 16px); /* 64px + 16px = 80px */
    --container-padding-bottom: calc(var(--bottom-nav-height) + var(--bottom-nav-gap) + 20px); /* Extra space above button */

    /* Safe Areas */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);

    /* View Dimensions */
    --view-max-width: 100%;
    --view-min-height: 100vh;

    /* Adaptive Container */
    --container-max-width: 640px; /* Standard max width for content */
}

/* ============================================
   Global Squircle Corners (Progressive Enhancement)
   ============================================ */
/*
   Применяем squircle ко всем элементам глобально
   Если браузер поддерживает corner-shape: squircle - используется он
   Если нет - fallback на стандартный border-radius
   Работает как прогрессивное улучшение без ломания совместимости
*/
* {
    corner-shape: squircle;
}

/* ============================================
   Reset & Base Styles
   ============================================ */

/* Запрет выделения текста (улучшает UX на мобильных) */
* {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Разрешаем выделение только в полях ввода */
input,
textarea,
[contenteditable="true"] {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: clip;
    overflow-y: auto;
    width: 100%;
}

body {
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    background: var(--color-background);
    color: var(--color-text-primary);
    overflow-x: clip;
    overflow-y: auto;
    width: 100%;
    margin: 0;
    padding: 0;
    min-height: var(--view-min-height);
    position: relative;
}

/* ============================================
   ADAPTIVE CONTAINER (Desktop/Mobile Layout)
   ============================================ */
.app-container {
    position: relative;
    width: 100%;
    max-width: var(--container-max-width);
    min-height: 100vh;
    margin: 0 auto; /* Center on desktop */
    background: var(--color-background);
}

/* Запрет горизонтального скролла для конкретных элементов */
.header,
.btn-container,
.gallery {
    overflow-x: clip;
}

/* Step должен разрешать overflow для слайдеров внутри */
.step {
    overflow: visible;
}

/* ============================================
   Common Typography
   ============================================ */
.header {
    text-align: center;
    padding: 20px 0;
    margin-bottom: var(--spacing-lg);
}

.header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    color: var(--color-text-primary);
}

.header p {
    font-size: 14px;
    color: var(--color-text-secondary);
}

/* ============================================
   Loading & Error States
   ============================================ */
.loading {
    text-align: center;
    padding: var(--spacing-xl) 20px;
    color: var(--color-text-secondary);
}

.loading p {
    animation: shimmer 2s linear infinite;
    background: linear-gradient(
        90deg,
        var(--color-text-secondary) 0%,
        var(--color-text-secondary) 40%,
        var(--color-text-primary) 50%,
        var(--color-text-secondary) 60%,
        var(--color-text-secondary) 100%
    );
    background-size: 200% 100%;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Spinner moved to loader.css */

.error {
    text-align: center;
    padding: var(--spacing-xl) 20px;
    color: #ff6b6b;
}

/* ============================================
   Common Animations
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 200% 50%;
    }
}

/* Shimmer Effect - используется для загрузочных состояний */
@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Shimmer для текста */
.shimmer-text {
    background: linear-gradient(
        90deg,
        currentColor 0%,
        currentColor 40%,
        rgba(255, 255, 255, 0.9) 50%,
        currentColor 60%,
        currentColor 100%
    );
    background-size: 200% 100%;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 2s linear infinite;
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center {
    text-align: center;
}

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* ============================================
   Button Styles (Common)
   ============================================ */
button {
    white-space: nowrap;
}

/* ============================================
   App Header (Fixed Top Area)
   ============================================ */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    z-index: 5000;

    /* Centered with max-width */
    max-width: var(--container-max-width);
    margin: 0 auto;

    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--container-padding-x);
    box-sizing: border-box;

    /* No background - transparent */
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    box-shadow: none;
}

/* Header left section (for logo/title) */
.app-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Page title in header */
.page-title h1 {
    font-size: 18px;
    font-weight: 600;
    color: #F5F7FA;
    margin: 0;
    padding: 0;
}

/* Header center section (for navigation) */
.app-header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

/* Header right section (for actions/balance) */
.app-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Generations Indicator - glassmorphism style like balance-indicator */
.generations-indicator {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 40px;
    height: 40px;
    padding: 8px;
    border-radius: 12px;

    /* Glassmorphism - matching balance indicator */
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);

    transition: all var(--transition-normal);
    cursor: pointer;
    position: relative;
}

.generations-indicator:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
}

/* Spinner - крутящийся лоадер */
.gen-spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.2);
    border-top-color: #FFFFFF;
    border-right-color: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
}

@keyframes genSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Checkmark - большая белая галочка (центр) */
.gen-checkmark {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #00C851;
    font-weight: bold;
}

/* Badge - маленький notification badge в углу */
.gen-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #00C851;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #FFFFFF;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    border: 2px solid var(--tg-theme-bg-color, #1a1a1a);
}

/* ============================================
   СОСТОЯНИЯ ИНДИКАТОРА (чистая структура)
   ============================================ */

/* Hidden - полностью скрыт */
.generations-indicator.hidden {
    display: none;
}

.generations-indicator.hidden .gen-spinner,
.generations-indicator.hidden .gen-checkmark {
    display: none;
}

/* Pending - крутится spinner + blur волна */
.generations-indicator.pending {
    animation: blurWave 1.5s ease-out;
}

.generations-indicator.pending .gen-spinner {
    display: block;
    animation: genSpin 0.6s linear infinite;
}

.generations-indicator.pending .gen-checkmark,
.generations-indicator.pending .gen-badge {
    display: none;
}

/* Completed - большая галочка в центре */
.generations-indicator.completed .gen-spinner {
    display: none;
}

.generations-indicator.completed .gen-checkmark {
    display: flex;
    animation: checkPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.generations-indicator.completed .gen-badge {
    display: none;
}

/* Ready - spinner + маленький badge (pending + есть непросмотренные completed) */
.generations-indicator.ready .gen-spinner {
    display: block;
    animation: genSpin 0.6s linear infinite;
}

.generations-indicator.ready .gen-checkmark {
    display: none;
}

.generations-indicator.ready .gen-badge {
    display: flex;
    animation: badgePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Анимация появления галочки */
@keyframes checkPop {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(0deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Анимация blur волны для индикатора генераций */
@keyframes blurWave {
    0% {
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        box-shadow:
            0 2px 8px rgba(0, 0, 0, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
    50% {
        backdrop-filter: blur(30px);
        -webkit-backdrop-filter: blur(30px);
        box-shadow:
            0 4px 20px rgba(106, 44, 255, 0.4),
            0 0 40px rgba(181, 101, 216, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.15);
    }
    100% {
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        box-shadow:
            0 2px 8px rgba(0, 0, 0, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
}

/* Анимация появления badge */
@keyframes badgePop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   GENERATION WAVE EFFECT (размытое белое свечение)
   ============================================ */
.generation-wave {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border-radius: 50%;

    /* Размытое белое свечение */
    background: rgba(255, 255, 255, 0.6);
    box-shadow:
        0 0 20px 8px rgba(255, 255, 255, 0.7),
        0 0 40px 16px rgba(255, 255, 255, 0.4),
        0 0 60px 24px rgba(255, 255, 255, 0.2);

    pointer-events: none;
    animation: waveExpand 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;

    /* GPU acceleration для плавности на старых телефонах */
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Анимация расширения волны с затуханием свечения */
@keyframes waveExpand {
    0% {
        transform: scale(1) translateZ(0);
        opacity: 1;
        box-shadow:
            0 0 20px 8px rgba(255, 255, 255, 0.8),
            0 0 40px 16px rgba(255, 255, 255, 0.5),
            0 0 60px 24px rgba(255, 255, 255, 0.3);
    }
    50% {
        opacity: 0.5;
        box-shadow:
            0 0 30px 12px rgba(255, 255, 255, 0.5),
            0 0 60px 24px rgba(255, 255, 255, 0.3),
            0 0 90px 36px rgba(255, 255, 255, 0.15);
    }
    100% {
        transform: scale(3.5) translateZ(0);
        opacity: 0;
        box-shadow:
            0 0 40px 16px rgba(255, 255, 255, 0),
            0 0 80px 32px rgba(255, 255, 255, 0),
            0 0 120px 48px rgba(255, 255, 255, 0);
    }
}

/* ============================================
   GENERATION START BADGE (glassmorphism под индикатором)
   ============================================ */
.generation-start-badge {
    /* Темный Glassmorphism стиль */
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;

    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);

    /* Типографика */
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #FFFFFF;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);

    /* Фиксированное позиционирование под header по центру */
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500; /* Под header (1000), над app-view (100) */
    pointer-events: none;

    /* Ограничение ширины */
    max-width: calc(100vw - 40px);

    /* Анимация появления */
    animation: badgeSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;

    /* GPU acceleration */
    will-change: transform, opacity;
    backface-visibility: hidden;
}

/* Анимация появления с плавным bounce эффектом */
@keyframes badgeSlideIn {
    0% {
        transform: translateX(-50%) translateY(-15px) scale(0.9);
        opacity: 0;
    }
    60% {
        transform: translateX(-50%) translateY(2px) scale(1.02);
        opacity: 1;
    }
    100% {
        transform: translateX(-50%) translateY(0) scale(1);
        opacity: 1;
    }
}

/* Анимация смены текста (небольшой bounce) */
.generation-start-badge.badge-second-text {
    animation: badgeTextChange 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badgeTextChange {
    0% {
        transform: translateX(-50%) scale(1);
    }
    50% {
        transform: translateX(-50%) scale(1.05);
    }
    100% {
        transform: translateX(-50%) scale(1);
    }
}

/* Анимация исчезновения */
.generation-start-badge.badge-fade-out {
    animation: badgeFadeOut 0.3s ease forwards;
}

@keyframes badgeFadeOut {
    0% {
        transform: translateX(-50%) translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateX(-50%) translateY(-10px) scale(0.95);
        opacity: 0;
    }
}

/* ============================================
   Back Button (In Header Left)
   ============================================ */
.header-back-button {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 12px;

    /* Glassmorphism - matching balance indicator */
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);

    font-size: 18px;
    color: var(--color-text-primary);

    transition: all var(--transition-normal);
    cursor: pointer;
}

.header-back-button:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
}

.header-back-button:active {
    transform: translateY(0);
}

/* ============================================
   Balance Indicator (In Header)
   ============================================ */
.balance-indicator {
    display: flex !important;
    align-items: center;
    gap: 8px;

    padding: 8px 14px;
    border-radius: 12px;

    /* Glassmorphism */
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);

    font-weight: 600;
    font-size: 14px;
    color: var(--color-text-primary);

    transition: all var(--transition-normal);
    cursor: pointer;

    /* Ensure visibility */
    opacity: 1 !important;
    visibility: visible !important;
}

.balance-indicator:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
}

/* Token Icon - star */
.token-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.token-icon img,
.token-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
    filter: drop-shadow(0 0 4px rgba(106, 44, 255, 0.6));
}

/* Balance amount */
.balance-amount {
    font-variant-numeric: tabular-nums;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    /* Body padding removed - handled by .app-view */

    .header h1 {
        font-size: 20px;
    }

    .header p {
        font-size: 13px;
    }

    .balance-indicator {
        padding: var(--spacing-sm) 12px;
        font-size: 14px;
    }

    .token-icon {
        width: 16px;
        height: 16px;
    }
}

/* ============================================
   Bottom Navigation Bar (Global)
   ============================================ */
.bottom-nav-bar {
    position: fixed;
    bottom: var(--bottom-nav-gap);
    left: 0;
    right: 0;
    margin: 0 auto;

    /* Width by content - not full width */
    width: fit-content;
    padding: 4px 12px; /* Smaller padding */
    padding-bottom: calc(4px + var(--safe-area-bottom));

    /* More transparent Glassmorphism */
    background: rgba(11, 11, 18, 0.5);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);

    /* Rounded edges */
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);

    /* Lighter Shadow */
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);

    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    z-index: 999;
}

.bottom-nav-bar.hidden {
    transform: translateY(150%);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px 18px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 16px;
    background: transparent;
    border: none;
    position: relative;
}

.bottom-nav-item:active {
    transform: scale(0.95);
    background: rgba(0, 122, 255, 0.1);
}

.bottom-nav-item.active {
    background: rgba(0, 122, 255, 0.08);
}

.bottom-nav-item.active .bottom-nav-label {
    color: #007AFF;
    font-weight: 600;
}

.bottom-nav-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bottom-nav-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: brightness(0) saturate(100%) invert(100%); /* White icons */
    opacity: 1; /* Full opacity for white icons */
}

.bottom-nav-item.active .bottom-nav-icon img {
    /* Active state: change to theme color */
    filter: brightness(0) saturate(100%) invert(27%) sepia(98%) saturate(5395%) hue-rotate(203deg) brightness(98%) contrast(105%);
    opacity: 1;
}

/* User avatar in nav bar */
.bottom-nav-icon.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
    position: relative;
}

/* Gradient spinner when pending generations exist */
.bottom-nav-icon.user-avatar::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    background: linear-gradient(0deg, rgba(0, 122, 255, 0.1) 33%, rgba(0, 122, 255, 1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: -1;
}

.bottom-nav-icon.user-avatar.has-pending::before {
    opacity: 1;
    animation: spin 0.8s linear infinite;
}

/* @keyframes spin moved to loader.css */

.bottom-nav-icon.user-avatar img {
    /* White icon by default (before avatar loads) */
    filter: brightness(0) saturate(100%) invert(100%);
    opacity: 0.7;
    transition: all 0.3s ease-in-out;
}

/* Remove filter when avatar is loaded (class added by JS) */
.bottom-nav-icon.user-avatar img.avatar-loaded {
    filter: none;
    opacity: 1;
}

.bottom-nav-item.active .bottom-nav-icon.user-avatar {
    border-color: #007AFF;
}

/* Active state: icon without avatar becomes blue */
.bottom-nav-item.active .bottom-nav-icon.user-avatar img {
    filter: brightness(0) saturate(100%) invert(27%) sepia(98%) saturate(5395%) hue-rotate(203deg) brightness(98%) contrast(105%);
    opacity: 1;
}

/* Active state with avatar loaded: keep avatar normal (no filter) */
.bottom-nav-item.active .bottom-nav-icon.user-avatar img.avatar-loaded {
    filter: none;
    opacity: 1;
}

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

.bottom-nav-label {
    font-size: 12px;
    font-weight: 500;
    color: #ffffff;
    transition: color 0.2s;
}

/* ============================================
   PRIMARY ACTION BUTTON (Global)
   ============================================

   Максимально простая кнопка без анимаций
   Использование: <button class="btn-action-primary">Создать</button>

   v26.4 - Mobile-first, no animations
   ============================================ */

.btn-action-primary {
    /* Позиционирование */
    position: fixed;
    bottom: var(--bottom-nav-gap);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;

    /* Белый фон и темный текст */
    background: #FFFFFF;
    color: var(--color-surface-light);
    border: none;

    /* Размеры using CSS variables */
    padding: var(--spacing-md) var(--spacing-xl);
    min-width: 200px;
    border-radius: var(--radius-lg);

    /* Шрифт */
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-ui);
    text-align: center;

    /* Статичная тень */
    box-shadow:
        0 4px 20px rgba(106, 44, 255, 0.3),
        0 2px 10px rgba(181, 101, 216, 0.2),
        inset 0 1px 2px rgba(255, 255, 255, 0.5);

    /* Мобильные оптимизации */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;

    cursor: pointer;
}

/* Минимальный feedback на active */
.btn-action-primary:active {
    opacity: 0.7;
}

.btn-action-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   BUTTONS CONTAINER (Global)
   ============================================ */

.buttons-container {
    position: fixed;
    bottom: var(--bottom-nav-gap);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    z-index: 200; /* Над app-view (100), под навигацией (500) */
    opacity: 0;
    transition: all var(--transition-slow);
}

.buttons-container.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Кнопки внутри контейнера */
.buttons-container .btn-action-primary {
    position: static;
    transform: none;
}

.buttons-container .btn-action-primary:active {
    opacity: 0.7;
}

/* ============================================
   SHIMMER ROUNDED BUTTON EFFECT
   ============================================
   
   Красивый shimmer эффект для кнопок с мерцающим свечением.
   
   Использование:
   <button class="btn-shimmer">
       <span class="shimmer"></span>
       <span class="text">Текст кнопки</span>
   </button>
   
   Модификаторы:
   - .btn-shimmer.active - активное состояние с анимацией
   - --glow-hue - цвет свечения (по умолчанию 222deg)
   - --shadow-hue - цвет тени (по умолчанию 180deg)
   
   v24.377
   ============================================ */

/* CSS Custom Properties для shimmer эффекта */
:root {
    --glow-hue: 222deg;
    --shadow-hue: 180deg;
    --spring-easing: linear(
        0, 0.002, 0.01 0.9%, 0.038 1.8%, 0.156, 0.312 5.8%, 0.789 11.1%, 1.015 14.2%,
        1.096, 1.157, 1.199, 1.224 20.3%, 1.231, 1.231, 1.226, 1.214 24.6%,
        1.176 26.9%, 1.057 32.6%, 1.007 35.5%, 0.984, 0.968, 0.956, 0.949 42%,
        0.946 44.1%, 0.95 46.5%, 0.998 57.2%, 1.007, 1.011 63.3%, 1.012 68.3%,
        0.998 84%, 1
    );
    --spring-duration: 1.33s;
}

/* CSS Houdini property для shimmer анимации */
@property --shimmer {
    syntax: "<angle>";
    inherits: false;
    initial-value: 33deg;
}

/* Shimmer rotation animation */
@keyframes shimmer {
    0% {
        --shimmer: 0deg;
    }
    100% {
        --shimmer: 360deg;
    }
}

/* Shine glow animation */
@keyframes shine {
    0% {
        opacity: 0;
    }
    15% {
        opacity: 1;
    }
    55% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* Text gradient sweep animation */
@keyframes shimmer-text {
    0% {
        background-position: 100% center;
    }
    100% {
        background-position: -100% center;
    }
}

/* Основной стиль кнопки с shimmer эффектом */
.btn-shimmer {
    --inset: 40px;
    
    /* Базовые стили */
    color: var(--bg, #1a1a2e);
    font-weight: 600;
    background-image: linear-gradient(
        315deg,
        #ffc4ec -10%,
        #efdbfd 50%,
        #ffedd6 110%
    );
    padding: 0.8em 1.4em;
    border: none;
    cursor: pointer;
    
    /* Positioning для shimmer overlay */
    position: relative;
    isolation: isolate;
    
    /* Тени и скругления */
    box-shadow: 
        0 2px 3px 1px hsl(var(--glow-hue) 50% 20% / 50%),
        inset 0 -10px 20px -10px hsla(var(--shadow-hue), 10%, 90%, 95%);
    border-radius: 0.66em;
    
    /* Spring анимация scale */
    scale: 1;
    transition: all var(--spring-duration) var(--spring-easing);
    
    /* GPU acceleration */
    will-change: scale, box-shadow;
    backface-visibility: hidden;
}

/* Hover и active состояния */
.btn-shimmer:hover:not(:active),
.btn-shimmer.active {
    transition-duration: calc(var(--spring-duration) * 0.5);
    scale: 1.2;
    box-shadow: 
        0 4px 8px -2px hsl(var(--glow-hue) 50% 20% / 50%),
        inset 0 0 0 transparent;
}

.btn-shimmer:active {
    scale: 1.1;
    transition-duration: calc(var(--spring-duration) * 0.5);
}

/* Shimmer overlay element */
.btn-shimmer .shimmer {
    position: absolute;
    inset: calc(var(--inset) * -1);
    border-radius: inherit;
    pointer-events: none;
    
    /* Conic gradient mask для shimmer эффекта */
    mask-image: conic-gradient(
        from var(--shimmer, 0deg),
        transparent 0%,
        transparent 20%,
        black 36%,
        black 45%,
        transparent 50%,
        transparent 70%,
        black 85%,
        black 95%,
        transparent 100%
    );
    mask-size: cover;
    
    /* Blend mode для свечения */
    mix-blend-mode: plus-lighter;
    
    /* Постоянная анимация вращения */
    animation: shimmer 1s linear infinite both;
}

/* Shimmer glow на hover/active */
.btn-shimmer:hover .shimmer::before,
.btn-shimmer:hover .shimmer::after,
.btn-shimmer.active .shimmer::before,
.btn-shimmer.active .shimmer::after {
    opacity: 1;
    animation: shine 1.2s ease-in 1 forwards;
}

/* Shimmer pseudo-elements для свечения */
.btn-shimmer .shimmer::before,
.btn-shimmer .shimmer::after {
    transition: all 0.5s ease;
    opacity: 0;
    content: "";
    border-radius: inherit;
    position: absolute;
    mix-blend-mode: color;
    inset: var(--inset);
    pointer-events: none;
}

/* Внешнее свечение (outer glow) */
.btn-shimmer .shimmer::before {
    box-shadow: 
        0 0 calc(var(--inset) * 0.1) 2px hsl(var(--glow-hue) 20% 95%),
        0 0 calc(var(--inset) * 0.18) 4px hsl(var(--glow-hue) 20% 80%),
        0 0 calc(var(--inset) * 0.33) 4px hsl(var(--glow-hue) 50% 70%),
        0 0 calc(var(--inset) * 0.66) 5px hsl(var(--glow-hue) 100% 70%);
    z-index: -1;
}

/* Внутреннее свечение (inner glow) */
.btn-shimmer .shimmer::after {
    box-shadow: 
        inset 0 0 0 1px hsl(var(--glow-hue) 70% 95%),
        inset 0 0 2px 1px hsl(var(--glow-hue) 100% 80%),
        inset 0 0 5px 2px hsl(var(--glow-hue) 100% 70%);
    z-index: 2;
}

/* Текст кнопки с gradient sweep эффектом */
.btn-shimmer .text {
    color: transparent;
    background-clip: text;
    -webkit-background-clip: text;
    background-color: var(--bg, #1a1a2e);
    background-image: linear-gradient(
        120deg,
        transparent,
        hsla(var(--glow-hue), 100%, 80%, 0.66) 40%,
        hsla(var(--glow-hue), 100%, 90%, 0.9) 50%,
        transparent 52%
    );
    background-repeat: no-repeat;
    background-size: 300% 300%;
    background-position: center 200%;
}

/* Text sweep анимация на hover/active */
.btn-shimmer:hover .text,
.btn-shimmer.active .text {
    animation: shimmer-text 0.66s ease-in 1 both;
}

/* Цветовые темы для shimmer эффекта */
.btn-shimmer.theme-blue {
    --glow-hue: 222deg;
    --shadow-hue: 180deg;
}

.btn-shimmer.theme-purple {
    --glow-hue: 280deg;
    --shadow-hue: 260deg;
}

.btn-shimmer.theme-pink {
    --glow-hue: 330deg;
    --shadow-hue: 310deg;
}

.btn-shimmer.theme-green {
    --glow-hue: 140deg;
    --shadow-hue: 120deg;
}

.btn-shimmer.theme-orange {
    --glow-hue: 30deg;
    --shadow-hue: 15deg;
}
