/* Advanced Editor — Transition / Zoom / Auto Insert / Giphy / Free PNG */

/* Visible scroll affordance on tool panels (users must see more content below) */
.ae-right-panels-scroll,
.ae-tool-rail-scroll,
#right-panels-container .overflow-y-auto,
#ts-body,
#layer-body,
#asset-panel-grid,
#ai-chat-messages,
.ae-media-grid {
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: #9A9890 #1E1E22;
}

/* Only the outermost rail traps the scroll chain. Inner panel bodies must let the
   wheel bubble up, otherwise `contain` on a non-overflowing body swallows the event
   and the rail can only be moved by dragging its scrollbar. */
.ae-right-panels-scroll,
.ae-tool-rail-scroll {
  overscroll-behavior: contain;
}

#right-panels-container .overflow-y-auto,
#ts-body,
#layer-body,
#asset-panel-grid,
.ae-media-grid {
  overscroll-behavior: auto;
}

#ai-chat-messages {
  overscroll-behavior: contain;
}

.ae-right-panels-scroll::-webkit-scrollbar,
.ae-tool-rail-scroll::-webkit-scrollbar,
#right-panels-container .overflow-y-auto::-webkit-scrollbar,
#ts-body::-webkit-scrollbar,
#layer-body::-webkit-scrollbar,
#asset-panel-grid::-webkit-scrollbar,
#ai-chat-messages::-webkit-scrollbar,
.ae-media-grid::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.ae-right-panels-scroll::-webkit-scrollbar-track,
.ae-tool-rail-scroll::-webkit-scrollbar-track,
#right-panels-container .overflow-y-auto::-webkit-scrollbar-track,
#ts-body::-webkit-scrollbar-track,
#layer-body::-webkit-scrollbar-track,
#asset-panel-grid::-webkit-scrollbar-track,
#ai-chat-messages::-webkit-scrollbar-track,
.ae-media-grid::-webkit-scrollbar-track {
  background: #1E1E22;
  border-radius: 6px;
}

.ae-right-panels-scroll::-webkit-scrollbar-thumb,
.ae-tool-rail-scroll::-webkit-scrollbar-thumb,
#right-panels-container .overflow-y-auto::-webkit-scrollbar-thumb,
#ts-body::-webkit-scrollbar-thumb,
#layer-body::-webkit-scrollbar-thumb,
#asset-panel-grid::-webkit-scrollbar-thumb,
#ai-chat-messages::-webkit-scrollbar-thumb,
.ae-media-grid::-webkit-scrollbar-thumb {
  background: #6E6C66;
  border-radius: 6px;
  border: 2px solid #1E1E22;
}

.ae-right-panels-scroll::-webkit-scrollbar-thumb:hover,
.ae-tool-rail-scroll::-webkit-scrollbar-thumb:hover,
#right-panels-container .overflow-y-auto::-webkit-scrollbar-thumb:hover,
#ts-body::-webkit-scrollbar-thumb:hover,
#layer-body::-webkit-scrollbar-thumb:hover,
#asset-panel-grid::-webkit-scrollbar-thumb:hover,
#ai-chat-messages::-webkit-scrollbar-thumb:hover,
.ae-media-grid::-webkit-scrollbar-thumb:hover {
  background: #9A9890;
}

.timeline-clip.is-loading,
.timeline-audio.is-loading {
  outline: 1px dashed rgba(214, 255, 58, 0.55);
  outline-offset: -1px;
}

