:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --controls-bg: rgba(0, 0, 0, 0.88);
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.4);
  --text: #e5e5e5;
  --text-muted: #737373;
  --seek-bg: rgba(255, 255, 255, 0.15);
  --buffer-bg: rgba(255, 255, 255, 0.25);
  --radius: 8px;
  --transition: 0.25s ease;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

.hidden { display: none !important; }

/* ── Video elements (hidden) ── */
#mainVideo, #previewVideo {
  position: fixed;
  top: -9999px;
  left: -9999px;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

/* ── Drop zone ── */
.drop-zone {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: var(--bg);
  cursor: pointer;
  transition: opacity 0.4s ease;
}

.drop-zone-content {
  text-align: center;
  padding: 60px;
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  transition: all 0.3s ease;
  max-width: 480px;
}

.drop-zone.drag-over .drop-zone-content {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.06);
  transform: scale(1.02);
}

.drop-icon {
  color: var(--text-muted);
  margin-bottom: 20px;
  transition: color var(--transition), transform var(--transition);
}

.drop-zone.drag-over .drop-icon {
  color: var(--accent);
  transform: translateY(4px);
}

.drop-zone-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.drop-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.drop-formats {
  color: var(--text-muted);
  font-size: 0.8rem;
  opacity: 0.6;
  letter-spacing: 0.5px;
}

/* ── Loading overlay ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 90;
  background: var(--bg);
  gap: 20px;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Canvas container ── */
.canvas-container {
  position: fixed;
  inset: 0;
  z-index: 1;
  cursor: grab;
}

.canvas-container:active {
  cursor: grabbing;
}

.canvas-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ── Controls ── */
.controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: 0 16px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,0.6) 30%, var(--controls-bg));
  opacity: 1;
  transition: opacity 0.4s ease;
  pointer-events: auto;
}

.controls.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 40px 4px 8px;
  gap: 12px;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-shrink: 0;
}

.file-name {
  font-size: 0.85rem;
  color: var(--text);
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.format-select {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
  flex-shrink: 0;
  transition: border-color var(--transition);
}

.format-select:hover,
.format-select:focus {
  border-color: var(--accent);
}

.format-select option,
.format-select optgroup {
  background: #1e1e1e;
  color: var(--text);
}

.adjust-toggles {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.depth3d-strength {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.08);
}

.depth3d-strength-label {
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.25px;
  text-transform: uppercase;
}

.depth3d-strength-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 92px;
  height: 4px;
  border-radius: 999px;
  background: var(--seek-bg);
  outline: none;
  cursor: pointer;
}

.depth3d-strength-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.depth3d-strength-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.ctrl-btn.top-btn {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
}

.ctrl-btn.top-btn:hover {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fff;
}

.depth3d-btn {
  width: auto;
  padding: 0 7px;
  font-size: 0.68rem;
  letter-spacing: 0.3px;
}

.toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}

.toggle-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
}

.toggle-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Seek bar ── */
.seek-container {
  position: relative;
  padding: 16px 4px 12px;
}

.seek-bar {
  --seek-hover-strength: 0;
  position: relative;
  height: calc(4px + var(--seek-hover-strength) * 10px);
  background: var(--seek-bg);
  border-radius: calc(2px + var(--seek-hover-strength) * 6px);
  cursor: pointer;
  transform: translateY(calc(var(--seek-hover-strength) * -2px));
  box-shadow: 0 0 calc(var(--seek-hover-strength) * 18px) rgba(99, 102, 241, 0.22);
  transition: height 0.2s ease, border-radius 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.buffer-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--buffer-bg);
  border-radius: 2px;
  pointer-events: none;
  width: 0%;
}

.progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  pointer-events: none;
  width: 0%;
  transition: none;
}

