/* Базовый сброс и настройки */
:root {
    --bg-primary: #f5f6fa;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.5);
    --text-main: #2d3038;
    --text-muted: #6e7282;
    --accent-purple: #8a7ff5;
    --accent-pink: #f582ae;
    --accent-blue: #00b4d8;
    --accent-green: #2ec4b6;
    --shadow-soft: 0 8px 32px 0 rgba(138, 127, 245, 0.12);
    --shadow-inset: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    --border-radius-m: 16px;
    --border-radius-s: 10px;
    --font-heading: 'Outfit', 'Rubik', sans-serif;
    --font-body: 'Rubik', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    background-attachment: fixed;
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-main);
    overflow: hidden;
}

/* Контейнер всего приложения */
.app-container {
    width: 100%;
    max-width: 480px;
    height: 100%;
    max-height: 920px;
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: 0px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: hidden;
}

@media (min-width: 481px) {
    .app-container {
        border-radius: var(--border-radius-m);
        height: 92%;
    }
}

/* Шапка приложения */
.app-header {
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.4);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

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

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(138, 127, 245, 0.3);
}

.logo-text h1 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, #6c5ce7, #f78fb3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.status-indicator {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-indicator.online::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green);
}

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

.voice-selector-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.8);
    padding: 6px 12px;
    border-radius: var(--border-radius-s);
    border: 1px solid var(--glass-border);
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    height: 36px;
}

.voice-selector-container select {
    border: none;
    background: transparent;
    outline: none;
    font-family: var(--font-body);
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    max-width: 105px;
}

/* Главная область чата */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    position: relative;
}

/* Квадратный скругленный виджет камеры */
.camera-widget {
    width: 140px;
    height: 140px;
    position: absolute;
    top: 90px;
    right: 20px;
    background: white;
    border-radius: 12px;
    border: 2px solid white;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 20;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.camera-widget.hidden {
    opacity: 0;
    transform: scale(0.8) translateY(-20px);
    pointer-events: none;
}

.camera-header {
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 8px;
    font-size: 0.65rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f2f6;
    color: var(--text-main);
    cursor: move;
    user-select: none;
}

.camera-header .red-dot {
    color: #ff4757;
    animation: flash 1.5s infinite;
}

.video-container {
    flex: 1;
    position: relative;
    background: #000;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
    pointer-events: none;
}

.icon-btn-small {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: color 0.2s;
}

.icon-btn-small:hover {
    color: #ff4757;
}

/* Приветственная карточка */
.welcome-card {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-m);
    padding: 24px;
    text-align: center;
    margin: auto 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.02);
}

.welcome-avatar {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: linear-gradient(135deg, #a8ff78, #78ffd6);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    color: white;
    box-shadow: 0 8px 20px rgba(120, 255, 214, 0.3);
}

.welcome-card h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
}

.welcome-card p {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.welcome-tips {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
    margin-top: 10px;
}

.tip-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 14px;
    border-radius: var(--border-radius-s);
    border: 1px solid var(--glass-border);
    font-size: 0.85rem;
    font-weight: 500;
}

.tip-item i {
    color: var(--accent-purple);
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

/* Пузыри сообщений в чате */
.messages-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    margin-bottom: 2px;
}

.message-wrapper.user {
    align-self: flex-end;
}

.message-wrapper.assistant {
    align-self: flex-start;
}

.message-bubble {
    position: relative;
    padding: 12px 36px 12px 16px;
    border-radius: var(--border-radius-m);
    font-size: 0.95rem;
    line-height: 1.45;
    word-break: break-word;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
}

