/* ─── «Знакомец» веб — тёмная тема, современный мессенджер ─────────
   Палитра: глубокий сине-фиолетовый графит + бирюзовый акцент. */

:root {
    --bg-main: #0f1220;
    --bg-header: #151b31;
    --bg-chat: #0b0e1a;
    --bg-input: #191f36;
    --bg-hover: #1d2542;
    --bg-card: #161c33;
    --accent: #3b82f6;
    --accent-soft: #60a5fa;
    --accent-deep: #2563eb;
    --accent-grad: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    --text-main: #e6eaf5;
    --text-dim: #99a2ba;
    --text-invert: #ffffff;
    --danger: #f87171;
    --danger-bg: rgba(248,113,113,.12);
    --success: #34d399;
    --success-bg: rgba(52,211,153,.12);
    --warning: #fbbf24;
    --border: #232b49;
    --bubble-in: #1a2140;
    --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: "Segoe UI", "Segoe UI Emoji", "Inter", "Arial", sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

/* ═══ Экраны ═══ */
.screen { display: none; width: 100%; height: 100%; }
.screen.active { display: flex; }
#login-screen, #register-screen {
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(900px 600px at 20% -10%, rgba(59,130,246,.18), transparent 60%),
        radial-gradient(800px 500px at 90% 110%, rgba(56,189,248,.12), transparent 60%),
        #0a0d18;
    padding: 16px;
}

/* ── Карточка входа ── */
.login-card {
    background: rgba(20,25,46,.85);
    backdrop-filter: blur(6px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 36px 34px;
    width: 380px;
    max-width: 92vw;
    box-shadow: 0 24px 70px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.03) inset;
    animation: card-in .28s ease-out;
}
@keyframes card-in {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to   { opacity: 1; transform: none; }
}
.login-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 14px;
    border-radius: 22px;
    background: var(--accent-grad);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    box-shadow: 0 10px 30px rgba(37,99,235,.35);
}
.login-title { text-align: center; margin-bottom: 22px; font-weight: 700; font-size: 22px; letter-spacing: .2px; }
.login-error {
    background: var(--danger-bg);
    border: 1px solid rgba(248,113,113,.35);
    color: #fca5a5;
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 13px;
    line-height: 1.4;
}
.login-links {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
}
.login-links a {
    color: var(--accent-soft);
    text-decoration: none;
    font-size: 13px;
    transition: color .15s;
}
.login-links a:hover { color: var(--accent); text-decoration: underline; }

/* ═══ Поля форм ═══ */
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; color: var(--text-dim); font-size: 12px; }
.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field input[type="datetime-local"],
.field textarea {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 14px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}
.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
}
.checkbox input { accent-color: var(--accent); width: 15px; height: 15px; }
.checkbox input:checked + span { color: var(--text-main); }

/* ═══ Кнопки ═══ */
.btn {
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: var(--bg-input);
    color: var(--text-main);
    font-size: 14px;
    transition: filter .15s, background .15s, transform .06s;
}
.btn:hover { filter: brightness(1.18); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
    background: var(--accent-grad);
    color: var(--text-invert);
    font-weight: 600;
    box-shadow: 0 6px 18px rgba(37,99,235,.3);
}
.btn.small { padding: 7px 12px; font-size: 12px; border-radius: 9px; }
.btn.send {
    border-radius: 50%;
    width: 42px;
    height: 42px;
    padding: 0;
    flex-shrink: 0;
    font-size: 17px;
    background: var(--accent-grad);
    color: var(--text-invert);
    box-shadow: 0 4px 14px rgba(37,99,235,.35);
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn.danger {
    background: var(--danger-bg);
    color: #fca5a5;
    border: 1px solid rgba(248,113,113,.35);
}
.btn.success {
    background: var(--success-bg);
    color: #6ee7b7;
    border: 1px solid rgba(52,211,153,.35);
}

/* Иконки-кнопки (сочетаемы с эмодзи/через SVG-вёрстку в index) */
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 18px;
    padding: 8px;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s, transform .06s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--accent-soft); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.icon-btn.recording { color: var(--danger); background: var(--danger-bg); animation: pulse 1.2s infinite; }
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(248,113,113,.4); }
    50%      { box-shadow: 0 0 0 6px rgba(248,113,113,0); }
}

