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

body {
    font-family: 'Courier New', monospace;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    background: #16213e;
    padding: 8px 15px;
    border-bottom: 2px solid #0f3460;
}

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

header h1 {
    font-size: 1.2em;
    color: #e94560;
}

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

.file-controls button {
    background: #0f3460;
    color: #eee;
    border: none;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.85em;
}

.file-controls button:hover {
    background: #4ecca3;
    color: #1a1a2e;
}

.demo-controls {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid #333;
}

.demo-label {
    color: #888;
    font-size: 0.85em;
    margin-right: 4px;
}

.demo-btn {
    background: #1a1a2e;
    color: #4ecca3;
    border: 1px solid #4ecca3;
    padding: 4px 10px;
    cursor: pointer;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.85em;
    min-width: 28px;
}

.demo-btn:hover {
    background: #4ecca3;
    color: #1a1a2e;
}

.transport-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.separator {
    width: 1px;
    height: 24px;
    background: #0f3460;
    margin: 0 4px;
}

.transport-controls button {
    background: #0f3460;
    color: #eee;
    border: none;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-family: inherit;
}

.transport-controls button:hover:not(:disabled) {
    background: #e94560;
}

.transport-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.transport-controls button.active {
    background: #4ecca3;
    color: #1a1a2e;
}

#btn-play, #btn-stop {
    font-size: 1.1em;
    padding: 5px 12px;
}

#btn-record {
    color: #e94560;
}

#btn-record.recording {
    background: #e94560 !important;
    color: #fff;
    animation: pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pulse {
    from { opacity: 1; }
    to { opacity: 0.7; }
}

.transport-controls label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85em;
}

.transport-controls input[type="number"],
.transport-controls select {
    background: #0f3460;
    color: #eee;
    border: 1px solid #16213e;
    padding: 0.3em 0.5em;
    border-radius: 4px;
    font-family: inherit;
    width: 4em;
}

#grid-snap {
    width: 5.5em;
}

#octave-display {
    background: #0f3460;
    padding: 4px 10px;
    border-radius: 4px;
    min-width: 30px;
    text-align: center;
}

#midi-input {
    width: auto;
    max-width: 120px;
}

.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Center Panel (contains track layout and pattern editor) */
.center-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Track Layout Area (Track Sidebar + Timeline in a row) */
.track-layout-area {
    display: flex;
    flex-direction: row;
    height: 420px;
    min-height: 120px;
    max-height: 420px;
    border-bottom: 2px solid #0f3460;
    flex-shrink: 0;
}

/* Main Editor Area (replaces center-editor-area) */
.main-editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Sequence Sidebar */
.sequence-sidebar {
    width: 6vw;
    min-width: 70px;
    max-width: 120px;
    background: #12122a;
    border-right: 2px solid #0f3460;
    display: flex;
    flex-direction: column;
}

.sequence-header {
    background: #0f3460;
    padding: 8px;
    text-align: center;
    font-size: 0.85em;
    font-weight: bold;
    color: #4ecca3;
}

.sequence-buttons {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 5px;
}

.sequence-buttons button {
    background: #1a1a2e;
    color: #eee;
    border: none;
    width: 24px;
    height: 24px;
    cursor: pointer;
    border-radius: 3px;
    font-size: 0.9em;
}

.sequence-buttons button:hover {
    background: #e94560;
}

#sequence-list {
    flex: 1;
    overflow-y: auto;
    padding: 5px;
}

.sequence-item {
    background: #0f3460;
    margin-bottom: 3px;
    padding: 8px;
    text-align: center;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.9em;
    border: 2px solid transparent;
    user-select: none;
}

.sequence-item:hover {
    background: #16213e;
}

.sequence-item.selected {
    border-color: #e94560;
    background: #1a1a2e;
}

.sequence-item.playing {
    background: #e94560;
    color: #fff;
}

.sequence-item.drag-over {
    border-color: #4ecca3;
    background: rgba(78, 204, 163, 0.2);
}

.pattern-pool {
    border-top: 2px solid #0f3460;
    max-height: 200px;
}

.pool-header {
    background: #0f3460;
    padding: 6px;
    text-align: center;
    font-size: 0.8em;
    color: #888;
}

#pattern-pool-list {
    padding: 5px;
    overflow-y: auto;
    max-height: 150px;
}

.pool-item {
    background: #16213e;
    margin-bottom: 2px;
    padding: 5px;
    text-align: center;
    cursor: grab;
    border-radius: 3px;
    font-size: 0.8em;
}

.pool-item:hover {
    background: #0f3460;
}

.pool-item.dragging {
    opacity: 0.5;
}

/* Track Sidebar (DAW-style) */
.track-sidebar {
    width: 140px;
    min-width: 120px;
    background: #12122a;
    border-right: 2px solid #0f3460;
    display: flex;
    flex-direction: column;
}

.track-sidebar-header {
    background: #0f3460;
    padding: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85em;
    font-weight: bold;
    color: #4ecca3;
}

.track-sidebar-buttons {
    display: flex;
    gap: 4px;
}

