/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== THEME TOKENS ===== */
[data-theme="dark"] {
    --bg-primary: #151e27;
    --bg-secondary: #0c141d;
    --bg-tertiary: #1c2a3a;
    --bg-message-own: #3a6ea5;
    --bg-message-other: #1b2a39;
    --bg-input: #222e3c;
    --bg-hover: #1f2a35;
    --bg-card: #1c2a38;
    --text-primary: #f2f5f8;
    --text-secondary: #7a8896;
    --text-muted: #586a7b;
    --accent: #54a3ee;
    --border: #1d2a39;
    --danger: #e6566a;
    --success: #4fae4e;
    --shadow: rgba(0, 0, 0, 0.32);
    --scrollbar-thumb: #38495c;
    --scrollbar-track: transparent;
    --recording-color: #e6566a;
    /* Message meta (time/checks) on own bubble — own bubble is dark, so light text */
    --msg-meta-own: rgba(255, 255, 255, 0.55);
    --msg-check-own: rgba(255, 255, 255, 0.45);
    /* Default chat backdrop (gradient + dot pattern) */
    --chat-bg-a: #0f1720;
    --chat-bg-b: #182430;
    --chat-dot: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f1f4f7;
    --bg-tertiary: #e8edf2;
    --bg-message-own: #e6f3d4;
    --bg-message-other: #f1f3f5;
    --bg-input: #eef1f4;
    --bg-hover: #eef1f4;
    --bg-card: #ffffff;
    --text-primary: #14202b;
    --text-secondary: #6b7783;
    --text-muted: #9aa6b1;
    --accent: #3390ec;
    --border: #e4e9ee;
    --danger: #e0364f;
    --success: #43a047;
    --shadow: rgba(20, 40, 60, 0.14);
    --scrollbar-thumb: #c6cfd8;
    --scrollbar-track: transparent;
    --recording-color: #e0364f;
    /* own bubble is light green → dark meta text */
    --msg-meta-own: rgba(0, 0, 0, 0.42);
    --msg-check-own: var(--accent);
    /* Default chat backdrop (gradient + dot pattern) */
    --chat-bg-a: #eef3f8;
    --chat-bg-b: #dfeaf3;
    --chat-dot: rgba(30, 70, 110, 0.08);
}

/* Tokens shared by all themes */
:root {
    /* Accent hover/dim are derived from --accent so an accent change cascades */
    --accent-hover: color-mix(in srgb, var(--accent), #fff 14%);
    --accent-dim: color-mix(in srgb, var(--accent) 16%, transparent);
    --danger-hover: color-mix(in srgb, var(--danger), #fff 12%);

    /* Shape & elevation scale */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-bubble: 16px;
    --elev-1: 0 1px 2px var(--shadow);
    --elev-2: 0 4px 16px var(--shadow);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.mobile-only { display: none; }
.text-danger { color: var(--danger) !important; }

/* ===== AUTH SCREENS ===== */
.auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg-secondary);
}

.auth-card {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 24px var(--shadow);
    text-align: center;
}

.auth-logo {
    font-size: 64px;
    margin-bottom: 8px;
}

.auth-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.auth-subtitle {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 14px;
    line-height: 1.5;
}

.auth-link {
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 13px;
}

.auth-link a {
    color: var(--accent);
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* Auth divider */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    color: var(--text-muted);
    font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Passkey button */
.btn-passkey {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    background: transparent;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.btn-passkey:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}
.btn-passkey:active {
    transform: scale(0.98);
}
.btn-passkey svg {
    flex-shrink: 0;
    opacity: 0.8;
}
.btn-passkey:hover svg {
    opacity: 1;
}

/* Passkey list items in settings */
.passkey-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-input);
    border-radius: 10px;
    margin-bottom: 8px;
}
.passkey-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    min-width: 0;
}
.passkey-item-info svg {
    flex-shrink: 0;
    opacity: 0.6;
}
.passkey-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.passkey-item-date {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.passkey-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    color: var(--text-muted);
    transition: all 0.15s;
    flex-shrink: 0;
}
.passkey-delete-btn:hover {
    background: rgba(255, 59, 48, 0.1);
    color: #ff3b30;
}

.info-box {
    background: var(--bg-input);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: left;
    line-height: 1.8;
}

/* ===== FORM ELEMENTS ===== */
.input-group {
    margin-bottom: 16px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.input-group input,
.input-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 2px solid transparent;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus,
.input-group textarea:focus {
    border-color: var(--accent);
}

.input-group input::placeholder,
.input-group textarea::placeholder {
    color: var(--text-muted);
}

.input-group input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-family: inherit;
    color: var(--text-primary);
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-full { width: 100%; }

.btn-small {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: 8px;
    background: var(--bg-input);
    cursor: pointer;
    margin-top: 8px;
}

.btn-small:hover { background: var(--bg-hover); }

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-send {
    color: var(--accent) !important;
}

/* ===== MAIN APP LAYOUT ===== */
#app {
    display: flex;
    height: 100vh;
    position: relative;
}

/* ===== SIDEBAR ===== */
#sidebar {
    width: 380px;
    min-width: 300px;
    max-width: 420px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 5;
}

#sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

#search-wrapper {
    flex: 1;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

#chat-search {
    width: 100%;
    padding: 8px 12px 8px 38px;
    background: var(--bg-input);
    border: none;
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

#chat-search::placeholder { color: var(--text-muted); }

/* Chat list */
#chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px;
    margin: 2px 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}

.chat-item:hover { background: var(--bg-hover); }
.chat-item.active {
    background: var(--accent-dim);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.chat-item-info {
    flex: 1;
    min-width: 0;
}

.chat-item-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.chat-item-name {
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 3px;
    min-width: 0;
    overflow: hidden;
}
/* усекается только текст имени — значок верификации не обрезается */
.chat-item-name .ci-name-txt {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.chat-item-name .verified-badge,
.chat-item-name .verified-badge-sm { flex-shrink: 0; }

.chat-item-time {
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
    margin-left: 8px;
}

.chat-item-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-item-preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.unread-badge {
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    flex-shrink: 0;
    margin-left: 8px;
}

/* ===== AVATAR ===== */
.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--accent);
    flex-shrink: 0;
    position: relative;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.avatar-sm { width: 40px; height: 40px; font-size: 16px; }
.avatar-xl { width: 100px; height: 100px; font-size: 36px; }

.avatar.avatar-coffee {
    background: transparent;
    padding: 0;
    overflow: hidden;
}
.avatar.avatar-coffee svg {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.avatar .online-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: #4caf50;
    border-radius: 50%;
    border: 3px solid var(--bg-secondary);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

/* ===== DROPDOWN MENU ===== */
.dropdown-menu {
    position: absolute;
    top: 56px;
    left: 12px;
    background: var(--bg-primary);
    border-radius: 10px;
    box-shadow: 0 4px 24px var(--shadow);
    min-width: 220px;
    z-index: 100;
    overflow: hidden;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item svg { color: var(--text-secondary); }

.dropdown-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 0;
}

/* ===== CHAT AREA ===== */
#chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

/* Empty state */
#chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

#chat-empty .empty-icon { font-size: 72px; margin-bottom: 16px; }
#chat-empty h2 { font-size: 20px; margin-bottom: 8px; color: var(--text-primary); }
#chat-empty p { font-size: 14px; }

/* Chat header */
#chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    min-height: 56px;
}

#chat-header-info { flex: 1; min-width: 0; }
#chat-header-name { font-weight: 600; font-size: 15px; }
#chat-header-status { font-size: 12px; color: var(--text-secondary); }
#chat-header-status.online { color: var(--accent); }

/* Messages */
#messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    /* Дефолтный «телеграмный» фон: мягкий градиент + едва заметные точки.
       Классы wallpaper-* перекрывают его целиком (background shorthand). */
    background:
        radial-gradient(var(--chat-dot) 1px, transparent 1.4px),
        linear-gradient(165deg, var(--chat-bg-a) 0%, var(--chat-bg-b) 55%, var(--chat-bg-a) 100%);
    background-size: 22px 22px, 100% 100%;
    background-attachment: local, fixed;
}

.message {
    max-width: 68%;
    padding: 7px 12px 6px;
    border-radius: var(--radius-bubble);
    word-wrap: break-word;
    position: relative;
    box-shadow: var(--elev-1);
    animation: msgIn 0.2s ease;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.own {
    background: var(--bg-message-own);
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.message.other {
    background: var(--bg-message-other);
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.message-text {
    font-size: 14.5px;
    line-height: 1.45;
    white-space: pre-wrap;
}

/* Inline Markdown inside messages / feed */
.message-text code,
.feed-post-text code {
    font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.88em;
    background: rgba(255, 255, 255, 0.1);
    padding: 1px 5px;
    border-radius: 5px;
}
.message-text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.message.other .message-text a,
.feed-post-text a { color: var(--accent); }

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 2px;
}

.message-time {
    font-size: 11px;
    color: var(--msg-meta-own);
}

.message.other .message-time { color: var(--text-secondary); }

.message-check {
    font-size: 14px;
    color: var(--msg-check-own);
}

.message-check.read {
    color: var(--accent);
}

/* Media messages */
.message-image {
    border-radius: 8px;
    max-width: 300px;
    max-height: 300px;
    cursor: pointer;
    display: block;
}

/* ===== Album / media grid ===== */
.message-album {
    padding: 3px;
    max-width: 360px;
    overflow: hidden;
}
.message-album .message-sender-name {
    padding: 4px 9px 2px;
}
.message-album .album-caption {
    padding: 6px 9px 0;
}
.message-album .message-meta {
    padding: 2px 9px 2px;
}

.media-grid {
    border-radius: 10px;
    overflow: hidden;
    width: 100%;
}

.media-grid-item {
    position: relative;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.15);
    cursor: pointer;
}

/* ── Single image: natural aspect ratio, no crop ── */
.media-grid-1 {
    display: block;
}
.media-grid-1 .media-grid-item img,
.media-grid-1 .media-grid-item video {
    display: block;
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    border-radius: 10px;
}

/* ── Multi-image grids: fixed cells, cover-crop ── */
.media-grid-2,
.media-grid-3,
.media-grid-4,
.media-grid-many {
    display: grid;
    gap: 3px;
}
.media-grid-2 .media-grid-item img,
.media-grid-2 .media-grid-item video,
.media-grid-3 .media-grid-item img,
.media-grid-3 .media-grid-item video,
.media-grid-4 .media-grid-item img,
.media-grid-4 .media-grid-item video,
.media-grid-many .media-grid-item img,
.media-grid-many .media-grid-item video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 2 images — side by side */
.media-grid-2 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 200px;
}

