/* =====================================================
   3D Graph Spectral Analysis - Tabbed Sidebar Design
   ===================================================== */

:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-card: #1a1a2e;
    --bg-hover: #252545;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #666680;
    --accent-blue: #4a9eff;
    --accent-green: #4CAF50;
    --accent-purple: #9c27b0;
    --accent-orange: #ff9800;
    --accent-red: #f44336;
    --accent-pink: #e91e63;
    --border-color: #333355;
    --border-radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    font-size: 13px;
}

#container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* =====================================================
   SIDEBAR
   ===================================================== */

#controls-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: 300px;
    min-width: 220px;
    max-width: 500px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: none; /* Disable transitions during resize */
}

/* Resize Handle */
#sidebar-resize-handle {
    position: absolute;
    left: -4px;
    top: 0;
    width: 8px;
    height: 100%;
    cursor: ew-resize;
    background: transparent;
    z-index: 101;
    transition: background 0.2s ease;
}

#sidebar-resize-handle:hover,
#sidebar-resize-handle.dragging {
    background: var(--accent-blue);
}

#sidebar-resize-handle::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 40px;
    background: var(--border-color);
    border-radius: 1px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

#sidebar-resize-handle:hover::after {
    opacity: 1;
}

/* Prevent text selection during resize */
body.resizing {
    cursor: ew-resize !important;
    user-select: none;
}

body.resizing * {
    cursor: ew-resize !important;
}

/* Sidebar Tab Navigation */
.sidebar-tabs {
    display: flex;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-tab {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    padding: 12px 4px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.sidebar-tab:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}

.sidebar-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
    background: transparent;
}

.tab-icon {
    font-size: 18px;
    line-height: 1;
}

.tab-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Sidebar Tab Content */
.sidebar-tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
}

.sidebar-tab-content.active {
    display: block;
}

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

.sidebar-tab-content::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.sidebar-tab-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* =====================================================
   CONTROL GROUPS
   ===================================================== */

.control-group {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 12px;
    margin-bottom: 12px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group h4 {
    margin: 0 0 10px 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-group h5 {
    margin: 12px 0 6px 0;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* =====================================================
   FORM ELEMENTS
   ===================================================== */

.input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.input-row:last-child {
    margin-bottom: 0;
}

.input-row label {
    font-size: 11px;
    color: var(--text-secondary);
    min-width: 40px;
    flex-shrink: 0;
}

#template-params .input-row label {
    min-width: auto;
}

#template-params .input-row input[type="number"] {
    width: 50px;
    flex: 0 0 auto;
}

.input-row input[type="number"],
.input-row input[type="text"] {
    flex: 1;
    min-width: 0;
}

.input-row input[type="range"] {
    flex: 1;
    min-width: 60px;
}

.input-row span {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 35px;
}

input[type="number"],
input[type="text"],
select {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 12px;
    width: 100%;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

input[type="range"] {
    accent-color: var(--accent-blue);
    height: 4px;
}

select {
    cursor: pointer;
}

.small-select {
    width: 50px !important;
    padding: 4px 6px;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 0;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-blue);
    flex-shrink: 0;
}

/* Teaching mode toggle */
.teaching-toggle {
    background: linear-gradient(135deg, rgba(79, 209, 197, 0.1), rgba(248, 113, 113, 0.1));
    border: 1px dashed var(--accent-purple);
    border-radius: 6px;
    padding: 8px 12px;
    margin-top: 8px;
    font-size: 11px;
}

.teaching-toggle:hover {
    background: linear-gradient(135deg, rgba(79, 209, 197, 0.2), rgba(248, 113, 113, 0.2));
}

/* Sub-options panel */
.sub-options {
    background: var(--bg-primary);
    border-radius: 6px;
    padding: 10px;
    margin-top: 8px;
}

/* Face Options Panel */
#face-options {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    margin-top: 10px;
}

#face-options.hidden {
    display: none !important;
}

#face-hint.hidden {
    display: none !important;
}

#face-options .input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

#face-options .input-row label {
    min-width: 55px;
    font-size: 12px;
    color: var(--text-secondary);
}

#face-options .input-row input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: var(--bg-hover);
    border-radius: 3px;
    cursor: pointer;
}

#face-options .input-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-blue);
    border-radius: 50%;
    cursor: pointer;
}

#face-options .input-row span {
    min-width: 35px;
    font-size: 11px;
    color: var(--text-primary);
    text-align: right;
}

#face-options button {
    width: 100%;
    margin-top: 0;
}

#face-hint {
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(74, 158, 255, 0.1);
    border-radius: 4px;
    border-left: 3px solid var(--accent-blue);
}

/* =====================================================
   BUTTONS
   ===================================================== */

