/* === Цветовые схемы === */
:root {
    --bg-main: #0d0d0d;
    --bg-sidebar: #1a1a1a;
    --bg-input: #2a2a2a;
    --bg-hover: #333333;
    --bg-active: #3d3d3d;
    --bg-dropdown: #222222;

    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #6b6b6b;

    --accent-bright: #f4a100;
    --accent-dim: #a06a00;
    --accent-hover: #ffb820;

    --border: #2a2a2a;

    /* Цвета из логотипа */
    --logo-blue: #1a4fc4;
    --logo-blue-dark: #0033a0;
    --logo-red: #d90012;
}

[data-theme="light"] {
    --bg-main: #ffffff;
    --bg-sidebar: #f5f5f5;
    --bg-input: #ffffff;
    --bg-hover: #e8e8e8;
    --bg-active: #dcdcdc;
    --bg-dropdown: #ffffff;

    --text-primary: #1a1a1a;
    --text-secondary: #555555;
    --text-muted: #999999;

    --accent-bright: #d68000;
    --accent-dim: #a06a00;
    --accent-hover: #ffa500;

    --border: #e0e0e0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100vh;
}

/* === Сайдбар === */
.sidebar {
    width: 280px;
    height: 100vh;
    max-height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.2s;
    overflow: hidden;
}