.track-sidebar-buttons button {
    background: #1a1a2e;
    color: #eee;
    border: none;
    width: 22px;
    height: 22px;
    cursor: pointer;
    border-radius: 3px;
    font-size: 0.75em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.track-sidebar-buttons button:hover {
    background: #4ecca3;
    color: #1a1a2e;
}

.track-list {
    flex: 1;
    overflow-y: scroll;  /* Allow scrolling but hide scrollbar */
    overflow-x: hidden;
    padding: 0;
    margin-top: 24px; /* Match timeline ruler height */
    scrollbar-width: none;  /* Firefox */
    -ms-overflow-style: none;  /* IE/Edge */
}

/* Hide scrollbar for track-list - Chrome/Safari */
.track-list::-webkit-scrollbar {
    display: none;
}

.track-list-item {
    background: #16213e;
    height: 60px;
    padding: 0 8px;
    border-radius: 0;
    font-size: 0.75em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid #0f3460;
    box-sizing: border-box;
}

.track-list-item:hover {
    background: #1a1a2e;
}

.track-list-item.selected {
    border-color: #e94560;
    background: #1a1a2e;
}

.track-list-item.muted {
    opacity: 0.5;
}

.track-list-item .track-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-list-item .track-controls {
    display: flex;
    gap: 2px;
}

.track-list-item .btn-track-mute,
.track-list-item .btn-track-solo {
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 2px;
    font-size: 0.65em;
    cursor: pointer;
    background: #0f3460;
    color: #888;
}

.track-list-item .btn-track-mute:hover,
.track-list-item .btn-track-solo:hover {
    background: #4ecca3;
    color: #1a1a2e;
}

.track-list-item .btn-track-mute.active {
    background: #e94560;
    color: #fff;
}

.track-list-item .btn-track-solo.active {
    background: #ffd93d;
    color: #1a1a2e;
}

.track-sidebar-footer {
    background: #0f3460;
    padding: 6px;
    text-align: center;
    font-size: 0.75em;
    color: #666;
}

/* Track Editor View (contains timeline) */
.track-editor-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 150px;
}

.track-editor-view.hidden {
    display: none;
}

/* Timeline Area */
.timeline-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1a1a2e;
    overflow: hidden;
    min-height: 100px;
}

.timeline-header {
    height: 64px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;  /* Firefox */
}

.timeline-header::-webkit-scrollbar {
    display: none;  /* Chrome/Safari */
}

.timeline-ruler {
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 4px;
    font-size: 0.7em;
    color: #666;
    cursor: pointer;
}

.timeline-ruler .beat-marker {
    position: absolute;
    color: #888;
    font-size: 0.9em;
}

.timeline-ruler .bar-marker {
    color: #4ecca3;
    font-weight: bold;
}

.timeline-ruler .sub-marker {
    position: absolute;
    color: #444;
    font-size: 0.8em;
}

.timeline-tracks {
    flex: 1;
    overflow: auto;
    position: relative;
}

/* Inner content wrapper - this is what creates the scrollable area */
.timeline-content {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

/* Style the native scrollbar in timeline-tracks */
.timeline-tracks::-webkit-scrollbar {
    height: 14px;
    width: 14px;
}

.timeline-tracks::-webkit-scrollbar-track {
    background: #1a1a2e;
}

.timeline-tracks::-webkit-scrollbar-thumb {
    background: #4ecca3;
    border-radius: 4px;
    border: 2px solid #1a1a2e;
}

.timeline-tracks::-webkit-scrollbar-thumb:hover {
    background: #6ee6b8;
}

.timeline-tracks::-webkit-scrollbar-corner {
    background: #1a1a2e;
}

/* Timeline info bar (below tracks) */
.timeline-info-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 4px 8px;
    background: #0a0a1a;
    border-top: 1px solid #0f3460;
    flex-shrink: 0;
}

#timeline-position-display {
    font-size: 11px;
    color: #4ecca3;
    font-family: monospace;
}

.timeline-track-row {
    height: 60px;
    border-bottom: 1px solid #0f3460;
    position: relative;
    box-sizing: border-box;
}

.timeline-track-row:nth-child(even) {
    background: rgba(15, 52, 96, 0.2);
}

.timeline-clip {
    position: absolute;
    height: 54px;
    top: 2px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    font-size: 0.7em;
    color: #fff;
    overflow: hidden;
    user-select: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    min-width: 30px;
}

.timeline-clip:hover {
    filter: brightness(1.1);
}

.timeline-clip.selected {
    box-shadow: 0 0 0 2px #e94560, 0 2px 6px rgba(233, 69, 96, 0.4);
}

/* Clip header with name */
.timeline-clip .clip-header {
    padding: 2px 20px 2px 18px;
    font-size: 0.85em;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(0,0,0,0.2);
    color: rgba(255,255,255,0.9);
}

/* Note visualization canvas */
.timeline-clip .clip-note-viz {
    flex: 1;
    width: 100%;
    pointer-events: none;
}

/* Loop handle - top left */
.timeline-clip .clip-loop-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 16px;
    height: 14px;
    background: rgba(0,0,0,0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    border-radius: 4px 0 4px 0;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.timeline-clip .clip-loop-handle:hover {
    opacity: 1;
    background: rgba(255,215,0,0.8);
    color: #1a1a2e;
}

.timeline-clip .clip-resize-handle:hover {
    background: rgba(255,255,255,0.3);
}

/* Split handle - appears on hover */
.timeline-clip .clip-split-handle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: #e94560;
    border-radius: 50%;
    cursor: crosshair;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 10;
}

.timeline-clip .clip-split-handle:hover {
    background: #ff6b8a;
    transform: translateY(-50%) scale(1.1);
}

/* Library item dragging */
.library-item.dragging {
    opacity: 0.5;
}

.library-item {
    cursor: grab;
}

.library-item:active {
    cursor: grabbing;
}

.timeline-grid-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #0f3460;
    pointer-events: none;
}

.timeline-grid-line.bar {
    background: #16213e;
}

.timeline-playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e94560;
    pointer-events: none;
    z-index: 10;
}

/* Song end marker (draggable) */
.timeline-end-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 6px;
    background: linear-gradient(90deg, #ffd93d 0%, transparent 100%);
    cursor: ew-resize;
    z-index: 5;
}