.message-wrapper.user .message-bubble {
    background: linear-gradient(135deg, #a29bfe, var(--accent-purple));
    color: white;
    border-bottom-right-radius: 4px;
}

.message-wrapper.assistant .message-bubble {
    background: white;
    color: var(--text-main);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Кнопка быстрого копирования текста сообщения */
.copy-msg-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease-in-out;
}

/* При наведении курсора показываем кнопку копирования */
.message-bubble:hover .copy-msg-btn {
    opacity: 0.6;
}

.copy-msg-btn:hover {
    opacity: 1 !important;
    background: rgba(0, 0, 0, 0.05);
}

/* На мобильных устройствах кнопка видна всегда в полупрозрачном виде */
@media (max-width: 768px) {
    .copy-msg-btn {
        opacity: 0.45;
    }
}

/* Цвета для кнопки копирования в пользовательских сообщениях (фиолетовый фон) */
.message-wrapper.user .copy-msg-btn {
    color: rgba(255, 255, 255, 0.8);
}
.message-wrapper.user .copy-msg-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* Цвета для кнопки копирования в ответах ассистента (белый фон) */
.message-wrapper.assistant .copy-msg-btn {
    color: var(--text-muted);
}

.message-image {
    max-width: 100%;
    border-radius: 12px;
    margin-bottom: 8px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.message-info {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.message-wrapper.user .message-info {
    align-self: flex-end;
}

.message-wrapper.assistant .message-info {
    align-self: flex-start;
}

.play-voice-btn {
    background: rgba(138, 127, 245, 0.1);
    border: none;
    color: var(--accent-purple);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    margin-left: 8px;
    transition: all 0.2s;
}

.play-voice-btn:hover {
    background: var(--accent-purple);
    color: white;
}

/* Превью изображения внизу */
.image-preview-container {
    display: flex;
    position: relative;
    align-self: flex-start;
    margin-top: 10px;
    padding: 4px;
    background: white;
    border-radius: var(--border-radius-s);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border: 1px solid var(--glass-border);
}

.image-preview-container.hidden {
    display: none;
}

.image-preview-container img {
    height: 64px;
    width: 64px;
    object-fit: cover;
    border-radius: 8px;
}

.remove-image-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: transparent;
    border: none;
    font-size: 1.1rem;
    color: #ff4757;
    cursor: pointer;
}

/* Нижняя панель ввода */
.input-panel {
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.5);
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 10;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.toggles-row {
    display: flex;
    gap: 16px;
}

/* Стилизация тумблеров (Switch) */
.switch-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    user-select: none;
}

.switch-container input {
    display: none;
}

.switch-slider {
    position: relative;
    width: 34px;
    height: 18px;
    background-color: rgba(0,0,0,0.1);
    border-radius: 9px;
    transition: background-color 0.3s;
}

.switch-slider::before {
    content: "";
    position: absolute;
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.switch-container input:checked + .switch-slider {
    background-color: var(--accent-purple);
}

.switch-container input:checked + .switch-slider::before {
    transform: translateX(16px);
}

.switch-label {
    display: flex;
    align-items: center;
    gap: 4px;
}

.switch-container input:checked ~ .switch-label {
    color: var(--accent-purple);
}

/* Строка ввода */
.input-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.action-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-s);
    border: 1px solid var(--glass-border);
    background: white;
    color: var(--text-muted);
    font-size: 1.1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.action-btn:hover {
    color: var(--accent-purple);
    border-color: var(--accent-purple);
}

.text-input-container {
    flex: 1;
    background: white;
    border-radius: var(--border-radius-s);
    border: 1px solid var(--glass-border);
    padding: 10px 14px;
    box-shadow: var(--shadow-inset);
    display: flex;
    align-items: center;
}

.text-input-container textarea {
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
    resize: none;
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.3;
    max-height: 80px;
}

/* Кнопка записи (Красная пульсация при удержании) */
.record-btn {
    width: 46px;
    height: 46px;
    border-radius: var(--border-radius-s);
    border: none;
    background: linear-gradient(135deg, var(--accent-purple), #9c88ff);
    color: white;
    font-size: 1.15rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 12px rgba(138, 127, 245, 0.3);
}

.record-btn.recording {
    background: linear-gradient(135deg, #ff4757, #ff6b81);
    transform: scale(1.15);
    box-shadow: 0 4px 16px rgba(255, 71, 87, 0.4);
}

.pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: var(--border-radius-s);
    border: 3px solid #ff4757;
    opacity: 0;
    pointer-events: none;
}

.record-btn.recording .pulse-ring {
    animation: ripple 1.2s infinite ease-out;
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-s);
    border: none;
    background: var(--text-main);
    color: white;
    font-size: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.send-btn:hover {
    background-color: var(--accent-purple);
}

/* Лоадеры и Анимации */
.loading-bubble {
    display: flex;
    gap: 4px;
    padding: 12px 20px !important;
}

.loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

@keyframes ripple {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.6); opacity: 0; }
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.animate-pulse {
    animation: pulse 2s infinite ease-in-out;
}

/* Стилизация скроллбара */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   НОВЫЕ СТИЛИ: БОКОВАЯ ПАНЕЛЬ И СТАТИСТИКА ТОКЕНОВ
   ========================================================================== */

/* Боковая панель чатов */
.sidebar-panel {
    position: absolute;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-right: 1px solid var(--glass-border);
    z-index: 30;
    display: flex;
    flex-direction: column;
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-panel.open {
    left: 0;
}

.sidebar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.25);
    z-index: 25;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent-purple);
}