.clip-loading-badge {
  position: absolute;
  left: 6px;
  right: auto;
  top: 4px;
  bottom: auto;
  height: auto;
  max-width: calc(100% - 12px);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(12, 12, 14, 0.78);
  color: #F2F0EA;
  font-size: 9px;
  font-weight: 600;
  pointer-events: none;
  text-align: left;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clip-loading-badge .spin {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(214, 255, 58, 0.35);
  border-top-color: #D6FF3A;
  border-radius: 50%;
  animation: ae-clip-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes ae-clip-spin {
  to { transform: rotate(360deg); }
}

@keyframes ae-layer-focus {
  0% { box-shadow: 0 0 0 0 rgba(214, 255, 58, 0.55); }
  100% { box-shadow: 0 0 0 6px rgba(214, 255, 58, 0); }
}

.ae-layer-focus-pulse {
  animation: ae-layer-focus 650ms ease-out;
}

.kl-depth-row:focus-within {
  border-color: rgba(214, 255, 58, 0.65);
}

.ae-tool-rail-scroll > .has-tooltip,
.ae-tool-rail-scroll > .ae-tool-btn {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
}

/* Hide in-rail absolute tooltips — they get clipped by the Assets/Layer panel.
   Floating tip (#ae-rail-float-tip) is used instead. */
#ae-right-tool-rail .tooltip {
  display: none !important;
}

#ae-right-tool-rail {
  position: relative;
  z-index: 80;
  flex-shrink: 0;
  width: 4.5rem;
  min-width: 4.5rem;
  overflow-x: visible !important;
  overflow-y: auto;
}

.ae-tool-btn {
  flex: 0 0 auto;
  width: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  padding: 5px 2px 4px;
}

.ae-tool-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.ae-tool-btn.tool-active {
  background: rgba(214, 255, 58, 0.12);
  box-shadow: inset 2px 0 0 #d6ff3a;
}

.ae-tool-label {
  display: block;
  max-width: 4.2rem;
  font-size: 9px;
  line-height: 1.2;
  text-align: center;
  color: rgba(220, 218, 232, 0.95);
  font-weight: 700;
  letter-spacing: 0.01em;
  word-break: break-word;
}

.ae-tool-btn.tool-active .ae-tool-label {
  color: #d6ff3a;
}

.ae-tool-btn .material-symbols-outlined {
  font-size: 22px;
  line-height: 1;
}

#ae-left-chrome {
  overflow: visible !important;
  z-index: 50;
}

#ae-left-chrome #right-panels-container {
  z-index: 40;
  position: relative;
  overflow-x: hidden;
}

#ae-left-chrome #right-panels-container.ae-panels-open {
  box-shadow: 8px 0 24px rgba(0, 0, 0, 0.35);
}

/* Floating rail tooltip — always above panels */
#ae-rail-float-tip {
  position: fixed;
  z-index: 2147483646;
  display: none;
  max-width: 14rem;
  padding: 6px 10px;
  border-radius: 8px;
  background: #1a1230;
  border: 1px solid rgba(214, 255, 58, 0.45);
  color: #f2f0ea;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  white-space: normal;
}

#ae-rail-float-tip.is-on {
  display: block;
}

#ae-new-tools-bar {
  display: none !important;
}

.ae-tl-tool-new {
  color: #c4b5fd !important;
}

.ae-tl-tool-new:hover {
  color: #d6ff3a !important;
}

/* Layer FX collapsible sections */
.ae-ly-collapse {
  overflow: hidden;
}
.ae-ly-collapse__sum {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.ae-ly-collapse__sum::-webkit-details-marker { display: none; }
.ae-ly-collapse__sum::after {
  content: 'expand_more';
  font-family: 'Material Symbols Outlined';
  margin-left: auto;
  font-size: 14px;
  opacity: 0.7;
  transition: transform 0.15s ease;
}
.ae-ly-collapse[open] > .ae-ly-collapse__sum::after {
  transform: rotate(180deg);
}
.ae-ly-collapse__body {
  padding: 0 8px 8px;
}

/* Mask preview overlay */
#ae-mask-overlay {
  position: absolute;
  z-index: 55;
  pointer-events: none;
  box-sizing: border-box;
}
#ae-mask-overlay:not(.hidden) {
  pointer-events: auto;
}
#ae-mask-overlay .ae-mask-box {
  position: absolute;
  inset: 0;
  border: 1.5px solid #f472b6;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
  cursor: move;
  border-radius: 2px;
}
#ae-mask-overlay.is-ellipse .ae-mask-box {
  border-radius: 50%;
}
#ae-mask-overlay .ae-mask-h {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 2px;
  background: #f9a8d4;
  border: 1px solid #831843;
  padding: 0;
  pointer-events: auto;
  z-index: 2;
}
#ae-mask-overlay .ae-mask-h[data-h="nw"] { left: 0; top: 0; cursor: nwse-resize; }
#ae-mask-overlay .ae-mask-h[data-h="n"] { left: 50%; top: 0; cursor: ns-resize; }
#ae-mask-overlay .ae-mask-h[data-h="ne"] { left: 100%; top: 0; cursor: nesw-resize; }
#ae-mask-overlay .ae-mask-h[data-h="e"] { left: 100%; top: 50%; cursor: ew-resize; }
#ae-mask-overlay .ae-mask-h[data-h="se"] { left: 100%; top: 100%; cursor: nwse-resize; }
#ae-mask-overlay .ae-mask-h[data-h="s"] { left: 50%; top: 100%; cursor: ns-resize; }
#ae-mask-overlay .ae-mask-h[data-h="sw"] { left: 0; top: 100%; cursor: nesw-resize; }
#ae-mask-overlay .ae-mask-h[data-h="w"] { left: 0; top: 50%; cursor: ew-resize; }

