/* 
 * BLOQQER Quantum Visualizer Design System
 * Hyper-minimal, Premium, "Apple-meets-Developer" Dark Theme
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Color Palette */
    --bg-primary: #0B0B0C;
    --bg-secondary: #121214;
    --bg-tertiary: #1C1C1E;
    
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-active: rgba(255, 255, 255, 0.15);
    
    --text-primary: #FFFFFF;
    --text-secondary: #D1D1D6;
    --text-muted: #6B6B76;
    
    --accent-green: #34C759;
    --accent-green-dim: rgba(52, 199, 89, 0.15);
    --accent-orange: #FF9F0A;
    --accent-zinc: #E4E4E7;
    --accent-zinc-hover: #F4F4F5;
    
    /* Font stacks */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', "SF Mono", Monaco, Menlo, Consolas, monospace;
}

/* Global Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    /* Prevent white borders when zooming out — background fills the entire html element */
    background-color: var(--bg-primary);
    overflow-x: hidden;
    /* Ensure scrollbar does not trigger horizontal overflow */
    scrollbar-gutter: stable;
}

body {
    background-color: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
}

.container {
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Typography Hierarchy */
h1, h2, h3, h4 {
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    margin-bottom: 8px;
}

h2 {
    font-size: 1.25rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

h3 {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* Section Labels (Apple-meets-Developer Telemetry Style) */
.section-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-label::before {
    content: "//";
    color: var(--accent-green);
    font-weight: bold;
}

/* Header */
header {
    margin-bottom: 48px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 24px;
    /* Ensure header never overflows horizontally */
    width: 100%;
    box-sizing: border-box;
}

.text-logo {
    font-family: var(--font-sans);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    color: var(--text-primary);
    text-transform: uppercase;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.text-logo .q-letters {
    color: var(--accent-green);
    text-shadow: 0 0 8px var(--accent-green-dim);
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Layout Architecture */
.main-content {
    width: 100%;
    overflow: hidden; /* Prevent child elements from causing horizontal scroll */
}

.visualization-controls-wrapper {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 40px;
    align-items: start;
    width: 100%;
}

.visualizer-circuit-section {
    display: flex;
    flex-direction: column;
    gap: 32px;
    min-width: 0; /* Prevent grid blowout */
}

/* 3D Visualization Container */
#visualization-container {
    width: 100%;
    aspect-ratio: 1.2 / 1;
    min-height: 350px; /* Prevent collapse when WebGL fails to initialize */
    background: #000000 !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

#visualization-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    outline: none !important;
}

/* Control Panel & Modular Sections */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 32px;
    min-width: 0; /* Prevent grid blowout */
}

.panel-section {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 24px;
    position: relative;
    /* Ensure panels never exceed their parent width without clipping inner scrollers */
    width: 100%;
    box-sizing: border-box;
    overflow-x: clip;
}

/* Buttons System */
button, .gate-btn, .circuit-btn, .export-btn, .path-btn {
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 4px;
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    text-decoration: none;
    outline: none;
}

/* Standard Secondary Monochromatic Button */
button, .gate-btn, .export-btn, .path-btn, .circuit-btn {
    background-color: #161618;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

button:hover, .gate-btn:hover, .export-btn:hover, .path-btn:hover, .circuit-btn:hover {
    background-color: #222225;
    border-color: var(--border-active);
    color: var(--text-primary);
}

/* Solid Zinc Primary Action Button */
#apply-rotation, #update-state, #reflect-circuit, #execute-circuit, #voice-command-btn.listening {
    background-color: var(--accent-zinc);
    color: #09090B;
    border: none;
    font-weight: 600;
}

#apply-rotation:hover, #update-state:hover, #reflect-circuit:hover, #execute-circuit:hover {
    background-color: var(--accent-zinc-hover);
    transform: none;
    box-shadow: none;
}

/* Specific Gate Buttons */
.gate-buttons {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-bottom: 20px;
    width: 100%;
}

.gate-btn {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 8px;
    min-height: 36px;
}

/* Center View & Copy buttons */
.center-view-btn, .copy-btn {
    width: 100%;
    margin-top: 12px;
}

/* Form Inputs & Sliders */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.input-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

input[type="text"] {
    width: 100%;
    background-color: #080809;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 10px 14px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s ease;
    /* iOS: prevent auto-zoom on focus (requires font-size ≥ 16px on mobile) */
    -webkit-text-size-adjust: 100%;
}

input[type="text"]:focus {
    border-color: var(--border-active);
}

/* Range Sliders */
.slider-group {
    margin-bottom: 16px;
}

.slider-group label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

.slider-group label span {
    color: var(--accent-green);
}

input[type="range"] {
    width: 100%;
    margin-top: 8px;
    height: 4px;
    background: var(--border-subtle);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-zinc);
    cursor: pointer;
    transition: transform 0.1s ease;
}

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

/* Toggle Switch Styling */
.path-controls-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 16px 0;
    padding: 16px 0;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.toggle-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Switch UI */
.switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #1C1C1E;
    transition: .2s;
    border-radius: 18px;
    border: 1px solid var(--border-subtle);
}

