.download {
  width: min(420px, 100%);
  display: flex;
  justify-content: center;
}

.download__button {
  width: min(176px, 100%);
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: linear-gradient(145deg, var(--primary), var(--primary-2));
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 18px;
  position: relative;
  overflow: hidden;
  z-index: 0;
  transition: width 0.35s ease, transform 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
}

.download__button:hover {
  filter: brightness(1.08);
}

.download__button:active {
  transform: translateY(1px);
}

.download__label,
.download__progress-text {
  position: relative;
  z-index: 2;
}

.download__progress {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  height: 6px;
  width: calc(100% - 44px);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(57, 71, 112, 0.45);
  border: 1px solid rgba(79, 97, 150, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 1;
}

.download__progress-bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #7f8dff 0%, #9eb6ff 100%);
  transition: width 0.2s ease;
}

.download__progress-text {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: #f3f6ff;
  font-size: 14px;
}

.download.is-downloading .download__button,
.download.is-error .download__button,
.download.is-complete-flash .download__button {
  width: min(420px, 100%);
  min-height: 56px;
}

.download.is-downloading .download__button {
  cursor: progress;
}

.download.is-cancel-pending .download__button {
  background: linear-gradient(145deg, #a56724, #d18732);
  cursor: pointer;
}

.download.is-cancel-pending .download__progress-text {
  color: #fff2cf;
}

.download.is-complete-flash .download__label,
.download.is-error .download__label {
  text-shadow: 0 1px 2px rgba(5, 8, 15, 0.42);
}

.download.is-downloading .download__progress-text,
.download.is-indeterminate .download__progress-text {
  display: inline;
}

.download.is-downloading .download__progress,
.download.is-complete-flash .download__progress,
.download.is-error .download__progress {
  opacity: 1;
}

.download.is-downloading .download__label {
  opacity: 0;
}

.download.is-complete-flash .download__button {
  background: linear-gradient(145deg, #22a66a, #30c57f);
  animation: download-complete-flash 0.95s ease;
}

.download.is-complete:not(.is-complete-flash) .download__button {
  width: min(176px, 100%);
  background: linear-gradient(145deg, #22a66a, #30c57f);
}

.download.is-complete:not(.is-complete-flash) .download__progress {
  opacity: 0;
}

.download.is-complete:not(.is-complete-flash) .download__progress-text {
  display: none;
}

.download.is-error .download__button {
  background: linear-gradient(145deg, #8f3d4f, #ca5666);
}

.download.is-indeterminate .download__progress-bar {
  width: 40%;
  animation: download-indeterminate 1.2s ease-in-out infinite;
}

@keyframes download-complete-flash {
  0% {
    filter: brightness(1);
    box-shadow: 0 0 0 rgba(64, 219, 143, 0);
  }
  35% {
    filter: brightness(1.18);
    box-shadow: 0 0 0 8px rgba(64, 219, 143, 0.18);
  }
  100% {
    filter: brightness(1);
    box-shadow: 0 0 0 rgba(64, 219, 143, 0);
  }
}

@keyframes download-indeterminate {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(260%);
  }
}
