/* ========================================
   Community Chat - Telegram/WhatsApp Style
   Professional, clean, modern design
   ======================================== */

/* ========== Variables ========== */


:root {
    --chat-bg: #0a0e17;
    --chat-surface: #111827;
    --chat-header-bg: #1a1f2e;
    --chat-input-bg: #1a1f2e;
    --bubble-own: #0ea5e9;
    --bubble-own-dark: #0284c7;
    --bubble-other: #1e293b;
    --bubble-other-hover: #273548;
    --chat-border: rgba(255, 255, 255, 0.08);
}

/* ========== Main Layout ========== */
.community {
    height: calc(100vh - 70px);
    max-width: 900px;
    margin: 0 auto;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    border-radius: 16px;
    overflow: hidden;
    margin: var(--spacing-md);
    border: 1px solid var(--chat-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    /* Ensure proper height calculation */
    max-height: calc(100vh - 70px - 2 * var(--spacing-md));
}

/* ========== Chat Header ========== */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--chat-header-bg);
    border-bottom: 1px solid var(--chat-border);
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0ea5e9, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.chat-header-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-header-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.chat-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.chat-header-status .status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fbbf24;
    animation: pulse 2s infinite;
}

.chat-header-status.connected .status-indicator {
    background: #22c55e;
    animation: none;
}

.chat-header-status.disconnected .status-indicator {
    background: #ef4444;
    animation: none;
}

.chat-header-status .online-count {
    color: var(--text-secondary);
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid var(--chat-border);
}

/* ========== Online User Avatars ========== */
.online-avatars {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: auto;
    padding-left: 12px;
}

.online-avatars .mini-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    border: 2px solid var(--chat-header-bg);
    margin-left: -8px;
    position: relative;
    cursor: default;
    transition: transform 0.2s ease, z-index 0.2s ease;
    flex-shrink: 0;
    overflow: hidden;
}

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

.online-avatars .mini-avatar:first-child {
    margin-left: 0;
}

.online-avatars .mini-avatar:hover {
    transform: scale(1.15);
    z-index: 10;
}

.online-avatars .mini-avatar-overflow {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--chat-header-bg);
    margin-left: -8px;
    flex-shrink: 0;
}

.mini-avatar-tooltip {
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 20;
}

.mini-avatar:hover .mini-avatar-tooltip {
    opacity: 1;
}

/* ========== Clickable Mini Avatar (header) ========== */
.mini-avatar--clickable {
    cursor: pointer;
}

.mini-avatar--clickable:focus-visible {
    outline: 2px solid var(--bubble-own);
    outline-offset: 2px;
}

@media (max-width: 480px) {
    .online-avatars .mini-avatar {
        width: 24px;
        height: 24px;
        font-size: 0.55rem;
        margin-left: -6px;
    }

    .online-avatars .mini-avatar-overflow {
        width: 24px;
        height: 24px;
        font-size: 0.5rem;
        margin-left: -6px;
    }
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-header-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ========== Messages Area ========== */
.chat-messages-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    position: relative;
    /* Ensure it takes remaining space and scrolls */
    min-height: 0;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 4px;
}



.scroll-bottom-fab {
    display: none;
}

.new-messages-badge {
    display: none;
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #ef4444;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--background-light);
    align-items: center;
    justify-content: center;
}

/* ========== Message Bubbles ========== */
.chat-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: messageIn 0.2s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Own messages - right aligned */
.chat-message.own-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-message.own-message .message-avatar {
    background: linear-gradient(135deg, #0ea5e9, #06b6d4);
}

/* ========== Clickable Avatar ========== */
.message-avatar--clickable {
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border-radius: 50%;
}

.message-avatar--clickable:hover {
    transform: scale(1.12);
    box-shadow: 0 0 0 2px var(--bubble-own);
}

.message-avatar--clickable:focus-visible {
    outline: 2px solid var(--bubble-own);
    outline-offset: 2px;
}

/* ========== Avatar Tooltip (desktop only) ========== */
.message-avatar-tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.88);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 20;
}

.message-avatar-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.88);
}

@media (hover: hover) and (pointer: fine) {
    .message-avatar--clickable:hover .message-avatar-tooltip {
        opacity: 1;
    }
}

.message-bubble {
    background: var(--bubble-other);
    border-radius: 18px;
    border-top-left-radius: 4px;
    padding: 8px 14px;
    position: relative;
    transition: background 0.15s ease;
    min-width: 0;
    overflow: hidden;
}

.message-bubble:hover {
    background: var(--bubble-other-hover);
}

.chat-message.own-message .message-bubble {
    background: var(--bubble-own);
    border-radius: 18px;
    border-top-right-radius: 4px;
}