button {
    background: linear-gradient(135deg, var(--accent-blue), #3a7bd5);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    margin-top: 8px;
}

button:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

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

button:first-child {
    margin-top: 0;
}

button.success {
    background: linear-gradient(135deg, var(--accent-green), #388e3c);
}

button.danger {
    background: linear-gradient(135deg, var(--accent-red), #c62828);
}

button.info {
    background: linear-gradient(135deg, #17a2b8, #138496);
}

button.secondary {
    background: linear-gradient(135deg, #6c757d, #545b62);
    font-size: 11px;
}

button.purple {
    background: linear-gradient(135deg, var(--accent-purple), #7b1fa2);
}

button.small {
    padding: 6px 12px;
    font-size: 11px;
    width: auto;
}

.button-row {
    display: flex;
    gap: 8px;
}

.button-row button {
    flex: 1;
    margin-top: 0;
}

/* Mode Buttons */
.mode-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-bottom: 10px;
}

.mode-btn {
    background: var(--bg-primary);
    color: var(--text-secondary);
    padding: 8px 4px;
    font-size: 10px;
    border-radius: 4px;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.mode-btn:hover {
    background: var(--bg-hover);
    transform: none;
}

.mode-btn.active {
    background: var(--accent-blue);
    color: white;
}

.mode-btn[data-mode="add"].active {
    background: var(--accent-green);
}

.mode-btn[data-mode="delete"].active {
    background: var(--accent-red);
}

.mode-btn[data-mode="drag"].active {
    background: var(--accent-purple);
}

/* =====================================================
   PROJECTION BUTTONS
   ===================================================== */

.projection-buttons {
    display: flex;
    gap: 4px;
    justify-content: space-between;
}

.projection-btn {
    flex: 1;
    padding: 6px 8px !important;
    font-size: 11px !important;
    font-weight: 600;
    background: var(--surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.projection-btn:hover {
    background: var(--surface-hover);
    border-color: var(--accent-cyan);
    color: var(--text-primary);
}

.projection-btn.active {
    background: linear-gradient(135deg, var(--accent-cyan), #0097a7);
    border-color: var(--accent-cyan);
    color: white;
}

/* =====================================================
   SNAP GRID CONTROLS
   ===================================================== */

#snap-grid-controls {
    background: linear-gradient(135deg, rgba(0, 188, 212, 0.1), rgba(0, 150, 136, 0.05));
    border: 1px solid rgba(0, 188, 212, 0.3);
    border-radius: 8px;
}

#snap-grid-controls h4 {
    color: var(--accent-cyan);
}

#snap-grid-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

#snap-grid-controls input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-cyan);
}

/* =====================================================
   MODE INDICATOR
   ===================================================== */

.mode-indicator {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mode-view { background: linear-gradient(135deg, #2196F3, #1976D2); color: white; }
.mode-add { background: linear-gradient(135deg, var(--accent-green), #388e3c); color: white; }
.mode-delete { background: linear-gradient(135deg, var(--accent-red), #c62828); color: white; }
.mode-drag { background: linear-gradient(135deg, var(--accent-purple), #7b1fa2); color: white; }

/* =====================================================
   HINTS & BADGES
   ===================================================== */

.hint {
    font-size: 10px;
    color: var(--text-muted);
    margin: 4px 0;
    line-height: 1.4;
}

.badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.success {
    background: var(--accent-green);
    color: white;
}

/* =====================================================
   STATS GRID
   ===================================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.stat-item {
    background: var(--bg-primary);
    border-radius: 6px;
    padding: 8px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 2px;
}

.stat-value {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-green);
}

.stat-value.blue { color: var(--accent-blue); }
.stat-value.orange { color: var(--accent-orange); }
.stat-value.pink { color: var(--accent-pink); }
.stat-value.green { color: var(--accent-green); }

/* =====================================================
   SIMULATE TAB - REORGANIZED LAYOUT
   ===================================================== */

/* Section containers */
.sim-section {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

.sim-section.sim-header {
    background: linear-gradient(135deg, var(--bg-secondary), rgba(59, 130, 246, 0.1));
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.sim-section h4 {
    margin: 0 0 4px 0;
    font-size: 14px;
    color: var(--text-primary);
}

.sim-section .hint {
    margin: 0 0 12px 0;
    font-size: 11px;
    color: var(--text-muted);
}

/* Section headers with numbers */
.sim-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sim-section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    color: white;
}

.sim-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-grow: 1;
}

/* Main button row */
.sim-button-row {
    display: flex;
    gap: 8px;
}

.sim-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sim-btn.start {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.sim-btn.start:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
}

.sim-btn.stop {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.sim-btn.stop:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.sim-btn.reset {
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    flex: 0.5;
}

.sim-btn.reset:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

/* Visualization Mode Selector */
.sim-mode-selector {
    display: flex;
    gap: 4px;
    background: var(--bg-primary);
    border-radius: 6px;
    padding: 4px;
}

.sim-mode-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.sim-mode-option input[type="radio"] {
    display: none;
}

.sim-mode-label {
    display: block;
    width: 100%;
    padding: 8px 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.sim-mode-option input[type="radio"]:checked + .sim-mode-label {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: white;
    font-weight: 600;
}

.sim-mode-option:hover .sim-mode-label {
    color: var(--text-primary);
}

.sim-mode-description {
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid var(--accent-blue);
    border-radius: 0 4px 4px 0;
    font-size: 10px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.sim-mode-description b {
    color: var(--text-primary);
    font-weight: 600;
}

.sim-mode-description br {
    display: block;
    margin: 2px 0;
}

/* Animation Controls - Slider rows */
.sim-slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.sim-slider-row:last-child {
    margin-bottom: 0;
}

.sim-slider-row label {
    font-size: 11px;
    color: var(--text-secondary);
    width: 80px;
    flex-shrink: 0;
}

.sim-slider-row input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-primary);
    border-radius: 2px;
    outline: none;
}

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

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

.sim-slider-value {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--accent-blue);
    width: 35px;
    text-align: right;
    flex-shrink: 0;
}

/* Simulation Status Grid */
.sim-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.sim-stat-item {
    background: var(--bg-primary);
    border-radius: 6px;
    padding: 10px 6px;
    text-align: center;
}

.sim-stat-value {
    display: block;
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font-mono);
    margin-bottom: 2px;
}

.sim-stat-value.blue { color: var(--accent-blue); }
.sim-stat-value.orange { color: var(--accent-orange); }
.sim-stat-value.pink { color: var(--accent-pink); }
.sim-stat-value.green { color: var(--accent-green); }

.sim-stat-label {
    display: block;
    font-size: 9px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}

.sim-stat-desc {
    display: block;
    font-size: 8px;
    color: var(--text-muted);
}

/* Energy section header with glow toggle */
.energy-glow-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: var(--text-muted);
    cursor: pointer;
    margin-left: auto;
}

.energy-glow-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent-green);
}

.energy-glow-toggle span {
    font-weight: 500;
}

/* Phase Diagram Button */
.sim-btn.phase-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    font-size: 12px;
}

.sim-btn.phase-btn:hover {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.phase-btn-icon {
    font-size: 14px;
}

/* Phase diagram controls */
.sim-phase-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sim-phase-select {
    flex: 1;
    padding: 6px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 11px;
}

.sim-node-selector {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sim-node-selector label {
    font-size: 11px;
    color: var(--text-secondary);
    width: 45px;
    flex-shrink: 0;
}

.sim-node-select {
    width: 50px;
    padding: 5px 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 11px;
    text-align: center;
}

.sim-vs-label {
    font-size: 10px;
    color: var(--text-muted);
    padding: 0 2px;
}

.sim-phase-buttons {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.sim-phase-buttons .sim-btn.small {
    flex: 0 0 auto;
    padding: 8px 12px;
    font-size: 11px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.sim-phase-buttons .sim-btn.small:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.sim-phase-buttons .sim-btn.phase-btn {
    flex: 1;
}

.sim-mode-description.phase-hint {
    margin-top: 8px;
    background: rgba(139, 92, 246, 0.1);
    border-left-color: var(--accent-purple);
}

/* Advanced Settings (Collapsible) */
.sim-advanced-details {
    margin: 0;
}

.sim-advanced-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 0;
    list-style: none;
    user-select: none;
}

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

.sim-advanced-arrow {
    margin-left: auto;
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.sim-advanced-details[open] .sim-advanced-arrow {
    transform: rotate(180deg);
}

.sim-advanced-content {
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 8px;
}

.sim-select-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.sim-select-row label {
    font-size: 11px;
    color: var(--text-secondary);
    width: 70px;
    flex-shrink: 0;
}

.sim-select-row select {
    flex: 1;
    padding: 6px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 11px;
}

.sim-integrator-info {
    margin-top: 10px;
    padding: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
}

.sim-integrator-item {
    font-size: 9px;
    color: var(--text-muted);
    margin-bottom: 4px;
    line-height: 1.3;
}

.sim-integrator-item:last-child {
    margin-bottom: 0;
}

.sim-integrator-item strong {
    color: var(--text-secondary);
}

/* Footer hint */
.sim-footer-hint {
    text-align: center;
    padding: 8px;
    margin-top: 4px;
}

.sim-footer-hint p {
    margin: 0;
    font-size: 10px;
    color: var(--text-muted);
}

.sim-footer-hint strong {
    color: var(--accent-purple);
}

/* =====================================================
   ENERGY DETAIL PANEL
   ===================================================== */

/* When energy panel is a sim-section, override the background */
.sim-section#energy-detail-panel {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(6, 182, 212, 0.05));
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Legacy support for standalone energy panel */
.energy-detail-panel:not(.sim-section) {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(6, 182, 212, 0.05));
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
}

.energy-detail-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.energy-icon {
    font-size: 14px;
}

#energy-panel-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-grow: 1;
}

.energy-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: var(--text-muted);
    cursor: pointer;
}

.energy-toggle input[type="checkbox"] {
    width: 12px;
    height: 12px;
}

.energy-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.energy-bar-row.total {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.energy-bar-label {
    font-size: 10px;
    font-weight: 500;
    width: 75px;
    flex-shrink: 0;
}

.energy-bar-label.kinetic { color: #f97316; }
.energy-bar-label.potential { color: #06b6d4; }
.energy-bar-label.total { color: #a78bfa; }
.energy-bar-label.state { color: #10b981; }

.energy-bar-track {
    flex-grow: 1;
    height: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.energy-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.1s ease-out;
}

.energy-bar-fill.kinetic {
    background: linear-gradient(90deg, #f97316, #fb923c);
}

.energy-bar-fill.potential {
    background: linear-gradient(90deg, #06b6d4, #22d3ee);
}

.energy-bar-fill.total {
    background: linear-gradient(90deg, #8b5cf6, #a78bfa);
}

.energy-bar-fill.state {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.energy-bar-value {
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    width: 45px;
    text-align: right;
    flex-shrink: 0;
}

.energy-conservation {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 8px;
    background: rgba(16, 185, 129, 0.15);
    border-radius: 4px;
    font-size: 10px;
}

.energy-conservation .conservation-icon {
    color: #10b981;
}

.energy-conservation.warning {
    background: rgba(245, 158, 11, 0.15);
}

.energy-conservation.warning .conservation-icon {
    color: #f59e0b;
}

.energy-conservation.state-only {
    background: rgba(16, 185, 129, 0.1);
}

#energy-conservation-text,
#energy-state-conservation {
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.energy-warning {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 8px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 4px;
    font-size: 10px;
}

.energy-warning .warning-icon {
    font-size: 12px;
}

.energy-warning .warning-text {
    color: #fbbf24;
}

.energy-hint {
    margin-top: 8px;
    padding: 8px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 4px;
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.4;
}

.energy-hint .hint-action {
    color: var(--text-secondary);
}

/* Non-realizable state styling */
#energy-nonrealizable-view .energy-bar-label {
    color: #10b981;
}

/* =====================================================
   PROGRESS BAR
   ===================================================== */

#finder-progress {
    background: var(--bg-primary);
    border-radius: 6px;
    padding: 10px;
    margin-top: 8px;
}

#finder-status {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.progress-bar {
    background: var(--border-color);
    height: 4px;
    border-radius: 2px;
    overflow: hidden;
}

#finder-progress-bar {
    background: var(--accent-blue);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

#finder-results {
    margin-top: 8px;
}

#finder-summary {
    font-size: 11px;
    color: var(--accent-green);
    margin-bottom: 8px;
}

#selected-graph-info {
    background: var(--bg-primary);
    border-radius: 6px;
    padding: 10px;
    margin: 8px 0;
    font-size: 11px;
}

#graph-family { color: var(--accent-green); font-weight: 600; }
#graph-edges { color: var(--text-secondary); margin-top: 4px; }
#graph-eigenvalues { color: var(--accent-blue); margin-top: 4px; }

/* =====================================================
   ANALYZE TAB - SPECTRAL DISPLAY
   ===================================================== */

.graph-type-box {
    background: linear-gradient(135deg, #2e7d32, #1b5e20);
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.graph-type-box span {
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.formula-display {
    background: var(--bg-primary);
    border-radius: 6px;
    padding: 10px;
    border-left: 3px solid var(--accent-green);
    font-family: 'Cambria Math', 'Times New Roman', serif;
    font-size: 13px;
    color: #81c784;
    line-height: 1.6;
    overflow-x: auto;
}

.formula-display .hint {
    font-family: 'Segoe UI', sans-serif;
    font-style: italic;
}

.polynomial-display {
    background: var(--bg-primary);
    border-radius: 6px;
    padding: 10px;
    font-family: 'Cambria Math', serif;
    font-size: 12px;
    color: #ffcc80;
    overflow-x: auto;
    white-space: nowrap;
}

/* Collapsible sections */
.collapsible {
    margin-top: 8px;
}

.collapsible summary {
    cursor: pointer;
    font-size: 11px;
    color: var(--text-secondary);
    padding: 6px 0;
    outline: none;
    user-select: none;
}

.collapsible summary:hover {
    color: var(--text-primary);
}

.collapsible summary h4 {
    margin: 0;
    display: inline;
    font-size: 11px;
}

.collapsible[open] summary {
    margin-bottom: 8px;
}

/* Eigenvalues list */
.eigenvalues-list {
    max-height: 150px;
    overflow-y: auto;
}

.eigenvalue-item {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    margin-bottom: 3px;
    font-family: 'Consolas', monospace;
    font-size: 11px;
}

.real-part { color: var(--accent-green); }
.imag-part { color: var(--accent-blue); }

/* Matrix display */
.matrix-scroll {
    overflow-x: auto;
    margin-top: 8px;
}

.matrix-table {
    border-collapse: collapse;
    font-size: 10px;
    font-family: 'Consolas', monospace;
}

.matrix-table th,
.matrix-table td {
    padding: 3px 6px;
    text-align: center;
    border: 1px solid var(--border-color);
    min-width: 24px;
}

.matrix-table th {
    background: var(--bg-card);
    color: var(--text-muted);
}

.matrix-table td {
    background: var(--bg-primary);
}

.matrix-table td.positive { color: var(--accent-green); font-weight: 600; }
.matrix-table td.negative { color: var(--accent-red); font-weight: 600; }
.matrix-table td.zero { color: var(--text-muted); }

/* Graph properties */
#graph-properties {
    margin-top: 8px;
}

.property-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    margin-bottom: 3px;
    font-size: 11px;
}

.property-label { color: var(--text-secondary); }
.property-value { font-weight: 600; color: var(--accent-green); }
.property-value.no { color: var(--accent-red); }

/* =====================================================
   PHASE CANVAS
   ===================================================== */

#phase-canvas {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 200px;
    aspect-ratio: 1/1;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-top: 8px;
}

#phase-axis-labels {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: center;
}

/* =====================================================
   BOUNDS TAB (Zeid-Rosenberg)
   ===================================================== */

#zr-complex-plane {
    width: 100%;
    max-width: 280px;
    height: 220px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin: 8px 0;
    display: block;
}

.bounds-display {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    margin-top: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    line-height: 1.6;
}

.bounds-display .bound-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid var(--border-color);
}

.bounds-display .bound-item:last-child {
    border-bottom: none;
}

.bounds-display .bound-label {
    color: var(--text-secondary);
}

.bounds-display .bound-value {
    color: var(--accent-blue);
    font-weight: 600;
}

.bounds-display .bound-value.stable {
    color: var(--accent-green);
}

.bounds-display .bound-value.unstable {
    color: var(--accent-red);
}

.stability-display {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    margin-top: 8px;
}

.stability-display .condition {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.stability-display .condition-icon {
    font-size: 14px;
}

.stability-display .condition-icon.pass {
    color: var(--accent-green);
}

.stability-display .condition-icon.fail {
    color: var(--accent-red);
}

.stability-display .condition-icon.warn {
    color: var(--accent-orange);
}

.comparison-display {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px;
    margin: 8px 0;
    font-size: 11px;
}

.comparison-display .tightness-bar {
    height: 8px;
    background: var(--bg-hover);
    border-radius: 4px;
    margin: 4px 0;
    overflow: hidden;
}

.comparison-display .tightness-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-blue));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.canvas-legend {
    display: flex;
    gap: 12px;
    justify-content: center;
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.legend-item .dot.stable {
    background: rgba(76, 175, 80, 0.3);
    border: 1px solid var(--accent-green);
}

.legend-item .dot.bound {
    background: transparent;
    border: 1px dashed var(--accent-orange);
}

.legend-item .dot.eigenvalue {
    background: var(--accent-blue);
}

.reference-table {
    margin-top: 8px;
    overflow-x: auto;
}

.formula-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.formula-table th,
.formula-table td {
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.formula-table th {
    background: var(--bg-hover);
    color: var(--text-primary);
    font-weight: 600;
}

.formula-table td {
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-family: 'Consolas', 'Monaco', monospace;
}

.formula-table tr:hover td {
    background: var(--bg-hover);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

/* =====================================================
   MOBILE STYLES
   ===================================================== */

/* Mobile toggle button */
#mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
}

#mobile-menu-toggle:hover {
    background: var(--bg-hover);
}

#mobile-menu-toggle:active {
    transform: scale(0.95);
}

#mobile-menu-toggle .toggle-icon {
    line-height: 1;
}

@media (max-width: 768px) {
    /* Show toggle button on mobile */
    #mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Sidebar collapses off-screen by default on mobile */
    #controls-panel {
        position: fixed;
        right: -320px;
        width: 300px;
        max-width: 85vw;
        transition: right 0.3s ease;
        z-index: 1000;
    }
    
    /* Show sidebar when active */
    #controls-panel.mobile-visible {
        right: 0;
    }
    
    /* Overlay when menu is open */
    #controls-panel.mobile-visible::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 300px;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }
    
    /* Update toggle icon when open */
    #mobile-menu-toggle.menu-open .toggle-icon::before {
        content: '✕';
    }
    
    .tab-label {
        display: none;
    }
    
    .tab-icon {
        font-size: 20px;
    }
    
    /* Make container full width when sidebar hidden */
    #container {
        width: 100vw !important;
    }
    
    /* Smaller fonts on mobile */
    .control-group h4 {
        font-size: 13px;
    }
    
    .hint {
        font-size: 10px;
    }
    
    button, select, input {
        font-size: 13px;
    }
    
    /* Keyboard shortcuts hint */
    .keyboard-hints {
        display: none;
    }
}

/* Formula box styling */
.formula-box {
    background: var(--bg-primary);
    border-radius: 6px;
    padding: 12px 15px;
    border-left: 4px solid var(--accent-green);
    margin: 8px 0;
}

.formula-box .formula {
    font-family: 'Cambria Math', 'Times New Roman', serif;
    font-size: 14px;
    color: #81c784;
    line-height: 1.6;
}

.formula-box.detected {
    border-left-color: #4CAF50;
    background: linear-gradient(90deg, rgba(76, 175, 80, 0.1) 0%, var(--bg-primary) 100%);
}

.formula-box.detected .formula {
    color: #a5d6a7;
}

.formula-box.unknown {
    border-left-color: #ff9800;
}

.formula-box.unknown .formula {
    color: #ffcc80;
}

.formula-box.factored {
    border-left-color: #4fc3f7;
    background: linear-gradient(90deg, rgba(79, 195, 247, 0.1) 0%, var(--bg-primary) 100%);
}

.formula-box.factored .formula {
    color: #4fc3f7;
}

.formula-box .formula-note {
    font-family: 'Cambria Math', 'Times New Roman', serif;
    font-size: 12px;
    color: #90a4ae;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.factorization {
    font-family: 'Cambria Math', 'Times New Roman', serif;
}

/* =====================================================
   EIGENVALUE PLOT (New in v17)
   ===================================================== */

#eigenvalue-canvas {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 160px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-top: 8px;
}

#eigenvalue-info-display {
    margin-top: 8px;
}

.eigenvalue-stats {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-secondary);
    padding: 6px;
    background: var(--bg-primary);
    border-radius: 4px;
    margin-bottom: 6px;
}

.eigenvalue-stats span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.eigenvalue-stats span span {
    color: var(--accent-blue);
    font-weight: 600;
    font-family: 'Consolas', monospace;
}

.eigenvalue-info {
    margin: 8px 0;
}

.stability-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    width: 100%;
}

.stability-badge.stable {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.3), rgba(76, 175, 80, 0.1));
    color: #81c784;
    border: 1px solid var(--accent-green);
}