#ae-timeline-toolbar .has-tooltip .tooltip {
  pointer-events: none;
}
.timeline-clip .clip-wave,
.timeline-audio .clip-wave {
  opacity: 1;
  z-index: 3;
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  pointer-events: none;
  display: block;
}

.ae-zoom-blocks {
  display: grid;
  gap: 8px;
}
.ae-zoom-block {
  border: 1px solid rgba(145, 143, 161, 0.25);
  border-radius: 12px;
  padding: 8px;
  background: rgba(16, 16, 24, 0.35);
}
.ae-zoom-block h4 {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #d6ff3a;
  text-align: center;
}

#rail-text-motion,
#rail-kinetic,
#rail-objects,
#rail-zoom {
  display: none;
}

.ae-embedded-section {
  flex: 0 0 auto;
  border-top: 1px solid #2A2A2E;
  padding-top: 6px;
}

.ae-embedded-section > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 6px;
  color: #F2F0EA;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.ae-embedded-section > summary::-webkit-details-marker {
  display: none;
}

.ae-embedded-section > summary:hover {
  background: #1E1E22;
  color: #D6FF3A;
}

.ae-embedded-section[open] > summary {
  color: #D6FF3A;
  background: rgba(214, 255, 58, 0.06);
}

.ae-embedded-panel {
  display: block;
  min-height: 0 !important;
  max-height: none !important;
  margin-top: 6px;
  padding: 6px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.ae-embedded-panel.hidden {
  display: none !important;
}

.ae-embedded-panel > :first-child {
  display: none;
}

#panel-text.ae-has-embedded,
#panel-layer.ae-has-embedded {
  overflow-y: auto;
}

#panel-layer.ae-has-embedded {
  max-height: none !important;
  height: 100%;
}

#subtitle-editor-panel {
  transition: width 180ms ease, opacity 140ms ease;
}

.ae-studio-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

/* Giphy / Free PNG: 2 large cards per row, scroll for more */
.ae-studio-grid.ae-media-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 8px;
}

.ae-media-grid .ae-studio-card {
  border-radius: 12px;
  background: #12131a;
}

.ae-media-grid .ae-studio-card__thumb {
  aspect-ratio: 1 / 1;
  min-height: 140px;
  background:
    radial-gradient(circle at 30% 20%, rgba(167, 139, 250, 0.12), transparent 55%),
    #0b0c12;
}

.ae-media-grid .ae-studio-card__thumb img,
.ae-media-grid .ae-studio-card__thumb video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
}

