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

html {
    height: 100%;
    position: relative;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* Фикс для Firefox */
@-moz-document url-prefix() {
    html, body {
        height: 100vh;
        height: -moz-available;
        height: stretch;
    }
    .container {
        height: 100vh;
        height: -moz-available;
        height: stretch;
    }
}

.container {
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========== СТИЛИ ДЛЯ ЛОГИНА ========== */
.login-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card h2 {
    margin-bottom: 10px;
    color: #333;
    font-size: 28px;
}

.login-card .subtitle {
    color: #666;
    margin-bottom: 30px;
    font-size: 14px;
}

.login-card input {
    width: 100%;
    padding: 14px;
    margin-bottom: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.login-card input:focus {
    outline: none;
    border-color: #667eea;
}

.login-card button {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
    margin-top: 10px;
}

.login-card button:hover {
    transform: translateY(-2px);
}

.error-message {
    color: #e74c3c;
    margin-top: 15px;
    font-size: 14px;
}

.register-link {
    margin-top: 20px;
    font-size: 14px;
    color: #667eea;
    cursor: pointer;
}

.register-link:hover {
    text-decoration: underline;
}

/* ========== СТИЛИ ДЛЯ ЧАТА ========== */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    min-height: 0;
}

/* Верхняя панель */
.top-bar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.logo {
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo span {
    font-size: 24px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.15);
    padding: 6px 12px;
    border-radius: 30px;
    cursor: pointer;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: white;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
}

/* Строка с селектором чата и кнопкой настроек */
.space-selector-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    padding: 8px 16px;
    flex-shrink: 0;
}

.space-selector {
    flex: 1;
    background: transparent;
    border-bottom: none;
    padding: 0;
}

.current-space {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.current-space:active {
    background: #e8e9ea;
}

.space-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.space-icon {
    font-size: 20px;
}

.space-name {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.space-count {
    font-size: 12px;
    color: #999;
    margin-left: 8px;
}

.dropdown-icon {
    font-size: 18px;
    color: #999;
}

.spaces-dropdown {
    display: none;
    background: white;
    border-radius: 12px;
    margin-top: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-height: 300px;
    overflow-y: auto;
}

.spaces-dropdown.show {
    display: block;
}

.space-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
}

.space-option:active {
    background: #f5f5f5;
}

.space-option.active {
    background: linear-gradient(135deg, rgba(102,126,234,0.1) 0%, rgba(118,75,162,0.1) 100%);
    border-left: 3px solid #667eea;
}

.space-option-name {
    font-size: 14px;
    color: #333;
}

.space-option-members {
    font-size: 12px;
    color: #999;
}

.empty-spaces {
    text-align: center;
    padding: 20px;
    color: #999;
}

.space-settings-btn {
    background: #f0f0f0;
    border: none;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.space-settings-btn:hover {
    background: #e0e0e0;
}

.space-settings-btn:active {
    transform: scale(0.95);
}

/* Область сообщений */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}

.message {
    display: flex;
    animation: slideIn 0.3s ease;
}

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

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

.message-content {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
}

.user1 .message-content {
    background: white;
    border: 1px solid #e0e0e0;
}

.user2 .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message-header {
    font-size: 11px;
    margin-bottom: 4px;
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: 6px;
}

.message-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
    transition: transform 0.2s;
}

.message-avatar:active {
    transform: scale(0.95);
}

.user2 .message-header {
    justify-content: flex-end;
}

.message-text {
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message-photo {
    margin-top: 6px;
    max-width: 200px;
    max-height: 200px;
    border-radius: 10px;
    cursor: pointer;
}

.message-time {
    font-size: 9px;
    margin-top: 4px;
    opacity: 0.5;
    text-align: right;
}

/* Стили для ответа */
.reply-preview {
    background: rgba(0, 0, 0, 0.05);
    border-left: 3px solid #667eea;
    padding: 6px 10px;
    margin-bottom: 6px;
    border-radius: 8px;
    font-size: 12px;
}

.user2 .reply-preview {
    background: rgba(255, 255, 255, 0.2);
    border-left-color: white;
}

.reply-header {
    font-size: 11px;
    opacity: 0.7;
    margin-bottom: 2px;
}

.reply-text {
    font-size: 11px;
    opacity: 0.8;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Блок предпросмотра ответа в области ввода */
.reply-preview-container {
    background: #f0f0f0;
    border-radius: 12px;
    margin-bottom: 8px;
    padding: 8px 12px;
    border-left: 3px solid #667eea;
}

.reply-preview-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.reply-preview-text {
    flex: 1;
    font-size: 12px;
    color: #666;
    word-break: break-word;
}

.reply-preview-text strong {
    color: #667eea;
}

.cancel-reply-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #999;
    padding: 0 4px;
    transition: color 0.2s;
}

.cancel-reply-btn:hover {
    color: #e74c3c;
}

.loading-messages {
    text-align: center;
    color: #999;
    padding: 20px;
}

.loading-indicator {
    text-align: center;
    color: #999;
    padding: 20px;
    font-size: 14px;
}

/* ========== ОБЛАСТЬ ВВОДА ========== */
.input-area {
    background: white;
    border-top: 1px solid #e0e0e0;
    padding: 12px;
    flex-shrink: 0;
}

.message-input-wrapper {
    margin-bottom: 10px;
}

.message-input-wrapper textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.4;
    resize: none;
    background: #f8f9fa;
    transition: all 0.2s ease;
}

.message-input-wrapper textarea:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.message-input-wrapper textarea::placeholder {
    color: #999;
    font-weight: 400;
}

.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}


.emoji-toggle-btn {
    background: #f0f0f0;
    border: none;
    width: 48px;
    min-width: 48px;
    height: 48px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.emoji-toggle-btn:active {
    background: #e0e0e0;
    transform: scale(0.98);
}

.emoji-picker {
    display: none;
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 10px;
    margin-top: 8px;
}

.emoji-picker.show {
    display: block;
}

.emoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 8px;
}

.emoji-picker-btn {
    border: none;
    background: white;
    border-radius: 12px;
    min-height: 40px;
    font-size: 22px;
    cursor: pointer;
}

.emoji-picker-btn:active {
    transform: scale(0.96);
}

.photo-label {
    background: #f0f0f0;
    padding: 12px 20px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s ease;
    flex: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #666;
}

.photo-label:active {
    background: #e0e0e0;
    transform: scale(0.98);
}

.send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    flex: 8;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.send-btn:active {
    transform: scale(0.98);
}

.send-btn:disabled {
    opacity: 0.6;
    transform: none;
    cursor: not-allowed;
}

.photo-preview {
    margin-top: 10px;
    position: relative;
    display: inline-block;
}

.photo-preview img {
    max-width: 60px;
    max-height: 60px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

.photo-preview button {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.photo-preview button:active {
    transform: scale(0.9);
}

/* Прогресс бар для оптимизации */
.optimize-progress {
    background: #e0e0e0;
    border-radius: 20px;
    height: 4px;
    overflow: hidden;
    margin-top: 8px;
    width: 100%;
}

.optimize-progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: width 0.2s ease;
}

.optimize-text {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    text-align: center;
}

/* Action Sheet стили */
.action-sheet-overlay {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.action-sheet-overlay.show {
    display: block;
}

.action-sheet {
    display: none;
    position: fixed;
    z-index: 1001;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    border-radius: 24px 24px 0 0;
    animation: slideUp 0.3s ease;
}

.action-sheet.show {
    display: block;
}

.action-sheet-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 600;
    color: #333;
}

.action-sheet-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
}

