:root {
    --bg-darkest: #05070a;
    --bg-surface: #0b0f17;
    --bg-card: #111724;
    --bg-card-hover: #161e2e;
    --border-subtle: rgba(255, 255, 255, 0.07);
    --border-active: rgba(0, 240, 255, 0.35);
    
    --text-primary: #f0f4fc;
    --text-secondary: #8e9bb5;
    --text-muted: #53607a;
    
    --accent-cyan: #00f0ff;
    --accent-cyan-glow: rgba(0, 240, 255, 0.3);
    --accent-emerald: #00ff9d;
    --accent-emerald-glow: rgba(0, 255, 157, 0.25);
    --accent-pink: #ff2a6d;
    --accent-pink-glow: rgba(255, 42, 109, 0.3);
    --accent-amber: #ffb800;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    
    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-darkest);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    background-image: 
        radial-gradient(circle at 20% 10%, rgba(0, 240, 255, 0.04) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(255, 42, 109, 0.03) 0%, transparent 40%);
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 1440px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ==================== TOP HEADER ==================== */
.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid var(--border-active);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-cyan);
    box-shadow: 0 0 16px var(--accent-cyan-glow);
}

.brand-title {
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: 1.5px;
    color: var(--text-primary);
    display: block;
}

.brand-sub {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--accent-cyan);
    letter-spacing: 1px;
}

.header-badges {
    display: flex;
    gap: 12px;
}

.badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.indicator-dot.green {
    background: var(--accent-emerald);
    box-shadow: 0 0 8px var(--accent-emerald-glow);
}

.indicator-dot.pulse {
    background: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan-glow);
    animation: pulseGlow 1.8s infinite;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.indicator-dot.cyan {
    background: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan-glow);
}

.session-badge {
    border-color: var(--accent-cyan-glow);
}

/* ==================== WORKSPACE GRID ==================== */
.workspace-grid {
    display: grid;
    grid-template-columns: 360px 1fr 380px;
    gap: 20px;
    align-items: start;
}

@media (max-width: 1200px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.015);
    border-bottom: 1px solid var(--border-subtle);
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: var(--text-primary);
}

.panel-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ==================== FORM ELEMENTS ==================== */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

input[type="text"],
input[type="password"],
.styled-select {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
.styled-select:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    padding-right: 40px;
}

.icon-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: color 0.2s;
}

.icon-btn:hover {
    color: var(--text-primary);
}

.field-hint {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* Status Pill */
.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border-radius: 20px;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.status-pill .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-pill.disconnected {
    background: rgba(255, 42, 109, 0.1);
    color: var(--accent-pink);
    border: 1px solid rgba(255, 42, 109, 0.25);
}
.status-pill.disconnected .status-dot { background: var(--accent-pink); }

.status-pill.connecting {
    background: rgba(255, 184, 0, 0.1);
    color: var(--accent-amber);
    border: 1px solid rgba(255, 184, 0, 0.25);
}
.status-pill.connecting .status-dot { background: var(--accent-amber); }

.status-pill.connected {
    background: rgba(0, 255, 157, 0.1);
    color: var(--accent-emerald);
    border: 1px solid rgba(0, 255, 157, 0.25);
    box-shadow: 0 0 10px var(--accent-emerald-glow);
}
.status-pill.connected .status-dot { background: var(--accent-emerald); }

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-md);
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 0.88rem;
    letter-spacing: 1px;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #00f0ff 0%, #00a8ff 100%);
    color: #05070a;
    box-shadow: 0 4px 20px var(--accent-cyan-glow);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(0, 240, 255, 0.45);
}

