/* ===== Родные.ОнЛайн — Мобильный CSS (синхронизирован с десктопом) ===== */
:root {
    --bg: #0a0a14; --surface: #141425; --surface2: #1a1a30;
    --text: #e8e8f0; --text2: #8888aa; --primary: #6c5ce7;
    --primary2: #a78bfa; --border: #2a2a4a; --danger: #ff4757;
    --success: #00d2a0;
}
[data-theme="light"] {
    --bg: #f0f2f5; --surface: #fff; --surface2: #f5f5f8;
    --text: #1a1a2e; --text2: #666; --border: #e2e2e8;
}
[data-theme="neon"] {
    --bg: #0a0014; --surface: #120024; --surface2: #180030;
    --text: #f0e0ff; --text2: #8870aa; --primary: #b44dff;
    --primary2: #d48fff; --border: #2a0050;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text); height: 100vh; height: 100dvh; overflow: hidden; -webkit-tap-highlight-color: transparent; }
.app { display: flex; flex-direction: column; height: 100%; }
.hidden { display: none !important; }
.flex-col { display: flex; flex-direction: column; }
.h-full { height: 100%; }

/* ===== HEADER ===== */
.header { background: var(--surface); padding: 10px 14px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); padding-top: max(10px, env(safe-area-inset-top)); z-index: 10; min-height: 52px; }
.header-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary2)); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 14px; cursor: pointer; flex-shrink: 0; overflow: hidden; }
.header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.header-info { flex: 1; min-width: 0; cursor: pointer; }
.header-name { font-size: 14px; font-weight: 700; }
.header-status { font-size: 10px; color: var(--text2); display: flex; align-items: center; gap: 4px; }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot.online { background: var(--success); }
.dot.offline { background: var(--text2); }
.header-actions { display: flex; gap: 4px; }
.header-btn { width: 32px; height: 32px; border-radius: 50%; background: var(--surface2); border: none; color: var(--text); font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.header-btn:active { transform: scale(0.9); background: var(--primary); color: #fff; }
.btn-back { font-size: 16px; font-weight: 700; }

/* ===== SEARCH ===== */
.search-container { padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.search-wrapper { position: relative; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text2); font-size: 14px; pointer-events: none; z-index: 1; }
.search-input { width: 100%; padding: 9px 14px 9px 34px; border-radius: 16px; border: 2px solid var(--border); background: var(--surface2); color: var(--text); font-size: 13px; font-family: inherit; outline: none; }
.search-input:focus { border-color: var(--primary); }

/* ===== CONTENT & CHAT LIST ===== */
.content { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--bg); }
.chat-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.02); }
.chat-item:active { background: rgba(108,92,231,0.06); }
.chat-avatar-wrapper { position: relative; flex-shrink: 0; }
.chat-avatar { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary2)); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 15px; overflow: hidden; }
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.online-dot { position: absolute; bottom: 2px; right: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--success); border: 2px solid var(--bg); }
.chat-info { flex: 1; min-width: 0; }
.chat-name { font-size: 13px; font-weight: 700; }
.chat-preview { font-size: 11px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat-meta { text-align: right; flex-shrink: 0; }
.chat-time { font-size: 10px; color: var(--text2); }
.unread-badge { background: var(--primary); color: #fff; font-size: 9px; font-weight: 800; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; margin-top: 3px; }
.fab { position: fixed; bottom: 70px; right: 14px; width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary2)); color: #fff; border: none; font-size: 22px; cursor: pointer; box-shadow: 0 3px 15px rgba(108,92,231,0.4); z-index: 30; display: flex; align-items: center; justify-content: center; }
.fab:active { transform: scale(0.9); }

/* ===== MESSAGES (как в десктопе) ===== */
.messages-container { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px; background: var(--bg); }

/* Обёртка */
.msg-wrapper { display: flex; margin-bottom: 4px; width: 100%; animation: msgIn 0.2s ease; }
.msg-mine { justify-content: flex-end; }
.msg-other { justify-content: flex-start; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Контент */
.msg-content { display: flex; flex-direction: column; max-width: 82%; }
.msg-mine .msg-content { align-items: flex-end; }
.msg-other .msg-content { align-items: flex-start; }

/* Аватар */
.msg-avatar { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary2)); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0; margin-right: 6px; overflow: hidden; cursor: pointer; }
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Отправитель */
.msg-sender { font-size: 10px; font-weight: 700; color: var(--primary2); margin-bottom: 2px; padding: 0 4px; cursor: pointer; }

