:root {
    --bg-dark: #0a0e1c;
    --card-bg: rgba(16, 23, 44, 0.65);
    --border-color: rgba(255, 255, 255, 0.07);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Accent colors */
    --color-indigo: #5c7cfa;
    --color-indigo-glow: rgba(92, 124, 250, 0.35);
    --color-magenta: #e83e8c;
    --color-magenta-glow: rgba(232, 62, 140, 0.35);
    --color-emerald: #10b981;
    --color-danger: #ef4444;

    --font-primary: 'Plus Jakarta Sans', -apple-system, sans-serif;
    --font-display: 'Outfit', sans-serif;
    --transition-speed: 0.25s;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-primary);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    position: relative;
}

/* Ambient glow background blobs */
.ambient-glows {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.glow-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.15;
}

.glow-indigo {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--color-indigo) 0%, transparent 70%);
}

.glow-magenta {
    bottom: -15%;
    right: -10%;
    width: 55vw;
    height: 55vw;
    background: radial-gradient(circle, var(--color-magenta) 0%, transparent 70%);
}

/* App Container Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Glassmorphism utility class */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
}

/* Sidebar Styling */
.sidebar {
    width: 380px;
    height: 100%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 24px;
    gap: 20px;
    z-index: 10;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.4);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.sidebar-header {
    margin-bottom: 5px;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--color-indigo);
    filter: drop-shadow(0 0 8px var(--color-indigo));
}

.logo-glow {
    position: absolute;
    width: 36px;
    height: 36px;
    background: var(--color-indigo);
    border-radius: 50%;
    filter: blur(10px);
    opacity: 0.3;
    left: -2px;
    top: -2px;
}

.sidebar-header h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.sidebar-header h1 span {
    background: linear-gradient(135deg, var(--color-indigo) 0%, var(--color-magenta) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Sidebar Section Cards */
.section-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: all var(--transition-speed);
}

.section-card:hover {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-card h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.puffs-count {
    background: rgba(92, 124, 250, 0.15);
    color: var(--color-indigo);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    border: 1px solid rgba(92, 124, 250, 0.2);
}

.active-item-name {
    font-size: 0.75rem;
    color: var(--color-magenta);
    font-weight: 600;
}

/* Actions Grid buttons */
.actions-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr 0.6fr;
    gap: 8px;
}

/* Buttons */
.btn {
    padding: 10px 14px;
    border-radius: 10px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    border: none;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all var(--transition-speed);
}

.btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.primary-btn {
    background: linear-gradient(135deg, var(--color-indigo) 0%, #3b5bdb 100%);
    color: #fff;
    box-shadow: 0 4px 12px var(--color-indigo-glow);
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--color-indigo-glow);
    filter: brightness(1.1);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.secondary-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

.danger-btn {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.danger-btn:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.25);
}

.danger-btn-small {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-danger);
    padding: 6px 12px;
    font-size: 0.75rem;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.danger-btn-small:hover {
    background: rgba(239, 68, 68, 0.2);
}

.text-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 4px 10px;
    font-size: 0.75rem;
}

.text-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

/* Puffs List styling */
.puffs-list-container {
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.15);
}

.puffs-list-container::-webkit-scrollbar {
    width: 4px;
}

.puffs-list-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
}

.puffs-list {
    list-style: none;
}

.puff-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all var(--transition-speed);
}

.puff-item:last-child {
    border-bottom: none;
}

.puff-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.puff-item.selected {
    background: rgba(92, 124, 250, 0.08);
    border-left: 3px solid var(--color-indigo);
    color: var(--text-primary);
}

.puff-item .item-details {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.puff-item.selected .item-details {
    color: var(--text-secondary);
}

/* Slider Controls Panel */
.property-sliders {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

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

.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.slider-value {
    color: var(--color-indigo);
    font-weight: 600;
}

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

.neon-slider:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.neon-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-indigo);
    box-shadow: 0 0 6px var(--color-indigo-glow);
    transition: transform 0.1s;
}

.neon-slider::-webkit-slider-thumb:hover:not(:disabled) {
    transform: scale(1.25);
}

#properties-panel.selected-active .slider-value {
    color: var(--color-magenta);
}

#properties-panel.selected-active .neon-slider::-webkit-slider-thumb {
    background: var(--color-magenta);
    box-shadow: 0 0 6px var(--color-magenta-glow);
}

/* JSON Text Area */
.json-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: -8px;
}

.json-area {
    width: 100%;
    height: 80px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    color: var(--text-muted);
    font-family: monospace;
    font-size: 0.7rem;
    padding: 8px;
    outline: none;
    resize: none;
    transition: all var(--transition-speed);
}

.json-area:focus {
    border-color: var(--color-indigo);
    color: var(--text-primary);
}

/* Viewports Main Container */
.viewports-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 20px;
    overflow: hidden;
}

/* Top bar controls */
.top-bar {
    border-radius: 16px;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

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

.presets-row .label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

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

.mode-row .label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.preset-btn {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed);
}

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

.preset-btn.active {
    background: rgba(9c, 124, 250, 0.1);
    border-color: var(--color-indigo);
    color: var(--text-primary);
    box-shadow: 0 0 10px rgba(92, 124, 250, 0.15);
}

.options-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-toggle {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.btn-toggle.active {
    color: var(--color-emerald);
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.08);
}

/* Viewports Grid */
.viewports-split {
    flex-grow: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    overflow: hidden;
}