/* 3 images — one big left, two stacked right */
.media-grid-3 {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 130px 130px;
}
.media-grid-3 .media-grid-item:nth-child(1) {
    grid-row: 1 / span 2;
}

/* 4 images — 2x2 */
.media-grid-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 160px 160px;
}

/* 5+ images — 3 cols */
.media-grid-many {
    grid-template-columns: 1fr 1fr 1fr;
    grid-auto-rows: 110px;
}

/* ===== Attach preview bar ===== */
#attach-preview-bar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px 8px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
}
#attach-preview-thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.attach-chip {
    position: relative;
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-input);
    border: 1px solid var(--border);
}
.attach-chip img,
.attach-chip video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.attach-chip-file {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}
.attach-chip-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.attach-chip-remove:hover {
    background: rgba(0, 0, 0, 0.85);
}
#attach-preview-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}
#attach-preview-count {
    font-weight: 500;
}

.message-video {
    border-radius: 8px;
    max-width: 350px;
    max-height: 300px;
}

.message-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
}

.message-file-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-dim);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 20px;
}

.message-file-info { min-width: 0; }
.message-file-name { font-size: 13px; font-weight: 500; }
.message-file-size { font-size: 11px; color: var(--text-secondary); }

/* Voice message */
.message-voice {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
}

.voice-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.voice-progress {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.voice-waveform {
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.voice-waveform-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    width: 0%;
    transition: width 0.1s linear;
}

.voice-duration {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Typing indicator */
.typing-indicator {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--accent);
    font-style: italic;
}

/* Date separator */
.date-separator {
    text-align: center;
    padding: 8px 0;
}

.date-separator span {
    background: var(--bg-tertiary);
    padding: 4px 12px;
    border-radius: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== MESSAGE INPUT ===== */
/* «Плавающий» бар: без сплошной подложки, поле и кнопки висят над фоном чата */
#message-input-area {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 8px 14px 12px;
    background: transparent;
    border-top: none;
}

#message-input-area .icon-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    box-shadow: var(--elev-1);
    transition: background 0.15s, color 0.15s;
}
#message-input-area .icon-btn:hover { background: var(--bg-hover); color: var(--accent); }
#message-input-area .btn-send {
    background: var(--accent);
    border-color: transparent;
    color: #fff;
}
#message-input-area .btn-send:hover { background: var(--accent-hover); color: #fff; }

#input-wrapper {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 21px;
    padding: 4px 14px;
    box-shadow: var(--elev-1);
    transition: border-color 0.15s;
}
#input-wrapper:focus-within { border-color: var(--accent); }

#message-input {
    width: 100%;
    padding: 8px 0;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
}

#message-input::placeholder { color: var(--text-muted); }

/* Voice recording */
#voice-recording {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
}

.recording-indicator {
    width: 12px;
    height: 12px;
    background: var(--recording-color);
    border-radius: 50%;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

#recording-time {
    flex: 1;
    font-size: 14px;
    color: var(--recording-color);
}

/* ===== SLIDE PANELS ===== */
.slide-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 380px;
    height: 100%;
    background: var(--bg-secondary);
    z-index: 20;
    display: flex;
    flex-direction: column;
    /* Мягкое появление вместо жёсткого слайда на всю ширину */
    animation: panelIn 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
    box-shadow: 4px 0 24px var(--shadow);
}

@keyframes panelIn {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
    .slide-panel, .slide-panel-right { animation: none; }
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    min-height: 56px;
}

.panel-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
}

/* ===== PROFILE REDESIGN ===== */
.profile-avatar-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
}
.avatar-overlay {
    position: absolute;
    bottom: 0; right: calc(50% - 50px);
    width: 36px; height: 36px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    border: 3px solid var(--bg-secondary);
    transition: transform 0.15s;
}
.avatar-overlay:hover { transform: scale(1.1); }
.avatar-overlay svg { width: 16px; height: 16px; color: #fff; }

.input-prefix-wrapper {
    display: flex; align-items: center;
    background: var(--bg-input);
    border-radius: 10px;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}
.input-prefix-wrapper:focus-within { border-color: var(--accent); }
.input-prefix {
    padding: 12px 0 12px 16px;
    color: var(--text-secondary);
    font-size: 14px; user-select: none;
}
.input-prefix-wrapper input {
    background: transparent !important;
    border: none !important;
    padding-left: 4px !important;
    outline: none;
}
.input-hint {
    display: block; margin-top: 4px;
    font-size: 12px; color: var(--text-muted);
}
.profile-info-row {
    display: flex; align-items: center;
    gap: 12px; padding: 12px 0; margin-bottom: 16px;
    font-size: 14px; color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

/* ===== SETTINGS REDESIGN ===== */
/* Centered, readable settings column on wide screens */
.settings-body {
    padding: 18px 16px 28px !important;
    max-width: 660px;
    margin: 0 auto;
}

.settings-user-card {
    display: flex; align-items: center;
    gap: 14px; padding: 14px 16px;
    cursor: pointer; transition: background 0.15s, border-color 0.15s;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
}
.settings-user-card:hover { background: var(--bg-hover); border-color: var(--accent); }
.settings-user-info { flex: 1; min-width: 0; }
.settings-user-name { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.settings-user-handle { font-size: 13px; color: var(--text-secondary); }
.settings-chevron { color: var(--text-muted); flex-shrink: 0; }
.settings-chevron-sm { color: var(--text-muted); flex-shrink: 0; }

.settings-card {
    background: var(--bg-card);
    margin: 0 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--elev-1);
}
.settings-card-title {
    display: flex; align-items: center;
    gap: 12px; padding: 14px 16px 8px;
    font-size: 14px; font-weight: 600; color: var(--accent);
}
.settings-card-title svg { color: var(--accent); flex-shrink: 0; }

.settings-row {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.settings-row:last-child { border-bottom: none; }
.settings-row.clickable { cursor: pointer; transition: background 0.15s; }
.settings-row.clickable:hover { background: var(--bg-hover); }
.settings-row-label { color: var(--text-primary); }
.settings-row-value { color: var(--text-secondary); }

.settings-subsection { padding: 8px 16px 16px; }

.settings-toggle-row {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px; color: var(--text-primary);
}

/* Toggle switch */
.toggle-switch {
    position: relative; width: 44px; height: 24px; flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0;
    background: var(--bg-input); border-radius: 12px;
    cursor: pointer; transition: background 0.3s;
}
.toggle-slider::before {
    content: ''; position: absolute;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--text-secondary);
    top: 3px; left: 3px;
    transition: transform 0.3s, background 0.3s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent-dim); }
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: var(--accent);
}

.settings-desc {
    font-size: 13px; color: var(--text-secondary); margin-bottom: 12px;
}

/* Theme segmented control */
.theme-segmented {
    display: flex; gap: 6px;
    background: var(--bg-input);
    padding: 4px; border-radius: var(--radius-md);
}
.theme-seg-btn {
    flex: 1; padding: 8px 10px;
    border: none; background: transparent;
    color: var(--text-secondary); font-size: 13px; font-weight: 600;
    border-radius: calc(var(--radius-md) - 4px);
    cursor: pointer; transition: background 0.15s, color 0.15s;
}
.theme-seg-btn:hover { color: var(--text-primary); }
.theme-seg-btn.active {
    background: var(--accent); color: #fff;
}

/* Accent color swatches */
.accent-swatches {
    display: flex; flex-wrap: wrap; gap: 12px;
}
.accent-swatch {
    width: 30px; height: 30px; border-radius: 50%;
    cursor: pointer; position: relative;
    border: 2px solid transparent; transition: transform 0.12s;
}
.accent-swatch:hover { transform: scale(1.1); }
.accent-swatch.active {
    box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px currentColor;
}
.accent-swatch.active::after {
    content: ''; position: absolute; inset: 0;
    background: no-repeat center/14px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
}

/* Active sessions list */
.sessions-list:empty::after {
    content: 'Загрузка…'; display: block;
    padding: 12px 16px; color: var(--text-secondary); font-size: 13px;
}
.session-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.session-item:last-child { border-bottom: none; }
.session-icon { color: var(--text-secondary); flex-shrink: 0; }
.session-info { flex: 1; min-width: 0; }
.session-name { font-size: 14px; color: var(--text-primary); }
.session-meta { font-size: 12px; color: var(--text-secondary); }
.session-current-tag {
    font-size: 11px; font-weight: 600; color: var(--success);
}
.session-revoke {
    background: none; border: none; cursor: pointer;
    color: var(--danger); font-size: 13px; flex-shrink: 0;
}
.session-revoke:hover { text-decoration: underline; }

.radio-group { margin-bottom: 16px; }
.radio-item {
    display: flex; align-items: center;
    gap: 10px; padding: 10px 0;
    cursor: pointer; font-size: 14px;
}
.radio-item input[type="radio"] {
    accent-color: var(--accent); width: 18px; height: 18px;
}