/* ═══ Каркас приложения ═══ */
.app { flex-direction: row; overflow: hidden; }

/* ── Сайдбар ── */
#sidebar {
    width: 320px;
    min-width: 260px;
    background: var(--bg-main);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
}
.sidebar-header {
    padding: 14px 16px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: .2px;
}
.sidebar-header > div { display: flex; gap: 4px; }

/* Вкладки — сегмент-контрол */
.sidebar-tabs {
    display: flex;
    gap: 6px;
    padding: 6px 12px 10px;
}
.tab-btn {
    flex: 1;
    padding: 8px 6px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 600;
    transition: background .15s, color .15s;
    position: relative;
}
.tab-btn:hover { background: var(--bg-hover); color: var(--text-main); }
.tab-btn.active {
    background: var(--bg-header);
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.tab-unread {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--accent);
    color: var(--text-invert);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    vertical-align: 1px;
    margin-left: 4px;
}

/* Поиск */
.search-wrap { padding: 0 12px 10px; }
.search-row { display: flex; gap: 8px; align-items: center; }
.search-row #group-search { flex: 1; }
.search-row .icon-btn { flex-shrink: 0; }
#meeting-create-btn { margin: 0 auto; width: 100%; justify-content: center; }
.btn.block { display: flex; align-items: center; gap: 8px; }
#contact-search, #group-search {
    width: 100%;
    padding: 10px 14px 10px 36px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: 24px;
    color: var(--text-main);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
#contact-search, #group-search { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2399a2ba' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 12px center; background-size: 16px; }
#contact-search:focus, #group-search:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.16);
}
#contact-search::placeholder, #group-search::placeholder { color: var(--text-dim); }

/* Списки */
.list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }

/* Контакты (JS: chat.js renderContacts) */
.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: background .12s;
}
.contact-item:hover { background: var(--bg-hover); }
.contact-body { flex: 1; overflow: hidden; min-width: 0; }
.contact-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.contact-status {
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.contact-status.online { color: var(--success); }
.contact-status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
}
.contact-status.online::before { background: var(--success); box-shadow: 0 0 6px rgba(52,211,153,.5); }
.unread {
    background: var(--accent);
    color: var(--text-invert);
    border-radius: 12px;
    min-width: 22px;
    height: 22px;
    line-height: 22px;
    padding: 0 7px;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    flex-shrink: 0;
}

/* Группы (JS: chat.js renderGroups) */
.group-item { padding: 6px 8px; cursor: pointer; border-radius: 10px; transition: background .12s; }
.group-item:hover { background: var(--bg-hover); }
.group-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    padding: 6px 2px;
    color: var(--accent-soft);
}
.subgroup-item {
    padding: 8px 12px 8px 34px;
    border-radius: 9px;
    color: var(--text-main);
    font-size: 13px;
    cursor: pointer;
    transition: background .12s, color .12s;
    position: relative;
}
.subgroup-item::before {
    content: "";
    position: absolute;
    left: 18px;
    top: 50%;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border);
    transform: translateY(-50%);
}
.subgroup-item:hover { background: var(--bg-hover); color: var(--accent-soft); }

/* Встречи в сайдбаре (JS: main.js loadMeetingsSidebar) */
.meeting-item { padding: 9px 10px; }
.meeting-item .meeting-title { font-weight: 600; font-size: 13.5px; }
.meeting-item .meeting-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; line-height: 1.4; }

/* Аватар */
.avatar {
    border-radius: 50%;
    color: var(--text-invert);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    background-clip: padding-box;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; display: none; }