.slider::before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    transition: .2s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-zinc);
    border-color: var(--accent-zinc);
}

input:checked + .slider::before {
    transform: translateX(14px);
    background-color: #09090B;
}

/* State display & Telemetry reads */
.state-display {
    background-color: #080809;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.state-display div {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.state-display div::before {
    content: "// ";
    color: var(--text-muted);
    font-weight: bold;
}

.state-display span {
    color: var(--accent-green);
}

/* Voice Commands widget */
#voice-command-btn {
    width: 100%;
}

#voice-command-btn.listening {
    background-color: var(--accent-green);
    color: #09090B;
    animation: voicePulse 1.5s infinite;
}

#voice-status {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 10px;
}

#voice-transcript {
    min-height: 48px;
    background-color: #080809;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

@keyframes voicePulse {
    0% { opacity: 0.85; }
    50% { opacity: 1; }
    100% { opacity: 0.85; }
}

/* Export Buttons Grid */
.export-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* Custom UI Overhaul for Circuit Composer */
.circuit-composer {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 24px;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

.circuit-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap; /* Wrap controls onto next line on narrow widths */
}

.circuit-header h2 {
    margin-bottom: 0;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
}

.circuit-controls {
    display: flex;
    gap: 8px;
}

.circuit-toolbar {
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 16px;
}

.gate-toolbar h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.gate-toolbar .gate-buttons {
    grid-template-columns: repeat(9, 1fr);
    margin-bottom: 16px;
}

.gate-tool-btn {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 6px;
    min-height: 32px;
    background-color: #161618;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.gate-tool-btn:hover, .gate-tool-btn.selected {
    background-color: var(--accent-zinc);
    color: #09090B;
    border-color: var(--accent-zinc);
}

/* Circuit Grid Workspace */
.circuit-workspace {
    background-color: #080809;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 16px;
    overflow-x: auto;
}

.circuit-grid {
    width: 100%;
}

.grid-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.grid-header, .grid-row {
    display: flex;
    gap: 4px;
}

.grid-cell {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    background-color: rgba(255, 255, 255, 0.01);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.15s ease;
}

