/* ============================================================
   音频播放器 · 样式（固定布局 · 无整页滚动 · 底部栏不遮挡）
   ============================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', 'PingFang SC', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* ========== 全局：禁止整页滚动 ========== */
html, body {
  height: 100%;
  overflow: hidden;              /* 关键：禁止整页滚动 */
  overscroll-behavior: none;
}

body {
  background: linear-gradient(160deg, #1b2242 0%, #2a2f5e 40%, #3b3160 70%, #4a3a6b 100%);
  background-attachment: fixed;
  color: #e6e9ff;
  position: relative;
  display: flex;
  justify-content: center;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* 星空层 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 20% 30%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 60% 15%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 80% 40%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 15% 70%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 45% 85%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 90% 80%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 35% 50%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 70% 65%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 10% 20%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 55%, #fff 50%, transparent 51%);
  opacity: 0.75;
  animation: twinkle 6s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

/* 月亮 */
body::after {
  content: '';
  position: fixed;
  top: 4%;
  right: 6%;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff8e0, #f6e6b8 55%, #e6cd7a 100%);
  box-shadow:
    0 0 30px rgba(255, 240, 200, 0.6),
    0 0 80px rgba(255, 220, 160, 0.35),
    inset -8px -8px 16px rgba(180, 150, 90, 0.25);
  pointer-events: none;
  z-index: 0;
}

@keyframes twinkle {
  0%   { opacity: 0.55; }
  100% { opacity: 0.95; }
}

/* ========== 主容器：撑满一屏，内部弹性布局 ========== */
.audio-app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 1rem 1rem 0;
  padding-top: calc(4.5rem + env(safe-area-inset-top));
  overflow: hidden;
}

/* 玻璃卡片效果统一放在内层 */
.app-header,
.search-box {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ========== 头部 ========== */
.app-header {
  margin-bottom: 0.7rem;
  padding: 1rem 1.2rem;
  border-radius: 24px;
  text-align: center;
  flex-shrink: 0;
}

.goodnight-title {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  margin-bottom: 0.5rem;
  background: linear-gradient(120deg, #ffd9b3, #ffb3d9, #b3c7ff, #ffd9b3);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: goodnightShimmer 6s ease-in-out infinite;
}

@keyframes goodnightShimmer {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.goodnight-lines {
  margin: 0.3rem 0 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.goodnight-lines p {
  font-size: 0.85rem;
  line-height: 1.5;
  color: rgba(230, 235, 255, 0.78);
  letter-spacing: 0.3px;
}

.app-sub {
  font-size: 0.8rem;
  color: rgba(230, 235, 255, 0.6);
  margin-top: 0.3rem;
  letter-spacing: 0.5px;
}

/* ========== 搜索框 ========== */
.search-box {
  position: relative;
  margin-bottom: 0.7rem;
  border-radius: 40px;
  flex-shrink: 0;
}

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  opacity: 0.6;
}

#searchInput {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.7rem;
  border-radius: 40px;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  color: #f0f3ff;
  outline: none;
}

#searchInput::placeholder {
  color: rgba(230, 235, 255, 0.45);
}

/* ========== 音频列表（唯一可滚动区域） ========== */
.audio-list {
  flex: 1;                        /* 占满剩余空间 */
  overflow-y: auto;               /* 内部滚动 */
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;   /* 滚动到头不会带动页面 */
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 4px 16px;
  margin-bottom: 0;
}

.audio-list::-webkit-scrollbar { width: 4px; }
.audio-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 10px;
}
.audio-list::-webkit-scrollbar-track { background: transparent; }

.audio-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.75rem 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 0.22s ease;
  user-select: none;
  -webkit-user-select: none;
  flex-shrink: 0;
}

.audio-item:active {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(0.99);
}

.audio-item.playing {
  background: linear-gradient(120deg, rgba(160, 180, 255, 0.22), rgba(200, 160, 255, 0.22));
  border-color: rgba(180, 200, 255, 0.4);
  box-shadow: 0 6px 22px rgba(120, 140, 220, 0.25);
}

.audio-item .item-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #d6ddff;
  flex-shrink: 0;
  transition: all 0.3s;
}

.audio-item.playing .item-icon {
  background: linear-gradient(135deg, #a0b4ff, #c7a0ff);
  color: #1b2242;
  box-shadow: 0 0 0 4px rgba(160, 180, 255, 0.2);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

.audio-item .item-name {
  flex: 1;
  font-size: 0.95rem;
  color: #e6e9ff;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.audio-item.playing .item-name {
  color: #ffffff;
  font-weight: 600;
}

.audio-item .item-duration {
  font-size: 0.78rem;
  color: rgba(230, 235, 255, 0.55);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* ========== 底部播放栏（固定布局，不浮动） ========== */
.player-bar {
  flex-shrink: 0;
  background: rgba(30, 35, 70, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.35);
  padding: 0.9rem 1rem;
  padding-bottom: calc(0.9rem + env(safe-area-inset-bottom));
  margin: 0 -1rem;                /* 抵消父容器 padding，铺满底部 */
  margin-top: 6px;
}

.player-bar .player-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 0.7rem;
}

.player-cover {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a0b4ff, #c7a0ff);
  color: #1b2242;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(140, 160, 240, 0.5);
}

.player-meta { flex: 1; min-width: 0; }

.player-title {
  font-size: 0.95rem;
  color: #ffffff;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-sub {
  font-size: 0.75rem;
  color: rgba(230, 235, 255, 0.6);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0.6rem;
}

.time-current, .time-total {
  font-size: 0.72rem;
  color: rgba(230, 235, 255, 0.65);
  min-width: 36px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

#progressBar {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
  cursor: pointer;
  min-width: 0;
}

#progressBar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #a0b4ff;
  box-shadow: 0 2px 8px rgba(140, 160, 240, 0.6);
  cursor: pointer;
}

#progressBar::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #a0b4ff;
  cursor: pointer;
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
}

