@charset "UTF-8";

:root {
    --bg-0: #05070d;
    --bg-1: #0b0f1a;
    --bg-2: #121729;
    --accent: #4ee1ff;
    --accent-2: #7c5cff;
    --text-main: #e6f1ff;
    --text-dim: #7d8aa8;
    --border: #1e2740;
    --danger: #ff4e6a;
    --admin-bg: #030a07;
}

* { box-sizing: border-box; }
.hidden { display: none !important; }

body {
    margin: 0;
    font-family: 'Segoe UI', 'Inter', system-ui, sans-serif;
    background: var(--bg-0);
    color: var(--text-main);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-2); }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

button, .chat-item, .rail-icon, input, textarea, a {
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
                box-shadow 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

/* ---------- AUTH SCREEN ---------- */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    position: relative;
    background: radial-gradient(circle at 50% 20%, #101830 0%, #05070d 70%);
}
.auth-bg-grid {
    position: absolute; inset: 0;
    background-image:
        linear-gradient(to right, rgba(78,225,255,0.04) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(78,225,255,0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}
.auth-card {
    position: relative;
    z-index: 1;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px 40px;
    width: 380px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 0 50px rgba(78,225,255,0.1), 0 20px 60px rgba(0,0,0,0.4);
    animation: authCardIn 0.35s cubic-bezier(.2,.8,.2,1);
}
@keyframes authCardIn {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.logo {
    font-size: 22px;
    letter-spacing: 3px;
    text-align: center;
    margin: 0 0 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.logo span { color: var(--text-dim); }
.auth-sub { text-align: center; color: var(--text-dim); margin-bottom: 20px; }
.auth-error {
    background: rgba(255,78,106,0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label {
    font-size: 13px;
    color: var(--text-dim);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.auth-form input[type="text"],
.auth-form input[type="password"],
.auth-form input[type="email"],
.auth-form input[type="file"],
.auth-form textarea {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-main);
    font-size: 14px;
    outline: none;
}
.auth-form input:focus, .auth-form textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(78,225,255,0.12);
}
.auth-form small { color: #556; font-size: 11px; }
.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] { width: 100%; max-width: 100%; }

/* ---------- Avatar cropper ---------- */
.avatar-picker {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 100%;
}
.avatar-file-input-hidden {
    position: absolute;
    width: 1px; height: 1px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}
.avatar-dropzone {
    position: relative;
    cursor: pointer;
    border-radius: 50%;
    outline: none;
}
.avatar-dropzone:focus-visible .avatar-crop-stage,
.avatar-dropzone:hover .avatar-crop-stage {
    border-color: var(--accent);
}
.avatar-dropzone.drag-over .avatar-crop-stage {
    border-color: var(--accent);
    border-style: dashed;
    background: rgba(78,225,255,0.08);
    transform: scale(1.04);
}
.avatar-crop-stage {
    position: relative;
    width: 96px; height: 96px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-2);
    border: 2px solid var(--border);
    cursor: grab;
    flex-shrink: 0;
    user-select: none;
    touch-action: none;
    transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.avatar-crop-stage.dragging { cursor: grabbing; }
.avatar-crop-stage .crop-img {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    display: none;
    pointer-events: none;
    max-width: none;
}
.avatar-crop-stage .crop-img.shown { display: block; }
.avatar-placeholder {
    position: absolute; inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-dim);
    pointer-events: none;
    transition: color 0.15s ease;
}
.avatar-dropzone:hover .avatar-placeholder,
.avatar-dropzone.drag-over .avatar-placeholder { color: var(--accent); }
.avatar-placeholder span { font-size: 10px; letter-spacing: 0.5px; }
.avatar-placeholder.hidden { display: none; }
.avatar-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}
.avatar-controls.hidden { display: none; }
.zoom-label {
    display: flex; flex-direction: column; gap: 4px;
    font-size: 11px; color: var(--text-dim);
    width: 100%;
    max-width: 180px;
}
.zoom-label input[type="range"] { width: 100%; accent-color: var(--accent); }
.avatar-remove-btn {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 11px;
    cursor: pointer;
    padding: 2px 4px;
}
.avatar-remove-btn:hover { text-decoration: underline; }
.btn-primary {
    background: linear-gradient(90deg, var(--accent-2), var(--accent));
    border: none;
    color: #04101c;
    font-weight: 600;
    padding: 11px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(78,225,255,0.18);
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(78,225,255,0.28); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 9px 14px;
    border-radius: 8px;
    cursor: pointer;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger {
    background: rgba(255,78,106,0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    width: 100%;
}
.btn-danger:hover { background: rgba(255,78,106,0.25); }
.danger-hint {
    color: var(--text-dim);
    font-size: 11px;
    text-align: center;
    display: block;
    margin-top: -4px;
}
.auth-switch { text-align: center; color: var(--text-dim); font-size: 13px; margin-top: 18px; }
.auth-switch a { color: var(--accent); text-decoration: none; }

/* ---------- APP LAYOUT ---------- */
.layout { display: flex; height: 100dvh; }

.rail {
    width: 68px;
    flex-shrink: 0;
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    gap: 20px;
}
.rail-avatar-btn {
    background: none; border: none; cursor: pointer; padding: 0; border-radius: 50%;
}
.rail-avatar-btn:hover { transform: scale(1.06); }
.rail-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    object-fit: cover;
    border: 2px solid transparent;
}
.rail-avatar.admin-glow {
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent);
}
.rail-icons { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.rail-icon {
    font-size: 18px; opacity: 0.6; cursor: pointer;
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 10px;
}
.rail-icon:hover { opacity: 1; background: var(--bg-2); }

.chat-list {
    width: 300px;
    min-width: 200px;
    max-width: 500px;
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    position: relative;
    display: flex;
    flex-direction: column;
}
.chat-list-header {
    padding: 16px 20px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.new-chat-btn {
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--accent);
    width: 26px; height: 26px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}
.new-chat-btn:hover { border-color: var(--accent); background: rgba(78,225,255,0.1); }
.search-btn {
    margin: 10px 14px 4px;
    padding: 9px 12px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-dim);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}
.search-btn:hover { border-color: var(--accent); color: var(--accent); }
.chat-list-body { flex: 1; overflow-y: auto; }
.chat-list-empty { color: var(--text-dim); text-align: center; margin-top: 40px; font-size: 13px; padding: 0 20px; }
.chat-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.02);
    border-left: 3px solid transparent;
    position: relative;
}
.chat-item:hover { background: var(--bg-2); border-left-color: var(--accent); }
.chat-item.active { background: var(--bg-2); border-left-color: var(--accent); }

/* Закреплённые чаты — заметная полоса слева + мягкая подсветка */
.chat-item.pinned {
    border-left-color: var(--accent-2);
    background: linear-gradient(90deg, rgba(124,92,255,0.07) 0%, transparent 40%);
}
.chat-item.pinned:hover,
.chat-item.pinned.active {
    background: linear-gradient(90deg, rgba(124,92,255,0.14) 0%, var(--bg-2) 45%);
    border-left-color: var(--accent-2);
}
.chat-item-avatar {
    width: 42px; height: 42px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: white;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    object-fit: cover;
}
.chat-avatar-wrap {
    position: relative;
    flex-shrink: 0;
    display: inline-block;
    width: 42px; height: 42px;
}
.chat-avatar-wrap .chat-item-avatar { width: 42px; height: 42px; display: block; }
.online-dot {
    position: absolute;
    right: -1px; bottom: -1px;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #4ee1ff;
    border: 2px solid var(--bg-1);
    box-shadow: 0 0 6px rgba(78,225,255,0.75);
    pointer-events: none;
}
.online-dot.offline { background: #556177; box-shadow: none; }
.admin-chat-avatar { background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.chat-item-info { min-width: 0; }
.chat-item-name {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}
.chat-item-name > span,
.chat-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-item.pinned .chat-item-name::after {
    content: '📌';
    font-size: 11px;
    line-height: 1;
    opacity: 0.85;
    flex-shrink: 0;
    transform: rotate(-15deg);
    transition: transform 0.15s ease;
}
.chat-item.pinned:hover .chat-item-name::after { transform: rotate(0deg) scale(1.1); }
.chat-tag {
    font-size: 9px; color: var(--accent); border: 1px solid var(--accent);
    border-radius: 6px; padding: 1px 5px; margin-left: 4px; vertical-align: middle;
}
.chat-item-last {
    font-size: 12px; color: var(--text-dim);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.resize-handle {
    position: absolute; top: 0; right: -3px; width: 6px; height: 100%;
    cursor: col-resize; z-index: 5;
}

.chat-main {
    flex: 1;
    background: var(--bg-0);
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}
.chat-placeholder.hidden { display: none; }
.chat-placeholder { margin: auto; text-align: center; color: var(--text-dim); padding: 20px; }
.chat-placeholder h2 {
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text; background-clip: text; color: transparent;
    letter-spacing: 2px;
}

/* ---------- Активный чат ---------- */
.chat-active { display: flex; flex-direction: column; height: 100%; }
.chat-active.hidden { display: none; }
.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-1);
    flex-shrink: 0;
}
.chat-back-btn {
    display: none;
    background: none; border: none;
    color: var(--text-main);
    font-size: 22px;
    width: 36px; height: 36px;
    border-radius: 50%;
    cursor: pointer;
    align-items: center; justify-content: center;
    flex-shrink: 0;
}
.chat-back-btn:hover { background: var(--bg-2); color: var(--accent); }
.chat-header-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.chat-header-name { font-weight: 600; font-size: 14px; }
.chat-header-sub { font-size: 12px; color: var(--text-dim); }
.chat-header-sub.online { color: #4ee1ff; font-weight: 600; }
.chat-header-members-btn,
.chat-header-edit-btn {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 14px;
}
.chat-header-edit-btn { margin-left: auto; margin-right: 6px; }
.chat-header-members-btn { margin-left: auto; }
.chat-header-edit-btn + .chat-header-members-btn { margin-left: 0; }
.chat-header-members-btn:hover,
.chat-header-edit-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Поисковый оверлей ---------- */
.search-overlay {
    position: absolute; inset: 0;
    background: var(--bg-0);
    display: flex;
    flex-direction: column;
    z-index: 20;
}
.search-overlay.hidden { display: none; }
.search-overlay-header {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-1);
}
.search-overlay-header input {
    flex: 1;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-main);
    font-size: 14px;
}
.search-overlay-results { flex: 1; overflow-y: auto; padding: 12px 16px; }
.search-section-header {
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-dim);
    padding: 14px 6px 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}

/* ---------- Заявки ---------- */
.request-bar {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-1);
    display: flex; align-items: center; justify-content: center;
    text-align: center;
}
.request-bar-text { color: var(--text-dim); font-size: 13px; }