.sidebar-logo h2 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(90deg, #6c5ce7, #f78fb3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.sidebar-actions {
    padding: 16px 20px;
}

.sidebar-btn {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--border-radius-s);
    border: none;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease-in-out;
}

.sidebar-btn.primary-btn {
    background: linear-gradient(135deg, var(--accent-purple), #9c88ff);
    color: white;
    box-shadow: 0 4px 12px rgba(138, 127, 245, 0.2);
}

.sidebar-btn.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(138, 127, 245, 0.3);
}

.chats-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-radius: var(--border-radius-s);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.4);
}

.chat-item:hover {
    background: rgba(138, 127, 245, 0.05);
}

.chat-item.active {
    background: rgba(138, 127, 245, 0.1);
    border-color: rgba(138, 127, 245, 0.25);
}

.chat-item.active .chat-title {
    font-weight: 600;
    color: #5f27cd;
}

.chat-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow: hidden;
}

.chat-title {
    font-size: 0.85rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.chat-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-top: 4px;
}

.chat-item-stats {
    font-size: 0.65rem;
    color: var(--accent-purple);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 3px;
    background: rgba(138, 127, 245, 0.08);
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid rgba(138, 127, 245, 0.15);
    white-space: nowrap;
}

.chat-item.active .chat-item-stats {
    background: rgba(95, 39, 205, 0.12);
    color: #5f27cd;
    border-color: rgba(95, 39, 205, 0.25);
}

.delete-chat-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px;
    cursor: pointer;
    border-radius: var(--border-radius-s);
    transition: all 0.2s;
    opacity: 0.6;
}

.chat-item:hover .delete-chat-btn {
    opacity: 1;
}

.delete-chat-btn:hover {
    color: #ff4757;
    background: rgba(255, 71, 87, 0.1);
}

.sidebar-stats {
    padding: 20px;
    border-top: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.6);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-stats h3 {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.75px;
    margin-bottom: 4px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stat-item span:last-child {
    font-weight: 600;
    color: var(--text-main);
}

.context-item {
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.context-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(0,0,0,0.06);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-pink));
    border-radius: 3px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.context-details {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: right;
}

/* Кнопка меню в шапке */
.menu-btn {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    color: var(--text-main);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    border-radius: 50%;
    margin-right: 4px;
}

.menu-btn:hover {
    color: var(--accent-purple);
    background: rgba(138, 127, 245, 0.08);
}