.btn-danger {
    background: linear-gradient(135deg, #ff1a53 0%, #e60049 50%, #990033 100%);
    color: #ffffff;
    border: 1px solid rgba(255, 42, 109, 0.45);
    box-shadow: 0 4px 22px rgba(255, 26, 83, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    letter-spacing: 1.2px;
    position: relative;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn-danger svg {
    color: #ffffff;
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.6));
    transition: transform 0.2s ease;
}
.btn-danger:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #ff3366 0%, #ff0055 50%, #b3003b 100%);
    border-color: #ff2a6d;
    box-shadow: 0 8px 30px rgba(255, 42, 109, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn-danger:hover svg {
    transform: scale(1.15) rotate(-5deg);
}
.btn-danger:active {
    transform: translateY(1px);
    box-shadow: 0 2px 12px rgba(255, 42, 109, 0.5);
}

.text-btn {
    background: none;
    border: none;
    color: var(--accent-cyan);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}
.text-btn:hover {
    background: rgba(0, 240, 255, 0.1);
}

.hidden {
    display: none !important;
}

/* Profile Card */
.profile-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    padding: 10px 14px;
    border-radius: var(--radius-md);
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--accent-cyan);
}

.profile-name {
    font-weight: 700;
    font-size: 0.88rem;
}

.profile-channel {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--accent-emerald);
}

/* Visualizer Box */
.visualizer-wrapper {
    background: var(--bg-card);
    border-top: 1px solid var(--border-subtle);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.visualizer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
}

.telemetry-readouts {
    display: flex;
    gap: 12px;
}
.telemetry-readouts strong {
    color: var(--accent-cyan);
}

#visualizerCanvas {
    width: 100%;
    height: 70px;
    border-radius: var(--radius-sm);
    background: #080c14;
    display: block;
}

/* ==================== DUAL AUDIO SOURCES ==================== */
.sub-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sub-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sub-title {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
}

.mini-badge {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
}
.mini-badge.playing {
    background: rgba(0, 255, 157, 0.15);
    color: var(--accent-emerald);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--accent-cyan);
    background: rgba(0, 240, 255, 0.04);
}

.drop-zone svg {
    color: var(--accent-cyan);
}

.drop-text {
    font-weight: 600;
    font-size: 0.88rem;
}

.drop-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.file-input-hidden {
    display: none;
}

.track-info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.track-label {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-right: 6px;
}

.track-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--accent-cyan);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

/* Progress bar */
.progress-container {
    width: 100%;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00f0ff, #00ff9d);
    transition: width 0.1s linear;
}

/* Controls */
.player-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.control-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.control-btn:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    transform: scale(1.05);
}

.control-btn.active {
    background: rgba(0, 240, 255, 0.15);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider.round {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.08);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 24px;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    box-sizing: border-box;
}

.slider.round:before {
    position: absolute;
    content: "";
    height: 15px;
    width: 15px;
    left: 3px;
    top: 3px;
    background-color: #8b9bb4;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

input:checked + .slider.round {
    background-color: rgba(0, 255, 157, 0.22);
    border-color: var(--accent-emerald);
    box-shadow: 0 0 12px rgba(0, 255, 157, 0.3);
}

input:checked + .slider.round:before {
    transform: translateX(21px);
    background-color: var(--accent-emerald);
    box-shadow: 0 0 10px var(--accent-emerald-glow);
}

.mode-select-row {
    display: flex;
    gap: 16px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.radio-label input {
    accent-color: var(--accent-cyan);
}

.mic-status-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ==================== DSP RACK ==================== */
.presets-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(95px, 1fr));
    gap: 6px;
}

.preset-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 8px 8px;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.preset-btn:hover {
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.preset-btn.active {
    background: rgba(0, 240, 255, 0.12);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: 0 0 12px var(--accent-cyan-glow);
}

/* Stereo Matrix Mode Switcher */
.stereo-modes-container {
    background: rgba(168, 85, 247, 0.05);
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: var(--radius-md);
    padding: 10px 12px;
}

.stereo-modes-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-top: 4px;
}

.stereo-mode-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 7px 6px;
    font-family: var(--font-mono);
    font-size: 0.67rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
}