.action-sheet-item:active {
    background: #f5f5f5;
}

.action-sheet-item.danger {
    color: #e74c3c;
}

.action-sheet-item-icon {
    font-size: 24px;
    width: 32px;
}

.action-sheet-item-label {
    font-size: 16px;
}

.action-sheet-cancel {
    padding: 16px;
    text-align: center;
    color: #666;
    cursor: pointer;
    font-weight: 500;
    border-top: 1px solid #f0f0f0;
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}

.modal .modal-content {
    background: white;
    padding: 24px;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal .modal-content-center {
    text-align: center;
}

.modal .modal-content h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 20px;
}

.modal .modal-content input,
.modal .modal-content textarea {
    width: 100%;
    padding: 14px;
    margin: 10px 0;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
}

.modal .modal-content button {
    width: 100%;
    padding: 14px;
    margin-top: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.modal .modal-content button.secondary {
    background: #e0e0e0;
    color: #333;
}

.invite-link {
    background: #f0f0f0;
    padding: 12px;
    border-radius: 12px;
    font-size: 12px;
    word-break: break-all;
    margin: 12px 0;
}

.member-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 15px 0;
}

.member-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #eee;
}

.member-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    margin-right: 12px;
    background-size: cover;
    background-position: center;
}

.member-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.remove-member {
    color: #e74c3c;
    cursor: pointer;
    font-size: 12px;
    padding: 6px 12px;
    background: #fee;
    border-radius: 20px;
}

.admin-badge {
    background: #ffd700;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: bold;
}

.member-item-actions {
    display: flex;
    gap: 8px;
}

.make-admin-btn {
    background: #f0f0f0;
    border: none;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    cursor: pointer;
    color: #667eea;
}

.remove-admin-btn {
    background: #f0f0f0;
    border: none;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    cursor: pointer;
    color: #e74c3c;
}

.space-edit-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    margin: 10px 0;
}

.space-edit-textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    margin: 10px 0;
    resize: vertical;
}

/* Стили для профиля */
.profile-avatar-large {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 20px;
    display: block;
}

.profile-avatar-placeholder {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 48px;
    color: white;
}

.avatar-upload-btn {
    text-align: center;
    margin-top: 10px;
    margin-bottom: 20px;
}

.avatar-upload-btn label {
    background: #f0f0f0;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
}

.gender-select {
    display: flex;
    gap: 20px;
    margin: 10px 0;
}

.gender-select label {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    cursor: pointer;
}

.profile-info {
    margin: 15px 0;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 12px;
}

.profile-field {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.profile-field:last-child {
    border-bottom: none;
}

.profile-label {
    color: #666;
    font-weight: 500;
}

.profile-value {
    color: #333;
}

.edit-profile-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    margin-top: 15px;
    width: 100%;
}

/* Стили для модального окна профиля пользователя */
.user-profile-modal {
    display: none;
    position: fixed;
    z-index: 1100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}

.user-profile-modal .modal-content {
    background: white;
    padding: 30px;
    border-radius: 28px;
    width: 85%;
    max-width: 320px;
    text-align: center;
    animation: slideUp 0.3s ease;
}

.user-profile-modal .user-avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 16px;
    display: block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.user-profile-modal .user-avatar-placeholder {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 56px;
    color: white;
}

.user-profile-modal .user-name-large {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.user-profile-modal .user-gender {
    font-size: 16px;
    color: #666;
    margin-bottom: 24px;
    padding: 8px 16px;
    background: #f5f5f5;
    border-radius: 20px;
    display: inline-block;
}

.user-profile-modal .close-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin-top: 16px;
}

.user-profile-modal .close-btn:active {
    transform: scale(0.98);
}

/* Анимации */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.message {
    animation: slideIn 0.3s ease;
}

/* Стили для выделения сообщения при долгом нажатии */
.message {
    transition: background 0.2s ease;
}

.message:active {
    background: rgba(102, 126, 234, 0.1);
}

/* Стили для Action Sheet сообщения */
#messageActionSheet .action-sheet-item.danger {
    color: #e74c3c;
}

/* Стили для скроллбара */
.messages-area::-webkit-scrollbar {
    width: 4px;
}