/* ---------- Сообщения ---------- */
.admin-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex; flex-direction: column; gap: 16px;
    overscroll-behavior: contain;
}

.bot-message {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    align-self: flex-start;
    max-width: min(72%, 640px);
    min-width: 0;
}
.bot-message-avatar {
    width: 40px; height: 40px; font-size: 16px;
    flex-shrink: 0;
    position: relative;
    z-index: 3;
}
.bot-message-content,
.self-message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    max-width: 100%;
    position: relative;
}
.bot-message-content { align-items: flex-start; }
.self-message-content { align-items: flex-end; z-index: 2; }

.bot-message-bubble,
.self-message-bubble {
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
    max-width: 100%;
    position: relative;
    z-index: 2;
    isolation: isolate;
}
.bot-text,
.self-message-text {
    display: block;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: pre-wrap;
    max-width: 100%;
}

.bot-message-bubble {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
}
.bot-message .bot-name {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 2px;
}
.bot-message .bot-text { font-size: 16px; line-height: 1.4; }
.msg-time {
    font-size: 10px;
    text-align: right;
    margin-top: 3px;
    opacity: 0.55;
    user-select: none;
}
.bot-message-bubble .msg-time { color: var(--text-dim); }
.self-message-bubble .msg-time { color: #04101c; opacity: 0.6; }

.self-message {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    align-self: flex-end;
    max-width: min(72%, 640px);
    min-width: 0;
    flex-direction: row-reverse;
    position: relative;
}
.self-message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    position: relative;
    z-index: 3;
}
.self-message-bubble {
    background: linear-gradient(135deg, var(--accent-2), var(--accent));
    color: #04101c;
    border-radius: 12px;
    padding: 10px 14px;
}
.self-message-name { font-size: 12px; font-weight: 700; opacity: 0.75; margin-bottom: 2px; }
.self-message-text { font-size: 16px; line-height: 1.4; }

/* ---------- Реакции, reply, editing ---------- */
.msg-reply-ref {
    border-left: 3px solid rgba(255,255,255,0.4);
    padding: 3px 8px;
    margin-bottom: 6px;
    border-radius: 4px;
    background: rgba(255,255,255,0.08);
    font-size: 12px;
    max-width: 100%;
    overflow: hidden;
}
.self-message-bubble .msg-reply-ref { border-left-color: rgba(4,16,28,0.4); background: rgba(4,16,28,0.12); }
.msg-reply-ref-name { font-weight: 700; margin-right: 6px; opacity: 0.85; }
.msg-reply-ref-text { opacity: 0.75; }

.reply-bar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    padding: 6px 10px;
    margin-bottom: 10px;
    font-size: 12px;
}
.reply-bar.hidden { display: none; }
.reply-bar-label { color: var(--text-dim); }
.reply-bar-name { color: var(--accent); font-weight: 600; margin-right: 4px; }
.reply-bar-snippet { color: var(--text-dim); }
.reply-bar-cancel {
    background: none; border: none; color: var(--text-dim);
    cursor: pointer; font-size: 13px; padding: 2px 6px; border-radius: 4px;
}
.reply-bar-cancel:hover { color: var(--danger); background: var(--bg-1); }

.msg-reactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.msg-reaction-pill {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px 10px 3px 3px;
    cursor: pointer;
    font-size: 13px;
    opacity: 0;
    transform: scale(0.6);
    transition: transform 0.12s ease, opacity 0.12s ease, border-color 0.12s ease;
}
.msg-reaction-pill.pill-in { opacity: 1; transform: scale(1); }
.msg-reaction-pill.pill-out { opacity: 0; transform: scale(0.6); }
.msg-reaction-pill:hover { border-color: var(--danger); }
.msg-reaction-avatar { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; }
.msg-reaction-emoji { line-height: 1; }

.msg-menu {
    position: fixed;
    z-index: 200;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.5);
    min-width: 220px;
    opacity: 0;
    transform: scale(0.92) translateY(-4px);
    transform-origin: top left;
    transition: opacity 0.12s ease, transform 0.12s ease;
}
.msg-menu.open { opacity: 1; transform: scale(1) translateY(0); }
.msg-menu-emojis {
    display: flex; justify-content: space-between; gap: 2px;
    padding-bottom: 8px; margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.msg-menu-emojis button {
    background: none; border: none; cursor: pointer;
    font-size: 18px; padding: 4px; border-radius: 8px; line-height: 1;
}
.msg-menu-emojis button:hover { background: var(--bg-2); transform: scale(1.2); }
.msg-menu-actions { display: flex; flex-direction: column; gap: 2px; }
.msg-menu-btn {
    background: none; border: none; color: var(--text-main);
    text-align: left; font-size: 13px; padding: 8px 10px; border-radius: 8px;
    cursor: pointer;
}
.msg-menu-btn:hover { background: var(--bg-2); }
.msg-menu-danger { color: var(--danger); }
.msg-menu-danger:hover { background: rgba(255,78,106,0.1); }

.msg-enter { opacity: 0; transform: translateY(8px) scale(0.98); }
.msg-enter-active { opacity: 1; transform: translateY(0) scale(1); transition: opacity 0.18s ease, transform 0.18s ease; }
.msg-leave { opacity: 0; transform: scale(0.9); transition: opacity 0.15s ease, transform 0.15s ease; }

.msg-editing .bot-message-bubble,
.msg-editing .self-message-bubble {
    box-shadow: 0 0 0 2px var(--accent), 0 0 16px rgba(78,225,255,0.5);
    animation: editPulse 1.4s ease-in-out infinite;
}
@keyframes editPulse {
    0%, 100% { box-shadow: 0 0 0 2px var(--accent), 0 0 0 10px rgba(78,225,255,0.35); }
    50%      { box-shadow: 0 0 0 2px var(--accent), 0 0 20px rgba(78,225,255,0.65); }
}
.editable-text {
    outline: none;
    cursor: text;
    border-radius: 6px;
    background: rgba(255,255,255,0.06);
    padding: 2px 4px;
    margin: -2px -4px;
}
.msg-edit-confirm {
    position: absolute;
    bottom: -12px; right: -12px;
    width: 26px; height: 26px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #04101c;
    font-size: 13px; font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    display: flex; align-items: center; justify-content: center;
}
.msg-edit-confirm:hover { filter: brightness(1.1); transform: scale(1.06); }
.msg-edited { font-size: 10px; color: var(--text-dim); font-style: italic; }
.msg-edited.hidden { display: none; }

/* ---------- Форма ввода ---------- */
.admin-chat-form {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-1);
    flex-shrink: 0;
}
.admin-chat-form.drag-over {
    background: rgba(78,225,255,0.06);
    outline: 2px dashed var(--accent);
    outline-offset: -6px;
}
.bot-toggle-wrap {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; color: var(--accent);
    margin-bottom: 8px;
}
.bot-toggle-wrap input[type="text"] {
    background: var(--bg-2); border: 1px solid var(--border);
    border-radius: 6px; padding: 4px 8px;
    color: var(--text-main); font-size: 12px;
    width: 140px;
}
.admin-chat-form-row { display: flex; gap: 8px; align-items: center; }
.admin-chat-form-row input[type="text"] {
    flex: 1;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--text-main);
    font-size: 14px;
    min-width: 0;
}

/* Прикрепить */
.attach-wrap { position: relative; flex-shrink: 0; }
.attach-btn {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 16px;
}
.attach-btn:hover { border-color: var(--accent); color: var(--accent); }
.attach-menu {
    position: absolute;
    bottom: 110%;
    left: 0;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.5);
    z-index: 30;
    min-width: 170px;
}
.attach-menu.hidden { display: none; }
.attach-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 13px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}
.attach-menu-item:hover { background: var(--bg-2); color: var(--accent); }

.attachment-preview-bar {
    margin-bottom: 10px;
    padding: 8px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.attachment-preview-bar.hidden { display: none; }
.attach-preview {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-width: 100%;
}
.attach-preview-image img {
    max-height: 90px;
    max-width: 200px;
    border-radius: 6px;
    display: block;
}
.attach-preview-video video {
    max-height: 100px;
    max-width: 220px;
    border-radius: 6px;
    background: #000;
}
.attach-preview-audio audio { max-width: 260px; }
.attach-preview-file { padding-right: 30px; }
.attach-preview-close {
    position: absolute;
    top: -6px; right: -6px;
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-0);
    color: var(--danger);
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
}

