/* Multi-Track Timeline Design */
.bottom-timeline {
  height: var(--timeline-height);
  background-color: var(--bg-darker);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 60;
  position: relative;
  overflow: hidden;
}

/* Timeline Toolbar & Transport */
.timeline-toolbar {
  height: 38px;
  background-color: var(--bg-dark);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  flex-shrink: 0;
}

.transport-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.transport-btn {
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.transport-btn:hover {
  background: var(--bg-surface);
  color: var(--text-main);
}
.transport-btn.play-btn {
  background: var(--accent-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  width: 32px;
  height: 30px;
}
.transport-btn.play-btn:hover {
  background: var(--accent-hover);
}
.transport-btn.active {
  color: var(--accent-primary);
}

.timeline-timecode-display {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-darkest);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
}
.timecode-val {
  background: transparent;
  border: none;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-primary);
  width: 82px;
  text-align: center;
}
.timecode-divider {
  color: var(--text-dim);
  font-size: 11px;
}
.duration-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.fps-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  background: var(--bg-surface);
  border-radius: var(--radius-xs);
  color: var(--accent-cyan);
  margin-left: 4px;
}

.timeline-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tl-tool-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tl-tool-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--border-muted);
}
.tl-tool-btn.highlight {
  border-color: rgba(139, 92, 246, 0.4);
  color: var(--accent-purple);
  background: rgba(139, 92, 246, 0.1);
}
.tl-tool-btn.highlight:hover {
  background: rgba(139, 92, 246, 0.2);
}

.tl-zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}
.zoom-label {
  font-size: 10px;
  color: var(--text-dim);
}
.slider-sm {
  width: 70px;
  height: 4px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

/* Timeline Main Body */
.timeline-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Left Column: Track Headers */
.timeline-track-headers {
  width: 250px;
  background: var(--bg-darker);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 15;
}

.track-header-top-bar {
  height: 28px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  flex-shrink: 0;
}
.col-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.track-headers-scroll {
  flex: 1;
  overflow-y: hidden;
  overflow-x: hidden;
}

/* Track Header Row */
.track-header-row {
  height: 32px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 6px;
  background: var(--bg-darker);
  transition: background 0.1s ease;
  position: relative;
}
.track-header-row:hover {
  background: var(--bg-surface);
}
.track-header-row.selected {
  background: rgba(59, 130, 246, 0.12);
  border-left: 3px solid var(--accent-primary);
}

.layer-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.layer-name-label {
  flex: 1;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.track-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0.7;
}
.track-header-row:hover .track-actions {
  opacity: 1;
}
.track-action-btn {
  width: 20px;
  height: 20px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  font-size: 11px;
}
.track-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}
.track-action-btn.active {
  color: var(--accent-primary);
}
.track-action-btn.muted {
  color: var(--accent-rose);
}

/* Property Sub-Track Row (When layer track is expanded) */
.subtrack-header-row {
  height: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  padding: 0 8px 0 28px;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}
.subtrack-header-row .subtrack-name {
  flex: 1;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

/* Right Column: Time Ruler & Lanes Viewport */
.timeline-tracks-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: var(--bg-darkest);
}

/* Time Ruler */
.timeline-ruler-container {
  height: 28px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
}
#timeline-ruler-canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.timeline-markers-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 12px;
  pointer-events: none;
}
.timeline-marker-flag {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  width: 10px;
  height: 12px;
  background: var(--accent-amber);
  clip-path: polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%);
  cursor: pointer;
  pointer-events: auto;
}

/* Playhead Needle & Line */
.timeline-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  pointer-events: none;
  z-index: 30;
  left: 0;
}
.playhead-needle {
  position: absolute;
  top: 0;
  left: -6px;
  width: 13px;
  height: 16px;
  background: var(--accent-rose);
  clip-path: polygon(0 0, 100% 0, 100% 60%, 50% 100%, 0 60%);
  pointer-events: auto;
  cursor: ew-resize;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.playhead-line {
  position: absolute;
  top: 16px;
  left: 0;
  bottom: 0;
  width: 1px;
  background: var(--accent-rose);
}

/* Track Lanes Scroll Area */
.timeline-lanes-scroll {
  flex: 1;
  overflow: auto;
  position: relative;
}
.timeline-lanes-content {
  position: relative;
  min-width: 100%;
}

/* Track Lane Row */
.track-lane-row {
  height: 32px;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
  background-image: repeating-linear-gradient(to right, transparent, transparent 39px, rgba(255, 255, 255, 0.02) 40px);
}
.track-lane-row.selected {
  background-color: rgba(59, 130, 246, 0.05);
}

/* Subtrack Lane Row */
.subtrack-lane-row {
  height: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  background-color: rgba(0, 0, 0, 0.15);
  position: relative;
}

/* Clip Bar in Lane */
.timeline-clip {
  position: absolute;
  top: 4px;
  height: 24px;
  border-radius: var(--radius-xs);
  background: rgba(59, 130, 246, 0.4);
  border: 1px solid rgba(59, 130, 246, 0.7);
  display: flex;
  align-items: center;
  padding: 0 6px;
  cursor: grab;
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: var(--shadow-sm);
}
.timeline-clip:active {
  cursor: grabbing;
}
.clip-trim-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: ew-resize;
  background: transparent;
}
.clip-trim-left {
  left: 0;
  border-top-left-radius: var(--radius-xs);
  border-bottom-left-radius: var(--radius-xs);
}
.clip-trim-right {
  right: 0;
  border-top-right-radius: var(--radius-xs);
  border-bottom-right-radius: var(--radius-xs);
}
.clip-trim-handle:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Keyframe Diamond Marker */
.keyframe-diamond {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  width: 9px;
  height: 9px;
  background: #f3f4f6;
  border: 1px solid #14171b;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.1s ease, background 0.1s ease;
}
.keyframe-diamond:hover {
  background: var(--accent-cyan);
  transform: translate(-50%, -50%) rotate(45deg) scale(1.3);
}
.keyframe-diamond.selected {
  background: var(--accent-amber);
  border-color: #fff;
  box-shadow: 0 0 6px var(--accent-amber);
}