/* Free PNG: Openverse thumbs are often wide banners — cover fills the square like Giphy cards */
.ae-media-grid .ae-studio-card__thumb--cover,
#ae-png-grid .ae-studio-card__thumb {
  background:
    linear-gradient(45deg, #1a1b22 25%, transparent 25%),
    linear-gradient(-45deg, #1a1b22 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1a1b22 75%),
    linear-gradient(-45deg, transparent 75%, #1a1b22 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #0b0c12;
}

.ae-media-grid .ae-studio-card__thumb--cover img,
#ae-png-grid .ae-studio-card__thumb img {
  object-fit: cover;
  object-position: center;
}

.ae-media-grid .ae-studio-card__label {
  padding: 8px 10px 4px;
  font-size: 11px;
}

.ae-media-grid .ae-studio-card__add {
  width: calc(100% - 16px);
  margin: 0 8px 10px;
  padding: 8px 0;
  border-radius: 8px;
  font-size: 11px;
}

.ae-studio-card {
  border: 1px solid #2A2A2E;
  background: #161618;
  border-radius: 8px;
  overflow: hidden;
  cursor: grab;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.ae-studio-card:hover {
  border-color: #D6FF3A;
}

.ae-studio-card:active {
  cursor: grabbing;
  transform: scale(0.98);
}

.ae-studio-card__thumb {
  aspect-ratio: 16 / 10;
  background: #0C0C0E;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.ae-studio-card__thumb img,
.ae-studio-card__thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ae-studio-card__label {
  padding: 6px 8px 2px;
  font-size: 10px;
  font-weight: 700;
  color: #F2F0EA;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ae-studio-card__add {
  display: block;
  width: calc(100% - 12px);
  margin: 0 6px 6px;
  padding: 4px 0;
  border: 1px solid #2A2A2E;
  border-radius: 6px;
  background: rgba(214, 255, 58, 0.08);
  color: #D6FF3A;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.ae-studio-card__add:hover {
  background: rgba(214, 255, 58, 0.18);
}

.ae-studio-search {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.ae-studio-search input {
  flex: 1;
  min-width: 0;
  background: #0C0C0E;
  border: 1px solid #2A2A2E;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: #F2F0EA;
}

.ae-studio-search input:focus {
  outline: none;
  border-color: #D6FF3A;
}

.ae-studio-search button,
.ae-studio-btn {
  border: 1px solid #2A2A2E;
  background: #1E1E22;
  color: #F2F0EA;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.ae-studio-search button:hover,
.ae-studio-btn:hover {
  border-color: #D6FF3A;
  color: #D6FF3A;
}

.ae-studio-btn--lime {
  background: #D6FF3A;
  color: #0C0C0E;
  border-color: #D6FF3A;
}

.ae-studio-btn--lime:hover {
  filter: brightness(1.05);
  color: #0C0C0E;
}

.ae-studio-hint {
  font-size: 10px;
  color: #9A9890;
  line-height: 1.45;
  margin-bottom: 8px;
}

.ae-studio-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px 8px;
  font-size: 11px;
  color: #6E6C66;
}

/* Transition preview chips */
.ae-trans-preview {
  width: 100%;
  height: 100%;
  background:
    linear-gradient(105deg, #161618 0 46%, #2A2A2E 46% 54%, #D6FF3A 54% 100%);
  position: relative;
}
.ae-trans-preview--dimensional {
  background:
    linear-gradient(90deg, #0C0C0E 0%, #2A2A2E 40%, transparent 50%),
    radial-gradient(circle at 70% 50%, #D6FF3A 0%, #161618 55%);
}
.ae-trans-preview--zoom {
  background: radial-gradient(circle at 50% 50%, #F2F0EA 0%, #161618 42%, #0C0C0E 70%);
}
.ae-trans-preview--blur {
  background: linear-gradient(90deg, #F2F0EA, #6E6C66 35%, #F2F0EA 70%);
  filter: blur(0.4px);
}
.ae-trans-preview--wipe {
  background: linear-gradient(90deg, #161618 0 50%, #D6FF3A 50% 100%);
}
.ae-trans-preview--glitch {
  background: repeating-linear-gradient(90deg, #FF4D6A 0 4px, #161618 4px 8px, #D6FF3A 8px 10px);
}
.ae-trans-preview--3d {
  background: linear-gradient(135deg, #161618, #3A3A40 45%, #D6FF3A);
}
.ae-trans-preview--cross,
.ae-trans-preview--cinematic {
  background: linear-gradient(90deg, #0C0C0E, #F2F0EA 50%, #0C0C0E);
}

.ae-trans-preview::after {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  color: #F2F0EA;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  letter-spacing: 0.02em;
}

.ae-junction {
  position: absolute;
  top: 0;
  width: 22px;
  height: 100%;
  transform: translateX(-50%);
  z-index: 24;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
}

.ae-junction__diamond {
  width: 14px;
  height: 14px;
  border: 1.5px solid #D6FF3A;
  background: #0C0C0E;
  transform: rotate(45deg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.ae-junction.has-transition .ae-junction__diamond {
  background: #D6FF3A;
  border-color: #F2F0EA;
}

.ae-junction.is-selected .ae-junction__diamond {
  transform: rotate(45deg) scale(1.2);
  box-shadow: 0 0 0 2px rgba(214, 255, 58, 0.45), 0 2px 8px rgba(0, 0, 0, 0.55);
}

.ae-junction.drop-target .ae-junction__diamond {
  background: #FFB020;
  border-color: #F2F0EA;
  transform: rotate(45deg) scale(1.25);
}

#right-panels-container.ae-panels-open {
  min-width: 18rem;
}

/* Advanced per-letter presets — glyph wrappers must not disturb the text layout */
.ae-ltr,
.ae-ltr-gap {
  display: inline-block;
  white-space: pre;
}

.ae-sfx-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ae-sfx-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(12, 12, 18, 0.55);
  cursor: pointer;
}

.ae-sfx-card:hover {
  border-color: rgba(214, 255, 58, 0.45);
}

.ae-sfx-card.is-active {
  border-color: #D6FF3A;
  background: rgba(214, 255, 58, 0.08);
}

.ae-sfx-card__play {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #F2F0EA;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ae-sfx-card__play .material-symbols-outlined {
  font-size: 16px;
}

.ae-sfx-card__body {
  flex: 1;
  min-width: 0;
}

.ae-sfx-card__add {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid rgba(214, 255, 58, 0.35);
  background: rgba(214, 255, 58, 0.1);
  color: #D6FF3A;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ae-sfx-card__add:hover {
  background: rgba(214, 255, 58, 0.22);
}

.ae-sfx-card__add .material-symbols-outlined {
  font-size: 16px;
}

.ae-sfx-card__label {
  font-size: 12px;
  font-weight: 700;
  color: #F2F0EA;
}

.ae-sfx-card__hint {
  font-size: 9px;
  color: rgba(242, 240, 234, 0.55);
}

/* Zoom envelope — orange boxes on clip */
.ae-zoom-env {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 10px;
  display: flex;
  z-index: 6;
  pointer-events: none;
}

.ae-zoom-env.is-editing {
  pointer-events: auto;
  height: 14px;
}

.ae-zoom-seg {
  height: 100%;
  border: 1px solid rgba(255, 140, 0, 0.95);
  background: rgba(255, 140, 0, 0.55);
  position: relative;
  min-width: 4px;
}

.ae-zoom-seg[data-kind="in"] {
  background: rgba(255, 140, 0, 0.45);
  border-radius: 2px 0 0 2px;
}

.ae-zoom-seg[data-kind="hold"] {
  background: rgba(255, 110, 0, 0.7);
}

.ae-zoom-seg[data-kind="out"] {
  background: rgba(255, 170, 40, 0.45);
  border-radius: 0 2px 2px 0;
}

.ae-zoom-handle {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 6px;
  background: #FF8C00;
  border: 1px solid #F2F0EA;
  border-radius: 2px;
  cursor: ew-resize;
  z-index: 2;
  pointer-events: auto;
}

.ae-zoom-handle--l { left: -3px; }
.ae-zoom-handle--r { right: -3px; }

.ae-zoom-blocks {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.ae-zoom-block {
  border: 1px solid rgba(255, 140, 0, 0.45);
  background: rgba(255, 140, 0, 0.08);
  border-radius: 8px;
  padding: 8px;
}

.ae-zoom-block h4 {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 800;
  color: #FFB020;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ae-split-slots {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  min-height: 160px;
}

.ae-split-slot {
  border: 1px dashed #3A3A40;
  border-radius: 8px;
  background: #0C0C0E;
  padding: 8px;
  min-height: 72px;
}

.ae-split-slot.is-target {
  border-color: #D6FF3A;
  background: rgba(214, 255, 58, 0.06);
}

.ae-split-slot__title {
  font-size: 10px;
  font-weight: 800;
  color: #9A9890;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.ae-split-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 4px 8px;
  margin: 0 4px 4px 0;
  border-radius: 6px;
  background: #1E1E22;
  border: 1px solid #2A2A2E;
  font-size: 10px;
  color: #F2F0EA;
}

.ae-split-chip button {
  border: 0;
  background: transparent;
  color: #9A9890;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

#preview-stage.ae-split-active #preview-subjects,
#preview-stage.ae-split-active #preview-video {
  /* layout driven by JS transforms */
}

.ae-layer-speed {
  border: 1px solid #2A2A2E;
  border-radius: 8px;
  padding: 8px;
  background: rgba(214, 255, 58, 0.05);
}

.ae-layer-speed label {
  display: block;
  font-size: 10px;
  color: #9A9890;
  margin-bottom: 4px;
}


/* Kinetic template group — one frame around every line the template produced */
#kinetic-group-frame {
  border: 1.5px dashed rgba(214, 255, 58, 0.9);
  border-radius: 8px;
  background: rgba(214, 255, 58, 0.06);
  box-sizing: border-box;
}

#kinetic-group-frame .kgf-tag {
  position: absolute;
  top: -20px;
  left: -1px;
  white-space: nowrap;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(214, 255, 58, 0.92);
  color: #10100E;
  pointer-events: none;
}

/* Solo-editing one layer of a template */
#kinetic-isolate-bar {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(16, 16, 14, 0.92);
  border: 1px solid rgba(214, 255, 58, 0.5);
  font-size: 11px;
  color: #F2F0EA;
  z-index: 80;
  pointer-events: auto;
}

#kinetic-isolate-bar button {
  border: 0;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  background: #D6FF3A;
  color: #10100E;
  cursor: pointer;
}

#kinetic-isolate-bar button kbd {
  font: inherit;
  font-weight: 600;
  opacity: 0.72;
}

/* The layer stack owns the last column of the right chrome. Floating it over the panels put it
 * on top of whichever panel was open — the tool icons and the word-category bins underneath it
 * were unreachable — so it holds its own space at the far right instead, and collapses to a
 * hairline strip when that space is needed back. */
#ae-right-chrome > #layer-stack-rail {
  position: relative;
  flex: 0 0 13rem;
  width: 13rem;
  transition: flex-basis 0.18s ease, width 0.18s ease;
}

#ae-right-chrome > #layer-stack-rail.ae-rail-collapsed {
  flex: 0 0 2.5rem;
  width: 2.5rem;
}

#layer-stack-rail.ae-rail-collapsed > *:not(.ae-rail-head) { display: none; }
#layer-stack-rail.ae-rail-collapsed .ae-rail-title { display: none; }
#layer-stack-rail.ae-rail-collapsed .ae-rail-head {
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem 0.25rem;
}

@media (max-width: 900px) {
  #ae-right-chrome > #layer-stack-rail {
    flex-basis: 11rem;
    width: 11rem;
  }
}

/* Compact desktop/laptop: preview is the primary work surface. Side inspectors become
 * drawers/strips instead of consuming 320 + 320 + 208px and crushing the canvas. */
@media (min-width: 901px) and (max-width: 1365px) {
  #editor-workspace-row {
    position: relative;
    gap: 8px;
    padding: 8px;
  }

  #subtitle-editor-panel {
    position: absolute;
    inset: 8px auto 8px 8px;
    z-index: 72;
    width: min(20rem, calc(100% - 16px));
    box-shadow: 12px 0 32px rgba(0, 0, 0, 0.48);
  }

  #btn-expand-subtitles {
    width: 2.25rem;
  }

  #right-panels-container {
    width: 18rem !important;
    max-width: 18rem;
  }

  #ae-right-chrome > #layer-stack-rail {
    flex-basis: 2.5rem;
    width: 2.5rem;
  }

  #ae-right-tool-rail {
    width: 4.5rem;
  }

  #preview-transport {
    gap: 8px;
    padding-inline: 10px;
  }
}