/* Кнопка загрузки кастомного голоса в селекторе */
.upload-voice-btn-icon {
    background: rgba(138, 127, 245, 0.12);
    border: 1px solid rgba(138, 127, 245, 0.25);
    color: var(--accent-purple);
    cursor: pointer;
    font-size: 0.95rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease-in-out;
    border-radius: var(--border-radius-s);
    flex-shrink: 0;
}

.upload-voice-btn-icon:hover {
    background: var(--accent-purple);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(138, 127, 245, 0.2);
}

/* Бейджи токенов и стоимости под сообщениями */
.message-meta-info {
    display: flex;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding-top: 6px;
    gap: 8px;
}

.token-badge {
    background: rgba(138, 127, 245, 0.06);
    color: var(--accent-purple);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Кнопка статистики в шапке */
.stats-btn-icon {
    background: rgba(138, 127, 245, 0.12);
    border: 1px solid rgba(138, 127, 245, 0.25);
    color: var(--accent-purple);
    cursor: pointer;
    font-size: 0.95rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease-in-out;
    border-radius: var(--border-radius-s);
    flex-shrink: 0;
}

.stats-btn-icon:hover {
    background: var(--accent-purple);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(138, 127, 245, 0.2);
}

/* Стили поповера статистики */
.stats-popover {
    position: absolute;
    top: 80px;
    right: 20px;
    width: 260px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-m);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    z-index: 25;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: opacity 0.25s ease, transform 0.25s ease;
    transform-origin: top right;
}

.stats-popover.hidden {
    opacity: 0;
    transform: scale(0.9) translateY(-10px);
    pointer-events: none;
}

.popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 8px;
}

.popover-header h3 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    font-family: var(--font-heading);
}

.popover-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.popover-stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.popover-stat-item span:first-child i {
    color: var(--accent-purple);
    margin-right: 4px;
    width: 14px;
    text-align: center;
}

.popover-stat-item span:last-child {
    font-weight: 600;
    color: var(--text-main);
}

.popover-context-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 2px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding-top: 8px;
}

.popover-context-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.popover-context-label span:first-child i {
    color: var(--accent-purple);
    margin-right: 4px;
}

.popover-context-label span:last-child {
    font-weight: 600;
    color: var(--text-main);
}

.popover-progress-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.popover-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-pink));
    border-radius: 3px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.popover-context-details {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: right;
}

/* ==========================================================================
   СТИЛИ АВТОРИЗАЦИИ (GLASSMORPHISM)
   ========================================================================== */

.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 15, 26, 0.82);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: opacity 0.4s ease, visibility 0.4s;
}

.auth-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.auth-card {
    width: 100%;
    max-width: 360px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 36px 30px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    color: white;
}

.auth-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 20px;
    font-size: 1.8rem;
    color: white;
    box-shadow: 0 8px 24px rgba(138, 127, 245, 0.4);
}

.auth-card h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(90deg, #a8a5ff, #ffb8d1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-card p {
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
    margin-bottom: 24px;
}

.auth-input-row {
    display: flex;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--border-radius-s);
    padding: 4px;
    transition: all 0.3s;
}

.auth-input-row:focus-within {
    border-color: var(--accent-purple);
    box-shadow: 0 0 12px rgba(138, 127, 245, 0.25);
    background: rgba(255, 255, 255, 0.1);
}

.auth-input-row input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    color: white;
    font-family: var(--font-body);
    font-size: 0.95rem;
    padding: 10px 14px;
}

.auth-input-row input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.auth-input-row button {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: white;
    color: var(--text-main);
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.auth-input-row button:hover {
    background: var(--accent-purple);
    color: white;
    transform: scale(1.05);
}

.auth-error {
    margin-top: 16px;
    font-size: 0.8rem;
    color: #ff4d4d;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    animation: fadeIn 0.3s ease;
}

.auth-error.hidden {
    display: none;
}

/* Анимации */
.animate-scale-in {
    animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes scaleIn {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.shake {
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