/* ОБЛАКО (как в десктопе) */
.msg-bubble { display: inline-block; max-width: 500px; padding: 8px 12px; border-radius: 18px; text-align: left; word-break: break-word; position: relative; font-size: 13px; line-height: 1.45; }
.msg-mine .msg-bubble { background: #4F8CFF; color: #fff; border-bottom-right-radius: 6px; }
.msg-other .msg-bubble { background: #2a2a3e; color: #e0e0e0; border-bottom-left-radius: 6px; }

/* Текст */
.msg-text { margin-bottom: 2px; }

/* Картинки */
.msg-image-file { width: 180px; height: 180px; border-radius: 12px; overflow: hidden; margin-bottom: 6px; cursor: pointer; }
.msg-image-file img { width: 100%; height: 100%; object-fit: cover; }

/* Стикеры */
.msg-sticker-img { width: 64px; height: 64px; object-fit: contain; }

/* Файлы */
.msg-file-attach { display: flex; align-items: center; gap: 8px; padding: 8px; background: rgba(255,255,255,0.08); border-radius: 8px; margin-top: 4px; cursor: pointer; }
.msg-file-attach .file-icon { font-size: 20px; }
.msg-file-attach .file-name { font-size: 11px; font-weight: 600; }

/* Реакции (прозрачный фон) */
.msg-reactions { display: flex; gap: 4px; margin-top: 3px; margin-left: 6px; flex-wrap: wrap; }
.msg-mine .msg-reactions { justify-content: flex-end; margin-left: 0; margin-right: 6px; }
.msg-reactions span { background: var(--surface2); padding: 2px 6px; border-radius: 10px; font-size: 10px; cursor: pointer; border: 1px solid var(--border); }
.msg-reactions span:active { background: var(--primary); color: #fff; }

/* Футер (как в десктопе) */
.msg-footer { display: flex; justify-content: flex-end; gap: 4px; font-size: 10px; padding-top: 4px; opacity: 0.7; margin-left: 6px; }
.msg-mine .msg-footer { margin-left: 0; margin-right: 6px; }
.msg-time { color: var(--text2); }
.msg-mine .msg-time { color: rgba(255,255,255,0.7); }
.msg-status { font-size: 10px; }
.msg-edited { font-size: 9px; font-style: italic; }

/* Триггер реакции */
.msg-reaction-trigger { position: absolute; bottom: -8px; right: 6px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 10px; opacity: 0; transition: opacity 0.2s; }
.msg-mine .msg-reaction-trigger { right: auto; left: 6px; }
.msg-wrapper:active .msg-reaction-trigger { opacity: 1; }

/* Разделители дат */
.date-separator { text-align: center; margin: 14px 0; }
.date-separator span { background: var(--surface); color: var(--text2); font-size: 9px; font-weight: 700; padding: 3px 8px; border-radius: 8px; }
.load-more { text-align: center; padding: 8px; cursor: pointer; color: var(--primary); font-weight: 700; font-size: 11px; }

/* ===== INPUT AREA ===== */
.input-area { background: var(--surface); padding: 8px 10px; display: flex; align-items: flex-end; gap: 5px; border-top: 1px solid var(--border); padding-bottom: max(8px, env(safe-area-inset-bottom)); z-index: 12; }
.input-wrapper { flex: 1; }
.msg-input { width: 100%; padding: 9px 12px; border-radius: 16px; border: 2px solid var(--border); background: var(--surface2); color: var(--text); font-size: 13px; font-family: inherit; outline: none; }
.msg-input:focus { border-color: var(--primary); }
.input-btn { width: 34px; height: 34px; border-radius: 50%; border: none; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.input-btn:active { transform: scale(0.9); }
.btn-send { background: #4F8CFF; color: #fff; }
.btn-attach { background: var(--surface2); color: var(--text); }
.btn-call { background: var(--success); color: #fff; }
.btn-video-call { background: #ff6b6b; color: #fff; }

/* ===== PANELS ===== */
.panel-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.35); z-index: 20; display: none; }
.panel-overlay.active { display: block; }
.panel-bottom { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-radius: 14px 14px 0 0; padding: 12px; box-shadow: 0 -3px 20px rgba(0,0,0,0.3); z-index: 25; transform: translateY(100%); transition: transform 0.25s ease; max-height: 50vh; overflow-y: auto; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.panel-bottom.active { transform: translateY(0); }
.attach-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.attach-item { display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer; padding: 8px; border-radius: 8px; }
.attach-item:active { background: var(--surface2); }
.attach-icon { width: 42px; height: 42px; border-radius: 50%; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.attach-label { font-size: 9px; color: var(--text2); font-weight: 600; }
.emoji-tabs, .sticker-tabs { display: flex; gap: 3px; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.emoji-tab, .sticker-tab { padding: 5px 10px; border-radius: 10px; cursor: pointer; font-size: 11px; font-weight: 700; color: var(--text2); background: transparent; border: 2px solid transparent; white-space: nowrap; font-family: inherit; }
.emoji-tab.active, .sticker-tab.active { background: var(--primary); color: #fff; }
.emoji-grid { display: grid; grid-template-columns: repeat(6,1fr); gap: 1px; }
.emoji-item { cursor: pointer; text-align: center; border-radius: 4px; padding: 2px; }
.emoji-item img { width: 36px; height: 36px; object-fit: contain; }
.sticker-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 5px; }
.sticker-item { cursor: pointer; text-align: center; border-radius: 6px; padding: 4px; }
.sticker-item img { width: 48px; height: 48px; object-fit: contain; }

/* ===== LOGIN ===== */
.login-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; padding: 20px; text-align: center; background: var(--bg); }
.login-logo { width: 60px; height: 60px; border-radius: 12px; background: linear-gradient(135deg, var(--primary), var(--primary2)); display: flex; align-items: center; justify-content: center; font-size: 26px; margin-bottom: 12px; color: #fff; }
.login-screen h1 { font-size: 20px; font-weight: 800; margin-bottom: 4px; background: linear-gradient(135deg, var(--primary), var(--primary2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.login-subtitle { color: var(--text2); margin-bottom: 18px; font-size: 11px; }
.login-form { width: 100%; max-width: 260px; }
.input-group { position: relative; margin-bottom: 10px; }
.input-group .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text2); font-size: 13px; }
.login-input { width: 100%; padding: 11px 11px 11px 34px; border-radius: 10px; border: 2px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; font-family: inherit; outline: none; }
.login-btn { width: 100%; padding: 11px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), var(--primary2)); color: #fff; border: none; font-size: 13px; font-weight: 800; cursor: pointer; margin-top: 4px; }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 100; display: flex; align-items: flex-end; }
.modal { background: var(--surface); border-radius: 14px 14px 0 0; padding: 16px; width: 100%; max-height: 65vh; overflow-y: auto; }
.modal-handle { width: 30px; height: 3px; background: var(--border); border-radius: 2px; margin: 0 auto 12px; }
.modal-btn { display: block; width: 100%; padding: 10px; margin-bottom: 6px; border-radius: 8px; border: 2px solid var(--border); background: var(--surface); color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer; text-align: left; }
.modal-btn.cancel { background: var(--surface2); text-align: center; }

/* ===== MENU & PROFILE & TOAST ===== */
.main-menu-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 90; display: none; }
.main-menu-overlay.active { display: block; }
.main-menu { position: fixed; top: 0; left: 0; width: 78%; max-width: 260px; height: 100%; background: var(--surface); z-index: 95; transform: translateX(-100%); transition: transform 0.25s ease; padding-top: max(14px, env(safe-area-inset-top)); overflow-y: auto; }
.main-menu.active { transform: translateX(0); }
.menu-header { padding: 14px 12px; background: linear-gradient(135deg, var(--primary), var(--primary2)); color: #fff; margin-bottom: 8px; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; cursor: pointer; font-size: 12px; font-weight: 600; }
.menu-icon { font-size: 15px; width: 20px; text-align: center; }
.toast { position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%); background: var(--surface); color: var(--text); padding: 8px 16px; border-radius: 14px; box-shadow: 0 4px 15px rgba(0,0,0,0.3); z-index: 200; font-weight: 700; font-size: 12px; white-space: nowrap; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.empty-state { text-align: center; padding: 30px 14px; color: var(--text2); }
.empty-state .icon { font-size: 36px; margin-bottom: 8px; opacity: 0.5; }
::-webkit-scrollbar { width: 2px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
