* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0a0a0f;
  color: #e0e0e0;
  min-height: 100vh;
}

header {
  text-align: center;
  padding: 32px 20px 16px;
}

header h1 {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, #6ee7b7, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: #888;
  margin-top: 8px;
  font-size: 14px;
}

/* Presets */
#preset-section {
  text-align: center;
  padding: 0 20px 8px;
}

.preset-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #1a1a24;
  border-radius: 10px;
  padding: 6px 12px;
}

.preset-label {
  font-size: 13px;
  color: #888;
  margin-right: 4px;
}

.preset-btn {
  padding: 6px 16px;
  border: 1px solid #333;
  background: #222;
  color: #ccc;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.preset-btn:hover {
  background: #333;
  border-color: #555;
}

.preset-btn.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

/* Upload Section */
#upload-section {
  display: flex;
  gap: 20px;
  padding: 20px 40px;
  max-width: 900px;
  margin: 0 auto;
}

.upload-box {
  flex: 1;
  border: 2px dashed #333;
  border-radius: 16px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  background: #111118;
}

.upload-box:hover {
  border-color: #3b82f6;
  background: #12121f;
}

.upload-box.has-file {
  border-color: #22c55e;
  border-style: solid;
}

.upload-content {
  pointer-events: none;
}

.upload-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #1e293b, #334155);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
  color: #6ee7b7;
}

#upload-right .upload-icon {
  color: #60a5fa;
}

.upload-box p {
  color: #999;
  font-size: 14px;
  line-height: 1.6;
}

.file-info {
  margin-top: 12px;
  font-size: 12px;
  color: #6ee7b7;
  word-break: break-all;
}

/* Mode Section */
#mode-section {
  text-align: center;
  padding: 8px 20px 16px;
}

.mode-tabs {
  display: inline-flex;
  gap: 4px;
  background: #1a1a24;
  border-radius: 10px;
  padding: 4px;
}

.mode-tab {
  padding: 8px 24px;
  border: none;
  background: transparent;
  color: #888;
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-tab:hover {
  color: #ccc;
}

.mode-tab.active {
  background: #3b82f6;
  color: white;
}

/* Compare Section */
#compare-section {
  padding: 0 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.compare-view {
  display: none;
}

.compare-view.active {
  display: block;
}

/* Slider Mode */
#slider-container {
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

#slider-video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

#video-left-slider,
#video-right-slider {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#slider-clip {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 50%;
  overflow: hidden;
}

#slider-clip video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* we transform clip's video to align with left video */
}

#slider-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  transform: translateX(-50%);
  cursor: ew-resize;
  z-index: 10;
}

.slider-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: white;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

.slider-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.video-label {
  position: absolute;
  bottom: 16px;
  padding: 4px 16px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  z-index: 5;
  pointer-events: none;
}

.label-left {
  left: 16px;
}

.label-right {
  right: 16px;
}

/* Side by Side Mode */
.sbs-container {
  display: flex;
  gap: 4px;
  max-width: 1400px;
  margin: 0 auto;
}

.sbs-panel {
  flex: 1;
  position: relative;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}

.sbs-panel video {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

.video-label-top {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 16px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  z-index: 5;
  white-space: nowrap;
}

/* Toggle Mode */
#toggle-container {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

#toggle-container video {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

#video-right-toggle {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  transition: opacity 0.1s;
}

#video-right-toggle.show {
  opacity: 1;
}

.toggle-label {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 24px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  z-index: 5;
  pointer-events: none;
  transition: background 0.15s;
}

.toggle-label.is-b {
  background: rgba(59, 130, 246, 0.8);
}

/* Zoom Lens */
#zoom-lens {
  position: fixed;
  width: 280px;
  height: 280px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  overflow: hidden;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  background: #000;
}

#zoom-canvas {
  width: 100%;
  height: 100%;
}

.zoom-label {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: white;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

/* Controls */
#controls-section {
  position: sticky;
  bottom: 0;
  background: #111118;
  border-top: 1px solid #222;
  z-index: 50;
}

.controls-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.controls-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.controls-center {
  flex: 1;
  min-width: 0;
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.controls-bar button {
  background: #222;
  border: 1px solid #333;
  color: #ddd;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.controls-bar button:hover {
  background: #333;
}

#time-display {
  font-size: 13px;
  color: #aaa;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#seek-bar {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #333;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

#seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: #3b82f6;
  border-radius: 50%;
  cursor: pointer;
}

.speed-label,
.zoom-toggle {
  font-size: 13px;
  color: #aaa;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.speed-label select {
  background: #222;
  border: 1px solid #333;
  color: #ddd;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 13px;
}

.zoom-toggle input {
  accent-color: #3b82f6;
}

/* Instructions */
#instructions-section {
  max-width: 600px;
  margin: 24px auto;
  padding: 0 20px 40px;
}

.instructions {
  background: #111118;
  border: 1px solid #1e1e2a;
  border-radius: 12px;
  padding: 20px 24px;
}

.instructions h3 {
  font-size: 15px;
  color: #aaa;
  margin-bottom: 12px;
}

.instructions ul {
  list-style: none;
  font-size: 13px;
  color: #777;
  line-height: 2;
}

.instructions li strong {
  color: #bbb;
  display: inline-block;
  min-width: 50px;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Drag over */
.upload-box.drag-over {
  border-color: #3b82f6;
  background: #1a1a30;
}

/* Fullscreen */
#compare-section:fullscreen {
  background: #000;
  max-width: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#compare-section:fullscreen .compare-view.active {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#compare-section:fullscreen #slider-container {
  max-width: none;
  width: 100%;
  height: 100%;
  border-radius: 0;
}

#compare-section:fullscreen #slider-video-wrapper {
  aspect-ratio: unset;
  width: 100%;
  height: 100%;
}

#compare-section:fullscreen .sbs-container {
  max-width: none;
  width: 100%;
  height: 100%;
  align-items: center;
}

#compare-section:fullscreen .sbs-panel video {
  aspect-ratio: unset;
  height: 100vh;
}

#compare-section:fullscreen #toggle-container {
  max-width: none;
  width: 100%;
  height: 100%;
  border-radius: 0;
}

#compare-section:fullscreen #toggle-container video {
  aspect-ratio: unset;
  width: 100%;
  height: 100%;
}

/* Responsive */
@media (max-width: 768px) {
  #upload-section {
    flex-direction: column;
    padding: 20px;
  }

  .sbs-container {
    flex-direction: column;
  }

  .controls-bar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
  }

  .controls-center {
    order: -1;
    width: 100%;
    flex-basis: 100%;
  }
}