/* Short laptop windows: the 320px timeline token plus the 64px header leave almost
 * no canvas. Keep a usable strip of tracks without swallowing the preview. */
@media (max-height: 820px) {
  body.ae-page .h-timeline-height {
    height: clamp(160px, 28vh, 240px) !important;
  }
}

/* Cursor chip over template layers: dragging moves the group, Ctrl opens one line */
#kinetic-hint-chip {
  position: fixed;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(16, 16, 14, 0.94);
  border: 1px solid rgba(214, 255, 58, 0.55);
  color: #F2F0EA;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

#kinetic-hint-chip .material-symbols-outlined {
  font-size: 13px;
  color: #D6FF3A;
}

/* Prepare-once MAIN pool videos (Premiere-style warm preview) */
#format-frame > video.ae-main-pool-video {
  pointer-events: none;
}
#format-frame > video.ae-main-pool-video:not(.ae-main-pool-active) {
  visibility: hidden !important;
}

/* aeadv32 — processing text pulse */
@keyframes ae-text-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* aeadv31+ — left-side tool/settings chrome */
#ae-left-chrome {
  display: flex;
  flex-shrink: 0;
  height: 100%;
  min-height: 0;
}
#ae-left-chrome #ae-right-tool-rail {
  border-left: none;
  border-right: 1px solid var(--outline-variant, rgba(70,69,85,0.45));
}
#ae-left-chrome #layer-stack-rail {
  border-left: none;
  border-right: 1px solid var(--outline-variant, rgba(70,69,85,0.45));
}
#ae-left-chrome #right-panels-container {
  border-right: 1px solid rgba(70,69,85,0.25);
}
#subtitle-editor-panel {
  min-width: 320px;
  max-width: 28rem;
}