.grid-cell:hover {
    background-color: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

.grid-cell.header-cell {
    background: transparent;
    border: none;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.grid-cell.time-cell, .grid-cell.qubit-label {
    background-color: #121214;
    border: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.wire-line {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: var(--border-subtle);
    transform: translateY(-50%);
    z-index: 0;
}

/* Placed Gate Element (Premium Glassmorphic Quantum Lab Aesthetic) */
.gate-element {
    position: relative;
    z-index: 2;
    background: rgba(28, 28, 30, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 3px solid var(--accent-green); /* Elegant neon category indicator */
    border-radius: 6px;
    width: 38px;
    height: 38px;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.05);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.gate-element:hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.08) translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4), 0 0 8px rgba(255, 255, 255, 0.1);
}

/* Category styling overrides based on gate class */
.gate-element.multi-qubit-gate {
    border-left-color: #007AFF; /* Electric control blue */
    text-shadow: 0 0 4px rgba(0, 122, 255, 0.2);
}

.gate-element.rotation-gate {
    border-left-color: var(--accent-orange); /* Rotation orange */
    text-shadow: 0 0 4px rgba(255, 159, 10, 0.2);
}

.gate-element[data-gate-type="M"] {
    border-left-color: #bf5af2; /* Measurement purple */
    text-shadow: 0 0 4px rgba(191, 90, 242, 0.2);
}

/* Connection Lines */
.control-dot {
    width: 10px;
    height: 10px;
    background-color: var(--accent-green);
    border-radius: 50%;
    position: absolute;
    z-index: 3;
    box-shadow: 0 0 8px var(--accent-green);
    animation: dotPulse 2s infinite ease-in-out;
}

@keyframes dotPulse {
    0%, 100% { transform: scale(1.0); box-shadow: 0 0 6px var(--accent-green); }
    50% { transform: scale(1.2); box-shadow: 0 0 12px var(--accent-green); }
}

/* Entanglement Warning Badge */
.entanglement-badge {
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(255, 69, 58, 0.08);
    border: 1px solid rgba(255, 69, 58, 0.2);
    border-radius: 6px;
    color: #FF453A;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.entanglement-badge .badge-icon {
    font-size: 0.8rem;
}

.entanglement-badge .purity-val {
    color: var(--text-muted);
    font-weight: 400;
    margin-left: auto;
}

/* Qubit Inspector Tab Segments */
.qubit-selector-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 4px;
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.qubit-selector-tabs .selector-label {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 8px;
}

.qubit-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.qubit-tab-btn.active {
    background: var(--accent-zinc);
    color: #09090B;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Premium Gate Edit Popover */
.gate-edit-popover {
    background: rgba(22, 22, 24, 0.85);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 14px;
    width: 200px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    font-family: var(--font-sans);
}

.popover-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 6px;
}

.popover-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.popover-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.popover-select, .popover-input {
    background: #09090B;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 4px 6px;
    outline: none;
    width: 80px;
    transition: border-color 0.2s ease;
}

.popover-select:focus, .popover-input:focus {
    border-color: var(--text-secondary);
}

.popover-desc {
    font-size: 0.68rem;
    color: var(--text-muted);
    line-height: 1.3;
    margin: 0;
}

.popover-footer {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 10px;
}

.popover-btn {
    flex: 1;
    border: none;
    border-radius: 4px;
    padding: 6px;
    font-size: 0.68rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: var(--font-mono);
    text-align: center;
}

.popover-btn.close-btn {
    background: var(--accent-zinc);
    color: #09090B;
}

.popover-btn.close-btn:hover {
    opacity: 0.9;
}

.popover-btn.delete-btn {
    background: rgba(255, 69, 58, 0.15);
    color: #FF453A;
    border: 1px solid rgba(255, 69, 58, 0.2);
}

.popover-btn.delete-btn:hover {
    background: rgba(255, 69, 58, 0.25);
}

/* Connection Overlay Styling */
.interactive-dot {
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.interactive-dot:hover {
    transform: scale(1.3);
}

.control-dot.cz-target {
    background-color: #f39c12;
}

.cnot-target-symbol {
    width: 22px;
    height: 22px;
    color: #ff6b6b;
    position: absolute;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cnot-target-symbol svg {
    width: 100%;
    height: 100%;
}

.swap-symbol {
    font-family: var(--font-mono);
    font-size: 1.3rem !important;
    font-weight: 300 !important;
    color: #4ecdc4;
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Reflection Controls Widget */
.reflection-controls {
    background-color: #080809;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 16px;
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reflection-info {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#reflection-step {
    color: var(--accent-green);
}

#reflection-gate {
    color: var(--text-muted);
}

.reflection-buttons {
    display: flex;
    gap: 8px;
}

/* Execution outputs */
.execution-output {
    background-color: #080809;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 16px;
    margin-top: 24px;
}

.execution-output h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.ket-output {
    display: flex;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--accent-green);
    margin-bottom: 16px;
    padding: 8px 12px;
    background-color: #121214;
    border-left: 2px solid var(--accent-green);
}

.ket-label {
    color: var(--text-muted);
    margin-right: 6px;
}

.output-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.output-item {
    display: flex;
    justify-content: space-between;
}

.output-item .label {
    color: var(--text-muted);
}

/* Tutorial panels & Modal dialogs */
.tutorial-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.tutorial-panel.visible {
    display: flex;
}

.tutorial-panel .modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 32px;
    width: 90%;
    max-width: 500px;
    /* Ensure modal scrolls on very small screens */
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#tutorial-content h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

#tutorial-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.6;
}

.tutorial-progress {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
}

.tutorial-nav {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

#close-tutorial {
    width: 100%;
}

/* Floating button */
.floating-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Footer styling — single canonical definition */
.social-links {
    display: flex;
    gap: 16px;
}

.social-icon {
    width: 16px;
    height: 16px;
    fill: var(--text-muted);
    transition: fill 0.2s ease;
}

.social-icon:hover {
    fill: var(--text-secondary);
}

/* ==========================================
   Responsive Breakpoints
   ========================================== */

/* --- Tablet / Narrow Desktop (≤ 1024px) --- */
@media (max-width: 1024px) {
    .visualization-controls-wrapper {
        display: flex;
        flex-direction: column;
        gap: 24px;
        width: 100%;
    }

    /* Flatten BOTH containers — all children become direct flex items
       of the wrapper so they can be freely ordered independently */
    .control-panel,
    .visualizer-circuit-section {
        display: contents;
    }

    /* "COHERENCE VISUALIZATION" label — stays glued above the sphere */
    .visualizer-circuit-section > .section-label {
        order: 1;
        width: 100%;
    }

    /* Bloch sphere — 1st: users see the visualization immediately */
    #visualization-container {
        order: 1;
        width: 100%;
        /* At single-column layout, square ratio looks better than 1.2:1 */
        aspect-ratio: 1 / 1;
    }

    /* Quantum State & Gates — 2nd: directly below the sphere so
       users can interact and watch the sphere update in real-time */
    .control-panel > .panel-section:nth-of-type(1) {
        order: 2;
        width: 100%;
    }

    /* Circuit Composer — 3rd: below the controls */
    .circuit-composer {
        order: 3;
        width: 100%;
    }

    /* Speech / Voice panel — 4th */
    .control-panel > .panel-section:nth-of-type(2) {
        order: 4;
        width: 100%;
    }

    /* Export panel — 5th */
    .control-panel > .panel-section:nth-of-type(3) {
        order: 5;
        width: 100%;
    }

    /* Gate toolbar: 9 cols is too many at tablet width — reduce to 6 */
    .gate-toolbar .gate-buttons {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* --- Mobile (≤ 768px) --- */
@media (max-width: 768px) {
    /* Container padding */
    .container {
        padding: 24px 16px;
        align-items: stretch; /* Stretch all child flex items to full width */
    }

    /* Header: center-align on mobile */
    header {
        margin-bottom: 32px;
        text-align: center;
    }

    /* Center the BLOQQER logo text */
    .text-logo {
        justify-content: center;
    }

    /* Main content full width */
    .main-content {
        width: 100%;
    }

    /* All panels take full width */
    .panel-section {
        padding: 16px;
        width: 100%;
    }

    /* Visualization container — square on mobile */
    #visualization-container {
        aspect-ratio: 1 / 1;
        min-height: 280px;
        width: 100%;
    }

    /* Gate buttons: 3 columns on mobile to prevent overflow */
    .gate-buttons {
        grid-template-columns: repeat(3, 1fr);
        width: 100%;
    }

    /* Circuit composer gate toolbar: fewer columns */
    .gate-toolbar .gate-buttons {
        grid-template-columns: repeat(5, 1fr);
    }

    /* iOS: prevent auto-zoom on input focus — Safari zooms on inputs < 16px */
    input[type="text"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px;
    }

    /* Update State & Center View buttons — full width */
    #update-state,
    #center-view,
    #clear-path,
    #apply-rotation,
    #voice-command-btn {
        width: 100%;
    }

    /* Circuit header: allow wrapping so controls don't overflow */
    .circuit-header {
        flex-wrap: wrap;
        gap: 12px;
    }

    .circuit-controls {
        flex-wrap: wrap;
        width: 100%;
        gap: 8px;
    }

    .circuit-controls button {
        flex: 1;
        min-width: 80px;
    }

    /* State display: smaller font, prevent content overflow */
    .state-display {
        font-size: 0.68rem;
        word-break: break-all;
    }

    /* State display rows: stack label and value */
    .state-display div {
        flex-wrap: wrap;
        gap: 4px;
    }

    /* Custom rotation section */
    .custom-gate {
        width: 100%;
    }

    /* Export buttons grid: 3 equal columns */
    .export-buttons {
        grid-template-columns: repeat(3, 1fr);
        width: 100%;
    }

    /* Path controls group: full width */
    .path-controls-group {
        width: 100%;
    }

    /* Toggle rows: keep label and switch aligned */
    .toggle-row {
        width: 100%;
        justify-content: space-between;
    }

    /* Reflection controls */
    .reflection-controls {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .reflection-buttons {
        display: flex;
        gap: 8px;
        width: 100%;
    }

    .reflection-buttons button {
        flex: 1;
    }

    /* Footer — perfectly centered */
    .site-footer {
        padding: 24px 16px;
    }

    .footer-content {
        align-items: center;
        text-align: center;
    }

    .footer-brand {
        justify-content: center;
        margin-bottom: 8px;
        width: 100%;
    }

    .production-credit {
        width: 100%;
        text-align: center;
    }

    .social-links {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 20px;
    }

    /* Floating tutorial button — smaller offset */
    .floating-btn {
        bottom: 16px;
        right: 16px;
    }
}

/* --- Small Mobile (≤ 480px) --- */
@media (max-width: 480px) {
    .container {
        padding: 16px 12px;
    }

    h1 {
        font-size: clamp(1.2rem, 6vw, 1.6rem);
    }

    h2 {
        font-size: 1.05rem;
        flex-wrap: wrap;
    }

    /* Gate buttons: 3 columns */
    .gate-buttons {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    /* Export buttons: single column on very small screens */
    .export-buttons {
        grid-template-columns: 1fr;
    }

    /* Qubit selector tabs: scroll horizontally */
    .qubit-selector-tabs {
        overflow-x: auto;
        width: 100%;
        max-width: 100%;
    }

    /* Visualization container */
    #visualization-container {
        min-height: 240px;
        aspect-ratio: 1 / 1;
    }

    /* Slider group: ensure label doesn't overflow */
    .slider-group label {
        flex-wrap: wrap;
        gap: 4px;
    }

    /* State display: mono text may need breaking */
    .state-display {
        font-size: 0.65rem;
        padding: 12px;
    }

    /* Footer padding */
    .site-footer {
        padding: 20px 12px;
    }

    .social-icon {
        width: 18px;
        height: 18px;
    }
}

/* --- Ultra-small screens (≤ 320px — e.g. iPhone SE 1st gen) --- */
@media (max-width: 320px) {
    .container {
        padding: 12px 10px;
    }

    /* iOS: prevent text input zoom — ensure 16px minimum */
    input[type="text"],
    input[type="range"],
    select,
    textarea {
        font-size: 16px !important;
    }

    h1 {
        font-size: 1.1rem;
    }

    .text-logo {
        font-size: 0.9rem;
        letter-spacing: 0.15em;
    }

    /* Gate buttons: 3 columns, tighter gap */
    .gate-buttons {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }

    .gate-btn {
        font-size: 0.75rem;
        padding: 6px 4px;
        min-height: 32px;
    }

    /* Panel padding: minimum breathing room */
    .panel-section {
        padding: 12px;
    }

    .circuit-composer {
        padding: 12px;
    }

    /* Visualization: minimum height */
    #visualization-container {
        min-height: 200px;
    }

    /* Tutorial modal: smaller padding */
    .tutorial-panel .modal-content {
        padding: 20px;
        width: 95%;
    }

    /* Export buttons: stack vertically */
    .export-buttons {
        grid-template-columns: 1fr;
    }

    /* Footer: tighter */
    .site-footer {
        padding: 16px 10px;
    }

    .social-links {
        gap: 14px;
    }
}

/* ==========================================
   WebGL Fallback & Export Modal Design System
   ========================================== */

/* Export Dialog / Panel Container positioned directly below Telemetry Export */
.export-modal {
    display: none;
    width: 100%;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 20px;
    margin-top: 16px;
    box-sizing: border-box;
}

.export-modal.visible {
    display: block;
}

.export-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.export-preview img {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    border: 1px solid var(--border-subtle);
    background: #000000;
}

.export-preview p {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    margin: 8px 0 0 0;
    word-break: break-all;
}

.export-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    margin-top: 4px;
}

