/* ============================================================
   Animation Engine — Timeline editor (CapCut Style)
   Light/Glassmorphism theme, matches TWA app styling
   ============================================================ */

/* ── Playback mode: hide UI ──────────────────────────────────── */

html[data-playing="true"] #twa-sidebar,
html[data-playing="true"] .twa-animation-bar,
html[data-playing="true"] #twa-add-panel,
html[data-playing="true"] .mapboxgl-ctrl-top-right,
html[data-playing="true"] .twa-draw-panel,
html[data-playing="true"] .twa-text-panel {
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0;
  transition: opacity var(--dur-base, 240ms) ease-out;
}

/* ── Esc hint ───────────────────────────────────────────────── */

.ae-esc-hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 8px 18px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--panel-shadow-hover);
  pointer-events: none;
}

.ae-esc-hint.ae-hide {
  display: none !important;
}

/* ── Main horizontal panel: CapCut Style ───────────── */

.twa-animation-bar {
  --ae-bg: rgba(255, 255, 255, 0.78);
  --ae-surface: rgba(0, 0, 0, 0.03);
  --ae-border: rgba(0, 0, 0, 0.1);
  --ae-text: #111111;
  --ae-text-dim: #666666;
  --ae-accent: #1a6fd4;
  --ae-accent-active: #1355a6;
  --ae-diamond: #f0932b;
  --ae-diamond-glow: rgba(240, 147, 43, 0.4);
  --ae-row-h: 30px;
  --ae-bar-margin: 24px; /* Equal left/right margin in all scenarios */

  position: fixed;
  left: calc(var(--canvas-gap) + var(--sidebar-width) + var(--ae-bar-margin));
  bottom: 20px;
  width: calc(100vw - var(--canvas-gap) - var(--sidebar-width) - 2 * var(--ae-bar-margin));
  z-index: 100;
  height: 220px;
  /* Fixed height for consistency */
  max-height: 50vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--ae-bg);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  border-radius: var(--panel-radius, 12px);
  border: 1px solid var(--ae-border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);

  /* Opening animation: scale + slide up + fade */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.92) translateY(24px);
  transition: opacity 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
    transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
    visibility 0.5s,
    left 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Open State */
.twa-animation-bar.ae-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  transform: scale(1) translateY(0);
}

/* Sidebar collapsed: bar expands with same equal margins */
html:has(#twa-sidebar.collapsed) .twa-animation-bar {
  left: var(--ae-bar-margin);
  width: calc(100vw - 2 * var(--ae-bar-margin));
}

.twa-animation-bar.ae-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.92) translateY(24px);
  transition-duration: 0.35s;
}

/* Top Toolbar */
.ae-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

.ae-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ae-play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--ae-accent, #1A6FD4);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}

.ae-play-btn .ae-play-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.ae-play-btn:hover {
  transform: scale(1.05);
  background: #1557b0;
}

.ae-play-btn:active {
  transform: scale(0.95);
}