/* aeadv31 — sleek workspace (Stitch-aligned) */
.custom-glass {
  backdrop-filter: blur(12px);
  background: rgba(26, 10, 51, 0.68);
  border-color: rgba(145, 143, 161, 0.16);
}
#ae-right-tool-rail {
  background: rgba(15, 6, 31, 0.96);
  border-left-color: rgba(70, 69, 85, 0.45);
}
#panel-layer.custom-glass,
#subtitle-editor-panel.custom-glass {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}
.ae-trans-group summary {
  list-style: none;
}
.ae-trans-group summary::-webkit-details-marker {
  display: none;
}
header.bg-surface-container-low {
  backdrop-filter: blur(8px);
  background: rgba(15, 6, 31, 0.92);
}

.timeline-clip.is-nest {
  background: repeating-linear-gradient(
    -45deg,
    rgba(163, 230, 53, 0.22) 0 6px,
    rgba(28, 36, 18, 0.95) 6px 12px
  ) !important;
  border-color: rgba(163, 230, 53, 0.55) !important;
}
.timeline-clip.is-adjustment {
  background: repeating-linear-gradient(
    45deg,
    rgba(251, 191, 36, 0.18) 0 6px,
    rgba(42, 32, 10, 0.95) 6px 12px
  ) !important;
  border-color: rgba(251, 191, 36, 0.5) !important;
}
#ae-nest-crumb {
  letter-spacing: 0.02em;
}
#ae-zoom-path-ui button {
  min-height: 28px;
}

