.deck {
  --deck-ink: #2b3562;
  --deck-soft: #6f7cad;
  --deck-accent: #7ea9ff;
  --deck-strong: #5b86e5;
  --deck-strong-hover: #4a74d6;
  --deck-pale: #e6efff;
  --deck-paler: #f1f6ff;
  --deck-edge: #c7d8ff;
  --deck-surface: #ffffff99;
  --deck-shadow: rgba(43, 53, 98, 0.22);
  --deck-w: 290px;
  --deck-ease: cubic-bezier(0.22, 1, 0.36, 1);

  position: fixed;
  bottom: 64px;
  left: 0;
  z-index: 9000;
  width: var(--deck-w);
  color: var(--deck-ink);
  font-family: 'departure-mono', monospace;
  transform: translateX(-100%);
}

.deck[hidden] {
  display: none;
}

.deck.is-ready {
  transition: transform 550ms var(--deck-ease);
}

.deck.is-open {
  transform: none;
}

.deck button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.deck button:focus-visible,
.deck-rail:focus-visible {
  outline: 2px solid var(--deck-ink);
  outline-offset: 2px;
}

.deck .deck-tab {
  position: absolute;
  bottom: 24px;
  left: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 44px;
  height: 96px;
  color: #ffffff;
  background: var(--deck-strong);
  border-radius: 0 14px 14px 0;
  box-shadow: 6px 8px 20px var(--deck-shadow);
  transition: width 300ms var(--deck-ease), background 200ms ease;
}

.deck-tab svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.deck-tab-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 13px;
}

.deck-tab-bars i {
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: currentColor;
  transform: scaleY(0.35);
  transform-origin: bottom;
  transition: transform 300ms ease;
}

.deck[data-state='playing'] .deck-tab-bars i {
  animation: deck-bars 900ms ease-in-out infinite;
}

.deck[data-state='playing'] .deck-tab-bars i:nth-child(2) {
  animation-delay: 150ms;
}

.deck[data-state='playing'] .deck-tab-bars i:nth-child(3) {
  animation-delay: 300ms;
}

.deck[data-hint] .deck-tab {
  animation: deck-pulse 2.2s ease-in-out infinite;
}

.deck-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100 * var(--vh, 1vh) - 100px);
  padding: 18px 18px 14px 16px;
  box-sizing: border-box;
  background: var(--deck-surface);
  border: 2px solid var(--deck-edge);
  border-left: 0;
  border-radius: 0 18px 18px 0;
  box-shadow: 10px 14px 36px var(--deck-shadow);
}

.deck-panel > * {
  opacity: 0;
  transform: translateX(-16px);
  transition: opacity 250ms ease, transform 400ms var(--deck-ease);
}

.deck.is-open .deck-panel > * {
  opacity: 1;
  transform: none;
}

.deck.is-open .deck-panel > :nth-child(1) { transition-delay: 90ms; }
.deck.is-open .deck-panel > :nth-child(2) { transition-delay: 130ms; }
.deck.is-open .deck-panel > :nth-child(3) { transition-delay: 170ms; }
.deck.is-open .deck-panel > :nth-child(4) { transition-delay: 190ms; }
.deck.is-open .deck-panel > :nth-child(5) { transition-delay: 220ms; }
.deck.is-open .deck-panel > :nth-child(6) { transition-delay: 260ms; }

.deck-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--deck-soft);
}

.deck-label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.deck-label::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--deck-edge);
  transition: background 300ms ease, box-shadow 300ms ease;
}

.deck[data-state='playing'] .deck-label::before {
  background: var(--deck-strong);
  box-shadow: 0 0 0 3px var(--deck-pale);
  animation: deck-blink 1.6s ease-in-out infinite;
}

.deck-now {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.deck-cover {
  flex: none;
  width: 64px;
  height: 64px;
  overflow: hidden;
  border-radius: 12px;
  background: var(--deck-pale);
  box-shadow: 0 6px 16px var(--deck-shadow);
}

.deck-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.75);
  transition: transform 700ms var(--deck-ease), filter 300ms ease;
}

.deck[data-state='playing'] .deck-cover img {
  filter: none;
  transform: scale(1.06);
}

.deck-now.is-swap .deck-cover,
.deck-now.is-swap .deck-text {
  animation: deck-swap 450ms var(--deck-ease);
}

.deck-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.deck-title,
.deck-artist,
.deck-item-title,
.deck-item-artist {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.deck-title {
  font-family: 'ZHFont', sans-serif;
  font-size: 16px;
  color: var(--deck-ink);
}

.deck-artist {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--deck-soft);
}

.deck-rail {
  --progress: 0;
  --hover: 0;
  position: relative;
  height: 16px;
  cursor: pointer;
  touch-action: none;
}

.deck-rail::before,
.deck-rail-fill {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  height: 4px;
  margin-top: -2px;
  border-radius: 4px;
}