.stability-badge.unstable {
    background: linear-gradient(135deg, rgba(244, 67, 54, 0.3), rgba(244, 67, 54, 0.1));
    color: #ef9a9a;
    border: 1px solid var(--accent-red);
}

.stability-badge.marginally-stable {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.3), rgba(255, 152, 0, 0.1));
    color: #ffcc80;
    border: 1px solid var(--accent-orange);
}

/* =====================================================
   HINT BOXES (Mode explanations)
   ===================================================== */

.hint-box {
    background: var(--bg-primary);
    border-left: 2px solid var(--accent-blue);
    padding: 6px 10px;
    margin: 6px 0;
    border-radius: 0 4px 4px 0;
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.4;
}

.hint-box span {
    display: block;
}

/* Animation mode explanations */
#animation-mode-explanation,
#phase-mode-explanation {
    transition: background 0.2s ease;
}

#animation-mode-explanation:hover,
#phase-mode-explanation:hover {
    background: var(--bg-hover);
}

/* Power mode detailed hint - scrollable and compact */
.power-mode-hint {
    max-height: 145px;
    overflow-y: auto;
    overflow-x: hidden;
    font-size: 9px;
    line-height: 1.35;
    padding: 8px 10px;
}

.power-mode-hint::-webkit-scrollbar {
    width: 4px;
}