.avatar.has-photo img { display: block; }
.avatar.has-photo .letter { opacity: 0; }
.letter { font-size: inherit; }

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge.pending { background: rgba(251,191,36,.13); color: var(--warning); }
.badge.accepted { background: var(--success-bg); color: var(--success); }
.badge.declined { background: var(--danger-bg); color: #fca5a5; }
.badge.confirmed { background: rgba(59,130,246,.15); color: var(--accent-soft); }
.badge.completed { background: rgba(153,162,186,.14); color: var(--text-dim); }
.badge.cancelled { background: var(--danger-bg); color: #fca5a5; }

/* ═══ Главная область ═══ */
#main-area { flex: 1; display: flex; flex-direction: column; height: 100%; position: relative; overflow: hidden; }
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    gap: 14px;
    background: var(--bg-chat);
    text-align: center;
    padding: 24px;
}
.empty-icon {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: rgba(255,255,255,.04);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 44px;
    opacity: .8;
}
.empty-state p { font-size: 14px; }

/* ═══ Чат ═══ */
#chat-view { flex: 1; display: flex; flex-direction: column; height: 100%; }
#chat-header {
    padding: 10px 14px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 5;
}
.chat-peer {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}
.chat-peer-text { min-width: 0; }
#chat-title {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#chat-subtitle {
    color: var(--text-dim);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.chat-actions .btn.small { display: inline-flex; align-items: center; gap: 6px; }

/* Реплай-бар */
#chat-replybar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(59,130,246,.08);
    border-left: 3px solid var(--accent);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.reply-label { color: var(--text-main); white-space: nowrap; }
.reply-label b { color: var(--accent-soft); font-weight: 600; }
.reply-quote {
    color: var(--text-dim);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-style: italic;
}
#chat-replybar .icon-btn { width: 30px; height: 30px; font-size: 14px; color: var(--text-dim); }

/* ═══ История сообщений ═══ */
#chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    background:
        radial-gradient(1000px 600px at 100% 0%, rgba(59,130,246,.05), transparent 55%),
        var(--bg-chat);
}
.bubble {
    max-width: 72%;
    padding: 8px 12px 6px;
    border-radius: 18px 18px 18px 6px;
    background: var(--bubble-in);
    border: 1px solid rgba(255,255,255,.05);
    color: var(--text-main);
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
    position: relative;
    align-self: flex-start;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.bubble.mine {
    align-self: flex-end;
    border-radius: 18px 18px 6px 18px;
    background: var(--accent-grad);
    border-color: transparent;
    color: var(--text-invert);
}
.bubble-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-soft);
    margin-bottom: 2px;
}
.bubble.mine .bubble-name { color: rgba(255,255,255,.9); }
.bubble-content { font-size: 14px; }
.bubble-meta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    float: right;
    margin: 6px 0 0 8px;
    font-size: 11px;
    color: var(--text-dim);
    position: relative;
    top: 3px;
    user-select: none;
}
.bubble.mine .bubble-meta { color: rgba(255,255,255,.75); }
.msg-read { color: var(--text-dim); }
.msg-read.green { color: var(--success); filter: drop-shadow(0 0 3px rgba(52,211,153,.4)); }
.bubble.mine .msg-read { color: rgba(255,255,255,.85); }
.msg-edited { font-size: 10px; opacity: .8; }

/* Содержимое: текст, цитаты, пересылки */
.msg-text { white-space: pre-wrap; word-wrap: break-word; }
.msg-text a, .msg-invite a { color: var(--accent-soft); }
.msg-quote {
    border-left: 4px solid var(--accent);
    background: rgba(255,255,255,.05);
    border-radius: 8px;
    padding: 6px 10px;
    margin-bottom: 6px;
}
.bubble.mine .msg-quote { background: rgba(255,255,255,.14); }
.msg-quote-label { font-size: 12px; font-weight: 700; color: var(--accent-soft); margin-bottom: 2px; }
.msg-quote-text { font-size: 13px; color: var(--text-dim); white-space: pre-wrap; word-wrap: break-word; }
.msg-forward {
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    margin-bottom: 6px;
}
.msg-forward-label { font-size: 12px; font-weight: 700; color: var(--accent-soft); margin-bottom: 2px; }
.msg-invite { margin-top: 6px; }
.msg-invite a { font-weight: 600; text-decoration: none; }
.msg-invite a:hover { text-decoration: underline; }

