* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

body { 
    background-color: #000; /* Идеально черный фон */
    /* Тонкие градиентные пятна на фоне для красоты стекла */
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(82, 136, 193, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(106, 17, 203, 0.15), transparent 25%);
    color: #f5f5f5; 
    height: 100vh; 
    display: flex; 
    overflow: hidden; 
    padding: 15px; /* Отступы от краев экрана для "островов" */
    gap: 15px; /* Расстояние между островами */
}

/* Общий класс для стеклянных островов */
.island {
    background: rgba(20, 20, 20, 0.6); /* Темное стекло */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px; /* Закругленные острова */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.screen { width: 100%; height: 100%; display: flex; gap: 15px;}
.hidden { display: none !important; }

/* Анимации */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease forwards; }

/* Auth Island */
#auth-screen { justify-content: center; align-items: center; width: 100%; height: 100%; margin: auto;}
.auth-container { 
    padding: 40px; 
    width: 380px; 
    text-align: center; 
}
.auth-container h2 { margin-bottom: 30px; font-size: 32px; font-weight: 600; letter-spacing: 1px;}
.input-glass { 
    width: 100%; padding: 16px; margin-bottom: 20px; 
    border-radius: 16px; border: 1px solid rgba(255,255,255,0.1); 
    background: rgba(0,0,0,0.5); color: #fff; outline: none;
    font-size: 16px; transition: 0.3s;
}
.input-glass:focus { border-color: rgba(255,255,255,0.3); background: rgba(0,0,0,0.8); box-shadow: 0 0 15px rgba(255,255,255,0.05);}
.btn-glass { 
    width: 100%; padding: 16px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.2); 
    background: rgba(255,255,255,0.1); 
    color: #fff; cursor: pointer; font-weight: 600; font-size: 16px;
    transition: 0.3s; backdrop-filter: blur(10px);
}
.btn-glass:hover { background: rgba(255,255,255,0.2); transform: translateY(-2px); }
.error-msg { color: #ff5252; font-size: 14px; margin-top: 15px; }

/* Sidebar Island */
.sidebar { width: 340px; z-index: 10; height: 100%; flex-shrink: 0;}
.sidebar-header { padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.05); }

.header-btn { 
    flex:1; padding: 12px; background: rgba(0,0,0,0.4); 
    color: #fff; border: 1px solid rgba(255,255,255,0.05); 
    border-radius: 12px; cursor: pointer; font-weight: 500; transition: 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px;
}
.header-btn:hover { background: rgba(255,255,255,0.1); }

.users-list { flex: 1; overflow-y: auto; padding: 10px; }
.users-list::-webkit-scrollbar { width: 4px; }
.users-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.user-item { 
    padding: 12px 15px; cursor: pointer; display: flex; align-items: center; gap: 15px; 
    border-radius: 16px; margin-bottom: 5px; transition: 0.2s; border: 1px solid transparent;
}
.user-item:hover { background: rgba(255,255,255,0.05); }
.user-item.active { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.1); }

.avatar { 
    width: 50px; height: 50px; border-radius: 50%; 
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.1);
    display: flex; align-items: center; justify-content: center; 
    font-weight: 600; flex-shrink: 0; color:#fff; font-size: 18px;
    object-fit: cover; backdrop-filter: blur(5px);
}

