#chat-container {
    position: fixed;
    bottom: 40px;
    left: 10px;
    width: 320px;
    height: 260px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    pointer-events: auto;
    z-index: 100;
    user-select: none;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding-bottom: 6px;
    mask-image: linear-gradient(to bottom, transparent, black 18%);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 18%);
    direction: rtl;
    padding-left: 4px;
}

#chat-messages::-webkit-scrollbar { width: 5px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.18);
    border-radius: 3px;
}
#chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.35);
}

.chat-msg {
    direction: ltr;
    font-family: 'Ubuntu', sans-serif;
    font-size: 11px;
    line-height: 1.45;
    margin-bottom: 2px;
    padding: 3px 10px 3px 8px;
    border-radius: 4px;
    word-wrap: break-word;
    background: linear-gradient(90deg, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0.22) 75%, rgba(0,0,0,0) 100%);
    backdrop-filter: blur(2px);
    transition: background 0.15s;
    margin-right: 10px;
    user-select: text;
    cursor: text;
    color: #ffffff;
}

.chat-msg:hover {
    background: linear-gradient(90deg, rgba(0,0,0,0.60) 0%, rgba(0,0,0,0.35) 75%, rgba(0,0,0,0) 100%);
}

.chat-time {
    font-size: 10px;
    color: rgba(255,255,255,0.35);
    margin-right: 2px;
    font-family: 'Courier New', Courier, monospace;
}

/* ── Light theme ── */
body:not(.dark-theme) .chat-msg {
    background: linear-gradient(90deg, rgba(255,255,255,0.65) 0%, rgba(255,255,255,0.35) 75%, rgba(255,255,255,0) 100%);
    color: #111111;
    backdrop-filter: blur(2px);
}

body:not(.dark-theme) .chat-msg:hover {
    background: linear-gradient(90deg, rgba(255,255,255,0.85) 0%, rgba(255,255,255,0.60) 75%, rgba(255,255,255,0) 100%);
}

body:not(.dark-theme) .chat-time {
    color: rgba(0,0,0,0.45);
}

body:not(.dark-theme) #chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
}

body:not(.dark-theme) #chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.28);
}

#chat-messages > :first-child { margin-top: auto; }