/* ===========================
   THEMES (CSS custom properties)
   =========================== */
:root, [data-theme="dark"] {
    --bg-primary: #36393f;
    --bg-secondary: #2f3136;
    --bg-tertiary: #202225;
    --bg-floating: #2b2d31;
    --bg-accent: #40444b;
    --bg-input: #1e1f22;
    --text-primary: #dcddde;
    --text-secondary: #b9bbbe;
    --text-muted: #72767d;
    --brand: #5865f2;
    --border-subtle: #222;
    --border-dim: #3f4147;
    --text-bright: #fff;
    --danger: #ed4245;
    --brand-hover: #4752c4;
    --green: #23a55a;
    --green-dark: #1a6334;
    --accent-dark: #4f545c;
    --link: #00b0f4;
    --bg-dark: #111214;
}
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f2f3f5;
    --bg-tertiary: #e3e5e8;
    --bg-floating: #ffffff;
    --bg-accent: #ebedef;
    --bg-input: #e3e5e8;
    --text-primary: #2e3338;
    --text-secondary: #4f5660;
    --text-muted: #747f8d;
    --brand: #5865f2;
    --border-subtle: #d4d6d9;
    --border-dim: #e3e5e8;
    --text-bright: #000;
    --danger: #ed4245;
    --brand-hover: #4752c4;
    --green: #23a55a;
    --green-dark: #1a6334;
    --accent-dark: #c4c9ce;
    --link: #00b0f4;
    --bg-dark: #e3e5e8;
}
[data-theme="oled"] {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #000000;
    --bg-floating: #111111;
    --bg-accent: #1a1a1a;
    --bg-input: #0a0a0a;
    --text-primary: #dcddde;
    --text-secondary: #b9bbbe;
    --text-muted: #72767d;
    --brand: #5865f2;
    --border-subtle: #222;
    --border-dim: #222;
    --text-bright: #fff;
    --danger: #ed4245;
    --brand-hover: #4752c4;
    --green: #23a55a;
    --green-dark: #1a6334;
    --accent-dark: #333;
    --link: #00b0f4;
    --bg-dark: #000;
}

/* Font size presets */
[data-font-size="small"] .messages { font-size: 13px; }
[data-font-size="normal"] .messages { font-size: 15px; }
[data-font-size="large"] .messages { font-size: 17px; }

/* Message density */
[data-density="compact"] .message { margin-bottom: 2px; padding: 2px 16px; }
[data-density="compact"] .avatar { width: 24px; height: 24px; font-size: 11px; }

/* ===========================
   RESET & BASE
   =========================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: var(--bg-primary); color: var(--text-primary); display: flex; height: 100vh; overflow: hidden; }
#app { display: flex; width: 100%; height: 100vh; overflow: hidden; }

/* ===========================
   ACCESSIBILITY (focus-visible)
   =========================== */
:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}
button:focus-visible,
.server-icon:focus-visible,
.channel:focus-visible,
.member-item:focus-visible,
.dm-channel:focus-visible,
.friend-item:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
    border-radius: 4px;
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 0;
}
/* Remove default outline for mouse users */
:focus:not(:focus-visible) {
    outline: none;
}

/* ===========================
   SERVERS SIDEBAR
   =========================== */
.servers { width: 72px; background: var(--bg-tertiary); display: flex; flex-direction: column; align-items: center; padding-top: 10px; padding-bottom: 10px; flex-shrink: 0; overflow-y: auto; scrollbar-width: none; }
.servers::-webkit-scrollbar { display: none; }
.server-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--bg-primary); margin-bottom: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: border-radius 0.2s; font-size: 18px; font-weight: 700; color: var(--text-bright); flex-shrink: 0; }
.server-icon:hover { border-radius: 30%; background: var(--bg-accent); }
.server-icon-colored { overflow: hidden; }
.server-icon-colored:hover { filter: brightness(1.1); background: none; }
.server-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.settings-server-icon { margin-bottom: 0; }
.settings-server-icon .server-svg-icon { stroke: var(--text-secondary); fill: none; }
.settings-server-icon:hover .server-svg-icon { stroke: var(--text-bright); }

