:host {
  display: block;
  max-width: 40rem;
}

.audio-player-shell {
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 2px);
  background:
    radial-gradient(circle at top left, hsl(var(--primary) / 0.14), transparent 42%),
    linear-gradient(180deg, hsl(var(--card)) 0%, hsl(var(--secondary) / 0.55) 100%);
  box-shadow: 0 10px 28px rgb(0 0 0 / 18%);
}

.audio-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 0.875rem 0.625rem;
}

.audio-body {
  display: flex;
  align-items: stretch;
  gap: 0.875rem;
  padding: 0 0.875rem 0.875rem;
}

.audio-play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  min-width: 3.25rem;
  border: 1px solid hsl(var(--primary) / 0.35);
  border-radius: 9999px;
  color: hsl(var(--primary-foreground));
  background: linear-gradient(180deg, hsl(var(--primary)) 0%, hsl(var(--primary) / 0.76) 100%);
  box-shadow: 0 10px 22px rgb(0 0 0 / 16%);
  transition:
    transform 0.16s ease,
    filter 0.16s ease;
}

.audio-play-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.audio-main {
  min-width: 0;
  flex: 1;
}

.audio-waveform-panel {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition:
    max-height 0.2s ease,
    opacity 0.2s ease,
    margin-bottom 0.2s ease;
}

.audio-waveform-panel.expanded {
  max-height: 5.5rem;
  opacity: 1;
  margin-bottom: 0.75rem;
}

.audio-waveform-shell {
  position: relative;
  overflow: hidden;
  height: 4.5rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid hsl(var(--border) / 0.8);
  border-radius: 0.95rem;
  background:
    linear-gradient(180deg, hsl(var(--background) / 0.72) 0%, hsl(var(--secondary) / 0.28) 100%);
}

.audio-waveform-container {
  width: 100%;
  height: 100%;
}

.audio-waveform-container.invisible {
  opacity: 0;
}

.audio-waveform-container ::part(wrapper) {
  cursor: pointer;
}

.audio-waveform-container ::part(cursor) {
  display: none;
}

.audio-waveform-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  text-align: center;
  font-size: 0.6875rem;
  line-height: 1.35;
  pointer-events: none;
}

.audio-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.625rem;
}

.audio-time-label {
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.audio-actions-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.audio-volume-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.audio-control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid hsl(var(--border) / 0.8);
  border-radius: 9999px;
  color: hsl(var(--foreground));
  background: hsl(var(--card) / 0.72);
  transition:
    background-color 0.16s ease,
    border-color 0.16s ease,
    transform 0.16s ease;
}

.audio-control-btn:hover {
  border-color: hsl(var(--primary) / 0.75);
  background: hsl(var(--primary) / 0.14);
  transform: translateY(-1px);
}

.seek-slider,
.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  cursor: pointer;
}

.seek-slider {
  width: 100%;
  height: 6px;
  margin-top: 0.75rem;
  border-radius: 9999px;
}

.volume-slider {
  width: 5.5rem;
  height: 6px;
  border-radius: 9999px;
}

.seek-slider::-webkit-slider-runnable-track,
.volume-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 9999px;
  background: transparent;
}

.seek-slider::-webkit-slider-thumb,
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -4px;
  border: 2px solid hsl(var(--card));
  border-radius: 50%;
  background: hsl(var(--primary));
  box-shadow: 0 1px 3px rgb(0 0 0 / 30%);
}

.seek-slider::-moz-range-track,
.volume-slider::-moz-range-track {
  height: 6px;
  border: none;
  border-radius: 9999px;
  background: hsl(var(--secondary));
}

.seek-slider::-moz-range-thumb,
.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 2px solid hsl(var(--card));
  border-radius: 50%;
  background: hsl(var(--primary));
  box-shadow: 0 1px 3px rgb(0 0 0 / 30%);
}

@keyframes audio-wave-motion {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-16px);
  }
}

@media (width <= 640px) {
  .audio-body {
    gap: 0.75rem;
  }

  .audio-play-btn {
    width: 3rem;
    height: 3rem;
    min-width: 3rem;
  }

  .audio-volume-group {
    display: none;
  }

  .audio-waveform-shell {
    height: 3.75rem;
  }

  .audio-controls-row {
    margin-top: 0.5rem;
  }
}
