:root {
   --bg: #0b0d16;
   --bg-2: #111424;
   --surface: rgba(255, 255, 255, 0.05);
   --surface-2: rgba(255, 255, 255, 0.08);
   --border: rgba(255, 255, 255, 0.1);
   --text: #eef0f8;
   --muted: #9aa0b5;
   --accent: #7c5cff;
   --accent-2: #22d3ee;
   --good: #34d399;
   --bad: #f87171;
   --radius: 18px;
   --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Animated ambient glow */
.bg-glow {
  position: fixed;
  inset: 0;
  background:
     radial-gradient(600px 400px at 15% 10%, rgba(124, 92, 255, 0.18), transparent 60%),
     radial-gradient(600px 400px at 85% 20%, rgba(34, 211, 238, 0.15), transparent 60%),
     radial-gradient(700px 500px at 50% 110%, rgba(124, 92, 255, 0.12), transparent 60%);
  z-index: -1;
  pointer-events: none;
}

/* Nav */
.nav {
  max-width: 900px;
  margin: 0 auto;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
}
.brand-mark { font-size: 22px; }
.nav-tag {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
}

/* Layout */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}

/* Hero */
.hero { text-align: center; margin: 28px 0 34px; }
.hero h1 {
  font-size: clamp(30px, 6vw, 48px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 0;
}
.accent {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.subtitle {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
  max-width: 460px;
  margin: 16px auto 0;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

/* Converter */
.converter { padding: 18px; }

.input-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
  flex-wrap: wrap;
}

.url-input {
  flex: 1 1 320px;
  min-width: 200px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 15px 16px;
  border-radius: 14px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.url-input::placeholder { color: #5b6178; }
.url-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.25);
}

/* Quality picker removed — always max quality */

/* Buttons */
.primary-btn {
  background: linear-gradient(120deg, var(--accent), #6a45f5);
  border: 0;
  color: white;
  font-weight: 700;
  font-size: 15px;
  padding: 0 26px;
  border-radius: 14px;
  cursor: pointer;
  transition: transform .08s, opacity .15s, box-shadow .15s;
  box-shadow: 0 10px 30px rgba(124, 92, 255, 0.35);
  min-width: 120px;
}
.primary-btn:hover { transform: translateY(-1px); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* Error */
.error {
  color: var(--bad);
  font-size: 14px;
  margin: 14px 4px 0;
  min-height: 0;
}
.error:empty { margin: 0; }

/* Result */
.result {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}
.result-inner { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.result-thumb {
  width: 160px;
  height: 96px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-2);
}
.result-meta { flex: 1 1 260px; min-width: 0; }
.result-title { margin: 0 0 4px; font-size: 17px; font-weight: 700; line-height: 1.3; }
.result-sub { margin: 0 0 14px; color: var(--muted); font-size: 13px; }

/* Progress */
.progress-wrap { display: flex; align-items: center; gap: 12px; }
.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width .3s ease;
}
.progress-label { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 80px; text-align: right; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: 0 0 auto;
}
.spinner-sm {
  border-color: rgba(255,255,255,0.25);
  border-top-color: var(--accent-2);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Primary button loading state */
.primary-btn .btn-spinner { display: none; }
.primary-btn.loading .btn-label { display: none; }
.primary-btn.loading .btn-spinner { display: inline-block; }

/* Completion banner */
.done-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  color: var(--good);
  font-weight: 600;
  font-size: 14px;
}

/* Error state on the result panel */
.error.show {
  color: var(--bad);
}

.result-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}
.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--good);
  color: #052015;
  font-weight: 700;
  font-size: 14px;
  padding: 11px 18px;
  border-radius: 12px;
  text-decoration: none;
  transition: transform .08s, filter .15s;
}
.download-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.download-size { color: var(--muted); font-size: 13px; }

/* History */
.history { margin-top: 26px; }
.history-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 0 0 12px;
  font-weight: 600;
}
.history-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  backdrop-filter: blur(8px);
}
.history-item img {
  width: 52px; height: 52px; object-fit: cover; border-radius: 9px;
  border: 1px solid var(--border);
}
.history-item .hi-meta { flex: 1; min-width: 0; }
.history-item .hi-title {
  font-weight: 600; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item .hi-sub { color: var(--muted); font-size: 12px; }
.history-item a.hi-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform .08s, background .15s;
}
.history-item a.hi-link:hover { transform: translateY(-1px); background: rgba(124,92,255,0.18); }
.history-item a.hi-link .hi-arrow { color: var(--accent-2); }
.status-dot { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }

/* Footer */
.footer {
  text-align: center;
  color: #5b6178;
  font-size: 12px;
  margin: 44px 0 30px;
}
.footer #footer-brand { font-weight: 700; color: var(--text); }

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

@media (max-width: 560px) {
  .nav { padding: 16px; }
  .container { padding: 8px 16px 16px; }
  .hero { margin: 16px 0 24px; }
  .subtitle { font-size: 15px; }
  .converter { padding: 14px; }
  .input-row { flex-direction: column; }
  /* flex-basis would become the height in a column; 16px stops iOS zoom-on-focus */
  .url-input { flex: 0 0 auto; min-width: 0; width: 100%; font-size: 16px; }
  .primary-btn { width: 100%; padding: 15px 26px; }
  .result-thumb { width: 100%; height: auto; aspect-ratio: 16 / 9; }
  .download-btn { flex: 1; justify-content: center; }
  .history-item img { width: 44px; height: 44px; }
  .history-item a.hi-link { padding: 8px 10px; }
}
