:root {
  --accent: #9146ff;
  --bg: #1b1b1f;
  --panel-bg: #232329;
  --border: #34343c;
  --text: #e8e8ec;
  --text-dim: #9b9ba3;
  --danger: #e5484d;
  --ok: #3ddc84;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
}

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

input[type="text"] {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 14px;
  width: 100%;
}

input[type="text"]:disabled {
  opacity: 0.5;
}

button {
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid var(--border);
  padding: 8px 14px;
  font-size: 14px;
  background: var(--panel-bg);
  color: var(--text);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.primary-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
  width: 100%;
}

.primary-btn:hover:not(:disabled) { filter: brightness(1.1); }

.secondary-btn {
  background: var(--panel-bg);
}

.secondary-btn:hover:not(:disabled) { border-color: var(--accent); }

.secondary-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Top rows --- */
.url-row {
  display: flex;
  gap: 8px;
}
.url-row #url-input { flex: 1; }

.range-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
}

.range-fields {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.range-fields label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
}
.range-fields input {
  width: 140px;
}

.range-required-label {
  color: var(--text-dim);
}

.status-line {
  color: var(--text-dim);
  min-height: 18px;
}
.status-line.error { color: var(--danger); }

.privacy-hint {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: -8px;
}

/* --- Main row: video + panel --- */
.main-row {
  display: flex;
  gap: 14px;
}

.video-wrap {
  flex: 1;
  position: relative;
  background: black;
  border-radius: 8px;
  overflow: hidden;
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#video {
  width: 100%;
  height: 100%;
  max-height: 500px;
  object-fit: contain;
  background: black;
  display: block;
}

.crop-overlay {
  position: absolute;
  inset: 0;
  cursor: default;
}
.crop-overlay.editing { cursor: crosshair; }

.crop-box {
  position: absolute;
  border: 2px dashed var(--accent);
  background: rgba(145, 70, 255, 0.12);
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.crop-overlay.editing .crop-box {
  pointer-events: auto;
  cursor: move;
}

.crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: white;
  border: 1px solid var(--accent);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.crop-overlay.editing .crop-handle {
  pointer-events: auto;
}

.panel {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  color: var(--text-dim);
  margin-top: 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.logo {
  display: block;
  width: 160px;
  margin: 12px auto 0;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0 4px;
}

.section-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.row-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dim-input { width: 70px; }

.crop-fields {
  gap: 14px;
}
.crop-fields label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
  font-size: 12px;
}
.dim-input-sm { width: 64px; }

.scale-row .scale-btn {
  flex: 1;
  padding: 6px 4px;
  font-size: 13px;
}

.crop-status {
  color: var(--text-dim);
  font-size: 12px;
  min-height: 16px;
}

.export-status {
  min-height: 20px;
  font-size: 13px;
  color: var(--text-dim);
}
.export-status.error { color: var(--danger); }
.export-status a {
  color: var(--ok);
  font-weight: 600;
  text-decoration: none;
}
.export-status a:hover { text-decoration: underline; }

/* --- Playback controls --- */
.controls-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.time-label {
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

.shortcut-hint {
  color: var(--text-dim);
  font-size: 12px;
  margin-left: auto;
}

/* --- Timeline --- */
.timeline-wrap {
  padding: 10px 0;
}

.timeline-track {
  position: relative;
  height: 14px;
  background: #3a3a3a;
  border-radius: 4px;
  margin: 0 10px;
  user-select: none;
}

.timeline-selection {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--accent);
  border-radius: 4px;
}

.timeline-playhead {
  position: absolute;
  top: -6px;
  bottom: -6px;
  width: 2px;
  background: white;
  pointer-events: none;
}

.timeline-handle {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  border: 1px solid #222;
  transform: translate(-50%, -50%);
  cursor: grab;
}
.timeline-handle:active { cursor: grabbing; }

@media (max-width: 760px) {
  .main-row { flex-direction: column; }
  .panel { width: 100%; }
  .video-wrap { min-height: 260px; }
}