.messages-area::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.messages-area::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 2px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ========== МОБИЛЬНАЯ АДАПТАЦИЯ ========== */
@media (max-width: 768px) {
    html, body {
        height: 100%;
        overflow: hidden;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
    }

    body {
        padding: 0;
    }

    .container {
        height: 100%;
        position: relative;
        overflow: hidden;
    }

    .chat-container {
        height: 100%;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .top-bar {
        padding: 10px 12px;
        padding-top: max(10px, env(safe-area-inset-top));
        min-height: 56px;
    }

    .logo {
        font-size: 18px;
    }

    .logo span {
        font-size: 20px;
    }

    .user-profile {
        padding: 5px 8px;
        gap: 6px;
    }

    .user-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .user-name {
        font-size: 13px;
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .space-selector-row {
        padding: 6px 12px;
        gap: 8px;
    }

    .current-space {
        padding: 10px 14px;
    }

    .space-name {
        font-size: 14px;
    }

    .space-icon {
        font-size: 18px;
    }

    .space-count {
        font-size: 11px;
    }

    .dropdown-icon {
        font-size: 16px;
    }

    .space-settings-btn {
        width: 44px;
        height: 44px;
        font-size: 18px;
        border-radius: 10px;
    }

    .messages-area {
        padding: 12px;
        gap: 10px;
    }

    .message-content {
        max-width: 85%;
        padding: 8px 12px;
    }

    .message-header {
        font-size: 10px;
    }

    .message-avatar {
        width: 18px;
        height: 18px;
        font-size: 9px;
    }

    .message-text {
        font-size: 13px;
    }

    .message-photo {
        max-width: 150px;
        max-height: 150px;
    }

    .message-time {
        font-size: 8px;
    }

    .reply-preview {
        padding: 4px 8px;
        font-size: 10px;
    }

    .reply-header {
        font-size: 9px;
    }

    .reply-text {
        font-size: 9px;
    }

    .reply-preview-container {
        padding: 6px 10px;
    }

    .reply-preview-text {
        font-size: 11px;
    }

    /* Область ввода - мобильная версия */
    .input-area {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .message-input-wrapper {
        margin-bottom: 8px;
    }

    .message-input-wrapper textarea {
        padding: 12px 16px;
        font-size: 16px;
        min-height: 44px;
        border-radius: 12px;
    }

    .action-buttons {
        gap: 10px;
        margin-top: 8px;
    }

    .emoji-toggle-btn {
        width: 48px;
        min-width: 48px;
        min-height: 48px;
        border-radius: 14px;
    }

    .emoji-picker-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .photo-label {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 48px;
        border-radius: 14px;
    }

    .send-btn {
        padding: 10px 16px;
        font-size: 14px;
        min-height: 48px;
        border-radius: 14px;
    }

    .modal .modal-content {
        padding: 20px;
        width: 95%;
    }

    .login-card {
        padding: 30px 20px;
        margin: 20px;
    }

    .login-card h2 {
        font-size: 24px;
    }

    .login-card input {
        padding: 12px;
        font-size: 15px;
    }

    .user-profile-modal .modal-content {
        padding: 24px;
        width: 90%;
    }

    .user-profile-modal .user-avatar-large,
    .user-profile-modal .user-avatar-placeholder {
        width: 100px;
        height: 100px;
        font-size: 48px;
    }

    .user-profile-modal .user-name-large {
        font-size: 20px;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 480px) {
    .top-bar {
        padding: 6px 10px;
        padding-top: max(6px, env(safe-area-inset-top));
        min-height: 48px;
    }

    .logo {
        font-size: 16px;
    }

    .logo span {
        font-size: 18px;
    }

    .user-profile {
        padding: 3px 8px;
    }

    .user-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .user-name {
        font-size: 12px;
        max-width: 80px;
    }

    .space-selector-row {
        padding: 4px 10px;
        gap: 6px;
    }

    .current-space {
        padding: 8px 12px;
    }

    .space-name {
        font-size: 13px;
    }

    .space-icon {
        font-size: 16px;
    }

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

    .space-settings-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
        border-radius: 8px;
    }

    .messages-area {
        padding: 8px;
        gap: 8px;
    }

    .message-content {
        padding: 6px 10px;
    }

    .message-text {
        font-size: 12px;
    }

    .input-area {
        padding: 8px 10px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    .message-input-wrapper textarea {
        padding: 10px 14px;
        font-size: 15px;
        min-height: 40px;
        border-radius: 22px;
    }

    .action-buttons {
        gap: 8px;
    }

    .emoji-toggle-btn {
        width: 44px;
        min-width: 44px;
        min-height: 44px;
        border-radius: 12px;
        font-size: 20px;
    }

    .emoji-picker-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .photo-label {
        padding: 8px 12px;
        font-size: 13px;
        min-height: 44px;
        border-radius: 12px;
    }

    .send-btn {
        padding: 8px 12px;
        font-size: 13px;
        min-height: 44px;
        border-radius: 12px;
    }

    .user-profile-modal .modal-content {
        padding: 20px;
    }

    .user-profile-modal .user-avatar-large,
    .user-profile-modal .user-avatar-placeholder {
        width: 80px;
        height: 80px;
        font-size: 40px;
    }

    .user-profile-modal .user-name-large {
        font-size: 18px;
    }
}

/* Для устройств с вырезом (notch) */
@supports (padding: max(0px)) {
    .top-bar {
        padding-top: max(10px, env(safe-area-inset-top));
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    @media (max-width: 480px) {
        .top-bar {
            padding-top: max(6px, env(safe-area-inset-top));
        }
    }

    .space-selector-row {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    @media (max-width: 480px) {
        .space-selector-row {
            padding-left: max(10px, env(safe-area-inset-left));
            padding-right: max(10px, env(safe-area-inset-right));
        }
    }

    .messages-area {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    @media (max-width: 480px) {
        .messages-area {
            padding-left: max(8px, env(safe-area-inset-left));
            padding-right: max(8px, env(safe-area-inset-right));
        }
    }

    .input-area {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    @media (max-width: 480px) {
        .input-area {
            padding-bottom: max(8px, env(safe-area-inset-bottom));
            padding-left: max(10px, env(safe-area-inset-left));
            padding-right: max(10px, env(safe-area-inset-right));
        }
    }
}

/* Фикс для Firefox на мобильных */
@-moz-document url-prefix() {
    .messages-area, .spaces-dropdown, .member-list {
        scrollbar-width: thin;
    }

    .current-space:active {
        background: #e8e9ea;
    }

    .space-option:active {
        background: #f5f5f5;
    }

    .action-sheet-item:active {
        background: #f5f5f5;
    }

    .photo-label:active {
        background: #e0e0e0;
        transform: scale(0.98);
    }

    .send-btn:active {
        transform: scale(0.98);
    }
}

/* Стили для ответов - усилены для мобильных */
.reply-preview {
    background: rgba(0, 0, 0, 0.08);
    border-left: 3px solid #667eea;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 10px;
    font-size: 12px;
    word-break: break-word;
}

.user2 .reply-preview {
    background: rgba(255, 255, 255, 0.25);
    border-left-color: rgba(255, 255, 255, 0.8);
}

.reply-header {
    font-size: 11px;
    opacity: 0.8;
    margin-bottom: 4px;
    font-weight: 500;
}

.reply-text {
    font-size: 11px;
    opacity: 0.9;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.4;
}

/* Блок предпросмотра ответа в области ввода */
.reply-preview-container {
    background: #f5f5f5;
    border-radius: 12px;
    margin-bottom: 10px;
    padding: 10px 12px;
    border-left: 4px solid #667eea;
}

.reply-preview-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.reply-preview-text {
    flex: 1;
    font-size: 13px;
    color: #555;
    word-break: break-word;
    line-height: 1.4;
}

.reply-preview-text strong {
    color: #667eea;
    font-weight: 600;
}

.cancel-reply-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
    padding: 0 6px;
    transition: color 0.2s;
    flex-shrink: 0;
}

.cancel-reply-btn:hover,
.cancel-reply-btn:active {
    color: #e74c3c;
}

/* Стили для выделения сообщения при долгом нажатии */
.message {
    transition: background 0.2s ease;
    -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
}

.message:active {
    background: rgba(102, 126, 234, 0.1);
}

/* Мобильная адаптация для ответов */
@media (max-width: 768px) {
    .reply-preview {
        padding: 6px 10px;
        font-size: 11px;
    }

    .reply-header {
        font-size: 10px;
    }

    .reply-text {
        font-size: 10px;
    }

    .reply-preview-container {
        padding: 8px 10px;
        margin-bottom: 8px;
    }

    .reply-preview-text {
        font-size: 12px;
    }

    .cancel-reply-btn {
        font-size: 18px;
        padding: 0 4px;
    }
}

@media (max-width: 480px) {
    .reply-preview {
        padding: 5px 8px;
        font-size: 10px;
    }

    .reply-header {
        font-size: 9px;
    }

    .reply-text {
        font-size: 9px;
    }

    .reply-preview-container {
        padding: 6px 8px;
    }

    .reply-preview-text {
        font-size: 11px;
    }
}

/* Стили для полноэкранного просмотра аватара */
.avatar-fullscreen-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.avatar-fullscreen-modal.show {
    display: flex;
}

.avatar-fullscreen-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    text-align: center;
}

.avatar-fullscreen-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

.avatar-fullscreen-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s;
    z-index: 2001;
    background: rgba(0, 0, 0, 0.5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.avatar-fullscreen-close:hover {
    transform: scale(1.1);
}

@media (max-width: 768px) {
    .avatar-fullscreen-close {
        top: 20px;
        right: 20px;
        background: rgba(0, 0, 0, 0.7);
        font-size: 30px;
        width: 40px;
        height: 40px;
    }

    .avatar-fullscreen-content img {
        max-height: 85vh;
    }
}

/* Уведомление об обновлении PWA */
.update-notification {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    animation: slideUp 0.3s ease;
}

.update-notification button {
    background: white;
    color: #667eea;
    border: none;
    padding: 8px 20px;
    border-radius: 30px;
    font-weight: bold;
    cursor: pointer;
    margin-left: 15px;
    font-size: 14px;
    transition: transform 0.2s;
}

.update-notification button:active {
    transform: scale(0.95);
}

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

@media (max-width: 480px) {
    .update-notification {
        left: 10px;
        right: 10px;
        border-radius: 15px;
        padding: 10px 15px;
        font-size: 12px;
    }

    .update-notification button {
        padding: 6px 15px;
        font-size: 12px;
    }
}
/* ===== Entry flow / landing / versions ===== */
.auth-screen {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

.screen-version {
    margin-top: 14px;
    text-align: center;
    font-size: 12px;
    color: #8a8f9c;
}

.landing-screen {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.landing-card {
    width: 100%;
    max-width: 520px;
    background: rgba(255,255,255,0.96);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(67, 79, 136, 0.15);
    padding: 28px 22px 22px;
}

.landing-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.landing-logo {
    width: 64px;
    height: 64px;
    border-radius: 18px;
}

.landing-title {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.1;
}

.landing-subtitle {
    color: #666;
    margin-top: 4px;
}

.landing-content h1 {
    font-size: 26px;
    line-height: 1.2;
    margin: 0 0 12px;
    color: #20253a;
}

.landing-content p {
    margin: 0;
    color: #50566b;
    line-height: 1.55;
}

.landing-features {
    display: grid;
    gap: 10px;
    margin: 20px 0 24px;
}

.landing-feature {
    background: #f5f7ff;
    border: 1px solid #e7ebff;
    border-radius: 16px;
    padding: 13px 14px;
    color: #2e3551;
}

.landing-actions {
    display: grid;
    gap: 12px;
}

.primary-action-btn,
.secondary-action-btn {
    border: none;
    border-radius: 16px;
    padding: 15px 18px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.primary-action-btn {
    color: #fff;
    background: linear-gradient(135deg, #0a38b8 0%, #b119f3 100%);
}

.secondary-action-btn {
    background: #eef1f8;
    color: #2f3650;
}

.install-hint {
    min-height: 20px;
    font-size: 13px;
    text-align: center;
    color: #6a7288;
}

.landing-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    justify-content: center;
    margin-top: 24px;
}

.landing-links a {
    color: #667eea;
    text-decoration: none;
    font-size: 13px;
}

/* ===== Chat list / chat view ===== */
.chat-list-screen,
.chat-view-screen {
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-list-header {
    padding: 18px 16px 10px;
}

.chat-list-title {
    font-size: 24px;
    font-weight: 700;
    color: #20253a;
}

.chat-list-subtitle {
    margin-top: 4px;
    font-size: 14px;
    color: #7a8092;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px 16px;
}

.chat-list-item {
    width: 100%;
    border: 1px solid #e7eaf4;
    background: #fff;
    border-radius: 18px;
    padding: 14px 14px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    text-align: left;
}

.chat-list-item:active {
    transform: scale(0.995);
}

.chat-list-item-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(10,56,184,0.12) 0%, rgba(177,25,243,0.12) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.chat-list-item-body {
    min-width: 0;
    flex: 1;
}

.chat-list-item-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2437;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-list-item-meta {
    margin-top: 4px;
    font-size: 13px;
    color: #7b8192;
}

.chat-list-footer {
    padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
    border-top: 1px solid #edf0f7;
    background: #fff;
}

.create-chat-btn {
    width: 100%;
    border: none;
    border-radius: 16px;
    padding: 15px 18px;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    background: linear-gradient(135deg, #0a38b8 0%, #b119f3 100%);
    cursor: pointer;
}

.chat-view-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #edf0f7;
    background: #fff;
}

.back-to-list-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: #eff2f8;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #2f3650;
    flex-shrink: 0;
}

.chat-view-title-wrap {
    min-width: 0;
    flex: 1;
}

.chat-view-title {
    font-size: 17px;
    font-weight: 700;
    color: #1f2437;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-view-meta {
    margin-top: 2px;
    font-size: 12px;
    color: #7b8192;
}

.empty-chat-list {
    padding: 24px 16px;
    text-align: center;
    color: #7b8192;
}

@media (max-width: 768px) {
    .landing-card {
        border-radius: 22px;
        padding: 22px 18px 18px;
    }

    .landing-content h1 {
        font-size: 22px;
    }

    .chat-list-title {
        font-size: 22px;
    }
}


/* ===== Zeer 2.3.2 full overrides ===== */
:root {
    --bg-main: #f5f7fb;
    --bg-panel: #ffffff;
    --bg-soft: #eef2f8;
    --text-main: #20253a;
    --text-muted: #697082;
    --border-soft: #dfe5f0;
    --bubble-self-start: #667eea;
    --bubble-self-end: #764ba2;
    --bubble-other: #ffffff;
}

:root[data-theme="dark"] {
    --bg-main: #0f1524;
    --bg-panel: #161d2f;
    --bg-soft: #1e2940;
    --text-main: #edf1fb;
    --text-muted: #9aa5bd;
    --border-soft: #2a3550;
    --bubble-self-start: #5e72eb;
    --bubble-self-end: #7b4db8;
    --bubble-other: #1b2336;
}

body, .chat-container, .chat-list-screen, .chat-view-screen, .messages-area, .input-area, .top-bar, .chat-view-header, .chat-list-header, .chat-list, .chat-list-item, .modal .modal-content, .action-sheet {
    background-color: var(--bg-main);
    color: var(--text-main);
}

.top-bar, .chat-view-header, .input-area, .modal .modal-content, .chat-list-item, .action-sheet {
    background: var(--bg-panel) !important;
    color: var(--text-main);
    border-color: var(--border-soft) !important;
}

.messages-area {
    background-color: var(--bg-main) !important;
}

.message {
    align-items: flex-start;
    gap: 10px;
    width: 100%;
}

.message.user2 {
    flex-direction: row-reverse;
}

.message-avatar-outer {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(34,42,68,.12);
}

.message-content {
    max-width: min(78%, 720px);
    padding: 10px 14px 8px;
    border-radius: 22px;
    box-shadow: 0 8px 24px rgba(27,39,73,.08);
}

.user1 .message-content {
    background: var(--bubble-other) !important;
    color: var(--text-main);
    border: 1px solid var(--border-soft);
}

.user2 .message-content {
    background: linear-gradient(135deg, var(--bubble-self-start) 0%, var(--bubble-self-end) 100%) !important;
    color: #fff;
}

.message-header {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
    opacity: .85;
}

.message-author {
    font-weight: 700;
}

.user2 .message-header {
    justify-content: flex-end;
}

.message-text {
    font-size: 15px !important;
    line-height: 1.48;
    word-break: break-word;
}

.message-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.message-photo-wrap {
    margin-top: 8px;
}

.message-photo.message-photo-full {
    width: min(100%, 420px);
    max-width: 420px;
    max-height: 70vh;
    object-fit: cover;
    border-radius: 16px;
    display: block;
}

.message-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    align-items: center;
    margin-top: 6px;
}

.message-time,
.message-edited {
    font-size: 10px;
    opacity: .72;
}

.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.message-reaction-pill {
    border: 1px solid rgba(255,255,255,.25);
    background: rgba(255,255,255,.18);
    color: inherit;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.user1 .message-reaction-pill {
    background: var(--bg-soft);
    border-color: var(--border-soft);
    color: var(--text-main);
}

.selected-space-avatar {
    margin-right: 10px;
}

.selected-space-avatar .space-avatar-chip,
.chat-list-item .space-avatar-chip,
.space-option .space-avatar-chip {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-weight: 700;
    background-size: cover;
    background-position: center;
}

.selected-space-avatar .space-avatar-chip {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 12px;
}

.space-option {
    display: flex;
    align-items: center;
    gap: 10px;
}

.space-option-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.space-option-top,
.chat-list-item-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.space-option-name,
.chat-list-item-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.space-option-last-message {
    margin-top: 4px;
    font-size: 12px;
    color: #7b8192;
}

.space-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.member-item.compact {
    border-bottom: 1px solid var(--border-soft);
    gap: 12px;
}

.member-meta {
    min-width: 0;
}

.member-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.member-username {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 2px;
}

.member-menu-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border-soft);
    background: var(--bg-soft);
    color: var(--text-main);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.owner-badge {
    background: #ffdb78;
}

.space-extra-settings {
    display: grid;
    gap: 14px;
    margin: 14px 0 18px;
}

.space-setting-group {
    display: grid;
    gap: 8px;
}

.space-setting-label {
    font-size: 13px;
    font-weight: 700;
}

.space-setting-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.space-setting-hint,
.space-setting-status {
    font-size: 12px;
    color: var(--text-muted);
}

.photo-modal-fullscreen {
    position: fixed;
    inset: 0;
    background: rgba(7,10,18,.94);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.photo-modal-fullscreen.show {
    display: flex;
}

.photo-modal-stage {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.photo-modal-stage img {
    max-width: min(100vw - 16px, 1400px);
    max-height: min(100vh - 16px, 96vh);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 14px;
}

.photo-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,.16);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
}

.avatar-like-btn,
.avatar-like-info {
    margin-top: 12px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-soft);
    color: var(--text-main);
    border: 1px solid var(--border-soft);
}

.avatar-like-btn.liked {
    background: #ffe8ee;
}

.user-profile-avatar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.user-meta-row {
    color: var(--text-muted);
    margin-top: 6px;
    text-align: center;
}

@media (max-width: 768px) {
    .messages-area {
        padding: 12px 10px !important;
    }

    .message {
        gap: 8px;
    }

    .message-avatar-outer {
        width: 38px;
        height: 38px;
        min-width: 38px;
        font-size: 12px;
    }

    .message-content {
        max-width: 82%;
        padding: 10px 13px 8px;
    }

    .message-text {
        font-size: 16px !important;
    }

    .message-photo.message-photo-full {
        width: min(100%, 82vw);
        max-width: 82vw;
        max-height: 58vh;
    }
}

@media (max-width: 480px) {
    .message-content {
        max-width: 84%;
    }

    .message-avatar-outer {
        width: 34px;
        height: 34px;
        min-width: 34px;
        border-radius: 50%;
    }

    .message-text {
        font-size: 16px !important;
    }

    .chat-view-header {
        gap: 8px;
    }
}

/* ===== hotfix 2.3.2 step 1 ===== */
.top-bar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: #fff !important;
    border-bottom: none !important;
}

.top-bar .user-profile {
    background: rgba(255,255,255,0.16);
    color: #fff;
}

.chat-view-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-view-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.chat-view-title-block {
    min-width: 0;
    flex: 1;
}

.selected-space-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0;
    flex-shrink: 0;
}

.message.user1 {
    justify-content: flex-start !important;
}

.message.user2 {
    flex-direction: row-reverse;
    justify-content: flex-start !important;
}

.message.user1 .message-content,
.message.user2 .message-content {
    margin: 0;
}

.message.user1 .message-avatar-outer {
    order: 0;
}

.message.user2 .message-avatar-outer {
    order: 0;
}

.message.user1 .message-content {
    order: 1;
}

.message.user2 .message-content {
    order: 1;
}

.message-avatar-outer {
    align-self: flex-start;
}

@media (max-width: 768px) {
    .chat-view-title-wrap {
        gap: 8px;
    }

    .selected-space-avatar .space-avatar-chip {
        width: 34px;
        height: 34px;
        min-width: 34px;
        border-radius: 11px;
    }
}


/* ===== hotfix 2.3.2 step 2 ===== */
.reaction-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 19, 34, 0.42);
    backdrop-filter: blur(4px);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 10020;
    padding: 16px;
}

.reaction-picker-overlay.show {
    display: flex;
}

.reaction-picker-sheet {
    width: min(100%, 420px);
    background: var(--bg-card, #fff);
    color: var(--text-main, #1e2430);
    border-radius: 22px;
    box-shadow: 0 18px 50px rgba(17, 24, 39, 0.22);
    padding: 16px;
    border: 1px solid var(--border-soft, rgba(0,0,0,.08));
}

.reaction-picker-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
}

.reaction-picker-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
}

.reaction-picker-btn {
    height: 48px;
    border-radius: 14px;
    border: 1px solid var(--border-soft, rgba(0,0,0,.08));
    background: var(--bg-soft, #f6f7fb);
    font-size: 24px;
    cursor: pointer;
}

.reaction-picker-close {
    margin-top: 12px;
    width: 100%;
    border: none;
    border-radius: 14px;
    padding: 12px;
    background: var(--bg-soft, #f6f7fb);
    color: var(--text-main, #1e2430);
    font-weight: 600;
    cursor: pointer;
}

.message-reaction-quickbar {
    display: flex;
    gap: 10px;
    padding: 14px 18px 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.message-reaction-quick-btn {
    border: 1px solid var(--border-soft);
    background: var(--bg-soft);
    border-radius: 18px;
    min-width: 46px;
    height: 42px;
    font-size: 24px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 auto;
}

.message-reaction-quick-btn:active {
    transform: scale(0.96);
}


.message-avatar-outer.is-self {
    cursor: default;
    pointer-events: none;
}

.message-avatar-outer.is-clickable {
    cursor: pointer;
}

.member-actions-trigger {
    border: 1px solid #d9dce5;
    background: #f5f6f8;
    color: #5f6675;
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.member-actions-trigger:active {
    transform: scale(0.98);
}

.member-actions-modal-content {
    max-width: 360px;
}

.member-actions-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 12px 0 6px;
}

.member-action-btn {
    width: 100%;
    border: 1px solid #e0e4ec;
    background: #f7f8fb;
    color: #2f3640;
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
}

.member-action-btn:active {
    transform: scale(0.99);
}

.member-action-empty {
    text-align: center;
    color: #7d8595;
    padding: 8px 0 12px;
}

@media (max-width: 768px) {
    .member-actions-trigger {
        padding: 8px 10px;
        font-size: 11px;
    }
}

/* ===== Zeer 2.3.8 ===== */
.selected-space-avatar.is-clickable,
.selected-space-avatar.is-clickable .space-avatar-chip {
    cursor: pointer;
}

.invite-links-create-panel,
.invite-links-list-wrap {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.invite-link-type-buttons,
.invite-link-actions,
.invite-custom-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.invite-custom-row input {
    flex: 1;
    min-width: 180px;
}

.invite-links-list {
    display: grid;
    gap: 10px;
}

.invite-link-item {
    border: 1px solid #e8e8ef;
    border-radius: 16px;
    padding: 12px;
    background: #fafbff;
}

.invite-link-meta {
    font-size: 12px;
    color: #666;
    margin-top: 8px;
}

.invite-link-action-btn {
    width: auto !important;
    margin-top: 0 !important;
    padding: 10px 14px !important;
}

.invite-link-delete-btn {
    color: #e74c3c !important;
}

.invite-type-btn {
    width: auto !important;
    margin-top: 0 !important;
}


/* ===== Zeer 2.3.11 ===== */
.pinned-message-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    margin: 0 12px 10px;
    background: rgba(255,255,255,0.88);
    border: 1px solid rgba(102,126,234,0.14);
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(30, 41, 59, 0.08);
}

.pinned-message-main {
    min-width: 0;
    flex: 1;
    cursor: pointer;
}

.pinned-message-kicker {
    font-size: 11px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 3px;
    letter-spacing: 0.02em;
}

.pinned-message-line {
    min-width: 0;
    color: #40485b;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pinned-message-unpin {
    width: auto !important;
    margin-top: 0 !important;
    padding: 8px 12px !important;
    border-radius: 999px !important;
    background: #f4f6fb !important;
    color: #55607a !important;
    font-size: 12px !important;
    border: 1px solid #dfe5f0 !important;
}

.message-pulse .message-content {
    box-shadow: 0 0 0 3px rgba(102,126,234,0.16), 0 8px 24px rgba(27,39,73,.08);
}

.space-extra-settings-v2311 {
    gap: 18px;
}

.space-visual-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.space-avatar-live-preview {
    width: 62px;
    height: 62px;
    min-width: 62px;
    border-radius: 18px;
    border: 1px solid #dfe5f0;
    color: #fff;
    font-size: 24px;
    font-weight: 700;
    background-size: cover !important;
    background-position: center !important;
    box-shadow: 0 8px 18px rgba(51,65,85,0.10);
}

.space-visual-side {
    min-width: 0;
    flex: 1;
    display: grid;
    gap: 10px;
}

.space-color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.space-color-dot {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 2px solid transparent;
    box-shadow: 0 0 0 1px rgba(31,36,55,0.08);
    cursor: pointer;
}

.space-color-dot.active {
    border-color: #fff;
    box-shadow: 0 0 0 2px #667eea;
}

.space-inline-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.space-inline-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: #667eea;
    font-size: 13px;
    padding: 0;
    cursor: pointer;
    text-decoration: none;
}

.space-inline-link.danger {
    color: #d05b74;
}

.space-background-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.space-bg-preset {
    padding: 0;
    border: 2px solid transparent;
    border-radius: 16px;
    background: transparent;
    cursor: pointer;
    overflow: hidden;
}

.space-bg-preset.active {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.12);
}

.space-bg-preset-thumb {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    background-size: cover;
    background-position: center;
    border-radius: 14px;
}

@media (max-width: 768px) {
    .pinned-message-bar {
        margin: 0 10px 8px;
        padding: 9px 12px;
    }

    .space-background-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.space-extra-settings-v2311,
.space-extra-settings-v2311 * {
    box-sizing: border-box;
}

.space-extra-settings-v2311 {
    width: 100%;
    max-width: 100%;
    overflow: visible;
}

.space-setting-group {
    min-width: 0;
}

.space-compact-picker {
    position: relative;
    width: fit-content;
    max-width: 100%;
}

.space-picker-popover {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 30;
    display: none;
    width: min(260px, calc(100vw - 64px));
    max-width: calc(100vw - 64px);
    padding: 12px;
    border-radius: 16px;
    border: 1px solid #dfe5f0;
    background: #fff;
    box-shadow: 0 16px 36px rgba(17, 24, 39, 0.14);
}

.space-picker-popover.wide {
    width: min(320px, calc(100vw - 64px));
}

.space-picker-popover.open {
    display: block;
}

.space-avatar-live-preview,
.space-bg-live-trigger {
    cursor: pointer;
}

.space-bg-live-trigger {
    width: 62px;
    height: 62px;
    padding: 0;
    border-radius: 18px;
    border: 1px solid #dfe5f0;
    background: #f7f8fc;
    box-shadow: 0 8px 18px rgba(51,65,85,0.10);
    overflow: hidden;
}

.space-bg-live-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #667085;
    font-size: 13px;
    background-size: cover;
    background-position: center;
}

.space-inline-actions.compact {
    margin-top: 10px;
    justify-content: space-between;
    gap: 10px;
}

.space-background-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 768px) {
    .space-picker-popover,
    .space-picker-popover.wide {
        width: min(280px, calc(100vw - 48px));
        max-width: calc(100vw - 48px);
    }

    .space-background-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


.space-color-palette.square {
    display: grid;
    grid-template-columns: repeat(3, 32px);
    gap: 10px;
}

.space-color-palette.square .space-color-dot {
    width: 32px;
    height: 32px;
    border-radius: 10px;
}

.space-picker-popover {
    width: min(220px, calc(100vw - 64px));
}

.space-picker-popover.wide {
    width: min(320px, calc(100vw - 64px));
}

.space-inline-actions.compact {
    justify-content: flex-start;
}


.pending-invites-wrap {
    display: grid;
    gap: 10px;
    padding: 0 16px 14px;
}

.pending-invites-title {
    font-size: 14px;
    font-weight: 700;
    color: #3b4354;
}

.pending-invites-list {
    display: grid;
    gap: 10px;
}

.pending-invite-card {
    background: #f8f9ff;
    border: 1px solid #e2e7f5;
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 8px 18px rgba(39, 51, 89, 0.05);
}

.pending-invite-text {
    font-size: 14px;
    line-height: 1.45;
    color: #2d3445;
}

.pending-invite-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.pending-invite-btn {
    width: auto !important;
    margin-top: 0 !important;
    padding: 10px 14px !important;
    border-radius: 12px !important;
}

.pending-invite-btn.accept {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: #fff !important;
}

.pending-invite-btn.decline {
    background: #eef1f6 !important;
    color: #3e4658 !important;
}


/* ===== Zeer 2.3.23 billing/paywall ===== */
.space-setting-badge,
.invite-billing-summary,
.space-plan-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(102, 126, 234, 0.10);
    color: #5b4bb7;
    font-size: 12px;
    font-weight: 600;
    margin: 4px 0 10px;
}

.space-setting-locked {
    opacity: 0.96;
}

.paywall-modal-content {
    max-width: 420px;
}

.paywall-badge {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(102, 126, 234, 0.12);
    color: #5f52c7;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 12px;
}

.paywall-subtitle {
    color: #666;
    line-height: 1.5;
    margin-bottom: 14px;
}

.paywall-features {
    margin: 0 0 12px 0;
    padding-left: 20px;
    color: #444;
}

.paywall-features li {
    margin-bottom: 8px;
    line-height: 1.4;
}

.paywall-feature-label {
    font-size: 12px;
    color: #777;
    margin-bottom: 10px;
}

.space-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    border-radius: 999px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 0 7px;
    margin-left: 8px;
}

.space-option-main,
.chat-list-item-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.space-option-meta,
.chat-list-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.chat-list-item-last {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

.invite-link-item {
    background: #f7f7fb;
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 10px;
}

.invite-link-meta {
    font-size: 12px;
    color: #666;
    margin: 8px 0;
}

.invite-link-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.invite-link-action-btn {
    width: auto !important;
    flex: 1;
    min-width: 120px;
}

@media (max-width: 480px) {
    .invite-link-actions {
        flex-direction: column;
    }
}


/* ===== Zeer 2.3.26 concept skin ===== */
:root {
    --z-bg: #f3f5fb;
    --z-bg2: #fbfcff;
    --z-surface: rgba(255,255,255,0.82);
    --z-surface-solid: #ffffff;
    --z-surface-2: #f4f7ff;
    --z-surface-3: #eef2ff;
    --z-text: #161a2d;
    --z-muted: #6f7895;
    --z-line: rgba(18,28,60,.09);
    --z-line-strong: rgba(18,28,60,.15);
    --z-shadow: 0 30px 90px rgba(33,40,80,.16);
    --z-card-shadow: 0 18px 46px rgba(33,40,80,.10);
    --z-primary-1: #0d3dbb;
    --z-primary-2: #7c4dff;
    --z-primary-3: #c668ff;
    --z-grad: linear-gradient(135deg,#0d3dbb 0%,#7c4dff 52%,#c668ff 100%);
    --z-grad-soft: linear-gradient(135deg,rgba(13,61,187,.12),rgba(198,104,255,.10));
    --z-hero:
        radial-gradient(circle at 0% 0%, rgba(13,61,187,.15), transparent 28%),
        radial-gradient(circle at 100% 0%, rgba(198,104,255,.16), transparent 30%),
        linear-gradient(180deg, rgba(255,255,255,.96), rgba(245,247,255,.94));
    --z-nav-bg: rgba(255,255,255,.78);
    --z-overlay: rgba(7,10,19,.52);
    --z-danger: #d64d68;
    --z-success: #12a36b;
    --z-warning: #f39a40;
}
html {
    background:
        radial-gradient(circle at 0% 0%, rgba(13,61,187,.08), transparent 18%),
        radial-gradient(circle at 100% 0%, rgba(198,104,255,.08), transparent 18%),
        var(--z-bg);
}
body {
    color: var(--z-text);
    background:
        radial-gradient(circle at 0% 0%, rgba(13,61,187,.08), transparent 18%),
        radial-gradient(circle at 100% 0%, rgba(198,104,255,.08), transparent 18%),
        var(--z-bg);
}
.container,
.chat-list-footer,
.chat-view-header,
.space-selector-row,
.input-area,
.top-bar,
.login-card,
.landing-card,
.chat-list-item,
.current-space,
.spaces-dropdown,
.modal .modal-content,
.user-profile-modal .modal-content,
.action-sheet,
.pending-invite-card,
.invite-link-item,
.notification-settings-card,
.member-item,
.profile-info {
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
}
.container {
    background: var(--z-hero);
}
.top-bar {
    background: transparent;
    color: var(--z-text);
    border-bottom: 1px solid var(--z-line);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}
.logo,
.user-name,
.chat-view-title,
.chat-list-title,
.space-name,
.space-option-name,
.profile-value,
.member-info span,
.modal .modal-content h3 {
    color: var(--z-text);
}
.logo span {
    filter: saturate(1.1);
}
.user-profile,
.space-settings-btn,
.back-to-list-btn,
.emoji-toggle-btn,
.photo-label,
.current-space,
.chat-view-header,
.chat-list-footer,
.reply-preview-container,
.space-bg-live-trigger,
.invite-link-item,
.pending-invite-card,
.member-item,
.profile-info,
.space-picker-popover,
.space-picker-popover.wide,
.space-color-dot,
#updateNotification .update-notification {
    background: var(--z-nav-bg) !important;
    border: 1px solid var(--z-line) !important;
    box-shadow: var(--z-card-shadow) !important;
}
.chat-list-item,
.current-space,
.spaces-dropdown,
.modal .modal-content,
.user-profile-modal .modal-content,
.action-sheet,
.login-card,
.landing-card,
.pending-invite-card,
.invite-link-item,
.member-item,
.profile-info {
    background: var(--z-surface) !important;
    border: 1px solid var(--z-line);
    box-shadow: var(--z-shadow);
}
.login-container,
.auth-screen,
.landing-screen {
    background:
        radial-gradient(circle at 0% 0%, rgba(13,61,187,.15), transparent 28%),
        radial-gradient(circle at 100% 0%, rgba(198,104,255,.16), transparent 30%),
        linear-gradient(180deg, rgba(255,255,255,.96), rgba(245,247,255,.94));
}
.login-card,
.landing-card {
    border-radius: 30px;
}
.login-card input,
.modal .modal-content input,
.modal .modal-content textarea,
.space-edit-input,
.space-edit-textarea,
.message-input-wrapper textarea,
.invite-custom-row input,
#inviteUsernameSpace,
#inviteMaxUsesSpace,
#inviteExpiresAtSpace {
    border: 1px solid var(--z-line-strong) !important;
    background: rgba(255,255,255,.78) !important;
    color: var(--z-text) !important;
    border-radius: 18px !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.45);
}
.login-card input:focus,
.modal .modal-content input:focus,
.modal .modal-content textarea:focus,
.space-edit-input:focus,
.space-edit-textarea:focus,
.message-input-wrapper textarea:focus,
.invite-custom-row input:focus,
#inviteUsernameSpace:focus,
#inviteMaxUsesSpace:focus,
#inviteExpiresAtSpace:focus {
    outline: none;
    border-color: rgba(124,77,255,.45) !important;
    box-shadow: 0 0 0 4px rgba(124,77,255,.10), inset 0 1px 0 rgba(255,255,255,.5) !important;
}
.login-card button,
.modal .modal-content button:not(.secondary),
.send-btn,
.create-chat-btn,
.edit-profile-btn,
#paywallPrimaryBtn,
.pending-invite-btn.accept,
.invite-link-action-btn:not(.secondary) {
    background: var(--z-grad) !important;
    color: #fff !important;
    border: none;
    box-shadow: 0 16px 32px rgba(88,63,255,.24);
}
.modal .modal-content button.secondary,
.pending-invite-btn.decline,
.invite-link-action-btn.secondary,
.invite-type-btn.secondary,
#paywallSecondaryBtn,
.action-sheet-cancel,
.secondary-action-btn {
    background: rgba(255,255,255,.78) !important;
    color: var(--z-text) !important;
    border: 1px solid var(--z-line) !important;
    box-shadow: var(--z-card-shadow) !important;
}
.chat-list-item,
.current-space,
.pending-invite-card,
.invite-link-item,
.member-item {
    border-radius: 24px !important;
}
.chat-list-item-icon,
.selected-space-avatar,
.space-avatar-live-preview,
.space-icon {
    background: var(--z-grad-soft) !important;
    color: var(--z-primary-1);
}
.chat-view-header,
.chat-list-footer,
.input-area,
.space-selector-row {
    background: rgba(255,255,255,.58) !important;
    border-color: var(--z-line) !important;
}
.chat-container,
.chat-view-screen,
.chat-list-screen,
.messages-area {
    background: transparent;
}
.messages-area {
    background: transparent !important;
    padding-bottom: 18px;
}
.message-content {
    border-radius: 22px !important;
    box-shadow: var(--z-card-shadow);
}
.user1 .message-content {
    background: rgba(255,255,255,.90) !important;
    border: 1px solid var(--z-line) !important;
}
.user2 .message-content {
    background: var(--z-grad) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 16px 30px rgba(78,76,241,.26);
}
.reply-preview,
.reply-preview-container {
    border-left-color: var(--z-primary-2) !important;
}
.action-sheet-overlay,
.modal,
.user-profile-modal,
.zeer-dialog-overlay {
    background: var(--z-overlay) !important;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.action-sheet {
    border-radius: 30px 30px 0 0 !important;
    overflow: hidden;
}
.action-sheet-header {
    font-size: 14px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--z-muted);
    border-bottom-color: var(--z-line);
}
.action-sheet-item,
.action-sheet-cancel {
    border-bottom-color: var(--z-line) !important;
}
.action-sheet-item:active,
.action-sheet-cancel:active,
.chat-list-item:active,
.space-option:active,
.current-space:active,
.user-profile:active,
.space-settings-btn:active,
.back-to-list-btn:active,
.emoji-toggle-btn:active,
.photo-label:active,
.send-btn:active,
.login-card button:active,
.modal .modal-content button:active {
    transform: scale(.985);
}
.modal .modal-content,
.user-profile-modal .modal-content {
    border-radius: 30px !important;
    padding: 26px !important;
}
.paywall-badge,
.space-setting-badge,
.invite-billing-summary,
.space-plan-chip,
.admin-badge,
.badge-like {
    background: var(--z-grad-soft) !important;
    color: var(--z-primary-1) !important;
    border: 1px solid rgba(124,77,255,.14);
}
.space-unread-badge {
    background: var(--z-grad) !important;
}
#updateNotification {
    position: fixed;
    top: calc(14px + env(safe-area-inset-top));
    left: 14px;
    right: 14px;
    z-index: 2100;
}
#updateNotification .update-notification {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-radius: 22px;
    padding: 14px 16px;
}
#updateNotification button {
    border: none;
    border-radius: 14px;
    padding: 10px 14px;
    background: var(--z-grad);
    color: #fff;
    font-weight: 700;
}
.zeer-dialog-root {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 4000;
}
.zeer-dialog-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    opacity: 0;
    pointer-events: auto;
    transition: opacity .18s ease;
}
.zeer-dialog-overlay.show { opacity: 1; }
.zeer-dialog-overlay.hide { opacity: 0; }
.zeer-dialog {
    width: min(420px, calc(100vw - 24px));
    background: var(--z-surface);
    border: 1px solid var(--z-line);
    border-radius: 30px;
    box-shadow: var(--z-shadow);
    padding: 24px;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}