/* Медиа */
.media-photo img {
    max-width: 320px;
    max-height: 300px;
    border-radius: 12px;
    cursor: pointer;
    display: block;
}
.media-video, .media-voice, .media-file {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 220px;
    padding: 6px 0;
    cursor: pointer;
}
.media-file { color: var(--accent-soft); }
.media-label { font-size: 13px; color: var(--text-dim); }
.bubble.mine .media-label { color: rgba(255,255,255,.85); }

/* Реакции */
.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.msg-reactions span {
    background: rgba(255,255,255,.1);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background .12s, transform .06s;
}
.msg-reactions span:hover { background: rgba(255,255,255,.2); transform: scale(1.08); }

/* Разделители дней */
.day-sep { text-align: center; margin: 10px 0 6px; }
.day-sep span {
    display: inline-block;
    background: var(--bg-header);
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
}

/* Карточка встречи в чате (JS: chat.js renderMeetingCard) */
.meeting-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    max-width: 320px;
    cursor: pointer;
    transition: border-color .15s, transform .1s;
}
.meeting-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.meeting-card-title { font-weight: 700; margin-bottom: 8px; }
.meeting-card .btn { margin-top: 6px; }

/* ═══ Панель ввода ═══ */
#chat-inputbar {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 10px 14px;
    background: var(--bg-header);
    border-top: 1px solid var(--border);
}
#chat-input {
    flex: 1;
    resize: none;
    max-height: 130px;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: 22px;
    color: var(--text-main);
    outline: none;
    line-height: 1.45;
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
}
#chat-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.16); }
#chat-input::placeholder { color: var(--text-dim); }
.mic-timer { font-size: 12px; color: var(--danger); align-self: center; white-space: nowrap; }

/* ═══ Детальные виды (встреча/группа) ═══ */
#meeting-view, #group-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    background: var(--bg-chat);
}
#meeting-header, #group-header {
    padding: 10px 14px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 5;
}
#meeting-title, #group-title { font-weight: 700; font-size: 16px; }
#meeting-body, #group-body { padding: 16px; }

.meeting-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 14px;
}
.meeting-section h4 { margin-bottom: 10px; font-size: 14px; color: var(--accent-soft); }
.participant-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
}
.participant-row .name { flex: 1; }
.receipt-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    font-size: 13px;
}
.receipt-row .rname { flex: 1; }
.receipt-row .rqty { color: var(--text-dim); }
.receipt-row .rprice { min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.receipt-row .remove-x {
    color: var(--danger);
    cursor: pointer;
    background: none;
    border: none;
    font-size: 15px;
    padding: 2px 4px;
    border-radius: 6px;
    transition: background .12s;
}
.receipt-row .remove-x:hover { background: var(--danger-bg); }
.settle-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.settle-total { font-size: 18px; font-weight: 700; text-align: center; margin: 12px 0; color: var(--text-main); }

/* Опросы (JS: groups.js) */
.poll-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    max-width: 320px;
}
.poll-title { font-weight: 700; margin-bottom: 8px; }
.poll-hint { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.poll-voted { font-size: 12px; color: var(--success); margin-bottom: 6px; }
.poll-row {
    padding: 6px 8px;
    border-radius: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    margin-bottom: 6px;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}
.poll-count { color: var(--text-dim); font-size: 12px; }
.poll-vote {
    background: transparent;
    border: none;
    color: var(--accent-soft);
    font-size: 13px;
    padding: 0;
    text-align: left;
    flex: 1;
    word-break: break-word;
}
.poll-vote:hover { text-decoration: underline; }

/* ═══ Скрытие (критично: перебивает display:flex и пр.) ═══ */
[hidden] { display: none !important; }

/* ═══ Модальные окна ═══ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(4,6,12,.66);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: modal-fade .18s ease-out;
}
@keyframes modal-fade { from { opacity: 0; } }
.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
    width: 440px;
    max-width: 92vw;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0,0,0,.6);
    animation: card-in .22s ease-out;
}
.modal-card h3 { margin-bottom: 18px; text-align: center; font-size: 17px; }
.modal-card-wide { width: 520px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.info-text { line-height: 1.55; color: var(--text-dim); white-space: pre-line; }

/* ═══ Всплывающие элементы ═══ */
.menu, .context-menu {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    z-index: 200;
    box-shadow: 0 12px 40px rgba(0,0,0,.55);
    overflow: hidden;
    padding: 6px;
    min-width: 160px;
    animation: pop .12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
.menu button, .context-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-main);
    font-size: 14px;
    transition: background .12s;
}
.menu button:hover, .context-menu button:hover { background: var(--bg-hover); }
.context-menu button.danger { color: #fca5a5; }
.context-menu button.danger:hover { background: var(--danger-bg); }

/* ═══ Тосты ═══ */
#toasts {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 300;
    align-items: center;
    pointer-events: none;
}
.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 11px 18px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,.45);
    font-size: 13px;
    max-width: 80vw;
    animation: toast-in .2s ease-out;
}
@keyframes toast-in {
    from { opacity: 0; transform: translateY(12px); }
}

