.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #f87171;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    pointer-events: none;
}

.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--site-accent, #3b82f6);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease, box-shadow 0.2s;
}

.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

.chat-fab img {
    width: 26px;
    height: 26px;
}

.chat-fab.hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

/* Floating chat panel — like Telegram/VK */
.chat-panel {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    height: 520px;
    z-index: 1500;
    border-radius: 16px;
    overflow: hidden;
    background: rgba(22, 22, 32, 0.98);
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(20px);
    flex-direction: column;
    transform-origin: bottom right;
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    transition: opacity 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-panel.show {
    display: flex;
    opacity: 1;
    transform: scale(1) translateY(0);
}

.chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(30, 30, 42, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.chat-panel-header .chat-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
}

.chat-panel-header .chat-status {
    color: var(--site-success, #4ade80);
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
}

.chat-panel-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

.chat-panel-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.chat-panel-close img {
    width: 18px;
    height: 18px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-messages::-webkit-scrollbar {
    width: 5px;
}

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

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

.chat-message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.08);
}

.message-content {
    flex: 1;
    min-width: 0;
}

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

.message-author {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--site-accent, #60a5fa);
}

.message-author.message-profile-link {
    text-decoration: none;
    transition: opacity 0.15s;
}

.message-author.message-profile-link:hover {
    opacity: 0.8;
}

.message-time {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.35);
}

.message-text {
    font-size: 0.88rem;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.9);
    word-break: break-word;
}

.reply-preview {
    margin: 4px 0 6px;
    padding: 6px 10px;
    border-left: 3px solid var(--site-accent, #60a5fa);
    background: rgba(96, 165, 250, 0.1);
    border-radius: 6px;
    font-size: 0.75rem;
    line-height: 1.35;
    color: rgba(255, 255, 255, 0.6);
}

.reply-btn {
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    padding: 0;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s;
}

.reply-btn:hover {
    color: var(--site-accent, #60a5fa);
}

.chat-reply-box {
    padding: 8px 10px;
    margin-bottom: 8px;
    background: rgba(96, 165, 250, 0.08);
    border: 1px solid rgba(96, 165, 250, 0.2);
    border-radius: 8px;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.7);
}

.chat-reply-box b {
    color: rgba(255, 255, 255, 0.9);
}

.chat-input-area {
    padding: 10px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(26, 26, 38, 0.95);
    flex-shrink: 0;
}

.chat-input-area form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.chat-input:focus {
    border-color: rgba(96, 165, 250, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: var(--site-accent, #3b82f6);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.15s;
}

.chat-send-btn:hover {
    background: #2563eb;
    transform: scale(1.05);
}

.chat-login-msg {
    text-align: center;
    padding: 10px 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
}

/* Message styles */
.chat-msg-deleted {
    color: rgba(255, 255, 255, 0.35);
    font-style: italic;
}

.chat-msg-edited {
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.7rem;
    margin-left: 4px;
}

.chat-msg-admin-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}

.chat-msg-admin-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
}

.chat-msg-admin-btn.danger:hover {
    color: #f87171;
}

/* Context menu */
.chat-context-menu {
    position: fixed;
    background: rgba(30, 30, 40, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 6px 0;
    min-width: 160px;
    z-index: 2000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(16px);
}

.chat-context-item {
    display: block;
    width: 100%;
    padding: 9px 16px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s;
}

.chat-context-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.chat-context-danger {
    color: #f87171;
}

/* Status messages */
.chat-slow-mode-msg {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.78rem;
    text-align: center;
    padding: 4px 0;
}

.chat-banned-msg {
    color: #f87171;
    font-size: 0.85rem;
    text-align: center;
    padding: 8px 0;
}

/* Mobile — full screen */
@media (max-width: 480px) {
    .chat-panel {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        transform-origin: bottom center;
    }

    .chat-panel.show {
        transform: translateY(0);
    }

    .chat-fab {
        bottom: 20px;
        right: 20px;
        width: 54px;
        height: 54px;
    }

    .chat-fab img {
        width: 24px;
        height: 24px;
    }

    .chat-badge {
        min-width: 16px;
        height: 16px;
        font-size: 0.65rem;
    }
}

/* Tablet — slightly smaller panel */
@media (min-width: 481px) and (max-width: 768px) {
    .chat-panel {
        width: 340px;
        height: 460px;
        bottom: 16px;
        right: 16px;
    }
}