.zeer-dialog-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--z-grad-soft);
    color: var(--z-primary-1);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 12px;
}
.zeer-dialog-title {
    margin: 0 0 10px;
    font-size: 24px;
    line-height: 1.1;
    color: var(--z-text);
}
.zeer-dialog-message {
    color: var(--z-muted);
    line-height: 1.55;
    font-size: 15px;
}
.zeer-dialog-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
}
.zeer-dialog-actions.single {
    grid-template-columns: 1fr;
}
.zeer-dialog-btn {
    border: 1px solid var(--z-line);
    border-radius: 18px;
    padding: 14px 16px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.zeer-dialog-btn.primary {
    background: var(--z-grad);
    color: #fff;
    border: none;
}
.zeer-dialog-btn.secondary {
    background: rgba(255,255,255,.78);
    color: var(--z-text);
}
.zeer-dialog-btn.danger {
    background: linear-gradient(135deg,#d64d68,#ff7a91);
    color: #fff;
    border: none;
}
@media (max-width: 768px) {
    .top-bar {
        min-height: 62px;
        padding-inline: 14px;
    }
    .chat-view-header,
    .chat-list-header,
    .pending-invites-wrap,
    .chat-list,
    .messages-area,
    .input-area {
        padding-left: 14px !important;
        padding-right: 14px !important;
    }
    .modal .modal-content,
    .user-profile-modal .modal-content,
    .zeer-dialog {
        border-radius: 28px !important;
    }
}


/* ===== Exact auth button fix ===== */
.login-card button {
    border-radius: 18px;
}

.login-card button.btn-ghost,
.login-card .btn-ghost,
.login-card .auth-secondary-btn {
    background: #ffffff !important;
    color: #161a2d !important;
    border: 1px solid rgba(18,28,60,.09) !important;
    box-shadow: none !important;
    font-weight: 500 !important;
    border-radius: 18px !important;
    padding: 14px 18px !important;
}

.login-card button.btn-ghost:hover,
.login-card .btn-ghost:hover,
.login-card .auth-secondary-btn:hover {
    background: #ffffff !important;
    color: #161a2d !important;
}

.login-card button.btn-ghost:active,
.login-card .btn-ghost:active,
.login-card .auth-secondary-btn:active {
    background: #ffffff !important;
    color: #161a2d !important;
    transform: scale(0.98);
}


/* ===== Zeer 2.4.4 header fix ===== */
.top-bar .logo,
.top-bar .logo-text,
.top-bar .logo span {
    color: #fff !important;
}


/* ===== 2.4.6 hotfix: update notification + white forms ===== */
#updateNotification {
    position: fixed;
    top: calc(14px + env(safe-area-inset-top));
    left: 14px;
    right: 14px;
    z-index: 2100;
    pointer-events: none;
    display: flex;
    justify-content: center;
}

#updateNotification .update-notification {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    width: min(100%, 560px);
    max-width: calc(100vw - 28px);
    min-width: 0;
    padding: 16px;
    border-radius: 24px;
    overflow: hidden;
    background: #ffffff !important;
    border: 1px solid var(--z-line, rgba(98, 110, 140, .18)) !important;
    box-shadow: 0 18px 44px rgba(22, 28, 45, .18) !important;
    color: var(--z-text, #20253a) !important;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

#updateNotification .update-notification::before {
    content: '';
    width: 4px;
    align-self: stretch;
    border-radius: 999px;
    background: var(--z-grad, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    flex-shrink: 0;
}

#updateNotification .update-notification-body {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#updateNotification .update-notification-title {
    margin: 0;
    font-size: 15px;
    line-height: 1.35;
    font-weight: 800;
    color: var(--z-text, #20253a);
    word-break: break-word;
}

#updateNotification .update-notification-text {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--z-muted, #697082);
    word-break: break-word;
}

#updateNotification .update-notification-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    min-width: 0;
    margin-left: auto;
}

