/* Mode Toggle (Timeline/Keyframe) */
.mode-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.mode-btn {
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  transition: background 0.15s, color 0.15s;
}
.mode-btn:hover {
  background: rgba(255,255,255,0.05);
}
.mode-btn.active {
  background: rgba(120,180,255,0.15);
  color: var(--accent);
}
.animation-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.animation-mode-btn .parameter-animation-diamond {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  flex-shrink: 0;
}

/* Parameter animation action: compact glyph, full button hit area. */
.keyframe-toggle {
  width: 24px;
  height: 26px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 4px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.keyframe-toggle:hover {
  background: rgba(255,255,255,0.08);
}
.keyframe-toggle.active {
  background: rgba(120,180,255,0.07);
}
.keyframe-toggle .parameter-animation-diamond,
.speed-ramp-k .parameter-animation-diamond {
  display: block;
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
}
.keyframe-toggle[data-animation-state="keyed"],
.keyframe-toggle[data-animation-state="at-key"],
.keyframe-toggle[data-animation-state="modulated"] {
  color: var(--accent);
}
.keyframe-toggle.active .parameter-animation-diamond,
.keyframe-toggle[data-animation-state="at-key"] .parameter-animation-diamond {
  fill: currentColor;
}
.keyframe-toggle[data-animation-state="modulated"] .parameter-animation-diamond {
  stroke-dasharray: 2 1;
}
.keyframe-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Keyframe Editor View */
#keyframeViewport {
  --keyframe-sticky-header-height: 44px;
  --keyframe-lane-header-width: 350px;
  --keyframe-ruler-height: 40px;
  --keyframe-ruler-wave-height: calc(var(--keyframe-ruler-height) + 50px);
  position: relative;
  flex: 1 1 auto;
  overflow: auto;
  overscroll-behavior: contain;
  background: rgba(0,0,0,0.20);
}
#keyframeViewport.keyframe-waveform-empty {
  --keyframe-ruler-wave-height: var(--keyframe-ruler-height);
}
#keyframeRuler {
  position: sticky;
  top: var(--keyframe-sticky-header-height);
  left: 0;
  z-index: 19;
  display: block;
  width: 100%;
  height: var(--keyframe-ruler-height);
  pointer-events: auto;
  background: #11141c;
}
#keyframeRulerCanvas {
  display: block;
  width: 100%;
  height: var(--keyframe-ruler-height);
}
#keyframeIdentity {
  position: absolute;
  top: 3px;
  left: 8px;
  width: calc(var(--keyframe-lane-header-width) - 16px);
  height: calc(var(--keyframe-ruler-height) - 6px);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--keyframe-identity-accent);
  border-radius: 7px;
  background: color-mix(in srgb, var(--keyframe-identity-accent) 17%, #11141c);
  color: var(--text);
  font: 600 12px var(--font);
  letter-spacing: .01em;
}
#keyframeIdentity[hidden] { display: none; }
#keyframeIdentity .entity-vector-icon {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  color: var(--keyframe-identity-accent);
}
.keyframe-identity-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#keyframeWaveCanvas {
  position: sticky;
  top: calc(var(--keyframe-sticky-header-height) + var(--keyframe-ruler-height));
  left: 0;
  z-index: 19;
  display: block;
  width: 100%;
  height: 50px;
  border-bottom: 1px solid var(--line2);
  cursor: pointer;
}
#keyframeViewport.keyframe-waveform-empty #keyframeWaveCanvas {
  display: none;
}
#keyframeTracksContainer {
  position: relative;
  min-height: 200px;
}
.keyframe-track {
  position: relative;
  height: 168px;
  border-bottom: 1px solid var(--line2);
  display: flex;
  transition: background 0.12s, box-shadow 0.12s;
}
.keyframe-track.selected {
  background: rgba(120,180,255,0.08);
  box-shadow: inset 0 0 0 1px rgba(120,180,255,0.35);
}
.keyframe-track.selected .keyframe-track-label {
  background: linear-gradient(180deg, rgba(120,180,255,0.15) 0%, rgba(120,180,255,0.08) 20%, rgba(120,180,255,0.05) 100%);
  color: var(--text);
}
.keyframe-track-label {
  position: sticky;
  left: 0;
  z-index: 7;
  width: var(--keyframe-lane-header-width);
  box-sizing: border-box;
  padding: 13px 14px;
  font-size: 12px;
  color: var(--muted);
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 20%, rgba(255,255,255,0.02) 100%);
  border-right: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 10px;
  cursor: pointer;
  overflow: hidden;
}
.keyframe-track-label:hover {
  background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.04) 20%, rgba(255,255,255,0.03) 100%);
}
.keyframe-track-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.keyframe-track-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.keyframe-track-title-row .keyframe-track-name {
  flex: 1;
  min-width: 0;
}
.keyframe-live-value {
  flex: 0 0 auto;
  color: #ff78d7;
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  opacity: 0.9;
}
.keyframe-track-drag-handle {
  color: rgba(255,255,255,0.38);
  cursor: grab;
  flex: 0 0 auto;
  font-size: 17px;
  line-height: 1;
  user-select: none;
}
.keyframe-track-drag-handle:active {
  cursor: grabbing;
}
.keyframe-track.dragging {
  opacity: 0.45;
}
.keyframe-track.drop-before {
  box-shadow: inset 0 2px 0 var(--accent);
}
.keyframe-track.drop-after {
  box-shadow: inset 0 -2px 0 var(--accent);
}
.curve-type-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
}
.curve-type-btn {
  width: 30px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s;
}
.curve-type-btn:hover {
  background: rgba(255,255,255,0.1);
}
.curve-type-btn.active {
  background: rgba(120,180,255,0.25);
  border-color: var(--accent);
  color: var(--accent);
}
.track-delete-btn {
  width: 28px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  opacity: 0.62;
  margin-left: auto;
}
.track-delete-btn .ui-icon {
  width: 14px;
  height: 14px;
}
.track-delete-btn:hover {
  background: rgba(255,100,100,0.2);
  border-color: #f66;
  opacity: 1;
}