/* ===== WALLPAPERS ===== */
.wallpaper-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px; padding: 0 16px;
}
.wallpaper-option {
    aspect-ratio: 3/4; border-radius: 12px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 0.2s, transform 0.15s;
    position: relative; overflow: hidden;
}
.wallpaper-option:hover { transform: scale(1.03); }
.wallpaper-option.active { border-color: var(--accent); }
.wallpaper-option.active::after {
    content: '\2713'; position: absolute;
    top: 6px; right: 6px;
    width: 22px; height: 22px;
    background: var(--accent); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 13px; font-weight: 700;
}
.wallpaper-option-label {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 4px 6px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    font-size: 10px; color: rgba(255,255,255,0.85); text-align: center;
}

/* Wallpaper backgrounds */
/* «Без обоев» = дефолтный градиент с точками (как база #messages-container) */
.wallpaper-none {
    background:
        radial-gradient(var(--chat-dot) 1px, transparent 1.4px),
        linear-gradient(165deg, var(--chat-bg-a) 0%, var(--chat-bg-b) 55%, var(--chat-bg-a) 100%);
    background-size: 22px 22px, 100% 100%;
}
.wallpaper-gradient-ocean { background: linear-gradient(135deg, #0c1829 0%, #162544 30%, #1a3a5c 60%, #0d2137 100%); }
.wallpaper-gradient-sunset { background: linear-gradient(160deg, #1a0a2e 0%, #2d1b4e 30%, #4a1942 60%, #1a0a2e 100%); }
.wallpaper-gradient-forest { background: linear-gradient(145deg, #0a1f0a 0%, #0d2818 30%, #152f1b 60%, #0a1a0a 100%); }
.wallpaper-gradient-twilight { background: linear-gradient(135deg, #0f0c29 0%, #1a1040 30%, #24243e 60%, #0f0c29 100%); }
.wallpaper-gradient-ember { background: linear-gradient(160deg, #1a0000 0%, #2d1010 30%, #3d1515 60%, #1a0505 100%); }
.wallpaper-gradient-arctic { background: linear-gradient(145deg, #0a1a2a 0%, #102842 30%, #0f3460 60%, #0a1525 100%); }
.wallpaper-pattern-dots {
    background-color: #111b27;
    background-image: radial-gradient(circle, #1a2d42 1px, transparent 1px);
    background-size: 20px 20px;
}
.wallpaper-pattern-grid {
    background-color: #0f1923;
    background-image: linear-gradient(rgba(92,160,211,0.05) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(92,160,211,0.05) 1px, transparent 1px);
    background-size: 30px 30px;
}
.wallpaper-pattern-diagonal {
    background-color: #111b27;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(92,160,211,0.03) 10px, rgba(92,160,211,0.03) 11px);
}
.wallpaper-pattern-hexagon {
    background-color: #0e1621;
    background-image:
        linear-gradient(30deg, #162233 12%, transparent 12.5%, transparent 87%, #162233 87.5%),
        linear-gradient(150deg, #162233 12%, transparent 12.5%, transparent 87%, #162233 87.5%),
        linear-gradient(30deg, #162233 12%, transparent 12.5%, transparent 87%, #162233 87.5%),
        linear-gradient(150deg, #162233 12%, transparent 12.5%, transparent 87%, #162233 87.5%);
    background-size: 40px 70px;
    background-position: 0 0, 0 0, 20px 35px, 20px 35px;
}
.wallpaper-gradient-coffee { background: linear-gradient(135deg, #1a120b 0%, #2c1e13 30%, #3d2b1a 50%, #1a120b 100%); }
.wallpaper-gradient-midnight { background: linear-gradient(160deg, #020111 0%, #0a0a2e 30%, #16164d 50%, #020111 100%); }

/* Admin panel */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Admin tabs */
.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 4px;
}

.admin-tab {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.admin-tab.active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.admin-tab:hover:not(.active) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.admin-tab-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding: 0 4px;
}

.admin-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

/* Admin card grid */
.admin-card-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-user-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 14px;
    position: relative;
    transition: box-shadow 0.2s;
}

.admin-user-card:hover {
    box-shadow: 0 2px 12px var(--shadow);
}

.admin-user-card.blocked {
    opacity: 0.6;
}

.admin-bot-card {
    border-left: 3px solid var(--accent);
}

.admin-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.admin-card-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    overflow: visible;
}

.admin-card-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.admin-card-avatar-letter {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent);
}

.status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
    z-index: 1;
}

.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--text-muted); }
.status-dot.bot-dot { background: var(--accent); }

.admin-card-info {
    flex: 1;
    min-width: 0;
}

.admin-card-name {
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.admin-card-username {
    font-size: 12px;
    color: var(--text-secondary);
}

.admin-card-menu-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.admin-card-menu-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.admin-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.admin-badge {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
}

.admin-badge-admin {
    background: var(--accent-dim);
    color: var(--accent);
}

.admin-badge-gold {
    background: rgba(245, 200, 66, 0.15);
    color: #f5c842;
}

.admin-badge-premium {
    background: rgba(145, 132, 217, 0.18);
    color: #b5abfc;
}

.admin-badge-verified {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.admin-badge-blocked {
    background: rgba(224, 79, 95, 0.15);
    color: var(--danger);
}

.admin-badge-bot {
    background: var(--accent-dim);
    color: var(--accent);
}

.admin-card-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
}

/* Admin dropdown */
.admin-card-dropdown {
    position: absolute;
    top: 48px;
    right: 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    z-index: 10;
    min-width: 180px;
    box-shadow: 0 4px 16px var(--shadow);
}

.admin-dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.admin-dropdown-item:hover {
    background: var(--bg-hover);
}

.admin-dropdown-item.danger {
    color: var(--danger);
}

.admin-dropdown-item.danger:hover {
    background: rgba(224, 79, 95, 0.1);
}

.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.badge-admin {
    background: var(--accent-dim);
    color: var(--accent);
}

.badge-online {
    background: rgba(79, 174, 78, 0.15);
    color: var(--success);
}

/* User search results */
.user-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.user-result-item:hover {
    background: var(--bg-hover);
    margin: 0 -16px;
    padding: 12px 16px;
}

.user-result-info {
    flex: 1;
    min-width: 0;
}

.user-result-name {
    font-weight: 500;
    font-size: 14px;
}

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

/* ===== USER CARD PANEL ===== */
.slide-panel-right {
    left: auto;
    right: 0;
    border-left: 1px solid var(--border);
    animation: panelInRight 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes panelInRight {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: translateX(0); }
}

.user-card-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.user-card-name {
    font-size: 20px;
    font-weight: 600;
    margin-top: 12px;
}

.user-card-status {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.user-card-status.online {
    color: var(--accent);
}

.user-card-section {
    margin-bottom: 24px;
}

.user-card-row {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.user-card-label {
    font-size: 12px;
    color: var(--accent);
    margin-bottom: 2px;
}

.user-card-value {
    font-size: 14px;
    color: var(--text-primary);
    word-break: break-word;
}

/* Media tabs */
.media-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.media-tab {
    padding: 6px 12px;
    border: none;
    background: var(--bg-input);
    color: var(--text-secondary);
    border-radius: 16px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.media-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.media-tab.active {
    background: var(--accent);
    color: #fff;
}

/* Media grid */
.media-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.media-grid-item {
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    background: var(--bg-input);
}

.media-grid-item img,
.media-grid-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-grid-item .media-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px 6px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    font-size: 10px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ===== FIX (главное): в flex-колонке ленты сообщения с overflow:hidden
   (медиа-альбомы) по спеке получают min-size:0 и СЖИМАЛИСЬ до нуля —
   медиа превращалось в тонкую полоску. Запрещаем сообщениям сжиматься. ===== */
.message { flex-shrink: 0; }

/* ===== FIX: сетка альбома в чате конфликтовала с галереей «общих медиа»
   (обе .media-grid). Скоупим под .message-album и фиксируем высоту строк. ===== */
.message-album .media-grid { width: 100%; display: block; }
.message-album .media-grid-2,
.message-album .media-grid-3,
.message-album .media-grid-4,
.message-album .media-grid-many { display: grid; gap: 3px; }
.message-album .media-grid-1 { display: block; }
.message-album .media-grid-2 { grid-template-columns: 1fr 1fr; grid-auto-rows: 150px; }
.message-album .media-grid-3 { grid-template-columns: 2fr 1fr; grid-template-rows: 110px 110px; }
.message-album .media-grid-3 .media-grid-item:nth-child(1) { grid-row: 1 / span 2; }
.message-album .media-grid-4 { grid-template-columns: 1fr 1fr; grid-auto-rows: 130px; }
.message-album .media-grid-many { grid-template-columns: 1fr 1fr 1fr; grid-auto-rows: 110px; }
.message-album .media-grid-item { aspect-ratio: auto; min-height: 0; }
.message-album .media-grid-2 .media-grid-item,
.message-album .media-grid-3 .media-grid-item,
.message-album .media-grid-4 .media-grid-item,
.message-album .media-grid-many .media-grid-item { height: 100%; }
.message-album .media-grid-item img,
.message-album .media-grid-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* одиночное фото в альбоме — натуральные пропорции */
.message-album .media-grid-1 .media-grid-item { aspect-ratio: auto; height: auto; }
.message-album .media-grid-1 .media-grid-item img,
.message-album .media-grid-1 .media-grid-item video {
    height: auto; max-height: 400px; object-fit: contain;
}

.media-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.media-file-item:hover {
    background: var(--bg-hover);
}

.media-file-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-dim);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.media-file-info { flex: 1; min-width: 0; }
.media-file-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-file-meta { font-size: 11px; color: var(--text-secondary); }

.media-empty {
    padding: 30px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
}

/* Admin create result */
#admin-create-result {
    margin-top: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
    border-left: 3px solid var(--success);
}

#admin-create-result .cred-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

#admin-create-result .cred-value {
    font-weight: 600;
    color: var(--accent);
    user-select: all;
}

.btn-copy {
    padding: 4px 10px;
    border: none;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
}

.btn-copy:hover { background: var(--accent); color: #fff; }

/* (old inline admin buttons removed — now using dropdown menus) */

/* Verified badge */
.badge-verified {
    background: rgba(59, 130, 246, 0.15) !important;
    color: #3b82f6 !important;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.badge-blocked {
    background: rgba(239, 68, 68, 0.15) !important;
    color: #ef4444 !important;
}

.verified-icon-sm {
    width: 12px;
    height: 12px;
    fill: currentColor;
}

/* Verified badge icon — used throughout the app */
.verified-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #3b82f6;
    border-radius: 50%;
    margin-left: 4px;
    vertical-align: middle;
    flex-shrink: 0;
}

.verified-badge svg {
    width: 11px;
    height: 11px;
    fill: #fff;
}

.verified-badge-sm {
    width: 15px;
    height: 15px;
}

.verified-badge-sm svg {
    width: 9px;
    height: 9px;
}

/* Verified badge in chat list */
.chat-item .chat-item-name .verified-badge { margin-left: 3px; }

/* Verified badge in chat header */
#chat-header-info .verified-badge { margin-left: 4px; }

/* Chat header clickable */
#chat-header-info {
    cursor: pointer;
}

#chat-header-avatar {
    cursor: pointer;
}

/* ===== TOAST ===== */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 13px;
    color: #fff;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    max-width: 350px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--accent); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}

/* ===== IMAGE VIEWER ===== */
.image-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.image-viewer-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
}

/* ===== CHANNEL READONLY ===== */
#channel-readonly {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 16px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
}

/* ===== GROUP/CHANNEL CHAT LIST ICONS ===== */
.chat-item-type-icon {
    font-size: 12px;
    margin-right: 4px;
    opacity: 0.7;
}

.chat-item-sender {
    color: var(--accent);
    font-weight: 500;
}

/* ===== GROUP MESSAGE SENDER NAME ===== */
.message-sender-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 2px;
}

/* ===== SELECTED MEMBERS (group creation) ===== */
.selected-members {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
    min-height: 0;
}

.selected-member-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 4px;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
}

.selected-member-chip .chip-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
}

.selected-member-chip .chip-remove {
    cursor: pointer;
    margin-left: 2px;
    opacity: 0.6;
    font-size: 14px;
}

.selected-member-chip .chip-remove:hover {
    opacity: 1;
}

/* ===== PANEL HEADER ACTIONS ===== */
.panel-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

/* ===== MEMBERS LIST IN USER CARD ===== */
.member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.member-item:hover {
    background: var(--bg-hover);
    margin: 0 -8px;
    padding: 8px;
    border-radius: 8px;
}

.member-item .member-info {
    flex: 1;
    min-width: 0;
}

.member-item .member-name {
    font-size: 13px;
    font-weight: 500;
}

.member-item .member-role {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
}

.member-item .member-role.owner {
    background: var(--accent-dim);
    color: var(--accent);
}

.member-item .member-role.admin {
    background: rgba(79, 174, 78, 0.15);
    color: var(--success);
}

.member-item .member-status {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Member action buttons (promote/demote/kick) */
.member-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.member-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
}

.member-action-btn.promote {
    background: rgba(79, 174, 78, 0.1);
    color: var(--success);
}

.member-action-btn.promote:hover {
    background: var(--success);
    color: #fff;
}

.member-action-btn.demote {
    background: rgba(255, 152, 0, 0.1);
    color: #ff9800;
}

.member-action-btn.demote:hover {
    background: #ff9800;
    color: #fff;
}

.member-action-btn.kick {
    background: rgba(224, 79, 95, 0.1);
    color: var(--danger);
}

.member-action-btn.kick:hover {
    background: var(--danger);
    color: #fff;
}

/* Add member search in card */
.add-member-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.add-member-info {
    flex: 1;
    min-width: 0;
}

.add-member-name {
    font-size: 13px;
    font-weight: 500;
}

.add-member-bio {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Channel search results */
.channel-search-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.channel-item-left {
    flex: 1;
    min-width: 0;
}

.channel-name {
    font-size: 14px;
    font-weight: 500;
}

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

/* ===== FEED ===== */
/* Cap content width so posts stay readable on wide screens */
#feed-posts {
    max-width: 620px;
    margin: 0 auto;
}

.feed-loading, .feed-empty {
    padding: 32px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.feed-post {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 0;
    margin-bottom: 16px;
    transition: box-shadow 0.2s, transform 0.15s;
    overflow: hidden;
    border: 1px solid var(--border);
}

.feed-post:hover {
    box-shadow: 0 4px 20px var(--shadow);
}

.feed-post-inner {
    padding: 14px 16px;
}

.feed-post-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.feed-channel-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.feed-channel-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.feed-channel-avatar-letter {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
}

.feed-post-header-info {
    flex: 1;
    min-width: 0;
}

.feed-channel-name {
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.feed-channel-goto:hover .feed-channel-name,
.feed-channel-name.feed-channel-goto:hover {
    color: var(--accent);
    text-decoration: underline;
}

.feed-verified {
    color: var(--accent);
    flex-shrink: 0;
}

.feed-system-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--accent-dim);
    color: var(--accent);
}

.feed-post-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.feed-post-text {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 8px;
    word-break: break-word;
}

.feed-post-text a {
    color: var(--accent);
    text-decoration: none;
}

.feed-post-text a:hover {
    text-decoration: underline;
}

.feed-post-media {
    overflow: hidden;
    margin: 0 -16px 8px -16px;
}

.feed-post-media img {
    width: 100%;
    max-height: 450px;
    object-fit: cover;
    cursor: pointer;
    display: block;
}

/* Одно фото — естественная ориентация (вертикальное/горизонтальное) */
.feed-album-1 img {
    object-fit: contain;
    max-height: 520px;
    background: #000;
}

/* Сетка альбома */
.feed-album {
    display: grid;
    gap: 3px;
}
.feed-album-2 { grid-template-columns: 1fr 1fr; }
.feed-album-3 { grid-template-columns: 1fr 1fr 1fr; }
.feed-album-4 { grid-template-columns: 1fr 1fr; }
.feed-album-cell {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    cursor: pointer;
}
.feed-album-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.feed-album-more {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 28px;
    font-weight: 700;
}

/* Лайтбокс */
#feed-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(0,0,0,0.92);
    align-items: center;
    justify-content: center;
}
#feed-lightbox .lb-img {
    max-width: 92vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 6px;
}
#feed-lightbox .lb-close {
    position: absolute;
    top: 18px; right: 22px;
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    font-size: 22px;
    width: 42px; height: 42px;
    border-radius: 50%;
    cursor: pointer;
}
#feed-lightbox .lb-prev,
#feed-lightbox .lb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    font-size: 38px;
    width: 56px; height: 56px;
    border-radius: 50%;
    cursor: pointer;
    line-height: 1;
}
#feed-lightbox .lb-prev { left: 18px; }
#feed-lightbox .lb-next { right: 18px; }
#feed-lightbox .lb-close:hover,
#feed-lightbox .lb-prev:hover,
#feed-lightbox .lb-next:hover { background: rgba(255,255,255,0.25); }
#feed-lightbox .lb-counter {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    background: rgba(255,255,255,0.12);
    padding: 6px 14px;
    border-radius: 20px;
}

.feed-post-media video {
    width: 100%;
    max-height: 450px;
    display: block;
}

.feed-post-file {
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 8px;
}

/* Feed actions */
.feed-post-actions {
    display: flex;
    gap: 2px;
    padding: 4px 12px;
    border-top: 1px solid var(--border);
}

.feed-action-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.feed-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.feed-action-btn.liked {
    color: #e74c3c;
}

.feed-action-btn.liked svg path {
    fill: #e74c3c;
}

.feed-action-btn svg {
    flex-shrink: 0;
}

.feed-like-count, .feed-comment-count {
    font-size: 12px;
    min-width: 8px;
}

.feed-action-btn.feed-goto-btn {
    margin-left: auto;
}

/* Feed comments bar — full width like Telegram */
.feed-comments-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
    color: var(--accent);
    font-size: 13px;
    font-weight: 500;
}

.feed-comments-bar:hover {
    background: var(--bg-hover);
}

.feed-comments-bar svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.feed-comments-bar-text {
    flex: 1;
}

.feed-comments-bar-arrow {
    color: var(--text-muted);
    font-size: 16px;
}

/* Feed comments panel (full screen overlay) */
.feed-comments-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    animation: feedCommentSlideIn 0.25s ease;
}

@keyframes feedCommentSlideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.feed-comments-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.feed-comments-header h3 {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}

.feed-comments-back {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.feed-comments-back:hover {
    background: var(--bg-hover);
}

.feed-comments-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.feed-comments-loading, .feed-comments-empty {
    padding: 32px 12px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.feed-comment {
    display: flex;
    gap: 10px;
    padding: 10px 0;
}

.feed-comment + .feed-comment {
    border-top: 1px solid var(--border);
}

.feed-comment-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.feed-comment-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.feed-comment-avatar-letter {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

.feed-comment-body {
    flex: 1;
    min-width: 0;
}

.feed-comment-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.feed-comment-name {
    font-size: 14px;
    font-weight: 600;
}

.feed-comment-time {
    font-size: 12px;
    color: var(--text-muted);
}

.feed-comment-text {
    font-size: 14px;
    line-height: 1.45;
    margin-top: 4px;
}

.feed-comments-input-bar {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
    align-items: center;
}

.feed-comment-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.feed-comment-input:focus {
    border-color: var(--accent);
}

.feed-comment-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}

.feed-comment-send:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

/* ===== CHANNEL MSG LIKES/COMMENTS ===== */
.msg-channel-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    padding-top: 4px;
}

.msg-like-btn, .msg-comment-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: none;
    border-radius: 12px;
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.msg-like-btn:hover, .msg-comment-btn:hover {
    background: rgba(255,255,255,0.12);
    color: var(--text-primary);
}

.msg-like-btn.liked {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

.msg-like-btn.liked svg path {
    fill: #e74c3c;
}

.msg-like-count, .msg-comment-count {
    font-size: 11px;
    min-width: 6px;
}

.msg-comments-panel {
    margin-top: 6px;
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: 10px;
    max-height: 300px;
    overflow-y: auto;
}

/* ===== BETA TAB ===== */
.beta-section {
    margin-top: 8px;
}

.beta-feature-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--bg-card);
    border-radius: 10px;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.beta-tag {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    letter-spacing: 0.5px;
}

.beta-user-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card);
    border-radius: 10px;
    margin-bottom: 6px;
}