.sidebar.collapsed {
    width: 60px !important;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .sidebar-level-2 .icon-btn:not(#collapseBtn),
.sidebar.collapsed .search-field,
.sidebar.collapsed .new-chat-btn,
.sidebar.collapsed .chat-list,
.sidebar.collapsed .subscription-block {
    display: none !important;
}

.sidebar.collapsed .sidebar-level-1 {
    padding: 12px 4px;
    justify-content: center;
}

.sidebar.collapsed .sidebar-level-2 {
    padding: 8px 4px;
    justify-content: center;
}

/* === Уровень 1: Лого === */
.sidebar-level-1 {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.logo-block {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-small {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    flex-shrink: 0;
}

.logo-text {
    font-size: 32px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

/* === Уровень 2: Иконки === */
.sidebar-level-2 {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--accent-bright);
}

/* === Выпадающие списки === */
.dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    background: var(--bg-dropdown);
    border: 1px solid var(--border);
    border-radius: 8px;
    min-width: 260px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.dropdown-menu.open {
    display: block;
}

.dropdown-title {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 10px 12px 6px;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.dropdown-list {
    padding: 6px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: background 0.15s;
    white-space: nowrap;
}

.dropdown-item:hover {
    background: var(--bg-hover);
}

.dropdown-checkbox {
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-muted);
    border-radius: 4px;
    flex-shrink: 0;
    transition: all 0.15s;
}

.dropdown-checkbox.checked {
    background: var(--accent-bright);
    border-color: var(--accent-bright);
}

/* === Поле поиска === */
.search-field {
    display: none;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-sidebar);
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.search-field.open {
    display: flex;
}

.search-field input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.search-field input:focus {
    border-color: var(--accent-dim);
}

.search-field input::placeholder {
    color: var(--text-muted);
}

/* === Уровень 3: Новый чат === */
.new-chat-btn {
    margin: 12px;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid var(--accent-dim);
    border-radius: 24px;
    color: var(--accent-bright);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.new-chat-btn:hover {
    background: var(--accent-dim);
    color: var(--text-primary);
}

.plus-icon {
    font-size: 14px;
}

/* === Список чатов === */
.chat-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 8px;
}

.chat-group {
    margin-bottom: 16px;
}

.group-title {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 8px 12px 4px;
    letter-spacing: 0.5px;
}

.chat-item {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    transition: background 0.15s;
    position: relative;
}

.chat-item:hover {
    background: var(--bg-hover);
}

.chat-item.active {
    background: var(--bg-active);
    color: var(--text-primary);
}

.pin-icon {
    font-size: 12px;
    color: var(--accent-bright);
    flex-shrink: 0;
}

.chat-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-name.editing {
    background: var(--bg-input);
    border: 1px solid var(--accent-dim);
    border-radius: 4px;
    padding: 2px 6px;
    color: var(--text-primary);
    outline: none;
    width: 100%;
}

/* === Подсветка поиска === */
.search-highlight {
    background: var(--accent-bright);
    color: #000;
    border-radius: 2px;
    padding: 0 2px;
}

/* === Блок подписки === */
.subscription-block {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
    background: var(--bg-sidebar);
}

.subscription-status {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: default;
    transition: all 0.2s;
}

.subscription-status.active {
    background: var(--logo-blue);
    border: 1px solid var(--logo-blue);
    cursor: default;
}

.subscription-status.active .subscription-label {
    color: #ffffff;
    font-weight: 600;
}

.subscription-status.active .subscription-timer {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
}

.subscription-status.expired {
    background: var(--logo-red);
    border: 1px solid var(--logo-red);
    cursor: pointer;
}

.subscription-status.expired:hover {
    opacity: 0.85;
}

.subscription-status.expired .subscription-label {
    color: #ffffff;
    font-weight: 600;
}

.subscription-label {
    font-size: 14px;
}

.subscription-timer {
    font-size: 12px;
    color: var(--text-muted);
}

/* === Модальное окно === */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 3000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    max-width: 600px;
    width: 90%;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.15s;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 24px;
    text-align: center;
}

.tariff-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.tariff-card {
    padding: 20px 16px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.tariff-card:hover {
    border-color: var(--accent-dim);
}

.tariff-card.selected {
    border-color: var(--accent-bright);
    background: rgba(244, 161, 0, 0.1);
}

.tariff-name {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.tariff-price {
    font-size: 20px;
    font-weight: 600;
    color: var(--accent-bright);
    margin-bottom: 4px;
}

.tariff-duration {
    font-size: 12px;
    color: var(--text-muted);
}

.modal-pay-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent-bright);
    border: none;
    border-radius: 10px;
    color: #000;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-pay-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.modal-pay-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* === Основная область === */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.chat-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 8px;
}

/* === Экран приветствия === */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px 20px;
}

.welcome-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.welcome-logo {
    width: 96px;
    height: 96px;
    border-radius: 16px;
}

.welcome-title {
    font-size: 36px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.welcome-message {
    font-size: 26px;
    color: var(--text-secondary);
    max-width: 600px;
    line-height: 1.5;
}

/* === Сообщения === */
.message {
    display: flex;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 0 16px;
}

.message.assistant {
    justify-content: flex-start;
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    max-width: 80%;
    box-sizing: border-box;
    overflow-x: hidden;
    word-wrap: break-word;
}

.message.assistant .message-content {
    background: var(--bg-sidebar);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.message.user .message-content {
    background: var(--accent-dim);
    color: var(--text-primary);
}

/* === Системное сообщение (лимит памяти) === */
.system-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px;
    margin: 0 auto;
    max-width: 500px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.system-message-text {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
}

.system-message-actions {
    display: flex;
    gap: 8px;
}

.system-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--accent-dim);
    background: transparent;
    color: var(--accent-bright);
}

.system-btn:hover {
    background: var(--accent-dim);
    color: var(--text-primary);
}

.system-btn.primary {
    background: var(--accent-bright);
    color: #000;
    border-color: var(--accent-bright);
}

.system-btn.primary:hover {
    background: var(--accent-hover);
}

/* === Поле ввода === */
.input-area {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.input-wrapper {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 4px 6px;
    transition: border-color 0.2s;
    box-sizing: border-box;
    overflow: hidden;
    flex-wrap: nowrap;
}

.input-wrapper:focus-within {
    border-color: var(--accent-dim);
}

.input-btn {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.input-btn:hover {
    background: var(--bg-hover);
    color: var(--accent-bright);
}

#messageInput {
    flex: 1 1 auto;
    min-width: 0;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    padding: 6px 4px;
    outline: none;
}

#messageInput::placeholder {
    color: var(--text-muted);
}

.send-btn {
    flex: 0 0 auto;
    background: var(--accent-bright);
    border: none;
    color: #000;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s;
}

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

/* === Скроллбар === */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-dim);
}