/* LFO Controls */
.lfo-btn {
  width: 42px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s;
  margin-left: 2px;
}
.lfo-btn:hover {
  background: rgba(255,200,100,0.15);
}
.lfo-btn.active {
  background: rgba(255,180,50,0.3);
  border-color: var(--gold);
  color: var(--gold);
}
.continuous-btn {
  width: 46px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 750;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s;
}
.continuous-btn:hover {
  background: rgba(87, 232, 215, 0.12);
}
.continuous-btn.active {
  background: rgba(87, 232, 215, 0.2);
  border-color: #57e8d7;
  color: #78f4e5;
  box-shadow: inset 0 0 12px rgba(87, 232, 215, 0.08);
}
.audio-reactive-btn {
  width: 54px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s;
}
.audio-reactive-btn:hover {
  background: rgba(255, 95, 207, 0.12);
}
.audio-reactive-btn.active {
  background: rgba(255, 95, 207, 0.2);
  border-color: #ff5fcf;
  color: #ff8bdc;
  box-shadow: inset 0 0 12px rgba(255, 95, 207, 0.08);
}
.lfo-controls {
  display: none;
  grid-template-columns: minmax(96px, 0.85fr) minmax(0, 1.15fr);
  gap: 7px 8px;
  margin-top: 1px;
  width: 100%;
}
.lfo-controls.visible {
  display: grid;
}
.lfo-controls select {
  width: 100%;
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(0,0,0,0.3);
  color: var(--text);
  font-size: 10.5px;
  cursor: pointer;
}
.lfo-controls select:focus {
  outline: none;
  border-color: var(--gold);
}
.lfo-rate-control {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.lfo-rate-mode {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 74px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.28);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.lfo-rate-mode:hover {
  border-color: var(--gold);
  background: rgba(255, 180, 50, 0.08);
}
.lfo-rate-mode:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.lfo-rate-mode-option {
  display: grid;
  place-items: center;
  height: 22px;
  border-radius: 3px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 8px;
  font-weight: 750;
  line-height: 1;
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}
.lfo-rate-mode-option.is-active {
  background: rgba(255, 180, 50, 0.22);
  color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(255, 200, 100, 0.22);
}
.lfo-rate-control .lfo-freq {
  min-width: 0;
}
/* Free-running speed takes the whole row so the logarithmic slider has room. */
.lfo-rate-control.free {
  grid-column: 1 / -1;
}
.lfo-rate-control .slider-wrapper {
  width: 100%;
  min-width: 0;
}
.lfo-speed-unit {
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 650;
}
.lfo-slider-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.lfo-slider-wrap label {
  font-size: 9px;
  color: var(--muted);
  min-width: 18px;
}
.lfo-slider-wrap input[type="range"] {
  flex: 1;
  min-width: 0;
  width: auto;
  height: 14px;
  -webkit-appearance: none;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  cursor: pointer;
}
.lfo-slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 14px;
  background: var(--gold);
  border-radius: 2px;
  cursor: pointer;
}

.continuous-controls {
  display: none;
  gap: 7px;
  margin-top: 4px;
  width: 100%;
}
.continuous-controls.visible {
  display: block;
}
.continuous-speed-slider-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.continuous-control-label,
.continuous-speed-unit {
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  white-space: nowrap;
}
.continuous-speed-slider-row .slider-wrapper {
  min-width: 0;
  width: 100%;
}
.continuous-speed-unit {
  min-width: 28px;
}

.audio-reactive-controls {
  display: none;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  width: 100%;
  margin-top: 2px;
}
.audio-reactive-controls.visible {
  display: grid;
}
.audio-reactive-preset-field {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.audio-reactive-field-heading {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 8px;
  font-weight: 750;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}
.audio-reactive-field-heading small {
  color: #ff8bdc;
  font-size: 8px;
  letter-spacing: 0.04em;
}
.audio-reactive-source-options,
.audio-reactive-feel-options {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.audio-reactive-source-options {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.audio-reactive-feel-options {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.audio-reactive-source-btn,
.audio-reactive-feel-btn {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}
.audio-reactive-source-btn {
  display: grid;
  place-items: center;
  height: 24px;
  padding: 0 4px;
  text-align: center;
}
.audio-reactive-source-btn span {
  overflow: hidden;
  width: 100%;
  color: var(--text);
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audio-reactive-source-btn small {
  overflow: hidden;
  width: 100%;
  color: rgba(255, 255, 255, 0.42);
  font-size: 7.5px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audio-reactive-feel-btn {
  height: 24px;
  padding: 0 4px;
  font-size: 9px;
  font-weight: 700;
}
.audio-reactive-source-btn:hover,
.audio-reactive-feel-btn:hover,
.audio-reactive-source-btn.active,
.audio-reactive-feel-btn.active {
  border-color: #ff5fcf;
  background: rgba(255, 95, 207, 0.13);
  color: #ff9ee3;
}
.audio-reactive-source-btn.active,
.audio-reactive-feel-btn.active {
  box-shadow: inset 0 0 12px rgba(255, 95, 207, 0.08);
}
.audio-reactive-primary-settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
  min-width: 0;
}
.audio-reactive-select-field,
.audio-reactive-slider-field {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
}
.audio-reactive-select-field select {
  width: 100%;
  min-width: 0;
  height: 24px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(0,0,0,0.3);
  color: var(--text);
  font-size: 10px;
}
.audio-reactive-select-field select:focus {
  outline: none;
  border-color: #ff5fcf;
}
.audio-reactive-slider-field input[type="range"] {
  width: 100%;
  min-width: 0;
  height: 14px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  cursor: pointer;
}
.audio-reactive-slider-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 14px;
  background: #ff5fcf;
  border-radius: 2px;
}
.audio-reactive-advanced {
  min-width: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 5px;
}
.audio-reactive-advanced summary {
  color: rgba(255, 255, 255, 0.46);
  cursor: pointer;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  list-style-position: inside;
  user-select: none;
}
.audio-reactive-advanced summary:hover,
.audio-reactive-advanced[open] summary {
  color: #ff8bdc;
}
.audio-reactive-advanced-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
  padding-top: 6px;
}
.keyframe-track:has(.audio-reactive-advanced[open]) {
  min-height: 392px;
}

.keyframe-track-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0) 20%);
}
.keyframe-track-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}
.audio-reactive-trace-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.95;
}
.keyframe-live-value-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  background: #ff63d2;
  box-shadow: 0 0 5px rgba(255, 99, 210, 0.8);
}
.keyframe-live-value-line.active {
  opacity: 0.95;
}
.keyframe-diamond {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--keyframe-track-colour, var(--accent));
  transform: rotate(45deg);
  cursor: pointer;
  z-index: 2;
  margin-left: -6px;
  margin-top: -6px;
}
.keyframe-diamond:hover {
  background: var(--keyframe-track-colour, var(--accent));
  outline: 1px solid #fff;
}
.keyframe-diamond.selected {
  background: var(--keyframe-track-colour, var(--accent));
  outline: 1px solid #fff;
  box-shadow: 0 0 6px var(--keyframe-track-colour, var(--accent));
  z-index: 4;
}
.keyframe-bezier-arm {
  position: absolute;
  height: 2px;
  border-top: 2px solid rgba(255, 196, 82, 0.9);
  transform-origin: 0 50%;
  pointer-events: none;
  z-index: 3;
}
.keyframe-bezier-arm.in {
  border-color: rgba(122, 202, 255, 0.82);
}
.keyframe-bezier-handle {
  position: absolute;
  display: block;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  top: 0;
  right: 0;
  width: 12px;
  height: 12px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 2px solid #ffc452;
  border-radius: 50%;
  background: #111722;
  box-shadow: 0 0 0 2px rgba(8, 11, 19, 0.72), 0 0 8px rgba(255, 196, 82, 0.3);
  transform: translate(50%, -50%);
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
}
.keyframe-bezier-handle.in {
  border-color: #7acaff;
  box-shadow: 0 0 0 2px rgba(8, 11, 19, 0.72), 0 0 8px rgba(122, 202, 255, 0.3);
}
.keyframe-bezier-handle:hover,
.keyframe-bezier-handle:focus-visible {
  background: #f7fbff;
  outline: none;
  transform: translate(50%, -50%) scale(1.12);
}
.keyframe-bezier-handle:active {
  cursor: grabbing;
}
.keyframe-value-tooltip {
  position: fixed;
  z-index: 10020;
  padding: 4px 7px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 4px;
  background: rgba(8, 11, 19, 0.96);
  box-shadow: 0 5px 18px rgba(0,0,0,0.38);
  color: var(--text);
  font: 10px/1.2 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -100%) translateY(-2px);
  transition: opacity 90ms ease, transform 90ms ease;
}
.keyframe-value-tooltip.visible {
  opacity: 1;
  transform: translate(-50%, -100%) translateY(-4px);
}
.keyframe-marquee {
  position: absolute;
  border: 1px solid var(--accent);
  background: rgba(120,180,255,0.15);
  pointer-events: none;
  z-index: 5;
}
#keyframeEmpty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 20px;
}
#keyframePlayhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  pointer-events: none;
  z-index: 10;
  left: var(--keyframe-lane-header-width);
}

