/* ==========================================================================
   COZONE Web — Persistent Hi-Fi Mini-Audio Bar (R1 · 极简深灰)
   Desktop 52px flat footer + Mobile 48px bar docked above 4-tab nav.
   Zero neon, zero LED VU bars, zero glows, zero gradient buttons.
   ========================================================================== */

.audio-engine-el {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

/* Shared Album Cover (32x32, 5px radius, crisp hairline inset ring) */
.audio-cover {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--surface, #1E1E22);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.audio-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--frame-hairline, rgba(255, 255, 255, 0.065));
  pointer-events: none;
}

.audio-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 180ms ease;
}

.audio-cover-img.is-loaded {
  opacity: 1;
}

.audio-cover-img[hidden] {
  display: none;
}

.audio-cover-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #636368);
  background: #232328;
}

.audio-cover-fallback[hidden] {
  display: none;
}

/* Shared quiet monochrome button reset */
.audio-icon-btn,
.audio-quality-btn,
.audio-track-btn,
.audio-lyric-snippet,
.audio-mobile-info {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  margin: 0;
  padding: 0;
  font-family: var(--font-sans, "PingFang SC", "Microsoft YaHei UI", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  color: inherit;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.audio-icon-btn:focus-visible,
.audio-quality-btn:focus-visible,
.audio-track-btn:focus-visible,
.audio-lyric-snippet:focus-visible,
.audio-mobile-info:focus-visible,
.audio-seek-hit:focus-visible,
.audio-vol-hit:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.55);
  outline-offset: 2px;
  border-radius: 4px;
}

.audio-icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Subtle loading arc & progress hairline buffering shimmer (monochrome, no glow) */
@keyframes audio-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes audio-buffer-shimmer {
  0% {
    transform: translateX(-115%);
  }
  100% {
    transform: translateX(260%);
  }
}

.audio-spinner {
  animation: audio-spin 0.9s linear infinite;
  transform-origin: center;
}

@media (prefers-reduced-motion: reduce) {
  .audio-spinner {
    animation: none;
  }

  .audio-cover-img {
    transition: none;
  }

  .audio-bar-desktop.is-loading .audio-seek-shimmer,
  .audio-bar-mobile.is-loading .audio-mobile-progress-shimmer {
    animation: none;
    transform: none;
    width: 100%;
    opacity: 0.36;
  }
}

/* Allow scrolling page content behind fixed mounts to frost cleanly through blur(16px) */
.desktop-audio-mount,
.mobile-audio-mount {
  background: transparent;
}

/* ==========================================================================
   Desktop Persistent Mini-Audio Bar (52px, >= 768px)
   Neutral frosted matte surface matching sticky topbar.
   ========================================================================== */