.chat-message.own-message .message-bubble:hover {
    background: var(--bubble-own-dark);
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.message-username {
    font-size: 0.8rem;
    font-weight: 600;
    color: #0ea5e9;
}

.chat-message.own-message .message-username {
    color: rgba(255, 255, 255, 0.9);
}

.message-text {
    font-size: 0.95rem;
    line-height: 1.4;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.message-text a {
    color: #38bdf8;
    text-decoration: underline;
}

.chat-message.own-message .message-text {
    color: white;
}

.chat-message.own-message .message-text a {
    color: rgba(255, 255, 255, 0.9);
}

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

.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.chat-message.own-message .message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* ========== Message Edit Feature ========== */

/* Pencil button – hidden until the bubble is hovered */
.message-edit-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0 2px;
    line-height: 1;
    color: rgba(255, 255, 255, 0.5);
    transition: color 0.15s ease, transform 0.15s ease;
    flex-shrink: 0;
}

.message-bubble:hover .message-edit-btn {
    display: inline-flex;
    align-items: center;
}

.message-edit-btn:hover {
    color: rgba(255, 255, 255, 0.9);
    transform: scale(1.15);
}

/* "edited" label */
.message-edited-label {
    font-size: 0.65rem;
    opacity: 0.55;
    font-style: italic;
    flex-shrink: 0;
}

.chat-message.own-message .message-edited-label {
    color: rgba(255, 255, 255, 0.7);
}

/* Editing state: expand bubble slightly */
.message-bubble--editing {
    outline: 2px solid rgba(14, 165, 233, 0.45);
    border-radius: 12px;
}

/* Inline textarea */
.message-edit-input {
    width: 100%;
    min-width: 180px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(14, 165, 233, 0.55);
    border-radius: 8px;
    color: inherit;
    font-size: 0.95rem;
    line-height: 1.4;
    padding: 6px 10px;
    resize: none;
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
}

/* Save / Cancel action row */
.message-edit-actions {
    display: flex;
    gap: 6px;
    margin-right: auto;
}

.message-edit-save,
.message-edit-cancel {
    padding: 2px 10px;
    border-radius: 12px;
    border: none;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.message-edit-save {
    background: rgba(255, 255, 255, 0.9);
    color: #0a0e17;
}

.message-edit-cancel {
    background: rgba(255, 255, 255, 0.15);
    color: inherit;
}

.message-edit-save:hover,
.message-edit-cancel:hover {
    opacity: 0.8;
}

/* Message Media */
.message-media {
    max-width: 280px;
    margin-top: 8px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
}

.message-media img,
.message-image,
.message-gif {
    width: 100%;
    max-width: 280px;
    display: block;
    border-radius: 12px;
    transition: transform 0.2s ease;
    cursor: pointer;
}

.message-media:hover img,
.message-image:hover,
.message-gif:hover {
    transform: scale(1.02);
}

/* Date Separator */
.chat-date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 0;
}

.chat-date-separator span {
    background: rgba(255, 255, 255, 0.08);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Empty State */
.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.chat-empty-state .empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.chat-empty-state h3 {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.chat-empty-state p {
    font-size: 0.9rem;
}

/* ========== Input Area ========== */
.chat-input-area {
    background: var(--chat-input-bg);
    border-top: 1px solid var(--chat-border);
    padding: 12px 16px;
    flex-shrink: 0;
}

/* Media Preview Bar */
.media-preview-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: rgba(14, 165, 233, 0.1);
    border: 1px solid rgba(14, 165, 233, 0.2);
    border-radius: 12px;
    padding: 8px 12px;
    margin-bottom: 12px;
    animation: slideDown 0.2s ease;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.media-preview-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.media-preview-content img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
}

.media-preview-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-preview-remove {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.2);
    color: var(--bubble-own);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.media-preview-remove:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* Input Row */
.chat-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-input-actions {
    display: flex;
    gap: 4px;
}

.chat-action-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 1.2rem;
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.chat-action-btn .gif-label {
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(139, 92, 246, 0.2);
    color: var(--background-light);
    padding: 4px 6px;
    border-radius: 4px;
}

.chat-input-field {
    flex: 1;
    position: relative;
}

.chat-input-field input,
#chatInput {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--chat-border);
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s ease;
}

.chat-input-field input::placeholder,
#chatInput::placeholder {
    color: var(--text-muted);
}

.chat-input-field input:focus,
#chatInput:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--bubble-own);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.chat-send-btn,
#sendBtn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: var(--bubble-own);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover,
#sendBtn:hover {
    background: var(--bubble-own-dark);
    transform: scale(1.05);
}

.chat-send-btn:active,
#sendBtn:active {
    transform: scale(0.95);
}

.chat-send-btn:disabled,
#sendBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ========== Emoji Picker ========== */
.emoji-picker-container {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--chat-surface);
    border: 1px solid var(--chat-border);
    border-radius: 16px;
    padding: 12px;
    margin-bottom: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
    z-index: 100;
}

.emoji-picker-container.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

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