/* Выбор цвета сервера */
.server-color-picker { background: var(--bg-floating, #2b2d31); border-radius: 8px; padding: 16px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); min-width: 220px; }
.server-color-picker-title { color: var(--text-secondary, #b5bac1); font-size: 12px; font-weight: 700; text-transform: uppercase; margin-bottom: 12px; letter-spacing: 0.02em; }
.server-color-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.server-color-swatch { width: 36px; height: 36px; border-radius: 50%; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; border: 3px solid transparent; }
.server-color-swatch:hover { transform: scale(1.15); }
.server-color-swatch.selected { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,0.3); }

/* ===========================
   CHANNELS SIDEBAR
   =========================== */
.channels {
    width: 240px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    padding: 20px 10px 120px 10px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    overflow-y: auto;
}

.channel { padding: 6px 10px; margin: 2px 0; border-radius: 4px; cursor: pointer; color: var(--text-muted); display: flex; align-items: center; transition: background 0.2s; position: relative; }
.channel:hover { background: var(--bg-accent); color: var(--text-primary); }
.channel.active { background: var(--bg-accent); color: var(--text-bright); }
.channel.unread { color: var(--text-bright); font-weight: 600; }
.unread-dot { position: absolute; left: -2px; top: 50%; transform: translateY(-50%); width: 8px; height: 8px; background: #fff; border-radius: 50%; }
.channel-muted { opacity: 0.4; }

/* Категории каналов */
.category-header { display: flex; align-items: center; gap: 2px; padding: 6px 4px; cursor: pointer; color: var(--text-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; margin-top: 12px; }
.category-header:first-child { margin-top: 0; }
.category-header:hover { color: var(--text-primary); }
.category-arrow { display: flex; align-items: center; transition: transform 0.2s; color: inherit; }
.category-arrow svg { stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.category-arrow.collapsed { transform: rotate(-90deg); }
.category-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-add-btn { opacity: 0; background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 2px; display: flex; align-items: center; margin-left: auto; }
.category-header:hover .category-add-btn { opacity: 1; }
.category-add-btn:hover { color: var(--text-primary); }

.channel.voice-channel { color: var(--green); display: flex; align-items: center; }
.channel.voice-channel i { margin-right: 6px; font-style: normal; }
.channel.voice-channel.active { background: var(--green); color: white; }

.voice-user-count { background: var(--bg-accent); color: var(--text-primary); border-radius: 12px; padding: 2px 8px; font-size: 11px; font-weight: 600; margin-left: 6px; }
.channel.voice-channel.active .voice-user-count { background: var(--bg-secondary); color: var(--text-bright); }

.voice-users-tooltip { position: absolute; left: 100%; top: 0; margin-left: 8px; background: var(--bg-dark); border-radius: 8px; padding: 8px; min-width: 220px; box-shadow: 0 8px 16px rgba(0,0,0,0.24); display: none; z-index: 1000; }
.channel.voice-channel:hover .voice-users-tooltip { display: block; }
.tooltip-title { color: var(--text-secondary); font-size: 12px; font-weight: 600; text-transform: uppercase; margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--bg-secondary); }

/* Voice controls (статус + список участников в сайдбаре) */
#voiceControls { margin-top: 20px; padding: 10px; background: var(--bg-secondary); border-radius: 8px; border: 1px solid var(--green); }
.voice-status { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding: 8px; background: var(--bg-tertiary); border-radius: 4px; font-size: 12px; color: var(--text-secondary); }
.voice-status.connected { color: var(--green); border-left: 3px solid var(--green); }
.voice-users-list { max-height: 200px; overflow-y: auto; margin-bottom: 8px; }

.voice-user-item { display: flex; align-items: center; padding: 8px; margin-bottom: 4px; background: var(--bg-accent); border-radius: 4px; }
.voice-user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; margin-right: 10px; transition: box-shadow .15s; flex-shrink: 0; }
.voice-user-info { flex: 1; min-width: 0; }
.voice-user-name { font-size: 14px; font-weight: 500; color: var(--text-bright); display: flex; align-items: center; gap: 8px; transition: color .15s; }
.voice-user-badge { font-size: 11px; color: var(--text-secondary); margin-left: 6px; }
.voice-user-volume { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.volume-slider { width: 80px; height: 4px; -webkit-appearance: none; background: var(--bg-tertiary); border-radius: 2px; outline: none; }
.volume-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #43b581; cursor: pointer; transition: transform 0.1s; }
.volume-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.volume-value { font-size: 11px; color: var(--text-secondary); min-width: 35px; }

.voice-user-name.dimmed { color: var(--text-muted); }
.voice-user-avatar.speaking { box-shadow: 0 0 0 2px #23a55a, 0 0 12px rgba(35,165,90,.35); }
.voice-user-name.speaking { color: #23a55a; }

/* Status icons */
.status-icons { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; flex: 0 0 auto; }
.status-icon { width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; }
.status-icon svg { width: 16px; height: 16px; }
.status-icon svg .s { stroke: var(--danger); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.status-icon svg .sl { stroke: var(--danger); stroke-width: 2; stroke-linecap: round; }

/* Индикатор качества соединения */
.connection-quality { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; cursor: help; }
.connection-quality svg { width: 14px; height: 14px; }

/* Section titles */
.section-title { color: var(--text-muted); font-size: 12px; margin: 10px 0 8px 0; text-transform: uppercase; letter-spacing: .3px; }
.divider { height: 1px; background: var(--bg-tertiary); margin: 10px 0; }

/* User bar */
.user-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 56px; padding: 8px 10px; background: var(--bg-tertiary); border-top: 1px solid var(--border-dim); display: flex; align-items: center; gap: 10px; }
.user-pill { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-dot { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); display: flex; align-items: center; justify-content: center; color: var(--text-bright); font-weight: 700; font-size: 14px; flex: 0 0 auto; }
.user-name { font-size: 12px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-bar-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-bar-status { font-size: 11px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.user-bar-status:hover { color: var(--text-primary); }
.logout-mini { width: 36px; height: 36px; border-radius: 8px; background: var(--bg-secondary); border: 1px solid #1f2024; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: background .2s, box-shadow .2s; padding: 0; margin: 0; flex-shrink: 0; }
.logout-mini:hover { background: #3a3d44; box-shadow: 0 0 10px rgba(237,66,69,0.4); }
.logout-mini svg { width: 18px; height: 18px; }
.logout-mini svg path { stroke: var(--danger); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* SVG icons — общий стиль (stroke-based) */
.voice-status svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; margin-right: 2px; }
.server-svg-icon { width: 24px; height: 24px; fill: none; stroke: var(--text-primary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.server-icon:hover .server-svg-icon { stroke: var(--text-bright); }
.channel-type-icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; flex-shrink: 0; }
.btn-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; margin-right: 2px; }
.file-svg-icon { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.file-remove-icon { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
.download-svg-icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chat-target-prefix { display: inline-flex; align-items: center; vertical-align: middle; }

/* ===========================
   MAIN CHAT AREA
   =========================== */
.chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100vh;
    background: var(--bg-primary);
    overflow: hidden;
}

/* ===========================
   TOOLBAR (enhanced chat-header)
   =========================== */
.chat-header {
    flex-shrink: 0;
    padding: 10px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
    display: flex;
    gap: 8px;
    align-items: center;
    height: 48px;
    position: relative;
    z-index: 10;
}
.chat-target-label { color: var(--text-secondary); font-size: 12px; flex: 1; }

.chat-toggle-btn {
    background: transparent; border: none; cursor: pointer;
    padding: 4px 6px; border-radius: 4px; color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s, opacity .15s;
}
.chat-toggle-btn:hover { background: var(--accent-dark); color: var(--text-bright); }

.member-toggle-btn {
    background: transparent; border: none; cursor: pointer;
    padding: 4px 6px; border-radius: 4px; color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s;
}
.member-toggle-btn:hover { background: var(--accent-dark); color: var(--text-bright); }
.member-toggle-btn.active { color: var(--text-bright); background: var(--accent-dark); }
.member-toggle-btn svg {
    width: 20px; height: 20px; fill: none; stroke: currentColor;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ===========================
   FLOATING VOICE CONTROLS
   =========================== */
.floating-voice-panel {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-input);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    z-index: 9999;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s 0s;
    opacity: 1;
    visibility: visible;
}
.floating-voice-panel.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s 0.2s;
}
.fv-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--bg-floating);
    color: #b5bac1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    position: relative;
}
.fv-btn:hover { background: #383a40; color: var(--text-bright); }
.fv-btn svg {
    width: 20px; height: 20px; fill: none; stroke: currentColor;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.fv-btn.fv-active { background: #248045; color: #fff; }
.fv-btn.fv-active:hover { background: #1a6334; }
.fv-btn.fv-muted { background: #da373c; color: #fff; }
.fv-btn.fv-muted:hover { background: #c23235; }
.fv-btn-leave { background: #da373c; color: #fff; }
.fv-btn-leave:hover { background: #a12d2f; }
.fv-separator {
    width: 1px;
    height: 32px;
    background: var(--border-dim);
    margin: 0 4px;
    flex-shrink: 0;
}
.fv-btn:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-dark);
    color: var(--text-bright);
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ===========================
   MEDIA + CHAT LAYOUT
   =========================== */

/*
  Дефолт: нет медиа → layout — колонка, media-panel скрыт,
  chat-panel занимает всё.

  Когда есть медиа (.has-media) → layout — строка:
    левая часть (media-panel) = flex:1
    правая часть (chat-panel) = 320px фиксированная боковая панель
*/

.media-chat-layout {
    flex: 1;
    display: flex;
    flex-direction: row;
    min-height: 0;
    overflow: hidden;
}

/* === Медиа-панель === */
.media-panel {
    display: none; /* скрыта пока нет медиа */
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
    background: var(--bg-dark);
    overflow: hidden;
}

/* Когда есть медиа — показываем media-panel */
.media-chat-layout.has-media .media-panel {
    display: flex;
}

/* === Чат-панель === */
.chat-panel {
    display: flex;
    flex-direction: column;
    flex: 1; /* по умолчанию занимает всё */
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

/* Когда есть медиа — чат-панель становится боковой панелью */
.media-chat-layout.has-media .chat-panel {
    flex: 0 0 420px;
    width: 420px;
    background: var(--bg-primary);
    border-left: 1px solid var(--bg-tertiary);
}

/* Скрытие чата при медиа (toggle-кнопка) */
.media-chat-layout.has-media.chat-hidden .chat-panel {
    display: none;
}

/* Сообщения */
.messages {
    flex: 1;
    min-height: 0;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.message { margin-bottom: 16px; display: flex; align-items: flex-start; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--brand); display: flex; align-items: center; justify-content: center; color: white; margin-right: 16px; flex-shrink: 0; }
.message-content { background: var(--bg-accent); padding: 10px; border-radius: 8px; max-width: 100%; }
.message-author { font-weight: bold; color: var(--link); margin-bottom: 4px; font-size: 13px; }
.message-text { color: var(--text-primary); font-size: 14px; word-break: break-word; }

/* Индикатор набора текста */
.typing-indicator { display: flex; align-items: center; gap: 4px; padding: 2px 16px; height: 24px; font-size: 12px; color: var(--text-secondary); flex-shrink: 0; }
.typing-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.typing-dots { display: inline-flex; gap: 1px; margin-left: 2px; }
.typing-dots span { display: inline-block; animation: typingBounce 1.4s infinite; font-weight: 700; font-size: 16px; line-height: 12px; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* @Упоминания */
.mention { color: #dee0fc; background: rgba(88,101,242,0.3); border-radius: 3px; padding: 0 2px; cursor: pointer; }
.mention:hover { background: rgba(88,101,242,0.5); color: #fff; }
.mention-special { background: rgba(88,101,242,0.4); font-weight: 600; }
.mention-special:hover { background: rgba(88,101,242,0.6); }
.message.mentioned { background: rgba(250,166,26,0.08); border-left: 2px solid #faa61a; }

/* Popup автокомплита @упоминаний */
.mention-popup { display: none; background: var(--bg-secondary); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.4); max-height: 240px; overflow-y: auto; padding: 4px 0; flex-shrink: 0; }
.mention-popup-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; }
.mention-popup-item:hover, .mention-popup-item.selected { background: var(--brand); }
.mention-popup-avatar { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-bright); font-weight: 700; font-size: 13px; flex-shrink: 0; }
.mention-popup-name { color: var(--text-bright); font-weight: 600; font-size: 14px; }
.mention-popup-username { color: var(--text-secondary); font-size: 12px; }

/* Markdown стили */
.md-bold { font-weight: 700; color: var(--text-bright); }
.md-italic { font-style: italic; }
.md-strikethrough { text-decoration: line-through; color: #a3a6aa; }
.md-code { font-family: 'Consolas', 'Monaco', 'Courier New', monospace; font-size: 0.85em; color: #e9a0ff; background: var(--bg-secondary); padding: 2px 6px; border-radius: 4px; }
.md-codeblock { font-family: 'Consolas', 'Monaco', 'Courier New', monospace; font-size: 0.875em; background: var(--bg-floating); border: 1px solid var(--bg-input); border-radius: 6px; padding: 10px 12px; margin: 4px 0; overflow-x: auto; }
.md-codeblock code { color: var(--text-primary); white-space: pre; display: block; }

/* Превью ответа над полем ввода */
.reply-preview { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg-secondary); border-left: 3px solid var(--brand); flex-shrink: 0; }
.reply-preview-name { color: var(--text-bright); font-weight: 600; font-size: 13px; white-space: nowrap; }
.reply-preview-text { color: var(--text-secondary); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.reply-preview-close { width: 24px; height: 24px; background: none; border: none; color: var(--text-secondary); cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 4px; padding: 0; }
.reply-preview-close:hover { background: var(--bg-accent); color: var(--text-bright); }

/* Цитата ответа в сообщении */
.reply-quote { display: flex; align-items: center; gap: 6px; padding: 4px 8px; margin-bottom: 4px; border-left: 2px solid var(--accent-dark); font-size: 12px; cursor: pointer; border-radius: 0 4px 4px 0; }
.reply-quote:hover { background: rgba(255,255,255,0.04); }
.reply-quote-name { color: var(--link); font-weight: 600; white-space: nowrap; }
.reply-quote-text { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Подсветка при скролле к цитируемому */
.message.message-highlight { background: rgba(88,101,242,0.15); transition: background 0.3s ease; }

/* Поле ввода */
.input-area { flex-shrink: 0; padding: 8px 12px; height: 56px; background: var(--bg-primary); border-top: 1px solid var(--bg-tertiary); display: flex; align-items: center; gap: 6px; box-sizing: border-box; }
#messageInput { flex: 1; min-width: 0; height: 36px; padding: 0 12px; background: var(--bg-accent); border: 1px solid var(--bg-tertiary); border-radius: 8px; color: var(--text-primary); outline: none; font-size: 14px; box-sizing: border-box; }
#messageInput::placeholder { color: var(--text-muted); }
#sendBtn { flex-shrink: 0; width: 36px; height: 36px; padding: 0; margin: 0; background: var(--brand); border: 1px solid var(--brand); border-radius: 50%; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; box-sizing: border-box; }
#sendBtn:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
/* SVG-иконки в кнопках панели ввода */
.input-action-btn svg, #sendBtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }

/* ===========================
   VIDEO AREA (внутри media-panel)
   =========================== */
.video-area {
    display: none;
    flex-shrink: 0;
}

.video-area.has-video {
    display: flex;
    flex-direction: column;
    /* Высота: JS выставляет через style.height */
}

/* Когда только видео (нет screenshare) — видео занимает весь media-panel */
.media-panel:not(.has-screenshare) .video-area.has-video {
    flex: 1;
    height: auto !important; /* JS не нужен когда flex:1 */
}

.video-grid {
    display: grid;
    gap: 8px;
    padding: 8px;
    flex: 1;
    min-height: 0;
    height: 100%;
    align-items: stretch;
    align-content: start;
}

/* Тайл */
.video-tile {
    position: relative;
    background: #1e2025;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
    transition: border-color 0.15s;
    min-height: 0;
    aspect-ratio: 16 / 9;
}

.video-tile.speaking {
    border-color: #23a55a;
    box-shadow: 0 0 0 2px rgba(35, 165, 90, 0.3);
}

.video-tile video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}

.video-tile.is-local video {
    transform: scaleX(-1);
}

/* Аватар — виден когда нет видео, скрывается когда видео играет */
.video-tile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-bright);
    user-select: none;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    transition: opacity 0.25s;
}

/* Как только видео запустилось — аватар исчезает */
.video-tile.video-playing .video-tile-avatar { opacity: 0; pointer-events: none; }

.video-tile-label {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 24px 10px 8px;
    background: linear-gradient(transparent, rgba(0,0,0,0.72));
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 0 0 10px 10px;
    pointer-events: none;
    z-index: 2;
}

.video-tile-name {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
    max-width: 75%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.video-tile-icons { display: flex; gap: 4px; align-items: center; }
.video-tile-icons .status-icon { width: 16px; height: 16px; opacity: 0.9; }
.video-tile-icons .status-icon svg { width: 16px; height: 16px; fill: none; stroke: #f04747; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.video-tile-icons .status-icon svg .sl { stroke: #f04747; }

/* Кнопка камеры */
#cameraBtn.active { background: #23a55a !important; color: #fff; }

/* ===========================
   SCREENSHARE (внутри media-panel)
   =========================== */
.screen-share-area {
    display: none;
    flex-direction: column;
    padding: 10px;
    background: var(--bg-dark);
    overflow: hidden;
}

/* Когда screenshare активен */
.media-panel.has-screenshare .screen-share-area {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* Когда screenshare + видео: Discord-style — screenshare основной, камеры фиксированные плитки внизу */
.media-panel.has-screenshare.has-cam .screen-share-area { flex: 1; min-height: 0; }
.media-panel.has-screenshare.has-cam .video-area.has-video {
    display: flex !important;
    flex: 0 0 auto;
    height: auto;
    max-height: none;
}
.media-panel.has-screenshare.has-cam .video-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    height: auto;
    flex: 0 0 auto;
    padding: 8px 12px;
}
.media-panel.has-screenshare .video-tile {
    width: 256px;
    height: 192px;
    aspect-ratio: auto;
}
.media-panel.has-screenshare .video-tile video {
    object-fit: cover;
}

.screen-share-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-shrink: 0;
}
.screen-share-title { color: var(--text-bright); font-size: 13px; opacity: 0.9; flex: 1; }

.screen-share-bar button {
    height: 30px;
    min-width: 90px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    margin: 0;
}

.screen-share-toggle { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.08); color: #fff; }
.screen-share-toggle:hover { background: rgba(255,255,255,0.14); }
.screen-share-stop { background: rgba(255,60,60,0.16); border: 1px solid rgba(255,60,60,0.22); color: #fff; }
.screen-share-stop:hover { background: rgba(255,60,60,0.28); }

/* Screenshare floating window */
.screen-share-area.ss-window {
    position: fixed;
    right: 14px; bottom: 14px;
    width: min(820px, calc(100vw - 28px));
    height: min(460px, calc(100vh - 28px));
    z-index: 9999;
    resize: both;
    overflow: hidden;
    box-shadow: 0 16px 40px rgba(0,0,0,0.45);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
}

/* Screenshare grids */
.screen-grid {
    display: grid;
    gap: 8px;
    flex: 1;
    min-height: 0;
    height: 100%;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    align-items: stretch;
}

.screen-grid.ss-single {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    place-items: stretch;
}
.screen-grid.ss-single .screen-tile { height: 100%; min-height: 0; aspect-ratio: auto; cursor: default; }

.screen-grid.ss-fit {
    height: 100%;
    align-items: stretch;
    justify-items: stretch;
}
.screen-grid.ss-fit .screen-tile { height: 100%; min-height: 0; aspect-ratio: auto; }

.ss-focus { display: grid; grid-template-columns: 1fr 260px; gap: 8px; flex: 1; min-height: 0; height: 100%; }
.ss-main { min-width: 0; height: 100%; min-height: 0; display: flex; flex-direction: column; }
.ss-side { display: flex; flex-direction: column; gap: 8px; height: 100%; overflow: auto; min-height: 0; }

/* Screen tile */
.screen-tile {
    position: relative;
    background: #0d0e10;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    min-height: 180px;
    cursor: pointer;
}
.screen-tile.is-main { min-height: 0; }
.ss-focus .ss-main .screen-tile.is-main { flex: 1 1 auto; height: 100%; min-height: 0; aspect-ratio: auto; }
.screen-tile.pinned { outline: 2px solid rgba(88,101,242,0.7); }
.screen-tile video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }

.screen-label {
    position: absolute; left: 10px; top: 10px;
    padding: 4px 8px; border-radius: 8px;
    background: rgba(0,0,0,0.55); color: #fff; font-size: 12px;
    border: 1px solid rgba(255,255,255,0.10);
    display: flex; align-items: center; gap: 10px;
    max-width: calc(100% - 20px);
}
.ss-actions { margin-left: auto; display: flex; gap: 6px; }
.ss-action-btn { width: 24px; height: 24px; border-radius: 6px; cursor: pointer; border: 1px solid rgba(255,255,255,0.14); background: rgba(255,255,255,0.08); color: #fff; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.ss-action-btn:hover { background: rgba(255,255,255,0.14); }

/* ===========================
   AUTH
   =========================== */
.auth {
    display: flex; justify-content: center; align-items: center;
    height: 100vh; width: 100vw;
    background: #313338;
    position: relative; overflow: hidden;
}

/* Анимированные блобы фона */
.auth-bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.auth-bg-blob {
    position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.45;
    animation: authBlobFloat 12s ease-in-out infinite alternate;
}
.auth-bg-blob-1 {
    width: 550px; height: 550px; top: -10%; left: -5%;
    background: radial-gradient(circle, #5865f2 0%, transparent 70%);
}
.auth-bg-blob-2 {
    width: 450px; height: 450px; bottom: -10%; right: -5%;
    background: radial-gradient(circle, #eb459e 0%, transparent 70%);
    animation-delay: -4s; animation-duration: 14s;
}
.auth-bg-blob-3 {
    width: 350px; height: 350px; top: 50%; left: 60%;
    background: radial-gradient(circle, #57f287 0%, transparent 70%);
    animation-delay: -8s; animation-duration: 16s;
}
@keyframes authBlobFloat {
    0% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -20px) scale(1.05); }
    66% { transform: translate(-20px, 30px) scale(0.95); }
    100% { transform: translate(10px, -10px) scale(1.02); }
}

/* Логотип в углу страницы */
.auth-page-brand {
    position: absolute; top: 24px; left: 32px; z-index: 2;
    display: flex; align-items: center; gap: 10px;
}
.auth-page-brand svg { flex-shrink: 0; }
.auth-page-brand-text {
    font-family: 'Raleway', sans-serif;
    font-size: 22px; font-weight: 700;
    letter-spacing: 0.14em; text-transform: uppercase;
    color: #f2f3f5;
}

/* Карточка формы — двухколоночная */
.auth-box {
    position: relative; z-index: 1;
    background: #1e1f22; padding: 32px; border-radius: 8px;
    width: 784px; max-width: 92vw;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    animation: authCardAppear 0.4s ease-out;
    display: flex; align-items: stretch;
}
@keyframes authCardAppear {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-box-left {
    flex: 1; min-width: 0;
}
.auth-box-divider {
    width: 1px; background: #3b3d44;
    margin: 0 32px; flex-shrink: 0;
}
.auth-box-right {
    width: 240px; flex-shrink: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center;
}

/* QR-секция */
.auth-qr-placeholder {
    width: 160px; height: 160px;
    background: #2b2d31; border-radius: 8px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 8px; margin-bottom: 20px;
    border: 1px solid #3b3d44;
}
.auth-qr-soon {
    font-size: 12px; color: #949ba4;
    text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}
.auth-qr-title {
    font-size: 20px; font-weight: 600; color: #f2f3f5;
    margin: 0 0 8px;
}
.auth-qr-desc {
    font-size: 14px; color: #b5bac1; line-height: 1.4;
    margin: 0;
}
.auth-qr-desc strong { color: #f2f3f5; }

/* Заголовки */
.auth-title {
    text-align: center; font-size: 24px; font-weight: 600;
    color: #f2f3f5; margin: 0 0 8px;
}
.auth-subtitle {
    text-align: center; font-size: 14px;
    color: #b5bac1; margin: 0 0 20px;
}

/* Поля формы */
.auth-label {
    display: block; font-size: 12px; font-weight: 700;
    color: #b5bac1; text-transform: uppercase;
    letter-spacing: 0.02em; margin-bottom: 8px;
}
.auth-required { color: #f23f42; }
.auth-box input {
    width: 100%; padding: 10px 12px; margin-bottom: 16px;
    background: #1a1b1e; border: 1px solid var(--border-dim);
    border-radius: 4px; color: #dbdee1; font-size: 15px;
    outline: none; transition: border-color 0.15s;
}
.auth-box input:focus { border-color: var(--brand); }

/* Кнопка входа */
.auth-submit-btn {
    width: 100%; padding: 12px; margin-top: 4px;
    background: var(--brand); border: none; border-radius: 4px;
    color: white; font-size: 15px; font-weight: 500;
    cursor: pointer; transition: background 0.15s;
}
.auth-submit-btn:hover { background: var(--brand-hover); }
.auth-submit-btn:active { background: #3c45a5; }

.auth-forgot-link {
    display: block;
    text-align: right;
    color: #00a8fc;
    font-size: 14px;
    margin: 4px 0 16px;
    cursor: pointer;
    text-decoration: none;
}
.auth-forgot-link:hover { text-decoration: underline; }

/* Переключатель login/register */
.auth-switch {
    margin-top: 12px; font-size: 14px; color: #949ba4;
}
.auth-switch a {
    color: #00a8fc; text-decoration: none; margin-left: 4px;
    font-weight: 500;
}
.auth-switch a:hover { text-decoration: underline; }

/* ===========================
   IMAGE CROPPER MODAL
   =========================== */
.cropper-modal {
    background: var(--bg-floating, #1e1f22);
    border-radius: 8px; width: 620px; max-width: 95vw;
    box-shadow: 0 16px 48px rgba(0,0,0,0.6);
    animation: modalSlideIn 0.15s ease;
    overflow: hidden; display: flex; flex-direction: column;
}
.cropper-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; flex-shrink: 0;
}
.cropper-title { color: var(--text-primary, #f2f3f5); font-size: 18px; font-weight: 600; margin: 0; }
.cropper-close {
    background: none; border: none; color: var(--text-muted, #949ba4);
    cursor: pointer; padding: 4px; display: flex; align-items: center;
    border-radius: 50%; transition: color 0.15s, background 0.15s;
}
.cropper-close:hover { color: var(--text-primary, #f2f3f5); background: rgba(255,255,255,0.1); }
.cropper-body { display: flex; gap: 24px; padding: 0 20px 16px; align-items: flex-start; }
.cropper-canvas-area {
    position: relative; flex-shrink: 0; user-select: none; -webkit-user-select: none;
    touch-action: none; border-radius: 4px; overflow: hidden; background: #000;
}
.cropper-canvas-area img { display: block; pointer-events: none; }
.cropper-dim { position: absolute; background: rgba(0,0,0,0.5); pointer-events: none; }
.cropper-dim-top { top: 0; left: 0; right: 0; }
.cropper-dim-bottom { left: 0; right: 0; bottom: 0; }
.cropper-dim-left { left: 0; }
.cropper-dim-right { right: 0; }
.cropper-selection {
    position: absolute; border: 2px solid #fff; cursor: move;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.3); box-sizing: border-box;
}
.cropper-handle {
    position: absolute; width: 12px; height: 12px;
    background: #fff; border: 1px solid rgba(0,0,0,0.3); border-radius: 50%;
    z-index: 1;
}
.cropper-handle-nw { top: -6px; left: -6px; cursor: nw-resize; }
.cropper-handle-ne { top: -6px; right: -6px; cursor: ne-resize; }
.cropper-handle-se { bottom: -6px; right: -6px; cursor: se-resize; }
.cropper-handle-sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.cropper-preview-section {
    display: flex; flex-direction: column; align-items: center;
    gap: 16px; flex-shrink: 0;
}
.cropper-preview-label {
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.02em; color: var(--text-secondary, #b5bac1); align-self: flex-start;
}
.cropper-preview-circle {
    width: 128px; height: 128px; border-radius: 50%;
    overflow: hidden; background: var(--bg-input, #1a1b1e); flex-shrink: 0;
}
.cropper-preview-square {
    width: 48px; height: 48px; border-radius: 8px;
    overflow: hidden; background: var(--bg-input, #1a1b1e); flex-shrink: 0;
}
.cropper-preview-circle img, .cropper-preview-square img { display: block; pointer-events: none; }
.cropper-footer {
    display: flex; flex-direction: column; gap: 8px;
    padding: 12px 20px; background: var(--bg-secondary, #2b2d31);
}
.cropper-footer-btns {
    display: flex; justify-content: flex-end; gap: 8px;
}
.cropper-zoom-row {
    display: flex; align-items: center; gap: 8px; width: 100%;
}
.cropper-zoom-btn {
    background: none; border: none; color: var(--text-secondary, #b5bac1);
    cursor: pointer; padding: 4px; border-radius: 4px; display: flex; align-items: center;
}
.cropper-zoom-btn:hover { color: var(--text-primary, #fff); background: rgba(255,255,255,0.08); }
.cropper-zoom-slider {
    flex: 1; height: 4px; -webkit-appearance: none; appearance: none;
    background: var(--bg-tertiary, #1e1f22); border-radius: 2px; outline: none;
}
.cropper-zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 14px; height: 14px;
    border-radius: 50%; background: var(--brand); cursor: pointer; border: none;
}
.cropper-zoom-slider::-moz-range-thumb {
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--brand); cursor: pointer; border: none;
}
@media (max-width: 600px) {
    .cropper-modal { width: 100vw; max-width: 100vw; border-radius: 0; }
    .cropper-body { flex-direction: column; align-items: center; }
    .cropper-preview-section { flex-direction: row; gap: 16px; }
}
@media (pointer: coarse) {
    .cropper-handle { width: 20px; height: 20px; }
    .cropper-handle-nw { top: -10px; left: -10px; }
    .cropper-handle-ne { top: -10px; right: -10px; }
    .cropper-handle-se { bottom: -10px; right: -10px; }
    .cropper-handle-sw { bottom: -10px; left: -10px; }
}

.hidden { display: none !important; }
button { background: var(--brand); color: white; border: none; padding: 8px 12px; border-radius: 4px; cursor: pointer; }

/* ===========================
   MISC
   =========================== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.channel-new { animation: fadeIn 0.25s ease; }
@keyframes viewFadeIn { from { opacity: 0; } to { opacity: 1; } }
.view-fade-in { animation: viewFadeIn 0.2s ease; }

.ctxmenu { position: fixed; z-index: 9999; min-width: 190px; padding: 6px; border-radius: 10px; background: rgba(20,20,24,0.98); border: 1px solid rgba(255,255,255,0.08); box-shadow: 0 10px 30px rgba(0,0,0,0.45); color: var(--text-bright); user-select: none; }
.ctxmenu .item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; opacity: 0.95; }
.ctxmenu .item:hover { background: rgba(255,255,255,0.08); opacity: 1; }
.ctxmenu .item.danger { color: #ff6b6b; }
.ctxmenu .sep { height: 1px; margin: 6px 4px; background: rgba(255,255,255,0.08); }

video:fullscreen { object-fit: contain !important; background: #000 !important; }
video:-webkit-full-screen { object-fit: contain !important; background: #000 !important; }

/* ===========================
   CUSTOM MODAL (replaces prompt/confirm/alert)
   =========================== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 99999;
    animation: modalFadeIn 0.15s ease;
}
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 24px;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 16px 40px rgba(0,0,0,0.5);
    animation: modalSlideIn 0.15s ease;
}
@keyframes modalSlideIn { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-title {
    color: var(--text-bright);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}
.modal-label-text {
    color: var(--text-secondary, #b5bac1);
    font-size: 14px;
    margin-bottom: 8px;
}
.modal-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    margin-bottom: 16px;
}
.modal-input:focus { border-color: var(--brand); }
.modal-text {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.5;
}
.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.modal-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    margin: 0;
}
.modal-btn-cancel { background: var(--accent-dark); color: var(--text-bright); }
.modal-btn-cancel:hover { background: #5d6269; }
.modal-btn-ok { background: var(--brand); color: var(--text-bright); }
.modal-btn-ok:hover { background: var(--brand-hover); }
.modal-btn-danger { background: var(--danger); color: var(--text-bright); }
.modal-btn-danger:hover { background: #d63638; }

/* ===========================
   ATTACHMENTS & VOICE MESSAGES
   =========================== */

/* Кнопки действий в поле ввода (📎 и 🎤) */
.input-action-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--bg-accent);
    border: 1px solid var(--bg-tertiary);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    margin: 0;
    box-sizing: border-box;
}
.input-action-btn:hover {
    background: var(--accent-dark);
    color: var(--text-primary);
}

/* Превью файлов перед отправкой */
.attachment-preview {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--bg-tertiary);
}
.attachment-preview-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-accent);
    padding: 6px 10px;
    border-radius: 8px;
    max-width: 200px;
}
.attachment-preview-item img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}
.file-icon { font-size: 24px; }
.file-name {
    font-size: 12px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100px;
}
.file-remove {
    width: 20px;
    height: 20px;
    padding: 0;
    margin: 0;
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.file-remove:hover { color: #ff6b6b; }

/* Вложения внутри сообщений */
.message-attachments {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.attachment-image {
    max-width: 400px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
}
.attachment-image img {
    max-width: 100%;
    max-height: 300px;
    display: block;
    border-radius: 8px;
}
.attachment-image img:hover { opacity: 0.9; }
.attachment-file-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-secondary);
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--bg-tertiary);
    text-decoration: none;
    color: var(--text-primary);
    max-width: 400px;
    transition: background 0.15s;
}
.attachment-file-card:hover { background: var(--bg-primary); }
.file-card-icon { font-size: 28px; flex-shrink: 0; }
.file-card-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-card-name { font-size: 14px; color: var(--link); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card-size { font-size: 11px; color: var(--text-muted); }
.file-card-download { font-size: 18px; color: var(--text-secondary); flex-shrink: 0; }

/* Голосовой плеер */
.voice-player {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-secondary);
    padding: 10px 14px;
    border-radius: 20px;
    min-width: 200px;
    max-width: 320px;
    margin-top: 4px;
}
.voice-play-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    background: var(--brand);
    border: none;
    color: var(--text-bright);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.voice-play-btn:hover { background: var(--brand-hover); }
.voice-waveform {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 2px;
    height: 24px;
}
.waveform-bar {
    width: 3px;
    background: var(--accent-dark);
    border-radius: 2px;
    transition: background 0.1s;
}
.waveform-bar.active { background: var(--brand); }
.voice-duration {
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
    min-width: 32px;
    text-align: right;
}

/* Индикатор записи */
.recording-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--bg-tertiary);
    font-size: 13px;
    color: var(--danger);
}
.rec-dot {
    width: 10px;
    height: 10px;
    background: var(--danger);
    border-radius: 50%;
    animation: recBlink 1s infinite;
}
@keyframes recBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
.rec-text { color: var(--text-primary); }
.rec-timer { color: var(--text-secondary); margin-left: auto; }

/* Кнопка микрофона в режиме записи */
.input-action-btn.recording {
    background: var(--danger);
    color: var(--text-bright);
    animation: recBlink 1s infinite;
}

/* Drag-and-drop подсветка */
.messages.drag-over {
    outline: 2px dashed var(--brand);
    outline-offset: -4px;
    background: rgba(88, 101, 242, 0.05);
}

/* ===========================
   MESSAGE CONTEXT MENU & EDITING
   =========================== */

/* Иконка в пункте контекстного меню */
.ctxmenu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-right: 8px;
}
.ctxmenu-icon svg {
    width: 16px;
    height: 16px;
}
.ctxmenu .item {
    display: flex;
    align-items: center;
}
.ctxmenu .item.danger .ctxmenu-icon svg {
    stroke: #ff6b6b;
}

/* Метка "(изм.)" */
.message-edited-badge {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 4px;
}

/* Подсветка сообщения при ховере */
.message {
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s;
}
.message:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Инлайн-редактирование сообщения */
.message-edit-input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--brand);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    margin-top: 2px;
    resize: vertical;
    min-height: 36px;
    max-height: 200px;
}
.message-edit-input:focus {
    border-color: #7983f5;
    box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.25);
}
.message-edit-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    padding-left: 2px;
}

/* Визуальная индикация режима редактирования */
.message.editing .message-content {
    background: #383a40;
    border-left: 2px solid var(--brand);
}

/* Анимация удаления сообщения */
@keyframes messageDeleteFade {
    from { opacity: 1; max-height: 300px; margin-bottom: 16px; }
    to   { opacity: 0; max-height: 0; margin-bottom: 0; overflow: hidden; }
}
.message.message-deleting {
    animation: messageDeleteFade 0.3s ease forwards;
    pointer-events: none;
}

/* ===========================
   MEMBERS PANEL (правый сайдбар)
   =========================== */
.members-panel {
    width: 240px; flex-shrink: 0; background: var(--bg-secondary);
    display: flex; flex-direction: column; height: 100vh;
    border-left: 1px solid var(--bg-tertiary); overflow-y: auto;
    transition: width 0.25s ease, opacity 0.2s ease, border-color 0.25s ease;
}
.members-panel.collapsed {
    width: 0; min-width: 0; opacity: 0; overflow: hidden;
    border-left-color: transparent;
}
.members-header {
    padding: 12px 16px; font-size: 12px; text-transform: uppercase;
    color: var(--text-muted); font-weight: 600; letter-spacing: 0.3px;
    display: flex; justify-content: space-between; align-items: center; flex-shrink: 0;
}
.members-header-right {
    display: flex; align-items: center; gap: 8px;
}
.members-invite-btn {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 4px; border-radius: 4px; display: flex; align-items: center; justify-content: center;
    transition: color 0.15s, background 0.15s;
}
.members-invite-btn:hover {
    color: var(--text-primary); background: var(--bg-accent);
}
.members-count {
    background: var(--bg-accent); color: var(--text-secondary); border-radius: 12px;
    padding: 1px 7px; font-size: 11px;
}
.members-section-title {
    padding: 16px 16px 4px; font-size: 11px; text-transform: uppercase;
    color: var(--text-muted); font-weight: 600; letter-spacing: 0.3px;
}
.members-list { flex: 1; overflow-y: auto; padding: 0 8px; }
.member-item {
    display: flex; align-items: center; padding: 6px 8px;
    border-radius: 4px; cursor: pointer; transition: background 0.15s; gap: 10px;
}
.member-item:hover { background: rgba(255,255,255,0.04); }
.member-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 14px;
    flex-shrink: 0; position: relative; overflow: visible;
}
.member-status-dot {
    position: absolute; bottom: -1px; right: -1px;
    width: 10px; height: 10px; border-radius: 50%;
    border: 2px solid var(--bg-secondary, #2b2d31);
    box-shadow: 0 0 0 1px var(--bg-secondary, #2b2d31);
}
.member-status-dot.online  { background: #23a55a; }
.member-status-dot.idle    { background: #f0b232; }
.member-status-dot.dnd     { background: #f23f42; }
.member-status-dot.offline { background: #80848e; }
.member-status-dot.invisible { background: #80848e; }
.member-name {
    font-size: 14px; color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.discriminator { color: var(--text-muted); font-size: 0.85em; }
.member-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.member-custom-status { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 3px; border: 1px solid; margin-left: 4px; vertical-align: middle; }
.role-manager-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--bg-tertiary); }
.role-color-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.role-manager-name { flex: 1; color: var(--text-primary); font-size: 14px; }
.role-manager-btn { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 16px; padding: 2px 6px; border-radius: 4px; }
.role-manager-btn:hover { background: rgba(255,255,255,0.1); color: var(--text-bright); }
.role-manager-btn.danger:hover { color: var(--danger); }
.roles-manager-modal { min-width: 320px; }
.member-item.offline .member-name { color: var(--text-muted); }
.member-item.offline .member-avatar { opacity: 0.4; }

/* ===========================
   FRIENDS VIEW
   =========================== */
.friends-view {
    flex: 1; display: flex; flex-direction: column;
    background: var(--bg-primary); min-width: 0; position: relative;
}
.friends-view .user-bar {
    position: relative; width: 100%; flex-shrink: 0;
    border-top: 1px solid var(--bg-tertiary);
}
.friends-header {
    flex-shrink: 0; padding: 10px 20px; background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary); display: flex;
    align-items: center; gap: 16px; height: 48px;
}
.friends-title { color: var(--text-bright); font-weight: 600; font-size: 16px; }
.friends-tabs { display: flex; gap: 4px; }
.friends-tab {
    padding: 4px 12px; border-radius: 4px; background: transparent;
    color: var(--text-secondary); border: none; cursor: pointer; font-size: 13px; margin: 0;
}
.friends-tab:hover { background: var(--bg-accent); color: var(--text-primary); }
.friends-tab.active { background: var(--bg-accent); color: var(--text-bright); }
.dm-tab { margin-left: auto; }
.add-friend-tab { background: #248046; color: var(--text-bright); }
.add-friend-tab:hover { background: var(--green-dark); color: var(--text-bright); }
.add-friend-tab.active { background: #248046; color: var(--text-bright); }
.add-friend-section {
    padding: 16px 20px; border-bottom: 1px solid var(--bg-tertiary);
    flex: 1;
}
.add-friend-hint {
    color: var(--text-secondary); font-size: 13px; margin-bottom: 12px;
}
.add-friend-row {
    display: flex; gap: 8px;
}
.add-friend-input {
    flex: 1; padding: 10px 12px; border-radius: 6px;
    background: var(--bg-tertiary); border: 1px solid #040405;
    color: var(--text-primary); font-size: 14px; outline: none;
}
.add-friend-input:focus { border-color: var(--brand); }
.add-friend-btn {
    padding: 10px 20px; border-radius: 6px; border: none;
    background: var(--brand); color: var(--text-bright); font-size: 14px;
    cursor: pointer; white-space: nowrap; margin: 0;
}
.add-friend-btn:hover { background: var(--brand-hover); }
.add-friend-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.add-friend-status {
    margin-top: 8px; font-size: 13px; min-height: 18px;
}
.add-friend-status.success { color: #43b581; }
.add-friend-status.error { color: var(--danger); }
.friends-list { flex: 1; overflow-y: auto; padding: 16px; }
.friend-item {
    display: flex; align-items: center; padding: 10px 12px;
    border-radius: 6px; gap: 12px; transition: background 0.15s;
}
.friend-item:hover { background: rgba(255,255,255,0.04); }
.friend-actions { margin-left: auto; display: flex; gap: 6px; }
.friend-action-btn {
    width: 32px; height: 32px; border-radius: 50%; border: none;
    background: var(--bg-secondary); color: var(--text-secondary); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; margin: 0; padding: 0;
}
.friend-action-btn:hover { background: var(--bg-accent); color: var(--text-bright); }
.friend-action-btn.accept { color: #43b581; }
.friend-action-btn.decline { color: var(--danger); }
.pending-badge {
    position: absolute; top: -2px; right: -2px;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--danger); color: var(--text-bright); font-size: 9px;
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.friends-tab { position: relative; }
.tab-badge {
    position: absolute; top: -4px; right: -4px;
    min-width: 16px; height: 16px; border-radius: 8px;
    background: var(--danger); color: var(--text-bright); font-size: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; padding: 0 4px; pointer-events: none;
}
/* Бейдж непрочитанных на сервере — белый кружок */
.server-unread-badge {
    position: absolute; bottom: -1px; right: -1px;
    width: 8px; height: 8px; border-radius: 50%;
    background: #fff; pointer-events: none;
    box-shadow: 0 0 0 2px var(--bg-tertiary, #202225);
}
/* Бейдж упоминаний — красный с числом */
.server-unread-badge.server-mention-badge {
    width: auto; height: 16px; min-width: 16px;
    border-radius: 8px; padding: 0 4px;
    background: var(--danger); color: var(--text-bright); font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    bottom: -4px; right: -4px;
}
.server-sep {
    width: 32px; height: 2px; background: var(--bg-primary);
    border-radius: 1px; margin: 4px auto 8px;
}

/* ===========================
   PROFILE CARD
   =========================== */
@keyframes profileCardIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.profile-card {
    position: fixed; z-index: 10000; width: 300px;
    background: var(--bg-secondary); border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    animation: profileCardIn 0.15s ease; overflow: hidden;
}
.profile-card-banner { height: 60px; }
.profile-card-avatar-wrap { position: relative; padding: 0 16px; margin-top: -30px; }
.profile-card-avatar {
    width: 80px; height: 80px; border-radius: 50%;
    border: 6px solid var(--bg-secondary); display: flex; align-items: center;
    justify-content: center; color: var(--text-bright); font-weight: 700;
    font-size: 28px; position: relative;
}
.profile-card-status-dot {
    position: absolute; bottom: 2px; right: 2px;
    width: 16px; height: 16px; border-radius: 50%;
    border: 4px solid var(--bg-secondary);
}
.profile-card-status-dot.online { background: #23a55a; }
.profile-card-status-dot.idle { background: #f0b232; }
.profile-card-status-dot.dnd { background: #f23f42; }
.profile-card-status-dot.offline { background: #80848e; }
.profile-card-status-dot.invisible { background: #80848e; }
.profile-card-body { padding: 12px 16px; }
.profile-card-name { font-size: 20px; font-weight: 700; color: var(--text-bright); margin-bottom: 2px; }
.profile-card-custom-status { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.profile-card-role { font-size: 12px; color: var(--text-primary); margin-bottom: 8px; display: flex; align-items: center; }
.profile-card-sep { height: 1px; background: var(--bg-tertiary); margin: 8px 0; }
.profile-card-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-secondary); letter-spacing: 0.02em; margin-bottom: 4px; }
.profile-card-about { font-size: 13px; color: var(--text-primary); word-break: break-word; margin-bottom: 8px; }
.profile-card-add-friend {
    width: 100%; padding: 8px; background: var(--brand); color: var(--text-bright);
    border: none; border-radius: 4px; cursor: pointer; font-size: 13px;
    font-weight: 600; margin-top: 8px; transition: background 0.2s;
}
.profile-card-add-friend:hover { background: var(--brand-hover); }

/* ===== Presence-индикатор ===== */
.presence-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2.5px solid var(--bg-secondary);
    cursor: pointer;
    z-index: 2;
}
.presence-online    { background: #23a55a; }
.presence-idle      { background: #f0b232; }
.presence-dnd       { background: #f23f42; }
.presence-invisible { background: #80848e; }
.presence-offline   { background: #80848e; }

/* ===== Пагинация сообщений ===== */
.messages-loading {
    text-align: center;
    padding: 12px;
    color: var(--text-muted);
    font-size: 13px;
}

/* Loading spinner (bouncing dots) */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 40px 0;
}
.loading-spinner-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted, #72767d);
    animation: typingBounce 1.4s infinite;
}
.loading-spinner-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-spinner-dot:nth-child(3) { animation-delay: 0.4s; }

/* Skeleton shimmer */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.skeleton-shimmer {
    background: linear-gradient(90deg, var(--bg-tertiary, #2b2d31) 25%, #393c41 50%, var(--bg-tertiary, #2b2d31) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}
.channel-skeleton {
    height: 32px;
    margin: 4px 8px;
}
.channel-skeleton-header {
    height: 10px;
    width: 55%;
    margin: 16px 8px 6px;
}

/* Auth button disabled */
.auth-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* ===== Direct Messages (DM) ===== */
.dm-friends-btn {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    margin: 4px 0 2px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-primary);
    font-weight: 500;
    transition: background 0.15s;
}
.dm-friends-btn svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dm-friends-btn:hover { background: var(--bg-accent); color: var(--text-bright); }
.dm-friends-btn .unread-badge {
    margin-left: auto;
    background: var(--danger);
    color: var(--text-bright);
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.dm-list-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 12px 10px 4px;
    letter-spacing: 0.02em;
}

.dm-channel {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}
.dm-channel:hover { background: var(--bg-accent); }
.dm-channel.active { background: var(--bg-accent); }
.dm-channel.unread .dm-channel-name { color: var(--text-bright); font-weight: 600; }

.dm-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-bright);
    font-weight: 700;
    font-size: 14px;
    position: relative;
}

.dm-status-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2.5px solid var(--bg-secondary);
}

.dm-channel-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.dm-channel-name {
    font-size: 14px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dm-channel.active .dm-channel-name { color: var(--text-bright); }

.dm-channel-preview {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dm-channel .unread-badge {
    background: var(--danger);
    color: var(--text-bright);
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    flex-shrink: 0;
}

/* ===== Search ===== */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
    margin-left: auto;
    margin-right: 4px;
}

.search-toggle-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}
.search-toggle-btn:hover { color: var(--text-primary); }

.search-input {
    width: 200px;
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    margin-left: 4px;
}
.search-input::placeholder { color: var(--text-muted); }

.search-results-panel {
    position: fixed;
    top: 48px;
    right: 240px;
    width: 420px;
    max-width: calc(100vw - 320px);
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 10000;
    padding: 8px 0;
}

.search-result-item {
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.1s;
}
.search-result-item:hover { background: var(--bg-accent); }

.search-result-context {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.search-result-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-bright);
    margin-bottom: 2px;
}

.search-result-text {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-date {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.search-no-results {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
    font-size: 13px;
}

/* ===== DM Calls ===== */
.dm-call-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
    animation: fadeInSimple 0.2s ease;
}
.dm-call-overlay.hidden { display: none; }

.dm-call-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    min-width: 300px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
    animation: profileCardIn 0.2s ease;
}

.dm-call-avatar {
    width: 80px; height: 80px;
    border-radius: 50%;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 28px;
    animation: callPulse 2s ease-in-out infinite;
}

@keyframes callPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(87, 242, 135, 0.4); }
    50% { box-shadow: 0 0 0 20px rgba(87, 242, 135, 0); }
}

.dm-call-caller {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 4px;
}

.dm-call-type {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.dm-call-actions {
    display: flex;
    gap: 24px;
    justify-content: center;
}

.dm-call-btn {
    width: 56px; height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, background 0.15s;
}
.dm-call-btn:hover { transform: scale(1.1); }

.dm-call-btn.accept { background: #3ba55d; color: #fff; }
.dm-call-btn.accept:hover { background: #2d8049; }
.dm-call-btn.decline { background: var(--danger); color: var(--text-bright); }
.dm-call-btn.decline:hover { background: #c73e3e; }

/* Кнопки звонка в шапке DM-чата */
.dm-call-header-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}
.dm-call-header-btn:hover { color: var(--text-bright); }

/* Таймер звонка в шапке */
.dm-call-timer {
    font-size: 12px;
    color: #3ba55d;
    font-weight: 600;
    margin-left: 8px;
}

/* Кнопка завершения звонка */
.dm-call-hangup-btn {
    background: var(--danger);
    border: none;
    color: var(--text-bright);
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s;
    margin-left: 8px;
}
.dm-call-hangup-btn:hover { background: #c73e3e; }

/* Системное сообщение звонка */
.message.system-call-msg {
    text-align: center;
    padding: 8px 16px;
}
.message.system-call-msg .message-text {
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
}

/* Анимированные точки «Вызов...» для исходящего звонка */
.dm-call-status-text::after {
    content: '';
    animation: dotPulse 1.4s infinite steps(4, end);
}
@keyframes dotPulse {
    0%   { content: ''; }
    25%  { content: '.'; }
    50%  { content: '..'; }
    75%  { content: '...'; }
    100% { content: ''; }
}

@keyframes fadeInSimple {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===========================
   EMOJI REACTIONS
   =========================== */
.reactions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 14px;
    background: var(--bg-primary);
    border: 1px solid var(--accent-dark);
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1.4;
}

.reaction-pill:hover {
    background: var(--accent-dark);
}

.reaction-pill.reaction-mine {
    border-color: var(--brand);
    background: #2d3040;
}

.reaction-pill.reaction-mine:hover {
    background: #3a3d55;
}

.reaction-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    font-size: 16px;
    color: #b5bac1;
    background: transparent;
    border: 1px dashed var(--accent-dark);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    line-height: 1;
}

.reaction-add-btn:hover {
    background: var(--accent-dark);
    color: var(--text-bright);
    border-color: #b5bac1;
}

/* Полный emoji picker */
.emoji-picker-full {
    position: fixed;
    z-index: 10001;
    width: 352px;
    max-height: 420px;
    background: var(--bg-floating, #2b2d31);
    border: 1px solid var(--bg-input);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    animation: fadeInSimple 0.1s ease;
    overflow: hidden;
}

.emoji-picker-search {
    padding: 8px;
    border-bottom: 1px solid var(--border-subtle, #3f4147);
}

.emoji-search-input {
    width: 100%;
    padding: 6px 10px;
    background: var(--bg-input, #1e1f22);
    border: none;
    border-radius: 4px;
    color: var(--text-primary, #f2f3f5);
    font-size: 14px;
    outline: none;
    box-sizing: border-box;
}
.emoji-search-input:focus {
    box-shadow: 0 0 0 2px var(--brand, #5865f2);
}

.emoji-quick-row {
    display: flex;
    gap: 2px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-subtle, #3f4147);
}

.emoji-category-tabs {
    display: flex;
    gap: 0;
    padding: 0 4px;
    border-bottom: 1px solid var(--border-subtle, #3f4147);
    overflow-x: auto;
    flex-shrink: 0;
}
.emoji-category-tabs::-webkit-scrollbar { height: 0; }

.emoji-category-tab {
    padding: 6px 8px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.15s, border-color 0.15s;
    flex-shrink: 0;
}
.emoji-category-tab:hover,
.emoji-category-tab.active {
    opacity: 1;
    border-bottom-color: var(--brand, #5865f2);
}

.emoji-content-area {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
    min-height: 0;
}

.emoji-category-section {
    margin-bottom: 8px;
}

.emoji-category-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted, #949ba4);
    padding: 8px 2px 4px;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}

.emoji-picker-btn {
    width: 36px;
    height: 36px;
    font-size: 20px;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
}

.emoji-picker-btn:hover {
    background: var(--bg-primary);
    transform: scale(1.2);
}

/* Легаси (не используется) */
.emoji-picker {
    position: fixed;
    z-index: 10001;
    background: var(--bg-floating);
    border: 1px solid var(--bg-input);
    border-radius: 8px;
    padding: 6px;
    display: flex;
    gap: 2px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    animation: fadeInSimple 0.1s ease;
}

/* ===========================
   CHANNEL INVITE BUTTON
   =========================== */
.channel-invite-btn {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    margin-left: auto;
    flex-shrink: 0;
    transition: color 0.15s, opacity 0.15s;
    line-height: 0;
}
.channel:hover .channel-invite-btn { opacity: 1; }
.channel-invite-btn:hover { color: var(--text-primary); }
.channel-invite-btn svg { display: block; }
.channel-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-voice-icon { display: flex; align-items: center; flex-shrink: 0; }
.channel.voice-channel .channel-label { text-align: center; }
.channel.voice-channel .channel-invite-btn { margin-left: 4px; }

/* ===========================
   INVITE FRIENDS MODAL
   =========================== */
.invite-friends-modal {
    background: var(--bg-floating);
    border-radius: 8px;
    width: 460px;
    max-width: 95vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    animation: fadeInSimple 0.15s ease;
    overflow: hidden;
}
.invite-friends-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 20px 0;
    flex-shrink: 0;
}
.invite-friends-title {
    color: var(--text-bright);
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
    word-break: break-word;
    padding-right: 12px;
}
.invite-friends-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    border-radius: 50%;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}
.invite-friends-close:hover { color: var(--text-bright); background: rgba(255,255,255,0.1); }
.invite-friends-close svg { display: block; }
.invite-friends-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    padding: 6px 20px 0;
    margin: 0;
    flex-shrink: 0;
}
.invite-friends-search {
    display: block;
    width: calc(100% - 40px);
    margin: 12px 20px 8px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--bg-input);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    flex-shrink: 0;
    box-sizing: border-box;
}
.invite-friends-search:focus { border-color: var(--brand); }
.invite-friends-search::placeholder { color: #6d6f78; }
.invite-friends-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px;
    max-height: 260px;
    min-height: 60px;
}
.invite-friends-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
    font-size: 13px;
}
.invite-friends-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.15s;
}
.invite-friends-row:hover { background: rgba(255,255,255,0.04); }
.invite-friends-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-bright);
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
.invite-friends-info { flex: 1; min-width: 0; }
.invite-friends-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.invite-friends-username {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.invite-friends-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 4px;
    background: var(--brand);
    color: var(--text-bright);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
    transition: background 0.15s;
}
.invite-friends-btn:hover:not(:disabled) { background: var(--brand-hover); }
.invite-friends-btn.invited,
.invite-friends-btn:disabled {
    background: transparent;
    border: 1px solid var(--accent-dark);
    color: var(--text-muted);
    cursor: default;
}
.invite-friends-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px 0;
    flex-shrink: 0;
}
.invite-friends-divider-line { flex: 1; height: 1px; background: var(--border-dim); }
.invite-friends-divider-text {
    color: #6d6f78;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
}
.invite-friends-link-section { padding: 12px 20px 20px; flex-shrink: 0; }
.invite-friends-link-label { color: var(--text-secondary); font-size: 12px; margin: 0 0 8px; }
.invite-friends-link-row { display: flex; gap: 8px; align-items: center; }
.invite-friends-link-input {
    flex: 1;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-dim);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 13px;
    outline: none;
    min-width: 0;
}
.invite-friends-copy-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    background: var(--brand);
    color: var(--text-bright);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
    transition: background 0.15s;
}
.invite-friends-copy-btn:hover:not(:disabled) { background: var(--brand-hover); }
.invite-friends-copy-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.invite-friends-expire { margin: 8px 0 0; font-size: 11px; color: #6d6f78; }

/* ===========================
   USER SETTINGS VIEW
   =========================== */
.settings-view {
    position: fixed; inset: 0; display: flex; z-index: 30000;
    background: rgba(0, 0, 0, 0.7);
    align-items: center; justify-content: center;
    animation: modalFadeIn 0.2s ease;
}
.settings-view.hidden { display: none !important; }
.settings-modal {
    display: flex; width: 900px; max-width: 95vw; height: 620px; max-height: 90vh;
    border-radius: 8px; overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    position: relative;
}

/* Левый сайдбар */
.settings-sidebar {
    width: 218px; flex-shrink: 0; background: var(--bg-secondary);
    display: flex; flex-direction: column; overflow: hidden;
}
.settings-sidebar-scroll {
    flex: 1; overflow-y: auto; padding: 20px 6px 20px 20px;
}
.settings-nav-label {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.02em; color: var(--text-muted); padding: 6px 10px; margin-top: 4px;
}
.settings-nav-item {
    display: block; width: 100%; text-align: left; padding: 6px 10px;
    border: none; border-radius: 4px; background: transparent;
    color: var(--text-secondary); font-size: 14px; cursor: pointer;
    margin-bottom: 2px; transition: background 0.15s, color 0.15s;
}
.settings-nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text-primary); }
.settings-nav-item.active { background: rgba(255,255,255,0.06); color: var(--text-bright); }
.settings-nav-danger { color: var(--danger) !important; }
.settings-nav-danger:hover { background: rgba(237,66,69,0.1) !important; color: var(--danger) !important; }
.settings-nav-sep { height: 1px; background: var(--border-dim); margin: 8px 10px; }

/* Правая контент-область */
.settings-content {
    flex: 1; background: var(--bg-primary); position: relative; display: flex; min-width: 0;
}
.settings-content-scroll {
    flex: 1; overflow-y: auto; padding: 30px 32px 40px; max-width: 740px;
}

/* Кнопка закрытия */
.settings-close-btn {
    position: absolute; top: 16px; right: 16px;
    width: 32px; height: 32px; border-radius: 4px;
    border: none; background: transparent;
    color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: color 0.15s, background 0.15s; padding: 0;
}
.settings-close-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.1); }
.settings-close-btn svg {
    width: 20px; height: 20px; fill: none; stroke: currentColor;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* Шестерёнка настроек — теперь в servers sidebar как server-icon */

/* ===== Секции контента ===== */
.settings-section-title {
    font-size: 20px; font-weight: 600; color: var(--text-bright); margin-bottom: 20px;
}
.settings-section-subtitle {
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.02em; color: var(--text-secondary); margin-bottom: 8px;
}

/* Карточка аккаунта */
.settings-account-card { background: var(--bg-floating); border-radius: 8px; overflow: hidden; }
.settings-account-banner { height: 100px; position: relative; }
.settings-account-info {
    padding: 16px; display: flex; align-items: flex-end; gap: 16px;
    margin-top: -40px; position: relative;
}
.settings-account-avatar {
    width: 80px; height: 80px; border-radius: 50%;
    border: 6px solid var(--bg-floating);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-bright); font-weight: 700; font-size: 28px;
    cursor: pointer; position: relative; flex-shrink: 0;
    overflow: hidden; background-size: cover; background-position: center;
}
.settings-account-avatar img {
    width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.settings-avatar-overlay {
    position: absolute; inset: 0; background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.15s; border-radius: 50%;
    font-size: 10px; font-weight: 700; text-transform: uppercase; color: #fff;
}
.settings-account-avatar:hover .settings-avatar-overlay { opacity: 1; }
.settings-account-name { font-size: 20px; font-weight: 600; color: var(--text-bright); }

/* Поля формы */
.settings-fields { padding: 16px; }
.settings-field { margin-bottom: 20px; }
.settings-field-label {
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.02em; color: var(--text-secondary); margin-bottom: 8px;
}
.settings-field-value {
    display: flex; align-items: center; justify-content: space-between;
}
.settings-field-text { color: var(--text-primary); font-size: 16px; }
.settings-field-input {
    width: 100%; padding: 10px; background: var(--bg-input);
    border: 1px solid var(--bg-input); border-radius: 4px;
    color: var(--text-primary); font-size: 16px; outline: none;
}
.settings-field-input:focus { border-color: var(--brand); }
.settings-field-textarea {
    width: 100%; padding: 10px; background: var(--bg-input);
    border: 1px solid var(--bg-input); border-radius: 4px;
    color: var(--text-primary); font-size: 14px; outline: none;
    resize: vertical; min-height: 80px; font-family: inherit;
}
.settings-field-textarea:focus { border-color: var(--brand); }

.settings-edit-btn {
    padding: 4px 16px; background: var(--accent-dark); border: none; border-radius: 4px;
    color: var(--text-bright); font-size: 13px; cursor: pointer; transition: background 0.15s;
    white-space: nowrap; flex-shrink: 0;
}
.settings-edit-btn:hover { background: #686d73; }

/* Профиль: превью */
.settings-profile-preview { display: flex; gap: 40px; align-items: flex-start; }
.settings-profile-form { flex: 1; min-width: 0; }
.settings-profile-card-preview {
    width: 300px; flex-shrink: 0; background: var(--bg-dark);
    border-radius: 8px; overflow: hidden;
}

/* Палитра цветов */
.settings-color-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; margin-bottom: 24px; }
.settings-color-swatch {
    width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
    border: 3px solid transparent; transition: border-color 0.15s, transform 0.1s;
}
.settings-color-swatch:hover { transform: scale(1.1); }
.settings-color-swatch.active { border-color: #fff; }

/* Пароль */
.settings-password-fields { max-width: 420px; }
.settings-save-btn {
    padding: 8px 24px; background: #248046; border: none; border-radius: 4px;
    color: var(--text-bright); font-size: 14px; font-weight: 500; cursor: pointer;
    margin-top: 16px; transition: background 0.15s;
}
.settings-save-btn:hover { background: var(--green-dark); }

/* Тема */
.settings-theme-grid { display: flex; gap: 16px; margin-bottom: 24px; }
.settings-theme-option {
    flex: 1; padding: 16px; border-radius: 8px;
    border: 2px solid transparent; background: var(--bg-floating);
    cursor: pointer; text-align: center; transition: border-color 0.15s;
}
.settings-theme-option:hover { border-color: var(--brand); }
.settings-theme-option.active { border-color: var(--brand); }
.settings-theme-preview {
    width: 100%; height: 60px; border-radius: 4px; margin-bottom: 8px;
}
.settings-theme-label { font-size: 14px; color: var(--text-primary); font-weight: 500; }

/* Селектор */
.settings-select-row {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; padding: 12px 0; border-bottom: 1px solid var(--border-dim);
}
.settings-select-label { color: var(--text-primary); font-size: 16px; }
.settings-select {
    padding: 6px 12px; background: var(--bg-input);
    border: 1px solid var(--border-dim); border-radius: 4px;
    color: var(--text-primary); font-size: 14px; outline: none;
}

/* Кастомный Discord-style dropdown */
.custom-select {
    position: relative; min-width: 200px;
}
.custom-select-trigger {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 8px 12px; background: var(--bg-tertiary); border: none;
    border-radius: 4px; color: var(--text-primary); font-size: 14px;
    cursor: pointer; transition: background 0.15s;
    user-select: none;
}
.custom-select-trigger:hover { background: var(--bg-accent); }
.custom-select.open .custom-select-trigger { background: var(--bg-accent); }
.custom-select-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-select-arrow {
    display: flex; align-items: center; color: var(--text-muted);
    transition: transform 0.2s;
}
.custom-select.open .custom-select-arrow { transform: rotate(180deg); }
.custom-select-options {
    display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: var(--bg-floating); border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3); z-index: 100;
    max-height: 200px; overflow-y: auto; padding: 4px;
}
.custom-select.open .custom-select-options { display: block; }
.custom-select-option {
    padding: 8px 10px; border-radius: 3px; color: var(--text-secondary);
    font-size: 14px; cursor: pointer; transition: background 0.1s, color 0.1s;
}
.custom-select-option:hover { background: var(--bg-accent); color: var(--text-primary); }
.custom-select-option.selected { background: rgba(88, 101, 242, 0.15); color: var(--text-bright); }

/* Описание в настройках */
.settings-description {
    color: var(--text-muted); font-size: 13px; margin-bottom: 12px; line-height: 1.4;
}

/* Слайдер чувствительности ввода (двухцветный оранжевый/зелёный) */
.sensitivity-slider-row {
    padding: 8px 0 16px; margin-bottom: 12px; border-bottom: 1px solid var(--border-dim);
}
.sensitivity-slider {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 8px; border-radius: 4px; outline: none; cursor: pointer;
    --sens-pct: 50%;
    background: linear-gradient(to right,
        #e8a33a 0%, #e8a33a var(--sens-pct),
        #43b581 var(--sens-pct), #43b581 100%
    );
}
.sensitivity-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px; border-radius: 50%;
    background: #fff; cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.sensitivity-slider::-moz-range-thumb {
    width: 18px; height: 18px; border-radius: 50%; border: none;
    background: #fff; cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Toggle-переключатель (Discord-style) */
.settings-toggle-row {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-dim);
}
.settings-toggle-label { color: var(--text-primary); font-size: 15px; flex: 1; }
.settings-toggle {
    width: 44px; height: 24px; border-radius: 12px; background: var(--text-muted);
    cursor: pointer; position: relative; transition: background 0.2s; flex-shrink: 0;
}
.settings-toggle.active { background: #23a55a; }
.settings-toggle-knob {
    width: 18px; height: 18px; border-radius: 50%; background: #fff;
    position: absolute; top: 3px; left: 3px; transition: left 0.2s;
}
.settings-toggle.active .settings-toggle-knob { left: 23px; }

/* Слайдер громкости */
.settings-slider-row {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-dim);
}
.settings-slider-label { color: var(--text-primary); font-size: 15px; min-width: 180px; flex-shrink: 0; }
.settings-range {
    flex: 1; height: 6px; -webkit-appearance: none; appearance: none;
    background: var(--accent-dark); border-radius: 3px; outline: none; cursor: pointer;
}
.settings-range::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px;
    border-radius: 50%; background: #fff; cursor: pointer; border: none;
}
.settings-range::-moz-range-thumb {
    width: 16px; height: 16px; border-radius: 50%;
    background: #fff; cursor: pointer; border: none;
}
.settings-slider-value {
    color: var(--text-secondary); font-size: 13px; min-width: 40px;
    text-align: right; font-variant-numeric: tabular-nums;
}

/* Удалить аватар */
.settings-remove-avatar-btn {
    padding: 4px 12px; background: transparent; border: 1px solid var(--danger);
    border-radius: 4px; color: var(--danger); font-size: 12px; cursor: pointer;
    margin-top: 8px; transition: background 0.15s;
}
.settings-remove-avatar-btn:hover { background: rgba(237,66,69,0.1); }

/* ===========================
   МОБИЛЬНЫЕ ЭЛЕМЕНТЫ (скрыты на десктопе)
   =========================== */
.mobile-nav { display: none; }
.mobile-hamburger-btn { display: none; }
.mobile-back-btn { display: none; }
.mobile-overlay { display: none; }

/* ===== Закреплённые сообщения ===== */
.pin-indicator {
    display: flex; align-items: center; gap: 4px;
    color: var(--text-muted); font-size: 12px;
    margin-top: 4px; padding: 2px 0;
}
.pin-indicator svg { width: 14px; height: 14px; flex-shrink: 0; }

.pin-toggle-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); padding: 4px 6px; border-radius: 4px;
    display: flex; align-items: center;
    transition: color 0.15s, background 0.15s;
}
.pin-toggle-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.pin-toggle-btn svg { width: 20px; height: 20px; }

.pinned-panel {
    position: fixed; z-index: 10001;
    width: 420px; max-height: 500px;
    background: var(--bg-floating); border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.pinned-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; font-weight: 600; font-size: 15px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
}
.pinned-panel-close {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 22px; line-height: 1;
    padding: 0 4px; border-radius: 4px;
}
.pinned-panel-close:hover { color: var(--text-primary); }

.pinned-panel-list {
    overflow-y: auto; flex: 1; padding: 8px;
}
.pinned-item {
    padding: 10px 12px; border-radius: 6px; cursor: pointer;
    transition: background 0.15s;
    border-left: 3px solid var(--brand);
    margin-bottom: 6px;
    background: var(--bg-secondary);
}
.pinned-item:hover { background: var(--bg-tertiary); }

.pinned-author {
    font-weight: 600; font-size: 13px;
    color: var(--text-primary); margin-bottom: 2px;
}
.pinned-text {
    font-size: 13px; color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pinned-date {
    font-size: 11px; color: var(--text-muted); margin-top: 4px;
}
.pinned-empty {
    text-align: center; color: var(--text-muted);
    padding: 32px 16px; font-size: 14px;
}

/* ===== Забаненные пользователи (модалка) ===== */
.banned-modal {
    background: var(--bg-floating); border-radius: 8px;
    width: 460px; max-height: 70vh;
    display: flex; flex-direction: column;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    padding: 20px;
}
.banned-modal-title {
    font-size: 18px; font-weight: 700;
    color: var(--text-primary); margin-bottom: 16px;
}
.banned-modal-list {
    flex: 1; overflow-y: auto;
    margin-bottom: 16px;
}
.banned-user-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border-radius: 6px;
    background: var(--bg-secondary); margin-bottom: 6px;
}
.banned-user-info { flex: 1; min-width: 0; }
.banned-user-name {
    font-weight: 600; font-size: 14px;
    color: var(--text-primary);
}
.banned-user-reason {
    font-size: 12px; color: var(--text-muted); margin-top: 2px;
}
.unban-btn {
    background: var(--brand); color: #fff; border: none;
    padding: 6px 14px; border-radius: 4px; cursor: pointer;
    font-size: 13px; font-weight: 600;
    flex-shrink: 0; margin-left: 12px;
    transition: background 0.15s;
}
.unban-btn:hover { background: var(--brand-hover); }
.banned-modal-close {
    background: var(--bg-tertiary); color: var(--text-primary);
    border: none; padding: 8px 0; border-radius: 4px;
    cursor: pointer; font-size: 14px; font-weight: 600;
    width: 100%; transition: background 0.15s;
}
.banned-modal-close:hover { background: var(--bg-input); }

/* ===========================
   ИНДИКАТОР СТАТУСА СОЕДИНЕНИЯ
   =========================== */
.connection-status {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50000;
    padding: 6px 16px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform: translateY(-100%);
    opacity: 0;
}
.connection-status.visible {
    transform: translateY(0);
    opacity: 1;
}
.connection-status.status-disconnected,
.connection-status.status-reconnecting {
    background: #f0b232;
    color: #1a1a1a;
}
.connection-status.status-failed {
    background: var(--danger);
    color: var(--text-bright);
}
.connection-status.status-connected {
    background: #23a55a;
    color: #fff;
}
.connection-status .conn-dots span {
    animation: connDotPulse 1.4s infinite both;
    opacity: 0;
}
.connection-status .conn-dots span:nth-child(1) { animation-delay: 0s; }
.connection-status .conn-dots span:nth-child(2) { animation-delay: 0.2s; }
.connection-status .conn-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes connDotPulse {
    0%, 80%, 100% { opacity: 0; }
    40% { opacity: 1; }
}
/* Кнопка «Попробовать снова» в баннере ошибки */
.conn-retry-btn {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 4px;
    padding: 4px 12px;
    margin-left: 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}
.conn-retry-btn:hover {
    background: rgba(255,255,255,0.35);
}
/* Индикация offline на поле ввода */
.input-area-offline {
    border-top: 2px solid #f0b232 !important;
    position: relative;
}
.input-area-offline #messageInput::placeholder {
    color: #f0b232;
}

/* ===========================
   МОБИЛЬНАЯ АДАПТАЦИЯ (< 768px)
   Discord Mobile style: серверы+каналы рядом, чат slide-in, 3 таба
   =========================== */
@media (max-width: 768px) {

    /* --- Auth mobile --- */
    .auth-box { flex-direction: column; width: auto; max-width: 92vw; }
    .auth-box-divider, .auth-box-right { display: none; }
    .auth-page-brand { top: 16px; left: 16px; }
    .auth-page-brand-text { font-size: 18px; }

    /* --- Base --- */
    body { overflow: hidden; position: fixed; width: 100%; height: 100%; }
    #app {
        position: relative;
        height: 100vh; height: 100dvh;
        overflow: hidden;
    }

    /* --- Bottom navigation (3 таба) --- */
    .mobile-nav {
        display: flex !important;
        position: fixed; bottom: 0; left: 0; right: 0;
        height: 60px; background: var(--bg-tertiary);
        border-top: 1px solid var(--border-dim);
        z-index: 9998; padding: 0; gap: 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .mobile-nav-btn {
        flex: 1; display: flex; flex-direction: column;
        align-items: center; justify-content: center; gap: 4px;
        background: none; border: none; color: var(--text-muted);
        font-size: 11px; padding: 6px 0; cursor: pointer;
        -webkit-tap-highlight-color: transparent; position: relative;
        transition: color 0.15s;
    }
    .mobile-nav-btn.active { color: var(--text-bright); }
    .mobile-nav-btn svg {
        width: 24px; height: 24px; fill: none; stroke: currentColor;
        stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
    }
    .mobile-nav-badge {
        position: absolute; top: 2px; right: calc(50% - 20px);
        min-width: 18px; height: 18px; border-radius: 9px;
        background: var(--danger); color: var(--text-bright); font-size: 11px; font-weight: 700;
        display: none; align-items: center; justify-content: center; padding: 0 5px;
    }
    .mobile-nav-badge.has-count { display: flex; }

    /* --- Overlay (для members оверлея) --- */
    .mobile-overlay {
        display: block !important;
        position: fixed; inset: 0; bottom: calc(60px + env(safe-area-inset-bottom, 0px));
        background: rgba(0,0,0,0.5); z-index: 180;
        opacity: 0; pointer-events: none;
        transition: opacity 0.25s ease;
    }
    .mobile-overlay.visible { opacity: 1; pointer-events: auto; }

    /* ========================================
       STATE-BASED LAYOUT
       Классы .mobile-state-* на #app управляют видимостью
       ======================================== */

    /* Все панели скрыты по умолчанию */
    .servers {
        position: fixed; left: 0; top: 0; width: 72px; bottom: calc(60px + env(safe-area-inset-bottom, 0px));
        height: auto; display: none !important;
        flex-direction: column; align-items: center;
        overflow-y: auto; overflow-x: hidden;
        padding: 8px 0; z-index: 100;
        background: var(--bg-dark, #1e1f22);
    }
    .channels {
        position: fixed; left: 72px; top: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom, 0px));
        width: auto !important; max-width: none; height: auto;
        display: none !important;
        flex-direction: column; padding-bottom: 0; z-index: 100;
    }
    .chat {
        position: fixed; left: 0; top: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom, 0px));
        width: 100%; height: auto;
        display: none !important;
        flex-direction: column; z-index: 150;
        transform: translateX(100%);
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .members-panel {
        position: fixed !important; right: 0; top: 0; bottom: calc(60px + env(safe-area-inset-bottom, 0px));
        left: auto !important;
        width: 85% !important; max-width: 320px; height: auto;
        display: flex !important;
        flex-direction: column; z-index: 200;
        opacity: 1 !important; overflow-y: auto !important;
        transform: translateX(100%);
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .members-panel.collapsed {
        display: flex !important; width: 85% !important; max-width: 320px;
        opacity: 1 !important; transform: translateX(100%);
    }

    /* === Состояние: серверы + каналы (домашний экран) === */
    .mobile-state-servers .servers {
        display: flex !important;
    }
    .mobile-state-servers .channels {
        display: flex !important;
    }

    /* === Состояние: чат (slide-in поверх) === */
    .mobile-state-chat .servers { display: flex !important; }
    .mobile-state-chat .channels { display: flex !important; }
    .mobile-state-chat .chat {
        display: flex !important;
        transform: translateX(0);
    }

    /* === Состояние: DMs (каналы на всю ширину) === */
    .mobile-state-dms .channels {
        display: flex !important;
        left: 0;
    }
    .mobile-state-dms .servers { display: none !important; }

    /* === Состояние: friends (friends view на всю ширину) === */
    .mobile-state-friends .friends-view {
        display: flex !important;
    }
    .mobile-state-friends .servers { display: none !important; }
    .mobile-state-friends .channels { display: none !important; }

    /* === Состояние: members (оверлей справа поверх чата) === */
    .mobile-state-members .servers { display: flex !important; }
    .mobile-state-members .channels { display: flex !important; }
    .mobile-state-members .chat {
        display: flex !important;
        transform: translateX(0);
    }
    .mobile-state-members .members-panel {
        transform: translateX(0);
    }

    /* === Состояние: you (настройки) === */
    /* Настройки открываются через showSettingsView(), z-index 30000 — поверх всего */

    /* --- Серверные иконки: увеличенные кружки --- */
    .servers .server-icon {
        width: 48px; height: 48px; margin-bottom: 8px;
        border-radius: 50%; position: relative;
    }
    .servers .server-icon img {
        width: 48px; height: 48px; border-radius: 50%;
    }
    /* Индикатор активного сервера — белая полоска слева */
    .servers .server-icon.active::before {
        content: ''; position: absolute; left: -12px; top: 50%;
        transform: translateY(-50%); width: 4px; height: 32px;
        background: var(--text-bright); border-radius: 0 4px 4px 0;
    }
    /* Скрыть server-name-mobile (больше не нужны) */
    .server-name-mobile { display: none !important; }
    /* Разделитель */
    .servers .server-separator {
        width: 32px; height: 2px; background: var(--border-dim);
        margin: 4px auto; border-radius: 1px;
    }

    /* --- Кнопка "назад" в chat-header --- */
    .mobile-back-btn {
        display: flex !important;
        background: none; border: none; color: var(--text-secondary);
        padding: 10px; margin: 0 4px 0 0;
        align-items: center; justify-content: center; cursor: pointer;
        -webkit-tap-highlight-color: transparent; flex-shrink: 0;
    }
    .mobile-back-btn svg {
        width: 24px; height: 24px; fill: none; stroke: currentColor;
        stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
    }
    .mobile-hamburger-btn { display: none !important; }

    /* --- Chat header --- */
    .chat-header { padding: 12px 14px; min-height: 50px; font-size: 16px; }

    /* --- Заголовок сервера в channels --- */
    .channels .server-header { font-size: 16px; font-weight: 700; padding: 14px 16px; }

    /* --- User bar: relative внутри панели --- */
    .user-bar {
        position: relative !important; transform: none !important;
        bottom: auto !important; z-index: auto !important;
        flex-shrink: 0; margin-top: auto;
        padding: 10px 12px;
    }
    .friends-view .user-bar {
        position: relative; transform: none; bottom: auto; z-index: auto;
    }

    /* --- Friends view --- */
    .friends-view {
        position: fixed; left: 0; top: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom, 0px));
        z-index: 100; height: auto; display: none;
    }
    .friends-header {
        flex-wrap: wrap; height: auto; min-height: 52px;
        padding: 10px 14px; gap: 8px;
    }
    .friends-title { font-size: 17px; }
    .friends-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
    .friends-tab { font-size: 14px; padding: 6px 12px; }
    .dm-tab { margin-left: 0; }
    .add-friend-tab { margin-left: auto; }
    .add-friend-row { flex-direction: column; gap: 8px; }
    .add-friend-btn { width: 100%; padding: 12px 16px; font-size: 15px; }
    /* Кнопки действий друзей: увеличенные touch targets */
    .friend-actions button {
        min-width: 40px; min-height: 40px;
        display: flex; align-items: center; justify-content: center;
    }

    /* --- Настройки: полноэкранные --- */
    .settings-view {
        background: var(--bg-tertiary);
        padding: 0;
    }
    .settings-modal {
        width: 100vw; max-width: 100vw;
        height: 100vh; height: 100dvh; max-height: 100vh;
        border-radius: 0; flex-direction: column;
    }
    .settings-sidebar {
        width: 100%; flex-shrink: 0;
        border-bottom: 1px solid var(--border-dim);
    }
    .settings-sidebar-scroll {
        display: flex; flex-wrap: wrap; gap: 6px;
        padding: 10px 14px; overflow-x: auto; overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }
    .settings-nav-label { width: 100%; font-size: 11px; padding: 4px 0; margin-top: 0; }
    .settings-nav-item {
        width: auto; padding: 8px 14px; font-size: 14px;
        border-radius: 16px; background: var(--bg-accent);
        margin-bottom: 0; white-space: nowrap;
    }
    .settings-nav-item.active { background: var(--brand); color: var(--text-bright); }
    .settings-nav-sep { display: none; }
    .settings-content-scroll { padding: 20px 16px 40px; }
    .settings-close-btn { top: 10px; right: 10px; z-index: 1; width: 36px; height: 36px; }
    .settings-profile-preview { flex-direction: column; gap: 20px; }
    .settings-profile-card-preview { width: 100%; }
    .settings-theme-grid { flex-direction: column; gap: 10px; }
    .settings-slider-row { flex-wrap: wrap; }
    .settings-slider-label { min-width: unset; width: 100%; margin-bottom: 4px; }

    /* --- Профиль-карточка: bottom sheet --- */
    .profile-card {
        position: fixed !important;
        bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important; left: 0 !important; right: 0 !important;
        top: auto !important; width: 100% !important; max-width: 100% !important;
        border-radius: 16px 16px 0 0; max-height: 75vh; overflow-y: auto;
        animation: mobileSlideUp 0.2s ease;
    }
    .profile-card::before {
        content: ''; display: block; width: 36px; height: 4px;
        background: var(--text-muted); border-radius: 2px;
        margin: 8px auto 4px; opacity: 0.5;
    }
    @keyframes mobileSlideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    /* --- Контекстное меню: action sheet --- */
    .ctxmenu {
        position: fixed !important;
        bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important; left: 8px !important; right: 8px !important;
        top: auto !important; width: auto !important; min-width: unset !important;
        border-radius: 16px 16px 0 0;
        animation: mobileSlideUp 0.15s ease;
    }
    .ctxmenu::before {
        content: ''; display: block; width: 36px; height: 4px;
        background: var(--text-muted); border-radius: 2px;
        margin: 8px auto 4px; opacity: 0.5;
    }
    .ctxmenu .item { padding: 14px 16px; font-size: 16px; min-height: 50px; }

    /* --- Emoji picker: bottom sheet --- */
    .emoji-picker-full {
        position: fixed !important;
        left: 0 !important; right: 0 !important;
        bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important; top: auto !important;
        width: 100% !important; max-height: 55vh;
        border-radius: 16px 16px 0 0;
        animation: mobileSlideUp 0.2s ease;
    }
    .emoji-picker-full::before {
        content: ''; display: block; width: 36px; height: 4px;
        background: var(--text-muted); border-radius: 2px;
        margin: 8px auto 4px; opacity: 0.5;
    }
    .emoji-grid { grid-template-columns: repeat(8, 1fr); }
    .emoji-picker-btn { width: 42px; height: 42px; font-size: 24px; }
    .emoji-picker {
        position: fixed !important;
        bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important; left: 50% !important;
        transform: translateX(-50%) !important; top: auto !important;
        border-radius: 12px 12px 0 0; padding: 12px; gap: 8px;
    }

    /* --- Поиск: полноэкранный --- */
    .search-results-panel {
        position: fixed !important;
        top: 50px !important; left: 0 !important; right: 0 !important;
        width: 100% !important; max-width: 100% !important;
        border-radius: 0;
    }

    /* --- Voice panel: над навбаром --- */
    .floating-voice-panel { bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }

    /* --- Модалки --- */
    .modal-box { width: calc(100vw - 32px); max-width: calc(100vw - 32px); }
    .invite-friends-modal {
        width: calc(100vw - 16px); max-width: calc(100vw - 16px);
        max-height: calc(100vh - 80px);
    }

    /* --- Input area --- */
    .input-area { padding: 10px 12px; gap: 6px; }
    #messageInput { font-size: 16px; min-height: 44px; }

    /* --- Сообщения --- */
    .messages { padding: 12px 10px; }
    .message { padding: 6px 8px; }
    .avatar { width: 40px; height: 40px; margin-right: 10px; }
    .message-content { max-width: calc(100vw - 72px); }
    .message-content .username { font-size: 14px; }
    .attachment-image { max-width: calc(100vw - 90px); }

    /* --- Touch-friendly размеры (увеличенные) --- */
    .channel { padding: 12px 16px; min-height: 48px; font-size: 15px; }
    .member-item { padding: 12px 16px; min-height: 52px; }
    .friend-item { padding: 14px 16px; min-height: 56px; }
    .dm-channel { padding: 12px 16px; min-height: 52px; }
    .category-header { padding: 12px 10px; min-height: 44px; font-size: 13px; }

    /* --- Invite btn: всегда видна (no hover на mobile) --- */
    .channel-invite-btn { opacity: 0.6; }

    /* --- Voice controls --- */
    #voiceControls { margin-bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }

    /* --- Mention popup --- */
    .mention-popup {
        position: fixed !important;
        bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important; left: 0 !important; right: 0 !important;
        width: 100% !important; max-height: 240px;
        border-radius: 8px 8px 0 0;
    }

    /* --- Server color picker --- */
    .server-color-picker {
        position: fixed !important;
        bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important; left: 50% !important;
        transform: translateX(-50%) !important; top: auto !important;
    }

    /* --- Видео --- */
    .video-grid { grid-template-columns: 1fr; }
    .video-tile { min-height: 120px; }
    .video-tile-avatar { width: 56px; height: 56px; font-size: 22px; }
    .media-panel.has-screenshare .video-tile { width: 128px; height: 96px; }

    /* --- DM call --- */
    .dm-call-card {
        padding: 24px; min-width: unset;
        width: calc(100vw - 48px); max-width: 360px;
    }

    /* --- Reply preview --- */
    .reply-preview { padding: 8px 10px; }

    /* --- Кроппер --- */
    .cropper-modal { max-height: 100vh; }

    /* --- Закреплённые сообщения --- */
    .pinned-panel {
        width: calc(100vw - 16px); left: 8px !important; right: 8px !important;
        max-height: 60vh; bottom: calc(60px + env(safe-area-inset-bottom, 0px)); top: auto !important;
        border-radius: 16px 16px 0 0;
    }

    /* --- Забаненные --- */
    .banned-modal { width: calc(100vw - 32px); max-width: 460px; }
}
