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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 32px;
}

.header h1 {
  font-size: 28px;
  font-weight: 700;
  color: #1a1a2e;
}

.subtitle {
  color: #6b7280;
  margin-top: 4px;
  font-size: 14px;
}

/* Upload Section */
.upload-section {
  margin-bottom: 32px;
}

.upload-zone {
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fff;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: #3b82f6;
  background: #eff6ff;
}

.upload-icon {
  font-size: 40px;
  color: #3b82f6;
  font-weight: 300;
  line-height: 1;
  margin-bottom: 8px;
}

.upload-text {
  font-size: 15px;
  color: #374151;
}

.upload-hint {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 4px;
}

/* Upload Preview */
.upload-preview {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.preview-container {
  max-height: 400px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: #f9fafb;
}

.preview-container img,
.preview-container video {
  max-width: 100%;
  max-height: 400px;
  display: block;
  border-radius: 8px;
}

.preview-info {
  text-align: center;
  font-size: 13px;
  color: #6b7280;
  margin-top: 10px;
}

/* Conversion option toggle */
.convert-option {
  text-align: center;
  margin-top: 12px;
}

.convert-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
  background: #f0fdf4;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid #bbf7d0;
  user-select: none;
}

.convert-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #22c55e;
  cursor: pointer;
}

.toggle-label {
  color: #166534;
}

/* Conversion progress bar */
.convert-progress {
  margin-top: 16px;
  text-align: center;
}

.convert-progress-bar {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.convert-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #22c55e);
  border-radius: 4px;
  transition: width 0.3s;
}

.convert-progress-text {
  font-size: 12px;
  color: #6b7280;
  margin-top: 6px;
}

/* FFmpeg loading state */
.convert-progress.loading .convert-progress-fill {
  width: 100%;
  background: linear-gradient(
    90deg,
    #3b82f6 25%,
    #60a5fa 50%,
    #3b82f6 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.preview-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-cancel {
  background: #f3f4f6;
  color: #374151;
}

.btn-cancel:hover {
  background: #e5e7eb;
}

.btn-upload {
  background: #3b82f6;
  color: #fff;
}

.btn-upload:hover {
  background: #2563eb;
}

.btn-upload:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}

/* Gallery */
.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.gallery-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.count {
  font-size: 13px;
  color: #6b7280;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.gallery-item {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gallery-item img,
.gallery-item video {
  width: 100%;
  height: 200px;
  display: block;
  object-fit: cover;
}

.gallery-item video {
  background: #000;
}

.gallery-item .badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  pointer-events: none;
}

.gallery-item .meta {
  padding: 10px 12px;
  font-size: 12px;
  color: #9ca3af;
  display: flex;
  justify-content: space-between;
  position: relative;
}

/* Video indicator play button overlay */
.gallery-item .play-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.gallery-item .play-indicator::after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-left: 16px solid #fff;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  margin-left: 4px;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.lightbox.active {
  display: flex;
}

.lightbox-content {
  max-width: 95%;
  max-height: 90vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.lightbox-content video {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  background: #000;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 24px;
  font-size: 36px;
  color: #fff;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  background: none;
  border: none;
  line-height: 1;
}

.lightbox-close:hover {
  opacity: 1;
}

/* Loading & Empty */
.loading,
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 20px;
  color: #6b7280;
  font-size: 14px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1f2937;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 2000;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: #dc2626;
}

.toast.success {
  background: #059669;
}

/* Responsive */
@media (max-width: 640px) {
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
  }

  .gallery-item img,
  .gallery-item video {
    height: 150px;
  }
}