.audio-bar-desktop {
  width: 100%;
  max-width: 100%;
  height: var(--audiobar-h, 52px);
  background: rgba(25, 25, 29, 0.86);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  backdrop-filter: saturate(140%) blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.075);
  padding: 0 28px;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto minmax(160px, 1fr);
  align-items: center;
  gap: 24px;
  box-sizing: border-box;
  overflow: hidden;
  color: var(--text, #F4F4F6);
  font-family: var(--font-sans, "PingFang SC", "Microsoft YaHei UI", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  user-select: none;
  -webkit-user-select: none;
}

.desktop-audio-mount > .audio-bar-desktop {
  height: 100%;
  border-top: 0;
}

.audio-bar-desktop.is-empty .audio-title {
  color: var(--text-secondary, #8E8E93);
  font-weight: 400;
}

.audio-bar-desktop.is-empty .audio-artist {
  color: var(--text-muted, #636368);
}

/* Left: Cover + Title + Artist */
.audio-left {
  display: flex;
  align-items: center;
  justify-self: start;
  min-width: 0;
  max-width: 100%;
}

.audio-track-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  max-width: 100%;
  text-align: left;
  padding: 4px 6px 4px 0;
  border-radius: 6px;
  transition: opacity 120ms ease;
}

.audio-track-btn:hover {
  opacity: 0.88;
}

.audio-track-meta {
  display: flex;
  flex-direction: column;
  gap: 1.5px;
  min-width: 0;
}

.audio-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 16px;
  letter-spacing: 0.005em;
  color: var(--text, #F4F4F6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-artist {
  font-size: 12px;
  font-weight: 400;
  line-height: 15px;
  color: var(--text-secondary, #8E8E93);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Center: Monochrome Transport + 2px White Progress Rule */
.audio-center {
  display: flex;
  align-items: center;
  gap: 20px;
  justify-self: center;
  min-width: 0;
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.audio-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #D4D4D8;
  transition: color 120ms ease, background-color 120ms ease, transform 90ms ease;
  flex-shrink: 0;
}

.audio-icon-btn:hover:not(:disabled) {
  color: #FFFFFF;
  background-color: rgba(255, 255, 255, 0.07);
}

.audio-icon-btn:active:not(:disabled),
.audio-quality-btn:active {
  transform: scale(0.94);
}

.audio-icon-btn--play {
  width: 30px;
  height: 30px;
  color: #FFFFFF;
}

.audio-icon-btn--muted-tone {
  width: 26px;
  height: 26px;
  color: var(--text-secondary, #8E8E93);
}

.audio-icon-btn--muted-tone:hover:not(:disabled) {
  color: var(--text, #F4F4F6);
}

.audio-icon-btn svg {
  display: block;
  flex-shrink: 0;
}

/* Progress Rule & Tabular Monospace Timestamps */
.audio-progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.audio-time {
  font-family: var(--font-mono, "SF Mono", "Cascadia Mono", "Consolas", monospace);
  font-size: 11px;
  line-height: 14px;
  letter-spacing: -0.01em;
  color: var(--text-secondary, #8E8E93);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  min-width: 38px;
  white-space: nowrap;
  flex-shrink: 0;
}

.audio-time--current {
  text-align: right;
}

.audio-time--duration {
  text-align: left;
}

.audio-seek-hit {
  width: clamp(136px, 19vw, 252px);
  height: 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
  position: relative;
  outline: none;
}

.audio-seek-track {
  width: 100%;
  height: 2px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.16);
  position: relative;
  transition: height 120ms ease;
}

.audio-seek-rail {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}

.audio-seek-shimmer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 42%;
  opacity: 0;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.14) 22%,
    rgba(255, 255, 255, 0.62) 50%,
    rgba(255, 255, 255, 0.14) 78%,
    transparent 100%
  );
  pointer-events: none;
  will-change: transform;
  transition: opacity 160ms ease;
}

.audio-bar-desktop.is-loading .audio-seek-shimmer {
  opacity: 1;
  animation: audio-buffer-shimmer 1.25s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.audio-seek-hit:hover .audio-seek-track,
.audio-seek-hit.is-dragging .audio-seek-track,
.audio-seek-hit:focus-visible .audio-seek-track {
  height: 3px;
}

.audio-seek-fill {
  height: 100%;
  width: 0%;
  border-radius: 1px;
  background: #FFFFFF;
  position: relative;
  z-index: 1;
  opacity: 0.9;
  transition: opacity 120ms ease;
}

.audio-seek-hit:hover .audio-seek-fill,
.audio-seek-hit.is-dragging .audio-seek-fill {
  opacity: 1;
}

.audio-seek-thumb {
  position: absolute;
  top: 50%;
  right: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #FFFFFF;
  transform: translateY(-50%) scale(0);
  transition: transform 120ms ease;
  pointer-events: none;
}

.audio-seek-hit:hover .audio-seek-thumb,
.audio-seek-hit.is-dragging .audio-seek-thumb,
.audio-seek-hit:focus-visible .audio-seek-thumb {
  transform: translateY(-50%) scale(1);
}

/* Right: Quiet Lyric Snippet + Quality + Mode + Volume */
.audio-right {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
  min-width: 0;
  max-width: 100%;
}

.audio-lyric-snippet {
  font-size: 12px;
  line-height: 16px;
  font-weight: 400;
  color: var(--text-secondary, #8E8E93);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  min-width: 0;
  padding: 2px 6px 2px 0;
  text-align: right;
  transition: color 120ms ease;
}

.audio-lyric-snippet:hover {
  color: var(--text, #F4F4F6);
}

.audio-lyric-snippet[hidden],
.audio-lyric-snippet:empty {
  display: none;
}

.audio-quality-btn {
  font-size: 11px;
  font-weight: 500;
  line-height: 14px;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary, #8E8E93);
  padding: 4px 6px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 120ms ease, background-color 120ms ease, transform 90ms ease;
}

.audio-quality-btn:hover {
  color: var(--text, #F4F4F6);
  background-color: rgba(255, 255, 255, 0.06);
}

.audio-mode-btn.is-active-mode {
  color: var(--text, #F4F4F6);
}

.audio-vol-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.audio-vol-hit {
  width: 72px;
  height: 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
  outline: none;
}

.audio-vol-track {
  width: 100%;
  height: 2px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.16);
  position: relative;
  transition: height 120ms ease;
}

.audio-vol-hit:hover .audio-vol-track,
.audio-vol-hit.is-dragging .audio-vol-track,
.audio-vol-hit:focus-visible .audio-vol-track {
  height: 3px;
}

.audio-vol-fill {
  height: 100%;
  width: 72%;
  border-radius: 1px;
  background: #C8C8CE;
  position: relative;
}

.audio-vol-hit:hover .audio-vol-fill,
.audio-vol-hit.is-dragging .audio-vol-fill {
  background: #FFFFFF;
}

.audio-vol-thumb {
  position: absolute;
  top: 50%;
  right: -3.5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #FFFFFF;
  transform: translateY(-50%) scale(0);
  transition: transform 120ms ease;
  pointer-events: none;
}

.audio-vol-hit:hover .audio-vol-thumb,
.audio-vol-hit.is-dragging .audio-vol-thumb,
.audio-vol-hit:focus-visible .audio-vol-thumb {
  transform: translateY(-50%) scale(1);
}

/* ==========================================================================
   Mobile Persistent Mini-Audio Bar (48px, < 768px)
   Docked directly above the mobile 4-tab bar with neutral frosted matte surface.
   ========================================================================== */
.audio-bar-mobile {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: var(--mobile-audio-h, 48px);
  background: rgba(29, 29, 33, 0.88);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  backdrop-filter: saturate(140%) blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding: 0 8px 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  overflow: hidden;
  color: var(--text, #F4F4F6);
  font-family: var(--font-sans, "PingFang SC", "Microsoft YaHei UI", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  user-select: none;
  -webkit-user-select: none;
}

.mobile-audio-mount > .audio-bar-mobile {
  height: 100%;
  border-top: 0;
  border-bottom: 0;
}

.audio-bar-mobile.is-empty .audio-mobile-title {
  color: var(--text-secondary, #8E8E93);
  font-weight: 400;
}

.audio-bar-mobile.is-empty .audio-mobile-artist {
  color: var(--text-muted, #636368);
}

.audio-mobile-progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1.5px;
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}

.audio-mobile-progress-fill {
  position: relative;
  z-index: 1;
  height: 100%;
  width: 0%;
  background: #FFFFFF;
}

.audio-mobile-progress-shimmer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 42%;
  opacity: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.16) 22%,
    rgba(255, 255, 255, 0.72) 50%,
    rgba(255, 255, 255, 0.16) 78%,
    transparent 100%
  );
  pointer-events: none;
  will-change: transform;
  transition: opacity 160ms ease;
}

.audio-bar-mobile.is-loading .audio-mobile-progress-shimmer {
  opacity: 1;
  animation: audio-buffer-shimmer 1.25s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.audio-mobile-info {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.audio-mobile-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5px;
}

.audio-mobile-title {
  font-size: 12.5px;
  font-weight: 500;
  line-height: 15px;
  color: var(--text, #F4F4F6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-mobile-artist {
  font-size: 10.5px;
  font-weight: 400;
  line-height: 13px;
  color: var(--text-secondary, #8E8E93);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-mobile-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.audio-mobile-btn {
  width: 36px;
  height: 36px;
  border-radius: 6px;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1179.98px) {
  .audio-lyric-snippet {
    display: none;
  }
}

@media (max-width: 959.98px) {
  .audio-bar-desktop {
    padding: 0 16px;
    gap: 12px;
    grid-template-columns: minmax(120px, 1fr) auto minmax(120px, 1fr);
  }

  .audio-center {
    gap: 12px;
  }

  .audio-controls {
    gap: 4px;
  }

  .audio-right {
    gap: 6px;
  }

  .audio-vol-hit {
    width: 52px;
  }
}

@media (max-width: 767.98px) {
  .audio-bar-desktop {
    display: none;
  }
}

@media (min-width: 768px) {
  .audio-bar-mobile {
    display: none;
  }
}

/* Solid surface fallback when backdrop-filter is unavailable */
@supports not ((backdrop-filter: blur(16px)) or (-webkit-backdrop-filter: blur(16px))) {
  .audio-bar-desktop {
    background: var(--bg-elevated, #19191D);
  }

  .audio-bar-mobile {
    background: var(--mobile-audio-bg, #1D1D21);
  }

  [data-theme="light"] .audio-bar-desktop {
    background: var(--bg-elevated, #F4F4F6);
  }

  [data-theme="light"] .audio-bar-mobile {
    background: var(--mobile-audio-bg, #FAFAFC);
  }
}

/* ==========================================================================
   Optional Light Theme Restraint ([data-theme="light"] from Settings modal)
   ========================================================================== */
[data-theme="light"] .audio-bar-desktop {
  background: rgba(246, 246, 248, 0.86);
  border-top-color: var(--border, #DCDCE2);
  color: var(--text, #141416);
}

[data-theme="light"] .audio-bar-mobile {
  background: rgba(250, 250, 252, 0.88);
  border-top-color: var(--border, #DCDCE2);
  border-bottom-color: var(--border, #E2E2E6);
  color: var(--text, #141416);
}

[data-theme="light"] .audio-seek-shimmer,
[data-theme="light"] .audio-mobile-progress-shimmer {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(20, 20, 22, 0.1) 22%,
    rgba(20, 20, 22, 0.42) 50%,
    rgba(20, 20, 22, 0.1) 78%,
    transparent 100%
  );
}

[data-theme="light"] .audio-cover::after {
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .audio-cover-fallback {
  background: #E8E8EC;
  color: #6E6E73;
}

[data-theme="light"] .audio-icon-btn {
  color: #3A3A3F;
}

[data-theme="light"] .audio-icon-btn--play {
  color: #141416;
}

[data-theme="light"] .audio-icon-btn:hover:not(:disabled),
[data-theme="light"] .audio-quality-btn:hover {
  color: #141416;
  background-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .audio-seek-track,
[data-theme="light"] .audio-vol-track,
[data-theme="light"] .audio-mobile-progress {
  background: rgba(20, 20, 22, 0.16);
}

[data-theme="light"] .audio-seek-fill,
[data-theme="light"] .audio-seek-thumb,
[data-theme="light"] .audio-vol-thumb,
[data-theme="light"] .audio-mobile-progress-fill {
  background: #141416;
}

[data-theme="light"] .audio-vol-fill {
  background: #3A3A3F;
}

[data-theme="light"] .audio-vol-hit:hover .audio-vol-fill,
[data-theme="light"] .audio-vol-hit.is-dragging .audio-vol-fill {
  background: #141416;
}

[data-theme="light"] .audio-icon-btn:focus-visible,
[data-theme="light"] .audio-quality-btn:focus-visible,
[data-theme="light"] .audio-track-btn:focus-visible,
[data-theme="light"] .audio-lyric-snippet:focus-visible,
[data-theme="light"] .audio-mobile-info:focus-visible,
[data-theme="light"] .audio-seek-hit:focus-visible,
[data-theme="light"] .audio-vol-hit:focus-visible {
  outline-color: rgba(20, 20, 22, 0.5);
}