.ae-time-display {
  font-family: var(--font-mono, monospace);
  font-size: 15px;
  font-weight: 500;
  color: var(--ae-accent, #1A6FD4);
  letter-spacing: 0.5px;
}

.ae-time-display-total {
  color: var(--ae-text-dim);
}

/* Duration preset — blurry glassy, blue theme (play stays black) */
.ae-duration-wrap {
  position: relative;
}
.ae-duration-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 14px;
  font-weight: 500;
  background: rgba(26, 111, 212, 0.12);
  color: var(--ae-accent);
  border: 1px solid rgba(26, 111, 212, 0.25);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.ae-duration-trigger:hover {
  background: rgba(26, 111, 212, 0.18);
  border-color: rgba(26, 111, 212, 0.4);
  box-shadow: 0 2px 8px rgba(26, 111, 212, 0.15);
}
.ae-duration-trigger:active {
  background: rgba(26, 111, 212, 0.22);
}
.ae-duration-arrow {
  opacity: 0.85;
}
.ae-duration-panel {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  padding: 8px;
  min-width: 150px;
  max-height: 280px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid rgba(26, 111, 212, 0.12);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  z-index: 99999;
}
.ae-duration-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}
.ae-duration-opt {
  padding: 6px 10px;
  font-size: 14px;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--ae-accent);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.ae-duration-opt:hover {
  background: rgba(26, 111, 212, 0.08);
}
.ae-duration-opt.active {
  background: rgba(26, 111, 212, 0.14);
  color: var(--ae-accent-active);
  font-weight: 600;
}
.ae-duration-custom-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  margin-top: 4px;
  border-top: 1px solid rgba(26, 111, 212, 0.12);
}
.ae-duration-input {
  width: 48px;
  padding: 4px 6px;
  font-size: 14px;
  border: 1px solid rgba(26, 111, 212, 0.2);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--ae-accent);
  outline: none;
}
.ae-duration-input:focus {
  border-color: var(--ae-accent);
  box-shadow: 0 0 0 1px rgba(26, 111, 212, 0.2);
}
.ae-duration-sec {
  font-size: 13px;
  color: var(--ae-text-dim);
}
.ae-duration-apply {
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 500;
  background: rgba(26, 111, 212, 0.15);
  color: var(--ae-accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.ae-duration-apply:hover {
  background: rgba(26, 111, 212, 0.25);
}

.ae-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ae-add-kf-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.05);
  color: var(--ae-text);
  border: 1px solid var(--ae-border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.ae-add-kf-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

.ae-add-kf-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ae-close-btn {
  padding: 6px;
  font-size: 16px;
  border: none;
  background: transparent;
  color: var(--ae-text-dim);
  cursor: pointer;
  transition: color 0.2s;
}

.ae-close-btn:hover {
  color: #111;
}

/* Body Layout */
.ae-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* Left column: Track labels — each row aligns 1:1 with timeline row */
.ae-track-headers-wrap {
  width: 200px;
  min-width: 200px;
  border-right: 2px solid var(--ae-border);
  background: rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 2;
  position: relative;
  transition: width 0.25s ease;
}

.ae-section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ae-text-dim);
  padding: 8px 12px 4px;
  border-bottom: 1px solid var(--ae-border);
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.03);
}

.ae-track-headers {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  /* Ruler spacer: track heads align 1:1 with timeline rows (ruler is 24px) */
  padding-top: 24px;
}

.ae-track-headers-wrap.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  border-right: none;
  overflow: hidden;
}

.ae-track-headers-wrap.collapsed .ae-section-label {
  display: none;
}

/* Toggle button — on bar root so never clipped by ae-body overflow */
/* Track area always visible — toggle removed */

/* Right side: Timeline */
.ae-timeline-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.ae-timeline-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.02);
}

.ae-timeline-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto;
}

.ae-timeline-section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ae-text-dim);
  padding: 8px 12px 4px;
  border-bottom: 1px solid var(--ae-border);
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.02);
}

.ae-zoom-wrapper {
  display: flex;
  flex-direction: column;
  min-width: 100%;
  flex: 1;
}

/* Zoom controls — CapCut style: − [slider] + ⊡ */
.ae-zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ae-zoom-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.1);
  color: var(--ae-text);
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}

.ae-zoom-btn svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.ae-zoom-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.ae-zoom-btn:active {
  background: rgba(255, 255, 255, 0.28);
  transform: scale(0.94);
}

.ae-zoom-slider-header {
  width: 72px;
  height: 4px;
  accent-color: var(--ae-accent);
  cursor: pointer;
  border-radius: 2px;
}

.ae-zoom-fit-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.1);
  color: var(--ae-text-dim);
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}

.ae-zoom-fit-btn svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.ae-zoom-fit-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.35);
  color: var(--ae-text);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.ae-zoom-fit-btn:active {
  background: rgba(255, 255, 255, 0.28);
  transform: scale(0.94);
}

/* Ruler */
.ae-ruler {
  height: 24px;
  background: rgba(0, 0, 0, 0.05);
  border-bottom: 1px solid var(--ae-border);
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
}