/* AI Assist — thinking pulse + in-chat plan */
.ai-thinking-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 11px;
  color: #a5b4c8;
}
.ai-thinking-dots {
  display: inline-flex;
  gap: 3px;
}
.ai-thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #a78bfa;
  animation: ai-dot-bounce 1s ease-in-out infinite;
}
.ai-thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.ai-thinking-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-3px); opacity: 1; }
}
.ai-plan-chat {
  border: 1px solid rgba(167, 139, 250, 0.35);
  background: rgba(167, 139, 250, 0.06);
  border-radius: 0.75rem;
  padding: 0.65rem 0.75rem;
}
.ai-plan-chat .ai-plan-step-row {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 0.25rem 0;
  font-size: 11px;
}
.ai-plan-chat .ai-chat-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.ai-plan-chat .ai-chat-actions button {
  flex: 1;
  padding: 0.45rem 0.5rem;
  border-radius: 0.5rem;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.ai-plan-chat .ai-btn-go {
  background: #a78bfa;
  color: #1e0a3c;
  border: none;
}
.ai-plan-chat .ai-btn-cancel {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.45);
  color: #cbd5e1;
}
#tl-magnet-guide {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #f472b6;
  box-shadow: 0 0 8px rgba(244, 114, 182, 0.75);
  z-index: 45;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.08s ease, box-shadow 0.12s ease, background 0.12s ease;
}
#tl-magnet-guide.is-on { opacity: 0.85; }
#tl-magnet-guide.is-snapped {
  opacity: 1;
  width: 3px;
  margin-left: -1.5px;
  background: #fb7185;
  box-shadow: 0 0 14px rgba(251, 113, 133, 0.95), 0 0 2px #fff;
}
#tl-magnet-guide .tl-magnet-guide__cap {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: #fb7185;
  box-shadow: 0 0 6px rgba(251, 113, 133, 0.9);
  opacity: 0;
}
#tl-magnet-guide.is-snapped .tl-magnet-guide__cap { opacity: 1; }