/* Keyframe Editor Header */
#keyframeHeader {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--keyframe-sticky-header-height);
  box-sizing: border-box;
  padding: 8px 12px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--line2);
  position: sticky;
  top: 0;
  z-index: 20;
}
#keyframeHeader label {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.kf-lane-hint {
  margin-left: auto;
  min-width: 0;
  overflow: hidden;
  color: rgba(255,255,255,0.42);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kf-snap-btn {
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.kf-snap-btn:hover {
  background: rgba(255,255,255,0.1);
}
.kf-snap-btn.active {
  background: rgba(120,180,255,0.25);
  border-color: var(--accent);
  color: var(--accent);
}
.kf-grid-select {
  height: 28px;
  min-width: 96px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
}
.kf-grid-select:focus {
  outline: none;
  border-color: var(--accent);
}
.kf-triplet-btn,
.kf-clipboard-btn,
.kf-draw-btn {
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.kf-triplet-btn {
  padding: 0 9px;
}
.kf-triplet-btn:hover,
.kf-draw-btn:hover {
  background: rgba(255,255,255,0.1);
}
.kf-triplet-btn.active {
  background: rgba(120,180,255,0.25);
  border-color: var(--accent);
  color: var(--accent);
}
.kf-draw-btn.active {
  background: rgba(255, 196, 82, 0.22);
  border-color: var(--gold);
  color: var(--gold);
}
#keyframeViewport.draw-mode .keyframe-track-area {
  cursor: crosshair;
}
#keyframeViewport.draw-mode .keyframe-diamond {
  pointer-events: none;
}
.keyframe-diamond.hold {
  border-radius: 1px 1px 1px 6px;
}
.keyframe-track-label.drop-target {
  outline: 1px dashed var(--accent);
}