.beta-user-info {
    flex: 1;
    min-width: 0;
}

.beta-user-name {
    font-size: 14px;
    font-weight: 500;
}

.beta-user-username {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Toggle switch */
.beta-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.beta-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.beta-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-tertiary);
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.3s;
}

.beta-toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all 0.3s;
}

.beta-toggle input:checked + .beta-toggle-slider {
    background: var(--accent);
}

.beta-toggle input:checked + .beta-toggle-slider::before {
    transform: translateX(20px);
    background: #fff;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .mobile-only { display: flex; }

    #sidebar {
        width: 100%;
        max-width: none;
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 10;
    }

    #chat-area {
        width: 100%;
    }

    #app.chat-open #sidebar { display: none; }
    #app:not(.chat-open) #chat-area { display: none; }

    .slide-panel,
    .slide-panel-right {
        width: 100%;
    }

    .message { max-width: 85%; }

    .admin-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== CALL UI ===== */
.call-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: callFadeIn 0.3s ease;
}
@keyframes callFadeIn { from { opacity: 0; } to { opacity: 1; } }

.call-overlay__bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(160deg, #1a1f3a 0%, #0d1020 40%, #000 100%);
    pointer-events: none;
}
.call-overlay__bg--active {
    background: linear-gradient(160deg, #0f1a2e 0%, #0a0f1f 40%, #050810 100%);
}

.call-overlay__content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 60px 20px 40px;
    padding-bottom: max(40px, env(safe-area-inset-bottom, 40px));
    box-sizing: border-box;
    overflow-y: auto;
}

/* Avatar */
.call-avatar {
    width: 120px; height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex; align-items: center; justify-content: center;
    font-size: 42px; font-weight: 600; color: #fff;
    text-transform: uppercase; overflow: hidden; flex-shrink: 0;
    position: relative; z-index: 2;
}
.call-avatar--large { width: 140px; height: 140px; font-size: 48px; }
.call-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Name & subtitle */
.call-name {
    color: #fff; font-size: 28px; font-weight: 600;
    margin: 24px 0 6px; text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    position: relative; z-index: 5;
}
.call-subtitle {
    color: rgba(255,255,255,0.55); font-size: 16px; margin: 0;
    position: relative; z-index: 5;
}
.call-timer {
    color: rgba(255,255,255,0.45); font-size: 20px; font-weight: 300;
    font-variant-numeric: tabular-nums; letter-spacing: 2px;
    margin: 8px 0 0; min-height: 26px;
    position: relative; z-index: 5;
}

/* Pulse rings */
.call-pulse-rings {
    position: absolute; top: 80px;
    width: 240px; height: 240px;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
}
.call-pulse-ring {
    position: absolute; border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.12);
    animation: callPulse 2s ease-in-out infinite;
}
.call-pulse-ring--1 { width: 160px; height: 160px; animation-delay: 0s; }
.call-pulse-ring--2 { width: 200px; height: 200px; animation-delay: 0.4s; }
.call-pulse-ring--3 { width: 240px; height: 240px; animation-delay: 0.8s; }
@keyframes callPulse {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.08); opacity: 0.1; }
}

/* Connected ring */
.call-connected-ring {
    position: absolute; width: 160px; height: 160px;
    border-radius: 50%; border: 3px solid transparent;
    transition: border-color 0.5s, box-shadow 0.5s;
    pointer-events: none;
}
.call-connected-ring.active {
    border-color: rgba(52,199,89,0.5);
    box-shadow: 0 0 30px rgba(52,199,89,0.15);
}

/* Incoming call actions */
.call-incoming-actions {
    display: flex; gap: 64px; margin-top: auto; padding-bottom: 20px;
}
.call-action-group {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.call-action-label { color: rgba(255,255,255,0.5); font-size: 13px; }

.call-action-btn {
    width: 68px; height: 68px; border-radius: 50%;
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #fff; transition: transform 0.2s, box-shadow 0.2s;
}
.call-action-btn:hover { transform: scale(1.08); }
.call-action-btn--accept {
    background: linear-gradient(135deg, #34c759, #28a745);
    box-shadow: 0 4px 20px rgba(52,199,89,0.35);
}
.call-action-btn--accept:hover { box-shadow: 0 6px 28px rgba(52,199,89,0.5); }
.call-action-btn--reject {
    background: linear-gradient(135deg, #ff3b30, #dc2626);
    box-shadow: 0 4px 20px rgba(255,59,48,0.35);
}
.call-action-btn--reject:hover { box-shadow: 0 6px 28px rgba(255,59,48,0.5); }

/* Audio call view */
.call-audio-view {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    position: relative; z-index: 5;
}

/* Video call view */
.call-video { position: absolute; inset: 0; z-index: 0; }
.call-video #remote-video { width: 100%; height: 100%; object-fit: cover; }
.call-video #local-video {
    position: absolute; top: 20px; right: 20px;
    width: 140px; height: 190px; object-fit: cover;
    border-radius: 12px; border: 2px solid rgba(255,255,255,0.2);
    box-shadow: 0 4px 16px rgba(0,0,0,0.5); z-index: 2;
}

/* Active call controls */
.call-controls {
    margin-top: auto;
    display: flex; flex-direction: column; align-items: center;
    gap: 28px; padding-bottom: 10px;
    position: relative;
    z-index: 10;
}
.call-controls__row { display: flex; gap: 36px; }

.call-ctrl-btn {
    width: 58px; height: 58px; border-radius: 50%;
    border: none; background: rgba(255,255,255,0.1);
    color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; backdrop-filter: blur(8px);
}
.call-ctrl-btn:hover { background: rgba(255,255,255,0.18); transform: scale(1.06); }
.call-ctrl-btn.active { background: rgba(255,255,255,0.95); color: #1a1f3a; }
.call-ctrl-btn.muted { background: #ff3b30; color: #fff; }
.call-ctrl-label { color: rgba(255,255,255,0.45); font-size: 12px; }

.call-end-btn {
    display: flex; align-items: center; justify-content: center;
    gap: 10px; padding: 0 32px; height: 54px; border-radius: 27px;
    border: none; background: linear-gradient(135deg, #ff3b30, #dc2626);
    color: #fff; font-size: 16px; font-weight: 500;
    cursor: pointer; transition: all 0.2s;
    box-shadow: 0 4px 20px rgba(255,59,48,0.3);
}
.call-end-btn:hover {
    transform: scale(1.04);
    box-shadow: 0 6px 28px rgba(255,59,48,0.45);
}

/* Call buttons in user card */
.user-card-call-buttons { display: flex; gap: 12px; margin: 16px 0; }
.call-button {
    flex: 1; padding: 12px; border-radius: 10px;
    border: none; background: var(--accent); color: white;
    cursor: pointer; font-size: 14px; font-weight: 500;
    display: flex; align-items: center; justify-content: center;
    gap: 8px; transition: all 0.2s;
}
.call-button:hover { background: var(--accent-hover); transform: translateY(-1px); }
.call-button svg { width: 20px; height: 20px; }

/* ===== NAVIGATION RAIL ===== */
#nav-rail {
    width: 64px;
    background: var(--bg-tertiary, #151e28);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px 0;
    flex-shrink: 0;
    transition: width 0.25s ease;
    z-index: 20;
    overflow: hidden;
}

#nav-rail.expanded {
    width: 240px;
}

.nav-rail-top,
.nav-rail-bottom {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 8px;
}

.nav-rail-version {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 16px 8px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.2;
    letter-spacing: 0.3px;
}
.nav-rail-version-line {
    display: block;
    font-weight: 700;
    font-size: 12px;
    color: var(--accent);
}
.nav-rail-version-date {
    display: block;
    opacity: 0.7;
    text-transform: capitalize;
}

.nav-rail-item {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 48px;
    padding: 0 12px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    text-align: left;
    width: 100%;
}

.nav-rail-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-rail-item.active {
    background: var(--accent-dim);
    color: var(--accent);
}

.nav-rail-item.nav-rail-danger {
    color: var(--danger, #e04f5f);
}

.nav-rail-item.nav-rail-danger:hover {
    background: rgba(224, 79, 95, 0.12);
    color: var(--danger, #e04f5f);
}

.nav-rail-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-rail-label {
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.2s, transform 0.2s;
    font-weight: 500;
    pointer-events: none;
}

#nav-rail.expanded .nav-rail-label {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.nav-rail-expanded-only {
    display: none !important;
}

#nav-rail.expanded .nav-rail-expanded-only {
    display: flex !important;
}

#nav-rail.expanded #nav-admin-wrapper.nav-rail-expanded-only,
#nav-rail.expanded #nav-admin-wrapper:not(.hidden) {
    display: block !important;
}

#nav-admin-wrapper:not(.hidden) #nav-admin {
    display: none;
}

#nav-rail.expanded #nav-admin-wrapper:not(.hidden) #nav-admin {
    display: flex;
}

.nav-rail-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 12px;
}

.nav-rail-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-hover) center/cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    flex-shrink: 0;
    overflow: hidden;
}

.nav-rail-avatar svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

#nav-profile .nav-rail-icon {
    width: 32px;
    height: 32px;
}

#nav-rail-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 19;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

#nav-rail-backdrop:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

/* ===== CHAT LIST WRAPPER + FAB ===== */
#chat-list-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-height: 0;
    position: relative;
}

#chat-search-results {
    border-top: 1px solid var(--border);
}

#chat-search-results .search-results-header {
    padding: 8px 16px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