/* ═══ Эмодзи-панель ═══ */
.emoji-panel {
    position: fixed;
    left: 330px;
    bottom: 74px;
    width: 300px;
    max-height: 260px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    z-index: 250;
    box-shadow: 0 16px 50px rgba(0,0,0,.55);
}
.emoji-item {
    font-size: 22px;
    text-align: center;
    padding: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .1s;
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.emoji-item:hover { background: var(--bg-hover); }

/* ═══ Поиск людей (sd-results и пр.) ═══ */
.search-results { margin-top: 4px; max-height: 300px; overflow-y: auto; }
.search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .12s;
}
.search-item:hover { background: var(--bg-hover); }
.search-item-name { font-weight: 600; }

/* ═══ Спиннер ═══ */
.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ Звонок (overlay) ═══ */
.call-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4,6,12,.92);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}
.call-window {
    width: min(600px, 92vw);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
#call-window-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
/* Индикатор защиты звонка: иконка + текст (не полагаемся только на цвет).
   Контраст к тёмному --bg-card: янтарный ~8:1, зелёный ~7:1. */
.call-security {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 auto 14px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
}
.call-security.verified {
    color: #34d399;
    background: rgba(52,211,153,.12);
    border-color: rgba(52,211,153,.35);
}
.call-security.unverified {
    color: #fbbf24;
    background: rgba(251,191,36,.12);
    border-color: rgba(251,191,36,.38);
}
.call-window video {
    max-width: 100%;
    border-radius: 14px;
    background: #000;
    margin-bottom: 12px;
}
#call-status { color: var(--text-dim); margin-bottom: 16px; min-height: 18px; }
.call-controls { display: flex; justify-content: center; gap: 14px; }
.call-btn {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: none;
    background: var(--bg-input);
    color: var(--text-main);
    font-size: 22px;
    transition: filter .15s, transform .06s;
}
.call-btn:hover { filter: brightness(1.2); }
.call-btn.danger { background: var(--danger); color: var(--text-invert); }

/* ═══ Скроллбары ═══ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #33406b; }

/* Тёмная тема — все инпуты на тёмном */
input, textarea, select { color-scheme: dark; }

/* Лёгкая адаптивность — сужение сайдбара */
@media (max-width: 820px) {
    #sidebar { width: 240px; }
    .emoji-panel { left: 20px; margin: 0 auto; }
    .bubble { max-width: 86%; }
}
@media (max-width: 600px) {
    .app { flex-direction: column; }
    #sidebar { width: 100%; height: 44%; border-right: none; border-bottom: 1px solid var(--border); }
    #main-area { height: 56%; }
}