.motion-timeline {
  --mt-label-width: 152px;
  --mt-track-gutter: 14px;
  --mt-accent: #a596ff;
  --mt-surface: #12141b;
  --mt-line: #292c38;
  min-width: 0;
  color: #e8e8f0;
  background: var(--mt-surface);
  border-top: 1px solid var(--mt-line);
  border-bottom: 1px solid var(--mt-line);
  font-variant-numeric: tabular-nums;
}

.mt-viewport {
  overflow: auto;
  max-height: 280px;
  scrollbar-width: thin;
  scrollbar-color: #474255 #161722;
}

.mt-body {
  position: relative;
  isolation: isolate;
  min-width: 510px;
}

.mt-columns {
  display: grid;
  grid-template-columns: var(--mt-label-width) minmax(0, 1fr);
}

.mt-header {
  min-height: 36px;
  border-bottom: 1px solid var(--mt-line);
  background: #181b24;
}

.mt-clock,
.mt-label {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 0;
  text-align: left;
  border: 0;
  border-right: 1px solid var(--mt-line);
}

.mt-clock {
  display: flex;
  align-items: center;
  padding: 0 13px;
  color: #c2b8ff;
  background: #181b24;
  font: 600 12px ui-monospace, SFMono-Regular, Consolas, monospace;
}

.mt-ruler {
  position: relative;
  min-width: 0;
  cursor: ew-resize;
  touch-action: none;
}

.mt-ruler-track {
  position: absolute;
  inset: 0 var(--mt-track-gutter);
  pointer-events: none;
}

.mt-tick {
  position: absolute;
  bottom: 0;
  white-space: nowrap;
  color: #a7aabb;
  font: 11px ui-monospace, SFMono-Regular, Consolas, monospace;
  padding-bottom: 11px;
  transform: translateX(-50%);
}

.mt-tick::after {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 1px;
  height: 7px;
  background: #626477;
  content: '';
}

.mt-tick.is-start { transform: none; }
.mt-tick.is-end { transform: translateX(-100%); }
.mt-tick.is-start::after { left: 0; }
.mt-tick.is-end::after { left: auto; right: 0; }

.mt-row { min-height: 38px; }
.mt-row + .mt-row { border-top: 1px solid var(--mt-line); }

.mt-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  min-height: 38px;
  color: #d8d8e4;
  background: #171a23;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.mt-label:hover,
.mt-row.is-selected .mt-label {
  background: #2a253e;
  color: #f4f1ff;
}

.mt-row.is-selected .mt-label {
  box-shadow: inset 3px 0 var(--mt-accent);
}

.mt-label-text {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.mt-type {
  display: grid;
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  place-items: center;
  border-radius: 4px;
  font-size: 10px;
  background: #242635;
  color: #c8bbff;
}

.mt-type-image::after { content: '▧'; }
.mt-type-text::after { content: 'T'; font-weight: 750; }
.mt-type-shape::after { content: '■'; font-size: 8px; }
.mt-row.is-hidden-layer .mt-label-text { color: #a2a4b3; }

.mt-track {
  position: relative;
  display: grid;
  align-items: center;
  padding: 0 var(--mt-track-gutter);
  cursor: ew-resize;
  touch-action: none;
}

.mt-track::before {
  position: absolute;
  inset: 0 var(--mt-track-gutter);
  pointer-events: none;
  background: repeating-linear-gradient(to right, #222532 0 1px, transparent 1px var(--mt-tick-size, 25%));
  content: '';
}

.mt-rail {
  position: relative;
  min-width: 0;
  height: 28px;
}

.mt-rail::before,
.mt-keyframe-span {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: #343647;
  transform: translateY(-50%);
  content: '';
}

.mt-keyframe-span {
  height: 4px;
  border-radius: 3px;
  background: #4e456b;
}
.mt-row.is-selected .mt-keyframe-span { background: #7563b8; }
.mt-row.is-selected .mt-track { background: #27213a55; }

.mt-keyframe {
  position: absolute;
  z-index: 1;
  top: 50%;
  display: grid;
  place-items: center;
  width: 26px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #b5a8ed;
  cursor: grab;
  transform: translate(-50%, -50%);
  touch-action: none;
}

.mt-keyframe::before {
  width: 9px;
  height: 9px;
  border: 1px solid #c2b6f0;
  border-radius: 1px;
  background: #51476e;
  transform: rotate(45deg);
  content: '';
}

.mt-row.is-selected .mt-keyframe::before { background: #9885e3; }
.mt-row.is-hidden-layer .mt-keyframe::before { border-style: dashed; }
.mt-keyframe:hover::before,
.mt-keyframe.is-current::before,
.mt-keyframe.is-dragging::before {
  border-color: #fcf8ff;
  background: #d2c3ff;
}

.mt-keyframe.is-dragging { cursor: grabbing; z-index: 3; }
.mt-keyframe.is-dragging::after {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 23px;
  transform: translateX(-50%);
  padding: 4px 6px;
  border: 1px solid #756ab0;
  border-radius: 4px;
  background: #272038;
  color: #f1ebff;
  white-space: nowrap;
  font: 11px ui-monospace, SFMono-Regular, Consolas, monospace;
  content: attr(data-preview-time);
}

.mt-overlay {
  position: absolute;
  z-index: 1;
  inset: 0 var(--mt-track-gutter) 0 calc(var(--mt-label-width) + var(--mt-track-gutter));
  pointer-events: none;
}

.mt-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--mt-accent);
  box-shadow: 0 0 4px #ad9aff65;
}

.mt-playhead::before {
  position: absolute;
  top: 0;
  left: 50%;
  width: 10px;
  height: 9px;
  transform: translateX(-50%);
  clip-path: polygon(0 0, 100% 0, 100% 45%, 50% 100%, 0 45%);
  background: var(--mt-accent);
  content: '';
}

.mt-empty {
  margin: 0;
  padding: 17px 13px;
  color: #a7aabb;
  font-size: 13px;
}

.motion-timeline .mt-ruler:focus-visible,
.motion-timeline .mt-label:focus-visible,
.motion-timeline .mt-keyframe:focus-visible {
  outline: 2px solid #d4caff;
  outline-offset: -2px;
  border-radius: 3px;
}

@media (max-width: 660px) {
  .motion-timeline { --mt-label-width: 110px; }
  .mt-label { padding-inline: 8px; }
  .mt-ruler,
  .mt-track { touch-action: pan-y; }
}