/* One driver panel at a time: tabs appear only when two drivers are on. */
.lane-driver-tabs {
  display: flex;
  gap: 3px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.28);
}
.lane-driver-tab {
  flex: 1 1 0;
  height: 20px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  font: inherit;
  font-size: 8.5px;
  font-weight: 750;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.lane-driver-tab[aria-selected="true"] {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}
.lane-driver-tab[data-driver="lfo"][aria-selected="true"] { color: var(--gold); }
.lane-driver-tab[data-driver="continuous"][aria-selected="true"] { color: #78f4e5; }
.lane-driver-tab[data-driver="audio"][aria-selected="true"] { color: #ff8bdc; }

/* Easing panel and the chip above a selected key */
.keyframe-easing-chip {
  position: absolute;
  z-index: 6;
  /* Below the key: the value tooltip owns the space above it. */
  transform: translate(-50%, 0);
  margin-top: 10px;
  height: 18px;
  padding: 0 7px 0 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 9px;
  background: rgba(8, 11, 19, 0.92);
  color: var(--text);
  font: 650 9.5px/16px Montserrat, sans-serif;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.keyframe-easing-chip::after {
  content: ' ▾';
  color: rgba(255, 255, 255, 0.5);
}
.keyframe-easing-chip:hover,
.keyframe-easing-chip.open {
  border-color: var(--accent);
  color: #fff;
}
.easing-panel {
  box-sizing: border-box;
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  position: fixed;
  z-index: 10030;
  width: 312px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  background: rgba(10, 13, 21, 0.97);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  color: var(--text);
  font-family: Montserrat, sans-serif;
}
.easing-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.easing-panel-title {
  font-size: 12px;
  font-weight: 700;
}
.easing-panel-count {
  flex: 1;
  color: var(--muted);
  font-size: 10px;
}
.easing-panel-close {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
}
.easing-panel-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.easing-panel-basics,
.easing-panel-families {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.easing-panel-directions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  margin: 10px 0 8px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
}
.easing-panel-direction {
  height: 22px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  font: 700 9.5px Montserrat, sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
}
.easing-panel-direction.active {
  background: rgba(120, 180, 255, 0.22);
  color: var(--accent);
}
.easing-tile {
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 5px 2px 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font: 650 9.5px Montserrat, sans-serif;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.easing-tile svg {
  width: 44px;
  height: 32px;
  overflow: visible;
}
.easing-tile path {
  fill: none;
  stroke: rgba(255, 255, 255, 0.72);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.easing-tile:hover {
  border-color: rgba(120, 180, 255, 0.7);
  background: rgba(120, 180, 255, 0.1);
  color: var(--text);
}
.easing-tile:hover path {
  stroke: var(--accent);
}
.easing-tile.active {
  border-color: var(--accent);
  background: rgba(120, 180, 255, 0.2);
  color: #fff;
}
.easing-tile.active path {
  stroke: #fff;
}


#hud{
  display: none; /* Debug HUD - hidden in production */
  position:absolute;
  left:12px; bottom:12px;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:14px;
  background: rgba(8,10,14,.45);
  backdrop-filter: blur(8px);
  color: rgba(255,255,255,.84);
  font-size:12px;
  line-height:1.25;
  white-space:pre;
  pointer-events:none;
}
#editor{
  flex: 1 1 auto;
  min-height: 340px;
  display:flex;
  flex-direction:column;
  background: linear-gradient(180deg, rgba(16,21,33,1), rgba(10,12,18,1));
  overflow: hidden;
  contain: strict;
  isolation: isolate;
  user-select:none;
  -webkit-user-select:none;
}
#editor input[type="text"],
#editor input[type="search"],
#editor input[type="number"],
#editor input[type="url"],
#editor input[type="email"],
#editor input[type="password"],
#editor textarea,
#editor [contenteditable="true"]{
  user-select:text;
  -webkit-user-select:text;
}
#editorBar{
  display:grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items:center;
  height: 52px;
  min-height: 52px;
  padding: 0 16px;
  box-sizing: border-box;
  border-bottom:1px solid var(--line);
  background: linear-gradient(rgba(255,255,255,.03), rgba(255,255,255,.03)), rgba(16,21,33,1);
  flex-shrink: 0;
}
#editorBar .editorbar-left{
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}
#editorBar .editorbar-center{
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
#editorBar .editorbar-right{
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: flex-end;
}
/* Keep transport geometry identical across workspaces and playback sources. */
#editorBar #timePill{
  width: 104px;
  flex: 0 0 104px;
  font-variant-numeric: tabular-nums;
}
#editorBar .editorbar-center .btn:disabled{
  background: rgba(255,255,255,.06);
  border-color: var(--line);
  color: var(--muted);
  transform: none;
}
/* Zoom control */
.zoom-control{
  display: flex;
  align-items: center;
  gap: 8px;
}
.zoom-icon{
  color: var(--muted);
}
.zoom-slider-wrapper{
  position: relative;
  width: 120px;
  height: 20px;
  display: flex;
  align-items: center;
}
.zoom-slider-wrapper input[type="range"]{
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  outline: none;
  margin: 0;
}
.zoom-slider-wrapper input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 16px;
  background: transparent;
  cursor: pointer;
  border: none;
}
.zoom-slider-wrapper input[type="range"]::-moz-range-thumb{
  width: 32px;
  height: 16px;
  background: transparent;
  cursor: pointer;
  border: none;
}
.zoom-thumb{
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(80,140,200,0.9);
  color: #fff;
  font-size: 9px;
  font-weight: 600;
  padding: 2px 4px;
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
  min-width: 24px;
  text-align: center;
  z-index: 1;
}
.zoom-slider-wrapper:hover .zoom-thumb{
  background: rgba(100,160,220,1);
}
.zoom-slider-wrapper input[type="range"]:focus + .zoom-thumb{
  background: rgba(120,180,255,1);
}
label.small{display:flex;gap:8px;align-items:center;color:var(--muted);font-size:12px;}
input[type="range"]{width:140px;}
input[type="number"]{
  width:72px;
  padding:7px 8px;
  border-radius:10px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.05);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}
