.stream-chat-widget {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    width: 380px;
    max-width: calc(100vw - 2rem);
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    background-color: rgb(17, 17, 17);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow: hidden;
}

.stream-chat-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    background-color: rgba(30, 30, 30, 0.8);
}

.stream-chat-widget-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: rgb(255, 255, 255);
    margin: 0;
}

.stream-chat-widget-viewers {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
}

.stream-chat-widget-pinned {
    padding: 0.625rem 0.75rem;
    margin: 0.5rem;
    border-radius: 0.375rem;
    background-color: rgba(227, 146, 20, 0.1);
    border: 1px solid rgba(227, 146, 20, 0.3);
    border-left: 3px solid rgb(227, 146, 20);
    flex-shrink: 0;
}

.stream-chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 200px;
    max-height: 400px;
}

.stream-chat-loading {
    text-align: center;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.5);
}

.stream-chat-message {
    position: relative;
    margin-bottom: 0.1rem;
    display: flex !important;
    align-items: flex-start;
    gap: 0.5rem;
    animation: streamChatMessageFadeIn 0.5s ease-out;
    background: #1c1c1c;
    border-radius: 6px;
}

.stream-chat-message.stream-chat-message-own {
    display: flex !important;
    justify-content: flex-end !important;
    flex-direction: row !important;
}

@keyframes streamChatMessageFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stream-chat-message:hover .stream-chat-message-actions {
    opacity: 1;
}

.stream-chat-message-card {
    margin-right: 0.5rem;
    margin-left: 0;
    flex: 1;
    max-width: 75%;
    overflow: hidden;
    border-radius: 0.375rem;
    background-color: rgb(30, 30, 30);
    padding: 0.5rem;
    padding-bottom: 1.5rem;
    position: relative;
}

.stream-chat-message.stream-chat-message-own .stream-chat-message-card {
    margin-right: 0 !important;
    margin-left: 0.5rem !important;
    background: linear-gradient(135deg, rgba(227, 146, 20, 0.2) 0%, rgba(227, 146, 20, 0.1) 100%) !important;
    border: 1px solid rgba(227, 146, 20, 0.3) !important;
}

.stream-chat-message-user {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    position: relative;
    z-index: 1;
}

.stream-chat-reply {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    margin-bottom: 0.625rem;
    border-left: 4px solid rgb(227, 146, 20);
    background: linear-gradient(90deg, rgba(227, 146, 20, 0.15) 0%, rgba(227, 146, 20, 0.05) 100%);
    border-radius: 0.375rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.stream-chat-reply::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, rgb(227, 146, 20) 0%, rgba(227, 146, 20, 0.5) 100%);
    border-radius: 4px 0 0 4px;
}

.stream-chat-reply:hover {
    background: linear-gradient(90deg, rgba(227, 146, 20, 0.2) 0%, rgba(227, 146, 20, 0.08) 100%);
    transform: translateX(2px);
}

.stream-chat-reply-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: rgb(227, 146, 20);
}

.stream-chat-reply-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.stream-chat-reply-username {
    color: rgb(227, 146, 20);
    font-weight: 700;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stream-chat-reply-username::before {
    content: 'â†©';
    font-size: 0.875rem;
    opacity: 0.8;
}

.stream-chat-reply-message {
    color: rgba(255, 255, 255, 0.7);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8125rem;
    font-style: italic;
}

.stream-chat-message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    margin-left: 8px;
}

.stream-chat-username {
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    transition: color 0.2s ease;
}

.stream-chat-username:hover {
    color: rgb(227, 146, 20);
}

.stream-chat-message-badges {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stream-chat-message-badge {
    display: flex;
    height: 1.5rem;
    align-items: center;
    border-radius: 0.125rem;
    background-color: rgb(17, 17, 17);
    padding: 0 0.5rem;
    text-align: center;
    font-size: 0.75rem;
    font-weight: bold;
    color: rgb(160, 160, 160);
}

.stream-chat-message-badge-mod {
    background-color: rgba(34, 197, 94, 0.8);
    color: rgba(255, 255, 255, 0.9);
}

.stream-chat-message-badge-sub {
    background-color: rgba(139, 92, 246, 0.8);
    color: rgba(255, 255, 255, 0.9);
}

.stream-chat-message-badge-friend {
    background-color: rgba(34, 211, 238, 0.8);
    color: rgba(255, 255, 255, 0.9);
}

.stream-chat-badge-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    vertical-align: middle;
}

.stream-chat-badge-label {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    background-color: rgba(227, 146, 20, 0.2);
    color: rgb(227, 146, 20);
    font-size: 0.625rem;
    font-weight: 600;
    vertical-align: middle;
}