#updateNotification .update-notification button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 16px;
    padding: 11px 16px;
    min-height: 44px;
    max-width: 100%;
    background: var(--z-grad, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    color: #fff;
    font-size: 14px;
    line-height: 1;
    font-weight: 800;
    white-space: nowrap;
    box-shadow: 0 12px 26px rgba(88,63,255,.24);
}

#updateNotification .update-notification button:hover {
    transform: translateY(-1px);
}

#updateNotification .update-notification button:active {
    transform: scale(.98);
}

.login-card,
.modal .modal-content,
.user-profile-modal .modal-content {
    background: #ffffff !important;
}

@media (max-width: 640px) {
    #updateNotification {
        top: calc(10px + env(safe-area-inset-top));
        left: 10px;
        right: 10px;
    }

    #updateNotification .update-notification {
        gap: 12px;
        padding: 14px;
        border-radius: 20px;
        max-width: calc(100vw - 20px);
    }

    #updateNotification .update-notification-title {
        font-size: 14px;
    }

    #updateNotification .update-notification-text {
        font-size: 12px;
    }

    #updateNotification .update-notification-actions {
        align-self: center;
    }

    #updateNotification .update-notification button {
        padding: 10px 14px;
        min-height: 42px;
        border-radius: 14px;
        font-size: 13px;
    }
}

@media (max-width: 520px) {
    #updateNotification .update-notification {
        align-items: stretch;
        flex-wrap: wrap;
        gap: 14px;
    }

    #updateNotification .update-notification-actions {
        width: 100%;
        margin-left: 0;
    }

    #updateNotification .update-notification button {
        width: 100%;
    }
}
