/* =========================================
   1. LAYOUT & CONTAINERS
   ========================================= */
.timeline-view {
    --snap-width: 20px;
    --lane-height: 120px; /* Matches the 120px .timeline-lane height */
}

.piano-roll-container {
    --snap-width: 20px;
    --lane-height: 22px; /* Matches your piano key height */
}


.timeline-area {
    flex-grow: 1;
    min-width: 0;
    min-height: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.timeline-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Ruler stays fixed; only scroller moves */
.timeline-scroller {
    flex: 1;
    min-height: 0;
    overflow-x: auto;
    overflow-y: auto; /* was hidden — enable vertical */
    position: relative;
	scrollbar-width: none;
}

/* =========================================
   3. DYNAMIC GRID & RULER
   ========================================= */
.timeline-ruler,
.piano-roll-ruler {
    height: 24px;
    flex-shrink: 0;
    background-color: var(--bg-surface-2, #2a2a2a);
    background-image: linear-gradient(to right, rgba(255, 255, 255, 0.3) 1px, transparent 1px);
    background-size: var(--snap-width, 20px) 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    position: sticky;
    top: 0;
    z-index: 50;
    overflow: hidden;
    cursor: text;
}

.timeline-content,
.piano-roll-content {
    position: relative;
    min-width: 100%;
    min-height: 100%;
    background-image: 
        linear-gradient(to right, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: var(--snap-width, 20px) var(--lane-height, 16px);
}

/* =========================================
   4. TRACKS, LANES & CLIPS
   ========================================= */
.timeline-tracks-container {
    display: flex;
    flex-direction: column;
    position: relative;
}

.timeline-lane {
    position: relative;
    height: 120px; /* <-- INCREASED FROM 80px */
    border-bottom: 1px solid var(--border-main, #444);
    background: rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    z-index: 1;
}

.timeline-lane.child-channel {
    height: 90px; /* <-- INCREASED FROM 60px */
    background: rgba(0, 0, 0, 0.4);
}

.timeline-item,
.timeline-clip {
    position: absolute;
    height: calc(100% - 2px);
    background: #4a90e2;
    border: 1px solid #2c5a8e;
    border-radius: 3px;
    box-sizing: border-box;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
    z-index: 10 !important;
}

.timeline-item.selected,
.timeline-clip.selected {
    background: #6ab0ff;
    border-color: #fff;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
}

.resize-handle {
    position: absolute;
    top: 0;
    width: 6px;
    height: 100%;
    cursor: ew-resize;
    background: rgba(255, 255, 255, 0.1);
}
.resize-handle:hover { background: rgba(255, 255, 255, 0.4); }
.resize-handle.left { left: 0; }
.resize-handle.right { right: 0; }

/* =========================================
   5. MIDI NOTES & BLOCKS
   ========================================= */
.midi-note-block {
    position: absolute;
    height: 4px;
    background: var(--accent, #00ff88);
    border-radius: 1px;
    opacity: 0.85;
    pointer-events: none;
}
.midi-note-block:hover {
    opacity: 1;
    background: #fff;
    cursor: pointer;
}



/* =========================================
   7. UTILITIES, CURSORS & OVERLAYS
   ========================================= */
.editor-top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.2);
    padding: 6px 12px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.playhead-cursor {
    position: absolute;
    top: 0; 
    bottom: 0;
    width: 2px;
    background: #ff0055;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 0 4px rgba(255, 0, 85, 0.5);
}

.marquee-box {
    position: absolute;
    border: 1px dashed #fff;
    background: rgba(255, 255, 255, 0.1);
    pointer-events: none;
    z-index: 1000;
}

.loop-visual {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(0, 255, 255, 0.2);
    border-left: 2px solid cyan;
    border-right: 2px solid cyan;
    cursor: grab;
    box-sizing: border-box;
    z-index: 10;
}
.loop-visual:active { cursor: grabbing; }

.loop-handle {
    position: absolute;
    top: 0;
    width: 8px;
    height: 100%;
    z-index: 11;
}
.loop-handle.left { left: -4px; cursor: ew-resize; }
.loop-handle.right { right: -4px; cursor: ew-resize; }

/* Dynamic Tool Cursors */
.timeline-view[data-tool="draw"] .timeline-scroller { cursor: crosshair; }
.timeline-view[data-tool="erase"] .timeline-scroller,
.timeline-view[data-tool="erase"] .timeline-item { cursor: not-allowed; }
.timeline-view[data-tool="cut"] .timeline-item { cursor: cell; }

/* Modifier Overrides */
.timeline-view[data-modifier="ctrl"] .timeline-item { cursor: cell !important; }
.timeline-view[data-modifier="shift"] .timeline-item { cursor: copy !important; }


.timeline-item.selected {
  outline: 2px solid #00e5ff;
  outline-offset: -1px;
  z-index: 20;
}
.timeline-marquee {
  z-index: 900 !important;
}
/* Automation clips on arrange */
.timeline-clip--automation,
.timeline-item.timeline-clip--automation {
  background: rgba(180, 100, 255, 0.22) !important;
  border: 1px solid #a64dff !important;
  overflow: hidden;
}
.timeline-automation-label {
  position: absolute;
  left: 4px;
  top: 2px;
  z-index: 2;
  font-size: 10px;
  opacity: 0.9;
  pointer-events: none;
  color: #e8d6ff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.timeline-automation-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* Shared curve editor (automation) */
.curve-editor-host {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 8px;
}
.curve-editor-canvas {
  width: 100%;
  height: 240px;
  display: block;
  background: #1a1a1a;
  touch-action: none;
  border: 1px solid var(--border-main, #333);
  border-radius: 4px;
  cursor: crosshair;
}
.curve-editor-point-list {
  max-height: 160px;
  overflow: auto;
}
.automation-editor-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  gap: 0;
}
.automation-editor-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-main, #333);
  background: var(--bg-elevated, #2a2a2a);
}
.automation-editor-meta,
.automation-editor-range,
.automation-editor-duration {
  font-size: 12px;
  opacity: 0.85;
}
.automation-editor-path {
  font-size: 11px;
  color: var(--accent, #00ff88);
}
.automation-editor-hint {
  opacity: 0.55;
  font-size: 11px;
}
.automation-editor-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px;
}
.automation-editor-playhead {
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: #ff3355;
  pointer-events: none;
  display: block;
  z-index: 5;
}
.automation-editor-playhead.is-hidden {
  display: none;
}
.automation-editor-window .window-content {
  display: flex;
  flex-direction: column;
  padding: 0;
  height: calc(100% - 32px);
}