/* Prep tab — sort + mark In/Out before library export */

.prep-panel {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding-bottom: var(--s-8);
}

.modal.modal-lg:has(.prep-modal) {
  width: min(1180px, 96vw);
  max-width: min(1180px, 96vw);
  max-height: min(92vh, 900px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.prep-modal {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.prep-panel-modal {
  min-height: 0;
  overflow: hidden;
  padding-bottom: 0;
}

.prep-panel-modal .prep-layout {
  min-height: 0;
  flex: 1;
}

.prep-panel-modal .prep-col {
  min-height: 0;
}

.prep-intro {
  padding: var(--s-5) var(--s-6);
}

.prep-title {
  margin: 0 0 var(--s-2);
  font-size: 1.1rem;
  font-weight: 600;
}

.prep-desc {
  margin: 0;
  color: var(--text-3);
  font-size: 0.9rem;
  line-height: 1.5;
}

.prep-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr minmax(220px, 300px);
  gap: var(--s-4);
  align-items: start;
  min-height: 480px;
}

.prep-col {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-4);
  min-height: 420px;
}

.prep-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.prep-col-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.prep-sources-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  align-items: center;
}

.prep-filter-input {
  flex: 1 1 100px;
  min-width: 0;
}

.prep-sort-select {
  width: auto;
  min-width: 5.5rem;
  font-size: 12px;
  padding: 6px 8px;
}

.prep-sources-list,
.prep-segments-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  flex: 1;
  overflow-y: auto;
  max-height: 52vh;
  min-height: 120px;
}

.prep-empty,
.prep-empty-main {
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
  padding: var(--s-6) var(--s-3);
}

.prep-source-item {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  padding: var(--s-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  text-align: right;
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.prep-source-item:hover {
  background: var(--surface-hover);
}

.prep-source-item.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.prep-source-thumb {
  width: 56px;
  height: 36px;
  border-radius: var(--r-xs);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.prep-source-thumb img,
.prep-source-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.prep-source-thumb-fallback {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.prep-source-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.prep-source-name {
  font-size: 0.85rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prep-source-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.prep-source-remove {
  flex-shrink: 0;
  opacity: 0.5;
}

.prep-source-item:hover .prep-source-remove {
  opacity: 1;
}

.prep-main-stage {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  flex: 1;
}

.prep-player-wrap {
  background: #000;
  border-radius: var(--r-md);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  max-height: 42vh;
}

.prep-player-wrap.is-image {
  background: var(--surface-2);
}

.prep-video,
.prep-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.prep-trim-bar {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.prep-trim-track {
  position: relative;
  height: 36px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  user-select: none;
}

.prep-trim-sel {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--accent-soft-2);
  border-left: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  pointer-events: none;
}

.prep-trim-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  margin-left: -5px;
  background: var(--accent);
  border-radius: 3px;
  cursor: ew-resize;
  z-index: 2;
}

.prep-trim-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--text);
  opacity: 0.7;
  pointer-events: none;
  z-index: 1;
}

.prep-trim-meta {
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

.prep-trim-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  justify-content: center;
}

.prep-segment-item {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
}

.prep-segment-item.dragging {
  opacity: 0.5;
}

.prep-segment-grip {
  cursor: grab;
  color: var(--text-muted);
  font-size: 14px;
  user-select: none;
}

.prep-segment-idx {
  font-weight: 600;
  font-size: 12px;
  color: var(--accent);
  min-width: 1.2em;
}

.prep-segment-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.prep-segment-label {
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prep-segment-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.prep-local-pick-list {
  max-height: 50vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  margin: var(--s-3) 0;
}

.prep-local-pick-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  cursor: pointer;
}

.prep-local-pick-row:hover {
  background: var(--surface-hover);
}

.prep-local-pick-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prep-local-pick-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.prep-local-path {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0 0 var(--s-2);
}

.badge.prep-badge {
  background: rgba(175, 82, 222, 0.12);
  color: var(--purple);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--r-pill);
}

@media (max-width: 960px) {
  .prep-layout {
    grid-template-columns: 1fr;
  }

  .prep-sources-list,
  .prep-segments-list {
    max-height: 240px;
  }
}