.stream-chat-message-time {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
}

.stream-chat-message-text {
    position: relative;
    margin-top: 0.5rem;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    font-size: 0.875rem;
    color: rgb(240, 240, 240);
    line-height: 1.5;
    left: 8px;
    margin-bottom: 8px;
}

.stream-chat-emote {
    height: 1.2em;
    vertical-align: middle;
    display: inline-block;
}

.stream-chat-message-actions {
    position: absolute;
    bottom: 0.25rem;
    right: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.stream-chat-reply-btn,
.stream-chat-delete-btn,
.stream-chat-pin-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.2s ease;
}

.stream-chat-reply-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.stream-chat-delete-btn:hover {
    background-color: rgba(239, 68, 68, 0.3);
    color: rgb(239, 68, 68);
    transform: scale(1.1);
}

.stream-chat-pin-btn:hover {
    background-color: rgba(245, 158, 11, 0.3);
    color: rgb(245, 158, 11);
    transform: scale(1.1);
}

.stream-chat-widget-input {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(33, 33, 33, 0.5);
    flex-shrink: 0;
}

.stream-chat-widget-emotes {
    display: none;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.5rem;
    background-color: rgb(30, 30, 30);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    max-height: 120px;
    overflow-y: auto;
}

.stream-chat-emote-item {
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: transform 0.2s ease;
    position: relative;
}

.stream-chat-emote-item img {
    width: 16px;
    height: 16px;
    display: block;
    object-fit: contain;
}

.stream-chat-emote-item:hover {
    transform: scale(1.3);
    z-index: 10;
}

.stream-chat-emote-item:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    white-space: nowrap;
    margin-bottom: 0.25rem;
    pointer-events: none;
    z-index: 1000;
}

.stream-chat-widget-input-wrapper {
    display: flex;
    width: 100%;
    flex-direction: column;
    gap: 0.5rem;
}

.stream-chat-widget-input-container {
    position: relative;
    flex: 1;
    width: 100%;
}

.stream-chat-widget-input-field {
    width: 100%;
    min-height: 2.5rem;
    max-height: 8rem;
    padding: 0.5rem;
    padding-right: 3rem;
    border-radius: 0.375rem;
    background-color: rgb(30, 30, 30);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgb(255, 255, 255);
    font-size: 0.875rem;
    box-sizing: border-box;
    overflow-y: auto;
    word-wrap: break-word;
    white-space: pre-wrap;
    font-family: inherit;
}

.stream-chat-widget-input-field:empty::before {
    content: attr(data-placeholder);
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
}

.stream-chat-widget-input-field:focus {
    outline: none;
    border-color: rgb(227, 146, 20);
}

.stream-chat-widget-input-field[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
}

.stream-chat-widget-emoji {
    position: absolute;
    right: 1.75rem;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.3s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stream-chat-widget-emoji:hover {
    transform: translateY(-50%) scale(1.05);
    color: rgb(234, 179, 8);
}

.stream-chat-widget-send {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    align-self: flex-end;
}

.stream-chat-widget-send-btn {
    border-radius: 0.375rem;
    background-color: rgb(227, 146, 20);
    padding: 0.5rem 1rem;
    color: rgb(255, 255, 255);
    cursor: not-allowed;
    opacity: 0.2;
    border: none;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.stream-chat-widget-send-btn:not(:disabled) {
    cursor: pointer;
    opacity: 1;
}

.stream-chat-widget-send-btn:not(:disabled):hover {
    background-color: rgb(200, 130, 18);
}

.stream-chat-widget,
.stream-chat-widget-header,
.stream-chat-widget-title,
.stream-chat-widget-viewers,
.stream-chat-widget-pinned,
.stream-chat-widget-messages,
.stream-chat-widget-input,
.stream-chat-widget-emotes,
.stream-chat-widget-input-wrapper,
.stream-chat-widget-input-container,
.stream-chat-widget-input-field,
.stream-chat-widget-emoji,
.stream-chat-widget-send,
.stream-chat-widget-send-btn {
    display: none !important;
}

.stream-chat-message-avatar {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .stream-chat-widget {
        width: calc(100vw - 1rem);
        right: 0.5rem;
        bottom: 0.5rem;
        max-height: calc(100vh - 1rem);
    }
    
    .stream-chat-widget-messages {
        max-height: 300px;
        padding: 0.5rem;
    }
    
    .stream-chat-widget-input {
        padding: 0.5rem;
    }
}

.stream-page-container ~ * .navbar-chat,
.stream-page-container ~ * #mobile-chat-btn {
    display: none !important;
}

body.stream-page .navbar-chat,
body.stream-page #mobile-chat-btn {
    display: none !important;
}