/* Trim magnet — brief edge glow on the clip/cue being trimmed (no full-height line). */
.timeline-clip.is-magnet-snapped,
.subtitle-clip.is-magnet-snapped,
.overlay-cue.is-magnet-snapped,
.kinetic-cue.is-magnet-snapped,
.timeline-audio.is-magnet-snapped {
  box-shadow: inset 0 0 0 2px rgba(251, 113, 133, 0.95), 0 0 12px rgba(251, 113, 133, 0.55);
  transition: box-shadow 0.06s ease;
}

/* Premiere-style clip keyframe diamonds */
.ae-kf-row {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.ae-kf-diamond {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ae-kf-diamond__gem {
  width: 8px;
  height: 8px;
  transform: rotate(45deg);
  border: 1.5px solid rgba(251, 191, 36, 0.55);
  background: transparent;
  border-radius: 1px;
  transition: background 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.ae-kf-diamond:hover .ae-kf-diamond__gem {
  border-color: #fbbf24;
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.45);
}
.ae-kf-diamond.is-on .ae-kf-diamond__gem {
  background: rgba(251, 191, 36, 0.35);
  border-color: #fbbf24;
}
.ae-kf-diamond.is-at-key .ae-kf-diamond__gem {
  background: #fbbf24;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.85);
}
.ae-kf-diamond:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.ae-clip-kf-rail {
  position: absolute;
  left: 0;
  right: 0;
  top: 13px;
  bottom: auto;
  height: 12px;
  z-index: 8;
  pointer-events: none;
}
.ae-clip-kf-tick {
  position: absolute;
  top: 2px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  transform: rotate(45deg);
  background: #fbbf24;
  box-shadow: 0 0 4px rgba(251, 191, 36, 0.8);
  border-radius: 1px;
  pointer-events: auto;
  cursor: ew-resize;
}
.ae-clip-kf-tick.is-at-playhead {
  background: #fff;
  box-shadow: 0 0 8px rgba(251, 191, 36, 1);
  z-index: 2;
}
.ae-clip-kf-ph {
  position: absolute;
  top: 11px;
  width: 2px;
  height: 16px;
  margin-left: -1px;
  background: #f43f5e;
  box-shadow: 0 0 6px rgba(244, 63, 94, 0.75);
  z-index: 7;
  pointer-events: none;
}
.ae-clip-kf-graph-wrap {
  margin-top: 6px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 10px;
  background: rgba(11, 18, 32, 0.85);
  padding: 6px;
}
.ae-clip-kf-graph-wrap.hidden { display: none; }
#ae-clip-kf-canvas {
  width: 100%;
  height: 120px;
  display: block;
  cursor: crosshair;
  border-radius: 6px;
  background: #0b1220;
  touch-action: none;
}
