:root {
    --bg-main: #1e1e24;
    --bg-sidebar: #24242b;
    --bg-input: #2b2b36;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #33333f;
    --msg-out: #3b82f6;
    --msg-in: #2b2b36;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.screen { display: none; height: 100vh; width: 100vw; }
.screen.active { display: flex; }

/* Auth */
.auth-box {
    margin: auto; width: 100%; max-width: 360px;
    background: var(--bg-sidebar); padding: 30px;
    border-radius: 12px; text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    animation: fadeUp 0.4s ease;
}
.auth-box h1 { margin-bottom: 5px; color: var(--accent); }
.auth-box p { color: var(--text-muted); margin-bottom: 20px; font-size: 14px; }
.auth-box input {
    width: 100%; padding: 12px; margin-bottom: 15px;
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text-main); border-radius: 8px; outline: none;
    transition: border 0.3s;
}
.auth-box input:focus { border-color: var(--accent); }
.auth-buttons { display: flex; gap: 10px; }
button {
    flex: 1; padding: 12px; border: none; border-radius: 8px;
    background: var(--accent); color: #fff; font-weight: 600;
    cursor: pointer; transition: background 0.2s, transform 0.1s;
}
button:hover { background: var(--accent-hover); }
button:active { transform: scale(0.98); }
button.outline { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
button.outline:hover { background: rgba(59, 130, 246, 0.1); }
.error-msg { color: #ef4444; font-size: 13px; margin-top: 10px; min-height: 15px; }

/* Main Chat Layout */
.sidebar {
    width: 320px; background: var(--bg-sidebar);
    border-right: 1px solid var(--border); display: flex; flex-direction: column;
}
.chat-area { flex: 1; display: flex; flex-direction: column; background: var(--bg-main); }

.sidebar-header { padding: 15px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.my-profile { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(45deg, #3b82f6, #8b5cf6); }

.search-bar { padding: 15px; }
.search-bar input {
    width: 100%; padding: 10px 15px; background: var(--bg-input);
    border: none; border-radius: 20px; color: var(--text-main); outline: none;
}

.dialogs-list { flex: 1; overflow-y: auto; }
.dialog-item {
    display: flex; align-items: center; gap: 15px; padding: 12px 15px;
    cursor: pointer; transition: background 0.2s;
}
.dialog-item:hover, .dialog-item.active { background: var(--bg-input); }
.dialog-info { flex: 1; overflow: hidden; }
.dialog-name { font-weight: 600; margin-bottom: 4px; }
.dialog-last { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-placeholder { margin: auto; color: var(--text-muted); font-size: 16px; }

/* Active Chat */
.chat-header { padding: 15px 20px; border-bottom: 1px solid var(--border); background: var(--bg-sidebar); }
.chat-user-info { display: flex; align-items: center; gap: 12px; }
.chat-user-info .name { font-weight: 600; }
.chat-user-info .status { font-size: 12px; color: var(--accent); }

.messages-container { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 70%; padding: 10px 15px; border-radius: 12px; position: relative; animation: popIn 0.2s ease-out; line-height: 1.4; }
.msg.in { background: var(--msg-in); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.out { background: var(--msg-out); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg-time { font-size: 11px; opacity: 0.7; margin-top: 5px; text-align: right; display: block; }

.chat-input-area { padding: 15px 20px; display: flex; gap: 10px; background: var(--bg-sidebar); border-top: 1px solid var(--border); }
.chat-input-area input {
    flex: 1; padding: 12px 15px; background: var(--bg-input);
    border: none; border-radius: 20px; color: var(--text-main); outline: none; font-size: 15px;
}
.chat-input-area button { flex: none; padding: 10px 20px; border-radius: 20px; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }