/* style.css — Portal Annush — Modern Dark Cinema
 * Style tokens follow ui-ux-pro-max "Modern Dark Cinema (Cinema Mobile)"
 * recommendation: deep gradient base, indigo accent, glass headers,
 * spring easing, scale-press on tappables, 16px radius, hairline borders.
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
    /* Surfaces — never pure black to avoid OLED smear. */
    --bg-deep: #020203;
    --bg-base: #050506;
    --bg-elevated: #0a0a0c;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-2: rgba(255, 255, 255, 0.07);
    --surface-strong: rgba(255, 255, 255, 0.10);

    /* Text */
    --foreground: #EDEDEF;
    --foreground-muted: #8A8F98;
    --foreground-faint: #5C616B;

    /* Accents */
    --accent: #5E6AD2;          /* indigo — primary CTA */
    --accent-hover: #6E7AE2;
    --accent-glow: rgba(94, 106, 210, 0.35);
    --accent-soft: rgba(94, 106, 210, 0.18);

    /* Status */
    --online: #4ADE80;
    --danger: #F87171;
    --warning: #FBBF24;
    --read-check: #60A5FA;

    /* Borders & rings */
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --ring: rgba(94, 106, 210, 0.55);

    /* Bubbles */
    --bubble-own: var(--accent);
    --bubble-own-text: #FFFFFF;
    --bubble-other: var(--surface-2);
    --bubble-other-text: var(--foreground);

    /* Geometry */
    --radius: 16px;
    --radius-sm: 10px;
    --radius-lg: 22px;

    /* Motion */
    --easing: cubic-bezier(0.16, 1, 0.3, 1);
    --easing-in: cubic-bezier(0.4, 0, 1, 1);
    --d-fast: 120ms;
    --d-base: 200ms;
    --d-slow: 320ms;

    /* Shadows */
    --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 4px 16px rgba(0, 0, 0, 0.32);
    --shadow-pop: 0 12px 48px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--border);
}

/* Backwards-compat aliases for legacy CSS that referenced old tokens. */
:root {
    --bg: var(--bg-base);
    --sidebar-bg: var(--bg-elevated);
    --chat-bg: var(--bg-base);
    --chat-pattern: none;
    --primary: var(--accent);
    --primary-dark: var(--accent-hover);
    --primary-light: var(--accent-soft);
    --text: var(--foreground);
    --text-secondary: var(--foreground-muted);
    --header-bg: rgba(10, 10, 12, 0.72);
    --input-bg: var(--surface-2);
    --online-dot: var(--online);
    --own-bubble: var(--bubble-own);
    --other-bubble: var(--bubble-other);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-base);
    background-image:
        radial-gradient(1200px 600px at 0% -10%, rgba(94, 106, 210, 0.08), transparent 60%),
        radial-gradient(800px 500px at 100% 110%, rgba(94, 106, 210, 0.05), transparent 70%),
        linear-gradient(180deg, #0a0a0f 0%, #020203 100%);
    color: var(--foreground);
    height: 100vh; overflow: hidden;
    -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}
body, input, textarea, button { font-family: inherit; }
a { color: var(--accent); }

/* Tabular figures for time-like content keep widths stable. */
.msg-time, .conv-time, .reaction-count { font-variant-numeric: tabular-nums; }

/* Universal focus ring (visible only on keyboard nav). */
:focus { outline: none; }
:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Honour reduced motion. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
    }
}

/* --- Connection Status Banner --- */
.connection-status {
    position: absolute; top: 0; left: 0; right: 0; z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 8px 16px; font-size: 13px; font-weight: 500;
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
}
.connection-status.reconnecting { background: rgba(251, 191, 36, 0.12); color: var(--warning); }
.connection-status.disconnected { background: rgba(248, 113, 113, 0.14); color: var(--danger); cursor: pointer; }

/* --- Login --- */
#login-screen {
    display: flex; align-items: center; justify-content: center; height: 100vh;
    background:
        radial-gradient(900px 500px at 30% 20%, rgba(94, 106, 210, 0.22), transparent 60%),
        radial-gradient(700px 500px at 70% 90%, rgba(94, 106, 210, 0.12), transparent 70%),
        linear-gradient(180deg, #0a0a14 0%, #020203 100%);
}
.login-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px; width: min(420px, 92vw);
    box-shadow: var(--shadow-pop);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo svg {
    width: 56px; height: 56px; color: var(--accent);
    filter: drop-shadow(0 0 18px var(--accent-glow));
}
.login-logo h1 { font-size: 22px; font-weight: 700; margin-top: 12px; color: var(--foreground); letter-spacing: -0.01em; }
.login-logo p { color: var(--foreground-muted); font-size: 14px; margin-top: 4px; }
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 12.5px; color: var(--foreground-muted);
    margin-bottom: 6px; font-weight: 500; letter-spacing: 0.01em;
}
.form-group input, .dialog input {
    width: 100%; padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--foreground);
    font-size: 15px; outline: none;
    transition: border-color var(--d-fast) var(--easing), background var(--d-fast) var(--easing), box-shadow var(--d-fast) var(--easing);
}
.form-group input::placeholder, .dialog input::placeholder { color: var(--foreground-faint); }
.form-group input:focus, .dialog input:focus {
    border-color: var(--accent); background: var(--surface-2);
    box-shadow: 0 0 0 4px var(--accent-soft);
}
#login-btn, .btn-primary {
    width: 100%; padding: 13px;
    background: var(--accent); color: #fff; border: none;
    border-radius: var(--radius-sm);
    font-size: 15px; font-weight: 600; cursor: pointer;
    transition: background var(--d-fast) var(--easing), transform var(--d-fast) var(--easing), box-shadow var(--d-fast) var(--easing);
    box-shadow: 0 8px 24px var(--accent-glow);
}
#login-btn:hover, .btn-primary:hover { background: var(--accent-hover); }
#login-btn:active, .btn-primary:active { transform: scale(0.98); }
#login-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
#login-error { color: var(--danger); font-size: 13px; margin-top: 12px; text-align: center; min-height: 18px; }

/* --- App Layout --- */
#app-screen { display: none; height: 100vh; width: 100vw; position: relative; }
.sidebar {
    width: 380px; min-width: 320px;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; height: 100vh;
}
.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    background: rgba(10, 10, 12, 0.72);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    min-height: 64px;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 5;
}
.sidebar-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.sidebar-actions { display: flex; gap: 2px; }

.icon-btn {
    width: 40px; height: 40px; border: none; background: none; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: var(--foreground-muted);
    transition: background var(--d-fast) var(--easing), color var(--d-fast) var(--easing), transform var(--d-fast) var(--easing);
}
.icon-btn:hover { background: var(--surface-2); color: var(--foreground); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 22px; height: 22px; }

#conversation-list { flex: 1; overflow-y: auto; padding: 4px 0; }