#fab-wrapper {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 10;
}

.fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.15s;
}

.fab:hover {
    background: var(--accent-hover, var(--accent));
    transform: scale(1.05);
}

.fab:active {
    transform: scale(0.95);
}

.fab svg {
    transition: transform 0.25s;
}

#fab-wrapper.open .fab svg {
    transform: rotate(45deg);
}

#fab-menu {
    position: absolute;
    bottom: 68px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--bg-secondary);
    padding: 6px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    min-width: 190px;
    transform-origin: bottom right;
    animation: fabMenuIn 0.18s ease;
}

@keyframes fabMenuIn {
    from { opacity: 0; transform: scale(0.9) translateY(6px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.fab-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
}

.fab-menu-item:hover {
    background: var(--bg-hover);
}

.fab-menu-item svg {
    color: var(--accent);
    flex-shrink: 0;
}

/* Hide old burger button on desktop (mobile-only) */
#btn-menu-mobile,
#mobile-avatar-btn {
    display: none;
}

/* ===== MESSAGE HOVER MENU BUTTON ===== */
.msg-hover-menu-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    transition: background 0.15s, color 0.15s;
    line-height: 1;
    padding: 0;
}

.msg-hover-menu-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.message:hover .msg-hover-menu-btn {
    display: flex;
}

/* ===== MESSAGE CONTEXT MENU ===== */
.msg-context-menu {
    position: fixed;
    z-index: 9999;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
    padding: 6px;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    animation: msgMenuIn 0.14s ease;
    transform-origin: top left;
}
@keyframes msgMenuIn {
    from { opacity: 0; transform: scale(0.92) translateY(-4px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.msg-context-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    transition: background 0.12s;
}
.msg-context-item:hover { background: var(--bg-hover); }
.msg-context-item.danger { color: #ff5252; }
.msg-context-item.danger:hover { background: rgba(255, 82, 82, 0.12); }
.msg-context-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* Edited label inside message meta */
.message-edited {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    margin-right: 4px;
}

/* Edit bar above input */
#edit-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    border-left: 3px solid var(--accent);
}
#edit-bar.hidden { display: none; }
.edit-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent);
    min-width: 0;
    flex: 1;
}
.edit-bar-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}
.edit-bar-text {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* ===== PANEL MODE: hide sidebar, expand slide-panel full-width ===== */
#app.panel-mode #sidebar { display: none !important; }
#app.panel-mode #chat-area { display: none !important; }
#app.panel-mode .slide-panel:not(.hidden) {
    left: 64px;
    width: calc(100% - 64px);
    max-width: none;
    box-shadow: none;
    border-right: none;
}
#app.panel-mode:has(#nav-rail.expanded) .slide-panel:not(.hidden) {
    left: 240px;
    width: calc(100% - 240px);
}
@media (max-width: 768px) {
    #app.panel-mode .slide-panel:not(.hidden) {
        left: 0;
        width: 100%;
    }
}

.avatar-xs {
    width: 32px;
    height: 32px;
    font-size: 11px;
}

/* ===== RESPONSIVE: hide rail on mobile, show in-header burger+avatar ===== */
@media (max-width: 768px) {
    #nav-rail {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 240px;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 100;
    }

    #nav-rail.mobile-open {
        transform: translateX(0);
    }

    #nav-rail.mobile-open .nav-rail-label {
        opacity: 1;
        transform: translateX(0);
        pointer-events: auto;
    }

    #nav-rail.mobile-open .nav-rail-expanded-only {
        display: flex !important;
    }

    #nav-rail.mobile-open #nav-admin-wrapper:not(.hidden) {
        display: block !important;
    }

    #nav-rail.mobile-open #nav-admin-wrapper:not(.hidden) #nav-admin {
        display: flex;
    }

    #btn-menu-mobile,
    #mobile-avatar-btn {
        display: flex;
    }

    #fab-wrapper {
        bottom: 16px;
        right: 16px;
    }
}

/* ===== HELP BOT MESSAGES ===== */
.help-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.help-msg-bot {
    background: var(--bg-message-other, #1e2c3a);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.help-msg-user {
    background: var(--bg-message-own, #2b5278);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.help-msg-meta {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    text-align: right;
    margin-top: 4px;
}
.help-msg-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.06);
    border-radius: 6px;
    margin-top: 6px;
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
}
.help-msg-file:hover {
    background: rgba(255,255,255,0.1);
}
/* Settings help button */
.settings-row-btn {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    font-size: 15px;
    font-family: inherit;
    transition: background .15s;
    border-radius: 10px;
}
.settings-row-btn:hover {
    background: rgba(255,255,255,0.04);
}
.settings-row-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.settings-row-left svg {
    color: var(--accent);
}

/* ===== REGISTRATION METHOD TABS ===== */
.reg-method-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.reg-tab {
    flex: 1;
    padding: 10px 12px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all .2s;
}
.reg-tab.active {
    background: var(--accent);
    color: #fff;
}
.reg-tab:hover:not(.active) {
    background: var(--bg-hover);
}
.info-box {
    background: var(--bg-tertiary);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 12px;
}
.input-prefix-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border-radius: 10px;
    border: 1px solid var(--border);
}
.input-prefix-wrapper input {
    border: none !important;
    background: transparent !important;
    border-radius: 0 10px 10px 0 !important;
    flex: 1;
}
.input-prefix {
    padding: 0 2px 0 12px;
    color: var(--text-secondary);
    font-size: 15px;
    user-select: none;
}

/* ===== PHONE BANNER ===== */
.phone-banner {
    background: linear-gradient(135deg, #2b3a4a, #1e2c3a);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 10;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
}
.phone-banner-text {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #f0c040;
    font-size: 13px;
}
.phone-banner-text span {
    color: var(--text-primary);
}
.phone-banner-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ===== GOLD PREMIUM BADGE ===== */
.verified-badge-gold {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: 4px;
    vertical-align: middle;
    flex-shrink: 0;
    position: relative;
    filter: drop-shadow(0 0 3px rgba(245, 200, 66, 0.4));
    transition: filter 0.3s ease;
}
.verified-badge-gold:hover {
    filter: drop-shadow(0 0 6px rgba(245, 200, 66, 0.7));
}
.verified-badge-gold svg {
    width: 100%;
    height: 100%;
}
.verified-badge-gold.verified-badge-sm {
    width: 17px;
    height: 17px;
}
/* Chat list gold badge spacing */
.chat-item .chat-item-name .verified-badge-gold { margin-left: 3px; }
#chat-header-info .verified-badge-gold { margin-left: 4px; }

.badge-gold {
    background: linear-gradient(135deg, #fde68a, #d4a017);
    color: #1a1a1a;
    font-weight: 600;
    text-shadow: 0 0.5px 0 rgba(255,255,255,0.3);
}

/* ===== FORWARDED MESSAGE LABEL ===== */
.message-forwarded {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--accent);
    margin-bottom: 4px;
    cursor: default;
}
.message-forwarded svg {
    flex-shrink: 0;
}

/* ===== PHONE NOT VERIFIED WARNING ===== */
.phone-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(224, 79, 95, 0.12);
    border: 1px solid rgba(224, 79, 95, 0.3);
    border-radius: 10px;
    padding: 8px 12px;
    margin: 8px 16px;
    font-size: 12px;
    color: var(--danger);
}
.phone-warning svg {
    flex-shrink: 0;
}

/* ===== FAVORITES CHAT ===== */
.chat-item-favorites .avatar {
    background: linear-gradient(135deg, var(--accent), #3b82c4);
}
.favorites-icon {
    display: inline-flex;
    margin-right: 2px;
}

/* ===== HELP BOT QUICK BUTTONS ===== */
.helpbot-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}
.helpbot-btn {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: all .2s;
    white-space: nowrap;
}
.helpbot-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ===== FORWARD MODAL ===== */
.forward-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.forward-modal {
    background: var(--bg-primary);
    border-radius: 14px;
    width: 340px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.forward-modal-header {
    padding: 14px 16px;
    font-weight: 600;
    font-size: 16px;
    border-bottom: 1px solid var(--border);
}
.forward-modal-search {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}
.forward-modal-search input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
}
.forward-modal-list {
    overflow-y: auto;
    max-height: 50vh;
    padding: 4px 0;
}
.forward-modal-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background .15s;
}
.forward-modal-item:hover {
    background: var(--bg-hover);
}
.forward-modal-item .avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
}

/* ===== VERIFICATION TOOLTIPS (only in user card) ===== */
.verified-tooltip {
    display: none;
}

#panel-user-card .verified-tooltip {
    display: block;
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.45;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 9999;
    width: 220px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.35);
    font-weight: 400;
}

#panel-user-card .verified-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
}

#panel-user-card .verified-badge:hover .verified-tooltip,
#panel-user-card .verified-badge-gold:hover .verified-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(-2px);
}

#panel-user-card .verified-badge {
    position: relative;
    cursor: help;
}

#panel-user-card .verified-badge-gold {
    position: relative;
    cursor: help;
}

.verified-tooltip-blue {
    background: #3b82f6;
    color: #fff;
}

.verified-tooltip-blue::after {
    border-top-color: #3b82f6;
}

.verified-tooltip-gold {
    background: linear-gradient(135deg, #f5c842, #d4a017);
    color: #1a1a1a;
}

.verified-tooltip-gold::after {
    border-top-color: #d4a017;
}

/* ===== CHANNEL EDIT MODAL ===== */
.channel-edit-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

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

.channel-edit-modal {
    background: var(--bg-card);
    border-radius: 16px;
    width: 420px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    animation: modalSlideUp 0.25s ease;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

@keyframes modalSlideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.channel-edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.channel-edit-header h3 {
    font-size: 17px;
    font-weight: 600;
}

.channel-edit-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.channel-edit-close:hover {
    background: var(--bg-hover);
}

.channel-edit-body {
    padding: 20px;
}

.channel-edit-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
}

.channel-edit-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: opacity 0.2s;
    font-size: 28px;
    font-weight: 600;
    color: var(--accent);
}