.export-actions button {
    flex: 1;
    min-height: 38px;
    font-size: 0.8rem;
    font-weight: 500;
}

.export-actions button:first-child {
    background-color: var(--accent-zinc);
    color: #09090B;
    border: none;
    font-weight: 600;
}

.export-actions button:first-child:hover {
    background-color: var(--accent-zinc-hover);
}

/* WebGL Fallback Container styling */
.webgl-fallback-container {
    width: 100%;
    height: 100%;
    min-height: 350px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #050506;
    border-radius: 4px;
    padding: 24px;
    box-sizing: border-box;
    position: relative;
}

.fallback-telemetry {
    position: absolute;
    top: 12px;
    left: 12px;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    color: var(--accent-orange);
    animation: fallbackPulse 2s infinite;
}

@keyframes fallbackPulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

.fallback-svg {
    width: 80%;
    max-width: 250px;
    height: auto;
    margin: 12px 0;
}

.svg-sphere-circle {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 1.5;
}

.svg-equator {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 1;
    stroke-dasharray: 4, 3;
}

.svg-axis-dashed {
    stroke: rgba(255, 255, 255, 0.12);
    stroke-width: 1;
    stroke-dasharray: 3, 4;
}

.svg-text {
    font-family: var(--font-mono);
    font-size: 8px;
    fill: var(--text-muted);
    text-anchor: middle;
    dominant-baseline: middle;
}