.power-mode-hint::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.power-mode-hint::-webkit-scrollbar-thumb {
    background: var(--accent-purple);
    border-radius: 2px;
}

.power-mode-hint span {
    line-height: 1.35;
}

.power-mode-hint strong {
    color: var(--accent-purple);
    font-size: 10px;
    display: block;
    margin-bottom: 2px;
}

.power-mode-hint b {
    color: var(--text-primary);
    font-size: 9px;
}

.power-mode-hint em {
    display: block;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dashed var(--border-color);
    color: var(--accent-blue);
    font-style: normal;
    font-size: 8px;
}

/* =====================================================
   ALPHA/BETA SLIDERS
   ===================================================== */

.input-row input[type="range"]#phase-alpha,
.input-row input[type="range"]#phase-beta,
.input-row input[type="range"]#zr-alpha-slider,
.input-row input[type="range"]#zr-beta-slider {
    background: linear-gradient(to right, var(--accent-blue), var(--accent-purple));
    border-radius: 2px;
}

.input-row span#phase-alpha-label,
.input-row span#phase-beta-label,
.input-row span#zr-alpha-label,
.input-row span#zr-beta-label {
    min-width: 30px;
    text-align: right;
    font-family: 'Consolas', monospace;
    color: var(--accent-blue);
}

/* =====================================================
   GRAPH TYPE BOX - UNKNOWN STATE
   ===================================================== */

.graph-type-box.unknown {
    background: linear-gradient(135deg, #616161, #424242);
}

/* =====================================================
   FORMULA BOX VARIANTS
   ===================================================== */

.formula-box.eigenvalue {
    border-left-color: var(--accent-blue);
}

.formula-box.eigenvalue .formula {
    color: #90caf9;
}

/* =====================================================
   ENHANCED VISUALIZATION POPUP
   ===================================================== */

.enhanced-popup {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 900px;
    max-width: 95vw;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    z-index: 1000;
    overflow: hidden;
    resize: both;
    min-width: 600px;
    min-height: 400px;
}

.enhanced-popup.minimized {
    height: 40px !important;
    min-height: 40px !important;
    resize: none;
}

.enhanced-popup.minimized .popup-content {
    display: none;
}

.enhanced-popup.maximized {
    top: 10px !important;
    left: 10px !important;
    right: 10px !important;
    bottom: 10px !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    transform: none !important;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: linear-gradient(135deg, #1a1a3a, #0a0a2a);
    border-bottom: 1px solid var(--border-color);
    cursor: move;
}

.popup-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--accent-blue);
}

.popup-controls {
    display: flex;
    gap: 5px;
}

.popup-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.popup-btn:hover {
    background: var(--accent-blue);
    color: white;
}

.popup-btn:last-child:hover {
    background: var(--accent-red);
}

.popup-content {
    padding: 15px;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
}

.viz-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.viz-panel {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    flex: 1;
    min-width: 200px;
}

.panel-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #222;
}

.viz-panel canvas {
    width: 100%;
    height: auto;
    display: block;
    background: #0a0a1a;
    border-radius: 4px;
}

.panel-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-secondary);
}

.panel-note {
    margin-top: 6px;
    padding: 4px 8px;
    background: rgba(74, 158, 255, 0.1);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-line {
    width: 16px;
    height: 2px;
    border-radius: 1px;
}

.legend-line.cyan {
    background: #00ffff;
}

.legend-line.orange {
    background: #ff9800;
}

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

.legend-dot.green {
    background: #4CAF50;
    border: 1px dashed rgba(76, 175, 80, 0.5);
}

.legend-dot.blue {
    background: #64b5f6;
    border: 1px dashed rgba(100, 181, 246, 0.5);
}

/* Energy Display */
.energy-display {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
}

.energy-label {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 50px;
}

.energy-bar-container {
    flex: 1;
    height: 24px;
    background: #1a1a2a;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.energy-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    transition: width 0.1s;
}

.energy-value {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    font-family: 'Consolas', monospace;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.energy-history {
    height: 40px;
    background: #0a0a1a;
    border-radius: 4px;
    margin-top: 8px;
}

/* Controls Row */
.viz-controls-row {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px 15px;
    background: var(--bg-card);
    border-radius: 6px;
    font-size: 12px;
    flex-wrap: wrap;
}

.viz-controls-row label {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-secondary);
    cursor: pointer;
}

.viz-controls-row input[type="checkbox"] {
    accent-color: var(--accent-blue);
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.zoom-controls input[type="range"] {
    width: 100px;
}

#viz-zoom-label {
    min-width: 40px;
    text-align: right;
    font-family: 'Consolas', monospace;
    color: var(--accent-blue);
}

/* Resize Handle */
.popup-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 50%, var(--border-color) 50%);
    border-radius: 0 0 12px 0;
}

/* =====================================================
   ANALYZE TAB - Complex Plane Visualization
   ===================================================== */

#complex-plane-container {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: 8px;
    margin-top: 8px;
}

#analyze-complex-plane {
    width: 100%;
    height: auto;
    border-radius: 4px;
    background: #050510;
}

.eigenvalue-info {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 10px;
    color: var(--text-muted);
    font-family: 'Consolas', monospace;
}

.eigenvalue-info span {
    padding: 2px 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
}

#symmetric-range {
    color: var(--accent-blue);
}

#spectral-radius {
    color: var(--accent-orange);
}

.eigenvalue-tooltip {
    position: absolute;
    display: none;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid var(--accent-blue);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 10px;
    font-family: 'Consolas', monospace;
    color: var(--text-primary);
    pointer-events: none;
    z-index: 100;
    white-space: nowrap;
}

.eigenvalue-tooltip.visible {
    display: block;
}

.checkbox-label.small {
    font-size: 11px;
    margin-bottom: 4px;
}

/* =====================================================
   BUILD ADVANCED TAB
   ===================================================== */

.product-builder {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 12px;
    margin-top: 8px;
}

.product-operator {
    text-align: center;
    margin: 10px 0;
    padding: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
}

.product-operator select {
    font-size: 14px;
    font-weight: bold;
    text-align: center;
}

.preview-box {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
    margin: 10px 0;
    font-size: 11px;
}

.preview-box span {
    display: block;
    margin: 3px 0;
}

.preview-title {
    color: var(--text-muted);
    font-size: 10px;
    text-transform: uppercase;
}

#product-result-name {
    color: var(--accent-blue);
    font-weight: bold;
    font-size: 13px;
}

#product-result-formula {
    color: var(--accent-green);
    font-family: 'Consolas', monospace;
}

.family-params {
    background: var(--bg-secondary);
    border-radius: 4px;
    padding: 10px;
    margin: 10px 0;
}

.param-info {
    background: var(--bg-primary);
    border-radius: 4px;
    padding: 8px;
    margin-top: 8px;
    font-size: 11px;
}

.param-info span {
    display: block;
    margin: 2px 0;
}

.param-info span:first-child {
    color: var(--accent-blue);
}

.param-info span:last-child {
    color: var(--accent-green);
    font-family: 'Consolas', monospace;
    font-size: 10px;
}

/* =====================================================
   COPY BUTTONS
   ===================================================== */

.copy-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    margin-left: 8px;
    vertical-align: middle;
}

.copy-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.copy-btn.small {
    font-size: 10px;
    padding: 1px 4px;
}

.copy-btn.copied {
    background: var(--accent-green);
    border-color: var(--accent-green);
    color: white;
}

/* Keyboard shortcuts hint */
.keyboard-hint {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    z-index: 100;
    pointer-events: none;
}

.keyboard-hint kbd {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 1px 5px;
    margin: 0 2px;
    font-family: 'Consolas', monospace;
}

/* =====================================================
   LIBRARY TAB STYLES
   ===================================================== */

/* Library Statistics */
.library-stats {
    display: flex;
    gap: 15px;
    margin-bottom: 5px;
}

.stat-mini {
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.15), rgba(74, 158, 255, 0.05));
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 10px;
    padding: 12px 18px;
    text-align: center;
    flex: 1;
    transition: all 0.3s ease;
}

.stat-mini:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.2);
}

.stat-mini-value {
    display: block;
    font-size: 1.8em;
    font-weight: 700;
    color: var(--accent-blue);
    line-height: 1.1;
}

