:root {
  --text: #fbf8ff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
  user-select: none;
}

input,
textarea {
  user-select: text;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(135deg, #050409 0%, #130d1f 45%, #050409 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  content: "";
  background-image:
    linear-gradient(rgba(185, 126, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(185, 126, 255, 0.055) 1px, transparent 1px);
  background-size: 46px 46px;
  background-position: center center;
}

#grid-effect {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

.page-shell {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: grid;
  grid-template-rows: auto auto;
  align-content: center;
  place-items: center;
  padding: 24px;
  transform: translateY(-34px);
}

.download-form {
  display: grid;
  grid-template-columns: minmax(260px, 560px) 116px 148px;
  width: fit-content;
  max-width: calc(100vw - 48px);
  overflow: visible;
  background: rgba(13, 10, 19, 0.96);
  border: 1px solid rgba(190, 94, 255, 0.24);
  border-radius: 8px;
}

.download-form input,
.download-form button {
  height: 58px;
  border: 0;
  color: #fbf8ff;
  font: inherit;
  outline: 0;
}

.download-form input {
  min-width: 0;
  padding: 0 20px;
  background: rgba(13, 10, 19, 0.96);
}

.download-form input[type="url"] {
  border-radius: 8px 0 0 8px;
}

.download-form input::placeholder {
  color: rgba(251, 248, 255, 0.44);
}

.format-dropdown {
  position: relative;
  height: 58px;
}

.download-form .format-trigger {
  width: 100%;
  height: 58px;
  color: #fbf8ff;
  font: inherit;
  background: rgba(18, 12, 27, 0.98);
  border-left: 1px solid rgba(190, 94, 255, 0.18);
  cursor: pointer;
  outline: 0;
  text-align: center;
}

.download-form .format-trigger:hover,
.download-form .format-trigger:focus-visible,
.format-dropdown.is-open .format-trigger {
  background: rgba(18, 12, 27, 0.98);
  box-shadow: none;
}

.format-menu {
  position: absolute;
  top: 100%;
  left: 1px;
  z-index: 5;
  display: none;
  width: calc(100% - 1px);
  overflow: hidden;
  background: rgba(18, 12, 27, 0.98);
  border: 0;
  border-top: 0;
  border-radius: 0;
  box-shadow:
    inset 1px 0 0 rgba(190, 94, 255, 0.18),
    inset -1px 0 0 rgba(190, 94, 255, 0.18),
    inset 0 -1px 0 rgba(190, 94, 255, 0.18),
    0 12px 22px rgba(5, 4, 9, 0.3);
}

.format-dropdown.is-open .format-menu {
  display: grid;
}

.download-form .format-menu button {
  width: 100%;
  height: 38px;
  padding: 0 16px;
  color: rgba(251, 248, 255, 0.84);
  font: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
}

.download-form .format-menu button:hover,
.download-form .format-menu button:focus-visible,
.download-form .format-menu button[aria-selected="true"] {
  color: #fbf8ff;
  background: rgba(157, 28, 255, 0.38);
  outline: 0;
}

.download-form button {
  background: #9d1cff;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 160ms ease,
    color 160ms ease;
}

.download-form button:hover,
.download-form button:focus-visible {
  background: #b94dff;
}

.download-form button:disabled {
  background: rgba(157, 28, 255, 0.52);
  cursor: wait;
}

.download-form .format-menu button {
  width: 100%;
  height: 38px;
  padding: 0 16px;
  color: rgba(251, 248, 255, 0.84);
  font: inherit;
  font-weight: 500;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
  transition:
    background 160ms ease,
    color 160ms ease;
}

.download-form .format-menu button:hover,
.download-form .format-menu button:focus-visible,
.download-form .format-menu button[aria-selected="true"] {
  color: #fbf8ff;
  background: rgba(157, 28, 255, 0.38);
  outline: 0;
}

.download-progress {
  width: min(560px, calc(100vw - 72px));
  height: 5px;
  margin-top: 14px;
  overflow: hidden;
  background: rgba(190, 94, 255, 0.12);
  border-radius: 999px;
  opacity: 0;
  transition: opacity 180ms ease;
}

.download-progress span {
  display: block;
  width: 34%;
  height: 100%;
  background: linear-gradient(90deg, transparent, #cf7aff, transparent);
  border-radius: inherit;
  transform: translateX(-120%);
}

.download-progress.is-active {
  opacity: 1;
}

.download-progress.is-active span {
  animation: progress-sweep 1.25s ease-in-out infinite alternate;
}

.download-percent {
  min-height: 18px;
  margin: 8px 0 0;
  color: rgba(207, 122, 255, 0.86);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  transition: opacity 180ms ease;
}

.download-percent.is-active {
  opacity: 1;
}

.download-percent span {
  color: rgba(251, 248, 255, 0.9);
}

.download-percent .progress-value {
  color: rgba(207, 122, 255, 0.86);
}

.download-percent .progress-count {
  color: rgba(207, 122, 255, 0.86);
}

.download-percent .progress-divider,
.download-percent .progress-dot,
.download-percent .progress-title {
  color: #ffffff;
}

.download-percent .progress-title {
  display: inline-block;
  max-width: min(360px, calc(100vw - 210px));
  overflow: hidden;
  vertical-align: bottom;
  white-space: nowrap;
}

.download-percent .progress-title span {
  display: inline-block;
  min-width: 100%;
}

.download-percent .progress-title.is-marquee span {
  min-width: max-content;
  animation: progress-title-marquee 8s ease-in-out infinite alternate;
}

.video-preview {
  display: none;
  width: min(560px, calc(100vw - 72px));
  margin-bottom: 34px;
  text-align: center;
}

.video-preview.is-visible {
  display: block;
}

.video-preview img {
  display: block;
  width: auto;
  max-width: min(380px, 100%);
  max-height: 380px;
  margin: 10px auto 0;
  object-fit: contain;
  background: transparent;
  border: 1.5px solid rgba(190, 94, 255, 0.62);
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(207, 122, 255, 0.18);
}

.video-preview img.is-video-thumbnail {
  width: min(380px, 100%);
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.video-preview img.is-natural-thumbnail {
  width: min(380px, 100%);
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.video-preview p {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
  color: rgba(251, 248, 255, 0.86);
  font-size: 1.06rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
}

.video-preview p span {
  display: inline-block;
  min-width: 100%;
}

.video-preview p.is-marquee span {
  min-width: max-content;
  animation: title-marquee 9s ease-in-out infinite alternate;
}

.video-preview .video-artist {
  display: none;
  max-width: 560px;
  margin: 1px auto 0;
  overflow: hidden;
  color: rgba(251, 248, 255, 0.58);
  font-size: 0.66rem;
  font-weight: 500;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-preview .video-artist.is-visible {
  display: block;
}

.quality-options {
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(74px, max-content));
  justify-content: center;
  gap: 8px;
  width: min(560px, calc(100vw - 72px));
  margin-top: 12px;
}

.quality-options.is-visible {
  display: grid;
}

.quality-options button {
  min-width: 74px;
  height: 34px;
  padding: 0 14px;
  color: rgba(251, 248, 255, 0.78);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(32, 20, 45, 0.9);
  border: 1px solid rgba(190, 94, 255, 0.22);
  border-radius: 8px;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.quality-options button:hover,
.quality-options button:focus-visible,
.quality-options button.is-selected {
  color: #fbf8ff;
  background: rgba(157, 28, 255, 0.72);
  border-color: rgba(207, 122, 255, 0.72);
}

.playlist-tracks {
  display: none;
  --playlist-row-gap: 4px;
  --playlist-row-height: 32px;
  --playlist-list-height: calc(var(--playlist-row-height) * 5 + var(--playlist-row-gap) * 4 + 16px);
  width: min(560px, calc(100vw - 72px));
  max-height: var(--playlist-list-height);
  margin-top: 12px;
  padding: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  background: rgba(12, 8, 18, 0.58);
  border: 1px solid rgba(190, 94, 255, 0.18);
  border-radius: 8px;
  scrollbar-width: none;
}

.playlist-tracks.is-visible {
  display: grid;
  grid-auto-rows: var(--playlist-row-height);
  gap: var(--playlist-row-gap);
}

.playlist-tracks.is-scrollable {
  height: var(--playlist-list-height);
  min-height: var(--playlist-list-height);
  max-height: var(--playlist-list-height);
}

.playlist-tracks::-webkit-scrollbar {
  display: none;
}

.playlist-track {
  display: grid;
  grid-template-columns: 18px 16px minmax(0, 1fr) 0 0 92px;
  align-items: center;
  column-gap: 6px;
  row-gap: 8px;
  min-height: 0;
  height: var(--playlist-row-height);
  padding: 0 8px;
  color: rgba(251, 248, 255, 0.78);
  font-size: 0.86rem;
  background: rgba(32, 20, 45, 0.38);
  border-radius: 6px;
}

.playlist-track.is-single-digit {
  grid-template-columns: 10px 16px minmax(0, 1fr) 0 0 92px;
}

.playlist-track.has-status {
  grid-template-columns: 18px 16px minmax(0, 1fr) 42px 26px 92px;
}

.playlist-track.is-single-digit.has-status {
  grid-template-columns: 10px 16px minmax(0, 1fr) 42px 26px 92px;
}

.playlist-track input {
  width: 14px;
  height: 14px;
  accent-color: #9d1cff;
}

.playlist-track > span:nth-child(1) {
  color: rgba(207, 122, 255, 0.78);
  font-weight: 700;
  text-align: left;
}

.playlist-track > span:nth-child(3) {
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-title span {
  display: inline-block;
  min-width: 100%;
}

.track-title,
.track-title span {
  color: #ffffff;
}

.track-title.is-marquee {
  text-overflow: clip;
}

.track-title.is-marquee span {
  min-width: max-content;
  animation: track-title-marquee 7s ease-in-out infinite alternate;
}

.track-percent {
  color: rgba(207, 122, 255, 0.78);
  font-size: 0.76rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 42px;
  text-align: right;
}

.track-percent .percent-symbol {
  color: #ffffff !important;
}

.track-state {
  color: #ff5e9c;
  font-size: 0.88rem;
  text-align: center;
}

.playlist-track.is-done .track-state {
  color: #5dff9d;
}

.playlist-track.is-error .track-state {
  color: #ff5e9c;
}

.playlist-track.is-active .track-state {
  color: #ffffff;
}

.playlist-track button {
  height: 26px;
  padding: 0 10px;
  color: #fbf8ff;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  background: #9d1cff;
  border: 1px solid #9d1cff;
  border-radius: 6px;
  cursor: pointer;
}

.playlist-track button:hover,
.playlist-track button:focus-visible {
  background: #b94dff;
  border-color: #b94dff;
  outline: 0;
}

.playlist-track button:disabled {
  color: rgba(251, 248, 255, 0.38);
  background: rgba(118, 112, 128, 0.26);
  border-color: rgba(180, 170, 196, 0.16);
  cursor: not-allowed;
}

.download-status {
  min-height: 22px;
  margin: 6px 0 0;
  color: rgba(251, 248, 255, 0.72);
  font-size: 0.92rem;
  text-align: center;
}

.download-status.error {
  color: #ff8bc2;
}

@keyframes progress-sweep {
  to {
    transform: translateX(300%);
  }
}

@keyframes title-marquee {
  0%,
  14% {
    transform: translateX(0);
  }

  86%,
  100% {
    transform: translateX(calc(-100% + min(560px, calc(100vw - 72px))));
  }
}

@keyframes progress-title-marquee {
  0%,
  14% {
    transform: translateX(0);
  }

  86%,
  100% {
    transform: translateX(calc(-1 * var(--marquee-distance, 0px)));
  }
}

@keyframes track-title-marquee {
  0%,
  14% {
    transform: translateX(0);
  }

  86%,
  100% {
    transform: translateX(calc(-1 * var(--track-title-distance, 0px)));
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  white-space: nowrap;
  border: 0;
  clip: rect(0, 0, 0, 0);
}

@media (max-width: 720px) {
  .download-form {
    grid-template-columns: 1fr;
    width: min(420px, 100%);
  }

  .download-progress {
    width: min(360px, 100%);
  }

  .video-preview {
    width: min(360px, 100%);
  }

  .quality-options {
    width: min(360px, 100%);
  }

  .playlist-tracks {
    width: min(360px, 100%);
    max-height: var(--playlist-list-height);
  }

  .download-form .format-trigger {
    border-top: 1px solid rgba(190, 94, 255, 0.18);
    border-left: 0;
  }
}