/* Duration bar: ana süre (0–Ns), ruler alanında — weather layer değil */
.ae-ruler-duration-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 6px;
  background: rgba(26, 111, 212, 0.35);
  border-radius: 2px;
  z-index: 0;
}

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

.ae-ruler-tick.major {
  height: 12px;
  background: var(--ae-text);
}

.ae-ruler-label {
  position: absolute;
  top: 2px;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  color: var(--ae-text-dim);
  transform: translateX(-50%);
}

/* Track type — kompakt nokta + harf */
.ae-track-type-dot {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: default;
}

.ae-track-type-symbol {
  background: rgba(155, 89, 182, 0.25);
  color: #6c3483;
}

.ae-track-type-draw {
  background: rgba(46, 204, 113, 0.25);
  color: #1e8449;
}

.ae-track-type-weather {
  background: rgba(52, 152, 219, 0.25);
  color: #1a5276;
}

/* Track header sol kenar — timeline satırıyla aynı renk, eşleşme net */
.ae-track-head:has(.ae-track-type-symbol)::before,
.ae-track-head:has(.ae-track-type-draw)::before,
.ae-track-head:has(.ae-track-type-weather)::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  pointer-events: none;
}
.ae-track-head:has(.ae-track-type-symbol)::before { background: rgba(108, 52, 131, 0.7); }
.ae-track-head:has(.ae-track-type-draw)::before   { background: rgba(30, 132, 73, 0.7); }
.ae-track-head:has(.ae-track-type-weather)::before { background: rgba(52, 152, 219, 0.6); }

/* Track Header Cell */
.ae-track-head {
  position: relative;
  height: var(--ae-row-h);
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--ae-border);
  box-sizing: border-box;
  cursor: pointer;
}

.ae-track-head.selected {
  background: rgba(0, 0, 0, 0.08);
}

.ae-track-head:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* Row index — track ile timeline satırı 1:1 eşleşmesi */
.ae-track-index {
  flex-shrink: 0;
  width: 18px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ae-text-dim);
  opacity: 0.8;
}