.stat-mini-label {
    display: block;
    font-size: 0.75em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* Filter Row */
.filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.filter-row label {
    font-size: 0.85em;
    color: var(--text-secondary);
}

.filter-row select {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
}

.sort-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.sort-row label {
    font-size: 0.85em;
    color: var(--text-secondary);
}

.sort-row select {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
}

/* Library Table Container */
.library-table-container {
    padding: 0 !important;
    background: transparent !important;
}

#library-table-wrapper {
    max-height: 350px;
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

/* Library Table */
.library-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85em;
}

.library-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(180deg, var(--bg-secondary), var(--bg-card));
}

.library-table th {
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--accent-blue);
    border-bottom: 2px solid var(--accent-blue);
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.library-table th.col-select {
    width: 30px;
    text-align: center;
}

.library-table th.col-n,
.library-table th.col-edges {
    width: 40px;
    text-align: center;
}

.library-table th.col-actions {
    width: 80px;
    text-align: center;
}

.library-table tbody tr {
    border-bottom: 1px solid rgba(51, 51, 85, 0.5);
    transition: all 0.2s ease;
}

.library-table tbody tr:hover {
    background: linear-gradient(90deg, rgba(74, 158, 255, 0.1), transparent);
}

.library-table tbody tr.selected {
    background: linear-gradient(90deg, rgba(74, 158, 255, 0.2), rgba(74, 158, 255, 0.05));
    border-left: 3px solid var(--accent-blue);
}

.library-table td {
    padding: 10px 8px;
    vertical-align: middle;
}

.library-table td.col-select,
.library-table td.col-n,
.library-table td.col-edges {
    text-align: center;
}

.library-table td.col-actions {
    text-align: center;
}

/* Graph Name Cell */
.graph-name-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.graph-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95em;
}

.graph-family {
    font-size: 0.8em;
    color: var(--text-muted);
    font-style: italic;
}

/* Table Action Buttons */
.table-action-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin: 0 2px;
}

.table-action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    transform: scale(1.1);
}

.table-action-btn.load-btn:hover {
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.table-action-btn.delete-btn:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.table-action-btn.export-btn:hover {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
}

/* Custom Checkbox Styling */
.library-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent-blue);
}

/* Empty State */
.library-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3em;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-title {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.empty-hint {
    font-size: 0.9em;
    line-height: 1.5;
}

/* Library Detail Modal/Panel */
.library-detail-panel {
    position: fixed;
    bottom: 0;
    right: 300px;
    width: 400px;
    max-height: 60vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    z-index: 150;
    display: none;
    overflow: hidden;
}

.library-detail-panel.active {
    display: block;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.detail-title {
    font-weight: 600;
    color: var(--accent-blue);
}

.detail-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
}

.detail-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.detail-content {
    padding: 15px;
    overflow-y: auto;
    max-height: calc(60vh - 60px);
}

.detail-section {
    margin-bottom: 15px;
}

.detail-section h5 {
    color: var(--text-muted);
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.detail-eigenvalues {
    font-family: 'Consolas', 'Monaco', monospace;
    background: rgba(74, 158, 255, 0.1);
    padding: 10px;
    border-radius: 6px;
    font-size: 0.9em;
    line-height: 1.6;
    max-height: 150px;
    overflow-y: auto;
}

.detail-edges {
    font-family: monospace;
    font-size: 0.85em;
    word-break: break-all;
    background: var(--bg-card);
    padding: 10px;
    border-radius: 6px;
    max-height: 100px;
    overflow-y: auto;
}

/* Graph Preview Canvas */
.graph-preview-canvas {
    width: 100%;
    height: 150px;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

/* Notification Toast */
.library-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--accent-blue);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    display: none;
    animation: fadeInUp 0.3s ease;
}

.library-toast.success {
    border-color: var(--accent-green);
}

.library-toast.error {
    border-color: var(--accent-red);
}

.library-toast.show {
    display: block;
}

@keyframes fadeInUp {
    from {
        transform: translateX(-50%) translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* Eigenvalue Pills */
.eigenvalue-pill {
    display: inline-block;
    background: rgba(74, 158, 255, 0.15);
    border: 1px solid rgba(74, 158, 255, 0.3);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    margin: 2px;
    font-family: 'Consolas', monospace;
}

/* Row highlight animation */
.library-table tbody tr.just-added {
    animation: highlightRow 1.5s ease;
}

@keyframes highlightRow {
    0% {
        background: rgba(76, 175, 80, 0.4);
    }
    100% {
        background: transparent;
    }
}

/* Button row styling for library */
.button-row {
    display: flex;
    gap: 8px;
}

.button-row button.small {
    font-size: 0.85em;
    padding: 6px 12px;
}

/* Purple button for library actions */
button.purple {
    background: linear-gradient(135deg, #9c27b0, #7b1fa2);
    color: white;
    border: none;
}

button.purple:hover {
    background: linear-gradient(135deg, #ab47bc, #9c27b0);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(156, 39, 176, 0.4);
}

/* Info button styling */
button.info.small {
    background: linear-gradient(135deg, var(--accent-blue), #357abd);
}

button.info.small:hover {
    background: linear-gradient(135deg, #5aadff, var(--accent-blue));
}

/* Scrollbar styling for library table */
#library-table-wrapper::-webkit-scrollbar {
    width: 8px;
}

#library-table-wrapper::-webkit-scrollbar-track {
    background: var(--bg-card);
    border-radius: 4px;
}

#library-table-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

#library-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

/* Responsive adjustments for library */
@media (max-width: 768px) {
    .library-detail-panel {
        right: 0;
        width: 100%;
        border-radius: 12px 12px 0 0;
    }
    
    .library-stats {
        flex-direction: column;
        gap: 10px;
    }
    
    .stat-mini {
        padding: 10px 15px;
    }
    
    .stat-mini-value {
        font-size: 1.5em;
    }
}

/* =====================================================
   GRAPH UNIVERSE VIEW TOGGLE STYLES
   ===================================================== */

/* View Toggle Buttons */
.view-toggle-container {
    display: flex;
    gap: 4px;
    margin: 12px 0;
    background: var(--bg-main);
    padding: 4px;
    border-radius: 8px;
}

.view-toggle-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

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

.view-toggle-btn.active {
    background: linear-gradient(135deg, var(--accent-blue), #3a7bd5);
    color: white;
    box-shadow: 0 2px 8px rgba(74, 158, 255, 0.3);
}

.view-toggle-btn .view-icon {
    font-size: 14px;
}

/* Universe Container */
#universe-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    background: #020205;
}

/* Universe HUD */
#universe-hud {
    position: absolute;
    bottom: 20px;
    left: 20px;
    color: #0f0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px 20px;
    border: 1px solid #0f0;
    border-radius: 8px;
    pointer-events: auto;
    z-index: 100;
    text-shadow: 0 0 5px #0f0;
    min-width: 200px;
}

#universe-hud .hud-drag-handle {
    cursor: move;
    padding: 2px 0 8px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(0, 255, 0, 0.3);
    font-size: 11px;
    color: #0a0;
    user-select: none;
}

#universe-hud.flying {
    border-color: #0ff;
    color: #0ff;
    text-shadow: 0 0 5px #0ff;
}

#universe-hud .hud-row {
    margin-bottom: 6px;
}

#universe-hud .hud-hint {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 255, 0, 0.3);
    font-size: 11px;
    color: #888;
    text-shadow: none;
}

/* Universe Info Panel */
#universe-info-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 300px;
    background: rgba(10, 10, 26, 0.95);
    border: 1px solid var(--accent-blue);
    border-radius: 12px;
    overflow: hidden;
    z-index: 200;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

#universe-info-panel .info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: linear-gradient(135deg, rgba(74, 158, 255, 0.2), rgba(74, 158, 255, 0.05));
    border-bottom: 1px solid var(--border-color);
    cursor: move;
    user-select: none;
}

#universe-info-panel .info-header span {
    font-weight: 600;
    color: var(--accent-blue);
    font-size: 14px;
}

#universe-info-panel #info-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}

#universe-info-panel #info-close-btn:hover {
    color: var(--danger-red);
}

#universe-info-panel .info-body {
    padding: 15px;
}

#universe-info-panel #info-description {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 12px;
}

#universe-info-panel #info-metrics {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding: 8px;
    background: rgba(74, 158, 255, 0.1);
    border-radius: 6px;
}

#universe-info-panel #info-metrics .metric {
    display: block;
    font-family: 'Courier New', monospace;
    color: var(--accent-green);
    margin: 2px 0;
}

#universe-info-panel #info-stats {
    font-size: 12px;
    color: var(--text-muted);
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

#universe-info-panel .eigenvalues {
    font-family: 'Courier New', monospace;
    color: var(--accent-green);
    font-size: 11px;
}

#universe-info-panel .info-actions {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