.deck-rail::before {
  right: 0;
  background: var(--deck-pale);
}

.deck-rail-fill {
  width: calc(var(--progress) * 100%);
  background: var(--deck-strong);
}

.deck-rail-head {
  position: absolute;
  top: 50%;
  left: calc(var(--progress) * 100%);
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  box-sizing: border-box;
  border: 2px solid var(--deck-strong);
  border-radius: 50%;
  background: var(--deck-surface);
  transform: scale(0.8);
  transition: transform 200ms var(--deck-ease);
}

.deck-rail.is-hover .deck-rail-head,
.deck-rail.is-scrubbing .deck-rail-head {
  transform: scale(1.15);
}

.deck-rail-tag {
  position: absolute;
  bottom: calc(100% + 4px);
  left: calc(var(--hover) * 100%);
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--deck-ink);
  color: #ffffff;
  font-size: 10px;
  opacity: 0;
  transform: translate(-50%, 4px);
  transition: opacity 180ms ease, transform 250ms var(--deck-ease);
  pointer-events: none;
}

.deck-rail.is-hover .deck-rail-tag {
  opacity: 1;
  transform: translate(-50%, 0);
}

.deck-times {
  display: flex;
  justify-content: space-between;
  margin-top: -8px;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--deck-soft);
}

.deck-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.deck .deck-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--deck-strong);
  transition: background 200ms ease, transform 200ms var(--deck-ease);
}

.deck-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.deck-btn:active {
  transform: scale(0.9);
}

.deck .deck-play {
  width: 48px;
  height: 48px;
  color: #ffffff;
  background: var(--deck-strong);
}

.deck-play svg {
  width: 20px;
  height: 20px;
}

.deck-play-icon,
.deck-pause-icon {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  transition: opacity 200ms ease, transform 300ms var(--deck-ease);
}

.deck-pause-icon {
  fill: none;
  stroke-width: 3;
  opacity: 0;
  transform: scale(0.5);
}

.deck[data-state='playing'] .deck-play-icon {
  opacity: 0;
  transform: scale(0.5);
}

.deck[data-state='playing'] .deck-pause-icon {
  opacity: 1;
  transform: none;
}

.deck-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 230px;
  margin: 0;
  padding: 10px 0 0;
  overflow-y: auto;
  list-style: none;
  border-top: 2px solid var(--deck-pale);
  scrollbar-width: thin;
  scrollbar-color: var(--deck-edge) transparent;
}

.deck-list::-webkit-scrollbar {
  width: 4px;
}

.deck-list::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: var(--deck-edge);
}

.deck .deck-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border-radius: 10px;
  text-align: left;
  transition: background 200ms ease;
}

.deck-item-number {
  flex: none;
  width: 20px;
  font-size: 10px;
  color: var(--deck-soft);
}

.deck-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.deck-item-title {
  font-family: 'ZHFont', sans-serif;
  font-size: 13px;
  color: var(--deck-ink);
}

.deck-item-artist {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--deck-soft);
}

.deck .deck-item.is-active {
  background: var(--deck-pale);
}

.deck-item.is-active .deck-item-number {
  color: var(--deck-strong);
}

.deck-overlay {
  position: fixed;
  inset: 0;
  z-index: 8990;
  background: rgba(20, 28, 60, 0.253);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 350ms ease, visibility 0s linear 350ms;
}

.deck-overlay.is-active {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

@media (hover: hover) {
  .deck .deck-tab:hover {
    width: 50px;
    background: var(--deck-strong-hover, 0.9);
  }

  .deck .deck-btn:hover {
    background: var(--deck-paler);
  }

  .deck .deck-item:hover {
    background: var(--deck-paler);
  }

  .deck .deck-item.is-active:hover {
    background: var(--deck-pale);
  }

  .deck .deck-play:hover {
    background: var(--deck-strong-hover);
    transform: translateY(-1px);
  }
}

@keyframes deck-bars {
  0%, 100% { transform: scaleY(0.35); }
  50% { transform: scaleY(1); }
}

@keyframes deck-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@keyframes deck-pulse {
  0%, 100% { box-shadow: 6px 8px 20px var(--deck-shadow); }
  50% { box-shadow: 6px 8px 20px var(--deck-shadow), 0 0 0 4px var(--deck-accent); }
}

@keyframes deck-swap {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .deck,
  .deck *,
  .deck-overlay {
    animation: none !important;
    transition-duration: 1ms !important;
    transition-delay: 0s !important;
  }
}

@media (max-width: 768px) {
  .deck {
    --deck-w: min(300px, calc(86 * var(--vw, 1vw)));
    bottom: 20px;
  }

  .deck-panel {
    max-height: calc(100 * var(--vh, 1vh) - 40px);
  }

  .deck .deck-tab {
    width: 38px;
    height: 84px;
  }

  .deck-list {
    max-height: calc(32 * var(--vh, 1vh));
  }
}