.emoji-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.emoji-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.15);
}

/* ========== Image Lightbox ========== */
.image-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    cursor: zoom-out;
}

.image-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.image-lightbox img {
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.image-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: var(--background-light);
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.image-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ========== Responsive Design ========== */
@media (max-width: 768px) {
    .community {
        height: calc(100vh - 60px);
        padding-top: 84px;
    }

    .chat-wrapper {
        margin: 8px;
        border-radius: 12px;
    }

    .chat-header {
        padding: 10px 12px;
    }

    .chat-header-avatar {
        width: 38px;
        height: 38px;
        font-size: 1.2rem;
    }

    .chat-header-title {
        font-size: 1rem;
    }

    .chat-messages-area {
        padding: 12px;
    }

    .chat-message {
        max-width: 90%;
    }

    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }

    .message-bubble {
        padding: 8px 12px;
    }

    .chat-input-area {
        padding: 10px 12px;
    }

    .chat-action-btn {
        width: 36px;
        height: 36px;
    }

    .chat-send-btn,
    #sendBtn {
        width: 44px;
        height: 44px;
    }

    .chat-input-field input,
    #chatInput {
        padding: 10px 14px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .chat-wrapper {
        margin: 4px;
        border-radius: 0;
    }

    .chat-header-status .online-count {
        display: none;
    }

    .chat-input-actions {
        gap: 2px;
    }

    .chat-action-btn {
        width: 32px;
        height: 32px;
    }

    .chat-action-btn .gif-label {
        font-size: 0.6rem;
        padding: 3px 5px;
    }

    .emoji-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .emoji-btn {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }
}

/* ========== Scrollbar Styling ========== */
.chat-messages-area::-webkit-scrollbar {
    width: 6px;
}

.chat-messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.chat-messages-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ========== System Message ========== */
.chat-message.system-message {
    align-self: center;
    max-width: 100%;
}

.chat-message.system-message .message-bubble {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 6px 16px;
}

.chat-message.system-message .message-text {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
    text-align: center;
}

/* ========== iOS PWA Safe Area Fix ========== */
/* On iPhone (PWA / standalone), the fixed navbar includes safe-area-inset-top
   for the notch / Dynamic Island, making it taller than the default 60-70px.
   Push the community section down so the tab bar (Chat/Messages/Stats) is visible. */
@media (max-width: 768px) {

    body.ios-pwa .community,
    html.ios-standalone .community,
    body.display-standalone .community {
        padding-top: calc(84px + env(safe-area-inset-top, 0px));
        height: calc(100vh - 60px - env(safe-area-inset-top, 0px));
    }
}

/* Safari (including non-PWA) on iOS: account for safe-area when present */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 768px) {
        .community {
            padding-top: calc(84px + env(safe-area-inset-top, 0px));
            height: calc(100vh - 60px - env(safe-area-inset-top, 0px));
        }
    }
}

/* ========== Reply-to Feature ========== */

/* Bar above the input shown when replying */
.reply-preview-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: rgba(14, 165, 233, 0.08);
    border-left: 3px solid #0ea5e9;
    border-radius: 8px;
    padding: 6px 10px;
    margin-bottom: 8px;
    gap: 8px;
    animation: slideDown 0.2s ease;
}

.reply-preview-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 1px;
}

.reply-preview-username {
    font-size: 0.75rem;
    font-weight: 700;
    color: #0ea5e9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-preview-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-preview-cancel {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.945);
    color: #000000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    transition: background 0.15s ease;
}

.reply-preview-cancel:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* Quoted block inside a message bubble */
.reply-quote {
    background: rgba(0, 0, 0, 0.15);
    border-left: 3px solid #0ea5e9;
    border-radius: 6px;
    padding: 4px 8px;
    margin-bottom: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 1px;
    transition: background 0.15s ease;
}

.reply-quote:hover {
    background: rgba(0, 0, 0, 0.25);
}

.reply-quote-username {
    font-size: 0.72rem;
    font-weight: 700;
    color: #38bdf8;
}

.reply-quote-text {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.65);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.chat-message.own-message .reply-quote {
    background: rgba(255, 255, 255, 0.12);
}

.chat-message.own-message .reply-quote:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Reply button – hidden until the bubble is hovered */
.message-reply-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    color: rgba(255, 255, 255, 0.45);
    transition: color 0.15s ease, transform 0.15s ease;
    flex-shrink: 0;
}

.message-bubble:hover .message-reply-btn {
    display: inline-flex;
    align-items: center;
}

.message-reply-btn:hover {
    color: rgba(255, 255, 255, 0.9);
    transform: scale(1.15);
}

/* Highlight flash when jumping to a quoted message */
.message-highlighted {
    animation: msgHighlight 1.5s ease;
}

@keyframes msgHighlight {
    0%   { background: rgba(14, 165, 233, 0.25); }
    100% { background: transparent; }
}