.svg-text.font-z {
    fill: var(--accent-zinc);
    font-weight: 500;
}

.svg-text.font-x {
    fill: var(--accent-orange);
}

.svg-state-vector {
    stroke: var(--accent-green);
    stroke-width: 2.5;
    stroke-linecap: round;
}

.svg-state-dot {
    fill: var(--accent-green);
    filter: drop-shadow(0 0 4px var(--accent-green));
}

.fallback-readout {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    background-color: #0b0b0c;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 12px 18px;
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.readout-row {
    display: flex;
    justify-content: space-between;
}

.readout-row span {
    color: var(--accent-green);
    font-weight: 500;
}

/* ==========================================
   Measurement & Probability Readouts
   ========================================== */

.grid-cell.measurement-header {
    width: 140px;
    min-width: 140px;
    font-weight: 600;
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 12px;
}

.grid-cell.measurement-readout {
    width: 140px;
    min-width: 140px;
    height: 44px;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 12px;
}

.mini-prob-chart {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.mini-prob-chart.inactive {
    opacity: 0.25;
}

.prob-bar-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.prob-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    min-width: 14px;
}

.prob-progress-bg {
    flex: 1;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.prob-progress-bar {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.prob-progress-bar.bar-zero {
    background: linear-gradient(90deg, #30D158, #34C759);
    box-shadow: 0 0 8px rgba(48, 209, 88, 0.4);
}

.prob-progress-bar.bar-one {
    background: linear-gradient(90deg, #0A84FF, #007AFF);
    box-shadow: 0 0 8px rgba(10, 132, 255, 0.4);
}

.prob-percent {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-secondary);
    min-width: 28px;
    text-align: right;
}

.mini-prob-chart:not(.inactive) .prob-percent {
    color: var(--text-primary);
    font-weight: 500;
}

.gate-element[data-gate-type="M"] {
    background-color: #7f3cdb !important;
    border-color: #bf5af2 !important;
    color: #ffffff !important;
    border-radius: 50% !important; /* Circular Dial look */
    font-size: 0.75rem !important;
    font-weight: bold !important;
    box-shadow: 0 0 10px rgba(191, 90, 242, 0.4);
}

/* ==========================================
   Lightweight Coherence Loader & Mobile Touch Action Fixes
   ========================================== */
#visualization-container {
    touch-action: none;
}

#visualization-container canvas {
    touch-action: none;
}

.bloch-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #050506;
    z-index: 10;
    gap: 16px;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.loader-spinner {
    width: 32px;
    height: 32px;
    border: 2px solid rgba(52, 199, 89, 0.15);
    border-top-color: var(--accent-green);
    border-radius: 50%;
    animation: loaderRotate 0.8s linear infinite;
    box-shadow: 0 0 10px rgba(52, 199, 89, 0.15);
}

.loader-text {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.15em;
    animation: loaderPulse 1.5s ease-in-out infinite;
}

@keyframes loaderRotate {
    to { transform: rotate(360deg); }
}

@keyframes loaderPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ==========================================
   CAD Viewport Background Design (Qollision Grid Style)
   ========================================== */
.cad-viewport-bg {
    position: fixed;
    /* Extend slightly beyond viewport to cover any white borders on zoom-out */
    top: -5px;
    left: -5px;
    width: calc(100vw + 10px);
    height: calc(100vh + 10px);
    z-index: -2; /* Render below everything including container */
    pointer-events: none;
    user-select: none;
    overflow: hidden;
    background-color: rgba(11, 11, 12, 0.96); /* Dark semi-transparent background */
    transform: translate3d(0, 0, 0); /* Force GPU compositing promotion */
    will-change: transform;
}

.blueprint-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Layer 1: 24px Minor grid lines (rgba 255,255,255,0.02) */
    /* Layer 2: 120px Major axis lines (rgba 255,255,255,0.04) */
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(rgba(255, 255, 255, 0.04) 1.5px, transparent 1.5px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1.5px, transparent 1.5px);
    background-size: 
        24px 24px, 
        24px 24px, 
        120px 120px, 
        120px 120px;
    pointer-events: none;
    transform: translate3d(0, 0, 0); /* Hardware accelerated compositing */
    will-change: transform;
}

.blueprint-svg-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.bg-watermark {
    position: absolute;
    pointer-events: none;
    user-select: none;
    /* Invert logo to make it white and add a soft orange glow */
    filter: invert(1) drop-shadow(0 0 10px rgba(255, 153, 51, 0.12));
    transform: translate3d(0, 0, 0); /* GPU acceleration */
    will-change: transform;
    z-index: -1;
}

.logo-large {
    left: 4vw;
    top: 25vh;
    width: clamp(120px, 12vw, 180px);
    height: auto;
    opacity: 0.010;
}

.logo-medium {
    right: 4vw;
    top: 55vh;
    width: clamp(90px, 9vw, 130px);
    height: auto;
    opacity: 0.008;
}

.logo-small {
    left: 8vw;
    top: 75vh;
    width: clamp(60px, 6vw, 90px);
    height: auto;
    opacity: 0.006;
}

/* Perfect alignment & responsive control to ensure absolutely no overlaps on smaller views */
@media (max-width: 1200px) {
    /* As the container collapses to 100% width on laptops/tablets, fade watermarks further to avoid clutter */
    .bg-watermark {
        opacity: 0.003;
    }
}

@media (max-width: 900px) {
    /* On mobile, completely hide to prevent messy overlaps under the single stacked column */
    .bg-watermark {
        display: none;
    }
}

.rotate-slow {
    transform-origin: 800px 500px;
    animation: rotateBlueprint 180s linear infinite;
}

@keyframes rotateBlueprint {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==========================================
   Footer Brand and Logo — Canonical Styles
   ========================================== */
.site-footer {
    border-top: 1px solid var(--border-subtle);
    padding: 40px 24px;
    background-color: rgba(11, 11, 12, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    margin-top: auto;
    /* Prevent white gaps at footer edges */
    width: 100%;
    box-sizing: border-box;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.footer-brand {
    margin-bottom: 8px;
    display: flex;
    justify-content: center;
}

.footer-logo-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.footer-logo-img {
    height: 22px;
    width: auto;
    filter: invert(1) drop-shadow(0 0 4px rgba(255, 153, 51, 0.25));
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.footer-logo-link:hover .footer-logo-img {
    transform: scale(1.08) rotate(3deg);
    filter: invert(1) drop-shadow(0 0 10px rgba(255, 153, 51, 0.8));
}

.footer-logo-text {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    color: #ff9933;
    text-transform: uppercase;
}

.footer-logo-text .footer-logo-sub {
    color: var(--text-primary);
    font-weight: 500;
}

.footer-brand-link {
    color: #ff9933 !important;
    font-weight: 600;
    text-shadow: 0 0 8px rgba(255, 153, 51, 0.25);
    text-decoration: none;
    transition: all 0.3s ease;
}

.footer-brand-link:hover {
    color: var(--text-primary) !important;
    text-shadow: none;
}

.production-credit {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.hidden {
    display: none !important;
}

/* Side-by-side Spheres Layout */
.side-by-side-spheres {
    display: flex !important;
    flex-direction: row;
    gap: 16px;
    background: transparent !important;
    border: none !important;
    aspect-ratio: auto !important;
    min-height: auto !important;
}

.sphere-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #000000;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.sphere-title {
    text-align: center;
    padding: 8px;
    font-family: "JetBrains Mono", monospace;
    font-size: 11px;
    font-weight: bold;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.02);
    letter-spacing: 0.1em;
}

.sphere-container {
    width: 100%;
    aspect-ratio: 1.2 / 1;
    min-height: 300px;
    position: relative;
}

/* Target Qubit Selector Group */
.target-qubit-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 4px 0;
}

.target-qubit-selector .selector-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    font-family: "JetBrains Mono", monospace;
}

.qubit-radio-group {
    display: flex;
    gap: 8px;
}

.target-qubit-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    padding: 6px 16px;
    border-radius: 4px;
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.target-qubit-btn.active {
    background: var(--accent-green) !important;
    border-color: var(--accent-green) !important;
    color: #000000 !important;
    text-shadow: 0 0 4px rgba(0,0,0,0.2);
}

/* Presets Action Row & Button styling */
.state-action-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.presets-btn {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--border-subtle) !important;
    color: var(--text-primary) !important;
}

.presets-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: var(--text-muted) !important;
}

