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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #232637;
  --border: #2e3147;
  --accent: #6c63ff;
  --accent-hover: #7d76ff;
  --accent-light: rgba(108, 99, 255, 0.12);
  --text: #e8eaf0;
  --text-muted: #7a7f9a;
  --success: #22c55e;
  --error: #ef4444;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

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

.app {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* Header */
.header {
  text-align: center;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.logo-icon {
  font-size: 28px;
  color: var(--accent);
  font-weight: 700;
}

.logo-text {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: var(--text-muted);
  font-size: 14px;
}

/* Main */
.main {
  position: relative;
}

/* Steps */
.step {
  display: none;
  flex-direction: column;
  gap: 20px;
  animation: fadeIn 0.25s ease;
}

.step.active {
  display: flex;
}

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

/* Drop Zone */
.drop-zone {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

.drop-icon {
  font-size: 40px;
  color: var(--accent);
  margin-bottom: 12px;
  line-height: 1;
}

.drop-text {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.drop-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.supported-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}

/* File Card */
.file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.file-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.file-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-name {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s;
}

.btn-icon:hover {
  color: var(--error);
}

/* Format Selector */
.format-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: "▾";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 12px;
}

select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  padding: 12px 40px 12px 14px;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

select:focus {
  outline: none;
  border-color: var(--accent);
}

optgroup {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

option {
  color: var(--text);
  background: var(--surface-2);
  font-size: 14px;
  padding: 6px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-convert {
  width: 100%;
}

/* Spinner */
.btn-spinner {
  display: inline-block;
  animation: spin 0.8s linear infinite;
  font-size: 16px;
}

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

.hidden {
  display: none !important;
}

/* Result */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.result-icon {
  width: 56px;
  height: 56px;
  background: rgba(34, 197, 94, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--success);
}

.result-title {
  font-size: 20px;
  font-weight: 700;
}

.result-info {
  font-size: 13px;
  color: var(--text-muted);
}

/* Error Toast */
.error-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #2d1a1a;
  border: 1px solid var(--error);
  color: #fca5a5;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 480px;
  z-index: 100;
  animation: slideUp 0.2s ease;
  box-shadow: var(--shadow);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.toast-close {
  background: none;
  border: none;
  color: currentColor;
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
  opacity: 0.7;
}

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

/* Footer */
.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* Loading overlay on drop zone */
.drop-zone.loading {
  pointer-events: none;
  opacity: 0.6;
}

/* --- Mode Tabs --- */
.mode-tabs {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
}

.mode-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mode-tab:hover:not(.active) {
  background: var(--surface-2);
  color: var(--text);
}

.mode-tab.active {
  background: var(--accent);
  color: #fff;
}

/* --- URL Panel --- */
.url-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.url-platforms span {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.url-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#urlInput {
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  padding: 14px 16px;
  transition: border-color 0.15s;
  outline: none;
}

#urlInput:focus {
  border-color: var(--accent);
}

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

.url-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  animation: fadeIn 0.2s ease;
}

.url-meta-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.url-meta-title {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.url-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.url-note {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}
