:root {
  --bg: #0f1117;
  --panel: #1e2230;
  --border: #2a2f3f;
  --text: #e8eaf0;
  --text-dim: #9aa1b5;
  --accent: #6366f1;
  --accent-hover: #4f52d8;
  --error: #f87171;
  --success: #22c55e;
  --warning: #fbbf24;
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Animated background */
.bg-animation {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: linear-gradient(135deg, #0f1117 0%, #141b33 45%, #1a1030 100%);
  animation: bg-shift 18s ease-in-out infinite alternate;
}

@keyframes bg-shift {
  0% {
    background-position: 0% 0%;
    filter: hue-rotate(0deg);
  }
  100% {
    background-position: 100% 100%;
    filter: hue-rotate(30deg);
  }
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  mix-blend-mode: screen;
  animation: float 22s ease-in-out infinite;
}

.orb-1 {
  width: 480px;
  height: 480px;
  background: #6366f1;
  top: -120px;
  left: -100px;
}

.orb-2 {
  width: 420px;
  height: 420px;
  background: #a855f7;
  bottom: -140px;
  right: -80px;
  animation-delay: -7s;
  animation-duration: 26s;
}

.orb-3 {
  width: 320px;
  height: 320px;
  background: #06b6d4;
  top: 40%;
  left: 55%;
  animation-delay: -13s;
  animation-duration: 30s;
}

@keyframes float {
  0% {
    transform: translate(0, 0) scale(1);
  }
  25% {
    transform: translate(60px, -40px) scale(1.1);
  }
  50% {
    transform: translate(-40px, 50px) scale(0.95);
  }
  75% {
    transform: translate(30px, 30px) scale(1.05);
  }
  100% {
    transform: translate(0, 0) scale(1);
  }
}

.app {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}

.app-header h1 {
  font-size: 22px;
  font-weight: 700;
}

.app-header p {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

.status-pill {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--warning);
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  padding: 8px 12px;
  border-radius: 999px;
}

.status-pill.hidden {
  display: none;
}

.dot-warn {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
}

.card {
  background: rgba(30, 34, 48, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}

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

#url-input {
  flex: 1;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

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

#fetch-btn {
  padding: 14px 24px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  white-space: nowrap;
}

#fetch-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

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

.hidden {
  display: none !important;
}

/* Video card */
.video-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.video-info {
  display: flex;
  gap: 16px;
}

.thumb-wrap {
  position: relative;
  flex-shrink: 0;
}

#thumb {
  width: 220px;
  max-height: 130px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
  background: var(--bg);
}

.duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, 0.75);
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
  color: #fff;
}

.meta h2 {
  font-size: 16px;
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta p {
  font-size: 13px;
  color: var(--text-dim);
}

.quality-block label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.quality-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.q-btn {
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.q-btn:hover {
  border-color: var(--accent);
}

.q-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

/* Progress */
.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
}

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

.progress p {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-dim);
}

/* Result */
.result-text {
  font-size: 14px;
  color: var(--success);
  margin-bottom: 14px;
  line-height: 1.5;
}

.btn-download {
  display: inline-block;
  padding: 13px 26px;
  border-radius: 12px;
  background: var(--success);
  color: #04130a;
  font-weight: 700;
  text-decoration: none;
  transition: filter 0.2s;
}

.btn-download:hover {
  filter: brightness(1.1);
}

.app-footer {
  margin-top: auto;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  padding-top: 16px;
}

@media (max-width: 640px) {
  .input-row {
    flex-direction: column;
  }

  .video-info {
    flex-direction: column;
  }

  #thumb {
    width: 100%;
    max-height: 200px;
  }
}
