#floating-livestream {
    position: fixed;
    z-index: 9999;
    background: #000;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    min-width: 100px;
    min-height: 56px;
    animation: fadeInLivestream 0.2s;
    transition: width 0.2s, height 0.2s, left 0.2s, top 0.2s, right 0.2s, bottom 0.2s;
}

@keyframes fadeInLivestream {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

#floating-livestream .grab-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 32px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10002;
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: 1em;
    user-select: none;
}

#floating-livestream:hover .grab-bar,
#floating-livestream.dragging .grab-bar {
    opacity: 1;
}

#floating-livestream .grab-bar:active {
    cursor: grabbing;
}

#floating-livestream button#close-livestream {
    position: absolute;
    top: 4px;
    right: 8px;
    z-index: 10004;
    /* highest z-index to always be on top */
    font-size: 1.5em;
    background: rgba(255, 255, 255, 0.7);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
}

#floating-livestream button#close-livestream:hover {
    background: #D4AF37;
    color: #000;
}

#floating-livestream .minimize-btn {
    position: absolute;
    left: 10px;
    top: 5px;
    z-index: 10003;
    font-size: 1.2em;
    background: transparent;
    color: #fff;
    border: none;
    cursor: pointer;
}

#floating-livestream .mute-btn {
    position: absolute;
    left: 42px;
    top: 6px;
    z-index: 10003;
    font-size: 1.2em;
    background: transparent;
    color: #fff;
    border: none;
    cursor: pointer;
}

/* Minimized state */
#floating-livestream.minimized {
    height: 36px !important;
    width: 200px !important;
    min-width: 100px !important;
    min-height: 36px !important;
    overflow: hidden;
    transition: height 0.2s, width 0.2s;
    border-radius: 8px 8px 0 0;
    background: #222;
}

#floating-livestream.minimized .resize-handle,
#floating-livestream.minimized iframe,
#floating-livestream.minimized #close-livestream,
#floating-livestream.minimized .mute-btn {
    display: none !important;
}

#floating-livestream.minimized .grab-bar {
    opacity: 1 !important;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.7);
}

/* Show video title on grab bar */
#floating-livestream .grab-bar .title {
    flex: 1;
    text-align: center;
    font-size: 1em;
    font-weight: bold;
}

/* Resize handle */
#floating-livestream .resize-handle {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 24px;
    height: 24px;
    cursor: nwse-resize;
    z-index: 10002;
    background: url('data:image/svg+xml;utf8,<svg fill="none" height="20" width="20" xmlns="http://www.w3.org/2000/svg"><path d="M18 18H2V2" stroke="white" stroke-width="2"/></svg>') no-repeat center/70%;
    opacity: 0.7;
}

/* Snap highlight */
#floating-livestream.snap {
    box-shadow: 0 0 0 2px #D4AF37, 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Mobile tweaks */
@media (max-width: 600px) {
    #floating-livestream {
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 32vw !important;
        min-width: 100vw !important;
        min-height: 56vw !important;
        border-radius: 0;
    }

    #floating-livestream .grab-bar,
    #floating-livestream .resize-handle,
    #floating-livestream .minimize-btn,
    #floating-livestream .mute-btn {
        display: none !important;
    }
}