.rl-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 1400px;
  margin: 0 auto;
  /* Не ограничиваем высоту — пусть растёт и скроллится вся страница */
}

.rl-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; }
.rl-title h2 { margin: 0 0 .25rem; font-size: 1.5rem; }
.rl-title p  { margin: 0; color: #64748b; font-size: .95rem; }
.rl-header-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.rl-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem .9rem; border-radius: 8px; border: none;
  font-size: .9rem; font-weight: 600; cursor: pointer; transition: .18s;
}
.rl-btn svg { width: 16px; height: 16px; }
.rl-btn.primary   { background: #7c5cff; color: #fff; }
.rl-btn.primary:hover { background: #6b4de0; }
.rl-btn.secondary { background: #f1f5f9; color: #334155; }
.rl-btn.secondary:hover { background: #e2e8f0; }
.rl-btn.accent    { background: linear-gradient(135deg,#7c5cff,#a855f7); color: #fff; }
.rl-btn.accent:hover { filter: brightness(1.1); }
.rl-btn:disabled  { opacity: .45; cursor: not-allowed; }

/* Upload */
.rl-upload {
  min-height: calc(100vh - 200px);
  display: flex; align-items: center; justify-content: center;
  background: #f8fafc; border: 2px dashed #e2e8f0; border-radius: 12px;
}
.rl-upload.drag { border-color: #7c5cff; background: #f5f3ff; }
.rl-upload-inner { text-align: center; max-width: 340px; }
.rl-upload-inner svg { width: 52px; height: 52px; color: #94a3b8; margin-bottom: 1rem; }
.rl-upload-inner h3 { margin: 0 0 .5rem; font-size: 1.25rem; }
.rl-upload-inner p  { color: #64748b; margin: 0 0 1.5rem; }

/* Loading */
.rl-loading {
  min-height: calc(100vh - 200px);
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; background: #fff; border-radius: 12px;
}
.rl-spinner {
  width: 40px; height: 40px; border: 4px solid #f1f5f9; border-top-color: #7c5cff;
  border-radius: 50%; animation: rl-spin 1s linear infinite; margin-bottom: 1rem;
}
@keyframes rl-spin { to { transform: rotate(360deg); } }
.rl-loading h3 { margin: 0 0 .4rem; font-size: 1.1rem; }
.rl-loading p  { margin: 0; color: #64748b; font-size: .9rem; }

/* Editor layout — grid, высота по содержимому */
.rl-editor {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.5rem;
  align-items: start;  /* Важно: не растягиваем колонки, каждая по своей высоте */
}

/* Левая колонка — просто flex-column, без фиксированной высоты */
.rl-left  { display: flex; flex-direction: column; gap: 1rem; }

/* Правая колонка — фиксированная высота и скролл внутри */
.rl-right {
  display: flex; flex-direction: column;
  background: #fff; border-radius: 12px; border: 1px solid #e2e8f0;
  max-height: 80vh;
  position: sticky;
  top: 1rem;
}

/* Video */
.rl-video-wrap {
  position: relative; background: #000; border-radius: 10px;
  overflow: hidden; line-height: 0;
}
.rl-video-wrap video {
  display: block; width: 100%; max-height: 460px; object-fit: contain;
}
.rl-video-wrap canvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
}

/* Timeline */
.rl-timeline-wrap {
  background: #fff; border-radius: 10px; border: 1px solid #e2e8f0;
  padding: .75rem 1rem;
}
.rl-timeline-label {
  font-size: .8rem; font-weight: 600; color: #94a3b8;
  margin-bottom: .5rem; text-transform: uppercase; letter-spacing: .03em;
}
.rl-timeline {
  position: relative; height: 32px; background: #f1f5f9;
  border-radius: 6px; overflow: hidden; cursor: pointer;
}
.rl-tl-block {
  position: absolute; height: 100%; background: #7c5cff;
  opacity: .65; border-radius: 3px; transition: opacity .15s;
}
.rl-tl-block.active, .rl-tl-block:hover { opacity: 1; }
.rl-tl-cursor {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: #f43f5e; pointer-events: none; z-index: 5;
}

/* Style panel */
.rl-style-panel {
  background: #fff; border-radius: 10px; border: 1px solid #e2e8f0;
  padding: .75rem 1rem;
}
.rl-style-title {
  font-size: .8rem; font-weight: 600; color: #94a3b8;
  margin-bottom: .75rem; text-transform: uppercase; letter-spacing: .03em;
}
.rl-style-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.rl-style-grid label {
  display: flex; flex-direction: column; gap: .3rem;
  font-size: .82rem; font-weight: 500; color: #475569;
}
.rl-style-grid select { width: 100%; padding: .3rem .4rem; border-radius: 6px; border: 1px solid #e2e8f0; }
.rl-style-grid input[type=range] { width: 100%; margin: 0; }
.rl-style-grid input[type=color] {
  width: 100%; height: 34px; border-radius: 6px;
  border: 1px solid #e2e8f0; cursor: pointer; padding: 2px;
}
.rl-val { color: #7c5cff; font-variant-numeric: tabular-nums; }
.rl-checkbox { flex-direction: row !important; align-items: center; gap: .4rem !important; }
.rl-checkbox input { width: auto; }

/* Captions list */
.rl-caps-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: .75rem 1rem; border-bottom: 1px solid #e2e8f0;
  font-size: .85rem; font-weight: 600; color: #334155; flex-shrink: 0;
}
.rl-caps-count { font-size: .8rem; color: #94a3b8; font-weight: 400; }
.rl-caps-list { flex: 1; overflow-y: auto; padding: .5rem; }

.rl-cap-item {
  border: 1.5px solid #e2e8f0; border-radius: 8px; padding: .6rem .75rem;
  margin-bottom: .5rem; cursor: pointer; transition: border-color .15s, box-shadow .15s;
  background: #fff;
}
.rl-cap-item:hover { border-color: #a78bfa; }
.rl-cap-item.active { border-color: #7c5cff; box-shadow: 0 0 0 3px rgba(124,92,255,.12); }

.rl-cap-times { display: flex; align-items: center; gap: .4rem; margin-bottom: .4rem; }
.rl-time-in {
  width: 60px; padding: .25rem .4rem; border: 1px solid #e2e8f0;
  border-radius: 5px; font-size: .82rem; font-variant-numeric: tabular-nums; text-align: center;
}
.rl-cap-times > span { font-size: .75rem; color: #94a3b8; }
.rl-cap-del {
  margin-left: auto; width: 24px; height: 24px; border-radius: 5px; border: none;
  background: transparent; color: #94a3b8; cursor: pointer; font-size: .85rem;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.rl-cap-del:hover { background: #fee2e2; color: #ef4444; }

.rl-cap-text {
  width: 100%; resize: none; min-height: 44px; border: 1px solid #e2e8f0;
  border-radius: 6px; padding: .4rem .5rem; font-size: .88rem;
  font-family: inherit; line-height: 1.4; box-sizing: border-box;
}
.rl-cap-text:focus { outline: none; border-color: #7c5cff; }

.rl-add-cap {
  width: 100%; padding: .6rem; border: 1.5px dashed #e2e8f0; border-radius: 8px;
  background: transparent; color: #94a3b8; cursor: pointer; font-size: .88rem;
  transition: .15s; margin-top: .25rem;
}
.rl-add-cap:hover { border-color: #7c5cff; color: #7c5cff; background: #f5f3ff; }

/* Export hint for non-Chrome */
.rl-export-hint {
  padding: .5rem .75rem; background: #f1f5f9; border-radius: 8px;
  font-size: .8rem; color: #64748b; margin-top: .5rem;
}

@media (max-width: 900px) {
  .rl-editor { grid-template-columns: 1fr; }
  .rl-right { max-height: none; position: static; }
  .rl-style-grid { grid-template-columns: 1fr; }
}