/* Conversation Items */
.conv-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; cursor: pointer; position: relative;
    transition: background var(--d-fast) var(--easing);
}
.conv-item::after {
    content: ''; position: absolute; left: 80px; right: 16px; bottom: 0;
    height: 1px; background: var(--border);
}
.conv-item:last-child::after { display: none; }
.conv-item:hover { background: var(--surface); }
.conv-item.active { background: var(--accent-soft); }
.conv-item.active::before {
    content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
    background: var(--accent); border-radius: 0 3px 3px 0;
}
.conv-avatar-wrap { position: relative; flex-shrink: 0; }
.conv-avatar {
    width: 48px; height: 48px; border-radius: 50%;
    background: linear-gradient(135deg, #5E6AD2 0%, #4451B8 100%);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 600; overflow: hidden;
    box-shadow: 0 0 0 1px var(--border) inset;
}
.conv-avatar.group { background: linear-gradient(135deg, #C084FC 0%, #7E22CE 100%); }
.conv-avatar img { width: 100%; height: 100%; object-fit: cover; }
.conv-avatar svg { width: 24px; height: 24px; fill: white; }
.online-dot {
    position: absolute; bottom: 0; right: 0;
    width: 12px; height: 12px;
    background: var(--online);
    border: 2.5px solid var(--bg-elevated);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
}
.conv-info { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; gap: 8px; }
.conv-name { font-weight: 600; font-size: 15px; color: var(--foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 12px; color: var(--foreground-muted); flex-shrink: 0; }
.conv-time.unread { color: var(--accent); font-weight: 600; }
.conv-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.conv-preview { font-size: 13.5px; color: var(--foreground-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.unread-badge {
    background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
    min-width: 20px; height: 20px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; padding: 0 6px;
    box-shadow: 0 0 12px var(--accent-glow);
}

/* --- Chat Panel --- */
.chat-panel {
    flex: 1; display: flex; flex-direction: column;
    background: var(--bg-base);
    background-image:
        radial-gradient(900px 500px at 50% 0%, rgba(94, 106, 210, 0.05), transparent 60%);
    height: 100vh; min-width: 0;
}
.chat-header {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
    background: rgba(10, 10, 12, 0.72);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border-bottom: 1px solid var(--border); min-height: 64px;
    position: sticky; top: 0; z-index: 5;
}
#chat-back-btn { display: none; }
#chat-header-info { flex: 1; min-width: 0; }
.chat-header-name { font-weight: 600; font-size: 16px; color: var(--foreground); }
.chat-header-status { font-size: 12.5px; color: var(--foreground-muted); margin-top: 2px; }
.chat-header-status.online { color: var(--online); }
.chat-header-status.online::before {
    content: ''; display: inline-block; width: 6px; height: 6px;
    background: var(--online); border-radius: 50%; margin-right: 6px;
    box-shadow: 0 0 6px var(--online);
}
.chat-header-status.typing { color: var(--accent); font-style: italic; }

/* Messages */
#messages-container {
    flex: 1; overflow-y: auto; padding: 16px 60px 8px;
    display: flex; flex-direction: column; gap: 4px;
    scroll-behavior: smooth;
}
.date-separator { text-align: center; margin: 16px 0 8px; }
.date-separator span {
    background: var(--surface);
    color: var(--foreground-muted); font-size: 12px; font-weight: 500;
    padding: 5px 14px; border-radius: 12px;
    display: inline-block;
    border: 1px solid var(--border);
}
.system-message {
    text-align: center; color: var(--foreground-muted); font-size: 12.5px;
    background: var(--surface); padding: 6px 16px; border-radius: 12px;
    margin: 8px auto; max-width: 80%; border: 1px solid var(--border);
}
.message { display: flex; margin: 1px 0; flex-direction: column; }
.message.own { align-items: flex-end; }
.message.other { align-items: flex-start; }
.msg-bubble {
    max-width: 65%; padding: 9px 13px 7px;
    border-radius: var(--radius);
    position: relative; word-break: break-word;
    box-shadow: var(--shadow-1);
    animation: bubble-in var(--d-base) var(--easing);
}
@keyframes bubble-in {
    from { opacity: 0; transform: translateY(6px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}
.message.own .msg-bubble {
    background: var(--bubble-own); color: var(--bubble-own-text);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 18px rgba(94, 106, 210, 0.32);
}
.message.other .msg-bubble {
    background: var(--bubble-other); color: var(--bubble-other-text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.message.own .msg-bubble .reply-preview { background: rgba(255,255,255,0.14); border-left-color: rgba(255,255,255,0.7); }
.message.own .reply-sender { color: rgba(255,255,255,0.95); }
.message.own .reply-text { color: rgba(255,255,255,0.78); }
.msg-sender { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }
.msg-text { font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; }
.msg-meta {
    display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px;
    margin-top: 2px; float: right; margin-left: 12px;
}
.msg-time { font-size: 11px; color: var(--foreground-muted); }
.message.own .msg-time { color: rgba(255, 255, 255, 0.78); }
.read-icon { display: inline-flex; align-items: center; color: rgba(255, 255, 255, 0.78); }
.read-icon svg { width: 16px; height: 12px; }
.read-icon.read svg { color: var(--read-check); }
.deleted-msg { font-style: italic; color: var(--foreground-muted); font-size: 13px; }

/* Decryption failure */
.msg-encrypted { color: var(--foreground-muted); font-style: italic; font-size: 13px; }
.msg-encrypted svg { width: 14px; height: 14px; vertical-align: middle; margin-right: 4px; color: var(--warning); }

/* Reply preview in message */
.reply-preview {
    background: rgba(255,255,255,0.06);
    border-left: 3px solid var(--accent);
    padding: 6px 10px; border-radius: 6px; margin-bottom: 6px; cursor: pointer;
    font-size: 13px;
}
.reply-sender { font-weight: 600; color: var(--accent); font-size: 12px; }
.reply-text { color: var(--foreground-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Highlight on scroll-to */
.message.highlight .msg-bubble { animation: highlight 1.6s var(--easing); }
@keyframes highlight {
    0%, 25% { box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-1); }
    100%    { box-shadow: var(--shadow-1); }
}

/* Image / video messages */
.image-msg { min-width: 200px; position: relative; }
.image-placeholder {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 28px;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    cursor: pointer; color: var(--foreground-muted); font-size: 13px;
    transition: background var(--d-fast) var(--easing);
}
.image-placeholder:hover { background: var(--surface-2); }
.thumb-img {
    max-width: 320px; max-height: 320px; border-radius: 12px; cursor: pointer;
    display: block;
}
.thumb-wrap { position: relative; display: inline-block; cursor: pointer; }
.video-play-overlay {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    pointer-events: none;
}
.video-play-overlay svg {
    background: rgba(0,0,0,0.6); border-radius: 50%; padding: 12px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.media-download {
    position: absolute; top: 8px; right: 8px;
    background: rgba(0,0,0,0.55); color: white;
    border: none; border-radius: 50%; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; opacity: 0.92;
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    transition: background var(--d-fast) var(--easing), transform var(--d-fast) var(--easing);
}
.media-download:hover { background: rgba(0,0,0,0.78); }
.media-download:active { transform: scale(0.92); }

/* Video viewer */
#video-viewer {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    z-index: 2000; align-items: center; justify-content: center;
}
#video-viewer-player { max-width: 92%; max-height: 92%; background: black; border-radius: 8px; }
#video-viewer-close, #viewer-close {
    position: fixed; top: 16px; right: 16px; width: 44px; height: 44px;
    background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.18);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-radius: 50%; color: white; font-size: 22px; cursor: pointer; z-index: 2001;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--d-fast) var(--easing), transform var(--d-fast) var(--easing);
}
#video-viewer-close:hover, #viewer-close:hover { background: rgba(255,255,255,0.22); }
#video-viewer-close:active, #viewer-close:active { transform: scale(0.94); }

/* Typing indicator */
#typing-indicator {
    display: none; padding: 4px 76px; font-size: 13px; color: var(--accent);
    font-style: italic; background: transparent;
}

/* Reply bar */
#reply-bar {
    display: none; align-items: center; padding: 10px 16px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.reply-bar-content { flex: 1; border-left: 3px solid var(--accent); padding-left: 10px; }
.reply-bar-sender { font-weight: 600; font-size: 13px; color: var(--accent); }
.reply-bar-text { font-size: 13px; color: var(--foreground-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-bar-close {
    background: none; border: none; font-size: 22px; cursor: pointer;
    color: var(--foreground-muted); padding: 0 8px;
    transition: color var(--d-fast) var(--easing);
}
.reply-bar-close:hover { color: var(--foreground); }

/* Upload progress */
#upload-progress {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; background: var(--accent-soft); color: var(--foreground);
    font-size: 13px; font-weight: 500;
    border-top: 1px solid var(--border);
}
#upload-progress-track {
    flex: 1; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.08); overflow: hidden;
}
#upload-progress-fill {
    height: 100%; width: 0%; border-radius: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    transition: width var(--d-base) var(--easing);
    box-shadow: 0 0 12px var(--accent-glow);
}

/* Input area */
.chat-input-area {
    display: flex; align-items: flex-end; padding: 10px 12px 12px;
    background: rgba(10, 10, 12, 0.85);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border-top: 1px solid var(--border);
    gap: 8px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}
#message-input {
    flex: 1; border: 1px solid var(--border); outline: none;
    padding: 11px 16px; border-radius: var(--radius-lg);
    background: var(--surface-2);
    color: var(--foreground);
    font-size: 15px; font-family: inherit;
    resize: none; max-height: 120px; min-height: 44px; line-height: 1.4;
    transition: border-color var(--d-fast) var(--easing), background var(--d-fast) var(--easing), box-shadow var(--d-fast) var(--easing);
}
#message-input::placeholder { color: var(--foreground-faint); }
#message-input:focus {
    border-color: var(--accent);
    background: var(--surface-strong);
    box-shadow: 0 0 0 4px var(--accent-soft);
}
#send-btn, #attach-btn {
    width: 44px; height: 44px; border: none; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background var(--d-fast) var(--easing), transform var(--d-fast) var(--easing), box-shadow var(--d-fast) var(--easing);
}
#send-btn { background: var(--accent); color: white; box-shadow: 0 6px 20px var(--accent-glow); }
#send-btn:hover { background: var(--accent-hover); }
#send-btn:active { transform: scale(0.92); }
#attach-btn { background: var(--surface-2); color: var(--foreground-muted); }
#attach-btn:hover { background: var(--surface-strong); color: var(--foreground); }
#attach-btn:active { transform: scale(0.92); }
#attach-btn svg, #send-btn svg { width: 22px; height: 22px; }

/* --- Dialogs --- */
.dialog-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    z-index: 1000; align-items: center; justify-content: center;
    animation: fade-in var(--d-base) var(--easing);
}
.dialog {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
    width: min(380px, 92vw);
    box-shadow: var(--shadow-pop);
    animation: dialog-in var(--d-base) var(--easing);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes dialog-in {
    from { opacity: 0; transform: scale(0.94) translateY(8px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.dialog h3 { margin-bottom: 16px; font-weight: 600; font-size: 18px; letter-spacing: -0.01em; }
.dialog input { margin-bottom: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-actions button {
    padding: 9px 18px; border-radius: var(--radius-sm); border: none;
    cursor: pointer; font-size: 14px; font-weight: 600;
    transition: background var(--d-fast) var(--easing), transform var(--d-fast) var(--easing);
}
.dialog-actions button:active { transform: scale(0.96); }
.btn-secondary {
    background: var(--surface-2); color: var(--foreground);
    border: 1px solid var(--border) !important;
}
.btn-secondary:hover { background: var(--surface-strong); }

/* --- Image Viewer --- */
#image-viewer {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    z-index: 2000; align-items: center; justify-content: center;
}
#viewer-image { max-width: 92%; max-height: 92%; object-fit: contain; border-radius: 8px; }

/* --- Action Sheet (Telegram-style, glass) --- */
.action-sheet-backdrop {
    position: fixed; inset: 0; background: transparent; z-index: 1499;
}
.action-sheet {
    position: fixed; z-index: 1500;
    background: rgba(20, 20, 24, 0.84);
    backdrop-filter: blur(28px) saturate(160%);
    -webkit-backdrop-filter: blur(28px) saturate(160%);
    border: 1px solid var(--border);
    border-radius: 16px; box-shadow: var(--shadow-pop);
    padding: 6px; min-width: 240px; max-width: 92vw;
    animation: action-sheet-in 200ms var(--easing);
}
@keyframes action-sheet-in {
    from { opacity: 0; transform: scale(0.92) translateY(4px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.action-emoji-row { display: flex; gap: 2px; padding: 4px; overflow-x: auto; scrollbar-width: none; }
.action-emoji-row::-webkit-scrollbar { display: none; }
.action-emoji {
    flex: 0 0 auto; width: 40px; height: 40px; border: none; background: none;
    border-radius: 50%; font-size: 22px; cursor: pointer; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--d-fast) var(--easing), transform var(--d-fast) var(--easing);
}
.action-emoji:hover { background: var(--surface-2); transform: scale(1.18); }
.action-emoji:active { transform: scale(0.94); }
.action-emoji.selected { background: var(--accent-soft); transform: scale(1.08); }
.action-divider { height: 1px; background: var(--border); margin: 4px 8px; }
.action-list { display: flex; flex-direction: column; padding: 2px; }
.action-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px;
    border: none; background: none; cursor: pointer; border-radius: 10px;
    font-size: 14.5px; color: var(--foreground); text-align: left;
    transition: background var(--d-fast) var(--easing);
}
.action-item:hover { background: var(--surface-2); }
.action-item:active { background: var(--surface-strong); }
.action-item.danger { color: var(--danger); }
.action-item svg { flex-shrink: 0; opacity: 0.85; }
.action-item.danger svg { opacity: 1; }

/* --- Reaction Chips --- */
.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.message.own .msg-reactions { justify-content: flex-end; padding-right: 8px; }
.message.other .msg-reactions { justify-content: flex-start; padding-left: 8px; }
.reaction-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 14px;
    padding: 2px 9px 2px 7px; font-size: 13px; line-height: 1;
    cursor: pointer; user-select: none;
    transition: background var(--d-fast) var(--easing), border-color var(--d-fast) var(--easing), transform var(--d-fast) var(--easing);
}
.reaction-chip:hover { background: var(--surface-strong); }
.reaction-chip:active { transform: scale(0.94); }
.reaction-chip.mine {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--foreground);
}
.reaction-emoji { font-size: 14px; }
.reaction-count { color: var(--foreground-muted); font-weight: 500; font-size: 12px; }
.reaction-chip.mine .reaction-count { color: var(--foreground); }

/* --- Notification bell button --- */
.notif-btn { position: relative; }
.notif-btn .notif-dot {
    position: absolute; top: 6px; right: 6px;
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-elevated);
    box-shadow: 0 0 8px var(--accent-glow);
}
.notif-btn.blocked { color: var(--danger); }
.notif-btn.blocked .notif-dot { background: var(--danger); }

/* --- Notification permission prompt --- */
#notif-prompt {
    position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
    background: rgba(20, 20, 24, 0.84);
    backdrop-filter: blur(28px) saturate(160%);
    -webkit-backdrop-filter: blur(28px) saturate(160%);
    border: 1px solid var(--border);
    border-radius: 14px; padding: 10px 14px;
    box-shadow: var(--shadow-pop);
    z-index: 1600;
    display: flex; align-items: center; gap: 10px;
    font-size: 14px; max-width: 92vw;
    color: var(--foreground);
    animation: notif-prompt-in var(--d-base) var(--easing);
}
@keyframes notif-prompt-in {
    from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.notif-prompt-text { color: var(--foreground); }
.notif-prompt-btn {
    border: 1px solid var(--border);
    padding: 6px 12px; border-radius: 8px;
    font-size: 13px; cursor: pointer;
    background: var(--surface-2); color: var(--foreground);
    transition: background var(--d-fast) var(--easing), transform var(--d-fast) var(--easing);
}
.notif-prompt-btn:hover { background: var(--surface-strong); }
.notif-prompt-btn:active { transform: scale(0.96); }
.notif-prompt-btn.primary {
    background: var(--accent); color: white; font-weight: 600; border-color: transparent;
    box-shadow: 0 4px 14px var(--accent-glow);
}
.notif-prompt-btn.primary:hover { background: var(--accent-hover); }

/* --- Toast --- */
#toast {
    position: fixed; bottom: 24px; left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: rgba(20, 20, 24, 0.92);
    backdrop-filter: blur(28px) saturate(160%);
    -webkit-backdrop-filter: blur(28px) saturate(160%);
    border: 1px solid var(--border);
    color: var(--foreground); padding: 12px 22px; border-radius: 12px;
    font-size: 14px; z-index: 3000;
    transition: transform var(--d-slow) var(--easing);
    pointer-events: none; max-width: 90%;
    box-shadow: var(--shadow-pop);
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* --- Empty State --- */
.empty-state {
    display: flex; align-items: center; justify-content: center; height: 100%;
    color: var(--foreground-muted); text-align: center; font-size: 15px; padding: 40px;
    line-height: 1.6;
}
.chat-panel-empty {
    flex: 1; display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 16px; color: var(--foreground-muted);
    padding: 40px;
}
.chat-panel-empty svg { width: 80px; height: 80px; opacity: 0.4; color: var(--accent); }
.chat-panel-empty p { font-size: 15px; }

/* --- Profile Panel --- */
#profile-panel {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    animation: fade-in var(--d-base) var(--easing);
}
#profile-panel .login-card {
    animation: dialog-in var(--d-base) var(--easing);
}
#profile-close {
    color: var(--foreground-muted) !important;
    transition: color var(--d-fast) var(--easing);
}
#profile-close:hover { color: var(--foreground) !important; }
#profile-bio {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    color: var(--foreground) !important;
    border-radius: var(--radius-sm) !important;
}
#profile-bio:focus { border-color: var(--accent) !important; box-shadow: 0 0 0 4px var(--accent-soft); }
#profile-avatar {
    background: linear-gradient(135deg, #5E6AD2 0%, #4451B8 100%) !important;
    box-shadow: 0 0 0 1px var(--border), 0 8px 28px var(--accent-glow);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar { width: 100%; }
    .chat-panel {
        position: fixed; top: 0; left: 100%; width: 100%; height: 100%;
        z-index: 100; transition: left var(--d-slow) var(--easing);
    }
    .chat-panel.active { left: 0; }
    #chat-back-btn { display: flex; }
    #messages-container { padding: 12px 12px 8px; }
    .msg-bubble { max-width: 78%; }
    .sidebar-title { font-size: 20px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--surface-strong); border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* Selection */
::selection { background: var(--accent-soft); color: var(--foreground); }
