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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface-hover: #252525;
  --border: #333;
  --text: #e0e0e0;
  --text-muted: #888;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --secondary: #374151;
  --secondary-hover: #4b5563;
  --success: #10b981;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 4rem 2rem;
  text-align: center;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s ease;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.drop-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}

.drop-zone p {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.drop-hint {
  color: var(--text-muted);
  font-size: 0.9rem !important;
}

.file-label {
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
}

.file-label:hover {
  color: var(--primary-hover);
}

/* Video Section */
.video-section {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.video-container {
  background: #000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.video-container video {
  max-width: 100%;
  max-height: 400px;
}

.controls {
  padding: 1.5rem;
}

.controls h3 {
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
  color: var(--text-muted);
}

.control-group {
  margin-bottom: 1rem;
}

.control-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.9rem;
}

.control-group input,
.control-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
}

.control-group input:focus,
.control-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.control-group .hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Crop Overlay */
.video-container {
  position: relative;
}

.crop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.crop-region {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 2px dashed var(--primary);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.crop-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  background: var(--primary);
  border: 2px solid white;
  border-radius: 50%;
  pointer-events: auto;
  cursor: pointer;
  transform: translate(-50%, -50%);
  z-index: 10;
}

.crop-handle:hover {
  background: var(--primary-hover);
  transform: translate(-50%, -50%) scale(1.2);
}

/* Corner handles */
.crop-handle.top-left { top: 0; left: 0; cursor: nwse-resize; }
.crop-handle.top-right { top: 0; right: 0; transform: translate(50%, -50%); cursor: nesw-resize; }
.crop-handle.bottom-left { bottom: 0; left: 0; transform: translate(-50%, 50%); cursor: nesw-resize; }
.crop-handle.bottom-right { bottom: 0; right: 0; transform: translate(50%, 50%); cursor: nwse-resize; }

/* Edge handles */
.crop-handle.top { top: 0; left: 50%; cursor: ns-resize; }
.crop-handle.bottom { bottom: 0; left: 50%; transform: translate(-50%, 50%); cursor: ns-resize; }
.crop-handle.left { top: 50%; left: 0; cursor: ew-resize; }
.crop-handle.right { top: 50%; right: 0; transform: translate(50%, -50%); cursor: ew-resize; }

.crop-handle.top-right:hover,
.crop-handle.bottom-left:hover { transform: translate(50%, -50%) scale(1.2); }
.crop-handle.bottom-right:hover { transform: translate(50%, 50%) scale(1.2); }
.crop-handle.bottom:hover { transform: translate(-50%, 50%) scale(1.2); }
.crop-handle.right:hover { transform: translate(50%, -50%) scale(1.2); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 0.5rem;
}

.btn.primary {
  background: var(--primary);
  color: white;
}

.btn.primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn.secondary {
  background: var(--secondary);
  color: var(--text);
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Progress */
.progress-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
}

.progress-content {
  max-width: 400px;
  margin: 0 auto;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.5rem;
}

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

#progressText {
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.3s ease;
}

/* Result */
.result-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}

.result-section h3 {
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
}

.gif-preview {
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
  display: inline-block;
}

.gif-preview img {
  max-width: 100%;
  max-height: 400px;
  display: block;
}

.result-info {
  margin-bottom: 1.5rem;
  color: var(--text-muted);
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  max-width: 400px;
  margin: 0 auto;
}

.result-actions .btn {
  margin-top: 0;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
}

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

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 1rem;
  }
  
  header h1 {
    font-size: 2rem;
  }
  
  .drop-zone {
    padding: 3rem 1.5rem;
  }
  
  .result-actions {
    grid-template-columns: 1fr;
  }
}