.timeline-end-marker::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #ffd93d;
}

.timeline-end-marker:hover {
    background: linear-gradient(90deg, #ff9f43 0%, transparent 100%);
}

.timeline-end-marker:hover::before {
    background: #ff9f43;
}

/* Loop region overlay */
.timeline-loop-region {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(78, 204, 163, 0.15);
    pointer-events: none;
    z-index: 1;
}

/* Loop start/end markers (draggable) */
.timeline-loop-start,
.timeline-loop-end {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 8px;
    background: #4ecca3;
    cursor: ew-resize;
    z-index: 6;
}

.timeline-loop-start {
    border-radius: 4px 0 0 4px;
}

.timeline-loop-end {
    border-radius: 0 4px 4px 0;
}

.timeline-loop-start:hover,
.timeline-loop-end:hover {
    background: #6ee6b8;
}

.timeline-loop-start::before,
.timeline-loop-end::before {
    content: '⟨';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #1a1a2e;
    font-size: 12px;
    font-weight: bold;
}

.timeline-loop-end::before {
    content: '⟩';
}

/* Arrangement end marker (shows where clips end, snapped to measure) */
.timeline-arrangement-end {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: rgba(108, 99, 255, 0.6);
    pointer-events: none;
    z-index: 4;
}

.timeline-arrangement-end::before {
    content: '▼';
    position: absolute;
    top: -2px;
    left: -5px;
    font-size: 10px;
    color: #6c63ff;
}

/* Pattern Editor Area (below track layout) */
.pattern-editor-area {
    display: flex;
    flex-direction: column;
    background: #12122a;
    flex: 1;
    overflow: hidden;
    margin-left: 140px;  /* Align with timeline (after track sidebar) */
}

.pattern-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #16213e;
    padding: 6px 12px;
    border-bottom: 1px solid #0f3460;
    flex-shrink: 0;
}

#pattern-editor-title {
    color: #4ecca3;
    font-weight: bold;
    font-size: 0.9em;
}

.pattern-editor-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pattern-editor-controls label {
    font-size: 0.8em;
    color: #888;
    display: flex;
    align-items: center;
    gap: 4px;
}

.pattern-editor-controls input[type="number"] {
    width: 50px;
    background: #0f3460;
    color: #eee;
    border: 1px solid #16213e;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.9em;
}

.pattern-editor-controls button {
    background: #4ecca3;
    color: #1a1a2e;
    border: none;
    padding: 4px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8em;
    font-weight: bold;
}

.pattern-editor-controls button:hover {
    background: #5fd9b4;
}

.pattern-editor-controls .column-label {
    font-size: 0.8em;
    color: #4ecca3;
    margin-left: 8px;
}

.pattern-editor-controls #note-col-count {
    font-size: 0.85em;
    color: #eee;
    background: #0f3460;
    padding: 2px 8px;
    border-radius: 3px;
    min-width: 20px;
    text-align: center;
}

.pattern-editor-controls #btn-note-col-minus,
.pattern-editor-controls #btn-note-col-plus {
    width: 24px;
    height: 24px;
    padding: 0;
    font-size: 1em;
    background: #0f3460;
    color: #eee;
}

.pattern-editor-controls #btn-note-col-minus:hover,
.pattern-editor-controls #btn-note-col-plus:hover {
    background: #e94560;
    color: #fff;
}

.pattern-editor-area.hidden {
    display: none;
}

/* Editor View Tabs */
.editor-view-tabs {
    display: flex;
    background: #0f3460;
    border-bottom: 2px solid #1a1a2e;
    flex-shrink: 0;
}

.editor-view-tab {
    background: transparent;
    color: #888;
    border: none;
    padding: 8px 20px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9em;
    font-weight: bold;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}

.editor-view-tab:hover {
    color: #eee;
    background: rgba(233, 69, 96, 0.1);
}

.editor-view-tab.active {
    color: #e94560;
    border-bottom-color: #e94560;
    background: #16213e;
}

/* Tracker Container (inside pattern-editor-container) */
.tracker-container {
    flex: 1;
    overflow: auto;
    padding: 8px;
    position: relative;
    background: #16213e;
}

.tracker-container.hidden {
    display: none;
}

/* Piano Roll Container */
.piano-roll-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1a1a2e;
    overflow: hidden;
}

.piano-roll-container.hidden {
    display: none;
}

.piano-roll-toolbar {
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    background: #0f3460;
    border-bottom: 1px solid #16213e;
    align-items: center;
}

.piano-roll-toolbar label {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #aaa;
    font-size: 12px;
}

.piano-roll-toolbar select,
.piano-roll-toolbar button {
    padding: 4px 8px;
    background: #16213e;
    border: 1px solid #0f3460;
    color: #e8e8e8;
    border-radius: 3px;
    cursor: pointer;
}

.piano-roll-toolbar select#piano-instrument {
    min-width: 120px;
}

.piano-roll-toolbar button:hover {
    background: #1a3a70;
}

.piano-roll-main {
    flex: 1;
    display: flex;
    overflow: auto;
}

.piano-keys {
    width: 60px;
    flex-shrink: 0;
    background: #0a0a1a;
    border-right: 1px solid #333;
    overflow-y: auto;
}

.piano-key {
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 4px;
    font-size: 9px;
    color: #888;
    border-bottom: 1px solid #222;
    cursor: pointer;
    user-select: none;
}

