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

:root {
  --bg-primary: #0a0a0b;
  --bg-secondary: #141416;
  --bg-tertiary: #1c1c1f;
  --text-primary: #ffffff;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --success: #22c55e;
  --error: #ef4444;
  --border: #27272a;
  --border-hover: #3f3f46;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.container {
  width: 100%;
  max-width: 640px;
}

header {
  text-align: center;
  margin-bottom: 40px;
}

h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 8px;
  background: linear-gradient(
    135deg,
    var(--text-primary) 0%,
    var(--text-secondary) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

/* Input Section */
.input-section {
  margin-bottom: 24px;
}

.input-group {
  display: flex;
  gap: 12px;
}

#urlInput {
  flex: 1;
  padding: 14px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: all 0.2s ease;
  outline: none;
}

#urlInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#urlInput::placeholder {
  color: var(--text-muted);
}

#convertBtn {
  padding: 14px 28px;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
}

#convertBtn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

#convertBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#convertBtn.loading .btn-text {
  display: none;
}

#convertBtn.loading .btn-loader {
  display: block;
}

.btn-loader {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.hint {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Progress Section */
.progress-section {
  display: none;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
}

.progress-section.visible {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.status-text {
  font-weight: 500;
  color: var(--text-primary);
}

.progress-percent {
  font-size: 0.875rem;
  color: var(--accent);
  font-weight: 600;
}

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

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-fill.indeterminate {
  width: 30%;
  animation: indeterminate 1.5s ease-in-out infinite;
}

@keyframes indeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(400%);
  }
}

.progress-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.progress-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.cancel-btn {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cancel-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--error);
  color: var(--error);
}

/* Video Section */
.video-section {
  display: none;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 24px;
}

.video-section.visible {
  display: block;
  animation: fadeIn 0.3s ease;
}

.video-container {
  background: #000;
  aspect-ratio: 16 / 9;
}

#videoPreview {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.video-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-size {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.download-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--success);
  color: white;
  text-decoration: none;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.925rem;
  transition: all 0.2s ease;
}

.download-btn:hover {
  background: #16a34a;
  transform: translateY(-1px);
}

/* Error Section */
.error-section {
  display: none;
  background: var(--bg-secondary);
  border: 1px solid var(--error);
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  margin-bottom: 24px;
}

.error-section.visible {
  display: block;
  animation: fadeIn 0.3s ease;
}

.error-icon {
  color: var(--error);
  margin-bottom: 16px;
}

.error-message {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 0.925rem;
}

.retry-btn {
  padding: 12px 24px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.925rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.retry-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-hover);
}

/* Footer */
footer {
  text-align: center;
  padding-top: 24px;
}

footer p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 480px) {
  .input-group {
    flex-direction: column;
  }

  #convertBtn {
    width: 100%;
  }

  .video-actions {
    flex-direction: column;
    gap: 16px;
  }

  .download-btn {
    width: 100%;
    justify-content: center;
  }
}