.stereo-mode-btn:hover {
    border-color: rgba(168, 85, 247, 0.4);
    color: #d8b4fe;
}

.stereo-mode-btn.active {
    background: rgba(168, 85, 247, 0.2);
    border-color: #c084fc;
    color: #f3e8ff;
    box-shadow: 0 0 14px rgba(168, 85, 247, 0.4);
}

.slider-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slider-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.slider-val {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
}

.text-neon-cyan { color: var(--accent-cyan); }
.text-neon-pink { color: var(--accent-pink); }
.text-neon-emerald { color: var(--accent-emerald); }
.text-neon-purple { color: #d175ff; }

/* Neon Sliders */
.neon-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    outline: none;
    cursor: pointer;
}

.neon-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    transition: transform 0.15s ease;
}

.neon-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.neon-slider.cyan::-webkit-slider-thumb {
    background: var(--accent-cyan);
    box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.neon-slider.pink::-webkit-slider-thumb {
    background: var(--accent-pink);
    box-shadow: 0 0 12px var(--accent-pink-glow);
}

.neon-slider.emerald::-webkit-slider-thumb {
    background: var(--accent-emerald);
    box-shadow: 0 0 12px var(--accent-emerald-glow);
}

.neon-slider.purple::-webkit-slider-thumb {
    background: #b026ff;
    box-shadow: 0 0 14px rgba(176, 38, 255, 0.75);
}

/* Enhanced Hardware Limiter Card */
.limiter-toggle-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: linear-gradient(135deg, rgba(16, 22, 34, 0.95) 0%, rgba(9, 13, 20, 0.98) 100%);
    border: 1px solid rgba(0, 255, 157, 0.35);
    padding: 13px 16px;
    border-radius: var(--radius-md);
    margin-top: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.limiter-toggle-card.bypassed {
    border-color: rgba(255, 42, 109, 0.35);
    box-shadow: 0 4px 20px rgba(255, 42, 109, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.limiter-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.limiter-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.limiter-title-row svg {
    color: var(--accent-emerald);
    filter: drop-shadow(0 0 6px var(--accent-emerald-glow));
    transition: color 0.25s ease;
}

.limiter-toggle-card.bypassed .limiter-title-row svg {
    color: var(--accent-pink);
    filter: drop-shadow(0 0 6px var(--accent-pink-glow));
}

.limiter-title {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: var(--text-primary);
}

.limiter-desc {
    font-size: 0.66rem;
    color: var(--text-muted);
    line-height: 1.35;
}

/* ==================== MOBILE & RESPONSIVE PERFECTION ==================== */
@media (max-width: 1024px) {
    .workspace-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .header-badges {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 12px;
    }
    .panel-body {
        padding: 16px 14px;
        gap: 16px;
    }
    /* Mobile tap target sizes */
    input[type="text"],
    input[type="password"],
    .styled-select {
        font-size: 16px; /* Prevents auto-zoom on iOS Safari */
        padding: 12px 14px;
    }
    .btn {
        padding: 14px;
        font-size: 0.95rem;
    }
    /* Touch friendly mobile drop zone */
    .drop-zone {
        padding: 24px 16px;
        border-width: 2px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .drop-zone:active {
        transform: scale(0.98);
        border-color: var(--accent-cyan);
    }
    .drop-text {
        font-size: 0.88rem;
    }
    .drop-sub {
        font-size: 0.72rem;
    }
    /* Slider touch areas */
    .neon-slider {
        height: 10px;
    }
    .neon-slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    /* Visualizer canvas on small screens */
    .visualizer-wrapper {
        padding: 12px 10px;
    }
}

@media (max-width: 480px) {
    .header-badges {
        flex-direction: column;
        align-items: stretch;
    }
    .badge {
        justify-content: center;
    }
    .presets-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .limiter-toggle-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .limiter-toggle-card .switch {
        align-self: flex-end;
    }
}