.piano-key.white {
    background: linear-gradient(90deg, #e0e0e0, #f8f8f8);
    color: #333;
}

.piano-key.black {
    background: linear-gradient(90deg, #222, #333);
    color: #888;
}

.piano-key:hover {
    filter: brightness(1.1);
}

.piano-key.playing {
    background: #4ecca3 !important;
    color: #000;
}

.piano-roll-grid {
    flex: 1;
    overflow: auto;
    position: relative;
}

#piano-roll-canvas {
    display: block;
}

.velocity-lane {
    height: 60px;
    background: #12122a;
    border-top: 1px solid #333;
    padding: 4px;
}

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

/* Sample Editor Container */
.sample-editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #12122a;
    overflow: hidden;
}

.sample-editor-container.hidden {
    display: none;
}

.sample-editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #0f3460;
    border-bottom: 1px solid #1a1a2e;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 8px;
}

.sample-info-display {
    display: flex;
    gap: 12px;
    align-items: center;
}

#sample-editor-name {
    color: #4ecca3;
    font-weight: bold;
    font-size: 0.9em;
}

#sample-editor-info {
    color: #888;
    font-size: 0.8em;
}

.sample-editor-controls {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.sample-editor-controls button {
    background: #1a1a2e;
    color: #eee;
    border: 1px solid #333;
    padding: 4px 10px;
    cursor: pointer;
    border-radius: 3px;
    font-family: inherit;
    font-size: 0.8em;
}

.sample-editor-controls button:hover {
    background: #e94560;
    border-color: #e94560;
}

.sample-editor-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8em;
    color: #888;
}

.sample-editor-controls input[type="range"] {
    width: 80px;
    cursor: pointer;
}

/* Waveform Display */
.waveform-container {
    flex: 1;
    position: relative;
    background: #0a0a14;
    border: 1px solid #0f3460;
    margin: 8px;
    overflow: hidden;
    min-height: 200px;
}

#waveform-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.waveform-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

/* Slice Markers */
.slice-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e94560;
    cursor: ew-resize;
    pointer-events: auto;
    z-index: 10;
}

.slice-marker:hover {
    background: #ff6b8a;
    width: 4px;
    margin-left: -1px;
}

.slice-marker.selected {
    background: #4ecca3;
}

.slice-marker::before {
    content: attr(data-slice-num);
    position: absolute;
    top: 2px;
    left: 4px;
    background: #e94560;
    color: #fff;
    font-size: 0.65em;
    padding: 1px 4px;
    border-radius: 2px;
    pointer-events: none;
}

.slice-marker.selected::before {
    background: #4ecca3;
    color: #1a1a2e;
}

/* Selection overlay */
.waveform-selection {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(78, 204, 163, 0.2);
    border-left: 1px solid #4ecca3;
    border-right: 1px solid #4ecca3;
    pointer-events: none;
}

/* Playhead */
.waveform-playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #ffd93d;
    pointer-events: none;
    z-index: 5;
}

/* Waveform Scrollbar */
.waveform-scrollbar-container {
    padding: 4px 8px;
    background: #0a0a14;
    flex-shrink: 0;
}

#waveform-scrollbar {
    width: 100%;
    height: 12px;
    cursor: pointer;
    -webkit-appearance: none;
    background: #1a1a2e;
    border-radius: 6px;
    outline: none;
}

#waveform-scrollbar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 40px;
    height: 12px;
    background: #4ecca3;
    border-radius: 6px;
    cursor: pointer;
}

#waveform-scrollbar::-moz-range-thumb {
    width: 40px;
    height: 12px;
    background: #4ecca3;
    border-radius: 6px;
    cursor: pointer;
    border: none;
}

#waveform-scrollbar::-webkit-slider-runnable-track {
    height: 12px;
    background: #1a1a2e;
    border-radius: 6px;
}

#waveform-scrollbar::-moz-range-track {
    height: 12px;
    background: #1a1a2e;
    border-radius: 6px;
}

/* Sample Editor Footer */
.sample-editor-footer {
    background: #0f3460;
    padding: 8px;
    border-top: 1px solid #1a1a2e;
    flex-shrink: 0;
    max-height: 120px;
    overflow-y: auto;
}

.slice-list-header {
    color: #888;
    font-size: 0.8em;
    margin-bottom: 6px;
}

#slice-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.slice-item {
    background: #1a1a2e;
    color: #e94560;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.75em;
    cursor: pointer;
    border: 1px solid transparent;
}

.slice-item:hover {
    background: #16213e;
    border-color: #e94560;
}

.slice-item.selected {
    background: #e94560;
    color: #fff;
}

.slice-code-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 6px;
    border-top: 1px solid #1a1a2e;
}

.slice-code-preview span {
    color: #888;
    font-size: 0.75em;
}

#slice-init-code {
    background: #1a1a2e;
    color: #4ecca3;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 0.75em;
    flex: 1;
    overflow-x: auto;
    white-space: nowrap;
}

/* Piano Roll Editor */
.piano-roll-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1a1a2e;
    overflow: hidden;
}

.piano-roll-container.hidden {
    display: none;
}

.piano-roll-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #16213e;
    padding: 8px 12px;
    border-bottom: 1px solid #0f3460;
}

.piano-roll-info {
    display: flex;
    gap: 16px;
    color: #4ecca3;
    font-size: 0.85em;
}

.piano-roll-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.piano-roll-controls label {
    font-size: 0.8em;
    color: #888;
}

.piano-roll-controls select {
    background: #0f3460;
    color: #eee;
    border: 1px solid #16213e;
    border-radius: 3px;
    padding: 4px 8px;
    font-size: 0.85em;
}

.piano-roll-controls button {
    background: #0f3460;
    color: #eee;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.9em;
}

.piano-roll-controls button:hover {
    background: #4ecca3;
    color: #1a1a2e;
}

