:root {
  --bg: #f4f7fb;
  --fg: #0f172a;
  --muted: #546176;
  --panel: #ffffff;
  --line: #d8e3f2;
  --primary: #0ea5a4;
  --primary-strong: #0284c7;
  --danger: #be123c;
  --ok: #047857;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Poppins", "Segoe UI", Tahoma, sans-serif;
  color: var(--fg);
  background: linear-gradient(180deg, #f8fbff 0%, #edf4fc 100%);
  position: relative;
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(12px);
  opacity: 0.45;
  z-index: 0;
}

.shape-1 {
  width: 280px;
  height: 280px;
  right: -80px;
  top: -80px;
  background: #67e8f9;
}

.shape-2 {
  width: 320px;
  height: 320px;
  left: -120px;
  bottom: -120px;
  background: #bfdbfe;
}

.container {
  position: relative;
  z-index: 1;
  width: min(860px, 94vw);
  margin: 2rem auto 3rem;
}

.hero {
  text-align: center;
  margin-bottom: 1.25rem;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  letter-spacing: 0.01em;
}

.hero p {
  margin: 0.55rem 0 0;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.1rem;
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.06);
}

.input-group {
  display: grid;
  gap: 0.75rem;
}

#videoUrl {
  width: 100%;
  border: 1px solid #c9d9ef;
  border-radius: 12px;
  padding: 0.86rem 0.9rem;
  font-size: 1rem;
  outline: none;
}

#videoUrl:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
}

#analyzeBtn,
.download-btn,
.quality-btn {
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.12s ease, background 0.2s ease;
}

#analyzeBtn {
  padding: 0.82rem 1rem;
  font-size: 1rem;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}

#analyzeBtn:hover {
  transform: translateY(-1px);
}

#analyzeBtn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.message {
  min-height: 1.5rem;
  margin: 0.8rem 0 0.2rem;
  font-weight: 600;
}

.message.error {
  color: var(--danger);
}

.message.ok {
  color: var(--ok);
}

.result {
  margin-top: 0.8rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.video-head {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.9rem;
  align-items: center;
}

.thumb {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
}

#title {
  margin: 0;
  font-size: 1.12rem;
}

.meta {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.quality-block {
  margin-top: 1rem;
}

.quality-label {
  margin: 0 0 0.55rem;
  font-weight: 600;
}

.quality-options {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.quality-btn {
  padding: 0.58rem 0.84rem;
  background: #edf4ff;
  color: #0f172a;
  border: 1px solid #c8dcfa;
}

.quality-btn.active {
  background: #d1fae5;
  border-color: #6ee7b7;
}

.quality-btn:disabled {
  background: #f3f4f6;
  border-color: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
}

.loading {
  margin-top: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  font-weight: 600;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #bae6fd;
  border-top-color: #0284c7;
  border-radius: 999px;
  animation: spin 0.7s linear infinite;
}

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

.download-btn {
  display: inline-block;
  margin-top: 1rem;
  text-decoration: none;
  color: #fff;
  background: #0f766e;
  padding: 0.74rem 1rem;
}

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

.hidden {
  display: none;
}

@media (max-width: 720px) {
  .container {
    margin-top: 1.2rem;
  }

  .panel {
    border-radius: 14px;
    padding: 0.95rem;
  }

  .video-head {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .thumb {
    width: 100%;
    max-width: 260px;
    height: auto;
    aspect-ratio: 1 / 1;
  }
}
