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

body {
    font-family: 'Press Start 2P', monospace;
    background: #0f0f0f;
    color: #c0c0c0;
    min-height: 100vh;
    overflow: hidden;
    image-rendering: pixelated;
}

.container {
    display: flex;
    height: 100vh;
}

/* ============================================
   SIDEBAR - Famicom Style Panel
   ============================================ */
.sidebar {
    width: 320px;
    background: #1a1a1a;
    padding: 16px;
    overflow-y: auto;
    border-right: 4px solid #404040;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 4px solid #404040;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: #c0c0c0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #0f0f0f;
    border: 2px solid #808080;
}

.logo h1 {
    font-size: 10px;
    color: #c0c0c0;
    letter-spacing: 1px;
    flex: 1;
}

.about-btn {
    width: 24px;
    height: 24px;
    background: transparent;
    border: 1px solid #333;
    color: #666;
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.2s;
}
.about-btn:hover {
    border-color: #fff;
    color: #fff;
}

.section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-header {
    font-size: 8px;
    letter-spacing: 2px;
    color: #606060;
    padding: 4px 0;
    border-bottom: 2px dashed #404040;
}

/* ============================================
   MIDI FILES LIST
   ============================================ */
.midi-files {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 360px;
    overflow-y: auto;
    border: 2px solid #404040;
    background: #1a1a1a;
}

.midi-composer-header {
    padding: 6px 8px;
    background: #404040;
    color: #c0c0c0;
    font-size: 6px;
    letter-spacing: 1px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.midi-file-item {
    padding: 6px 12px;
    background: #252525;
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    font-size: 5px;
    border-bottom: 1px solid #303030;
}

.midi-file-item:hover {
    background: #353535;
    color: #ffffff;
}

.midi-file-item.active {
    background: #c0c0c0;
    color: #0f0f0f;
}

/* ============================================
   VISUALIZATION MODE GRID
   ============================================ */
.viz-mode-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
}

.viz-mode-btn {
    padding: 10px 6px;
    background: #252525;
    border: 2px solid #404040;
    color: #808080;
    cursor: pointer;
    transition: all 0.1s;
    font-family: 'Press Start 2P', monospace;
    font-size: 5px;
    text-align: center;
}

.viz-mode-btn:hover {
    background: #303030;
    border-color: #808080;
    color: #c0c0c0;
}

.viz-mode-btn.active {
    background: #c0c0c0;
    border-color: #ffffff;
    color: #0f0f0f;
}

/* ============================================
   ML METHOD SELECTOR
   ============================================ */
.ml-method-section {
    transition: all 0.2s;
}

.ml-method-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.ml-method-btn {
    padding: 8px 4px;
    background: #252525;
    border: 2px solid #404040;
    color: #808080;
    cursor: pointer;
    transition: all 0.1s;
    font-family: 'Press Start 2P', monospace;
    font-size: 5px;
    text-align: center;
}

.ml-method-btn:hover {
    background: #303030;
    border-color: #808080;
    color: #c0c0c0;
}

.ml-method-btn.active {
    background: #c0c0c0;
    border-color: #ffffff;
    color: #0f0f0f;
}

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

/* ============================================
   DIMENSION TOGGLE (2D/3D)
   ============================================ */
.dimension-row {
    display: flex;
    gap: 4px;
}

.dim-btn {
    flex: 1;
    padding: 6px 4px;
    background: #252525;
    border: 2px solid #404040;
    color: #808080;
    cursor: pointer;
    transition: all 0.1s;
    font-family: 'Press Start 2P', monospace;
    font-size: 6px;
    text-align: center;
}

.dim-btn:hover {
    background: #303030;
    border-color: #808080;
    color: #c0c0c0;
}

.dim-btn.active {
    background: #c0c0c0;
    border-color: #ffffff;
    color: #0f0f0f;
}

/* ============================================
   COLOR MAP SELECTOR
   ============================================ */
.colormap-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.colormap-btn {
    padding: 6px 4px;
    background: #252525;
    border: 2px solid #404040;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.1s;
    font-family: 'Press Start 2P', monospace;
    font-size: 5px;
    text-align: center;
    text-shadow: 0 0 2px #000, 0 0 4px #000, 1px 1px 0 #000;
}

.colormap-btn:hover {
    border-color: #ffffff;
    filter: brightness(1.2);
}