/* === Контекстное меню === */
.context-menu {
    position: fixed;
    background: var(--bg-dropdown);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
    min-width: 180px;
    z-index: 2000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.context-item {
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.context-item svg { flex-shrink: 0; }
.context-item:hover { background: var(--bg-hover); color: var(--accent-bright); }

/* === Кнопка записи === */
.voice-btn.recording,
.input-btn.recording {
    background: #d90012 !important;
    color: #fff !important;
    min-width: 40px;
    padding: 8px 10px;
}

.record-time {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

/* === Блокировка ввода === */
#messageInput:disabled,
#sendBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === Заголовок чата === */
.main-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.main-header-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Красное уведомление об общей памяти */
.global-limit-banner {
    background: #d90012;
    color: #ffffff;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 14px;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 100;
}

.global-limit-banner button {
    background: #ffffff;
    color: #d90012;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.global-limit-banner button:hover {
    opacity: 0.85;
}

/* Уведомление «Отменить» */
.undo-notification {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-dropdown);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
    color: var(--text-primary);
    z-index: 3000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.undo-notification button {
    background: var(--accent-bright);
    color: #000;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

/* Поле редактирования сообщения */
.message-edit-input {
    background: var(--bg-input);
    border: 1px solid var(--accent-dim);
    border-radius: 12px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    width: 100%;
    max-width: 80%;
}

/* Фото в сообщении */
.message-photo {
    max-width: 100%;
    max-height: 300px;
    width: auto;
    height: auto;
    border-radius: 12px;
    cursor: pointer;
    display: block;
    object-fit: contain;
    box-sizing: border-box;
}

.message-photo:hover {
    opacity: 0.9;
}

/* Голосовое сообщение */
.message-voice {
    width: 100%;
    max-width: 300px;
    height: 40px;
    border-radius: 8px;
}

/* === Превью вложений === */
.attachments-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.attachment-item {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    background: #2a2a2a;
}

.attachment-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attachment-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-remove:hover {
    background: rgba(255, 0, 0, 0.8);
}

/* === Переключение режима в сайдбаре === */
.mode-switch-prompt {
    margin: 8px 16px;
    padding: 12px;
    background: rgba(255, 149, 0, 0.1);
    border: 1px solid rgba(255, 149, 0, 0.3);
    border-radius: 8px;
    font-size: 12px;
}

.mode-switch-text {
    color: #fff;
    margin-bottom: 10px;
    line-height: 1.4;
}

.mode-switch-text small {
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
}

.mode-switch-actions {
    display: flex;
    gap: 8px;
}

.mode-switch-btn {
    flex: 1;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-switch-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mode-switch-btn.primary {
    background: #ff9500;
    border-color: #ff9500;
    color: #000;
    font-weight: 600;
}

.mode-switch-btn.primary:hover {
    background: #ffaa33;
}

/* Скрытие крестика принудительно */
#tariffsCloseBtn[style*="none"],
#tariffsCloseBtn[style*="hidden"] {
    display: none !important;
    visibility: hidden !important;
}

/* === Красное уведомление в чате (в стиле «подписка истекла») === */
.chat-warning {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: var(--logo-red);
    border: 1px solid var(--logo-red);
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    z-index: 100;
    animation: slideDown 0.3s ease;
}

.chat-warning-text {
    flex: 1;
}

.chat-warning-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.9;
}

.chat-warning-close:hover {
    opacity: 1;
    color: #ffffff;
}

@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* === Сворачиваемый футер === */
footer#mainFooter {
    position: relative;
    text-align: center;
    padding: 8px 30px 8px 10px;
    color: #666;
    border-top: 1px solid #eee;
    margin-top: 6px;
    line-height: 1.4;
    font-size: 10px;
    transition: max-height 0.3s ease, padding 0.3s ease;
    overflow: hidden;
}
footer#mainFooter.collapsed {
    max-height: 24px;
    padding-top: 4px;
    padding-bottom: 4px;
}
footer#mainFooter.expanded {
    max-height: 200px;
}
footer#mainFooter .footer-content {
    transition: opacity 0.2s ease;
}
footer#mainFooter.collapsed .footer-content {
    opacity: 0;
    pointer-events: none;
}
.footer-toggle {
    position: absolute;
    top: 4px;
    right: 6px;
    width: 20px;
    height: 20px;
    border: 1px solid #444;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    z-index: 10;
}
.footer-toggle::after {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 6px solid #aaa;
    transition: transform 0.3s ease;
}
footer#mainFooter.collapsed .footer-toggle::after {
    transform: rotate(180deg);
}
@media (max-width: 768px) {
    footer#mainFooter { font-size: 8px; }
}


