/* --- 5. Timeline --- */
.timeline-panel {
    height: var(--timeline-h);
    background: var(--bg-panel);
    display: flex;
    flex-direction: column;
    position: relative;
    flex: none;
    overflow: hidden;
    min-height: 0;
    border-top: 1px solid var(--border);
    z-index: 60;
}

/* CRITICAL FIX: Remove transition from timeline-panel to prevent drag lag */
/* No transition on resize */

.timeline-header {
    padding: 7px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 44px;
    flex: none;
    overflow-x: auto;
    background: var(--bg-panel-alt);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    position: sticky;
    top: 0;
    z-index: 20;
}
.timeline-header::-webkit-scrollbar { height: 0; }

.timeline-scroll-area {
    flex: 1;
    overflow-x: auto;
    overflow-y: auto;
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    direction: ltr;
    touch-action: pan-x pan-y;
}
.timeline-scroll-area::-webkit-scrollbar { height: 8px; width: 8px; }
.timeline-scroll-area::-webkit-scrollbar-track { background: var(--bg-dark); }
.timeline-scroll-area::-webkit-scrollbar-thumb { background: #3a3d46; border-radius: 4px; }

.tracks-wrapper {
    position: relative;
    min-width: 100%;
    padding-bottom: 50px;
    padding-top: 25px;
}

.timeline-ruler-area {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 25px;
    background: var(--bg-panel-alt);
    border-bottom: 1px solid var(--border);
    z-index: 90;
    cursor: pointer;
}
.timeline-ruler-area:hover { background: var(--bg-hover); }
.timeline-range-overlay {
    position: absolute;
    top: 0;
    height: 100%;
    background: var(--range-color);
    border-left: 1px solid rgba(59,130,246,0.6);
    border-right: 1px solid rgba(59,130,246,0.6);
    pointer-events: auto;
    z-index: 80;
    cursor: grab;
    user-select: none;
}
.timeline-range-overlay:active { cursor: grabbing; }
.timeline-range-overlay .range-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 8px;
    background: rgba(59, 130, 246, 0.25);
    border-left: 1px solid rgba(59,130,246,0.6);
    border-right: 1px solid rgba(59,130,246,0.6);
    cursor: col-resize;
    z-index: 81;
    user-select: none;
}
.timeline-range-overlay .range-handle.left { left: -4px; }
.timeline-range-overlay .range-handle.right { right: -4px; }

.draw-frames-track {
    display: flex;
    align-items: flex-start;
    padding: 2px 0 0 0;
    min-height: 68px;
    height: auto;
    position: relative;
    gap: 2px;
    border-bottom: 1px solid rgba(129, 140, 248, 0.3);
    margin-bottom: 8px;
    background: rgba(129, 140, 248, 0.04);
}
.draw-frames-track::before {
    content: 'DRAW';
    position: absolute;
    left: 4px;
    top: 2px;
    font-size: 9px;
    font-weight: 700;
    color: rgba(129, 140, 248, 0.6);
    letter-spacing: 0.08em;
    pointer-events: none;
    z-index: 5;
}
.draw-frame {
    height: 65px;
    background: #0c0e1a;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: 2px solid rgba(129, 140, 248, 0.4);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.4);
    position: relative;
    font-size: 9px;
    flex-shrink: 0;
    user-select: none;
    overflow: hidden;
    padding-right: 10px;
    transition: border-color 0.1s, color 0.1s;
}
.draw-frame-thumb {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 2px;
    background: rgba(0,0,0,0.5);
    z-index: 1;
}
.draw-frame:hover { border-color: rgba(129, 140, 248, 0.5); color: rgba(129, 140, 248, 0.7); }
.draw-frame.selected {
    outline: 2px solid rgba(129, 140, 248, 0.95);
    outline-offset: -1px;
    box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.25);
    z-index: 2;
}
.draw-frame.active {
    border: 2px solid var(--accent, #818cf8);
    outline: 2px solid rgba(129, 140, 248, 0.6);
    outline-offset: -1px;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
    color: rgba(129, 140, 248, 0.9);
    z-index: 3;
}
.draw-frame.selected {
    border-color: rgba(129, 140, 248, 0.7);
    color: rgba(129, 140, 248, 0.8);
}
.draw-frame:hover .frame-handle {
    opacity: 1;
    background: rgba(129, 140, 248, 0.08);
}

.frames-track {
    display: flex;
    align-items: flex-start;
    padding: 10px 0 0 0;
    height: 85px;
    position: relative;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 5px;
}
.frame {
    height: 65px;
    background: #0c0c0f;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    position: relative;
    font-size: 10px;
    flex-shrink: 0;
    user-select: none;
    overflow: hidden;
    padding-right: 10px;
    transition: border-color 0.1s;
}
.frame:hover { border-color: #4a4d56; }
.frame.selected {
    outline: 2px solid rgba(139, 92, 246, 0.95);
    outline-offset: -1px;
    box-shadow: 0 0 0 1px rgba(139,92,246,0.25);
    z-index: 2;
}
.frame.active {
    border: 2px solid var(--accent);
    outline: 2px solid #818cf8;
    outline-offset: -1px;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.5);
    z-index: 3;
}
/* Inner color stripe - sits above frame background color */
.frame .frame-inner-stripe {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: transparent;
    border-radius: 0 0 3px 3px;
    pointer-events: none;
    z-index: 10;
    transition: background 0.15s;
}
.frame.selected .frame-inner-stripe,
.frame.active .frame-inner-stripe {
    box-shadow: 0 0 0 2px rgba(139,92,246,0.5) inset;
}