.item-info { flex:1; overflow: hidden; }
.item-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.item-status { font-size: 12px; color: rgba(255,255,255,0.5); }
.online { color: #00e676; }

/* Chat Area Island */
.chat-area { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    height: 100%;
}
.chat-header { 
    padding: 15px 25px; 
    border-bottom: 1px solid rgba(255,255,255,0.05); 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    flex-shrink: 0;
    background: rgba(0,0,0,0.2);
}
.chat-header-info { display: flex; align-items: center; gap: 15px; cursor: pointer; }
.typing-indicator { font-size: 13px; color: #82b1ff; font-style: italic; display:none; }

.burger-menu { font-size: 24px; cursor: pointer; padding: 5px; opacity: 0.7; transition: 0.2s; background:none; border:none; color:#fff;}
.burger-menu:hover { opacity: 1; }

.messages-container { flex: 1; padding: 25px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; }
.messages-container::-webkit-scrollbar { width: 4px; }
.messages-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* Message Islands */
.message { 
    max-width: 65%; padding: 15px 20px; border-radius: 20px; position: relative; 
    font-size: 15px; display: flex; flex-direction: column; line-height: 1.5;
    background: rgba(255,255,255,0.05); /* Темное стекло сообщения */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.05);
}
.message.sent { 
    align-self: flex-end; 
    background: rgba(82, 136, 193, 0.15); /* Слегка синий для своих */
    border: 1px solid rgba(82, 136, 193, 0.2);
    border-bottom-right-radius: 6px;
}
.message.received { 
    align-self: flex-start; 
    border-bottom-left-radius: 6px;
}
.message-time { font-size: 11px; opacity: 0.4; align-self: flex-end; margin-top: 8px; }
.message-sender { font-size: 13px; color: #82b1ff; margin-bottom: 6px; font-weight: 600; }

.file-link { color: #fff; text-decoration: none; font-weight: 500; display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,0.3); padding: 12px 18px; border-radius: 14px; margin-top: 10px; border: 1px solid rgba(255,255,255,0.05);}
.file-img { max-width: 100%; max-height: 350px; border-radius: 14px; cursor: pointer; object-fit: contain; margin-top: 10px; border: 1px solid rgba(255,255,255,0.05);}
.file-video { max-width: 100%; max-height: 350px; border-radius: 14px; outline: none; margin-top: 10px; background: #000; border: 1px solid rgba(255,255,255,0.05);}
.file-audio { width: 100%; height: 50px; outline: none; margin-top: 10px; border-radius: 25px; }

/* Input Area Island */
.message-input-area { 
    margin: 15px; padding: 8px 15px; border-radius: 20px; 
    background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.1);
    display: flex; align-items: center; gap: 12px; z-index: 100;
    flex-shrink: 0;
}
#message-form { display: flex; flex: 1; gap: 15px; align-items: center; }
#message-input { 
    flex: 1; padding: 12px 15px; border-radius: 20px; border: none; 
    background: transparent; color: #fff; outline: none; font-size: 15px;
}

.add-btn { background: none; border: none; color: rgba(255,255,255,0.5); cursor: pointer; display:flex; align-items:center; justify-content:center; transition: 0.2s;}
.add-btn:hover { color: #fff; transform: scale(1.1);}
#send-btn { 
    background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.1); color: #fff; 
    width: 40px; height: 40px; border-radius: 50%; cursor: pointer; 
    display: flex; align-items: center; justify-content: center; transition: 0.2s;
}
#send-btn:hover { background: rgba(255,255,255,0.2); transform: scale(1.05); }

/* Подписка / Вступление */
.subscribe-area {
    margin: 20px; text-align: center;
}
.subscribe-btn {
    padding: 15px 40px; border-radius: 24px; border: 1px solid rgba(255,255,255,0.2); 
    background: rgba(255,255,255,0.1); color: #fff; font-weight: 600; cursor: pointer; font-size: 16px;
    backdrop-filter: blur(10px); transition: 0.3s; width: 100%; max-width: 300px;
}
.subscribe-btn:hover { background: rgba(255,255,255,0.2); transform: translateY(-2px); }

/* Modal Styles */
#modal-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 9999;
    backdrop-filter: blur(5px);
}
.modal-content {
    width: 90%; max-width: 400px; padding: 30px; text-align: center;
}
#modal-title { margin-bottom: 15px; font-size: 20px; }
#modal-text { margin-bottom: 20px; color: rgba(255,255,255,0.7); line-height: 1.5; }
.modal-buttons { display: flex; gap: 10px; margin-top: 20px; }
.btn-glass.secondary { background: rgba(255,255,255,0.05); border-color: transparent; }

/* Profile Info Panel Island */
.profile-panel {
    width: 360px; height: 100%; flex-shrink: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
    display: flex; flex-direction: column;
}
.profile-panel.hidden-panel { display: none !important; }

.profile-cover { height: 160px; background: rgba(0,0,0,0.5); position: relative; border-bottom: 1px solid rgba(255,255,255,0.05);}
.profile-avatar-large { 
    width: 110px; height: 110px; border-radius: 50%; border: 6px solid #141414;
    position: absolute; bottom: -55px; left: 25px; box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    background: rgba(255,255,255,0.1); display: flex; align-items: center; justify-content: center; font-size: 40px;
    backdrop-filter: blur(10px); object-fit: cover;
}
.profile-details { padding: 75px 25px 25px; flex: 1; overflow-y: auto;}
.profile-details::-webkit-scrollbar { width: 4px; }
.profile-details::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.profile-name { font-size: 24px; font-weight: 700; margin-bottom: 5px; letter-spacing: 0.5px;}
.profile-handle { color: rgba(255,255,255,0.5); margin-bottom: 15px; font-size: 15px; }
.profile-stats { font-size: 14px; color: #82b1ff; margin-bottom: 25px; font-weight: 500;}
.profile-bio { font-size: 15px; color: #ddd; margin-bottom: 25px; line-height: 1.6; background: rgba(0,0,0,0.3); padding: 18px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.05);}

.action-btn { 
    width: 100%; padding: 14px; margin-bottom: 12px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.05); 
    background: rgba(255,255,255,0.05); color: #fff; cursor: pointer; transition: 0.2s; font-weight: 600; font-size: 15px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}
.action-btn:hover { background: rgba(255,255,255,0.1); }
.action-btn.danger { color: #ff5252; background: rgba(255, 82, 82, 0.05); border-color: rgba(255, 82, 82, 0.1);}
.action-btn.danger:hover { background: rgba(255, 82, 82, 0.15); }

.close-profile { 
    position: absolute; top: 15px; right: 15px; background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.1); 
    color: #fff; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; z-index: 2;
    display: flex; align-items: center; justify-content: center; transition: 0.2s;
}
.close-profile:hover { background: rgba(255,255,255,0.2); }

/* Фикс для строк в островах */
.chat-header, .message-input-area {
    flex-direction: row !important;
    display: flex !important;
}

/* Новые стили для файлов и превью */
#file-preview-area {
    background: rgba(26, 26, 46, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: slideUp 0.3s ease;
}

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

.custom-media-player {
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid rgba(255,255,255,0.05);
}

.custom-media-player:hover {
    background: rgba(255,255,255,0.05);
}

.custom-media-player.video svg {
    filter: drop-shadow(0 0 10px rgba(0,0,0,0.5));
}

.file-description {
    font-size: 14px;
    margin-bottom: 8px;
    color: rgba(255,255,255,0.9);
    line-height: 1.4;
}

.message img.file-img {
    max-width: 100%;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.message img.file-img:hover {
    transform: scale(1.02);
}

/* Модалка 2FA */
.modal-content h3 { margin-bottom: 10px; color: #82b1ff; }
#twofa-verify-code {
    text-align: center;
    font-size: 24px;
    letter-spacing: 5px;
    font-weight: bold;
}

/* Фиксы для мобильного приложения (Native Feel) */
html, body {
    overflow: hidden; /* Запрещаем скролл всей страницы */
    position: fixed;
    width: 100%;
    height: 100%;
    user-select: none; /* Запрещаем выделение текста везде, кроме сообщений */
    -webkit-tap-highlight-color: transparent; /* Убираем синий квадрат при нажатии */
    touch-action: manipulation;
}

.messages-container {
    -webkit-overflow-scrolling: touch; /* Плавный нативный скролл для iOS/Android */
    user-select: text; /* В сообщениях текст выделять можно */
}

input, textarea {
    user-select: text;
}