@media (max-width: 1024px) {
    .viewports-split {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
}

.viewport-box {
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.viewport-label {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 5;
    background: rgba(10, 14, 28, 0.4);
}

.viewport-label h3 {
    font-size: 0.9rem;
    font-weight: 600;
}

.badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-indigo {
    background: rgba(92, 124, 250, 0.15);
    color: var(--color-indigo);
    border: 1px solid rgba(92, 124, 250, 0.2);
}

.badge-magenta {
    background: rgba(232, 62, 140, 0.15);
    color: var(--color-magenta);
    border: 1px solid rgba(232, 62, 140, 0.2);
}

/* Canvas Viewport Containers */
.canvas-container {
    flex-grow: 1;
    position: relative;
    background: #04060d;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.viewport-tips {
    position: absolute;
    bottom: 12px;
    left: 20px;
    font-size: 0.7rem;
    color: var(--text-muted);
    pointer-events: none;
    z-index: 5;
}

/* 2D Projection view Toggles */
.projection-toggles {
    position: absolute;
    bottom: 12px;
    right: 20px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 4px;
}

.projection-toggles .label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0 6px;
}

.view-toggle-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
}

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

.view-toggle-btn.active {
    background: var(--color-magenta);
    color: #fff;
    box-shadow: 0 0 8px var(--color-magenta-glow);
}

/* Sidebar Tabs */
.sidebar-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 5px;
}

.tab-btn {
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--color-indigo) 0%, #3b5bdb 100%);
    color: #fff;
    box-shadow: 0 4px 10px var(--color-indigo-glow);
}

/* Tab Panels */
.tab-panel {
    display: none;
    flex-direction: column;
    gap: 20px;
}

.tab-panel.active {
    display: flex;
}

/* Audio reactive elements in sidebar */
.audio-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.theme-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.theme-card {
    width: 100%;
    min-height: 72px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
    display: grid;
    grid-template-columns: 44px 1fr;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: all var(--transition-speed);
}

.theme-card:hover {
    transform: translateY(-1px);
    border-color: rgba(92, 124, 250, 0.45);
    background: rgba(255, 255, 255, 0.04);
}

.theme-card.active {
    border-color: var(--color-indigo);
    background: linear-gradient(135deg, rgba(92, 124, 250, 0.15), rgba(232, 62, 140, 0.1));
    box-shadow: 0 0 16px rgba(92, 124, 250, 0.15);
}

.theme-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.22);
    font-size: 1.25rem;
}

.theme-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.theme-copy strong {
    font-size: 0.92rem;
    line-height: 1.2;
}

.theme-copy small {
    color: var(--text-secondary);
    font-size: 0.72rem;
    line-height: 1.25;
}

.auto-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
}

.btn-auto {
    justify-content: flex-start;
    color: #d7f7ff;
    background: rgba(92, 124, 250, 0.08);
    border: 1px solid rgba(92, 124, 250, 0.18);
    width: 100%;
}

.btn-auto.active {
    border-color: var(--color-indigo);
    background: rgba(92, 124, 250, 0.15);
    box-shadow: 0 0 16px rgba(92, 124, 250, 0.18);
}

.template-summary {
    color: var(--text-secondary);
    font-size: 0.72rem;
    line-height: 1.45;
}

.playback-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(0, 0, 0, 0.15);
    padding: 8px 12px;
    border-radius: 8px;
}

.btn-secondary-playback {
    background: rgba(239, 71, 111, 0.1);
    border: 1px solid rgba(239, 71, 111, 0.2);
    color: #ef476f;
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-speed);
    outline: none;
    border-radius: 8px;
    font-weight: 600;
}

.btn-secondary-playback:hover {
    background: #ef476f;
    color: white;
}

.volume-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-grow: 1;
}

.volume-icon {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Details Panel dropdown styling */
.advanced-panel {
    background: rgba(255, 255, 255, 0.01) !important;
}

.advanced-panel > summary {
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.advanced-panel > summary::-webkit-details-marker {
    display: none;
}

.advanced-panel > summary::after {
    content: '▼';
    color: var(--color-indigo);
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.advanced-panel[open] > summary::after {
    transform: rotate(180deg);
}

.config-controls {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.label-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.custom-select {
    font-family: inherit;
    font-size: 0.82rem;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px;
    outline: none;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.custom-select:focus {
    border-color: var(--color-indigo);
    background: rgba(10, 14, 28, 0.8);
    box-shadow: 0 0 10px rgba(92, 124, 250, 0.15);
}

.custom-select option {
    background-color: #0a0e1c;
    color: var(--text-primary);
}

/* Spectrum Canvas */
.spectrum-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

#analyzer-canvas {
    width: 100%;
    height: 90px;
    display: block;
}

/* LED Strip Visualizer */
.led-strip-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.led-strip-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.led-strip {
    display: flex;
    justify-content: space-between;
    gap: 3px;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.03);
    overflow-x: auto;
}

.led-pixel {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #222;
    flex-shrink: 0;
    transition: background-color 0.05s ease-out, box-shadow 0.05s ease-out;
}

/* Energy Bar */
.energy-bar-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.energy-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.progress-track {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--color-indigo), var(--color-magenta));
    border-radius: 3px;
    box-shadow: 0 0 10px rgba(92, 124, 250, 0.5);
    transition: width 0.08s ease-out;
}