.piano-roll-main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.piano-keys {
    width: 60px;
    background: #16213e;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.piano-key {
    height: 16px;
    display: flex;
    align-items: center;
    padding-left: 4px;
    font-size: 0.65em;
    border-bottom: 1px solid #0f3460;
    cursor: pointer;
    user-select: none;
}

.piano-key.white {
    background: #ddd;
    color: #333;
}

.piano-key.black {
    background: #333;
    color: #aaa;
}

.piano-key:hover {
    background: #4ecca3;
    color: #1a1a2e;
}

.piano-key.playing {
    background: #e94560;
    color: #fff;
}

.piano-grid-container {
    flex: 1;
    overflow: auto;
    position: relative;
}

#piano-roll-canvas {
    display: block;
}

.velocity-lane {
    height: 60px;
    background: #12122a;
    border-top: 1px solid #0f3460;
    flex-shrink: 0;
}

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

.piano-note {
    position: absolute;
    background: #4ecca3;
    border-radius: 2px;
    cursor: pointer;
    min-width: 4px;
}

.piano-note:hover {
    background: #5fd9b4;
}

.piano-note.selected {
    background: #e94560;
}

.piano-note .note-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    cursor: ew-resize;
}

#tracker-grid {
    display: flex;
    gap: 2px;
    min-width: fit-content;
}

/* Pattern grid containers - multiple kept in DOM for instant switching */
.pattern-grid-container {
    display: contents; /* When visible, doesn't affect layout */
}

.track {
    background: #16213e;
    border-radius: 4px;
    min-width: 10em;
}

.track.collapsed {
    min-width: 3em;
}

.track.collapsed .track-rows,
.track.collapsed .column-controls {
    display: none;
}

.track.muted,
.track.silenced {
    opacity: 0.4;
}

.track-header {
    background: #0f3460;
    padding: 6px;
    text-align: center;
    font-weight: bold;
    border-radius: 4px 4px 0 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.track-header .track-title {
    color: #e94560;
    margin-bottom: 4px;
    font-size: 0.9em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.track-title-text {
    cursor: pointer;
}

.track-controls {
    display: flex;
    gap: 3px;
}

.track-controls button {
    background: #1a1a2e;
    color: #eee;
    border: none;
    width: 18px;
    height: 18px;
    cursor: pointer;
    border-radius: 2px;
    font-size: 0.7em;
    line-height: 1;
}

.track-controls button:hover {
    background: #e94560;
}

.track-controls button.active {
    background: #4ecca3;
    color: #1a1a2e;
}

.column-controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
}

.column-group {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 0.75em;
}

.column-group span {
    color: #888;
}

.column-group button {
    background: #1a1a2e;
    color: #eee;
    border: none;
    width: 18px;
    height: 18px;
    cursor: pointer;
    border-radius: 3px;
    font-size: 0.85em;
    line-height: 1;
}

.column-group button:hover {
    background: #e94560;
}

.track-rows {
    position: relative;
}

/* Column labels row - uses same sizing as data cells for perfect alignment */
.column-labels {
    display: flex;
    background: #0f3460;
    border-bottom: 1px solid #1a1a2e;
    color: #888;
    position: sticky;
    z-index: 9;
}

.column-labels .row-number {
    background: transparent;
    width: 2.5em;
    font-size: 0.7em;
}

.column-labels .note-columns,
.column-labels .fx-columns {
    display: flex;
}

.column-labels .note-column,
.column-labels .fx-column {
    display: flex;
}

.column-labels .cell {
    padding: 0.2em;
    text-align: center;
    border-right: 1px solid #1a1a2e;
    font-size: 0.8em;
}

.column-labels .cell.note-label {
    color: #4ecca3;
    width: 3.5em;
}

.column-labels .cell.amp-label {
    color: #ffd93d;
    width: 2.5em;
}

.column-labels .cell.fx-label {
    color: #6c63ff;
    width: 4.5em;
}

.track-row {
    display: flex;
    border-bottom: 1px solid #1a1a2e;
    position: relative;
}

.track-row:nth-child(4n+2) {
    background: rgba(233, 69, 96, 0.05);
}

.track-row:nth-child(16n+2) {
    background: rgba(233, 69, 96, 0.12);
}

.track-row.playing {
    background: rgba(233, 69, 96, 0.35) !important;
}

.track-row.cursor {
    outline: 1px solid #4ecca3;
}

.row-number {
    width: 2.5em;
    padding: 0.2em;
    text-align: center;
    background: #0f3460;
    color: #888;
    font-size: 0.7em;
}

/* Note column group (note + amp + fx columns) */
.note-column-group {
    display: flex;
    border-right: 2px solid #e94560;
}

.note-column-group:last-child {
    border-right: none;
}

/* FX controls in column labels */
.fx-controls {
    display: flex;
    align-items: center;
    padding: 0 2px;
}

.fx-controls button {
    width: 18px;
    height: 18px;
    padding: 0;
    font-size: 0.75em;
    background: #0f3460;
    color: #eee;
    border: 1px solid #1a1a2e;
    cursor: pointer;
    margin: 0 1px;
}

.fx-controls button:hover {
    background: #e94560;
}

/* Per-note-column FX +/- buttons in label row */
.fx-col-controls {
    display: flex;
    align-items: center;
    padding: 0 2px;
    gap: 1px;
}

.fx-col-controls button {
    width: 20px;
    height: 18px;
    padding: 0;
    font-size: 0.7em;
    background: #16213e;
    color: #6c63ff;
    border: 1px solid #1a1a2e;
    cursor: pointer;
    border-radius: 2px;
}

.fx-col-controls button:hover {
    background: #6c63ff;
    color: #fff;
}

/* Note column +/- controls at end of labels row */
.note-col-controls {
    display: flex;
    align-items: center;
    padding: 0 4px;
    gap: 2px;
}

.note-col-controls button {
    width: 24px;
    height: 18px;
    padding: 0;
    font-size: 0.7em;
    background: #4ecca3;
    color: #1a1a2e;
    border: none;
    cursor: pointer;
    border-radius: 2px;
    font-weight: bold;
}

.note-col-controls button:hover {
    background: #e94560;
    color: #fff;
}

/* Legacy support */
.note-columns {
    display: flex;
    border-right: 2px solid #e94560;
}

.note-column {
    display: flex;
}

.cell {
    width: 3em;
    padding: 0.2em;
    text-align: center;
    font-size: 0.8em;
    border-right: 1px solid #1a1a2e;
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
}

/* Prevent text selection during drag */
body.selecting {
    user-select: none;
    -webkit-user-select: none;
    cursor: crosshair;
}

body.selecting * {
    user-select: none;
    -webkit-user-select: none;
}

/* Ensure grid can receive pointer events */
#tracker-grid {
    touch-action: none;
}