.ctrl-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #d6ddff;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 6px;
  border-radius: 50%;
  min-width: 40px;
  min-height: 40px;
}

.ctrl-btn:active { transform: scale(0.9); }
.ctrl-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.play-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a0b4ff, #c7a0ff);
  color: #1b2242;
  font-size: 1.35rem;
  box-shadow: 0 8px 22px rgba(140, 160, 240, 0.55);
}

.play-btn:active { transform: scale(0.96); }

/* ========== 加载动画层 ========== */
.loading-tip {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(30, 35, 70, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(180, 200, 255, 0.25);
  border-radius: 24px;
  padding: 1.6rem 1.8rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.loading-tip.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.loading-moon {
  font-size: 2.2rem;
  animation: moonFloat 1.8s ease-in-out infinite;
  filter: drop-shadow(0 0 12px rgba(255, 220, 160, 0.5));
}

@keyframes moonFloat {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50%      { transform: translateY(-6px) rotate(8deg); }
}

.loading-text {
  color: #e6e9ff;
  font-size: 0.9rem;
  letter-spacing: 1px;
  font-weight: 500;
}

.loading-dots {
  display: flex;
  gap: 6px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a0b4ff, #c7a0ff);
  animation: dotJump 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.loading-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dotJump {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%           { transform: translateY(-6px); opacity: 1; }
}

/* ========== 移动端小屏适配 ========== */
@media (max-width: 480px) {
  .audio-app {
    padding: 0.7rem 0.7rem 0;
    padding-top: calc(4rem + env(safe-area-inset-top)); 
  }

  .app-header { padding: 0.9rem 1rem; margin-bottom: 0.6rem; }
  .goodnight-title { font-size: 1.5rem; margin-bottom: 0.4rem; }
  .goodnight-lines p { font-size: 0.78rem; }
  .app-sub { font-size: 0.75rem; }

  .search-box { margin-bottom: 0.6rem; }
  #searchInput { padding: 0.65rem 1rem 0.65rem 2.5rem; font-size: 0.9rem; }

  .audio-list { gap: 7px; padding-bottom: 12px; }
  .audio-item { padding: 0.65rem 0.85rem; gap: 10px; border-radius: 14px; }
  .audio-item .item-icon { width: 32px; height: 32px; font-size: 0.9rem; }
  .audio-item .item-name { font-size: 0.88rem; }
  .audio-item .item-duration { font-size: 0.72rem; }

  .player-bar {
    padding: 0.8rem 0.9rem;
    padding-bottom: calc(0.8rem + env(safe-area-inset-bottom));
    margin: 0 -0.7rem;
    margin-top: 5px;
  }

  .player-cover { width: 38px; height: 38px; font-size: 1.15rem; }
  .player-title { font-size: 0.88rem; }
  .player-sub { font-size: 0.7rem; }

  .time-current, .time-total { font-size: 0.68rem; min-width: 32px; }
  .player-controls { gap: 1.6rem; }
  .ctrl-btn { font-size: 1.2rem; min-width: 36px; min-height: 36px; padding: 5px; }
  .play-btn { width: 46px; height: 46px; font-size: 1.2rem; }
}

@media (max-width: 375px) {
  .goodnight-title { font-size: 1.35rem; }
  .goodnight-lines p { font-size: 0.74rem; }
  .audio-item .item-name { font-size: 0.85rem; }
  .player-controls { gap: 1.3rem; }
  .play-btn { width: 42px; height: 42px; font-size: 1.1rem; }
}

@media (max-width: 320px) {
  .goodnight-title { font-size: 1.2rem; }
  .goodnight-lines p { font-size: 0.7rem; }
  .audio-item .item-duration { display: none; }
}

/* ========== 通用返回按钮 ========== */
.back-fab {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top));
  left: 1rem;
  z-index: 999;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e6e9ff;
  font-size: 1.3rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.22s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
}

.back-fab:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateX(-2px);
}

.back-fab:active { transform: scale(0.92); }

@media (max-width: 480px) {
  .back-fab {
    top: calc(0.7rem + env(safe-area-inset-top));
    left: 0.7rem;
    width: 40px;
    height: 40px;
    font-size: 1.15rem;
  }
}