:root {
  color-scheme: dark;
  --bg: #121416;
  --panel: #1b1f23;
  --line: #2c333a;
  --ink: #e7ecef;
  --muted: #9aa3ab;
  --video: #1d6f97;
  --audio: #1d7a52;
  --accent: #3ecfb2;
  --playhead: #ff5d5d;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body {
  overflow: hidden;
}

.editor {
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.editor-topbar {
  min-height: 52px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: #171b1f;
}

.editor-topbar .btn {
  white-space: nowrap;
}

.topbar-note,
.toolbar-note,
.export-status,
.library-meta,
.inspector-hint {
  color: var(--muted);
}

.topbar-note {
  margin-left: 10px;
  font-size: 13px;
}

.editor-main {
  flex: 1;
  min-height: 0;
  display: flex;
}

.panel {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.library {
  width: 300px;
  flex: none;
  border-right: 1px solid var(--line);
}

.export-pane {
  width: 280px;
  flex: none;
  border-left: 1px solid var(--line);
  padding-bottom: 12px;
}

.panel-title {
  padding: 12px 14px 8px;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.library.is-over {
  outline: 2px dashed var(--accent);
  outline-offset: -6px;
}

.library-empty {
  margin: 8px 14px;
  padding: 22px 12px;
  border: 1px dashed #3c4650;
  border-radius: 10px;
  text-align: center;
  color: var(--muted);
}

.library-empty p {
  margin: 0 0 6px;
}

.library-empty[hidden] {
  display: none;
}

.library-list {
  list-style: none;
  margin: 0;
  padding: 0 10px 12px;
  overflow: auto;
}

.library-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "badge text"
    "actions actions";
  gap: 6px 8px;
  align-items: center;
  padding: 8px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: #23282d;
  cursor: grab;
}

.library-item:active {
  cursor: grabbing;
}

.kind-badge {
  grid-area: badge;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  padding: 3px 5px;
}

.kind-video {
  background: #1d6f97;
}

.kind-audio {
  background: #1d7a52;
}

.library-text {
  grid-area: text;
  min-width: 0;
}

.library-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}

.library-meta {
  font-size: 12px;
}

.library-actions {
  grid-area: actions;
  display: flex;
  gap: 6px;
}

.library-actions .btn {
  flex: 1;
  padding-inline: 8px;
}

.preview-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #101214;
}

.preview-stage {
  position: relative;
  flex: 1;
  min-height: 180px;
  background: #000;
}

.preview-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
}

.preview-empty[hidden] {
  display: none !important;
}

.transport {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: #171b1f;
}

.time-label {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  min-width: 8.5em;
}

.scrub {
  flex: 1;
  margin: 0;
}

.inspector {
  border-top: 1px solid var(--line);
  padding: 10px 12px 12px;
  background: #171b1f;
}

.inspector-hint {
  font-size: 13px;
}

.inspector-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.inspector-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.number-field,
.volume-field,
.zoom-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.volume-field {
  margin-top: 8px;
}

.inspector-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.mute-check {
  margin: 0;
}

.export-pane form {
  padding: 0 14px;
  overflow: auto;
}

.export-pane .form-label {
  margin: 10px 0 4px;
  font-size: 12px;
  color: var(--muted);
}

.export-pane fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-inline-size: 0;
}

.export-duration {
  display: flex;
  justify-content: space-between;
  margin: 12px 0;
  font-variant-numeric: tabular-nums;
}

.export-status {
  font-size: 12px;
  margin: 8px 0 0;
}

.timeline-pane {
  height: 292px;
  flex: none;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
  background: #15191c;
}

.timeline-toolbar {
  height: 42px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.toolbar-note {
  font-size: 12px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.snap-check {
  margin: 0;
  font-size: 13px;
  white-space: nowrap;
}

.zoom-label {
  flex-direction: row;
  align-items: center;
  margin: 0;
  white-space: nowrap;
}

.zoom-range {
  width: 110px;
  margin: 0;
}

.timeline-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

.track-labels {
  width: 104px;
  flex: none;
  border-right: 1px solid var(--line);
  background: #171b1f;
}

.ruler,
.ruler-spacer {
  height: 28px;
}

.track-label,
.track-lane {
  height: 72px;
}

.track-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 10px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.track-label span {
  color: var(--muted);
  font-size: 11px;
}

.timeline-scroll {
  flex: 1;
  min-width: 0;
  overflow: auto;
  position: relative;
  user-select: none;
}

.timeline-canvas {
  position: relative;
  min-height: 100%;
}

.ruler {
  position: relative;
  border-bottom: 1px solid var(--line);
  background: #171b1f;
}

.tick {
  position: absolute;
  top: 0;
  height: 28px;
  border-left: 1px solid #3a424a;
  color: var(--muted);
  font-size: 10px;
  line-height: 28px;
  padding-left: 4px;
  font-variant-numeric: tabular-nums;
}

.track-lane {
  position: relative;
  border-top: 1px solid #2a3138;
}

.track-lane[data-track="v2"] {
  background: #1b242c;
}

.track-lane[data-track="v1"] {
  background: #182028;
}

.track-lane[data-track="a1"] {
  background: #17241e;
}

.track-lane.is-target {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.clip {
  position: absolute;
  top: 8px;
  height: 56px;
  border-radius: 6px;
  color: white;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.clip:active {
  cursor: grabbing;
}

.clip-video {
  background: var(--video);
}

.clip-audio {
  background: var(--audio);
}

.clip.is-muted {
  background: #5c6770;
}

.clip.is-selected {
  box-shadow: inset 0 0 0 2px #fff;
}

.trim {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  z-index: 2;
  cursor: ew-resize;
  background: rgba(255, 255, 255, 0.28);
}

.trim-left {
  left: 0;
}

.trim-right {
  right: 0;
}

.clip-body {
  padding: 6px 12px;
  pointer-events: none;
}

.clip-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clip-meta {
  display: flex;
  gap: 6px;
  font-size: 11px;
  opacity: 0.9;
}

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  z-index: 6;
  pointer-events: none;
}

.playhead::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 2px;
  background: var(--playhead);
}

.playhead::after {
  content: "";
  position: absolute;
  top: 0;
  left: -5px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid var(--playhead);
}

.playhead-hit {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -8px;
  width: 16px;
  pointer-events: auto;
  cursor: ew-resize;
}

.media-sink {
  position: fixed;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}

.media-sink video,
.media-sink audio {
  width: 160px;
  height: 90px;
}

.is-exporting .library,
.is-exporting .preview-pane .transport,
.is-exporting .inspector,
.is-exporting .timeline-pane,
.is-exporting #import-btn {
  pointer-events: none;
  opacity: 0.72;
}

@media (max-width: 1100px) {
  body {
    overflow: auto;
  }

  .editor-topbar {
    align-items: flex-start;
  }

  .editor {
    height: auto;
    min-height: 100vh;
  }

  .editor-main {
    flex-direction: column;
  }

  .library,
  .export-pane {
    width: 100%;
    border: 0;
    border-top: 1px solid var(--line);
  }

  .library {
    max-height: 280px;
  }

  .preview-stage {
    min-height: 240px;
  }

  .timeline-pane {
    height: 340px;
  }

  .toolbar-note {
    display: none;
  }
}
