 :root {
            --bg-color: #f0f2f5;
            --app-bg: #f9fbfd;
            --panel-bg: #ffffff;
            --text-main: #2c3e50;
            --text-muted: #7f8c8d;
            --primary: #3498db;
            --msg-user: #e3f2fd;
            --msg-bot: #ffffff;
            --border-radius-large: 24px;
            --app-height: 100vh;
        }

        html, body { margin: 0; padding: 0; height: 100%; }

        body {
            font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
            background-color: var(--bg-color);
            color: var(--text-main);
            display: flex;
            justify-content: center;
            height: var(--app-height);
            overflow: hidden;
            font-size: 16px;
            position: fixed;
            width: 100%;
            top: 0;
            left: 0;
        }

        .app-wrapper {
            width: 100%;
            max-width: 600px;
            height: var(--app-height);
            background-color: var(--app-bg);
            position: relative;
            display: flex;
            flex-direction: column;
            box-shadow: 0 0 30px rgba(0,0,0,0.1);
            overflow: hidden;
        }

        .backdrop {
            position: absolute;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0, 0, 0, 0.45);
            backdrop-filter: blur(2px);
            z-index: 105;
            opacity: 0;
            visibility: hidden;
            transition: opacity 0.3s ease, visibility 0.3s ease;
            pointer-events: none;
        }

        .backdrop.active { opacity: 1; visibility: visible; pointer-events: auto; }

        .header {
            background-color: transparent; 
            box-shadow: none;
            padding: 8px 12px;
            padding-top: calc(8px + env(safe-area-inset-top));
            display: flex;
            align-items: center;
            gap: 12px;
            position: absolute;
            top: 0; left: 0; right: 0;
            z-index: 110;
        }

        .circle-btn {
            width: 50px; height: 50px;
            border-radius: 50%;
            background-color: #f0f4f8;
            border: 1px solid #e1e8ed;
            display: flex; align-items: center; justify-content: center;
            cursor: pointer;
            color: var(--text-main);
            flex-shrink: 0;
            padding: 0;
            transition: background 0.2s, transform 0.1s;
            box-sizing: border-box;
            box-shadow: 0 2px 8px rgba(0,0,0,0.04);
        }

        .circle-btn:active { background: #e2e8f0; transform: scale(0.95); }

        .profile-pill {
            flex: 1;
            display: flex; align-items: center; gap: 12px;
            height: 50px;
            padding: 0 16px 0 4px;
            background-color: #f0f4f8;
            border-radius: 25px;
            border: 1px solid #e1e8ed;
            cursor: pointer;
            box-sizing: border-box;
            box-shadow: 0 2px 8px rgba(0,0,0,0.04);
            transition: background 0.2s, transform 0.1s;
            min-width: 0;
        }

        .profile-pill:active { background: #e2e8f0; transform: scale(0.98); }

        .profile-info { display: flex; flex-direction: column; min-width: 0; justify-content: center; }
        .profile-name { font-weight: 600; font-size: 1.15rem; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .profile-sub { font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }

        .gemini-icon {
            width: 42px; height: 42px;
            background: linear-gradient(135deg, #a8c0ff, #3f2b96);
            border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
            color: white;
            overflow: hidden;
            flex-shrink: 0;
            position: relative;
        }

        .gemini-icon-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
        .gemini-icon-fallback { display: none; }

        .dropdown {
            position: absolute;
            top: 75px;
            background: var(--panel-bg);
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.15);
            padding: 8px 0;
            width: 270px;
            z-index: 110;
            opacity: 0;
            visibility: hidden;
            transform: translateY(-10px);
            transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        }

        .dropdown.active { opacity: 1; visibility: visible; }
        .dropdown-left { left: 12px; }
        .dropdown-right { right: 12px; }
        .dropdown-center { left: 50%; transform: translateX(-50%) translateY(-10px); }
        .dropdown-center.active { transform: translateX(-50%) translateY(0); }

        .menu-item {
            display: flex; align-items: center; gap: 12px;
            padding: 8px 20px;
            cursor: pointer;
            font-size: 1rem;
            color: var(--text-main);
            transition: background 0.2s;
            margin: 6px 8px;
            border-radius: 6px;
			text-decoration:none;
        }
        .menu-item:hover, .menu-item:active { background: #f5f7fa; color: #007aff; }
        .menu-item svg { flex-shrink: 0; width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
        .menu-divider { height: 1px; background: #eee; margin: 5px 0; }

        .balance-widget {
            margin: 8px 16px 12px;
            padding: 16px;
            background: linear-gradient(135deg, #e3f2fd, #f0f4f8);
            border-radius: 14px;
            display: flex; flex-direction: column; gap: 6px;
            border: 1px solid #d0e3f2;
        }
        .balance-label { font-size: 0.8rem; color: #5d758f; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
        .balance-amount { font-size: 1.5rem; font-weight: 700; color: var(--text-main); display: flex; align-items: center; gap: 8px; }
        .balance-amount svg { width: 22px; height: 22px; fill: #f39c12; }
        .balance-currency { font-size: 0.95rem; color: var(--text-muted); font-weight: 500; margin-top: 4px; }

        .bot-hero { padding: 16px 20px 8px; display: flex; flex-direction: column; align-items: center; text-align: center; }
        .bot-hero-avatar {
            width: 100px; height: 100px;
            border-radius: 50%;
            background: linear-gradient(135deg, #a8c0ff, #3f2b96);
            padding: 3px;
            box-shadow: 0 6px 16px rgba(52, 152, 219, 0.2);
            margin-bottom: 12px;
        }
        .bot-hero-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid white; box-sizing: border-box; background: var(--panel-bg); }
        .bot-hero-name { font-size: 1.25rem; font-weight: 700; color: var(--text-main); margin-bottom: 2px; }
        .bot-hero-sub { font-size: 0.9rem; color: var(--text-muted); }

        .chat-container {
            flex: 1;
            padding: 80px 20px 110px 20px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 16px;
            -webkit-overflow-scrolling: touch;
        }

        .msg {
            max-width: 85%;
            padding: 12px 12px 6px 12px;
            border-radius: 20px;
            line-height: 1.4;
            position: relative;
            word-wrap: break-word;
        }

        .msg-user { background-color: var(--msg-user); align-self: flex-end; border-bottom-right-radius: 3px; }
        .msg-bot { background-color: var(--msg-bot); align-self: flex-start; border-top-left-radius: 3px; box-shadow: 0 2px 10px rgba(0,0,0,0.03); border: 1px solid #edf2f7; }

        .msg img { cursor: pointer; border-radius: 12px; transition: opacity 0.15s ease; }
        .msg img:active { opacity: 0.85; }

.msg img,
.lightbox-overlay img,
.lightbox-close {
    -webkit-tap-highlight-color: transparent; /* Убирает синий прямоугольник при тапе */
    -webkit-touch-callout: none;              /* Отключает контекстное меню при долгом нажатии */
    user-select: none;                       /* Запрещает выделение текста/картинки */
    outline: none;                            /* Убирает рамку фокуса */
}

        .footer {
            position: absolute;
            bottom: 0; left: 0; right: 0;
            background-color: var(--panel-bg);
            border-radius: var(--border-radius-large) var(--border-radius-large) 0 0;
            box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
            padding: 12px 20px 0 20px;
            padding-bottom: calc(6px + env(safe-area-inset-bottom));
            z-index: 100;
        }

        .input-area { padding: 0 16px; }

        .chat-input {
            width: 100%;
            border: none;
            background: transparent;
            font-size: 1rem;
            outline: none;
            resize: none;
            font-family: inherit;
            color: var(--text-main);
            overflow-y: hidden;
            max-height: 120px;
            line-height: 1.4;
            min-height: 24px;
            display: block;
        }
        .chat-input::placeholder { color: #a0aebc; }

        .controls { display: flex; justify-content: space-between; align-items: center; }

        .btn-icon {
            background: transparent;
            border: none;
            padding: 8px;
            cursor: pointer;
            border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
            transition: background 0.2s;
        }
        .btn-icon:active { background: #e2e6ea; }
        .btn-icon svg { width: 24px; height: 24px; fill: var(--text-muted); }
        .btn-send svg { fill: var(--primary); }
        .controls-right { display: flex; gap: 8px; }

        ::-webkit-scrollbar { width: 6px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb { background: #dcdde1; border-radius: 3px; }

        /* ===== LIGHTBOX ===== */
        .lightbox-overlay {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0, 0, 0, 0.92);
            z-index: 9999;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            visibility: hidden;
            overflow: hidden;
            touch-action: none;
        }

        .lightbox-overlay.active { opacity: 1; visibility: visible; }

        .lightbox-overlay img {
            max-width: 100%;
            max-height: 100%;
            object-fit: contain;
            display: block;
            transform: translate(0px, 0px) scale(1);
            transition: transform 0.25s ease;
            touch-action: none;
            -webkit-user-select: none;
            user-select: none;
            cursor: pointer; /* Добавлено: курсор-поинтер для ПК */
        }

.lightbox-close {
            position: absolute;
            top: 20px;
            top: calc(20px + env(safe-area-inset-top));
            right: 20px;
            width: 44px;
            height: 44px;
            background: rgba(255, 255, 255, 0.15);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 10000;
            backdrop-filter: blur(4px);
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            -webkit-user-select: none;
            user-select: none;
        }

        .lightbox-close svg {
            width: 24px;
            height: 24px;
            fill: #ffffff;
            transition: transform 0.3s ease;
        }

        /* Эффект при наведении */
        .lightbox-close:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: scale(1.1);
            box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
        }

        .lightbox-close:hover svg {
            transform: rotate(90deg);
        }

        /* Эффект при нажатии */
        .lightbox-close:active {
            transform: scale(0.95);
        }
		
		
/* Стили страницы ЧАТА */
/* Контейнер прижат к правому краю */
.dots-loader {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 0;
  margin: 8px auto 8px 26px; /* Выравнивание по правому краю */
  width: fit-content;
}

/* Маленькие четкие точки без теней */
.dots-loader span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #e2e8f0;
  box-shadow: none;
  animation: pulseDot 1.2s infinite ease-in-out;
}

/* Задержка волны слева направо */
.dots-loader span:nth-child(1) {
  animation-delay: 0s;
}

.dots-loader span:nth-child(2) {
  animation-delay: 0.2s;
}

.dots-loader span:nth-child(3) {
  animation-delay: 0.4s;
}

/* Волна основного цвета приложения */
@keyframes pulseDot {
  0%, 100% {
    background-color: #e2e8f0;
    transform: scale(1);
  }
  33% {
    background-color: var(--primary, #3498db);
    transform: scale(1.3);
  }
}

/* Стили футера */

.login-prompt {
    position: absolute;
    bottom: calc(100% + 16px); 
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--primary);
    color: var(--msg-bot);
    padding: 10px 24px;
    border-radius: var(--border-radius-large);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.35);
    z-index: 101;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.login-prompt:hover {
    background-color: #2980b9;
    transform: translateX(-50%) translateY(-2px);
}

/* Горизонтальный контейнер с прокруткой для нескольких превью */
.image-preview-container {
    display: none;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 8px;
    max-width: 100%;
}

.image-preview-item {
    position: relative;
    flex: 0 0 75px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-item .remove-file {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
}

/* Сетка картинок внутри сообщения в чате */
.msg-images-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.msg-img {
    display: block;
    width: 120px;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* Мелкая надпись стоимости/времени под сообщением */
.msg-cost {
    font-size: 11px;
    color: #8a8a8e;
    margin-top: 2px;
    text-align: right;
    user-select: none;
    opacity: 0.85;
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

/* Неактивное состояние кнопки отправки */
.btn-send:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}