/* === Фото в чате — не вылезают за грань === */
img.chat-photo,
.attachments-preview img,
.message-photo img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    margin: 4px 0;
}

.attachments-preview {
    max-width: 100%;
    overflow: hidden;
    padding: 0 8px;
    box-sizing: border-box;
}


/* === FIX: messages should not clip vertically === */
.message,
.message-content,
.chat-message,
.chat-bubble {
    overflow: visible !important;
    max-height: none !important;
}

.message-content {
    overflow-x: hidden !important;
    overflow-y: visible !important;
}


/* === FIX: photo must fit screen === */
.message img.message-photo,
.message-content img.message-photo,
img.message-photo {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    max-height: 60vh !important;
    display: block !important;
    object-fit: contain !important;
    border-radius: 12px;
    box-sizing: border-box;
}

.message.user .message-content {
    max-width: 85% !important;
    overflow: visible !important;
}

.message.assistant .message-content {
    max-width: 85% !important;
    overflow: visible !important;
}

/* === AUTH SCREEN === */
.auth-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-main, #ffffff);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    box-sizing: border-box;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-sidebar, #f7f7f8);
    border-radius: 16px;
    padding: 32px 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    box-sizing: border-box;
}

.auth-logo {
    text-align: center;
    margin-bottom: 24px;
}

.auth-logo-img {
    width: 64px;
    height: 64px;
    margin-bottom: 12px;
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 4px 0;
    color: var(--text-primary, #111);
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-secondary, #888);
    margin: 0;
}

.auth-tabs {
    display: flex;
    background: rgba(0,0,0,0.04);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary, #666);
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--bg-main, #fff);
    color: var(--text-primary, #111);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.auth-field {
    margin-bottom: 16px;
}

.auth-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary, #333);
}

.auth-field input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 10px;
    font-size: 15px;
    box-sizing: border-box;
    background: var(--bg-main, #fff);
    color: var(--text-primary, #111);
    outline: none;
    transition: border-color 0.2s;
}

.auth-field input:focus {
    border-color: var(--accent, #c89b3c);
}

.auth-error {
    color: #d33;
    font-size: 13px;
    min-height: 18px;
    margin-bottom: 12px;
}

.auth-submit {
    width: 100%;
    padding: 14px;
    background: var(--accent, #c89b3c);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.auth-submit:hover {
    opacity: 0.9;
}

.auth-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.auth-footer {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-secondary, #888);
}

.auth-footer a {
    color: var(--accent, #c89b3c);
    text-decoration: none;
    font-weight: 600;
    margin-left: 4px;
}

/* === USER INFO (sidebar bottom) === */
.user-info {
    margin-top: auto;
    padding: 12px 16px;
    border-top: 1px solid var(--border, #e0e0e0);
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-sidebar, #f7f7f8);
    flex-shrink: 0;
}

.user-email {
    flex: 1;
    font-size: 12px;
    color: var(--text-secondary, #888);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.user-logout {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary, #888);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.user-logout:hover {
    background: rgba(200, 60, 60, 0.1);
    color: #c83c3c;
}

/* === PASSWORD TOGGLE === */
.password-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrap input {
    padding-right: 44px !important;
    width: 100%;
}

.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary, #888);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    padding: 0;
}

.password-toggle:hover {
    color: var(--text-primary, #333);
    background: rgba(0, 0, 0, 0.05);
}

.password-toggle svg {
    display: block;
}