.channel-edit-avatar:hover {
    opacity: 0.8;
}

.channel-edit-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.channel-edit-avatar-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: 50%;
}

.channel-edit-avatar:hover .channel-edit-avatar-overlay {
    opacity: 1;
}

.channel-edit-avatar-hint {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.channel-edit-field {
    margin-bottom: 16px;
}

.channel-edit-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.channel-edit-field input,
.channel-edit-field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.channel-edit-field input:focus,
.channel-edit-field textarea:focus {
    border-color: var(--accent);
}

.channel-edit-field textarea {
    min-height: 80px;
    resize: vertical;
}

.channel-edit-toggles {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.channel-edit-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-radius: 10px;
}

.channel-edit-toggle-label {
    font-size: 14px;
}

.channel-edit-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    border: none;
    padding: 0;
}

.channel-edit-switch.active {
    background: var(--accent);
}

.channel-edit-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
}

.channel-edit-switch.active::after {
    transform: translateX(20px);
}

.channel-edit-actions {
    display: flex;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.channel-edit-actions .btn {
    flex: 1;
}

/* ===== ADMIN QUICK ACTIONS ===== */
.admin-card-quick-actions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.admin-quick-btn {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.admin-quick-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.admin-quick-btn.danger {
    color: var(--danger);
    border-color: rgba(224,79,95,0.2);
}

.admin-quick-btn.danger:hover {
    background: rgba(224,79,95,0.1);
}

/* ============================================================
   Calendar UI
   ============================================================ */

#pinned-event-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--accent-dim);
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
#pinned-event-bar:hover { background: rgba(92,160,211,0.22); }
#pinned-event-bar.hidden { display: none; }
#pinned-event-bar .pinned-icon { font-size: 15px; }
#pinned-event-bar .pinned-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cal-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 420px;
    max-width: 100vw;
    background: var(--bg-secondary);
    z-index: 90;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.24s ease;
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 24px rgba(0,0,0,0.32);
}
.cal-panel.cal-panel-open { transform: translateX(0); }
@media (max-width: 520px) {
    .cal-panel { width: 100vw; border-left: none; }
}

.cal-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.cal-panel-header h3 {
    margin: 0;
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}
.cal-back, .cal-add {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cal-back:hover, .cal-add:hover { background: rgba(255,255,255,0.06); }
.cal-add { color: var(--accent); }

.cal-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.cal-month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.cal-month-nav button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
}
.cal-month-nav button:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.cal-month-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    text-align: center;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 18px;
}
.cal-cell {
    position: relative;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-primary);
}
.cal-weekday {
    aspect-ratio: auto;
    padding: 4px 0;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.cal-day {
    cursor: pointer;
    transition: background 0.12s;
}
.cal-day:hover { background: rgba(255,255,255,0.05); }
.cal-day-out { opacity: 0; pointer-events: none; }
.cal-day-num { position: relative; z-index: 1; }
.cal-day-today .cal-day-num {
    color: var(--accent);
    font-weight: 700;
}
.cal-day-selected {
    background: var(--accent);
    color: #fff;
}
.cal-day-selected .cal-day-num { color: #fff; }
.cal-day-dot {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--accent);
}
.cal-day-selected .cal-day-dot { background: #fff; }

.cal-day-section { margin-top: 14px; }
.cal-day-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}
.cal-day-list { display: flex; flex-direction: column; gap: 8px; }
.cal-day-empty {
    padding: 18px;
    color: var(--text-muted);
    text-align: center;
    font-size: 13px;
    background: var(--bg-card);
    border-radius: 10px;
}

.cal-event-row {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.1s, background 0.15s;
}
.cal-event-row:hover {
    background: #25364a;
    transform: translateX(2px);
}
.cal-event-bar {
    width: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}
.cal-event-body { flex: 1; min-width: 0; }
.cal-event-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.cal-event-title {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.3;
}
.cal-event-loc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.cal-modal-overlay,
.cal-detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cal-fade-in 0.18s ease;
}
@keyframes cal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
.cal-modal,
.cal-detail {
    width: 480px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 36px rgba(0,0,0,0.5);
    animation: cal-pop 0.18s ease;
}
@keyframes cal-pop {
    from { transform: translateY(8px) scale(0.98); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
.cal-modal-header,
.cal-detail-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.cal-modal-header h3 {
    flex: 1;
    margin: 0;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.cal-modal-cancel, .cal-modal-save {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 14px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
}
.cal-modal-save { font-weight: 600; }
.cal-modal-cancel:hover, .cal-modal-save:hover { background: rgba(255,255,255,0.05); }
.cal-modal-save:disabled { opacity: 0.5; cursor: default; }

.cal-modal-body, .cal-detail-body {
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.cal-input {
    width: 100%;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}
.cal-input:focus { outline: none; border-color: var(--accent); }
.cal-title { font-size: 16px; font-weight: 500; }
.cal-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.cal-row .cal-input { flex: 1; }
.cal-label {
    flex: 0 0 130px;
    font-size: 13px;
    color: var(--text-secondary);
}
.cal-row-toggle .cal-allday {
    width: 18px; height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}
.cal-color-row {
    display: flex;
    gap: 8px;
    flex: 1;
}
.cal-color-dot {
    width: 24px; height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    transition: transform 0.1s;
}
.cal-color-dot:hover { transform: scale(1.1); }
.cal-color-dot.active { border-color: var(--text-primary); }

.cal-desc { resize: vertical; min-height: 56px; }

.cal-detail-close {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cal-detail-close:hover { background: rgba(255,255,255,0.06); }
.cal-detail-edit, .cal-detail-del {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
}
.cal-detail-edit:hover { color: var(--accent); background: rgba(255,255,255,0.06); }
.cal-detail-del:hover { color: #ff5b5b; background: rgba(255,91,91,0.08); }

.cal-detail-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.25;
}
.cal-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    color: var(--text-secondary);
    font-size: 13px;
}
.cal-detail-loc {
    color: var(--text-secondary);
    font-size: 13px;
}
.cal-detail-section { margin-top: 6px; }
.cal-detail-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.cal-detail-rsvp { margin-top: 4px; }
.cal-rsvp-buttons {
    display: flex;
    gap: 8px;
}
.cal-rsvp-btn {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}
.cal-rsvp-btn:hover { background: #25364a; }
.cal-rsvp-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.cal-detail-people {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.cal-person {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 8px;
}
.cal-person:hover { background: var(--bg-card); }
.cal-person-status {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cal-status-yes { background: #3ecf8e; }
.cal-status-no { background: #ff5b5b; }
.cal-status-maybe { background: #ff9d3a; }
.cal-status-pending { background: #546778; }

.cal-person-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.cal-person-letter {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}
.cal-person-name {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cal-person-rsvp {
    font-size: 11px;
    color: var(--text-muted);
}

.cal-detail-desc {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.cal-detail-actions {
    display: flex;
    gap: 8px;
    padding-top: 6px;
}
.cal-export-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
}
.cal-export-btn:hover { background: #25364a; }

/* ============================================================
   Mini-Apps Menu (popover under apps button)
   ============================================================ */
.apps-menu {
    position: fixed;
    z-index: 150;
    min-width: 240px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    animation: cal-pop 0.14s ease;
}
.apps-menu-section { display: flex; flex-direction: column; gap: 2px; padding: 6px 4px; }
.apps-menu-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 8px 6px;
}
.apps-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    width: 100%;
    font-size: 14px;
}
.apps-menu-item:hover { background: var(--bg-hover); }
.apps-menu-icon { font-size: 18px; min-width: 22px; text-align: center; }
.apps-menu-name { flex: 1; }
.apps-menu-action { color: var(--accent); }
.apps-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}
.apps-menu-empty {
    padding: 14px 10px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

/* ============================================================
   Mini-Apps Store
   ============================================================ */
.store-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cal-fade-in 0.18s ease;
}
.store-modal {
    width: 720px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 36px rgba(0,0,0,0.5);
    animation: cal-pop 0.2s ease;
}
.store-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.store-header h2 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; color: var(--text-primary); }
.store-close {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
}
.store-close:hover { background: var(--bg-hover); }
.store-body { overflow-y: auto; padding: 16px; }
.store-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 12px;
}
.store-loading { padding: 30px; text-align: center; color: var(--text-muted); }

.store-card {
    display: flex;
    gap: 12px;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: border-color 0.15s, transform 0.1s;
}
.store-card:hover { border-color: var(--accent); }
.store-card-icon {
    font-size: 36px;
    width: 56px; height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 14px;
    flex-shrink: 0;
}
.store-card-body { flex: 1; min-width: 0; }
.store-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.store-card-head h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.store-badge {
    font-size: 10px;
    background: var(--accent-dim);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 500;
}
.store-card-desc {
    margin: 0 0 6px 0;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}
.store-card-meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
}
.store-card-actions {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
}
.store-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.store-btn:hover:not(:disabled) { background: var(--accent-hover); }
.store-btn-uninstall {
    background: transparent;
    color: #ff5b5b;
    border: 1px solid rgba(255,91,91,0.25);
}
.store-btn-uninstall:hover:not(:disabled) {
    background: rgba(255,91,91,0.1);
}
.store-btn:disabled { opacity: 0.6; cursor: default; }

.store-installed-badge {
    font-size: 12px;
    color: #3ecf8e;
    font-weight: 500;
}
.store-incompatible {
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    max-width: 130px;
}

/* ============================================================
   Admins panel
   ============================================================ */
.admins-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 210;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cal-fade-in 0.18s ease;
}
.admins-modal {
    width: 480px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 36px rgba(0,0,0,0.5);
    animation: cal-pop 0.2s ease;
}
.admins-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.admins-header h2 { flex: 1; margin: 0; font-size: 16px; font-weight: 600; color: var(--text-primary); }
.admins-close, .admins-add, .admins-save {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
}
.admins-close:hover, .admins-add:hover { background: var(--bg-hover); }
.admins-add { color: var(--accent); }
.admins-save {
    color: var(--accent);
    font-weight: 600;
    font-size: 14px;
    padding: 6px 10px;
}
.admins-save:hover { background: var(--bg-hover); }
.admins-body {
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.admins-loading { padding: 30px; text-align: center; color: var(--text-muted); }

.admin-row {
    padding: 8px 6px;
    border-radius: 10px;
}
.admin-row:hover { background: var(--bg-card); }
.admin-row-head {
    display: flex;
    align-items: center;
    gap: 10px;
}
.admin-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.admin-avatar-letter {
    background: var(--bg-card);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}
.admin-row-info { flex: 1; min-width: 0; }
.admin-row-name {
    font-size: 14px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.admin-row-title {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.admin-row-edit, .admin-row-del {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 14px;
}
.admin-row-edit:hover { background: var(--bg-hover); color: var(--text-primary); }
.admin-row-del:hover { background: rgba(255,91,91,0.1); color: #ff5b5b; }

.perm-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 6px;
    border-bottom: 1px solid var(--border);
}
.perm-row:last-child { border-bottom: none; }
.perm-label {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
}
.perm-label small { color: var(--text-muted); font-size: 11px; }
.perm-flag {
    width: 18px; height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}
.perm-title {
    width: 100%;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
}
.perm-title:focus { outline: none; border-color: var(--accent); }

/* ============================================================
   Shared mini-app panel (Polls / Expenses / Lists)
   ============================================================ */
.mini-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 460px;
    max-width: 100vw;
    background: var(--bg-secondary);
    z-index: 90;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.24s ease;
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 24px rgba(0,0,0,0.32);
}
.mini-panel.mini-panel-open { transform: translateX(0); }
@media (max-width: 540px) {
    .mini-panel { width: 100vw; border-left: none; }
}
.mini-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.mini-panel-header h3 {
    margin: 0;
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}
.mini-back, .mini-add {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mini-back:hover, .mini-add:hover { background: var(--bg-hover); }
.mini-add { color: var(--accent); }
.mini-panel-body { flex: 1; overflow-y: auto; padding: 16px; }
.mini-loading, .mini-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    background: var(--bg-card);
    border-radius: 10px;
}

.mini-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 220;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cal-fade-in 0.18s ease;
}
.mini-modal {
    width: 480px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 36px rgba(0,0,0,0.5);
    animation: cal-pop 0.18s ease;
}
.mini-modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.mini-modal-header h3 {
    flex: 1;
    margin: 0;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.mini-modal-cancel, .mini-modal-save {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 14px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
}
.mini-modal-save { font-weight: 600; }
.mini-modal-cancel:hover, .mini-modal-save:hover { background: var(--bg-hover); }
.mini-modal-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.mini-input {
    width: 100%;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}
.mini-input:focus { outline: none; border-color: var(--accent); }

/* ===== Polls ===== */
.polls-list { display: flex; flex-direction: column; gap: 10px; }
.poll-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 14px;
    border: 1px solid var(--border);
}
.poll-card.poll-closed { opacity: 0.75; }
.poll-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.poll-creator { flex: 1; }
.poll-actions { display: flex; gap: 4px; }
.poll-mini-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
}
.poll-mini-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.poll-mini-del { color: #ff5b5b; padding: 3px 7px; }
.poll-mini-del:hover { background: rgba(255,91,91,0.1); border-color: #ff5b5b; }
.poll-question {
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 12px;
    line-height: 1.3;
}
.poll-options { display: flex; flex-direction: column; gap: 6px; }
.poll-opt {
    position: relative;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
    border: 1px solid var(--border);
}
.poll-opt:hover { border-color: var(--accent); }
.poll-opt.voted { border-color: var(--accent); }
.poll-opt-bar {
    position: absolute;
    inset: 0;
    background: var(--accent-dim);
    transition: width 0.3s;
}
.poll-opt-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-primary);
}
.poll-opt-check {
    width: 16px;
    color: var(--accent);
    font-weight: 700;
    text-align: center;
}
.poll-opt-text { flex: 1; }
.poll-opt-count {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}
.poll-footer {
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-muted);
}
.poll-opts-edit { display: flex; flex-direction: column; gap: 8px; }
.mini-add-opt-btn {
    align-self: flex-start;
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--accent);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}
.mini-add-opt-btn:hover { background: var(--accent-dim); }

/* ===== Expenses ===== */
.exp-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}
.exp-tab {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
}
.exp-tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.exp-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-card);
    border-radius: 10px;
    margin-bottom: 8px;
}
.exp-row-icon {
    width: 36px; height: 36px;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.exp-row-body { flex: 1; min-width: 0; }
.exp-row-title { font-size: 14px; color: var(--text-primary); font-weight: 500; }
.exp-row-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.exp-row-amount {
    text-align: right;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 600;
}
.exp-row-amount small { display: block; font-size: 10px; color: var(--text-muted); font-weight: normal; }
.exp-del {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 18px;
    border-radius: 6px;
}
.exp-del:hover { background: rgba(255,91,91,0.1); color: #ff5b5b; }

.exp-amount-row { display: flex; gap: 8px; }
.exp-amount-row .exp-currency { max-width: 100px; }
.exp-split-title {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
    margin-bottom: 4px;
}
.exp-split-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    margin-bottom: 4px;
}
.exp-split-header .exp-split-title { flex: 1; margin: 0; }
.exp-split-all {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
}
.exp-split-all:hover { background: var(--bg-hover); color: var(--text-primary); }
.exp-split-list { display: flex; flex-direction: column; }

.exp-payer-toggle {
    display: flex;
    gap: 6px;
    background: var(--bg-card);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
}
.exp-payer-opt {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
}
.exp-payer-opt.active {
    background: var(--accent);
    color: #fff;
    font-weight: 500;
}

.exp-split-mode {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.exp-split-radio {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s;
}
.exp-split-radio:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-dim);
}
.exp-split-radio input {
    accent-color: var(--accent);
    margin-top: 2px;
}
.exp-split-radio span {
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--text-primary);
    font-size: 14px;
}
.exp-split-radio small {
    color: var(--text-muted);
    font-size: 11px;
}

