* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    height: 100dvh;          /* правильно учитывает высоту на телефоне */
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0e1621;
    color: #fff;
}

/* ===== LOGIN ===== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #1a2634, #0e1621);
}

.login-box {
    background: #17212b;
    padding: 40px;
    border-radius: 16px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 28px;
    color: #fff;
}

.login-box p {
    text-align: center;
    color: #8a9aa9;
    margin-bottom: 30px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-radius: 10px;
    background: #242f3d;
    color: #fff;
    font-size: 15px;
    outline: none;
}

.form-group input::placeholder {
    color: #6d7f8f;
}

.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    background: #2AABEE;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s;
}

.btn:hover {
    background: #229ED9;
}

.btn-secondary {
    background: transparent;
    border: 1px solid #2AABEE;
    color: #2AABEE;
    margin-top: 12px;
}

.btn-secondary:hover {
    background: rgba(42, 171, 238, 0.1);
}

.error {
    color: #ff6b6b;
    font-size: 13px;
    margin-top: 12px;
    text-align: center;
    display: none;
}

/* ===== CHAT ===== */
.chat-app {
    display: flex;
    height: 100%;
    height: 100dvh;
}

.sidebar {
    width: 340px;
    background: #17212b;
    border-right: 1px solid #0e1621;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px;
    background: #17212b;
    border-bottom: 1px solid #0e1621;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 18px;
}

.user-list {
    flex: 1;
    overflow-y: auto;
}

.user-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.user-item:hover, .user-item.active {
    background: #202b36;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #2AABEE;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

.user-info h3 {
    font-size: 15px;
    margin-bottom: 2px;
}

.user-info p {
    font-size: 13px;
    color: #8a9aa9;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0e1621;
}

.chat-header {
    padding: 12px 20px;
    background: #17212b;
    border-bottom: 1px solid #0e1621;
    display: flex;
    align-items: center;
    gap: 12px;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.4;
    position: relative;
}

.message.mine {
    align-self: flex-end;
    background: #2b5278;
    border-bottom-right-radius: 4px;
}

.message.theirs {
    align-self: flex-start;
    background: #182533;
    border-bottom-left-radius: 4px;
}

.message .time {
    font-size: 11px;
    color: #8a9aa9;
    margin-top: 4px;
    text-align: right;
}

.chat-input-area {
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom)); /* не перекрывается панелью телефона */
    background: #17212b;
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input-area input,
.chat-input-area textarea {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 22px;
    background: #242f3d;
    color: #fff;
    font-size: 15px;
    outline: none;
    resize: none;
    max-height: 120px;
    min-height: 42px;
    line-height: 1.4;
    font-family: inherit;
    overflow-y: auto;
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #2AABEE;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;   /* ← добавь эту строку */
}

.empty-chat {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8a9aa9;
    font-size: 16px;
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 10;
        height: 100%;
        left: 0;
        top: 0;
    }
    .sidebar.hidden {
        display: none;
    }
    .chat-area {
        width: 100%;
    }

    /* Кнопка «Назад» видна только на телефоне */
    .back-btn {
        display: flex !important;
    }
        .chat-input-area {
        gap: 6px;
        padding-left: 8px;
        padding-right: 8px;
    }

    .file-btn,
    .send-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
        flex-shrink: 0;
    }

    .chat-input-area input,
    .chat-input-area textarea {
        padding: 10px 12px;
        font-size: 14px;
        min-width: 0;   /* важно — иначе поле не сжимается */
    }
}

.back-btn {
    display: none; /* на компьютере скрыта */
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 0 8px 0 0;
    margin-right: 4px;
}

.online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background-color: #4caf50;
    border: 2px solid #17212b;
    border-radius: 50%;
}

.file-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #242f3d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.file-btn:hover {
    background: #2b5278;
}

.message img {
    cursor: pointer;
}
.unread-badge {
    background: #2AABEE;
    color: white;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}