#universe-info-panel .load-build-btn {
    width: 100%;
    padding: 8px 12px;
    background: linear-gradient(135deg, #2a5a8a 0%, #1a3a5a 100%);
    border: 1px solid var(--accent-blue);
    border-radius: 6px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

#universe-info-panel .load-build-btn:hover {
    background: linear-gradient(135deg, #3a7aba 0%, #2a5a8a 100%);
    border-color: #4facfe;
    box-shadow: 0 2px 10px rgba(79, 172, 254, 0.3);
    transform: translateY(-1px);
}

#universe-info-panel .load-build-btn:active {
    transform: translateY(0);
}

#universe-info-panel .toggle-expand-btn {
    width: 100%;
    padding: 6px 10px;
    margin-top: 6px;
    background: linear-gradient(135deg, #5a2a8a 0%, #3a1a5a 100%);
    border: 1px solid #9966ff;
    border-radius: 6px;
    color: white;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

#universe-info-panel .toggle-expand-btn:hover {
    background: linear-gradient(135deg, #7a4aba 0%, #5a3a8a 100%);
    border-color: #bb99ff;
    box-shadow: 0 2px 10px rgba(153, 102, 255, 0.3);
}

/* Universe Axis Control Panel */
#universe-axis-panel {
    position: absolute;
    bottom: 100px;
    right: 320px;
    width: 200px;
    background: rgba(10, 10, 26, 0.95);
    border: 1px solid var(--accent-blue);
    border-radius: 8px;
    padding: 12px;
    z-index: 200;
    font-size: 12px;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#universe-axis-panel .axis-panel-header {
    font-weight: 600;
    color: var(--accent-blue);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    cursor: move;
    user-select: none;
}

#universe-axis-panel .axis-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
}

#universe-axis-panel .axis-row label {
    width: 20px;
    font-weight: 600;
    color: var(--text-secondary);
}

#universe-axis-panel .axis-row:nth-child(3) label { color: #ff6666; }
#universe-axis-panel .axis-row:nth-child(4) label { color: #66ff66; }
#universe-axis-panel .axis-row:nth-child(5) label { color: #6666ff; }

#universe-axis-panel .preset-row label { color: #ffaa44; }

#universe-axis-panel .axis-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}

#universe-axis-panel select {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 4px 6px;
    font-size: 11px;
    cursor: pointer;
}

#universe-axis-panel select:hover {
    border-color: var(--accent-blue);
}

#universe-axis-panel select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 5px rgba(74, 158, 255, 0.3);
}

#universe-axis-panel #axis-apply-btn {
    width: 100%;
    margin-top: 8px;
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--accent-blue), #3a7ecc);
    border: none;
    border-radius: 4px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

#universe-axis-panel #axis-apply-btn:hover {
    background: linear-gradient(135deg, #5aaeFF, var(--accent-blue));
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(74, 158, 255, 0.4);
}

#universe-axis-panel #axis-apply-btn:active {
    transform: translateY(0);
}

#universe-axis-panel .axis-desc {
    background: rgba(0, 100, 150, 0.3);
    border: 1px solid rgba(0, 200, 255, 0.3);
    border-radius: 4px;
    padding: 6px 8px;
    margin: 8px 0;
    font-size: 10px;
    color: #aaddff;
    line-height: 1.4;
}

#universe-axis-panel .axis-desc strong {
    color: #00ffff;
}

#universe-axis-panel .axis-help {
    text-align: center;
    margin-top: 6px;
    opacity: 0.6;
}

#universe-axis-panel .axis-help small {
    font-size: 9px;
    color: #88aacc;
}

/* Universe Navigation Controls */
#universe-nav-controls {
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.05), rgba(0, 255, 255, 0.02));
    border: 1px solid rgba(0, 255, 136, 0.2);
}

#universe-nav-controls h4 {
    color: #0f8;
}

#universe-galaxy-jump {
    width: 100%;
}

/* =====================================================
   TEMPLATE PREVIEW PANEL
   ===================================================== */

.template-preview {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 10px;
    margin: 10px 0;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

#template-preview-canvas {
    background: var(--bg-primary);
    border-radius: 4px;
    flex-shrink: 0;
}

#template-preview-info {
    flex: 1;
    min-width: 0;
}

#preview-name {
    font-weight: 600;
    color: var(--accent-blue);
    font-size: 12px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#preview-stats {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

#preview-stats span {
    display: inline-block;
    margin-right: 8px;
}

#preview-formula {
    font-size: 10px;
    color: var(--accent-green);
    font-family: 'Courier New', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Hide preview when custom selected */
.template-preview.hidden {
    display: none;
}

/* =====================================================
   EIGENMODE ANIMATION UI
   ===================================================== */

/* Hint text above eigenvalue list */
.eigenmode-hint {
    font-size: 11px;
    color: #4af;
    margin-bottom: 6px;
    font-style: italic;
    padding: 4px 8px;
    background: rgba(68, 170, 255, 0.1);
    border-radius: 4px;
}

/* Inline hint in summary */
.eigenmode-play-hint {
    font-size: 10px;
    color: #4af;
    font-style: italic;
    margin-left: 6px;
    opacity: 0.8;
}

/* Make eigenvalues clickable */
.eigenvalue-clickable {
    cursor: pointer;
    padding: 4px 8px;
    margin: 2px 0;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-left: 3px solid transparent;
}

.eigenvalue-clickable:hover {
    background: rgba(100, 200, 255, 0.25);
    border-left-color: #4af;
    transform: translateX(3px);
}

.eigenvalue-clickable:hover .eigenmode-icon {
    opacity: 1;
    color: #4af;
}

/* Play icon for eigenmode animation */
.eigenmode-icon {
    font-size: 12px;
    opacity: 0.4;
    color: #4af;
    transition: all 0.2s ease;
    margin-left: 8px;
}

/* Active/selected eigenvalue */
.eigenvalue-active {
    background: rgba(100, 255, 150, 0.3) !important;
    border-left: 3px solid #4f8;
}

.eigenvalue-active .eigenmode-icon {
    opacity: 1;
    color: #4f8;
    animation: pulse-icon 1s ease-in-out infinite;
}

@keyframes pulse-icon {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* Eigenmode info display in dynamics panel */
.eigenmode-info {
    background: rgba(80, 200, 120, 0.15);
    border: 1px solid rgba(80, 200, 120, 0.4);
    border-radius: 4px;
    padding: 8px;
    margin-top: 8px;
    font-size: 11px;
}

.eigenmode-info .mode-formula {
    font-family: 'Courier New', monospace;
    color: #8f8;
    font-weight: bold;
}

.eigenmode-info .mode-period {
    color: #aaa;
    margin-left: 10px;
}

/* Standing wave indicator */
.standing-wave-indicator {
    display: inline-block;
    width: 40px;
    height: 12px;
    background: linear-gradient(90deg, 
        rgba(255,100,100,0.8) 0%, 
        rgba(100,100,255,0.8) 25%, 
        rgba(255,100,100,0.8) 50%, 
        rgba(100,100,255,0.8) 75%, 
        rgba(255,100,100,0.8) 100%);
    border-radius: 2px;
    margin-left: 8px;
    animation: wave-shift 2s linear infinite;
}

@keyframes wave-shift {
    0% { background-position: 0 0; }
    100% { background-position: 40px 0; }
}

/* =====================================================
   PHYSICS ENGINE PANEL
   ===================================================== */

/* Section Layout - Clear INPUT → OUTPUT flow */
.physics-input-section,
.physics-output-section,
.physics-simulation-section {
    margin-bottom: 12px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.physics-input-section {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(59, 130, 246, 0.05));
    border-color: rgba(139, 92, 246, 0.2);
}

.physics-output-section {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), rgba(6, 182, 212, 0.05));
    border-color: rgba(16, 185, 129, 0.15);
}

.physics-simulation-section {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.05), rgba(245, 158, 11, 0.05));
    border-color: rgba(251, 191, 36, 0.15);
}

.physics-section-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.physics-input-section .physics-section-label {
    color: #A78BFA;
}

.physics-output-section .physics-section-label {
    color: #6EE7B7;
}

.physics-simulation-section .physics-section-label {
    color: #FCD34D;
}

/* Audit button row */
.physics-audit-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.physics-audit-row .physics-btn {
    flex: 1;
}

.physics-auto-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: var(--text-muted);
    cursor: pointer;
}

.physics-auto-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
}

/* Violations count in dims grid */
.physics-dim-value.violation-count {
    color: #FCA5A5;
    font-weight: 700;
}

.physics-dim-value.violation-count.zero {
    color: #6EE7B7;
}

/* Status badge next to title */
.physics-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: bold;
    text-transform: uppercase;
    margin-left: 8px;
    vertical-align: middle;
}

.physics-badge.physical {
    background: #10b981;
    color: white;
}

.physics-badge.non-physical {
    background: #f97316;
    color: white;
}

/* Status card with indicator dot */
.physics-status-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    margin-bottom: 12px;
}

.physics-status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #666;
    flex-shrink: 0;
}

.physics-status-dot.physical {
    background: #10b981;
    box-shadow: 0 0 10px #10b981;
}

.physics-status-dot.non-physical {
    background: #f97316;
    box-shadow: 0 0 10px #f97316;
    animation: physics-pulse 1.5s infinite;
}