/* Enable pointer capture on cells */
.cell {
    touch-action: none;
}

.cell.selected {
    outline: 2px solid #4ecca3;
    outline-offset: -2px;
    background: rgba(78, 204, 163, 0.15);
}

.cell.note {
    color: #4ecca3;
    width: 3.5em;
}

.cell.note-off {
    color: #e94560;
}

.cell.amp {
    color: #ffd93d;
    width: 2.5em;
}

.fx-columns {
    display: flex;
}

.fx-column .cell {
    color: #6c63ff;
    width: 4.5em;
}

/* FX cells within note column groups */
.cell.fx {
    color: #6c63ff;
    width: 4.5em;
}

.column-labels .cell.fx-label {
    color: #6c63ff;
    width: 4.5em;
}

/* Param columns (p6, p7, etc.) */
.param-columns {
    display: flex;
}

.param-column {
    display: flex;
}

.param-column .cell {
    color: #ff9f43;
    width: 3.5em;
}

.cell.param {
    color: #ff9f43;
    width: 3.5em;
}

.column-labels .cell.param-label {
    color: #ff9f43;
    width: 3.5em;
}

/* Single track view */
.track.single-track {
    min-width: auto;
    width: 100%;
}

.track.single-track .track-header {
    position: sticky;
    top: 0;
    z-index: 20;
}

/* Pattern control bar (above columns) */
.pattern-control-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #0f3460;
    padding: 6px 12px;
    border-bottom: 1px solid #1a1a2e;
    position: sticky;
    top: 0;
    z-index: 25;
}

.pattern-instr-select {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pattern-instr-select label {
    font-size: 0.8em;
    color: #4ecca3;
    display: flex;
    align-items: center;
    gap: 4px;
}

.pattern-instr-select select {
    background: #1a1a2e;
    color: #eee;
    border: 1px solid #16213e;
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 0.85em;
    width: 60px;
}

.pattern-col-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pattern-col-controls button {
    background: #1a1a2e;
    color: #eee;
    border: 1px solid #16213e;
    padding: 4px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.75em;
    font-weight: bold;
}

.pattern-col-controls button:hover {
    background: #4ecca3;
    color: #1a1a2e;
}

.pattern-col-controls .control-sep {
    color: #333;
    font-size: 0.8em;
}

/* Editor Container */
.editor-container {
    flex: 1;
    min-width: 20vw;
    max-width: 30vw;
    background: #16213e;
    border-left: 2px solid #0f3460;
    display: flex;
    flex-direction: column;
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: #0f3460;
    color: #e94560;
    font-weight: bold;
    font-size: 0.95em;
}

.editor-header .shortcut-hint {
    font-size: 0.7em;
    color: #888;
    font-weight: normal;
}

.editor-header button {
    background: #4ecca3;
    color: #1a1a2e;
    border: none;
    padding: 5px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-family: inherit;
    font-weight: bold;
    font-size: 0.8em;
}

.editor-header button:hover {
    background: #3db892;
}

/* Main Tabs */
.main-tabs {
    display: flex;
    background: #12122a;
    border-bottom: 2px solid #0f3460;
}

.main-tab {
    flex: 1;
    background: transparent;
    color: #888;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8em;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.main-tab:hover {
    color: #eee;
    background: rgba(233, 69, 96, 0.1);
}

.main-tab.active {
    color: #e94560;
    border-bottom-color: #e94560;
    background: rgba(233, 69, 96, 0.1);
}

/* Tab Content */
.tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tab-content.hidden {
    display: none;
}

/* Instrument Tabs */
.instrument-tabs {
    display: flex;
    flex-wrap: wrap;
    background: #1a1a2e;
    padding: 4px;
    gap: 2px;
}

.instr-tab {
    background: #0f3460;
    color: #888;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.7em;
    border-radius: 3px;
    min-width: 28px;
}

.instr-tab:hover {
    background: #16213e;
    color: #eee;
}

.instr-tab.active {
    background: #e94560;
    color: #fff;
}

.instr-tab.instr-more-btn {
    background: #1a1a2e;
    color: #4ecca3;
    font-weight: bold;
    min-width: 32px;
}

.instr-tab.instr-more-btn:hover {
    background: #4ecca3;
    color: #1a1a2e;
}

.instr-page-info {
    padding: 0.25em 0.5em;
    color: #666;
    font-size: 0.75em;
    align-self: center;
}

#code-editor, #opcodes-editor {
    flex: 1;
    background: #1a1a2e;
    color: #eee;
    border: none;
    border-top: 1px solid #0f3460;
    padding: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    resize: none;
    outline: none;
    line-height: 1.4;
}