.colormap-btn.active {
    border-color: #ffffff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

/* ============================================
   PLAYBACK CONTROLS - 8bit Buttons
   ============================================ */
.playback-section {
    background: #252525;
    border: 4px solid #404040;
    padding: 12px;
}

.playback-controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.playback-btn {
    width: 36px;
    height: 36px;
    background: #404040;
    border: 2px solid #606060;
    color: #c0c0c0;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Press Start 2P', monospace;
}

.playback-btn:hover:not(:disabled) {
    background: #606060;
    border-color: #c0c0c0;
}

.playback-btn:active:not(:disabled) {
    transform: scale(0.95);
}

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

.playback-btn.play-btn {
    width: 44px;
    height: 44px;
    font-size: 16px;
    background: #c0c0c0;
    border-color: #ffffff;
    color: #0f0f0f;
}

.playback-btn.play-btn:hover:not(:disabled) {
    background: #ffffff;
}

.playback-btn.play-btn.playing {
    background: #808080;
    color: #ffffff;
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress-container {
    margin-bottom: 8px;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: #1a1a1a;
    border: 2px solid #404040;
    cursor: pointer;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: #c0c0c0;
    width: 0%;
    transition: width 0.05s linear;
}

.time-display {
    display: flex;
    justify-content: space-between;
    font-size: 6px;
    color: #606060;
    margin-top: 6px;
}

/* ============================================
   SLIDERS - 8bit Style
   ============================================ */
.controls-row {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.control-item {
    flex: 1;
}

.control-item-spaced {
    margin-top: 8px;
}

.control-label {
    display: flex;
    justify-content: space-between;
    font-size: 5px;
    margin-bottom: 6px;
    color: #808080;
}

.control-value {
    color: #c0c0c0;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    background: #1a1a1a;
    border: 2px solid #404040;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 16px;
    background: #c0c0c0;
    border: 2px solid #808080;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #ffffff;
}

/* ============================================
   STATS GRID
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.stat-item {
    background: #252525;
    border: 2px solid #404040;
    padding: 10px;
    text-align: center;
}

.stat-value {
    font-size: 12px;
    color: #c0c0c0;
}

.stat-label {
    font-size: 5px;
    color: #606060;
    margin-top: 4px;
}

/* ============================================
   MAIN CANVAS AREA
   ============================================ */
.main-view {
    flex: 1;
    position: relative;
    background: #0a0a0a;
}

#canvas-container {
    width: 100%;
    height: 100%;
}

/* ============================================
   INFO OVERLAY - 8bit Window
   ============================================ */
.info-overlay {
    position: absolute;
    top: 16px;
    left: 16px;
    background: #1a1a1a;
    border: 4px solid #404040;
    padding: 12px 16px;
    max-width: 280px;
}

.info-overlay::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    height: 16px;
    background: #404040;
    border-bottom: 4px solid #606060;
}

.info-overlay h3 {
    font-size: 8px;
    color: #c0c0c0;
    margin-top: 12px;
    margin-bottom: 8px;
}

.info-overlay p {
    font-size: 6px;
    color: #808080;
    line-height: 1.8;
}

/* ============================================
   BOTTOM PANEL - Combined Keyboard + Chroma
   ============================================ */
.bottom-panel {
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.keyboard-container {
    flex: 1;
    background: #1a1a1a;
    border: 4px solid #404040;
    padding: 12px;
    min-width: 0;
}

.keyboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.keyboard-header h4 {
    font-size: 6px;
    color: #606060;
}

.active-count {
    font-size: 6px;
    color: #c0c0c0;
}

.sustain-indicator {
    font-size: 6px;
    color: #404040;
    background: #1a1a1a;
    padding: 2px 6px;
    border: 1px solid #303030;
    border-radius: 2px;
    transition: all 0.1s;
}

.sustain-indicator.active {
    color: #00ffff;
    background: #003333;
    border-color: #00ffff;
    text-shadow: 0 0 4px #00ffff;
}

.piano-keys {
    display: flex;
    gap: 0;
    height: 40px;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
}

.piano-key {
    flex-shrink: 0;
    width: 8px;
    height: 100%;
    background: #404040;
    border: 1px solid #505050;
    transition: all 0.05s;
    position: relative;
}

.piano-key.black {
    width: 6px;
    height: 60%;
    background: #1a1a1a;
    border-color: #303030;
    margin: 0 -3px;
    z-index: 1;
}

.piano-key.active {
    background: #ffffff;
    border-color: #c0c0c0;
}

.piano-key.black.active {
    background: #c0c0c0;
    border-color: #808080;
}

/* Active Notes Display - Fixed height */
.notes-display {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    height: 24px;
    overflow: hidden;
    margin-top: 8px;
    align-items: flex-start;
}

.notes-display-empty {
    color: #606060;
    font-size: 5px;
    line-height: 24px;
}

.note-badge {
    padding: 3px 6px;
    background: #404040;
    border: 1px solid #606060;
    font-size: 5px;
    color: #c0c0c0;
}

/* ============================================
   CHROMA DISPLAY - 8bit Bars (now in bottom panel)
   ============================================ */
.chroma-display {
    flex-shrink: 0;
    background: #1a1a1a;
    border: 4px solid #404040;
    padding: 12px;
}

.chroma-title {
    font-size: 5px;
    color: #606060;
    margin-bottom: 8px;
}

.chroma-bars {
    display: flex;
    gap: 2px;
    height: 48px;
    align-items: flex-end;
}

.chroma-bar {
    width: 14px;
    background: #c0c0c0;
    transition: height 0.1s;
    min-height: 2px;
}

.chroma-labels {
    display: flex;
    gap: 2px;
    margin-top: 4px;
}

.chroma-label {
    width: 14px;
    text-align: center;
    font-size: 4px;
    color: #606060;
}

/* ============================================
   CONSOLE DISPLAY - Retro Terminal
   ============================================ */
.console-display {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 260px;
    background: #0a0a0a;
    border: 4px solid #404040;
    font-family: 'Press Start 2P', monospace;
}

.console-header {
    background: #404040;
    padding: 6px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #606060;
}

.console-title {
    font-size: 6px;
    color: #00ff00;
    text-shadow: 0 0 4px #00ff00;
}

.console-indicator {
    width: 8px;
    height: 8px;
    background: #00ff00;
    box-shadow: 0 0 4px #00ff00;
    animation: blink 1s step-start infinite;
}

@keyframes blink {
    50% { opacity: 0.3; }
}

.console-body {
    padding: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.console-line {
    font-size: 5px;
    line-height: 1.8;
    margin-bottom: 4px;
    color: #00cc00;
    text-shadow: 0 0 2px #00cc00;
}

.console-line.dim {
    color: #006600;
    text-shadow: none;
}

.console-line.highlight {
    color: #00ff00;
    text-shadow: 0 0 4px #00ff00;
}

.console-line.warn {
    color: #ffcc00;
    text-shadow: 0 0 2px #ffcc00;
}

.console-line.info {
    color: #00ccff;
    text-shadow: 0 0 2px #00ccff;
}

.console-section {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px dashed #404040;
}

.console-section:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.console-label {
    font-size: 4px;
    color: #808080;
    margin-bottom: 2px;
}

/* ============================================
   LOADING - 8bit Spinner
   ============================================ */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 100;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #404040;
    border-top-color: #c0c0c0;
    animation: spin 0.5s steps(8) infinite;
    margin: 0 auto 16px;
}

.loading p {
    color: #808080;
    font-size: 6px;
}

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

.hidden {
    display: none !important;
}

/* ============================================
   TIMELINE - Piano Roll
   ============================================ */
.timeline-container {
    flex: 1;
    min-width: 200px;
    background: #0a0a0a;
    border: 2px solid #404040;
    padding: 4px;
    display: flex;
    flex-direction: column;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.timeline-title {
    font-size: 8px;
    color: #808080;
}

.timeline-stats {
    font-size: 7px;
    color: #00ff00;
}

.timeline-canvas {
    width: 100%;
    height: 60px;
    background: #0a0a0a;
    cursor: pointer;
    image-rendering: pixelated;
}

/* ============================================
   WATERFALL - Volume Visualization
   ============================================ */
.waterfall-container {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    border: 4px solid #404040;
    padding: 8px;
}

.waterfall-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.waterfall-title {
    font-size: 8px;
    color: #808080;
}

.waterfall-canvas {
    width: 100%;
    height: 80px;
    background: #0a0a0a;
    image-rendering: pixelated;
    flex: 1;
}

/* ============================================
   SCROLLBAR - 8bit Style
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
    border: 2px solid #404040;
}

::-webkit-scrollbar-thumb {
    background: #606060;
}

::-webkit-scrollbar-thumb:hover {
    background: #808080;
}

/* ============================================
   TOOLTIP - 8bit Box
   ============================================ */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 8px;
    background: #0f0f0f;
    border: 2px solid #606060;
    color: #c0c0c0;
    font-size: 5px;
    white-space: nowrap;
    margin-bottom: 6px;
    font-family: 'Press Start 2P', monospace;
}

/* ============================================
   RESPONSIVE ANIMATIONS - Pixel Style
   ============================================ */
@keyframes noteIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.note-badge {
    animation: noteIn 0.1s steps(3);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.display-toggles {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 6px;
    color: #808080;
    cursor: pointer;
}

.toggle-checkbox {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* ============================================
   MODAL STYLES
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay.hidden {
    display: none;
}
.modal-content {
    background: #0f0f0f;
    border: 4px solid #00ff00;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    font-family: 'VT323', monospace;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #00ff00;
    color: #0f0f0f;
}
.modal-title {
    font-size: 14px;
    font-weight: bold;
}
.modal-close {
    background: #0f0f0f;
    border: none;
    color: #00ff00;
    font-family: inherit;
    font-size: 12px;
    padding: 2px 6px;
    cursor: pointer;
}
.modal-close:hover {
    background: #00ff00;
    color: #0f0f0f;
}
.modal-body {
    padding: 20px;
    color: #00ff00;
    font-size: 12px;
    line-height: 1.6;
}
.modal-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px dashed #004400;
}
.modal-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}
.modal-section h3 {
    color: #00ff00;
    font-size: 13px;
    margin-bottom: 10px;
    text-shadow: 0 0 10px #00ff00;
}
.modal-section p {
    margin-bottom: 8px;
    color: #00cc00;
}
.modal-section strong {
    color: #00ff00;
}
.formula-box {
    background: #001a00;
    border: 1px solid #004400;
    padding: 10px 12px;
    margin: 8px 0;
}
.formula-title {
    color: #00ff00;
    font-size: 11px;
    margin-bottom: 4px !important;
}
.formula-box code {
    display: block;
    color: #ffff00;
    font-size: 12px;
    margin: 4px 0;
    font-family: 'VT323', monospace;
}
.formula-desc {
    color: #008800 !important;
    font-size: 10px;
    margin-bottom: 0 !important;
}