input[type="checkbox"]{transform: translateY(1px);}
select{
  padding:7px 8px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,0.2);
  background: #1a1d24;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  max-width: 240px;
}
select option {
  background: #1a1d24;
  color: #e0e0e0;
}
#timelineViewport{
  --timeline-track-header-width: 272px;
  position:relative;
  flex: 1 1 auto;
  overflow-x: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(0,0,0,.20);
  user-select:none;
  -webkit-user-select:none;
}
#timelineViewport input[type="text"],
#timelineViewport input[type="search"],
#timelineViewport input[type="number"],
#timelineViewport textarea,
#timelineViewport [contenteditable="true"]{
  user-select:text;
  -webkit-user-select:text;
}
.timeline-layer-toolbar{
  --timeline-track-header-width:272px;
  position:sticky;
  bottom:0;
  z-index:140;
  flex:0 0 44px;
  min-height:44px;
  display:flex;
  align-items:stretch;
  overflow:hidden;
  border-top:1px solid rgba(255,255,255,.1);
  background:linear-gradient(180deg, rgba(18,23,33,.99), rgba(11,15,23,.99));
  box-shadow:0 -10px 24px rgba(0,0,0,.22);
}
.timeline-layer-toolbar[hidden]{display:none;}
.timeline-layer-toolbar-heading{
  width:var(--timeline-track-header-width);
  min-width:var(--timeline-track-header-width);
  display:flex;
  align-items:center;
  gap:8px;
  padding:0 12px;
  box-sizing:border-box;
  border-right:1px solid rgba(255,255,255,.08);
  background:linear-gradient(90deg, rgba(80,137,207,.12), transparent 76%);
  color:rgba(231,239,250,.88);
}
.timeline-layer-toolbar-heading > span:last-child{
  min-width:0;
  display:flex;
  align-items:baseline;
  gap:7px;
}
.timeline-layer-toolbar-heading strong{
  font:650 11px/1 var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
}
.timeline-layer-toolbar-heading small{
  color:rgba(184,198,220,.5);
  font:500 9px/1 var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  white-space:nowrap;
}
.timeline-layer-toolbar-plus{
  width:20px;
  height:20px;
  flex:0 0 20px;
  display:grid;
  place-items:center;
  border:1px solid rgba(118,180,248,.38);
  border-radius:6px;
  background:rgba(63,126,201,.18);
  color:#9dd0ff;
  font:500 17px/18px var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
}
.timeline-layer-toolbar-actions{
  min-width:0;
  flex:1 1 auto;
  display:flex;
  align-items:center;
  gap:4px;
  overflow-x:auto;
  overflow-y:hidden;
  padding:5px 8px;
  scrollbar-width:thin;
  scrollbar-color:rgba(144,171,205,.25) transparent;
}
.timeline-layer-toolbar-button{
  --layer-rgb:145,160,184;
  height:33px;
  flex:0 0 auto;
  display:inline-flex;
  align-items:center;
  gap:7px;
  padding:0 10px 0 7px;
  border:1px solid rgba(255,255,255,.1);
  border-radius:7px;
  background:rgba(255,255,255,.035);
  color:rgba(226,234,246,.78);
  font:600 10px/1 var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  white-space:nowrap;
  cursor:pointer;
  transition:color .14s ease, border-color .14s ease, background .14s ease, transform .14s ease, box-shadow .14s ease;
}
.timeline-layer-toolbar-button[data-layer-type="scene"]{--layer-rgb:var(--family-scene-rgb);}
.timeline-layer-toolbar-button[data-layer-type="media"]{--layer-rgb:var(--family-media-rgb);}
.timeline-layer-toolbar-button[data-layer-type="text"]{--layer-rgb:var(--family-text-rgb);}
.timeline-layer-toolbar-button[data-layer-type="audio"]{--layer-rgb:var(--family-audio-rgb);}
.timeline-layer-toolbar-button[data-layer-type="shader"]{--layer-rgb:var(--family-shader-rgb);}
.timeline-layer-toolbar-button[data-layer-type="postfx"]{--layer-rgb:var(--family-postfx-rgb);}
.timeline-layer-toolbar-button[data-layer-type="lut"]{--layer-rgb:var(--family-lut-rgb);}
.timeline-layer-toolbar-button[data-layer-type="webcam"]{ --layer-rgb:var(--family-webcam-rgb); }
.timeline-layer-toolbar-button[data-layer-type="screen"]{ --layer-rgb:var(--family-screen-rgb); }
.timeline-layer-toolbar-button[data-layer-type="mask"]{ --layer-rgb:var(--family-mask-rgb); }
.timeline-layer-toolbar-button:hover,
.timeline-layer-toolbar-button:focus-visible{
  outline:none;
  color:rgba(245,249,255,.98);
  border-color:rgba(var(--layer-rgb),.58);
  background:rgba(var(--layer-rgb),.13);
  box-shadow:inset 0 0 0 1px rgba(var(--layer-rgb),.08), 0 3px 10px rgba(0,0,0,.18);
}
.timeline-layer-toolbar-button:focus-visible{
  box-shadow:0 0 0 2px rgba(var(--layer-rgb),.22), 0 3px 10px rgba(0,0,0,.18);
}
.timeline-layer-toolbar-button:active{
  transform:translateY(1px);
  background:rgba(var(--layer-rgb),.2);
}
.timeline-layer-toolbar-button img,
.timeline-layer-toolbar-mask-icon{
  width:19px;
  height:19px;
  flex:0 0 19px;
}
.timeline-layer-toolbar-button img{
  display:block;
  object-fit:contain;
  filter:saturate(.86) brightness(.95);
}
.timeline-layer-toolbar-button:hover img,
.timeline-layer-toolbar-button:focus-visible img{
  filter:saturate(1.08) brightness(1.08);
}
.timeline-layer-toolbar-mask-icon{
  position:relative;
  display:block;
}
.timeline-layer-toolbar-mask-icon::before,
.timeline-layer-toolbar-mask-icon::after{
  content:"";
  position:absolute;
  width:10px;
  height:10px;
  border-radius:3px;
}
.timeline-layer-toolbar-mask-icon::before{
  left:1px;
  top:1px;
  border:1px solid rgba(205,216,232,.72);
  background:rgba(205,216,232,.08);
}
.timeline-layer-toolbar-mask-icon::after{
  right:1px;
  bottom:1px;
  border:1px solid rgba(var(--layer-rgb),.88);
  background:rgba(var(--layer-rgb),.42);
  box-shadow:0 0 7px rgba(var(--layer-rgb),.18);
}
#timelineContent{
  position:relative;
  min-height: 100%;
  overflow: visible;
}
#timelineRulerRow{
  position:sticky;
  top:0;
  z-index:120;
  height:38px;
  min-width:100%;
  background:#11141c;
  box-shadow:0 1px 0 rgba(255,255,255,.08), 0 8px 18px rgba(0,0,0,.18);
}
#timelineRowFilterBar{
  position:sticky;
  left:0;
  top:0;
  z-index:18;
  width:var(--timeline-track-header-width);
  height:38px;
  padding:5px 7px;
  box-sizing:border-box;
  display:flex;
  align-items:center;
  gap:5px;
  background:linear-gradient(180deg, rgba(15,19,28,.99), rgba(11,15,23,.99));
  border-right:1px solid rgba(255,255,255,.08);
  border-bottom:1px solid rgba(255,255,255,.09);
  box-shadow:8px 0 18px rgba(0,0,0,.14);
}
.timeline-row-search{
  min-width:0;
  height:28px;
  flex:1 1 auto;
  display:flex;
  align-items:center;
  gap:6px;
  padding:0 8px;
  border:1px solid rgba(255,255,255,.13);
  border-radius:7px;
  background:rgba(4,8,15,.72);
  color:rgba(202,216,238,.54);
  transition:border-color .14s ease, background .14s ease, box-shadow .14s ease;
}
.timeline-row-search:focus-within{
  border-color:rgba(111,178,255,.68);
  background:rgba(7,13,23,.92);
  box-shadow:0 0 0 2px rgba(69,139,222,.13);
  color:rgba(143,196,255,.9);
}
.timeline-row-search svg{
  width:14px;
  height:14px;
  flex:0 0 auto;
  fill:none;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
}
.timeline-row-search input{
  min-width:0;
  width:100%;
  height:100%;
  padding:0;
  border:0;
  outline:0;
  background:transparent;
  color:rgba(238,244,253,.92);
  font:600 11px/1 var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
}
.timeline-row-search input::placeholder{color:rgba(190,201,219,.42);}
.timeline-row-search input::-webkit-search-cancel-button{appearance:none;}
.timeline-ruler-filter-btn{
  width:28px;
  height:28px;
  flex:0 0 28px;
  display:grid;
  place-items:center;
  padding:0;
  border:1px solid rgba(255,255,255,.13);
  border-radius:7px;
  background:rgba(14,20,30,.92);
  color:rgba(195,208,227,.62);
  cursor:pointer;
  transition:color .14s ease, border-color .14s ease, background .14s ease, box-shadow .14s ease;
}
.timeline-ruler-filter-btn:hover{
  color:rgba(225,237,253,.95);
  border-color:rgba(125,177,239,.42);
}
.timeline-ruler-filter-btn[aria-pressed="true"]{
  color:#91c8ff;
  border-color:rgba(99,171,255,.78);
  background:rgba(49,105,176,.32);
  box-shadow:inset 0 0 0 1px rgba(127,190,255,.12), 0 0 12px rgba(67,143,231,.12);
}
.timeline-ruler-filter-btn svg{
  width:13px;
  height:13px;
  fill:currentColor;
  stroke:none;
}
#rulerCanvas{
  position:absolute;
  left:var(--timeline-track-header-width);
  top:0;
  display:block;
  margin-left:0;
  pointer-events:auto;
  height:38px;
  will-change: transform;
}
.trackRow[hidden]{display:none !important;}
#waveCanvas{
  display:block;
  width:100%;
  height:100%;
  pointer-events:auto;
  cursor: pointer;
}
#tracks{
  position:relative;
  min-height: 200px;
  overflow: visible;
}
.timeline-empty-workspace-hint{
  position:relative;
  width:100%;
  min-width:100%;
  height:64px;
  overflow:visible;
  pointer-events:none;
}
.timeline-empty-workspace-hint > span{
  position:sticky;
  left:0;
  display:flex;
  justify-content:center;
  width:100vw;
  max-width:100%;
  padding:18px 0 0 var(--timeline-track-header-width);
  box-sizing:border-box;
  color:rgba(184,198,220,.34);
  font:500 11px/1.2 var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  letter-spacing:.015em;
  text-align:center;
  white-space:nowrap;
}
.trackRow{
  position:relative;
  height: 80px;
  border-bottom: 1px solid var(--line2);
  overflow: hidden;
  contain: paint layout;
}
#tracks.loop-range-visible .track-content::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--timeline-loop-left, 0px);
  width: var(--timeline-loop-width, 0px);
  box-sizing: border-box;
  background: rgba(255, 160, 82, 0.055);
  border-left: 1px solid rgba(255, 174, 92, 0.16);
  border-right: 1px solid rgba(255, 174, 92, 0.16);
  box-shadow:
    inset 8px 0 14px -14px rgba(255, 176, 100, 0.34),
    inset -8px 0 14px -14px rgba(255, 176, 100, 0.34);
  pointer-events: none;
  z-index: 4;
}
.trackLabel{
  position:absolute;
  left:10px;
  top:8px;
  color: rgba(255,255,255,.5);
  font-size:11px;
  pointer-events:none;
  z-index: 5;
}
.seg{
  position:absolute;
  top: 4px;
  height: calc(100% - 8px);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 8px 20px rgba(0,0,0,.35);
  overflow:hidden;
  cursor: grab;
  contain: layout style;
}
.seg .title{
  position:absolute;
  left:8px; right:8px; top:6px;
  font-size:11px;
  color: rgba(0,0,0,.85);
  text-shadow: 0 1px 0 rgba(255,255,255,.18);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  pointer-events:none;
}
.seg .meta{
  position:absolute;
  left:8px; right:8px; bottom:6px;
  font-size:10px;
  color: rgba(0,0,0,.65);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  pointer-events:none;
}
.timeline-clip-expand-btn{
  appearance:none;
  position:absolute;
  left:4px;
  top:50%;
  z-index:12;
  display:grid;
  place-items:center;
  width:18px;
  height:18px;
  box-sizing:border-box;
  padding:2px;
  border:0;
  border-radius:0;
  transform:translateY(-50%);
  background:transparent;
  color:rgba(7,35,65,.7);
  box-shadow:none;
  opacity:.78;
  cursor:pointer;
  pointer-events:auto;
  transition:color .14s ease, opacity .14s ease;
}
.timeline-clip-expand-btn:hover,
.timeline-clip-expand-btn:focus-visible{
  background:transparent;
  color:rgba(3,28,55,.98);
  opacity:1;
  outline:none;
}
.timeline-clip-expand-btn svg{
  width:12px;
  height:12px;
  fill:none;
  stroke:currentColor;
  stroke-width:2.15;
  stroke-linecap:round;
  stroke-linejoin:round;
  transition:filter .14s ease, transform .14s ease;
}
.timeline-clip-expand-btn:hover svg,
.timeline-clip-expand-btn:focus-visible svg{
  filter:drop-shadow(0 0 2px rgba(235,246,255,.32));
}
.timeline-clip-expand-btn.is-expanded svg{
  transform:rotate(90deg);
}
.timeline-clip-expand-btn.is-expanded{
  padding:2px 3px 2px 1px;
}
.seg.has-sublayers > .title,
.seg.has-sublayers > .meta{
  left:26px;
}
.trackRow.minimized .timeline-clip-expand-btn{
  left:3px;
  width:16px;
  height:16px;
}
.trackRow.minimized .seg.has-sublayers > .title,
.trackRow.minimized .seg.has-sublayers > .meta{
  left:22px;
}
.timeline-clip-actions{
  position:absolute;
  right:4px;
  top:50%;
  z-index:20;
  display:flex;
  align-items:center;
  gap:1px;
  padding:0;
  border:0;
  border-radius:5px;
  transform:translateY(-50%) translateX(3px);
  opacity:0;
  visibility:hidden;
  background:transparent;
  box-shadow:none;
  pointer-events:none;
  transition:opacity .12s ease, transform .12s ease, visibility .12s ease;
}
.seg:hover > .timeline-clip-actions,
.seg:focus-within > .timeline-clip-actions{
  transform:translateY(-50%) translateX(0);
  opacity:1;
  visibility:visible;
  pointer-events:auto;
}
.timeline-clip-action-btn{
  appearance:none;
  display:grid;
  place-items:center;
  width:20px;
  height:20px;
  padding:3px;
  border:0;
  border-radius:5px;
  background:transparent;
  color:rgba(10,29,47,.58);
  cursor:pointer;
  transition:color .12s ease, filter .12s ease, transform .12s ease;
}
.timeline-clip-action-btn .ui-icon{
  width:14px;
  height:14px;
}
.timeline-clip-action-btn:hover,
.timeline-clip-action-btn:focus-visible{
  color:rgba(247,251,255,.96);
  background:transparent;
  filter:drop-shadow(0 0 3px rgba(226,242,255,.38));
}
.timeline-clip-action-btn:focus-visible{
  outline:1px solid rgba(237,246,255,.68);
  outline-offset:-1px;
}
.timeline-clip-action-btn:active{
  transform:scale(.92);
}
.timeline-clip-delete-btn:hover,
.timeline-clip-delete-btn:focus-visible{
  color:rgba(255,222,227,.98);
  background:transparent;
  filter:drop-shadow(0 0 3px rgba(255,126,146,.42));
}
.timeline-clip-action-btn:disabled{
  opacity:.34;
  cursor:not-allowed;
}
.seg.timeline-clip-hidden{
  filter:saturate(.48);
}
.seg.timeline-clip-hidden::after{
  content:"";
  position:absolute;
  inset:0;
  z-index:14;
  border-radius:inherit;
  background:rgba(3,10,19,.4);
  pointer-events:none;
  transition:background .12s ease;
}
.seg.timeline-clip-hidden:hover::after,
.seg.timeline-clip-hidden:focus-within::after{
  background:rgba(3,10,19,.3);
}
.trackRow.minimized .timeline-clip-actions{
  right:2px;
  gap:1px;
  padding:0;
  border-radius:5px;
}
.trackRow.minimized .timeline-clip-action-btn{
  width:16px;
  height:16px;
  padding:2px;
  border-radius:4px;
}
.trackRow.minimized .timeline-clip-action-btn .ui-icon{
  width:12px;
  height:12px;
}
.handle{
  position:absolute;
  top:0; bottom:0;
  width:8px;
  background: transparent;
  cursor: ew-resize;
}
.handle.left{left:0;}
.handle.right{right:0;}
.seg.selected{
  outline: 2px solid rgba(120,190,255,.92);
  outline-offset: -2px;
  box-shadow:
    0 0 0 1px rgba(204,231,255,.76),
    0 0 16px rgba(67,145,235,.34),
    0 8px 20px rgba(0,0,0,.35);
}
.seg.selected.selection-primary{
  outline-color:rgba(216,239,255,.98);
  box-shadow:
    0 0 0 2px rgba(89,164,255,.92),
    0 0 20px rgba(65,151,255,.5),
    0 8px 20px rgba(0,0,0,.35);
}
.timeline-selection-marquee{
  position:fixed;
  z-index:10010;
  pointer-events:none;
  border:1px solid rgba(126,190,255,.92);
  border-radius:3px;
  background:rgba(74,143,229,.18);
  box-shadow:inset 0 0 0 1px rgba(214,235,255,.12),0 0 18px rgba(52,132,226,.16);
}
.video-segment-filmstrip{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  display:block;
  pointer-events:none;
  opacity:.96;
}
.video-segment::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background:linear-gradient(180deg,rgba(4,8,13,.62),transparent 42%,rgba(4,8,13,.62));
}
.video-segment .title,
.video-segment .meta,
.video-segment .handle{
  z-index:2;
  color:rgba(246,250,255,.96);
  text-shadow:0 1px 3px rgba(0,0,0,.96);
}
.timeline-clip-context-menu{
  position:fixed;
  z-index:10020;
  width:236px;
  padding:6px;
  border:1px solid rgba(135,170,218,.3);
  border-radius:10px;
  background:rgba(13,18,28,.98);
  box-shadow:0 18px 50px rgba(0,0,0,.56),inset 0 1px 0 rgba(255,255,255,.035);
  backdrop-filter:blur(18px);
}
.timeline-clip-context-heading{
  padding:8px 10px 10px;
  overflow:hidden;
  color:rgba(150,195,248,.86);
  font:700 10px/1.25 var(--mono,ui-monospace,SFMono-Regular,Menlo,monospace);
  letter-spacing:.08em;
  text-overflow:ellipsis;
  text-transform:uppercase;
  white-space:nowrap;
}
.timeline-clip-context-action{
  width:100%;
  min-height:34px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:0 10px;
  border:0;
  border-radius:6px;
  background:transparent;
  color:rgba(235,241,250,.9);
  font:600 12px/1 var(--mono,ui-monospace,SFMono-Regular,Menlo,monospace);
  text-align:left;
  cursor:pointer;
}
.timeline-clip-context-action:hover,
.timeline-clip-context-action:focus-visible{
  outline:0;
  background:rgba(103,164,235,.16);
}
.timeline-clip-context-action:disabled{
  color:rgba(181,190,204,.3);
  cursor:default;
}
.timeline-clip-context-action:disabled:hover{background:transparent;}
.timeline-clip-context-action.is-danger{color:rgba(255,155,166,.9);}
.timeline-clip-context-action kbd{
  color:rgba(183,196,216,.52);
  font:600 10px/1 var(--mono,ui-monospace,SFMono-Regular,Menlo,monospace);
}
.timeline-clip-context-divider{
  height:1px;
  margin:5px 6px;
  background:rgba(255,255,255,.08);
}
#keyframePlayhead,
#keyframeWavePlayhead,
#playhead{
  background:rgba(139,199,255,.9);
  box-shadow:0 0 0 1px rgba(0,0,0,.34), 0 0 16px rgba(74,156,244,.28);
}
#playhead{
  position:absolute;
  left: var(--timeline-track-header-width);
  top:0;
  width:2px;
  height: 100%;
  pointer-events:none;
  z-index:130;
}
#keyframePlayheadHandle,
#playheadHandle{
  position:absolute;
  top:-11px;
  left:50%;
  width:26px;
  height:24px;
  padding:0;
  border:0;
  outline:0;
  transform:translateX(-50%);
  background:transparent;
  color:#d9edff;
  cursor:ew-resize;
  pointer-events:auto;
  touch-action:none;
}
#keyframePlayheadHandle::before,
#playheadHandle::before{
  content:"";
  position:absolute;
  left:5px;
  top:4px;
  width:16px;
  height:10px;
  box-sizing:border-box;
  border:1px solid rgba(187,224,255,.7);
  border-radius:5px 5px 4px 4px;
  background:linear-gradient(180deg, rgba(104,188,255,.98), rgba(47,123,211,.96));
  box-shadow:0 2px 7px rgba(8,42,82,.5), inset 0 1px 0 rgba(255,255,255,.25);
  transition:filter .14s ease, transform .14s ease, box-shadow .14s ease;
}
#keyframePlayheadHandle::after,
#playheadHandle::after{
  content:"";
  position:absolute;
  left:10px;
  top:13px;
  width:6px;
  height:6px;
  box-sizing:border-box;
  border-right:1px solid rgba(187,224,255,.62);
  border-bottom:1px solid rgba(187,224,255,.62);
  border-radius:0 0 2px 0;
  transform:rotate(45deg);
  background:#347dcd;
}
#keyframePlayheadHandle:hover::before,
#playheadHandle:hover::before,
#keyframePlayheadHandle:focus-visible::before,
#playheadHandle:focus-visible::before{
  filter:brightness(1.12);
  transform:translateY(-1px);
  box-shadow:0 3px 9px rgba(8,42,82,.58), 0 0 0 3px rgba(84,163,245,.14), inset 0 1px 0 rgba(255,255,255,.3);
}
#keyframePlayheadHandle:focus-visible,
#playheadHandle:focus-visible{
  outline:2px solid rgba(133,196,255,.72);
  outline-offset:-3px;
  border-radius:8px;
}
#playheadFrameBadge{
  position:absolute;
  left:50%;
  top:-21px;
  min-width:38px;
  padding:4px 6px;
  border:1px solid rgba(111,180,246,.35);
  border-radius:6px;
  transform:translate(-50%, 3px);
  background:rgba(8,18,32,.94);
  box-shadow:0 5px 14px rgba(0,0,0,.28);
  color:rgba(190,224,255,.94);
  font:600 10px/1 var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  letter-spacing:.02em;
  opacity:0;
  visibility:hidden;
  white-space:nowrap;
  transition:opacity .12s ease, transform .12s ease, visibility .12s ease;
}
#playheadHandle:hover #playheadFrameBadge,
#playheadHandle:focus-visible #playheadFrameBadge{
  opacity:1;
  visibility:visible;
  transform:translate(-50%, 0);
}
#wavePlayhead {
  display: none; /* Hidden - #playhead covers all tracks including audio */
}
#keyframeWavePlayhead {
  position: sticky;
  left: var(--keyframe-lane-header-width);
  top: var(--keyframe-sticky-header-height);
  width: 2px;
  height: var(--keyframe-ruler-wave-height);
  margin-top: calc(0px - var(--keyframe-ruler-wave-height));
  pointer-events: none;
  z-index: 50;
}
#keyframePlayheadHandle {
  top: 0;
}
#keyframeWavePlayhead[data-overflow="before"],
#keyframeWavePlayhead[data-overflow="after"] {
  /* The parked scrubber must remain draggable above clip-range handles. */
  z-index: 60;
}
#keyframeWavePlayhead[data-overflow="before"]::after,
#keyframeWavePlayhead[data-overflow="after"]::after {
  content: attr(data-time-label);
  position: absolute;
  top: 2px;
  right: 10px;
  padding: 3px 6px;
  border-radius: 3px;
  background: #192e46;
  color: #c4e3ff;
  font: 600 10px/1.2 var(--mono, ui-monospace, monospace);
  white-space: nowrap;
}
#keyframeWavePlayhead[data-overflow="before"]::after {
  left: 10px;
  right: auto;
}
/* A single cap starts at the ruler edge and tapers into the playhead line. */
#keyframePlayheadHandle::before {
  left: 6px;
  top: 0;
  width: 14px;
  height: 16px;
  border: 0;
  border-radius: 2px 2px 0 0;
  clip-path: polygon(0 0, 100% 0, 100% 60%, 50% 100%, 0 60%);
  box-shadow: inset 0 1px 0 rgba(220,241,255,.65);
}
#keyframePlayheadHandle::after {
  display: none;
}
#keyframePlayheadHandle:hover::before,
#keyframePlayheadHandle:focus-visible::before {
  transform: none;
  box-shadow: inset 0 1px 0 rgba(240,249,255,.9);
}
#keyframePlayheadHandle:focus-visible {
  outline: none;
}
#inspector{
  flex: 0 0 auto;
  border-top:1px solid var(--line);
  background: rgba(255,255,255,.03);
  padding: 10px 12px;
  display:none;
  gap: 14px;
  align-items:center;
  flex-wrap:wrap;
}
#inspector.debug-visible{
  display:flex;
}
.kv{
  display:flex; flex-direction:column; gap:6px;
  color: var(--muted);
  font-size:12px;
}
.kv b{color:var(--text); font-size:12px;}
.warn{color: var(--bad);}
.ok{color: var(--good);}
#startOverlay{
  position:fixed;
  inset:0;
  display:grid;
  place-items:center;
  overflow:hidden;
  isolation:isolate;
  background:#050812;
  z-index: 100;
}
#startOverlay::before {
  content:'';
  position:absolute;
  inset:-34%;
  background:
    radial-gradient(circle at 24% 30%, rgba(72, 118, 230, .42) 0, rgba(72, 118, 230, 0) 34%),
    radial-gradient(circle at 72% 28%, rgba(99, 55, 191, .34) 0, rgba(99, 55, 191, 0) 32%),
    radial-gradient(circle at 64% 72%, rgba(22, 135, 151, .29) 0, rgba(22, 135, 151, 0) 36%),
    radial-gradient(circle at 22% 78%, rgba(161, 54, 121, .20) 0, rgba(161, 54, 121, 0) 30%),
    #050812;
  filter:blur(26px) saturate(112%);
  transform:translate3d(-2%, -1%, 0) scale(1.02);
  animation:start-gradient-drift 26s ease-in-out infinite alternate;
  z-index: 0;
}
#startOverlay::after {
  content:'';
  position:absolute;
  inset:0;
  background:
    radial-gradient(ellipse at center, transparent 30%, rgba(2, 4, 10, .34) 72%, rgba(1, 3, 8, .78) 100%),
    linear-gradient(135deg, rgba(255, 255, 255, .018), transparent 42%);
  pointer-events:none;
  z-index:0;
}
@keyframes start-gradient-drift {
  0% { transform:translate3d(-3%, -2%, 0) scale(1.02) rotate(-1deg); }
  48% { transform:translate3d(3%, 1%, 0) scale(1.08) rotate(1deg); }
  100% { transform:translate3d(-1%, 4%, 0) scale(1.04) rotate(-.5deg); }
}
@media (prefers-reduced-motion: reduce) {
  #startOverlay::before { animation:none; }
}
#startCard {
  z-index: 1;
}
#startCard{
  width: min(1200px, 92vw);
  position: relative;
  border-radius: 20px;
  padding: 1px;
  background: linear-gradient(135deg, 
    rgba(100,140,180,0.3) 0%, 
    rgba(60,80,120,0.15) 50%,
    rgba(100,140,180,0.2) 100%);
  box-shadow: 
    0 25px 80px rgba(0,0,0,.7),
    0 8px 32px rgba(0,0,0,.4);
}
#startCardInner{
  background: linear-gradient(145deg, 
    rgba(15,22,35,0.95) 0%,
    rgba(10,16,28,0.98) 100%);
  border-radius: 19px;
  padding: 16px;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 32px;
  overflow: hidden;
}
#startCard::before{
  content: '';
  position: absolute;
  inset: 1px;
  border-radius: 19px;
  background: linear-gradient(180deg, 
    rgba(255,255,255,0.03) 0%, 
    transparent 30%);
  pointer-events: none;
}

.kf-clipboard { display: flex; gap: 4px; flex-shrink: 0; }
.kf-clipboard-btn:hover:not(:disabled) { background: rgba(255,255,255,.1); }
.kf-clipboard-btn:disabled { opacity: .35; cursor: default; }