.seek-handle {
  position: absolute;
  top: 50%;
  left: 0%;
  width: calc(14px + var(--seek-hover-strength) * 8px);
  height: calc(14px + var(--seek-hover-strength) * 8px);
  background: var(--accent);
  border-radius: 50%;
  opacity: calc(var(--seek-hover-strength) * 0.98);
  transform: translate(-50%, -50%) scale(calc(0.4 + var(--seek-hover-strength) * 0.6));
  pointer-events: none;
  transition: transform 0.2s ease, width 0.2s ease, height 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* Seek preview tooltip */
.seek-preview {
  position: absolute;
  bottom: calc(100% + 12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  transform: translateX(-50%);
  z-index: 60;
}

.seek-preview canvas {
  border-radius: 4px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: #000;
}

.preview-time {
  font-size: 0.75rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.8);
  padding: 2px 8px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}

.seek-preview.loading canvas {
  opacity: 0.45;
}

.seek-preview.loading::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -13px 0 0 -9px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  z-index: 1;
  pointer-events: none;
}

/* ── Bottom bar ── */
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 0;
  gap: 12px;
}

.left-controls,
.right-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  border-radius: 6px;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.time-display {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.time-sep {
  margin: 0 3px;
  opacity: 0.5;
}

/* Volume */
.volume-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.volume-slider-wrap {
  display: flex;
  align-items: center;
  width: 0;
  overflow: hidden;
  transition: width 0.25s ease;
}

.volume-group:hover .volume-slider-wrap {
  width: 80px;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  margin: 0;
  padding: 0;
  background: var(--seek-bg);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  vertical-align: middle;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

/* ── Help button ── */
.help-btn {
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.5;
  transition: opacity var(--transition), background var(--transition), color var(--transition);
}

.help-btn:hover,
.help-btn.active {
  opacity: 1;
  background: rgba(0, 0, 0, 0.7);
  color: var(--text);
}

/* ── Shortcuts hint ── */
.shortcuts-hint {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 80;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.shortcuts-hint.auto-show {
  pointer-events: none;
  animation: fadeInOut 3.5s ease forwards;
}

.shortcuts-hint.manual-show {
  opacity: 1;
  pointer-events: auto;
}

.shortcuts-hint .hint-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.shortcuts-hint .hint-section {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.25);
  margin-top: 10px;
  margin-bottom: 4px;
}

.shortcuts-hint .hint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 3px 0;
}

.shortcuts-hint .hint-keys {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.shortcuts-hint .hint-label {
  color: var(--text-muted);
  white-space: nowrap;
}

.shortcuts-hint kbd {
  display: inline-block;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.75rem;
  font-family: inherit;
  min-width: 22px;
  text-align: center;
  color: var(--text);
}

@keyframes fadeInOut {
  0%   { opacity: 0; }
  8%   { opacity: 1; }
  78%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Buffering indicator ── */
.canvas-container.buffering::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  pointer-events: none;
  z-index: 10;
}

/* ── Big play overlay ── */
.canvas-container .big-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.canvas-container .big-play.show {
  opacity: 1;
}

.canvas-container .big-play svg {
  margin-left: 4px;
}

/* ── Error overlay ── */
.error-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 90;
  background: var(--bg);
  gap: 12px;
  color: var(--text-muted);
}

.error-overlay .error-title {
  color: #ef4444;
  font-size: 1.1rem;
  font-weight: 600;
}

.error-overlay .error-detail {
  font-size: 0.85rem;
  max-width: 400px;
  text-align: center;
  line-height: 1.5;
}

.error-overlay button {
  margin-top: 8px;
  padding: 8px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .top-bar { padding-top: 30px; }
  .top-bar-actions { gap: 6px; }
  .file-name { font-size: 0.75rem; }
  .format-select { font-size: 0.75rem; padding: 4px 6px; }
  .depth3d-strength { padding: 0 8px; }
  .depth3d-strength-slider { width: 72px; }
  .time-display { font-size: 0.75rem; }
  .ctrl-btn { width: 32px; height: 32px; }
  .volume-group:hover .volume-slider-wrap { width: 60px; }
  .seek-preview canvas { width: 120px; height: 68px; }
}