#code-editor:focus, #opcodes-editor:focus {
    background: #1f1f3a;
}

/* Opcodes Tab */
.opcodes-info {
    padding: 8px 10px;
    background: #0f3460;
    color: #4ecca3;
    font-size: 0.8em;
}

/* Sample Import Tab */
.sample-controls {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: #1a1a2e;
    align-items: center;
    flex-wrap: wrap;
}

.sample-controls label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85em;
}

.sample-controls input[type="number"] {
    width: 60px;
    background: #0f3460;
    color: #eee;
    border: 1px solid #16213e;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: inherit;
}

.sample-controls button {
    background: #4ecca3;
    color: #1a1a2e;
    border: none;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-family: inherit;
    font-weight: bold;
    font-size: 0.8em;
}

.sample-controls button:hover {
    background: #3db892;
}

.sample-list-header {
    padding: 6px 10px;
    background: #0f3460;
    color: #888;
    font-size: 0.8em;
}

#sample-list {
    flex: 1;
    overflow-y: auto;
    padding: 5px;
    background: #1a1a2e;
    transition: background 0.2s, border-color 0.2s;
    border: 2px dashed transparent;
}

#sample-list.drag-over,
#tab-samples.drag-over {
    background: #1f2a4a;
    border-color: #4ecca3;
}

#tab-samples {
    position: relative;
}

#tab-samples.drag-over::after {
    content: 'Drop audio files here';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #4ecca3;
    font-size: 1.2em;
    pointer-events: none;
}

.sample-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: #16213e;
    margin-bottom: 3px;
    border-radius: 3px;
    font-size: 0.8em;
}

.sample-item .sample-name {
    color: #4ecca3;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.sample-item .sample-name:hover {
    color: #6fffca;
    text-decoration: underline;
}

.sample-item .sample-table {
    color: #ffd93d;
    margin-left: 10px;
    margin-right: 8px;
}

.sample-item button {
    border: none;
    padding: 2px 6px;
    cursor: pointer;
    border-radius: 2px;
    font-size: 0.8em;
}

.sample-item .sample-play-btn {
    background: #4ecca3;
    color: #1a1a2e;
    margin-right: 8px;
    padding: 3px 8px;
}

.sample-item .sample-play-btn:hover {
    background: #6fffca;
}

.sample-item .sample-delete-btn {
    background: #e94560;
    color: #fff;
}

.sample-item .sample-delete-btn:hover {
    background: #ff6b8a;
}

/* Sample Sections Layout */
.sample-sections {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 10px;
    padding: 10px;
}

.sample-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #12122a;
    border-radius: 4px;
    overflow: hidden;
    min-height: 100px;
}

.sample-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #0f3460;
    font-size: 0.9em;
    color: #fff;
}

.sample-section-header button {
    background: #4ecca3;
    color: #1a1a2e;
    border: none;
    padding: 4px 12px;
    cursor: pointer;
    border-radius: 3px;
    font-size: 0.85em;
}

.sample-section-header button:hover {
    background: #6fffca;
}

.sample-section-header button#btn-clear-library {
    background: #e94560;
    color: #fff;
}

.sample-section-header button#btn-clear-library:hover {
    background: #ff6b8a;
}

.sample-section-header .ftable-info {
    font-size: 0.8em;
    color: #ffd93d;
}

.sample-list {
    flex: 1;
    overflow-y: auto;
    padding: 5px;
    background: #1a1a2e;
}

.sample-list.drag-over {
    background: #1f2a4a;
    outline: 2px dashed #4ecca3;
}

.sample-list-empty {
    padding: 15px;
    text-align: center;
    color: #666;
    font-size: 0.8em;
    font-style: italic;
}

.sample-section-info {
    padding: 6px 10px;
    background: #0a0a14;
    font-size: 0.7em;
    color: #666;
}

.sample-section-info code {
    background: #0f3460;
    padding: 1px 4px;
    border-radius: 2px;
    color: #4ecca3;
}

/* Library item - can be loaded to ftable */
.library-item {
    display: flex;
    align-items: center;
    padding: 5px 8px;
    background: #16213e;
    border-radius: 3px;
    margin-bottom: 3px;
    gap: 8px;
}

.library-item:hover {
    background: #1f2a4a;
}