.exp-bal-section { margin-bottom: 16px; }
.exp-bal-title {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.exp-bal-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: 8px;
    margin-bottom: 4px;
    font-size: 14px;
}
.exp-bal-name { color: var(--text-primary); }
.exp-bal-net { font-weight: 600; }
.exp-bal-pos { color: #3ecf8e; }
.exp-bal-neg { color: #ff5b5b; }
.exp-bal-zero { color: var(--text-muted); }
.exp-settle-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: 8px;
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--text-primary);
}
.exp-settle-arrow { color: var(--accent); font-weight: 700; }
.exp-settle-amt { font-weight: 600; color: var(--accent); }

/* ===== Lists ===== */
.list-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    border: 1px solid var(--border);
}
.list-card:hover { border-color: var(--accent); }
.list-card-icon {
    font-size: 26px;
    width: 42px; height: 42px;
    background: var(--bg-secondary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.list-card-body { flex: 1; min-width: 0; }
.list-card-title { font-size: 15px; color: var(--text-primary); font-weight: 500; }
.list-card-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.list-card-del {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 18px;
    border-radius: 6px;
}
.list-card-del:hover { background: rgba(255,91,91,0.1); color: #ff5b5b; }

.list-detail-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 12px;
}
.list-detail-head h4 { margin: 0; font-size: 18px; color: var(--text-primary); font-weight: 600; }
.list-detail-head small { color: var(--text-muted); font-size: 11px; }

.list-items { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: 8px;
}
.list-item.done .list-item-text {
    text-decoration: line-through;
    color: var(--text-muted);
}
.list-item-check {
    width: 18px; height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}
.list-item-text {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}
.list-item-del {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 16px;
    border-radius: 6px;
}
.list-item-del:hover { background: rgba(255,91,91,0.1); color: #ff5b5b; }

.list-quick-add {
    display: flex;
    gap: 6px;
}
.list-quick-add .mini-input { flex: 1; }
.mini-add-inline {
    background: var(--accent);
    color: #fff;
    border: none;
    width: 42px;
    border-radius: 10px;
    font-size: 20px;
    cursor: pointer;
}
.mini-add-inline:hover { background: var(--accent-hover); }

/* ============================================================
   Call message in chat (Telegram-style centered pill)
   ============================================================ */
.call-msg {
    display: flex;
    justify-content: center;
    margin: 8px 0;
}
.call-msg-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px 10px 8px 12px;
    max-width: 80%;
}
.call-msg-icon {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--accent-dim);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.call-msg--bad .call-msg-icon { background: rgba(224,79,95,0.15); color: #e0566b; }
.call-msg-info { display: flex; flex-direction: column; gap: 1px; }
.call-msg-title {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}
.call-msg--bad .call-msg-title { color: #e0566b; }
.call-msg-title .call-arrow { opacity: 0.7; }
.call-msg-sub { font-size: 12px; color: var(--text-muted); }
.call-msg-back {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.call-msg-back:hover { background: var(--accent-dim); }

/* ============================================================
   Calls screen (list) — like Telegram
   ============================================================ */
#panel-calls .calls-list { display: flex; flex-direction: column; }
.call-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}
.call-row:hover { background: var(--bg-hover); }
.call-row-avatar {
    width: 46px; height: 46px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-card);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; color: var(--text-primary);
}
.call-row-body { flex: 1; min-width: 0; }
.call-row-name { font-size: 15px; color: var(--text-primary); font-weight: 500; }
.call-row-name.missed { color: #e0566b; }
.call-row-meta { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.call-row-meta .call-arrow { opacity: 0.7; }
.call-row-time { font-size: 12px; color: var(--text-muted); }
.call-row-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.call-row-btn:hover { background: var(--accent-dim); }
.calls-empty { padding: 40px 20px; text-align: center; color: var(--text-muted); }
