/* ── Timeline backdrop (separate from Find/Replace backdrop) ── */
#timelineBackdrop {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, .4);
  display: none;
  z-index: 950;
}

/* ── Timeline modal container ── */
#timelineModal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 620px;
  max-width: 94%;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
  z-index: 1000;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ── */
.tm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  font-weight: 600;
  font-size: 15px;
  background: #f8f9fa;
}

.tm-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #aaa;
  padding: 0 4px;
  transition: color .15s;
}
.tm-close:hover { color: #333; }

/* ── Info row ── */
.tm-info {
  padding: 12px 20px 4px;
  font-family: monospace;
  font-size: 13px;
  color: #444;
}
.tm-arrow { color: #999; margin: 0 4px; }
.tm-dur   { color: #888; font-size: 12px; margin-left: 8px; }

/* ── Bar wrap ── */
.tm-bar-wrap {
  padding: 10px 24px 4px;
}

.tm-bar {
  height: 36px;
  background: linear-gradient(to right, #dbeeff, #c8e8ff);
  border: 1px solid #aad4f0;
  border-radius: 8px;
  position: relative;
  cursor: pointer;
  user-select: none;
}

/* Draggable handle */
.tm-handle {
  width: 14px;
  height: 52px;
  background: var(--color-primary);
  border-radius: 5px;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: ew-resize;
  box-shadow: 0 2px 8px rgba(0, 123, 255, .4);
  transition: box-shadow .1s;
  touch-action: none;
}
.tm-handle:hover  { box-shadow: 0 2px 14px rgba(0, 123, 255, .6); }
.tm-handle:active { box-shadow: 0 2px 18px rgba(0, 123, 255, .8); }

/* ── Labels row ── */
.tm-labels {
  position: relative;
  height: 22px;
  margin-top: 2px;
  font-family: monospace;
  font-size: 10px;
}

.tm-label-start {
  position: absolute;
  left: 0;
  color: #888;
}

.tm-label-end {
  position: absolute;
  right: 0;
  color: #888;
}

.tm-label-split {
  position: absolute;
  transform: translateX(-50%);
  color: var(--color-primary);
  font-weight: 700;
  font-size: 11px;
  white-space: nowrap;
  background: #fff;
  padding: 0 3px;
  border-radius: 3px;
}

/* ── Preview segments ── */
.tm-preview {
  display: flex;
  gap: 12px;
  padding: 14px 20px 10px;
}

.tm-seg {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.tm-seg-time {
  font-size: 10px;
  font-family: monospace;
  color: #555;
  background: #f0f6ff;
  border-radius: 5px;
  padding: 4px 8px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tm-seg-text {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}
.tm-seg-text:focus { border-color: var(--color-primary); }

/* ── Footer ── */
.tm-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #eee;
  background: #f8f9fa;
}

/* ── Mobile adjustments ── */
@media (max-width: 640px) {
  #timelineModal { max-width: 98%; }
  .tm-preview { flex-direction: column; }
  .tm-seg-time { white-space: normal; }
}