@keyframes physics-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#physics-status-text {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Dimensions grid */
.physics-dims-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.physics-dim-item {
    background: rgba(0, 0, 0, 0.25);
    padding: 8px;
    border-radius: 6px;
    text-align: center;
}

.physics-dim-label {
    display: block;
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.physics-dim-value {
    display: block;
    font-size: 16px;
    font-weight: bold;
    color: #4FD1C5;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
}

/* Energy section */
.physics-energy-section {
    background: rgba(0, 0, 0, 0.25);
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 12px;
}

.physics-energy-title {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.physics-energy-bar {
    display: flex;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

.physics-bar-kinetic {
    background: linear-gradient(90deg, #F87171, #FB923C);
    transition: width 0.3s ease;
}

.physics-bar-potential {
    background: linear-gradient(90deg, #4FD1C5, #38BDF8);
    transition: width 0.3s ease;
}

.physics-energy-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    margin-bottom: 4px;
}

.physics-kinetic-label {
    color: #F87171;
}

.physics-potential-label {
    color: #4FD1C5;
}

.physics-energy-total {
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'Consolas', monospace;
}

.physics-conservation {
    color: #10b981;
    margin-left: 6px;
}

.physics-conservation.warning {
    color: #f97316;
}

/* Violations panel */
.physics-violations {
    background: rgba(248, 113, 113, 0.15);
    border: 1px solid rgba(248, 113, 113, 0.3);
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 12px;
}

.physics-violations-header {
    font-size: 11px;
    font-weight: 600;
    color: #F87171;
    margin-bottom: 6px;
}

.physics-violations-list {
    margin: 0;
    padding-left: 18px;
    font-size: 10px;
    color: #FCA5A5;
}

.physics-violations-list li {
    margin-bottom: 3px;
}

/* Predicted Frequencies section */
.physics-frequencies {
    background: rgba(79, 209, 197, 0.15);
    border: 1px solid rgba(79, 209, 197, 0.3);
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 12px;
}

.frequencies-header {
    font-size: 11px;
    font-weight: 600;
    color: #4FD1C5;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.frequencies-icon {
    font-size: 14px;
}

.frequencies-formula {
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 10px;
    border-radius: 4px;
    margin-bottom: 10px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 11px;
    color: #81E6D9;
}

.formula-text {
    overflow-x: auto;
    white-space: nowrap;
}

.frequencies-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
}

.frequencies-table th {
    text-align: left;
    padding: 4px 6px;
    background: rgba(0, 0, 0, 0.3);
    color: #4FD1C5;
    font-weight: 600;
    border-bottom: 1px solid rgba(79, 209, 197, 0.3);
}

.frequencies-table td {
    padding: 4px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-family: 'JetBrains Mono', 'Consolas', monospace;
}

.frequencies-table tr:hover {
    background: rgba(79, 209, 197, 0.1);
}

.frequencies-table tr.zero-mode {
    color: #94A3B8;
}

.discriminant-info {
    margin-top: 10px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    font-size: 10px;
    color: #A7F3D0;
}

.discriminant-info strong {
    color: #4FD1C5;
    font-size: 12px;
}

/* Divergence section */
.physics-divergence-section {
    background: rgba(0, 0, 0, 0.25);
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 12px;
}

.physics-divergence-title {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.physics-divergence-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.physics-div-cell {
    width: 28px;
    height: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
}

.physics-div-cell-label {
    font-size: 7px;
    opacity: 0.7;
}

.physics-div-cell-value {
    font-size: 11px;
    font-weight: bold;
}

.physics-div-cell.positive {
    background: rgba(248, 113, 113, 0.3);
    color: #F87171;
}

.physics-div-cell.negative {
    background: rgba(79, 209, 197, 0.3);
    color: #4FD1C5;
}

.physics-div-cell.zero {
    background: rgba(148, 163, 184, 0.2);
    color: #94A3B8;
}

/* Action buttons */
.physics-actions {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.physics-btn {
    flex: 1;
    padding: 8px 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.physics-btn.audit {
    background: linear-gradient(135deg, #3B82F6, #1D4ED8);
    color: white;
}

.physics-btn.audit:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(59, 130, 246, 0.4);
}

.physics-btn.discover {
    background: linear-gradient(135deg, #8B5CF6, #6D28D9);
    color: white;
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 10px;
}

.physics-btn.discover:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(139, 92, 246, 0.4);
}

.physics-btn.rectify {
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
}

.physics-btn.rectify:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(16, 185, 129, 0.4);
}

.physics-btn.rectify:disabled {
    background: #374151;
    color: #6B7280;
    cursor: not-allowed;
    transform: none;
}

.physics-btn.matrix {
    background: linear-gradient(135deg, #8B5CF6, #6D28D9);
    color: white;
    flex: 0 0 auto;
    padding: 8px 12px;
}

.physics-btn.matrix:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(139, 92, 246, 0.4);
}

/* Options */
.physics-options {
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.physics-option-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
}

.physics-option-label input {
    accent-color: #4FD1C5;
}

/* Matrix display panel */
.physics-matrix-panel {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-top: 12px;
    overflow: hidden;
}

.physics-matrix-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-card);
    font-size: 11px;
    font-weight: 600;
}

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

.physics-close-btn:hover {
    color: #F87171;
}

.physics-matrix-content {
    padding: 10px;
    margin: 0;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 9px;
    line-height: 1.4;
    color: #4FD1C5;
    overflow-x: auto;
    white-space: pre;
    max-height: 200px;
    overflow-y: auto;
}

/* B-Matrix Section */
.physics-bmatrix-section {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    margin-bottom: 12px;
    overflow: hidden;
}

.physics-bmatrix-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: rgba(139, 92, 246, 0.2);
    font-size: 10px;
    color: #A78BFA;
}

.physics-toggle-btn {
    background: #8B5CF6;
    color: white;
    border: none;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 9px;
    cursor: pointer;
    transition: background 0.2s;
}

.physics-toggle-btn:hover {
    background: #7C3AED;
}

.physics-bmatrix-container {
    padding: 12px;
    max-height: 350px;
    overflow: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    margin-top: 8px;
}

.physics-bmatrix-content {
    font-family: 'JetBrains Mono', 'Consolas', 'Courier New', monospace;
    font-size: 11px;
    line-height: 1.4;
    color: #E2E8F0;
    margin: 0;
    white-space: pre;
    tab-size: 4;
}

/* Column Analysis */
.physics-column-analysis {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    margin-bottom: 12px;
    padding: 10px;
}

.physics-column-header {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.physics-column-header .violation-count {
    color: #FCA5A5;
    font-weight: 600;
    font-size: 9px;
    padding: 2px 6px;
    background: rgba(239, 68, 68, 0.2);
    border-radius: 10px;
    text-transform: none;
    letter-spacing: 0;
}

.physics-column-header .all-valid {
    color: #6EE7B7;
    font-weight: 600;
    font-size: 9px;
    padding: 2px 6px;
    background: rgba(16, 185, 129, 0.2);
    border-radius: 10px;
    text-transform: none;
    letter-spacing: 0;
}

.physics-column-list {
    max-height: 200px;
    overflow-y: auto;
}

/* New column item layout */
.physics-column-item {
    display: flex;
    flex-direction: column;
    padding: 6px 8px;
    margin-bottom: 4px;
    border-radius: 4px;
    font-size: 10px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    transition: all 0.2s ease;
}

.physics-column-item.valid {
    background: rgba(16, 185, 129, 0.15);
    border-left: 3px solid #10B981;
}

.physics-column-item.invalid {
    background: rgba(239, 68, 68, 0.25);
    border-left: 4px solid #EF4444;
    box-shadow: inset 0 0 12px rgba(239, 68, 68, 0.2);
    animation: violation-pulse 2s ease-in-out infinite;
}

.physics-column-item.invalid:hover {
    background: rgba(239, 68, 68, 0.35);
    transform: translateX(2px);
}

@keyframes violation-pulse {
    0%, 100% { 
        background: rgba(239, 68, 68, 0.2);
        border-left-color: #EF4444;
    }
    50% { 
        background: rgba(239, 68, 68, 0.35);
        border-left-color: #F87171;
    }
}

.physics-column-main {
    display: flex;
    align-items: center;
}

.physics-column-info {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 2px;
}

.physics-column-violation {
    font-size: 9px;
    color: #FECACA;
    margin-top: 4px;
    padding: 3px 6px;
    background: rgba(239, 68, 68, 0.15);
    border-radius: 3px;
    font-style: italic;
}

.physics-column-index {
    color: #94A3B8;
    min-width: 50px;
}

.physics-column-values {
    color: #E2E8F0;
    flex: 1;
    margin: 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.physics-column-sum {
    font-weight: bold;
    min-width: 70px;
    text-align: right;
    padding: 2px 6px;
    border-radius: 3px;
}

.physics-column-sum.zero {
    color: #10B981;
    background: rgba(16, 185, 129, 0.1);
}

.physics-column-sum.nonzero {
    color: #FEE2E2;
    background: rgba(239, 68, 68, 0.4);
    font-weight: 700;
    text-shadow: 0 0 4px rgba(239, 68, 68, 0.5);
}

.physics-column-status {
    margin-left: 8px;
    font-size: 12px;
}

.physics-column-item.invalid .physics-column-status {
    color: #FCA5A5;
    text-shadow: 0 0 6px rgba(248, 113, 113, 0.6);
    animation: status-glow 1.5s ease-in-out infinite;
}

@keyframes status-glow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Physics Mode Selection */
.physics-mode-section {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 12px;
}

.physics-mode-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

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

.physics-mode-label input[type="radio"] {
    accent-color: #8B5CF6;
}

.physics-n-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.physics-n-row label {
    font-size: 11px;
    color: var(--text-secondary);
}

.physics-n-row input[type="number"] {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 4px 8px;
    font-size: 12px;
}

.physics-hint {
    font-size: 10px;
    color: var(--text-muted);
}

.physics-mode-indicator {
    background: rgba(0, 0, 0, 0.25);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-align: center;
}

.physics-mode-indicator span {
    color: #A78BFA;
    font-weight: 600;
}

/* State Space Visualization */
.physics-state-section {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.physics-state-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(139, 92, 246, 0.2);
    font-size: 11px;
    color: #A78BFA;
    font-weight: 600;
}

.physics-state-hint {
    font-size: 9px;
    color: var(--text-muted);
    font-weight: normal;
}

/* Clickable Partition Grid */
.physics-partition-container {
    padding: 8px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    margin-top: 8px;
}

.physics-partition-instructions {
    font-size: 9px;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-align: center;
}

.physics-partition-instructions .p-label {
    color: #F87171;
    font-weight: 600;
}

.physics-partition-instructions .q-label {
    color: #4FD1C5;
    font-weight: 600;
}

.physics-node-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    justify-content: center;
    margin-bottom: 6px;
}

.physics-node-btn {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    border: 2px solid transparent;
    cursor: pointer;
    font-size: 9px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.physics-node-btn.is-p {
    background: rgba(248, 113, 113, 0.3);
    border-color: #F87171;
    color: #F87171;
}

.physics-node-btn.is-q {
    background: rgba(79, 209, 197, 0.12);
    border-color: rgba(79, 209, 197, 0.4);
    color: rgba(79, 209, 197, 0.75);
    width: 22px;
    height: 22px;
    font-size: 8px;
    opacity: 0.7;
}

.physics-node-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 10px currentColor;
}

.physics-partition-summary {
    display: flex;
    justify-content: center;
    gap: 16px;
    font-size: 9px;
    color: var(--text-muted);
    padding-top: 6px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.physics-partition-summary .p-label {
    color: #F87171;
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
}

.physics-partition-summary .q-label {
    color: rgba(79, 209, 197, 0.8);
    font-family: 'JetBrains Mono', monospace;
    font-size: 8px;
}

.physics-state-container {
    display: flex;
    align-items: stretch;
    padding: 10px;
    gap: 0;
}

.physics-state-block {
    flex: 1;
    min-width: 0;
}

.physics-p-block {
    border-right: none;
}

.physics-q-block {
    border-left: none;
}

.physics-block-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    text-align: center;
}

.physics-p-block .physics-block-label {
    color: #F87171;
}

.physics-q-block .physics-block-label {
    color: #4FD1C5;
}

.physics-state-cells {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    justify-content: center;
}

.physics-state-cell {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-family: 'JetBrains Mono', monospace;
    transition: all 0.15s ease;
}

.physics-state-cell.p-cell {
    background: rgba(248, 113, 113, 0.2);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: #F87171;
}

.physics-state-cell.q-cell {
    background: rgba(79, 209, 197, 0.12);
    border: 1px solid rgba(79, 209, 197, 0.3);
    color: rgba(79, 209, 197, 0.75);
    width: 20px;
    height: 20px;
    font-size: 7px;
    opacity: 0.8;
}

.physics-state-cell.active {
    transform: scale(1.1);
    box-shadow: 0 0 8px currentColor;
}

.physics-state-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    min-width: 20px;
}

.physics-divider-line {
    width: 2px;
    flex: 1;
    background: linear-gradient(to bottom, transparent, #6B7280, transparent);
}

.physics-divider-label {
    color: #6B7280;
    font-size: 16px;
    font-weight: bold;
    padding: 4px 0;
}

/* Hamiltonian Real-time Plot */
.physics-hamiltonian-section {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.physics-hamiltonian-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(16, 185, 129, 0.2);
    font-size: 11px;
    color: #10B981;
    font-weight: 600;
}

.physics-hamiltonian-controls {
    display: flex;
    gap: 4px;
}

.physics-mini-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    font-size: 10px;
    transition: all 0.2s;
}

.physics-mini-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.physics-mini-btn.playing {
    background: #10B981;
}

.physics-energy-live {
    padding: 10px;
}

.physics-energy-values {
    display: flex;
    justify-content: space-around;
    margin-bottom: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
}

.physics-t-value {
    color: #F87171;
}

.physics-v-value {
    color: #4FD1C5;
}

.physics-h-value {
    color: #FBBF24;
    font-weight: bold;
}

#physics-energy-canvas {
    width: 100%;
    height: 80px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    display: block;
}

.physics-plot-legend {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 6px;
    font-size: 9px;
}

.legend-h { color: #FBBF24; }
.legend-t { color: #F87171; }
.legend-v { color: #4FD1C5; }

.physics-time-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.2);
    font-size: 10px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

#physics-time-value {
    color: #A78BFA;
}

.physics-conservation-ok {
    color: #10B981;
    font-size: 9px;
}

.physics-conservation-warning {
    color: #F59E0B;
    font-size: 9px;
}

/* Rectification Prompt */
.physics-rectify-prompt {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(239, 68, 68, 0.15));
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
}

.physics-rectify-message {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-primary);
}

