/* Toolbar Premium Styling */
.toolbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: rgba(0, 0, 0, 0.85);
    /* Semi-transparent dark */
    backdrop-filter: blur(12px);
    /* Glass effect */
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Span full width */
    padding: 0 2rem;
    /* More breathing room */
    z-index: 2000;
    gap: 1.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.toolbar::-webkit-scrollbar {
    display: none;
}

/* Toolbar Groups */
.toolbar-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    /* More spacing */
    height: 60%;
    position: relative;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    padding-right: 1.5rem;
    flex-shrink: 0;
    /* Prevent squishing */
}

.toolbar-group:last-child {
    border-right: none;
    padding-right: 0;
}

/* Base Button Style */
.toolbar button {
    background: transparent;
    border: none;
    color: #a3a3a3;
    padding: 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar button svg {
    width: 24px;
    height: 24px;
    stroke-width: 2;
}

.toolbar button:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.toolbar button:active {
    transform: translateY(0);
}

.toolbar button.active {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.15);
}

/* Sliders (Range Inputs) */
.control-group {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 120px;
    gap: 6px;
}

.control-group label {
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.8px;
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
}

.control-group span {
    color: #60a5fa;
}

/* Custom Range Slider */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    margin-top: -5px;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3);
    /* Glow ring */
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #404040;
    border-radius: 2px;
}

/* Color Pickers (Styled as Icons) */
.color-picker-wrapper {
    position: relative;
    width: 32px;
    height: 32px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
}

.color-picker-wrapper:hover {
    transform: scale(1.1);
    border-color: #fff;
}

.color-picker-wrapper input[type="color"] {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    padding: 0;
    margin: 0;
    border: none;
    cursor: pointer;
}

/* Record Button - Pill Shape highlighted */
#recordBtn {
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #fca5a5;
    background: rgba(220, 38, 38, 0.1);
    font-weight: 600;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    border-radius: 50px;
    /* Pill */
    white-space: nowrap;
    gap: 8px;
    display: flex;
    align-items: center;
}

#recordBtn:hover {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
    box-shadow: 0 0 12px rgba(220, 38, 38, 0.6);
}

#recordBtn.recording {
    background: #dc2626;
    color: white;
    animation: pulseRecording 2s infinite;
}

@keyframes pulseRecording {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(220, 38, 38, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
    }
}

/* Tooltip */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid #333;
    color: #e5e5e5;
    padding: 6px 10px;
    font-size: 11px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 2001;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .toolbar {
        height: 70px;
        padding: 0 1rem;
        justify-content: flex-start;
        /* Left align to allow scroll */
    }

    .toolbar-group {
        gap: 0.8rem;
        padding-right: 1rem;
    }

    .control-group {
        min-width: 100px;
    }

    #recordBtn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }

    /* Ensure last item has padding to not hit edge */
    .toolbar-group:last-child {
        padding-right: 1rem;
    }

    /* Window Controls Group */
    .window-controls {
        border-left: 1px solid rgba(255, 255, 255, 0.1);
        border-right: none;
        padding-left: 1rem;
        padding-right: 0;
        margin-left: auto;
        /* Push to right */
    }

    /* Drag Handle */
    .drag-handle {
        cursor: grab;
        color: #666;
        padding: 8px;
        display: flex;
        align-items: center;
    }

    .drag-handle:active {
        cursor: grabbing;
        color: #fff;
    }

    /* Floating State */
    .toolbar.floating {
        position: fixed;
        /* Remains fixed to viewport but movable */
        top: 20px;
        left: 20px;
        width: auto;
        max-width: 90vw;
        height: auto;
        min-height: 80px;
        border-radius: 16px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
        resize: both;
        /* Allow resizing */
        overflow: hidden;
        /* For resize handle */
        padding-right: 20px;
        /* Space for resize handle */

        /* Transition for smooth docking */
        transition: width 0.3s, border-radius 0.3s, backdrop-filter 0.3s;
    }

    /* Ensure resize handle is visible */
    .toolbar.floating::-webkit-resizer {
        background-color: transparent;
    }

    /* When floating, allow wrapping if resized small */
    .toolbar.floating {
        flex-wrap: wrap;
        justify-content: flex-start;
        overflow-y: auto;
        /* Allow content scroll if squished */
    }

    /* Mobile Responsiveness for Floating */
    @media (max-width: 768px) {
        .toolbar.floating {
            width: 90%;
            left: 5% !important;
            /* Center on mobile if undocked initially */
        }
    }

    /* Re-add end bracket provided in original context */
}