.library-item .sample-name {
    flex: 1;
    color: #aaa;
    font-size: 0.85em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-item .sample-size {
    color: #666;
    font-size: 0.75em;
}

.library-item .btn-load-ftable {
    background: #4ecca3;
    color: #1a1a2e;
    border: none;
    padding: 2px 8px;
    cursor: pointer;
    border-radius: 2px;
    font-size: 0.75em;
}

.library-item .btn-load-ftable:hover {
    background: #6fffca;
}

.library-item .btn-remove {
    background: #e94560;
    color: #fff;
    border: none;
    padding: 2px 6px;
    cursor: pointer;
    border-radius: 2px;
    font-size: 0.75em;
}

.library-item .btn-remove:hover {
    background: #ff6b8a;
}

/* Ftable pool item */
.ftable-item {
    display: flex;
    align-items: center;
    padding: 5px 8px;
    background: #16213e;
    border-radius: 3px;
    margin-bottom: 3px;
    gap: 8px;
    cursor: grab;
    transition: transform 0.1s, opacity 0.1s;
}

.ftable-item:hover {
    background: #1f2a4a;
}

.ftable-item.dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.ftable-item.drag-above {
    border-top: 2px solid #4ecca3;
    margin-top: -2px;
}

.ftable-item.drag-below {
    border-bottom: 2px solid #4ecca3;
    margin-bottom: 1px;
}

.ftable-item .ftable-num {
    color: #ffd93d;
    font-weight: bold;
    font-size: 0.85em;
    min-width: 45px;
}

.ftable-item .sample-name {
    flex: 1;
    color: #4ecca3;
    font-size: 0.85em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.ftable-item .sample-name:hover {
    color: #6fffca;
    text-decoration: underline;
}

.ftable-item .btn-play {
    background: #4ecca3;
    color: #1a1a2e;
    border: none;
    padding: 2px 8px;
    cursor: pointer;
    border-radius: 2px;
    font-size: 0.8em;
}

.ftable-item .btn-play:hover {
    background: #6fffca;
}

.ftable-item .btn-delete {
    background: #e94560;
    color: #fff;
    border: none;
    padding: 2px 6px;
    cursor: pointer;
    border-radius: 2px;
    font-size: 0.75em;
}

.ftable-item .btn-delete:hover {
    background: #ff6b8a;
}

.sample-info {
    padding: 10px;
    background: #12122a;
    font-size: 0.75em;
    color: #888;
    border-top: 1px solid #0f3460;
}

.sample-info code {
    background: #0f3460;
    padding: 2px 6px;
    border-radius: 3px;
    color: #4ecca3;
}

.sample-info p {
    margin-bottom: 5px;
}

/* Console */
#console-container {
    background: #0a0a14;
    border-top: 2px solid #0f3460;
    height: 10em;
    display: flex;
    flex-direction: column;
}

#console-header {
    background: #0f3460;
    padding: 4px 10px;
    font-size: 0.8em;
    color: #4ecca3;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

#btn-toggle-console {
    background: #1a1a2e;
    color: #4ecca3;
    border: 1px solid #4ecca3;
    padding: 2px 8px;
    font-size: 0.9em;
    cursor: pointer;
    border-radius: 3px;
}

#btn-toggle-console:hover {
    background: #4ecca3;
    color: #1a1a2e;
}

.keyboard-hint {
    font-size: 0.85em;
    color: #888;
}

#console {
    flex: 1;
    overflow-y: auto;
    padding: 6px 10px;
    font-size: 0.75em;
    line-height: 1.4;
    color: #aaa;
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
}

#status-bar {
    background: #0f3460;
    padding: 6px 15px;
    font-size: 0.85em;
    color: #4ecca3;
    display: flex;
    justify-content: space-between;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
    background: #0f3460;
    border-radius: 4px;
}

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

/* Drag and drop visual feedback */
.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    background: #e94560;
    padding: 8px 16px;
    border-radius: 4px;
    opacity: 0.9;
}

/* Floating edit input for cell editing */
.cell-edit-input {
    display: none;
    position: fixed;
    z-index: 100;
    background: #0f3460;
    color: #4ecca3;
    border: 2px solid #e94560;
    font-family: 'Courier New', monospace;
    font-size: 0.8em;
    text-align: center;
    outline: none;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

.cell-edit-input:focus {
    background: #1a1a2e;
    border-color: #4ecca3;
}

/* Context Menu */
.context-menu {
    display: none;
    position: fixed;
    z-index: 1000;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    min-width: 150px;
    padding: 4px 0;
}

.context-menu.visible {
    display: block;
}

.context-menu-item {
    padding: 8px 16px;
    cursor: pointer;
    color: #eee;
    font-size: 0.85em;
    transition: background 0.1s;
}

.context-menu-item:hover {
    background: #e94560;
    color: #fff;
}

.context-menu-item.disabled {
    color: #666;
    cursor: default;
}

.context-menu-item.disabled:hover {
    background: transparent;
    color: #666;
}

.context-menu-separator {
    height: 1px;
    background: #0f3460;
    margin: 4px 8px;
}

/* Chords Tab */
.chords-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: #0f3460;
    color: #888;
    font-size: 0.8em;
}

.chords-header label {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #eee;
}

.chords-header input[type="number"] {
    width: 3.5em;
    background: #1a1a2e;
    color: #eee;
    border: 1px solid #16213e;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: inherit;
}

.chord-grid {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    background: #1a1a2e;
}

.chord-row {
    display: flex;
    align-items: center;
    margin-bottom: 2px;
    gap: 2px;
}

.chord-root {
    width: 24px;
    font-weight: bold;
    color: #e94560;
    font-size: 0.75em;
    text-align: center;
    flex-shrink: 0;
}

.chord-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: 2px;
    flex: 1;
    overflow-x: auto;
}

.chord-btn {
    background: #0f3460;
    color: #eee;
    border: none;
    padding: 3px 4px;
    cursor: pointer;
    border-radius: 2px;
    font-family: inherit;
    font-size: 0.65em;
    min-width: 28px;
    flex-shrink: 0;
    transition: background 0.1s;
}

.chord-btn:hover {
    background: #4ecca3;
    color: #1a1a2e;
}

.chord-btn:active {
    background: #e94560;
    color: #fff;
}

.chord-btn.major {
    border-left: 2px solid #4ecca3;
}

.chord-btn.minor {
    border-left: 2px solid #6c63ff;
}

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

/* Base scaling - font size scales with viewport width */
html {
    font-size: clamp(10px, 0.9vw + 4px, 20px);
}

/* High DPI / Retina displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    html {
        font-size: clamp(11px, 0.85vw + 5px, 18px);
    }
}

/* Very small screens */
@media (max-width: 1024px) {
    .header-top {
        flex-wrap: wrap;
        gap: 8px;
    }

    .demo-controls {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
    }
}