.physics-rectify-icon {
    font-size: 18px;
}

.physics-rectify-question {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.physics-rectify-note {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.4;
}

.physics-btn.rectify-yes {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s;
    width: 100%;
}

.physics-btn.rectify-yes:hover {
    background: linear-gradient(135deg, #D97706, #B45309);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

/* Undo Panel */
.physics-undo-panel {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(6, 182, 212, 0.15));
    border: 1px solid rgba(16, 185, 129, 0.4);
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.physics-undo-message {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-primary);
}

.physics-undo-icon {
    color: #10B981;
    font-size: 14px;
}

.physics-btn.undo {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 10px;
    transition: all 0.2s;
}

.physics-btn.undo:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #F87171;
}

/* Partition Suggestion Panel */
.physics-partition-suggestion {
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.15), rgba(34, 197, 94, 0.1));
    border: 1px solid rgba(74, 222, 128, 0.4);
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
}

.physics-suggestion-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #4ade80;
    margin-bottom: 8px;
}

.physics-suggestion-icon {
    font-size: 16px;
}

.physics-suggestion-message {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.4;
}

.physics-suggestion-partition {
    font-size: 11px;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    font-family: var(--font-mono);
}

.physics-suggestion-partition div {
    margin: 4px 0;
}

.physics-btn.apply-partition {
    width: 100%;
    background: linear-gradient(135deg, #10B981, #059669);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s;
}

.physics-btn.apply-partition:hover {
    background: linear-gradient(135deg, #34D399, #10B981);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Partition Section */
.physics-partition-section {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 12px;
}

.physics-partition-header {
    font-size: 11px;
    color: #A78BFA;
    font-weight: 600;
    margin-bottom: 8px;
}

/* Rectification Prompt */
.physics-rectify-prompt {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
}

.physics-rectify-message {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #FBBF24;
    margin-bottom: 8px;
}

.physics-rectify-icon {
    font-size: 16px;
}

.physics-rectify-question {
    font-size: 11px;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.physics-rectify-note {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.4;
}

.physics-btn.rectify-yes {
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    color: white;
    width: 100%;
    padding: 8px 12px;
    font-size: 11px;
}

.physics-btn.rectify-yes:hover {
    background: linear-gradient(135deg, #FBBF24 0%, #F59E0B 100%);
}

/* Undo Panel */
.physics-undo-panel {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
}

.physics-undo-message {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #10B981;
    margin-bottom: 10px;
}

.physics-undo-icon {
    font-size: 16px;
}

.physics-btn.undo {
    background: linear-gradient(135deg, #6B7280 0%, #4B5563 100%);
    color: white;
    width: 100%;
    padding: 8px 12px;
    font-size: 11px;
}

.physics-btn.undo:hover {
    background: linear-gradient(135deg, #9CA3AF 0%, #6B7280 100%);
}

/* Computing indicator for async eigenvalue computation */
.computing {
    animation: pulse 1.5s ease-in-out infinite;
    color: #888;
}

.computing-hint {
    color: #888;
    font-style: italic;
    padding: 10px;
    text-align: center;
}

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