/* Presets Sidebar styling */
.presets-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 340px;
    height: 100%;
    background: rgba(10, 10, 11, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-subtle);
    z-index: 10000;
    transform: translate3d(-100%, 0, 0);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 15px 0 40px rgba(0, 0, 0, 0.6);
}

.presets-sidebar.open {
    transform: translate3d(0, 0, 0);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header h3 {
    margin: 0;
    font-family: "JetBrains Mono", monospace;
    font-size: 15px;
    font-weight: bold;
    color: var(--text-primary);
    letter-spacing: 0.05em;
}

.close-sidebar-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

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

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.preset-save-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.preset-save-section input {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: "Inter", sans-serif;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.preset-save-section input:focus {
    border-color: var(--text-muted);
}

.save-preset-btn {
    background: var(--accent-orange);
    border: none;
    border-radius: 4px;
    padding: 10px 14px;
    color: #000000;
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
}

.save-preset-btn:hover {
    opacity: 0.9;
}

.presets-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.preset-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s, border-color 0.2s;
}

.preset-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--text-muted);
}

.preset-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    flex: 1;
}

.preset-name {
    font-weight: bold;
    font-size: 13px;
    color: var(--text-primary);
}

.preset-desc {
    font-size: 10px;
    color: var(--text-muted);
    font-family: "JetBrains Mono", monospace;
}

.delete-preset-btn {
    background: none;
    border: none;
    color: rgba(255, 69, 58, 0.5);
    font-size: 16px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 4px;
    transition: all 0.2s;
}

.delete-preset-btn:hover {
    color: rgb(255, 69, 58);
    background: rgba(255, 69, 58, 0.1);
}

/* Responsive side-by-side visualizer on smaller screens */
@media (max-width: 992px) {
    .side-by-side-spheres {
        flex-direction: column;
    }
}