/* Вложения в сообщениях */
.msg-attach { margin: 4px 0; }
.msg-attach-image img {
    max-width: 100%;
    max-height: 320px;
    border-radius: 8px;
    display: block;
    cursor: zoom-in;
}
.msg-attach-video video {
    max-width: 100%;
    max-height: 320px;
    border-radius: 8px;
    background: #000;
    display: block;
}
.msg-attach-meta {
    font-size: 11px;
    color: inherit;
    opacity: 0.75;
    margin-top: 2px;
    display: flex;
    gap: 8px;
    justify-content: space-between;
}
.msg-attach-audio {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.15);
    padding: 6px 10px;
    border-radius: 10px;
    min-width: 220px;
}
.self-message-bubble .msg-attach-audio { background: rgba(0,0,0,0.2); }
.audio-toggle {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 1px solid var(--accent);
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.audio-icon-pause { display: none; }
.msg-attach-audio.playing .audio-icon-play { display: none; }
.msg-attach-audio.playing .audio-icon-pause { display: inline; }
.audio-main { flex: 1; min-width: 140px; }
.audio-name {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}
.audio-progress {
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,0.2);
    overflow: hidden;
    cursor: pointer;
}
.self-message-bubble .audio-progress { background: rgba(0,0,0,0.25); }
.audio-progress-fill {
    height: 100%;
    width: 0;
    background: currentColor;
    opacity: 0.85;
}
.audio-meta {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    opacity: 0.75;
    margin-top: 2px;
}
.msg-attach-file {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.15);
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
}
.self-message-bubble .msg-attach-file { background: rgba(0,0,0,0.2); }
.file-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    color: var(--accent);
}
.self-message-bubble .file-icon { background: rgba(0,0,0,0.15); }
.file-main { min-width: 0; }
.file-name { font-size: 13px; font-weight: 600; word-break: break-all; }
.file-size { font-size: 11px; opacity: 0.7; }

/* ---------- SVG-иконки ---------- */
.icon-svg {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: middle;
    fill: currentColor;
    flex-shrink: 0;
}
.search-btn .icon-svg,
.attach-menu-item .icon-svg,
.btn-secondary .icon-svg,
.chat-header-edit-btn .icon-svg,
.chat-header-members-btn .icon-svg,
.attach-btn .icon-svg,
.msg-menu-btn .icon-svg {
    width: 1.1em;
    height: 1.1em;
    margin-right: 4px;
    vertical-align: -2px;
}
.file-icon .icon-svg {
    width: 22px;
    height: 22px;
    margin-right: 0;
    fill: var(--accent);
}

/* Просмотр изображения */
.image-view-box {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
}
.image-view-box img {
    max-width: 95vw;
    max-height: 95vh;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.7);
}
.image-view-close {
    position: absolute;
    top: -14px; right: -14px;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--bg-1);
    border: 1px solid var(--border);
    color: var(--danger);
    cursor: pointer;
    font-size: 14px;
}

/* ---------- Просмотр текстовых файлов ---------- */
.text-view-modal {
    width: 720px;
    max-width: 92vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}
.text-view-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-1);
    flex-wrap: wrap;
}
.text-view-toggle {
    font-size: 13px;
    color: var(--text-dim);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}
.text-view-toggle input[type="checkbox"] { accent-color: var(--accent); }
.text-view-actions { display: flex; gap: 8px; }
.text-view-body {
    flex: 1;
    overflow: auto;
    background: var(--bg-2);
    padding: 12px 0;
}
.text-view-body pre {
    margin: 0;
    padding: 0 16px;
    font-family: 'Consolas', 'Menlo', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-main);
    white-space: pre;
    tab-size: 4;
}
.text-view-body pre.with-numbers { counter-reset: line; }
.text-view-body pre.with-numbers .line::before {
    counter-increment: line;
    content: counter(line);
    display: inline-block;
    width: 3em;
    text-align: right;
    margin-right: 1em;
    color: var(--text-dim);
    opacity: 0.6;
    user-select: none;
    border-right: 1px solid var(--border);
    padding-right: 8px;
}
.text-view-body pre.with-numbers .line { display: block; }
@media (max-width: 800px) {
    .text-view-modal { width: 100vw; max-width: 100vw; max-height: 100dvh; border-radius: 0; }
    .text-view-toolbar { padding: 8px 12px; }
    .text-view-body pre { font-size: 12px; padding: 0 10px; }
}

/* ---------- Контекстное меню чата ---------- */
.chat-ctx-menu {
    min-width: 200px;
    padding: 6px;
}
.chat-ctx-menu .msg-menu-btn {
    display: block;
    width: 100%;
}