.ae-track-icon {
  width: 20px;
  height: 20px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.ae-track-icon img {
  max-width: 14px;
  max-height: 14px;
}

.ae-track-icon .ae-track-thumb {
  width: 20px;
  height: 20px;
  object-fit: contain;
  border-radius: 4px;
}

.ae-track-title {
  font-size: 14px;
  color: var(--ae-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Track Timeline Row */
.ae-tracks-list {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.ae-track-row {
  height: var(--ae-row-h);
  border-bottom: 1px solid var(--ae-border);
  position: relative;
  box-sizing: border-box;
}

.ae-track-row:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

/* Row index — timeline tarafında, track ile hizalı */
.ae-track-row-index {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 600;
  color: var(--ae-text-dim);
  background: rgba(255,255,255,0.7);
  padding: 1px 4px;
  border-radius: 3px;
  z-index: 2;
  pointer-events: none;
}

/* Hover: track header ve timeline satırı birlikte vurgula */
.ae-track-head.ae-highlighted,
.ae-track-row.ae-highlighted {
  background: rgba(26, 111, 212, 0.14) !important;
  box-shadow: inset 0 0 0 1px rgba(26, 111, 212, 0.25);
}

/* Sol kenar rengi — track header ile timeline satırı eşleşmesi */
.ae-track-row-type-symbol { box-shadow: inset 3px 0 0 rgba(108, 52, 131, 0.7); }
.ae-track-row-type-draw   { box-shadow: inset 3px 0 0 rgba(30, 132, 73, 0.7); }
.ae-track-row-type-weather { box-shadow: inset 3px 0 0 rgba(52, 152, 219, 0.6); }

/* The visual bar inside the track */
.ae-track-strip {
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 100%;
  background: rgba(26, 111, 212, 0.2);
  border-radius: 4px;
  border: 1px solid rgba(26, 111, 212, 0.4);
  pointer-events: auto;
}

/* Playhead overlay — fixed in viewport, always visible */
.ae-playhead-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 25;
}

.ae-playhead-overlay .ae-playhead-handle {
  pointer-events: auto;
}

/* Playhead — kırmızı zaman göstergesi, her zaman net görünür */
.ae-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #ff4757;
  box-shadow: 0 0 6px rgba(255, 71, 87, 0.6);
  z-index: 26;
  pointer-events: none;
  transition: left 0.08s linear;
}
.ae-playhead.ae-dragging {
  transition: none;
}

.ae-playhead-handle {
  position: absolute;
  top: 0;
  width: 14px;
  height: 14px;
  background: #ff4757;
  left: -6px;
  clip-path: polygon(0 0, 100% 0, 100% 60%, 50% 100%, 0 60%);
  cursor: grab;
  box-shadow: 0 1px 4px rgba(255, 71, 87, 0.5);
}

.ae-playhead-handle:active {
  cursor: grabbing;
}

/* Keyframe Diamonds */
.ae-keyframe {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  background: var(--ae-diamond);
  box-shadow: 0 0 6px var(--ae-diamond-glow);
  transform: translate(-50%, -50%) rotate(45deg);
  cursor: grab;
  z-index: 5;
  transition: transform 0.1s, box-shadow 0.1s;
}

.ae-keyframe:hover {
  transform: translate(-50%, -50%) rotate(45deg) scale(1.2);
  box-shadow: 0 0 10px var(--ae-diamond-glow);
}

.ae-keyframe:active {
  cursor: grabbing;
  transform: translate(-50%, -50%) rotate(45deg) scale(1.1);
}

/* Spacer for scrolling */
.ae-track-spacer {
  height: 24px;
  /* for ruler */
}

/* Floating Popover */
.ae-popover {
  position: fixed;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  padding: 10px;
  width: 180px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  transform: translateX(-50%) translateY(10px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ae-popover.active {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  transform: translateX(-50%) translateY(0);
}

.ae-popover-arrow {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: rgba(255, 255, 255, 0.95);
  border-right: 1px solid rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.ae-popover h4 {
  margin: 0;
  font-size: 13px;
  color: var(--ae-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ae-popover hr {
  margin: 0;
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.ae-popover label {
  font-size: 13px;
  color: var(--ae-text);
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

.ae-pop-extra-props {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding-top: 8px;
  margin-top: 4px;
}

.ae-pop-slider {
  width: 100%;
}

.ae-pop-select {
  width: 100%;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: #111;
  border-radius: 4px;
  padding: 4px;
  font-size: 13px;
}

.ae-pop-del-btn {
  background: rgba(255, 60, 60, 0.15);
  color: #ff4757;
  border: 1px solid rgba(255, 60, 60, 0.3);
  padding: 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s;
}

.ae-pop-del-btn:hover {
  background: rgba(255, 60, 60, 0.3);
}

.ae-pop-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  color: #888;
  cursor: pointer;
}

.ae-pop-close:hover {
  color: #111;
}

/* ============================================================
   Clip-Bar Timeline — new CapCut-style additions
   ============================================================ */

/* Track name (new template uses .ae-track-name) */
.ae-track-name {
  font-size: 14px;
  color: var(--ae-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Scroll area that wraps playhead + tracks-list inside timeline-container */
.ae-tracks-scroll-area {
  position: relative;
  flex: 1;
  min-height: 0;
}

/* ── Weather bar (full-width, read-only) ─────────────────────── */

.ae-weather-bar {
  position: absolute;
  left: 2%;
  right: 2%;
  top: 50%;
  transform: translateY(-50%);
  height: 60%;
  max-height: 16px;
  background: linear-gradient(90deg, rgba(26,111,212,0.25) 0%, rgba(26,111,212,0.18) 100%);
  border: 1px solid rgba(26,111,212,0.35);
  border-radius: 4px;
  cursor: default;
  overflow: hidden;
}

/* ── No-clip row hint ────────────────────────────────────────── */

.ae-track-row.ae-no-clip {
  background: transparent;
}

/* Per-row hint — adds clip for THIS track only */
.ae-add-clip-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 13px;
  color: var(--ae-text-dim, #666);
  font-weight: 500;
  padding: 4px 12px;
  border: 1px dashed rgba(0,0,0,0.2);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ae-add-clip-hint:hover {
  background: rgba(0,0,0,0.04);
  border-color: rgba(26,111,212,0.5);
  color: var(--ae-accent, #1a6fd4);
}

/* ── Clip bar (main draggable element) ───────────────────────── */
/* Base + asset-type colors: symbol=purple, draw=green (matches track badges) */

.ae-clip-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 60%;
  max-height: 16px;
  display: flex;
  align-items: stretch;
  border-radius: 5px;
  background: rgba(26,111,212,0.22);
  border: 1.5px solid rgba(26,111,212,0.55);
  cursor: grab;
  box-sizing: border-box;
  overflow: hidden;
  user-select: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ae-clip-bar-type-symbol {
  background: rgba(155, 89, 182, 0.28);
  border-color: rgba(108, 52, 131, 0.65);
}

.ae-clip-bar-type-draw {
  background: rgba(46, 204, 113, 0.28);
  border-color: rgba(30, 132, 73, 0.65);
}

.ae-clip-bar:hover {
  border-color: rgba(26,111,212,0.85);
  box-shadow: 0 0 0 2px rgba(26,111,212,0.15);
}

.ae-clip-bar-type-symbol:hover {
  border-color: rgba(108, 52, 131, 0.9);
  box-shadow: 0 0 0 2px rgba(155, 89, 182, 0.2);
}

.ae-clip-bar-type-draw:hover {
  border-color: rgba(30, 132, 73, 0.9);
  box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.2);
}

/* Asset adı — timeline bar üzerinde */
.ae-clip-label {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.95);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 24px);
  pointer-events: none;
  z-index: 1;
}

.ae-clip-bar:active {
  cursor: grabbing;
}

/* ── Resize handles ──────────────────────────────────────────── */

.ae-clip-handle {
  flex-shrink: 0;
  width: 7px;
  background: rgba(26,111,212,0.5);
  cursor: ew-resize;
  position: relative;
  z-index: 3;
  transition: background 0.15s;
}

.ae-clip-handle:hover {
  background: rgba(26,111,212,0.9);
}

/* Vertical grip lines */
.ae-clip-handle::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 40%;
  background: rgba(255,255,255,0.6);
  border-radius: 1px;
}

/* ── Effect zones (in / out) ─────────────────────────────────── */

.ae-clip-zone {
  flex-shrink: 0;
  height: 100%;
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: opacity 0.15s;
  min-width: 6px;
}

.ae-clip-zone:hover {
  opacity: 0.8;
}

.ae-clip-in {
  background: repeating-linear-gradient(
    -45deg,
    rgba(255,255,255,0.25),
    rgba(255,255,255,0.25) 2px,
    transparent 2px,
    transparent 6px
  );
  border-right: 1px solid rgba(255,255,255,0.3);
}

.ae-clip-out {
  background: repeating-linear-gradient(
    45deg,
    rgba(0,0,0,0.1),
    rgba(0,0,0,0.1) 2px,
    transparent 2px,
    transparent 6px
  );
  border-left: 1px solid rgba(255,255,255,0.2);
}

/* Middle filler — grows to fill remaining space */
.ae-clip-mid {
  flex: 1;
  min-width: 0;
}

/* ── Effect Picker popup ─────────────────────────────────────── */

.ae-effect-picker {
  position: fixed;
  z-index: 2000;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 14px;
  padding: 13px 15px;
  width: 218px;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.28),
    0 2px 8px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(6px) scale(0.98);
  transition: opacity 0.18s, transform 0.18s, visibility 0.18s;
}

.ae-effect-picker.active {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

.ae-ep-title {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  color: var(--ae-text-dim, #888);
  text-transform: uppercase;
  letter-spacing: 1.1px;
}

.ae-ep-btns {
  display: flex;
  gap: 4px;
}

.ae-ep-btns button {
  flex: 1;
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans, sans-serif);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--ae-text, #111);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  backdrop-filter: blur(4px);
}

.ae-ep-btns button:hover {
  background: rgba(26, 111, 212, 0.08);
  border-color: rgba(26, 111, 212, 0.35);
  color: #1a6fd4;
}

.ae-ep-btns button.active {
  background: var(--ae-accent, #1a6fd4);
  border-color: var(--ae-accent, #1a6fd4);
  color: #fff;
  box-shadow: 0 2px 8px rgba(26, 111, 212, 0.3);
}

.ae-ep-dur-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ae-ep-dur-label {
  font-size: 13px;
  color: var(--ae-text-dim, #666);
  flex-shrink: 0;
}

.ae-ep-dur-slider {
  flex: 1;
  accent-color: var(--ae-accent, #1a6fd4);
  cursor: pointer;
}

.ae-ep-dur-val {
  font-size: 13px;
  font-family: var(--font-mono, monospace);
  color: var(--ae-text, #111);
  min-width: 28px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Add Clip button (header) — adds clips to ALL unclipped elements ────────────────────────────────── */

.ae-add-clip-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  background: var(--ae-accent, #1a6fd4);
  color: #fff;
  border: 1px solid rgba(26,111,212,0.6);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.ae-add-clip-btn:hover {
  background: var(--ae-accent-active, #1355a6);
  border-color: rgba(26,111,212,0.9);
}

/* ── Empty state ─────────────────────────────────────────────── */

.ae-empty-msg {
  padding: 24px 16px;
  font-size: 14px;
  color: var(--ae-text-dim, #666);
  text-align: center;
  line-height: 1.6;
}

/* ── Keyframe diamonds on clip bar ──────────────────────────── */
.ae-kf-diamond {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  background: var(--ae-diamond, #f0932b);
  box-shadow: 0 0 4px rgba(240, 147, 43, 0.5);
  transform: translate(-50%, -50%) rotate(45deg);
  cursor: grab;
  z-index: 6;
  transition: transform 0.1s, box-shadow 0.1s;
  pointer-events: auto;
  flex-shrink: 0;
}

.ae-kf-diamond:hover {
  transform: translate(-50%, -50%) rotate(45deg) scale(1.3);
  box-shadow: 0 0 8px rgba(240, 147, 43, 0.8);
}

.ae-kf-diamond:active {
  cursor: grabbing;
}

/* ── Keyframe stamp button in track header ───────────────────── */
.ae-kf-stamp-btn {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
  padding: 0;
  border: 1px solid rgba(240, 147, 43, 0.4);
  border-radius: 6px;
  background: rgba(240, 147, 43, 0.08);
  color: var(--ae-diamond, #f0932b);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s, transform 0.1s, background 0.15s, border-color 0.15s;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ae-track-head:hover .ae-kf-stamp-btn {
  opacity: 1;
}

.ae-kf-stamp-btn:hover {
  transform: scale(1.08);
  background: rgba(240, 147, 43, 0.18);
  border-color: rgba(240, 147, 43, 0.7);
}

.ae-kf-stamp-btn:active {
  transform: scale(0.95);
  background: rgba(240, 147, 43, 0.25);
}

/* ── Keyframe popover ────────────────────────────────────────── */
.ae-kf-popover {
  position: fixed;
  z-index: 2100;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 10px;
  padding: 10px 12px;
  width: 180px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}

.ae-kf-popover.active {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  transform: translateY(0);
}

.ae-kfp-title {
  font-size: 13px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.ae-kfp-props {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ae-kfp-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #333;
}

.ae-kfp-row span:first-child {
  color: #888;
}

.ae-kfp-del-btn {
  background: rgba(255,60,60,0.12);
  color: #e53935;
  border: 1px solid rgba(255,60,60,0.25);
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.ae-kfp-del-btn:hover {
  background: rgba(255,60,60,0.25);
}