:root {
  --color-primary: #9b4dff;
  --color-primary-soft: rgba(155, 77, 255, 0.18);
  --color-background: #121216;
  --color-surface: #1b1b22;
  --color-text: #f5f5f7;
  --color-text-secondary: #9a9aa8;
  --color-progress-bg: rgba(255, 255, 255, 0.08);
  --primary-gradient: linear-gradient(135deg, #ff2d8a 0%, #9b4dff 48%, #3b82f6 100%);
  --secondary-gradient: linear-gradient(135deg, #3b82f6 0%, #9b4dff 52%, #ff2d8a 100%);
  --progress-gradient: linear-gradient(90deg, #ff2d8a 0%, #9b4dff 50%, #3b82f6 100%);
  --spacing-xs: 8px;
  --spacing-sm: 12px;
  --spacing-md: 16px;
  --control-gap: 8px;
  --size-button: 44px;
  --size-icon: 16px;
  --progress-height: 4px;
  --progress-thumb: 12px;
  --progress-hit: 28px;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --surface-button: rgba(255, 255, 255, 0.04);
  --surface-button-hover: rgba(255, 255, 255, 0.09);
  --accent-success: #22c55e;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
}

.audio-player-footer,
.audio-player-footer * {
  box-sizing: border-box;
}

.audio-player-footer {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  padding: var(--spacing-sm) var(--spacing-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, transparent 40%),
    var(--color-background);
  color: var(--color-text);
  font-family: inherit;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  will-change: transform;
  border: 0;
  border-top: 1px solid var(--border-subtle);
  border-radius: 0;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.audio-player-footer.footer-visible {
  transform: translateY(0);
}

.progress-container {
  position: relative;
  width: 100%;
  height: var(--progress-height);
  margin-block: var(--spacing-xs) var(--spacing-sm);
  cursor: pointer;
  background: var(--color-progress-bg);
  border-radius: 999px;
  overflow: visible;
  direction: ltr;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-tap-highlight-color: transparent;
}

.progress-container::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 50%;
  height: var(--progress-hit);
  transform: translateY(-50%);
  border-radius: 999px;
}

.progress-container:focus-visible,
.control-button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

.progress-bar {
  position: absolute;
  inset-block: 0;
  left: 0;
  width: var(--progress-width, 0%);
  max-width: 100%;
  background: var(--progress-gradient);
  border-radius: 999px;
  transform-origin: left center;
  transition: width 0.12s linear;
  will-change: width;
  pointer-events: none;
}

.progress-bar.no-transition {
  transition: none !important;
}

.progress-bar::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  width: var(--progress-thumb);
  height: var(--progress-thumb);
  transform: translate(50%, -50%);
  background: #ffffff;
  border: 2px solid #c084fc;
  border-radius: 50%;
  pointer-events: none;
}

.progress-container:active,
.progress-container:active .progress-bar {
  cursor: grabbing;
}

.time-row,
.controls-row,
.controls-side,
.controls-center,
.sleep-timer-inline,
.control-button :is(i, span) {
  display: flex;
  align-items: center;
}

.time-row,
.controls-row {
  width: 100%;
}

.time-row {
  justify-content: space-between;
  margin-bottom: var(--spacing-xs);
  padding-inline: 4px;
}

.time-display {
  min-width: 88px;
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: center;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  white-space: nowrap;
  letter-spacing: 0.04em;
  unicode-bidi: isolate;
  opacity: 0.95;
}

.controls-row {
  justify-content: space-between;
  margin-bottom: var(--spacing-xs);
  gap: var(--control-gap);
}

.controls-side,
.controls-center,
.sleep-timer-inline {
  gap: var(--control-gap);
}

.controls-side,
.sleep-timer-inline {
  flex: 0 0 auto;
}

.controls-side {
  min-width: 88px;
}

.controls-left {
  justify-content: flex-start;
}

.controls-right {
  justify-content: flex-end;
}

.controls-center {
  justify-content: center;
  flex: 1 1 auto;
  min-width: 0;
}

.sleep-timer-inline {
  direction: ltr;
}

.control-button,
.sleep-timer-circle {
  display: grid;
  place-items: center;
  width: var(--size-button);
  aspect-ratio: 1;
  border-radius: 50%;
  color: var(--color-text);
  background: var(--surface-button);
  border: 1px solid var(--border-subtle);
  box-shadow: none;
  flex: 0 0 auto;
  line-height: 1;
}

.control-button {
  position: relative;
  padding: 0;
  margin: 0;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-size: var(--size-icon);
  appearance: none;
  -webkit-appearance: none;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.control-button:hover,
.control-button:active {
  background: var(--surface-button-hover);
  border-color: var(--border-strong);
}

.control-button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

#play-toggle {
  width: calc(var(--size-button) + 6px);
  background: var(--primary-gradient);
  border: 0;
  color: #ffffff;
}

#play-toggle:hover {
  background: var(--secondary-gradient);
}

.control-button :is(i, span) {
  justify-content: center;
}

.control-button i,
[class^="icon-"] {
  font-size: var(--size-icon);
  line-height: 1;
}

#play-toggle i.fa-play:not(.audio-spinner),
#play-toggle i.fa-pause:not(.audio-spinner),
.fa-play:not(.audio-spinner),
.fa-play:not(.audio-spinner)::before {
  direction: ltr !important;
  unicode-bidi: bidi-override;
  transform: none !important;
}

#play-toggle .audio-spinner {
  animation: audio-spin 0.8s linear infinite;
}

.control-button span,
.sleep-timer-circle {
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}

.sleep-timer-circle {
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
  background: var(--color-primary-soft);
  border-color: rgba(155, 77, 255, 0.35);
  color: #d8b4fe;
}

.audio-spinner {
  display: inline-block;
  animation: audio-spin 0.8s linear infinite;
}

:is(#btn-volume, #btn-timer, #btn-rate) span {
  display: none;
}

:is(#btn-volume, #btn-timer, #btn-rate).active span {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-success);
}

:is(#btn-volume, #btn-timer, #btn-rate).active i {
  display: none;
}

.icon-repeat-none {
  opacity: 1;
}

.icon-repeat-one,
.icon-shuffle-active {
  color: var(--accent-success);
}

.icon-repeat-all {
  color: var(--accent-warning);
}

.icon-repeat-stop,
.icon-muted {
  color: var(--accent-danger);
}

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

@media (prefers-reduced-motion: reduce) {
  .audio-player-footer,
  .progress-bar,
  .control-button {
    transition: none;
  }

  .audio-spinner:not(#play-toggle .audio-spinner) {
    animation: none;
  }
}

@media (max-width: 600px) {
  .audio-player-footer {
    --size-button: 40px;
    --size-icon: 15px;
    --progress-thumb: 11px;
    --progress-hit: 32px;
    padding: var(--spacing-xs) var(--spacing-sm);
  }

  .time-display,
  .controls-side {
    min-width: 80px;
  }

  #play-toggle {
    width: calc(var(--size-button) + 4px);
  }
}

@media (max-width: 380px) {
  .audio-player-footer {
    --size-button: 36px;
    --size-icon: 14px;
    --control-gap: 4px;
  }

  .time-display,
  .controls-side {
    min-width: 72px;
  }

  .time-display {
    font-size: 0.75rem;
  }
}
