:root {
    --bg-app: #070a12;
    --bg-panel: #0f172a;
    --bg-surface: #1e293b;
    --bg-input: #020617;
    --border-color: #1e293b;
    --accent-color: #06b6d4;
    --accent-hover: #0891b2;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --msg-my-bg: #0284c7;
    --msg-other-bg: #1e293b;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: var(--font-family);
    height: 100dvh;
    overflow: hidden;
    user-select: none;
}

.hidden { display: none !important; }

/* УНИКАЛЬНЫЙ ВЕРИФИЦИРОВАННЫЙ БЕЙДЖ #ID */
.uid-badge {
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-color);
    border: 1px solid rgba(6, 182, 212, 0.3);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-block;
}

/* LANDING PAGE */
.landing-container {
    height: 100dvh;
    overflow-y: auto;
    background: radial-gradient(circle at top, #1e1b4b 0%, #070a12 65%);
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.landing-header { display: flex; justify-content: space-between; align-items: center; max-width: 1100px; margin: 0 auto; width: 100%; }
.brand { font-size: 1.4rem; font-weight: 800; color: var(--accent-color); }

.landing-hero { max-width: 900px; margin: 60px auto 0; text-align: center; }
.hero-badge { display: inline-block; padding: 6px 16px; background: rgba(6, 182, 212, 0.1); border: 1px solid var(--accent-color); border-radius: 20px; color: var(--accent-color); font-size: 0.85rem; margin-bottom: 20px; }
.landing-hero h1 { font-size: 3rem; font-weight: 800; line-height: 1.2; margin-bottom: 20px; background: linear-gradient(to right, #ffffff, #94a3b8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.landing-hero p { font-size: 1.1rem; color: var(--text-muted); max-width: 650px; margin: 0 auto 36px; line-height: 1.6; }

.btn-lg { padding: 16px 36px; font-size: 1.1rem; border-radius: 30px; }

.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-top: 60px; }
.feature-card { background: rgba(15, 23, 42, 0.7); border: 1px solid var(--border-color); padding: 24px; border-radius: 16px; text-align: left; backdrop-filter: blur(10px); }
.feature-icon { font-size: 2rem; margin-bottom: 12px; }
.feature-card h3 { margin-bottom: 8px; font-size: 1.1rem; }
.feature-card p { font-size: 0.9rem; color: var(--text-muted); }

/* МОДАЛКА */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex; justify-content: center; align-items: center;
    z-index: 2000;
}

.auth-card {
    background: var(--bg-panel); border: 1px solid var(--border-color);
    padding: 32px; border-radius: 20px; width: 100%; max-width: 400px;
    position: relative; box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}

.auth-card h2 { margin-bottom: 20px; text-align: center; }
.input-field { margin-bottom: 14px; }
.input-field label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
.input-field input, textarea { width: 100%; padding: 12px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: 10px; color: var(--text-main); font-size: 0.95rem; outline: none; }
.input-field input:focus, textarea:focus { border-color: var(--accent-color); }

.btn { padding: 12px 20px; border-radius: 10px; border: none; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.btn-primary { background: var(--accent-color); color: #000; font-weight: 700; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-main); }
.full-width { width: 100%; }

.auth-footer { margin-top: 16px; text-align: center; font-size: 0.85rem; color: var(--text-muted); }
.btn-text { background: none; border: none; color: var(--accent-color); cursor: pointer; font-weight: 600; }
.form-error { color: #ef4444; font-size: 0.85rem; margin-bottom: 12px; text-align: center; }

/* ГЛАВНЫЙ ИНТЕРФЕЙС */
.app-layout { display: flex; width: 100vw; height: 100dvh; overflow: hidden; }

.sidebar {
    width: 320px; background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column; flex-shrink: 0;
}

.user-bar { padding: 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); }
.user-preview { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: var(--accent-color); display: flex; align-items: center; justify-content: center;
    font-weight: bold; color: #000; background-size: cover; flex-shrink: 0;
}

.user-meta { display: flex; flex-direction: column; gap: 2px; }
.nickname-row { display: flex; align-items: center; gap: 6px; }
.nickname-row .nickname { font-weight: 600; font-size: 0.95rem; }
.status-online { font-size: 0.72rem; color: #10b981; }

.btn-icon { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; padding: 6px; }

.search-box { padding: 12px; position: relative; }
.search-box input { width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: 20px; color: var(--text-main); font-size: 0.85rem; outline: none; }
.search-results { position: absolute; top: 100%; left: 12px; right: 12px; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 12px; max-height: 200px; overflow-y: auto; z-index: 100; }
.search-item { padding: 10px; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.search-item:hover { background: rgba(255,255,255,0.05); }

.chat-sections { flex: 1; overflow-y: auto; padding: 8px 12px; }
.section-label { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin: 12px 6px 6px; }

.chat-card { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; cursor: pointer; transition: background 0.15s; margin-bottom: 4px; }
.chat-card:hover { background: var(--bg-surface); }
.chat-card.active { background: var(--accent-color); color: #000; }
.chat-card.active .card-preview, .chat-card.active .card-time { color: #0f172a; }

.card-icon { font-size: 1.3rem; }
.card-info { flex: 1; min-width: 0; }
.card-title-row { display: flex; justify-content: space-between; align-items: center; }
.card-title { font-weight: 600; font-size: 0.9rem; }
.card-time { font-size: 0.75rem; opacity: 0.7; }
.card-preview { font-size: 0.8rem; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.chat-workspace { flex: 1; display: flex; flex-direction: column; background: var(--bg-app); }
.workspace-header { padding: 14px 20px; background: var(--bg-panel); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; gap: 12px; }
.active-chat-info { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.title-row { display: flex; align-items: center; gap: 8px; }
.subtitle { font-size: 0.75rem; color: #10b981; }

.messages-scroll-area { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }

.msg-bubble { max-width: 65%; padding: 10px 14px; border-radius: 14px; font-size: 0.95rem; line-height: 1.4; word-break: break-word; }
.msg-bubble.my { align-self: flex-end; background: var(--msg-my-bg); color: white; border-bottom-right-radius: 2px; }
.msg-bubble.other { align-self: flex-start; background: var(--msg-other-bg); color: var(--text-main); border-bottom-left-radius: 2px; }

.msg-author-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; cursor: pointer; }
.msg-author-name { font-size: 0.78rem; font-weight: 700; color: var(--accent-color); }
.msg-time { font-size: 0.65rem; opacity: 0.6; float: right; margin-left: 10px; margin-top: 4px; }
.msg-img { max-width: 100%; max-height: 250px; border-radius: 8px; margin-top: 6px; cursor: pointer; }

.voice-player { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.voice-play-btn { width: 32px; height: 32px; border-radius: 50%; border: none; background: #fff; color: #000; cursor: pointer; font-size: 0.8rem; }

.workspace-footer { padding: 12px 20px; background: var(--bg-panel); border-top: 1px solid var(--border-color); position: relative; }

.send-form { display: flex; align-items: center; gap: 10px; }
.attach-btn { font-size: 1.3rem; cursor: pointer; padding: 6px; background: none; border: none; color: var(--text-muted); }
.attach-btn.recording { color: #ef4444; animation: pulse 1s infinite; }

@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.4; } 100% { opacity: 1; } }

.send-form input[type="text"] { flex: 1; padding: 12px 16px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: 24px; color: var(--text-main); outline: none; }
.btn-send { border-radius: 50%; width: 42px; height: 42px; padding: 0; display: flex; align-items: center; justify-content: center; }

.image-preview-bar { margin-top: 8px; font-size: 0.8rem; color: var(--accent-color); display: flex; justify-content: space-between; align-items: center; }

.modal-window { background: var(--bg-panel); border: 1px solid var(--border-color); padding: 28px; border-radius: 20px; width: 90%; max-width: 380px; position: relative; }
.modal-close-btn { position: absolute; top: 14px; right: 14px; background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; }
.profile-summary { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 16px; }
.avatar-large { width: 72px; height: 72px; border-radius: 50%; background: var(--accent-color); font-size: 1.8rem; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; color: #000; }
.modal-name-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.register-date { font-size: 0.75rem; color: var(--text-muted); }
.bio-container { background: var(--bg-input); padding: 12px; border-radius: 10px; border: 1px solid var(--border-color); margin-bottom: 16px; }
.field-label { font-size: 0.75rem; color: var(--text-muted); display: block; margin-bottom: 4px; }
.bio-text { font-size: 0.9rem; }

.modal-section { margin-top: 16px; }

.mobile-only { display: none; }
@media (max-width: 768px) {
    .sidebar { width: 100%; }
    .chat-workspace { display: none; width: 100%; }
    .mobile-only { display: block; }
    .app-layout.mobile-chat-open .sidebar { display: none; }
    .app-layout.mobile-chat-open .chat-workspace { display: flex; }
}
