/* ============================================
           CSS VARIABLES
           ============================================ */
        :root {
            --copper: #b87333;
            --copper-light: #d4956a;
        }

        /* ============================================
           APP LAYOUT
           ============================================ */

        .app-container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 20px;
        }

        /* Header */
        .header {
            text-align: center;
            padding: 20px 0 30px;
            user-select: none;
        }

        .header h1 {
            font-size: 2.5rem;
            font-weight: 600;
            letter-spacing: 0.1em;
            color: var(--white);
            margin-bottom: 5px;
        }

        .header .subtitle {
            font-size: 0.9rem;
            font-weight: 300;
            letter-spacing: 0.2em;
            color: var(--gray-500);
            text-transform: lowercase;
        }

        /* Control Bar */
        .control-bar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 20px;
            padding: 15px 20px;
            background: var(--gray-800);
            border-radius: 12px;
            margin-bottom: 20px;
            flex-wrap: wrap;
            user-select: none;
        }

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

        .btn {
            background: var(--gray-700);
            color: var(--white);
            border: none;
            padding: 10px 18px;
            border-radius: 8px;
            cursor: pointer;
            font-family: inherit;
            font-size: 0.85rem;
            font-weight: 400;
            letter-spacing: 0.05em;
            transition: all 0.2s ease;
        }

        .btn:hover {
            background: var(--gray-600);
        }

        .btn:active {
            transform: scale(0.97);
        }

        .btn.primary {
            background: var(--cyan-500);
            color: var(--black);
        }

        .btn.primary:hover {
            background: var(--cyan-400);
        }

        .btn.danger {
            background: var(--red-600);
        }

        .btn.danger:hover {
            background: var(--red-500);
        }

        .btn.success {
            background: var(--green-600);
        }

        .btn.success:hover {
            background: var(--green-500);
        }

        .btn[disabled] {
            opacity: 0.5;
            cursor: not-allowed;
        }

        /* Tempo Control */
        .tempo-control {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .tempo-control label {
            font-size: 0.8rem;
            color: var(--gray-400);
            text-transform: uppercase;
            letter-spacing: 0.1em;
        }

        .tempo-control input {
            width: 70px;
            padding: 8px 10px;
            background: var(--gray-700);
            border: 1px solid var(--gray-600);
            border-radius: 6px;
            color: var(--white);
            font-family: inherit;
            font-size: 0.9rem;
            text-align: center;
        }

        .tempo-control input:focus {
            outline: none;
            border-color: var(--cyan-500);
        }

        /* Key Control */
        .key-control {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .key-control label {
            font-size: 0.8rem;
            color: var(--gray-400);
            text-transform: uppercase;
            letter-spacing: 0.1em;
        }

        .key-control select {
            padding: 8px 12px;
            background: var(--gray-700);
            border: 1px solid var(--gray-600);
            border-radius: 6px;
            color: var(--white);
            font-family: inherit;
            font-size: 0.9rem;
            cursor: pointer;
        }

        .key-control select:focus {
            outline: none;
            border-color: var(--cyan-500);
        }

        /* Time Display */
        .time-display {
            font-family: 'Courier New', monospace;
            font-size: 1.4rem;
            color: var(--cyan-400);
            background: var(--gray-900);
            padding: 8px 16px;
            border-radius: 6px;
            min-width: 120px;
            text-align: center;
        }

        /* File Actions */
        .file-actions {
            display: flex;
            gap: 10px;
        }

        /* ============================================
           TIMELINE
           ============================================ */

        .timeline-container {
            background: var(--gray-800);
            border-radius: 12px;
            overflow: hidden;
            user-select: none;
        }

        .timeline-header {
            display: flex;
            background: var(--gray-700);
            border-bottom: 1px solid var(--gray-600);
        }

        .track-header-add {
            width: 180px;
            min-width: 180px;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0 10px;
            position: relative;
            border-right: 1px solid var(--gray-600);
        }

        .add-track-btn {
            width: 40px;
            height: 24px;
            padding: 0;
            font-size: 1.2rem;
            line-height: 1;
            background: var(--gray-600);
        }

        .add-track-btn:hover {
            background: var(--cyan-500);
            color: var(--black);
        }

        .add-track-menu {
            position: absolute;
            top: 100%;
            left: 50%;
            transform: translateX(-50%);
            background: var(--gray-800);
            border: 1px solid var(--gray-600);
            border-radius: 8px;
            padding: 5px;
            z-index: 100;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        .add-track-option {
            display: block;
            width: 100%;
            padding: 8px 15px;
            background: none;
            border: none;
            color: var(--white);
            font-family: inherit;
            font-size: 0.85rem;
            text-align: left;
            cursor: pointer;
            border-radius: 4px;
            white-space: nowrap;
        }

        .add-track-option:hover {
            background: var(--gray-700);
        }

        /* Timeline Header / Ruler */
        .timeline-ruler {
            flex: 1;
            height: 30px;
            position: relative;
            overflow: hidden;
        }

        .ruler-marks {
            position: absolute;
            top: 0;
            left: 0;
            height: 100%;
            display: flex;
            will-change: transform;
            margin-left: -1px;
        }

        .ruler-bar {
            height: 100%;
            position: relative;
            border-left: 1px solid var(--gray-500);
            flex-shrink: 0;
            box-sizing: border-box;
        }

        .ruler-bar-num {
            position: absolute;
            top: 4px;
            left: 6px;
            font-size: 0.75rem;
            font-weight: 600;
            color: var(--gray-400);
        }

        .ruler-tick {
            position: absolute;
            bottom: 0;
            width: 1px;
            height: 8px;
            background: var(--gray-600);
        }

        .ruler-tick.bar-start {
            height: 12px;
            background: var(--gray-500);
        }

        /* Legacy ruler-mark for compatibility */
        .ruler-mark {
            height: 100%;
            border-left: 1px solid var(--gray-500);
            font-size: 0.75rem;
            font-weight: 600;
            color: var(--gray-400);
            padding-left: 6px;
            padding-top: 5px;
            flex-shrink: 0;
        }

        .ruler-mark.bar-mark {
            border-left: 2px solid var(--gray-500);
        }

        /* Tracks Area */
        .tracks-area {
            min-height: 300px;
            max-height: 500px;
            overflow: auto;
            position: relative;
        }

        .track {
            display: flex;
            border-bottom: 1px solid var(--gray-700);
            min-height: 80px;
        }

        .track-info {
            width: 180px;
            min-width: 180px;
            background: var(--gray-700);
            padding: 10px;
            display: flex;
            flex-direction: column;
            gap: 8px;
            border-right: 1px solid var(--gray-600);
            user-select: none;
            position: sticky;
            left: 0;
            z-index: 5;
        }

        .track-name {
            font-size: 0.85rem;
            font-weight: 500;
            color: var(--white);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

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

        .track-btn {
            background: var(--gray-600);
            border: none;
            color: var(--gray-400);
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 0.7rem;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .track-btn:hover {
            background: var(--gray-500);
            color: var(--white);
        }

        .track-btn.active {
            background: var(--cyan-500);
            color: var(--black);
        }

        .track-btn.delete {
            background: var(--red-600);
            color: var(--white);
        }

        .track-btn.delete:hover {
            background: var(--red-500);
        }

        /* Track Role Badge */
        .track-role-badge {
            display: inline-block;
            padding: 2px 6px;
            border-radius: 3px;
            font-size: 0.65rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            margin-left: 8px;
        }

        .track-role-badge.melody {
            background: #22d3ee;
            color: #000;
        }

        .track-role-badge.harmony {
            background: #22c55e;
            color: #000;
        }

        .track-role-badge.bass {
            background: #a855f7;
            color: #fff;
        }

        /* Track Context Menu */
        .track-context-menu {
            position: fixed;
            background: var(--gray-800);
            border: 1px solid var(--gray-600);
            border-radius: 8px;
            padding: 5px;
            z-index: 1000;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
            min-width: 120px;
        }

        .track-context-menu-item {
            display: flex;
            align-items: center;
            gap: 8px;
            width: 100%;
            padding: 8px 12px;
            background: none;
            border: none;
            color: var(--white);
            font-family: inherit;
            font-size: 0.85rem;
            text-align: left;
            cursor: pointer;
            border-radius: 4px;
        }

        .track-context-menu-item:hover {
            background: var(--gray-700);
        }

        .track-context-menu-item.active {
            background: var(--gray-600);
        }

        .track-context-menu-item .role-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
        }

        .track-context-menu-item .role-dot.melody { background: #22d3ee; }
        .track-context-menu-item .role-dot.harmony { background: #22c55e; }
        .track-context-menu-item .role-dot.bass { background: #a855f7; }

        /* Volume Slider */
        .volume-slider {
            width: 100%;
            height: 4px;
            -webkit-appearance: none;
            appearance: none;
            background: var(--gray-600);
            border-radius: 2px;
            cursor: pointer;
        }

        .volume-slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 12px;
            height: 12px;
            background: var(--cyan-400);
            border-radius: 50%;
            cursor: pointer;
        }

        /* Track Timeline */
        .track-timeline {
            flex: 1;
            position: relative;
            background: var(--gray-800);
            background-image: repeating-linear-gradient(
                90deg,
                var(--gray-700) 0px,
                var(--gray-700) 1px,
                transparent 1px,
                transparent var(--grid-size, 50px)
            );
        }

        .track-timeline.instrument-timeline {
            cursor: crosshair;
        }

        /* Drop target highlight for cross-track dragging */
        .track-timeline.drop-target {
            background-color: rgba(184, 115, 51, 0.2);
            box-shadow: inset 0 0 0 2px var(--copper);
        }

        /* Audio Region */
        .region {
            position: absolute;
            top: 10px;
            height: calc(100% - 20px);
            background: linear-gradient(135deg, var(--purple-500), var(--purple-600));
            border-radius: 6px;
            cursor: grab;
            display: flex;
            align-items: center;
            padding: 0 10px;
            font-size: 0.75rem;
            color: var(--white);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
            overflow: hidden;
            user-select: none;
        }

        .region:active {
            cursor: grabbing;
        }

        .region-waveform {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            opacity: 0.3;
        }

        .region-label {
            position: relative;
            z-index: 1;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        /* Playhead */
        .playhead {
            position: absolute;
            top: 0;
            width: 2px;
            height: 100%;
            background: var(--cyan-400);
            box-shadow: 0 0 10px var(--cyan-400);
            z-index: 100;
            pointer-events: none;
        }

        /* Empty State */
        .empty-state {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 200px;
            color: var(--gray-500);
            font-size: 0.9rem;
            user-select: none;
            cursor: pointer;
            transition: color 0.15s;
        }

        .empty-state:hover {
            color: var(--gray-400);
        }

        /* ============================================
           STATUS BAR
           ============================================ */

        .status-bar {
            margin-top: 20px;
            padding: 10px 15px;
            background: var(--gray-800);
            border-radius: 8px;
            font-size: 0.8rem;
            color: var(--gray-400);
            display: flex;
            justify-content: space-between;
            user-select: none;
        }

        /* ============================================
           PIANO ROLL INLINE EDITOR
           ============================================ */

        .piano-roll-inline {
            background: var(--gray-800);
            border-radius: 0;
            margin-top: -12px;
            padding-top: 12px;
            border-top: 2px solid var(--cyan-500);
            user-select: none;
        }

        .piano-roll-resize-handle {
            height: 10px;
            background: var(--gray-700);
            cursor: ns-resize;
            transition: background 0.15s;
            border-bottom: 3px solid var(--cyan-500);
        }

        .piano-roll-resize-handle:hover,
        .piano-roll-resize-handle.dragging {
            background: var(--gray-600);
        }

        .piano-roll-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 15px;
            border-bottom: 1px solid var(--gray-700);
        }

        .piano-roll-title {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .piano-roll-title span {
            font-weight: 500;
            color: var(--cyan-400);
        }

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

        .piano-roll-controls label {
            font-size: 0.85rem;
            color: var(--gray-400);
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .piano-roll-controls .hint {
            font-size: 0.8rem;
            color: var(--gray-500);
            font-style: italic;
        }

        .piano-roll-controls input {
            width: 50px;
            padding: 5px;
            background: var(--gray-700);
            border: 1px solid var(--gray-600);
            border-radius: 4px;
            color: var(--white);
            font-size: 0.85rem;
            text-align: center;
        }

        .triad-toggle-btn {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 6px 12px;
            background: var(--gray-700);
            border: 1px solid var(--gray-600);
            border-radius: 6px;
            color: var(--gray-400);
            font-family: inherit;
            font-size: 0.8rem;
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .triad-toggle-btn:hover:not(:disabled) {
            background: var(--gray-600);
            color: var(--white);
        }

        .triad-toggle-btn.active {
            background: #22c55e;
            border-color: #16a34a;
            color: #000;
        }

        .triad-toggle-btn:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

        .triad-icon {
            font-size: 1.1rem;
        }

        .piano-roll-container {
            display: flex;
            overflow: hidden;
            height: 250px;
        }

        .piano-keys {
            width: 60px;
            flex-shrink: 0;
            background: var(--gray-800);
            border-right: 2px solid var(--gray-600);
            overflow-y: auto;
            scrollbar-width: none;
        }

        .piano-keys::-webkit-scrollbar {
            display: none;
        }

        .piano-key {
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: flex-end;
            padding-right: 8px;
            font-size: 0.75rem;
            color: var(--gray-400);
            border-bottom: 1px solid var(--gray-700);
            cursor: pointer;
            transition: background 0.1s;
        }

        .piano-key:nth-child(odd) {
            background: rgba(255, 255, 255, 0.02);
        }

        .piano-key:hover {
            background: var(--gray-700);
        }

        .piano-key.black {
            background: rgba(0, 0, 0, 0.35);
            color: var(--gray-500);
        }

        .piano-key.black:hover {
            background: var(--gray-800);
        }

        .piano-grid-wrapper {
            flex: 1;
            overflow: auto;
            margin-left: 120px; /* Align with track timeline (180px track-info - 60px piano keys) */
        }

        .piano-grid {
            display: grid;
            min-width: 100%;
            width: max-content;
            position: relative;
        }
        
        .piano-grid::after {
            content: '';
            display: block;
            height: 17px; /* Space for horizontal scrollbar */
            width: 100%;
        }

        .piano-row {
            display: flex;
            height: 32px;
            border-bottom: 1px solid var(--gray-800);
            position: relative;
        }

        .piano-row:nth-child(odd) {
            background: rgba(255, 255, 255, 0.02);
        }

        .piano-row.black-key {
            background: rgba(0, 0, 0, 0.25);
        }

        .piano-cell {
            width: 25px;
            height: 32px;
            border-right: 1px solid var(--gray-800);
            cursor: pointer;
            transition: background 0.1s;
            flex-shrink: 0;
        }

        .piano-cell:hover {
            background: var(--gray-700);
        }

        .piano-cell.beat-start {
            border-right-color: var(--gray-600);
        }

        .piano-cell.bar-start {
            border-right: 2px solid var(--gray-500);
        }

        /* Note blocks */
        .piano-note {
            position: absolute;
            height: 30px;
            background: var(--cyan-500);
            border-radius: 3px;
            cursor: pointer;
            display: flex;
            align-items: center;
            min-width: 20px;
            box-shadow: inset 0 0 0 1px var(--cyan-400);
            z-index: 10;
        }

        .piano-note:hover {
            background: var(--cyan-400);
        }

        .piano-note .note-body {
            flex: 1;
            height: 100%;
            cursor: move;
        }

        .piano-note.selected {
            background: #eab308;
            box-shadow: inset 0 0 0 2px #facc15, 0 0 8px rgba(234, 179, 8, 0.5);
        }

        .piano-note.selected:hover {
            background: #facc15;
        }

        .piano-note .note-resize {
            width: 8px;
            height: 100%;
            cursor: ew-resize;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 0 3px 3px 0;
        }

        .piano-note .note-resize:hover {
            background: rgba(255, 255, 255, 0.4);
        }

        /* ============================================
           SYNTH CONTROLS PANEL
           ============================================ */

        .synth-controls-panel {
            background: var(--gray-800);
            border-top: 1px solid var(--gray-700);
            padding: 15px 20px;
            display: flex;
            gap: 30px;
            flex-wrap: wrap;
            border-radius: 0 0 12px 12px;
            user-select: none;
        }

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

        .synth-section h4 {
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            color: var(--gray-400);
            margin: 0;
        }

        .synth-knobs {
            display: flex;
            gap: 20px;
        }

        .synth-control {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 5px;
        }

        .synth-control label {
            font-size: 0.7rem;
            color: var(--gray-500);
            text-transform: uppercase;
        }

        .synth-control input[type="range"] {
            width: 80px;
            height: 6px;
            -webkit-appearance: none;
            appearance: none;
            background: var(--gray-700);
            border-radius: 3px;
            cursor: pointer;
        }

        .synth-control input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 14px;
            height: 14px;
            background: var(--cyan-400);
            border-radius: 50%;
            cursor: pointer;
        }

        .knob-value {
            font-size: 0.7rem;
            color: var(--cyan-400);
            font-family: 'Courier New', monospace;
            min-width: 50px;
            text-align: center;
        }

        .wave-selector {
            display: flex;
            gap: 5px;
        }

        .wave-btn {
            width: 36px;
            height: 36px;
            background: var(--gray-700);
            border: 2px solid var(--gray-600);
            border-radius: 6px;
            color: var(--gray-400);
            font-size: 1.1rem;
            cursor: pointer;
            transition: all 0.15s ease;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .wave-btn:hover {
            border-color: var(--gray-500);
            color: var(--white);
        }

        .wave-btn.active {
            background: var(--cyan-500);
            border-color: var(--cyan-400);
            color: var(--black);
        }

        /* ============================================
           BEATS EDITOR PANEL
           ============================================ */

        .beats-editor-inline {
            background: var(--gray-800);
            border-radius: 0;
            margin-top: -12px;
            padding-top: 12px;
            border-top: 2px solid var(--cyan-500);
            user-select: none;
        }

        .beats-editor-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 15px;
            border-bottom: 1px solid var(--gray-700);
        }

        .beats-editor-title {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .beats-editor-title span {
            font-weight: 500;
            color: var(--cyan-400);
        }

        .beats-editor-controls {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .beats-editor-controls .hint {
            font-size: 0.8rem;
            color: var(--gray-500);
            font-style: italic;
        }

        .beats-grid-container {
            padding: 15px;
            max-height: 300px;
            overflow-y: auto;
        }

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

        .beats-row-label {
            width: 80px;
            font-size: 0.8rem;
            font-weight: 600;
            color: var(--white);
            text-transform: uppercase;
            text-align: right;
            padding-right: 12px;
        }

        .beats-row-steps {
            display: flex;
            gap: 4px;
            flex: 1;
        }

        .beats-step {
            flex: 1;
            height: 36px;
            background: var(--gray-700);
            border: none;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.1s ease;
        }

        .beats-step:hover {
            background: var(--gray-600);
        }

        .beats-step.active {
            background: var(--cyan-500);
            box-shadow: 0 0 8px rgba(184, 115, 51, 0.4);
        }

        .beats-step.beat-start {
            margin-left: 8px;
        }

        .beats-step-numbers {
            display: flex;
            gap: 4px;
            margin-left: 80px;
            padding-left: 12px;
            margin-top: 8px;
        }

        .beats-step-number {
            flex: 1;
            text-align: center;
            font-size: 0.7rem;
            color: var(--gray-500);
        }

        .beats-step-number.beat-start {
            margin-left: 8px;
        }

        .beats-row-remove {
            width: 24px;
            height: 24px;
            background: transparent;
            border: none;
            color: var(--gray-500);
            font-size: 1rem;
            cursor: pointer;
            padding: 0;
            margin-left: 8px;
            border-radius: 4px;
            transition: all 0.15s ease;
        }

        .beats-row-remove:hover {
            background: var(--red-600);
            color: var(--white);
        }

        .beats-add-row {
            display: flex;
            align-items: center;
            margin-top: 12px;
            padding-top: 12px;
            border-top: 1px solid var(--gray-700);
        }

        .beats-add-btn {
            width: 36px;
            height: 36px;
            background: var(--gray-700);
            border: 2px dashed var(--gray-500);
            color: var(--cyan-400);
            font-size: 1.5rem;
            font-weight: bold;
            cursor: pointer;
            border-radius: 6px;
            margin-left: 80px;
            transition: all 0.15s ease;
        }

        .beats-add-btn:hover {
            background: var(--gray-600);
            border-color: var(--cyan-500);
        }

        .beats-sound-picker {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.75);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1000;
        }

        .beats-sound-picker-content {
            background: var(--gray-800);
            border: 2px solid var(--cyan-500);
            border-radius: 12px;
            padding: 24px;
            max-width: 500px;
            width: 90%;
            box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
        }

        .beats-sound-picker h3 {
            color: var(--cyan-400);
            margin: 0 0 16px 0;
            font-size: 1.25rem;
        }

        .beats-sound-picker-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 10px;
            margin-bottom: 16px;
        }

        .beats-sound-option {
            padding: 12px 16px;
            background: var(--gray-700);
            border: none;
            border-radius: 6px;
            color: var(--white);
            font-weight: 500;
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .beats-sound-option:hover {
            background: var(--cyan-600);
            transform: scale(1.02);
        }

        .beats-sound-picker-cancel {
            width: 100%;
            padding: 12px;
            background: var(--gray-600);
            border: none;
            border-radius: 6px;
            color: var(--white);
            font-weight: 500;
            cursor: pointer;
        }

        .beats-sound-picker-cancel:hover {
            background: var(--gray-500);
        }

        .beats-effects-panel {
            background: var(--gray-750, #2a2a2a);
            border-top: 1px solid var(--gray-700);
            padding: 15px 20px;
            display: flex;
            gap: 30px;
            flex-wrap: wrap;
        }

        .beats-effects-panel .synth-section h4 {
            color: var(--cyan-400);
        }

        .beats-lofi-toggle {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-top: 8px;
        }

        .beats-lofi-toggle label {
            font-size: 0.85rem;
            color: var(--gray-300);
        }

        .beats-lofi-btn {
            padding: 6px 16px;
            background: var(--gray-700);
            border: 1px solid var(--gray-600);
            border-radius: 4px;
            color: var(--gray-300);
            font-size: 0.85rem;
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .beats-lofi-btn:hover {
            background: var(--gray-600);
        }

        .beats-lofi-btn.active {
            background: var(--cyan-600);
            border-color: var(--cyan-500);
            color: var(--white);
        }

        /* ============================================
           AUDIO EFFECTS PANEL
           ============================================ */

        .audio-effects-panel {
            background: var(--gray-800);
            border-top: 1px solid var(--gray-700);
            padding: 15px 20px;
            border-radius: 0 0 12px 12px;
            user-select: none;
        }

        .audio-effects-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 1px solid var(--gray-700);
        }

        .audio-effects-header span {
            font-weight: 600;
            color: var(--cyan-400);
        }

        .audio-effects-header .close-btn {
            background: var(--gray-700);
            border: none;
            color: var(--gray-400);
            width: 24px;
            height: 24px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 0.8rem;
        }

        .audio-effects-header .close-btn:hover {
            background: var(--gray-600);
            color: var(--white);
        }

        .effects-section {
            display: inline-flex;
            flex-direction: column;
            gap: 10px;
            margin-right: 40px;
            vertical-align: top;
        }

        .effects-section h4 {
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            color: var(--gray-400);
            margin: 0;
        }

        .effect-controls {
            display: flex;
            gap: 20px;
        }

        .effect-control {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 5px;
        }

        .effect-control label {
            font-size: 0.7rem;
            color: var(--gray-500);
            text-transform: uppercase;
        }

        .effect-control input[type="range"] {
            width: 80px;
            height: 6px;
            -webkit-appearance: none;
            appearance: none;
            background: var(--gray-700);
            border-radius: 3px;
            cursor: pointer;
        }

        .effect-control input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 14px;
            height: 14px;
            background: var(--cyan-400);
            border-radius: 50%;
            cursor: pointer;
        }

        .effect-value {
            font-size: 0.7rem;
            color: var(--cyan-400);
            font-family: 'Courier New', monospace;
            min-width: 50px;
            text-align: center;
        }

        /* ============================================
           MIDI REGIONS
           ============================================ */

        .region.midi-region {
            background: linear-gradient(135deg, var(--green-600), var(--green-500));
            cursor: grab;
        }

        .region.midi-region:hover {
            background: linear-gradient(135deg, var(--green-500), var(--green-600));
        }

        .region.piano-region {
            background: linear-gradient(135deg, var(--copper), #a06030);
            cursor: grab;
        }

        .region.piano-region:hover {
            background: linear-gradient(135deg, var(--copper-light), var(--copper));
        }

        .region.beats-region {
            background: linear-gradient(135deg, var(--cyan-500), var(--cyan-400));
            cursor: grab;
        }

        .region.beats-region:hover {
            background: linear-gradient(135deg, var(--cyan-400), var(--cyan-500));
        }

        .region.audio-region {
            background: linear-gradient(135deg, var(--purple-600), var(--purple-500));
            cursor: grab;
        }

        .region.audio-region:hover {
            background: linear-gradient(135deg, var(--purple-500), var(--purple-600));
        }

        /* Drop target highlight for audio tracks */
        .track-timeline.audio-timeline.drop-target {
            background-color: rgba(139, 92, 246, 0.2);
            box-shadow: inset 0 0 0 2px var(--purple-500);
        }

        .region.editing {
            box-shadow: 0 0 0 2px var(--cyan-400), 0 4px 12px rgba(0, 0, 0, 0.4);
        }

        .region.selected {
            box-shadow: 0 0 0 2px var(--yellow-400), 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        /* Region resize handles */
        .region-resize {
            position: absolute;
            top: 50%;
            bottom: 0;
            width: 10px;
            cursor: ew-resize;
            z-index: 5;
        }

        .region-resize.resize-left {
            left: 0;
            border-radius: 6px 0 0 6px;
        }

        .region-resize.resize-right {
            right: 0;
            border-radius: 0 6px 6px 0;
        }

        .region-resize:hover {
            background: rgba(255, 255, 255, 0.2);
        }

        /* Region content area (shows original length vs looped) */
        .region-content {
            position: absolute;
            top: 0;
            left: 0;
            height: 100%;
            pointer-events: none;
            z-index: 1;
        }

        .region:not(.looping) .region-content {
            display: none;
        }

        /* Loop repeat markers */
        .loop-marker {
            position: absolute;
            top: 0;
            height: 100%;
            width: 8px;
            margin-left: -4px;
            pointer-events: none;
            z-index: 2;
        }

        /* Center line */
        .loop-marker::before {
            content: '';
            position: absolute;
            top: 8px;
            bottom: 8px;
            left: 50%;
            width: 1px;
            background: rgba(0, 0, 0, 0.3);
            transform: translateX(-50%);
        }

        /* Top notch - creates rounded corner illusion */
        .loop-marker .notch-top {
            position: absolute;
            top: -3px;
            left: 50%;
            transform: translateX(-50%);
            width: 12px;
            height: 12px;
            background: var(--gray-800);
            border-radius: 50%;
        }

        /* Bottom notch */
        .loop-marker .notch-bottom {
            position: absolute;
            bottom: -3px;
            left: 50%;
            transform: translateX(-50%);
            width: 12px;
            height: 12px;
            background: var(--gray-800);
            border-radius: 50%;
        }

        /* Loop handle - top right corner */
        .region-loop-handle {
            position: absolute;
            top: 0;
            right: 0;
            width: 14px;
            height: 50%;
            cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M17 2l4 4-4 4"/><path d="M3 11v-1a4 4 0 0 1 4-4h14"/><path d="M7 22l-4-4 4-4"/><path d="M21 13v1a4 4 0 0 1-4 4H3"/></svg>') 10 10, e-resize;
            z-index: 6;
            border-radius: 0 6px 0 0;
        }

        .region-loop-handle:hover {
            background: rgba(255, 255, 255, 0.25);
        }

        .region-loop-handle::after {
            content: '';
            position: absolute;
            top: 4px;
            right: 3px;
            width: 6px;
            height: 6px;
            border: 2px solid rgba(255, 255, 255, 0.5);
            border-left: none;
            border-bottom: none;
            border-radius: 0 3px 0 0;
        }

        .midi-region-notes {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            display: flex;
            flex-direction: column;
            justify-content: center;
            padding: 4px;
            pointer-events: none;
        }

        .midi-note-preview {
            height: 2px;
            background: rgba(255, 255, 255, 0.5);
            margin: 1px 0;
            border-radius: 1px;
        }

        /* Track type indicator */
        .track-type {
            font-size: 0.65rem;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: var(--gray-500);
            margin-bottom: 4px;
        }

        .track-type.midi {
            color: var(--green-500);
        }

        .track-type.piano {
            color: var(--copper);
        }

        .track-type.beats {
            color: var(--cyan-400);
        }

        /* ============================================
           MODAL
           ============================================ */

        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.7);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1000;
        }

        .modal {
            background: var(--gray-800);
            border-radius: 12px;
            padding: 25px;
            max-width: 450px;
            width: 90%;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
        }

        .modal h3 {
            margin-bottom: 15px;
            font-size: 1.2rem;
        }

        .modal p {
            color: var(--gray-400);
            margin-bottom: 10px;
            font-size: 0.9rem;
        }

        .modal ul {
            background: var(--gray-900);
            border-radius: 6px;
            padding: 12px 12px 12px 30px;
            margin-bottom: 15px;
            max-height: 150px;
            overflow-y: auto;
        }

        .modal li {
            color: var(--cyan-400);
            font-size: 0.85rem;
            margin-bottom: 5px;
            font-family: 'Courier New', monospace;
        }

        .modal .hint {
            font-size: 0.8rem;
            color: var(--gray-500);
        }

        .modal-actions {
            display: flex;
            gap: 10px;
            margin-top: 20px;
        }

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

        @media (max-width: 768px) {
            .control-bar {
                flex-direction: column;
                gap: 15px;
            }

            .transport-controls,
            .file-actions {
                width: 100%;
                justify-content: center;
            }

            .track-info {
                width: 120px;
                min-width: 120px;
            }

            .header h1 {
                font-size: 1.8rem;
            }
        }

/* ============================================
   COMPOSITION RULE WARNINGS
   ============================================ */
.piano-note .note-warning {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: #f59e0b;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #000;
    font-weight: bold;
    cursor: pointer;
    z-index: 30;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: transform 0.15s ease;
}

.piano-note .note-warning:hover {
    transform: scale(1.2);
    background: #fbbf24;
}

.warning-popup {
    position: fixed;
    background: var(--gray-800);
    border: 1px solid var(--gray-600);
    border-radius: 10px;
    padding: 15px;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    max-width: 280px;
    font-size: 0.85rem;
}

.warning-popup-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: #f59e0b;
    font-weight: 600;
}

.warning-popup-header .warning-icon {
    font-size: 1.2rem;
}

.warning-popup-message {
    color: var(--gray-300);
    margin-bottom: 12px;
    line-height: 1.4;
}

.warning-popup-suggestion {
    background: var(--gray-700);
    padding: 8px 10px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 0.8rem;
    color: var(--gray-400);
}

.warning-popup-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.warning-popup-btn {
    padding: 6px 14px;
    border-radius: 6px;
    border: none;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.warning-popup-btn.accept {
    background: #22c55e;
    color: #000;
}

.warning-popup-btn.accept:hover {
    background: #16a34a;
}

.warning-popup-btn.dismiss {
    background: var(--gray-600);
    color: var(--white);
}

.warning-popup-btn.dismiss:hover {
    background: var(--gray-500);
}