/* ---------- MODALS ---------- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(3,6,13,0.7);
    backdrop-filter: blur(3px);
    display: none; align-items: center; justify-content: center;
    z-index: 100;
    animation: overlayIn 0.15s ease;
}
.modal-overlay.open { display: flex; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 380px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: modalIn 0.2s cubic-bezier(.2,.8,.2,1);
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px; border-bottom: 1px solid var(--border);
    font-weight: 600;
}
.modal-close {
    background: none; border: none; color: var(--text-dim);
    cursor: pointer; font-size: 16px;
    width: 26px; height: 26px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg-2); color: var(--danger); }

/* ---------- Profile modal ---------- */
.profile-modal { padding-bottom: 10px; }
.profile-view { text-align: center; padding: 24px; position: relative; z-index: 2; }
.profile-avatar-big {
    width: 96px; height: 96px; border-radius: 50%; object-fit: cover;
    border: 2px solid transparent;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 40px; color: #fff;
    background: #141a33; vertical-align: middle;
}
.profile-avatar-big img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.profile-avatar-big.admin-glow { border-color: var(--accent); box-shadow: 0 0 20px var(--accent); }
.profile-avatar-big.heaven-glow {
    border-color: #a85c2a;
    box-shadow:
        0 0 26px rgba(168,92,42,0.55),
        0 0 60px rgba(168,92,42,0.25),
        inset 0 0 20px rgba(200,120,60,0.18);
}
.profile-username { color: var(--text-dim); margin-top: -6px; }
.profile-description { font-size: 13px; color: var(--text-dim); margin: 10px 0 16px; word-break: break-word; }
.profile-description.desc-glow-purple {
    font-size: 16px;
    font-weight: 600;
    color: #dcc2ff;
    max-width: 92%;
    margin-left: auto;
    margin-right: auto;
    line-height: 2.1;
    padding: 20px 14px;
    text-shadow:
        0 0 6px rgba(168,85,255,0.9),
        0 0 14px rgba(140,60,255,0.7),
        0 0 28px rgba(124,92,255,0.5);
    animation: descGlowPurplePulse 2.6s ease-in-out infinite;
}
@keyframes descGlowPurplePulse {
    0%, 100% {
        text-shadow:
            0 0 6px rgba(168,85,255,0.9),
            0 0 14px rgba(140,60,255,0.7),
            0 0 28px rgba(124,92,255,0.5);
    }
    50% {
        text-shadow:
            0 0 10px rgba(200,140,255,1),
            0 0 22px rgba(160,90,255,0.9),
            0 0 42px rgba(124,92,255,0.7);
    }
}
.admin-badge {
    display: inline-block; padding: 4px 10px; border-radius: 20px;
    background: rgba(78,225,255,0.1); border: 1px solid var(--accent);
    color: var(--accent); font-size: 11px; letter-spacing: 1px; margin-bottom: 14px;
}
.logout-link {
    display: block; text-align: center; color: var(--danger);
    font-size: 13px; padding: 12px; text-decoration: none;
    position: relative; z-index: 2;
}
.settings-form {
    padding: 18px; display: flex; flex-direction: column; gap: 12px;
    overflow-y: auto; position: relative; z-index: 2;
}
.settings-form.hidden { display: none; }
.settings-form label { font-size: 12px; color: var(--text-dim); display: flex; flex-direction: column; gap: 5px; }
.settings-form input, .settings-form textarea {
    background: var(--bg-2); border: 1px solid var(--border); border-radius: 7px;
    padding: 8px 10px; color: var(--text-main); font-size: 13px;
}
.settings-form hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; width: 100%; }
.settings-buttons { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Admin matrix profile effect ---------- */
.matrix-canvas {
    position: absolute; inset: 0; width: 100%; height: 100%;
    display: none; z-index: 0; pointer-events: none; overflow: visible;
}
.profile-modal.admin-effect {
    background: #030a07;
    position: relative;
    width: 1100px;
    max-width: 95vw;
    max-height: 90vh;
    animation: crtFlicker 4s infinite linear;
}
.profile-modal.admin-effect .profile-view { padding: 44px; }
.profile-modal.admin-effect .profile-avatar-big { width: 168px; height: 168px; font-size: 72px; }
.profile-modal.admin-effect .profile-view h3 { font-size: 28px; letter-spacing: 1px; }
.profile-modal.admin-effect .profile-username { font-size: 16px; }
.profile-modal.admin-effect .profile-description { font-size: 15px; max-width: 520px; margin-left: auto; margin-right: auto; }
.profile-modal.admin-effect .modal-header { border-bottom-color: #16351f; }
.profile-modal.admin-effect .matrix-canvas { display: block; }
.profile-modal.admin-effect .admin-badge { background: rgba(79,255,129,0.1); border-color: #4fff81; color: #4fff81; }
.profile-modal.admin-effect .profile-avatar-big.admin-glow,
.profile-modal.admin-effect .rail-avatar.admin-glow { border-color: #4fff81; box-shadow: 0 0 20px #4fff81; }
.profile-modal.admin-effect::after {
    content: ""; position: absolute; inset: 0;
    background: repeating-linear-gradient(0deg,
        rgba(79,255,129,0.05) 0px, rgba(79,255,129,0.05) 1px,
        transparent 1px, transparent 3px);
    pointer-events: none; z-index: 3; mix-blend-mode: overlay;
}
@keyframes crtFlicker {
    0%,100% { filter: brightness(1); }
    3%      { filter: brightness(0.96); }
    6%      { filter: brightness(1.03); }
    9%      { filter: brightness(1); }
    52%     { filter: brightness(1); }
    54%     { filter: brightness(0.9); }
    56%     { filter: brightness(1.05); }
    58%     { filter: brightness(1); }
}
.profile-modal.admin-effect .profile-view::before {
    content: ""; position: absolute;
    left: 0; right: 0; height: 60px;
    background: linear-gradient(180deg, transparent, rgba(79,255,129,0.12), transparent);
    top: -60px; z-index: 1; pointer-events: none;
    animation: scanBeam 5s infinite linear;
}
@keyframes scanBeam { 0% { top: -60px; } 100% { top: 100%; } }
.static-flash {
    position: absolute; inset: 0; z-index: 5; pointer-events: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/></svg>");
    mix-blend-mode: overlay; opacity: 0;
    animation: staticFlash 0.15s steps(2, end);
}
@keyframes staticFlash { 0% { opacity: 0; } 30% { opacity: 0.55; } 60% { opacity: 0.2; } 100% { opacity: 0; } }
.profile-modal.admin-effect .profile-view h3.scrambling { color: #4fff81; text-shadow: 0 0 8px rgba(79,255,129,0.6); }
.glitch-slice {
    position: absolute; left: 0; width: 100%;
    background: inherit; z-index: 4; pointer-events: none;
    box-shadow: 0 0 0 1px rgba(79,255,129,0.4);
}
.profile-modal.admin-effect.glitch-active { animation: glitchDisplace 0.15s steps(2, end); }
.profile-modal.admin-effect.glitch-active .modal-header,
.profile-modal.admin-effect.glitch-active .profile-view,
.profile-modal.admin-effect.glitch-active .logout-link { animation: glitchRgbSplit 0.15s steps(2, end); }
@keyframes glitchDisplace {
    0%   { transform: translate(0,0); filter: brightness(1) contrast(1); }
    15%  { transform: translate(-4px, 1px); filter: brightness(1.6) contrast(1.4); clip-path: inset(10% 0 30% 0); }
    30%  { transform: translate(5px, -2px); filter: brightness(0.6) contrast(1.6) hue-rotate(20deg); clip-path: inset(50% 0 5% 0); }
    45%  { transform: translate(-3px, 0); filter: brightness(1.4); clip-path: inset(0 0 60% 0); }
    60%  { transform: translate(4px, 2px); clip-path: inset(30% 0 20% 0); }
    75%  { transform: translate(-2px, -1px); filter: brightness(1.2); clip-path: inset(0 0 0 0); }
    100% { transform: translate(0,0); filter: brightness(1) contrast(1); clip-path: inset(0 0 0 0); }
}
@keyframes glitchRgbSplit {
    0%, 100% { text-shadow: none; transform: translate(0); }
    20% { text-shadow: -2px 0 #ff4e6a, 2px 0 #4fff81; transform: translate(-1px, 0); }
    40% { text-shadow: 2px 0 #4fff81, -2px 0 #4ee1ff; transform: translate(1px, 0); }
    60% { text-shadow: -1px 0 #ff4e6a, 1px 0 #4fff81; transform: translate(-1px, 1px); }
    80% { text-shadow: 1px 0 #4fff81; transform: translate(0, -1px); }
}

/* Описание-картинка для MatrixBro93 */
.matrix-desc-img {
    display: inline-block;
    max-width: 100%;
    max-height: 220px;
    width: auto; height: auto;
    margin: 12px auto 18px;
    border-radius: 10px;
    filter:
        drop-shadow(0 0 6px rgba(13, 255, 81, 0.55))
        drop-shadow(0 0 18px rgba(13, 255, 81, 0.25));
    animation: matrixDescPulse 3.6s ease-in-out infinite;
    user-select: none;
    -webkit-user-drag: none;
}
.profile-modal.admin-effect .matrix-desc-img {
    max-height: 260px;
    filter:
        drop-shadow(0 0 8px rgba(13, 255, 81, 0.7))
        drop-shadow(0 0 24px rgba(13, 255, 81, 0.35));
}
@keyframes matrixDescPulse {
    0%, 100% { filter: drop-shadow(0 0 6px rgba(13, 255, 81, 0.55)) drop-shadow(0 0 18px rgba(13, 255, 81, 0.25)); }
    50%      { filter: drop-shadow(0 0 10px rgba(13, 255, 81, 0.85)) drop-shadow(0 0 28px rgba(13, 255, 81, 0.45)); }
}

/* =====================================================================
   НЕБЕСНЫЙ ПРОФИЛЬ (SYNAPSE-HEAVEN-DMI56TD)
   ===================================================================== */
.profile-modal.heaven-effect {
    background: #060310;
    position: relative;
    width: 1100px;
    max-width: 95vw;
    max-height: 90vh;
    overflow: hidden;
    border-color: #1a1230;
    animation: heavenBreath 9s ease-in-out infinite;
}
@keyframes heavenBreath {
    0%, 100% { filter: brightness(0.94) saturate(0.95); }
    50%      { filter: brightness(1.02) saturate(1.05); }
}
.profile-modal.heaven-effect .profile-view { padding: 44px; }
.profile-modal.heaven-effect .profile-avatar-big { width: 168px; height: 168px; font-size: 72px; border-color: #a85c2a; }
.profile-modal.heaven-effect .profile-view h3 {
    font-size: 28px; letter-spacing: 1px; color: #cbb8e0;
    text-shadow: 0 0 10px rgba(124,92,255,0.25);
}
.profile-modal.heaven-effect .profile-username { font-size: 16px; color: #8578a8; }
.profile-modal.heaven-effect .profile-description {
    font-size: 15px; max-width: 520px;
    margin-left: auto; margin-right: auto;
    color: #9b8dbd;
}
.profile-modal.heaven-effect .modal-header { border-bottom-color: #1a1230; color: #cbb8e0; }
.profile-modal.heaven-effect .admin-badge { background: rgba(168,92,42,0.12); border-color: #a85c2a; color: #d18a4e; }
.profile-modal.heaven-effect .btn-secondary {
    background: rgba(124,92,255,0.06); border-color: #2a1e50; color: #a896c8;
}
.profile-modal.heaven-effect .btn-secondary:hover { border-color: #6a4fa8; color: #c8b8e0; }
.profile-modal.heaven-effect .logout-link { color: #8a6a3a; }
.profile-modal.heaven-effect::after { content: none; }

/* Небо */
.heaven-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 50% 42%, rgba(74,53,114,0.30) 0%, transparent 55%),
        radial-gradient(circle at 50% 110%, rgba(60,30,80,0.40) 0%, transparent 60%),
        linear-gradient(180deg, #04020a 0%, #0b0722 45%, #060310 100%);
}

/* Умирающее фиолетовое солнце */
.heaven-sun {
    position: absolute;
    left: 50%; top: 42%;
    width: 260px; height: 260px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle,
        rgba(110,80,170,0.55) 0%,
        rgba(74,53,114,0.32) 35%,
        rgba(52,32,90,0.12) 60%,
        transparent 100%);
    filter: blur(4px);
    box-shadow:
        0 0 80px rgba(74,53,114,0.30),
        0 0 160px rgba(74,53,114,0.12);
    animation: heavenSunFade 14s ease-in-out infinite;
}
@keyframes heavenSunFade {
    0%, 100% { transform: translate(-50%, -50%) scale(1);    opacity: 0.68; }
    50%      { transform: translate(-50%, -50%) scale(1.03); opacity: 0.82; }
}

/* Лучи света за солнцем */
.heaven-rays {
    position: absolute;
    left: 50%; top: 42%;
    width: 900px; height: 900px;
    transform: translate(-50%, -50%);
    background: repeating-conic-gradient(
        rgba(168,140,255,0.10) 0deg 4deg,
        transparent 4deg 18deg
    );
    mix-blend-mode: screen;
    opacity: 0.5;
    animation: heavenRaysSpin 90s linear infinite;
    pointer-events: none;
}
@keyframes heavenRaysSpin {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to   { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Парящие искры/пылинки */
.heaven-motes {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}
.heaven-mote {
    position: absolute;
    bottom: -6px;
    border-radius: 50%;
    background: radial-gradient(circle, #f0e6ff 0%, #b89cff 55%, transparent 100%);
    box-shadow: 0 0 6px rgba(200,170,255,0.8);
    animation:
        heavenMoteRise var(--rise-dur, 10s) linear infinite,
        heavenMoteTwinkle var(--twinkle-dur, 2s) ease-in-out infinite;
}
@keyframes heavenMoteRise {
    0%   { transform: translateY(0) translateX(0); }
    50%  { transform: translateY(-55vh) translateX(12px); }
    100% { transform: translateY(-110vh) translateX(-6px); }
}
@keyframes heavenMoteTwinkle {
    0%, 100% { opacity: 0.15; }
    50%      { opacity: 0.9; }
}

/* Перья */
.heaven-feather {
    position: absolute;
    top: -24px;
    width: 14px;
    height: 26px;
    background: linear-gradient(160deg, #efe6ff 0%, #c8b6ee 40%, #8a72c0 100%);
    clip-path: polygon(50% 0%, 100% 35%, 78% 100%, 50% 82%, 22% 100%, 0% 35%);
    opacity: 0.85;
    filter: drop-shadow(0 0 4px rgba(200,170,255,0.5));
    animation: heavenFeatherFall var(--fall-dur, 8s) ease-in forwards;
    pointer-events: none;
}
@keyframes heavenFeatherFall {
    0%   { transform: translate(0, 0) rotate(0deg);                          opacity: 0; }
    8%   { opacity: 0.85; }
    50%  { transform: translate(var(--sway, 20px), 55vh) rotate(calc(var(--rot, 200deg) * 0.5)); }
    92%  { opacity: 0.85; }
    100% { transform: translate(calc(var(--sway, 20px) * -1), 112vh) rotate(var(--rot, 200deg)); opacity: 0; }
}

/* Божественная вспышка */
.profile-modal.heaven-effect.heaven-pulse-active .heaven-bg {
    animation: heavenPulseFlash 0.9s ease-out;
}
.profile-modal.heaven-effect.heaven-pulse-active .heaven-sun {
    animation: heavenSunFade 14s ease-in-out infinite, heavenSunPulseBoost 0.9s ease-out;
}
.profile-modal.heaven-effect.heaven-pulse-active .heaven-crystal {
    animation-name: heavenCrystalSway, heavenCrystalShimmer, heavenCrystalPulse, heavenCrystalPulseBoost;
    animation-duration: 10s, 3.4s, 5.2s, 0.9s;
    animation-iteration-count: infinite, infinite, infinite, 1;
}
@keyframes heavenPulseFlash {
    0%   { filter: brightness(1); }
    15%  { filter: brightness(1.55); }
    100% { filter: brightness(1); }
}
@keyframes heavenSunPulseBoost {
    0%   { filter: brightness(1); }
    20%  { filter: brightness(1.8); }
    100% { filter: brightness(1); }
}
@keyframes heavenCrystalPulseBoost {
    0%   { filter: brightness(1); }
    20%  { filter: brightness(1.7); }
    100% { filter: brightness(1); }
}

/* Плотные облака */
.heaven-cloud {
    position: absolute;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 45%, rgba(84,60,130,0.75) 0%, rgba(50,32,90,0.45) 45%, transparent 75%),
        radial-gradient(circle at 70% 55%, rgba(60,40,105,0.55) 0%, transparent 70%);
    filter: blur(20px);
    opacity: 0.85;
    animation: heavenCloudDrift linear infinite;
    mix-blend-mode: screen;
}
@keyframes heavenCloudDrift {
    0%   { transform: translateX(-25%); }
    100% { transform: translateX(125%); }
}

/* Кометы */
.heaven-comet {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #d0bff0;
    border-radius: 50%;
    box-shadow:
        0 0 5px #e0d0ff,
        0 0 12px #7a5cff,
        0 0 24px rgba(122,92,255,0.6);
    pointer-events: none;
    opacity: 0;
}
.heaven-comet::after {
    content: "";
    position: absolute;
    top: 50%; right: 0;
    width: 130px; height: 1.5px;
    background: linear-gradient(90deg,
        rgba(224,208,255,0.85) 0%,
        rgba(122,92,255,0.5) 40%,
        rgba(74,53,114,0) 100%);
    transform: translateY(-50%);
    transform-origin: right center;
}

/* Кристаллы снизу */
.heaven-crystals {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 46%;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}
.heaven-crystal {
    position: absolute;
    bottom: -12px;
    width: 14px;
    height: 100px;
    background: linear-gradient(180deg,
        rgba(150,120,220,0.05) 0%,
        rgba(110,80,180,0.55) 30%,
        rgba(74,53,140,0.85) 65%,
        rgba(26,15,56,1) 100%);
    clip-path: polygon(50% 0, 92% 38%, 78% 100%, 22% 100%, 8% 38%);
    filter: blur(0.4px) brightness(1);
    box-shadow:
        inset 0 0 6px rgba(200,180,255,0.25),
        0 0 8px rgba(90,60,160,0.35);
    transform-origin: bottom center;
    animation:
        heavenCrystalSway 10s ease-in-out infinite,
        heavenCrystalShimmer 3.4s ease-in-out infinite,
        heavenCrystalPulse 5.2s ease-in-out infinite;
    animation-delay: 0s, calc(var(--i, 0) * -0.37s), calc(var(--i, 0) * -0.61s);
    animation-fill-mode: none, none, none;
}
.heaven-crystal.spawn-in {
    animation:
        heavenCrystalSpawn 0.6s cubic-bezier(.2,1.4,.4,1) both,
        heavenCrystalSway 10s ease-in-out infinite,
        heavenCrystalShimmer 3.4s ease-in-out infinite,
        heavenCrystalPulse 5.2s ease-in-out infinite;
}
@keyframes heavenCrystalSway {
    0%, 100% { transform: rotate(-1.2deg) translateX(var(--px, 0px)); }
    50%      { transform: rotate(1.2deg) translateX(var(--px, 0px)); }
}
@keyframes heavenCrystalShimmer {
    0%, 100% { filter: blur(0.4px) brightness(1); }
    45%      { filter: blur(0.4px) brightness(1.35); }
    55%      { filter: blur(0.4px) brightness(0.92); }
}
@keyframes heavenCrystalPulse {
    0%, 100% {
        box-shadow: inset 0 0 6px rgba(200,180,255,0.25), 0 0 8px rgba(90,60,160,0.35);
    }
    50% {
        box-shadow: inset 0 0 10px rgba(210,190,255,0.45), 0 0 16px rgba(124,92,255,0.55);
    }
}
@keyframes heavenCrystalSpawn {
    0%   { transform: scale(0.15) translateY(20%); opacity: 0; filter: brightness(2.4); }
    55%  { opacity: 1; filter: brightness(1.8); }
    100% { transform: scale(1) translateY(0); opacity: 1; filter: brightness(1); }
}
.heaven-crystal::after {
    content: '';
    position: absolute;
    inset: -6px;
    background: radial-gradient(circle, rgba(200,170,255,0.9) 0%, rgba(124,92,255,0) 70%);
    opacity: 0;
    pointer-events: none;
}
.heaven-crystal.spawn-in::after {
    animation: heavenCrystalSparkBurst 0.6s ease-out both;
}
@keyframes heavenCrystalSparkBurst {
    0%   { opacity: 0.9; transform: scale(0.3); }
    100% { opacity: 0; transform: scale(2.2); }
}
@media (prefers-reduced-motion: reduce) {
    .heaven-crystal, .heaven-crystal.spawn-in, .heaven-crystal::after {
        animation: none !important;
    }
}

/* ---------- Broadcast-эффект ---------- */
.effect-broadcast-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    overflow: hidden;
    animation: effectOverlayFade 0.4s ease-out;
}
.effect-broadcast-overlay.hidden { display: none; }
.effect-broadcast-overlay .heaven-crystals { height: 60%; }
.effect-broadcast-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
@keyframes effectOverlayFade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---------- Слои эффектов вокруг сообщений ---------- */
.msg-particle-layer {
    position: absolute;
    pointer-events: none;
    z-index: 0;
    opacity: 0.30;
    overflow: hidden;
    border-radius: 12px;
}
.msg-matrix-stream {
    position: absolute;
    top: 0; height: 100%;
    width: 14px; overflow: hidden;
    font-family: monospace;
    font-size: 12px;
    font-weight: 700;
    line-height: 14px;
    color: #4fff81;
    text-shadow: 0 0 4px rgba(79,255,129,0.5);
    opacity: var(--matrix-opacity, 0.32);
    white-space: pre;
    mix-blend-mode: screen;
}
.msg-matrix-stream span { display: block; height: 14px; }
.msg-matrix-track {
    position: absolute; left: 0; top: 0;
    display: flex; flex-direction: column;
    will-change: transform;
}
.msg-matrix-stream.is-down .msg-matrix-track { animation: matrixFlowDown var(--matrix-speed, 7s) linear infinite; }
.msg-matrix-stream.is-up   .msg-matrix-track { animation: matrixFlowUp   var(--matrix-speed, 7s) linear infinite; }
@keyframes matrixFlowDown { from { transform: translateY(-50%); } to { transform: translateY(0); } }
@keyframes matrixFlowUp   { from { transform: translateY(0); }   to { transform: translateY(-50%); } }

.msg-crystal-layer {
    position: absolute;
    pointer-events: none;
    z-index: 0;
    overflow: visible;
    opacity: 0.85;
}
.msg-crystal {
    position: absolute;
    top: 0;
    background: linear-gradient(180deg,
        rgba(150,120,220,0) 0%,
        rgba(110,80,180,0.65) 40%,
        rgba(74,53,140,0.9) 70%,
        rgba(26,15,56,1) 100%);
    clip-path: polygon(50% 0, 100% 42%, 76% 100%, 24% 100%, 0 42%);
    filter: blur(0.3px);
    box-shadow:
        inset 0 0 5px rgba(200,180,255,0.3),
        0 0 6px rgba(90,60,160,0.55);
    transform-origin: top center;
    transform: scaleY(0);
    opacity: 0;
    animation: crystalGrowDown 4.4s cubic-bezier(.22,.9,.3,1) infinite;
    animation-delay: var(--c-delay, 0s);
}
@keyframes crystalGrowDown {
    0%   { transform: scaleY(0);    opacity: 0; }
    22%  { transform: scaleY(1.05); opacity: 0.95; }
    36%  { transform: scaleY(1);    opacity: 0.95; }
    55%  { transform: scaleY(1);    opacity: 0.95; }
    74%  { transform: scaleY(0.05); opacity: 0; }
    100% { transform: scaleY(0.05); opacity: 0; }
}

/* ---------- Прочие модалки ---------- */
.new-group-modal .new-group-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.new-group-body label { font-size: 12px; color: var(--text-dim); display: flex; flex-direction: column; gap: 5px; }
.new-group-body input[type="text"] {
    background: var(--bg-2); border: 1px solid var(--border);
    border-radius: 8px; padding: 9px 11px;
    color: var(--text-main); font-size: 13px;
}
.group-type-options { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-main); }
.group-type-options label { flex-direction: row; align-items: center; gap: 6px; }
.group-member-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--bg-2); border: 1px solid var(--border); border-radius: 20px; padding: 4px 8px; font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.chip-remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 13px; }

.members-modal .members-list { padding: 10px 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.member-row { display: flex; align-items: center; gap: 10px; }
.member-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.member-info { flex: 1; min-width: 0; }
.member-name { font-size: 13px; font-weight: 600; }
.member-username { font-size: 11px; color: var(--text-dim); }
.member-role-label { font-size: 11px; color: var(--text-dim); }
.member-role-select {
    background: var(--bg-2); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text-main);
    font-size: 11px; padding: 3px 5px;
}
.member-remove-btn { background: none; border: none; color: var(--danger); font-size: 11px; cursor: pointer; margin-left: 4px; }

.user-search-results { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.user-result { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.user-result:hover { background: var(--bg-2); }
.user-result-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.user-result-main { flex: 1; min-width: 0; }
.user-result-name { font-size: 13px; font-weight: 600; }
.user-result-username { font-size: 11px; color: var(--text-dim); }
.user-result-tag {
    font-size: 10px; letter-spacing: 0.6px;
    color: var(--text-dim); border: 1px solid var(--border);
    border-radius: 10px; padding: 2px 8px;
    text-transform: uppercase; flex-shrink: 0; white-space: nowrap;
}
.user-result-tag.tag-channel { color: #7c5cff; border-color: #7c5cff; background: rgba(124,92,255,0.08); }
.user-result-tag.tag-group   { color: var(--accent); border-color: var(--accent); background: rgba(78,225,255,0.08); }
.chat-result .user-result-avatar { border: 1px solid var(--border); }
.admin-mini-badge { font-size: 9px; color: var(--accent); border: 1px solid var(--accent); border-radius: 6px; padding: 0 4px; margin-left: 4px; }

/* =====================================================================
   АДАПТАЦИЯ
   ===================================================================== */
@media (max-width: 1024px) {
    .chat-list { width: 260px; }
    .profile-modal.admin-effect,
    .profile-modal.heaven-effect { width: 92vw; }
}
@media (max-width: 800px) {
    .layout { position: relative; display: block; height: 100dvh; }
    .rail {
         position: fixed; left: 0; right: 0; top: 0;
         width: 100%; height: 56px;
         padding: 0 12px; padding-top: env(safe-area-inset-top);
         flex-direction: row; justify-content: space-between;
         border-right: none; border-bottom: 1px solid var(--border);
         z-index: 40; gap: 8px;
     }
    .rail-avatar { width: 38px; height: 38px; }
    .rail-icons { flex-direction: row; gap: 6px; margin: 0; }
    .rail-icon { width: 34px; height: 34px; font-size: 16px; }
    .chat-list {
        position: absolute; inset: 56px 0 0 0;
        width: 100% !important; min-width: 0; max-width: none;
        border-right: none;
    }
    .resize-handle { display: none; }
    .chat-main {
        position: absolute; inset: 56px 0 0 0;
        z-index: 10; background: var(--bg-0);
        display: none;
    }
    .layout.mobile-show-chat .chat-main { display: flex; }
    .layout.mobile-show-chat .chat-list { display: none; }
    .chat-placeholder { display: none !important; }
    .chat-back-btn { display: inline-flex; }
    .chat-header { padding: 10px 12px; gap: 8px; }
    .chat-header-avatar { width: 34px; height: 34px; }
    .admin-chat-messages { padding: 12px; gap: 12px; }
    .bot-message, .self-message { max-width: 86%; gap: 8px; }
    .bot-message-avatar, .self-message-avatar { width: 32px; height: 32px; font-size: 13px; }
    .admin-chat-form { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
    .admin-chat-form-row input[type="text"] { font-size: 16px; padding: 10px 12px; }
    .modal { width: 100vw; max-width: 100vw; max-height: 100dvh; border-radius: 0; }
    .profile-modal.admin-effect,
    .profile-modal.heaven-effect { width: 100vw; max-width: 100vw; max-height: 100dvh; }
    .profile-modal.admin-effect .profile-avatar-big,
    .profile-modal.heaven-effect .profile-avatar-big { width: 120px; height: 120px; font-size: 52px; }
    .profile-modal.admin-effect .profile-view,
    .profile-modal.heaven-effect .profile-view { padding: 24px 14px; }
    .profile-modal.admin-effect .profile-view h3,
    .profile-modal.heaven-effect .profile-view h3 { font-size: 22px; }
    .matrix-desc-img { max-height: 150px; }
}
@media (max-width: 420px) {
    .user-result-tag { display: none; }
    .matrix-desc-img { max-height: 110px; }
    .bot-message, .self-message { max-width: 92%; }
}
@media (max-width: 900px) and (orientation: landscape) {
    .rail { height: 44px; }
    .chat-list, .chat-main { margin-bottom: 44px; }
}
/* ---------- Упоминания @username в сообщениях ---------- */
.mention {
    color: #4ee1ff;
    background: rgba(78,225,255,0.12);
    border-radius: 4px;
    padding: 1px 4px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}
.mention:hover {
    background: rgba(78,225,255,0.25);
}
.self-message-bubble .mention {
    color: #04101c;
    background: rgba(4,16,28,0.15);
}
.self-message-bubble .mention:hover {
    background: rgba(4,16,28,0.28);
}

/* ---------- Меню @ в поле ввода ---------- */
.mention-menu {
    position: fixed;
    z-index: 250;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.55);
    min-width: 220px;
    max-width: 320px;
    max-height: 260px;
    overflow-y: auto;
    padding: 4px;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}
.mention-menu.open {
    opacity: 1;
    transform: translateY(0);
}
.mention-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
}
.mention-menu-item:hover,
.mention-menu-item.active {
    background: var(--bg-2);
}
.mention-menu-item .mm-nickname {
    font-weight: 600;
    color: var(--text-main);
}
.mention-menu-item .mm-username {
    font-size: 11px;
    color: var(--text-dim);
    margin-left: auto;
}
.mention-menu-empty {
    padding: 10px 12px;
    color: var(--text-dim);
    font-size: 12px;
    text-align: center;
}
/* ---------- Добавление участников в группу ---------- */
.members-add-block {
    padding: 12px 16px 4px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-1);
}
.members-add-block input[type="text"] {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 11px;
    color: var(--text-main);
    font-size: 13px;
    outline: none;
    margin-bottom: 8px;
}
.members-add-block input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(78,225,255,0.12);
}
.members-add-block .user-search-results {
    max-height: 180px;
    margin-bottom: 8px;
}
.members-add-toggle {
    margin: 10px 16px 14px;
    width: calc(100% - 32px);
    text-align: center;
}
/* =====================================================================
   MECHA — светлый индустриальный профиль (SYNAPSE-MECHA-ALEXAND1914)
   ===================================================================== */
.profile-modal.mecha-effect {
    background: #2a1f10;
    position: relative;
    width: 1100px;
    max-width: 95vw;
    max-height: 90vh;
    overflow: hidden;
    border: 2px solid #6a5028;
    box-shadow:
        inset 0 0 80px rgba(255,180,60,0.08),
        inset 0 0 200px rgba(120,80,20,0.15),
        0 0 40px rgba(255,180,60,0.15);
    animation: mechaBgPulse 10s ease-in-out infinite;
}
@keyframes mechaBgPulse {
    0%, 100% { filter: brightness(0.94) saturate(0.95); }
    50%      { filter: brightness(1.05) saturate(1.10); }
}

.profile-modal.mecha-effect .profile-view { padding: 44px; position: relative; z-index: 2; }
.profile-modal.mecha-effect .profile-avatar-big {
    width: 168px; height: 168px; font-size: 72px;
    border-color: #d4a24a;
    box-shadow:
        0 0 26px rgba(212,162,74,0.65),
        0 0 60px rgba(212,162,74,0.30),
        inset 0 0 20px rgba(255,210,120,0.20);
}
.profile-modal.mecha-effect .profile-view h3 {
    font-size: 28px; letter-spacing: 2px; color: #f0d28a;
    text-shadow:
        0 0 8px rgba(212,162,74,0.6),
        0 0 18px rgba(212,162,74,0.35);
}
.profile-modal.mecha-effect .profile-username {
    font-size: 16px; color: #b89860;
}
.profile-modal.mecha-effect .profile-description {
    font-size: 15px; max-width: 520px;
    margin-left: auto; margin-right: auto;
    color: #e8c98a;
    text-shadow: 0 0 6px rgba(212,162,74,0.35);
}
.profile-modal.mecha-effect .modal-header {
    border-bottom-color: #6a5028;
    color: #f0d28a;
}
.profile-modal.mecha-effect .admin-badge {
    background: rgba(212,162,74,0.15);
    border-color: #d4a24a;
    color: #f0d28a;
}
.profile-modal.mecha-effect .btn-secondary {
    background: rgba(212,162,74,0.08);
    border-color: #6a5028;
    color: #e8c98a;
}
.profile-modal.mecha-effect .btn-secondary:hover {
    border-color: #d4a24a;
    color: #f0d28a;
}
.profile-modal.mecha-effect .logout-link { color: #b8823a; }
.profile-modal.mecha-effect::after { content: none; }

/* Морзе-пульсация рамки профиля (SYNAPSE = ... -. .- .--. ... .) */
.profile-modal.mecha-effect .modal-header,
.profile-modal.mecha-effect .profile-view {
    animation: none;
}
.profile-modal.mecha-effect::before {
    content: "";
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
    border-radius: inherit;
    pointer-events: none;
    z-index: 4;
    animation: mechaMorseBorder 6s steps(2, end) infinite;
}
@keyframes mechaMorseBorder {
    /* S = ... */
    0%, 6%    { border-color: #ffc95c; box-shadow: 0 0 20px rgba(255,201,92,0.55); }
    6.1%, 10% { border-color: transparent; box-shadow: none; }
    10.1%, 16%   { border-color: #ffc95c; box-shadow: 0 0 20px rgba(255,201,92,0.55); }
    16.1%, 20%   { border-color: transparent; box-shadow: none; }
    20.1%, 26%   { border-color: #ffc95c; box-shadow: 0 0 20px rgba(255,201,92,0.55); }
    26.1%, 34%   { border-color: transparent; box-shadow: none; }
    /* Y = -.-- */
    34.1%, 46%   { border-color: #ffc95c; box-shadow: 0 0 22px rgba(255,201,92,0.6); }
    46.1%, 50%   { border-color: transparent; box-shadow: none; }
    50.1%, 56%   { border-color: #ffc95c; box-shadow: 0 0 20px rgba(255,201,92,0.55); }
    56.1%, 60%   { border-color: transparent; box-shadow: none; }
    60.1%, 72%   { border-color: #ffc95c; box-shadow: 0 0 22px rgba(255,201,92,0.6); }
    72.1%, 76%   { border-color: transparent; box-shadow: none; }
    76.1%, 82%   { border-color: #ffc95c; box-shadow: 0 0 20px rgba(255,201,92,0.55); }
    82.1%, 100%  { border-color: transparent; box-shadow: none; }
}

/* Заклёпки по углам */
.mecha-rivet {
    position: absolute;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #d4a24a, #6a5028 70%, #2a1f10);
    box-shadow: 0 0 4px rgba(212,162,74,0.5);
    z-index: 3;
    pointer-events: none;
}
.mecha-rivet.tl { top: 8px; left: 8px; }
.mecha-rivet.tr { top: 8px; right: 8px; }
.mecha-rivet.bl { bottom: 8px; left: 8px; }
.mecha-rivet.br { bottom: 8px; right: 8px; }

/* Шестерёнки в фоне профиля (большие) */
.mecha-gear-bg {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #3a2c14 0%, #1a1408 100%);
    box-shadow:
        inset 0 0 20px rgba(0,0,0,0.6),
        0 0 30px rgba(0,0,0,0.4);
    z-index: 0;
    pointer-events: none;
    opacity: 0.55;
}
.mecha-gear-bg::before {
    content: "";
    position: absolute;
    inset: 18%;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #5a4020 0%, #1a1408 100%);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
}
.mecha-gear-bg::after {
    content: "";
    position: absolute;
    inset: 38%;
    border-radius: 50%;
    background: #0a0805;
    box-shadow: inset 0 0 6px rgba(0,0,0,0.9);
}
/* Зубья через conic-gradient — сымитируем через box-shadow и обводку */
.mecha-gear-teeth {
    position: absolute;
    inset: -6%;
    border-radius: 50%;
    background:
        repeating-conic-gradient(
            #4a3418 0deg 8deg,
            transparent 8deg 16deg
        );
    -webkit-mask: radial-gradient(circle, transparent 45%, #000 46%, #000 55%, transparent 56%);
    mask: radial-gradient(circle, transparent 45%, #000 46%, #000 55%, transparent 56%);
    animation: mechaGearSpin 12s linear infinite;
    filter: drop-shadow(0 0 4px rgba(212,162,74,0.3));
}

@keyframes mechaGearSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
@keyframes mechaGearSpinRev {
    from { transform: rotate(0deg); }
    to   { transform: rotate(-360deg); }
}
/* Рывок — раз в 4-6 сек «заедает» */
.mecha-gear-bg.jerk {
    animation: mechaGearJerk 5s ease-in-out infinite;
}
@keyframes mechaGearJerk {
    0%, 80%   { transform: rotate(0deg); }
    82%       { transform: rotate(4deg); }
    84%       { transform: rotate(0deg); }
    86%       { transform: rotate(6deg); }
    88%, 100% { transform: rotate(0deg); }
}

/* Мелкая пыль */
.mecha-dust {
    position: absolute;
    width: 2px; height: 2px;
    border-radius: 50%;
    background: radial-gradient(circle, #ffd27a 0%, #a87630 60%, transparent 100%);
    box-shadow: 0 0 3px rgba(255,210,120,0.7);
    pointer-events: none;
    z-index: 1;
    animation: mechaDustFloat var(--dust-dur, 12s) linear infinite;
}
@keyframes mechaDustFloat {
    0%   { transform: translate(0, 0);       opacity: 0; }
    10%  { opacity: 0.9; }
    50%  { transform: translate(8px, -40px); opacity: 0.7; }
    90%  { opacity: 0.4; }
    100% { transform: translate(-6px, -80px); opacity: 0; }
}

/* Пар / дым из труб */
.mecha-steam {
    position: absolute;
    bottom: 0;
    width: 40px;
    height: 100px;
    background: linear-gradient(180deg,
        rgba(200,180,140,0.0) 0%,
        rgba(200,180,140,0.15) 40%,
        rgba(200,180,140,0.28) 70%,
        rgba(200,180,140,0.0) 100%);
    filter: blur(8px);
    pointer-events: none;
    z-index: 1;
    animation: mechaSteamRise var(--steam-dur, 8s) ease-out infinite;
}
@keyframes mechaSteamRise {
    0%   { transform: translateY(0) scale(0.8); opacity: 0; }
    20%  { opacity: 0.7; }
    100% { transform: translateY(-260px) scale(1.6); opacity: 0; }
}

/* Мигающие лампочки */
.mecha-lamp {
    position: absolute;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff3c8, #d4a24a 55%, #6a5028);
    box-shadow:
        0 0 8px rgba(255,210,120,0.9),
        0 0 20px rgba(255,210,120,0.4);
    pointer-events: none;
    z-index: 3;
    animation: mechaLampBlink var(--lamp-dur, 3s) steps(2, end) infinite;
    animation-delay: var(--lamp-delay, 0s);
}
@keyframes mechaLampBlink {
    0%, 40%   { opacity: 1; filter: brightness(1); }
    41%, 50%  { opacity: 0.15; filter: brightness(0.4); }
    51%, 70%  { opacity: 1; filter: brightness(1); }
    71%, 80%  { opacity: 0.15; filter: brightness(0.4); }
    81%, 100% { opacity: 1; filter: brightness(1); }
}

/* Тёмные полосы (потёки/царапины) */
.mecha-crack {
    position: absolute;
    background: linear-gradient(180deg,
        rgba(0,0,0,0.0) 0%,
        rgba(0,0,0,0.35) 30%,
        rgba(0,0,0,0.25) 70%,
        rgba(0,0,0,0.0) 100%);
    pointer-events: none;
    z-index: 1;
    border-radius: 2px;
}

/* Искры */
.mecha-spark {
    position: absolute;
    width: 3px; height: 3px;
    background: #fff3c8;
    border-radius: 50%;
    box-shadow:
        0 0 4px #ffd27a,
        0 0 10px #d4a24a;
    pointer-events: none;
    z-index: 5;
    animation: mechaSparkFly var(--spark-dur, 1.2s) ease-out forwards;
}
@keyframes mechaSparkFly {
    0%   { transform: translate(0,0) scale(1); opacity: 1; }
    100% { transform: translate(var(--sx, 20px), var(--sy, 40px)) scale(0.4); opacity: 0; }
}

/* =========================================================
   MECHA — шестерёнки вокруг сообщений
   ========================================================= */
.msg-gear-layer {
    position: absolute;
    pointer-events: none;
    z-index: 0;
    overflow: visible;
    opacity: 0.9;
}
.msg-gear {
    position: absolute;
    top: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #5a4020 0%, #2a1f10 100%);
    box-shadow:
        inset 0 0 4px rgba(0,0,0,0.6),
        0 0 4px rgba(212,162,74,0.4);
    transform-origin: 50% 50%;
    animation: mechaGearSpin var(--gear-dur, 6s) linear infinite;
}
.msg-gear.rev { animation-name: mechaGearSpinRev; }
.msg-gear::before {
    content: "";
    position: absolute;
    inset: 25%;
    border-radius: 50%;
    background: #1a1408;
}
.msg-gear::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background:
        repeating-conic-gradient(
            #7a5a28 0deg 20deg,
            transparent 20deg 45deg
        );
    -webkit-mask: radial-gradient(circle, transparent 42%, #000 43%, #000 56%, transparent 57%);
    mask: radial-gradient(circle, transparent 42%, #000 43%, #000 56%, transparent 57%);
    animation: mechaGearSpin var(--gear-teeth-dur, 3s) linear infinite;
}
.msg-gear.rev::after { animation-name: mechaGearSpinRev; }

@media (prefers-reduced-motion: reduce) {
    .mecha-gear-bg, .mecha-gear-bg.jerk, .mecha-gear-teeth,
    .mecha-dust, .mecha-steam, .mecha-lamp, .mecha-spark,
    .msg-gear, .msg-gear::after {
        animation: none !important;
    }
}
/* =====================================================================
   СТИКЕРЫ
   ===================================================================== */
.sticker-wrap { position: relative; flex-shrink: 0; }

.sticker-btn {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: border-color 0.15s ease, transform 0.1s ease;
}
.sticker-btn:hover  { border-color: var(--accent); }
.sticker-btn:active { transform: scale(0.95); }

/* ---------- Меню стикеров ---------- */
.sticker-menu {
    position: absolute;
    bottom: 110%;
    right: 0;
    width: 280px;
    max-height: 340px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.5);
    z-index: 30;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: stickerMenuIn 0.15s cubic-bezier(.2,.9,.2,1);
}
.sticker-menu.hidden { display: none; }
@keyframes stickerMenuIn {
    from { opacity: 0; transform: translateY(6px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.sticker-menu-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--bg-2);
    flex-shrink: 0;
}
.sticker-menu-tab {
    flex: 1;
    padding: 8px 10px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 12px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.sticker-menu-tab:hover  { color: var(--text-main); }
.sticker-menu-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.sticker-menu-grid {
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    overflow-y: auto;
    flex: 1;
    align-content: start;
}
.sticker-item {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    transition: border-color 0.15s ease, transform 0.1s ease;
}
.sticker-item:hover  { border-color: var(--accent); transform: scale(1.04); }
.sticker-item:active { transform: scale(0.97); }
.sticker-item img {
    max-width: 100%;
    max-height: 100%;
    display: block;
    object-fit: contain;
    pointer-events: none;
}
.sticker-menu-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
    padding: 24px 0;
}

/* ---------- Сообщение-стикер ---------- */
.sticker-message {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    max-width: min(72%, 640px);
    min-width: 0;
}
.sticker-message.self-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.sticker-message.bot-message { align-self: flex-start; }

.sticker-message-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.sticker-message.self-message .sticker-message-content { align-items: flex-end; }
.sticker-message.bot-message .sticker-message-content   { align-items: flex-start; }

.sticker-wrap-img {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    background: none;
    border: none;
    box-shadow: none;
}

.sticker-hidden-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: transparent;
    font-size: 12px;
    user-select: none;
    pointer-events: none;
    z-index: 0;
    white-space: nowrap;
}

.sticker-image {
    max-width: 180px;
    max-height: 180px;
    display: block;
    position: relative;
    z-index: 1;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
    background: none;
    border: none;
    box-shadow: none;
}

.sticker-message .msg-time {
    color: var(--text-dim);
    opacity: 0.55;
    font-size: 10px;
    text-align: right;
    user-select: none;
    padding: 0 2px;
}
.sticker-message.bot-message .msg-time { text-align: left; }

.sticker-message .msg-reactions { margin-top: 2px; }

@media (max-width: 800px) {
    .sticker-menu { width: 240px; max-height: 300px; }
    .sticker-image { max-width: 150px; max-height: 150px; }
    .sticker-menu-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 420px) {
    .sticker-image { max-width: 130px; max-height: 130px; }
}

/* ---------- Кто отправил последнее сообщение ---------- */
.chat-last-sender { color: var(--accent); font-weight: 600; opacity: 0.9; }

/* =====================================================================
ОБНОВЛЁННЫЕ ВЛОЖЕНИЯ
===================================================================== */
.msg-attach { margin: 6px 0; }
.msg-attach-image { position: relative; display: inline-block; border-radius: 10px; overflow: hidden; background: rgba(0,0,0,0.2); line-height: 0; max-width: 100%; }
.msg-attach-image img { max-width: 100%; max-height: 340px; border-radius: 10px; display: block; cursor: zoom-in; }
.msg-attach-video { border-radius: 10px; overflow: hidden; background: #000; max-width: 100%; }
.msg-attach-video video { max-width: 100%; max-height: 340px; display: block; background: #000; }
.msg-attach-audio { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,0.22); padding: 8px 12px; border-radius: 12px; min-width: 240px; border: 1px solid rgba(255,255,255,0.06); }
.audio-toggle { width: 38px; height: 38px; border-radius: 50%; border: none; background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #04101c; cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.audio-icon-pause { display: none; }
.msg-attach-audio.playing .audio-icon-play { display: none; }
.msg-attach-audio.playing .audio-icon-pause { display: inline; }
.audio-main { flex: 1; min-width: 150px; }
.audio-name { font-size: 12px; font-weight: 700; margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.audio-progress { height: 5px; border-radius: 3px; background: rgba(255,255,255,0.16); overflow: hidden; cursor: pointer; }
.audio-progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.audio-meta { display: flex; justify-content: space-between; font-size: 10px; opacity: 0.7; margin-top: 4px; }
.msg-attach-file { display: flex; align-items: center; gap: 12px; background: linear-gradient(135deg, rgba(78,225,255,0.05), rgba(124,92,255,0.05)); padding: 10px 12px; border-radius: 12px; cursor: pointer; border: 1px solid rgba(78,225,255,0.15); max-width: 320px; }
.msg-attach-file:hover { border-color: var(--accent); }
.msg-attach-file[data-mime^="image/"] .file-icon { color: #4ee1ff; }
.msg-attach-file[data-mime^="video/"] .file-icon { color: #ff6a9e; }
.msg-attach-file[data-mime^="audio/"] .file-icon { color: #b389ff; }
.msg-attach-file[data-mime="application/pdf"] .file-icon { color: #ff5a5a; }
.msg-attach-file[data-mime^="text/"] .file-icon { color: #4fff81; }
.msg-attach-file[data-mime^="application/json"] .file-icon { color: #ffe066; }

/* =====================================================================
   КАРТОЧКА ГРУППЫ / КАНАЛА
   ===================================================================== */
.group-card-modal {
    width: 520px;
    max-width: 95vw;
    max-height: 88vh;
    padding: 0;
    overflow: hidden;
}
.group-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.group-card-hero {
    position: relative;
    padding: 28px 24px 22px;
    background:
        radial-gradient(circle at 50% 0%, rgba(78,225,255,0.18) 0%, transparent 65%),
        radial-gradient(circle at 90% 90%, rgba(124,92,255,0.16) 0%, transparent 55%),
        linear-gradient(180deg, #0e1526 0%, #0b0f1a 100%);
    border-bottom: 1px solid var(--border);
    text-align: center;
}
.group-card-avatar {
    width: 92px; height: 92px;
    border-radius: 50%;
    object-fit: cover;
    display: inline-block;
    border: 3px solid rgba(78,225,255,0.45);
    box-shadow:
        0 0 0 4px rgba(78,225,255,0.08),
        0 12px 32px rgba(0,0,0,0.45);
    background: var(--bg-2);
}
.group-card-name {
    margin: 14px 0 6px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: var(--text-main);
    word-break: break-word;
}
.group-card-type-tag {
    display: inline-block;
    font-size: 10px;
    letter-spacing: 2px;
    font-weight: 700;
    color: var(--accent);
    border: 1px solid var(--accent);
    background: rgba(78,225,255,0.06);
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
}

.group-card-body {
    padding: 18px 22px 8px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow-y: auto;
    min-height: 0;
}
.group-card-section { display: flex; flex-direction: column; gap: 8px; }
.group-card-label {
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-dim);
    font-weight: 600;
}
.group-card-description {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-main);
    word-break: break-word;
    white-space: pre-wrap;
    padding: 12px 14px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.group-card-description.empty {
    color: var(--text-dim);
    font-style: italic;
}

/* Ссылка (slug) */
.group-card-slug-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.group-card-slug {
    flex: 1;
    color: var(--accent);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    letter-spacing: 0.4px;
    word-break: break-all;
}
.group-card-slug[data-slug=""] { color: var(--text-dim); font-style: italic; font-weight: 400; }
.group-card-slug:hover { text-decoration: underline; }
.group-card-icon-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    width: 30px; height: 30px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.group-card-icon-btn:hover { border-color: var(--accent); color: var(--accent); }

.group-card-slug-editor {
    margin-top: 8px;
    padding: 12px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.group-card-slug-input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 10px;
    overflow: hidden;
}
.group-card-slug-prefix {
    color: var(--accent);
    font-weight: 700;
    font-size: 14px;
    margin-right: 2px;
}
.group-card-slug-input-wrap input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-size: 14px;
    padding: 9px 0;
    font-family: 'Consolas', 'Menlo', monospace;
    letter-spacing: 0.5px;
}
.group-card-slug-editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.group-card-slug-editor-actions .btn-primary,
.group-card-slug-editor-actions .btn-secondary { padding: 7px 12px; font-size: 12px; }
.group-card-slug-hint {
    font-size: 11px;
    color: var(--danger);
    min-height: 0;
}
.group-card-slug-hint:empty { display: none; }

/* Владелец */
.group-card-owner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.group-card-owner-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
    flex-shrink: 0;
}
.group-card-owner-info { min-width: 0; }
.group-card-owner-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.group-card-owner-username {
    font-size: 12px;
    color: var(--text-dim);
}
.group-card-owner-empty {
    color: var(--text-dim);
    font-style: italic;
    font-size: 13px;
}

/* Документы */
.group-card-docs {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.group-card-doc {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
}
.group-card-doc:hover { border-color: var(--accent); }
.group-card-doc-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: rgba(78,225,255,0.08);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.group-card-doc-icon .icon-svg { width: 18px; height: 18px; fill: var(--accent); }
.group-card-doc-main { min-width: 0; flex: 1; }
.group-card-doc-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.group-card-doc-meta {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 2px;
}
.group-card-docs-empty {
    padding: 14px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
    font-style: italic;
    background: var(--bg-2);
    border: 1px dashed var(--border);
    border-radius: 10px;
}

/* Футер карточки */
.group-card-footer {
    padding: 12px 22px 18px;
    border-top: 1px solid var(--border);
    background: var(--bg-1);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.group-card-footer .btn-danger,
.group-card-footer .btn-secondary {
    flex: 1;
    min-width: 140px;
    padding: 10px 14px;
    font-size: 13px;
}

/* Модалка передачи владения */
.leave-group-modal { width: 460px; max-width: 95vw; }
.leave-group-body {
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.leave-group-text {
    margin: 0;
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.5;
}
.leave-group-body label {
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.leave-group-body select {
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 13px;
    width: 100%;
}
.leave-group-body select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(78,225,255,0.12);
}

@media (max-width: 800px) {
    .group-card-modal { width: 100vw; max-width: 100vw; max-height: 100dvh; border-radius: 0; }
    .group-card-avatar { width: 78px; height: 78px; }
    .group-card-name { font-size: 18px; }
    .leave-group-modal { width: 100vw; max-width: 100vw; }
}
/* =====================================================================
   ERROR.LOG — рамка-ромб поверх сообщения
   =====================================================================
   Ожидается, что хост-элемент (пузырь или .sticker-wrap-img) уже
   имеет position: relative — это так и есть для .bot-message-bubble,
   .self-message-bubble и .sticker-wrap-img.
*/

.msg-error-frame {
    position: absolute;
    inset: -14px;
    border: 2px solid #ff3040;
    border-radius: 3px;
    background: transparent;
    transform: rotate(15deg);
    pointer-events: none;
    z-index: 1;
    box-shadow:
        0 0 6px rgba(255,48,64,0.85),
        0 0 18px rgba(255,48,64,0.45),
        inset 0 0 12px rgba(255,48,64,0.15);
    animation:
        msgErrorPulse 2.2s ease-in-out infinite,
        msgErrorShimmer 3.2s linear infinite;
    overflow: visible;
}

.msg-error-frame-inner {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translate(-50%, 60%) rotate(1deg);
    transform-origin: center center;
    color: #ff8a94;
    background: rgba(20, 4, 8, 0.85);
    border: 1px solid rgba(255, 48, 64, 0.55);
    border-radius: 4px;
    padding: 2px 8px;
    font-family: 'Consolas', 'Menlo', 'Courier New', monospace;
    font-size: 40px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    text-shadow:
        0 0 6px rgba(255,48,64,0.9),
        0 0 14px rgba(255,48,64,0.55);
    white-space: nowrap;
    max-width: 999px;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    animation: msgErrorTextGlow 2.2s ease-in-out infinite;
}

@keyframes msgErrorPulse {
    0%, 100% {
        box-shadow:
            0 0 6px rgba(255,48,64,0.85),
            0 0 18px rgba(255,48,64,0.45),
            inset 0 0 12px rgba(255,48,64,0.15);
        filter: brightness(1);
    }
    50% {
        box-shadow:
            0 0 14px rgba(255,48,64,1),
            0 0 34px rgba(255,48,64,0.75),
            inset 0 0 22px rgba(255,48,64,0.32);
        filter: brightness(1.35);
    }
}

@keyframes msgErrorShimmer {
    0%   { border-color: #ff3040; }
    25%  { border-color: #ff7a5c; }
    50%  { border-color: #ff3040; }
    75%  { border-color: #ffb040; }
    100% { border-color: #ff3040; }
}

@keyframes msgErrorTextGlow {
    0%, 100% { opacity: 0.82; }
    50%      { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .msg-error-frame,
    .msg-error-frame-inner { animation: none !important; }
}
