/* ===== 基础重置 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #f0f0f5;
  background: #0a0e1a;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;          /* 去掉移动端 300ms 点击延迟 */
}
button { cursor: pointer; border: none; background: none; color: inherit; font-family: inherit; }
input { font-family: inherit; }
ul { list-style: none; }
img { display: block; }

/* ===== 背景模糊层 ===== */
.bg-blur {
  position: fixed; inset: -80px; z-index: -2;
  background: linear-gradient(135deg, #0f3a4a 0%, #0a0e1a 50%, #1a2f4a 100%);
  background-size: cover;
  background-position: center;
  filter: blur(64px) saturate(2);
  opacity: 0;
  transition: opacity 1.1s ease;
  will-change: opacity, transform;
  animation: bgDrift 28s ease-in-out infinite alternate;
}
.bg-blur.show { opacity: 1; }
.bg-blur:nth-of-type(2) { animation-delay: -14s; }

@keyframes bgDrift {
  0%   { transform: scale(1.08) translate(0, 0); }
  25%  { transform: scale(1.14) translate(-2%, 1.5%); }
  50%  { transform: scale(1.1)  translate(1.5%, -2%); }
  75%  { transform: scale(1.16) translate(-1.5%, -1%); }
  100% { transform: scale(1.1)  translate(2%, 2%); }
}
.bg-mask {
  position: fixed; inset: 0; z-index: -1;
  background: rgba(8, 12, 20, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ===== 主容器 ===== */
.app {
  height: 100vh;
  display: grid;
  grid-template-rows: 64px 1fr 32px;
  padding: 16px 24px;
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ===== 顶部栏 ===== */
.topbar { display: flex; align-items: center; gap: 24px; }
.logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 24px; font-weight: 700; letter-spacing: 1px;
}
.logo-icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #5eead4, #38bdf8);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #0a0e1a;
  box-shadow: 0 4px 20px rgba(56, 189, 248, 0.35);
}
.search {
  flex: 1; max-width: 600px;
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 4px 4px 4px 18px;
  transition: all 0.2s;
}
.search:focus-within {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(94, 234, 212, 0.5);
  box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.12);
}
.search-ico { color: rgba(255, 255, 255, 0.5); flex-shrink: 0; }
.search input {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none;
  color: #fff; font-size: 14px;
}
.search input::placeholder { color: rgba(255, 255, 255, 0.4); }
.search button {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  background: linear-gradient(135deg, #5eead4, #38bdf8);
  border-radius: 20px;
  font-size: 14px; font-weight: 500; color: #0a0e1a;
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
.search button:hover { transform: scale(1.04); box-shadow: 0 4px 16px rgba(56, 189, 248, 0.35); }
.search button:active { transform: scale(0.97); }

/* ===== 卡片基底 ===== */
.card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* ===== 内容区 ===== */
.content {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  min-height: 0;
}

/* ===== 当前播放 ===== */
.now-playing {
  display: flex; flex-direction: column; align-items: center;
  padding: 32px; overflow: hidden; position: relative;
}
.cover-wrap { position: relative; width: 240px; height: 240px; margin-bottom: 24px; }
.cover-disc {
  width: 100%; height: 100%; border-radius: 50%; overflow: hidden;
  background: #1a1a2a;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5),
              inset 0 0 0 8px rgba(0, 0, 0, 0.3),
              inset 0 0 0 9px rgba(255, 255, 255, 0.05),
              0 0 0 1px rgba(255, 255, 255, 0.07);  /* 静止外环 */
  animation: spin 20s linear infinite;
  animation-play-state: paused;
  transition: box-shadow 0.6s ease;
}
.cover-disc.playing {
  animation-play-state: running;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55),
              inset 0 0 0 8px rgba(0, 0, 0, 0.3),
              inset 0 0 0 9px rgba(255, 255, 255, 0.05),
              0 0 0 2px rgba(94, 234, 212, 0.35),   /* 青色外环 */
              0 0 32px rgba(94, 234, 212, 0.12);    /* 弥散光晕 */
}
.cover-disc img { width: 100%; height: 100%; object-fit: cover; display: none; }
.cover-disc img.loaded { display: block; }
.cover-empty {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: rgba(255, 255, 255, 0.3); gap: 12px; font-size: 13px;
}
.cover-empty.hidden { display: none; }
.needle {
  position: absolute; top: -10px; left: 50%;
  width: 6px; height: 80px;
  background: linear-gradient(180deg, #888 0%, #ddd 50%, #888 100%);
  border-radius: 3px;
  transform-origin: top center;
  transform: translateX(-50%) rotate(-25deg);
  transition: transform 0.4s ease;
  z-index: 2;
}
.needle::before {
  content: ''; position: absolute; top: -8px; left: 50%;
  transform: translateX(-50%);
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #eee, #555);
}
.cover-disc.playing ~ .needle { transform: translateX(-50%) rotate(0deg); }
@keyframes spin { to { transform: rotate(360deg); } }

.meta { text-align: center; margin-bottom: 24px; width: 100%; }
.song-title {
  font-size: 22px; font-weight: 500; margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.song-artist { font-size: 14px; color: rgba(255, 255, 255, 0.7); margin-bottom: 4px; }
.song-album { font-size: 12px; color: rgba(255, 255, 255, 0.45); margin-bottom: 10px; }
.badges { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 11px; padding: 3px 10px; border-radius: 10px;
  background: rgba(94, 234, 212, 0.14);
  color: #99f6e4;
  border: 1px solid rgba(94, 234, 212, 0.3);
}

/* ===== 播放器 ===== */
.player { width: 100%; max-width: 480px; margin-top: auto; }
.progress {
  position: relative; height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px; cursor: pointer;
  touch-action: none;                  /* 拖动进度时不滚动页面 */
}
.progress::before { content: ''; position: absolute; inset: -12px 0; }  /* 扩大触控命中区 */
.progress-fill {
  position: absolute; top: 0; left: 0; height: 100%; width: 0;
  background: linear-gradient(90deg, #5eead4, #38bdf8);
  border-radius: 3px;
  transition: width 0.1s linear;
  box-shadow: 0 0 8px rgba(94, 234, 212, 0.4);   /* 进度条发光 */
}
.progress-handle {
  position: absolute; top: 50%; left: 0;
  width: 14px; height: 14px;
  background: #fff; border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0; transition: opacity 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.progress:hover .progress-handle { opacity: 1; }

.time-row {
  display: flex; justify-content: space-between;
  font-size: 12px; color: rgba(255, 255, 255, 0.6);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex; align-items: center; justify-content: center;
  gap: 24px; margin-top: 16px;
}
.ctrl-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.85);
  transition: all 0.15s;
}
.ctrl-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.ctrl-btn:active { transform: scale(0.92); }
.play-btn {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, #5eead4, #38bdf8);
  color: #0a0e1a;
  box-shadow: 0 6px 24px rgba(56, 189, 248, 0.4);
}
.play-btn:hover { background: linear-gradient(135deg, #6ff0dc, #56c8fa); }

/* 控制行里的额外按钮（模式/歌单）默认只在移动端显示 */
.ctrl-extra { display: none; }

.bottom-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 18px;
}
.mode-btn {
  font-size: 12px; padding: 5px 12px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
  transition: all 0.15s;
}
.mode-btn:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.volume { display: flex; align-items: center; gap: 8px; color: rgba(255, 255, 255, 0.7); }
.volume input[type="range"] {
  width: 100px; -webkit-appearance: none; appearance: none;
  height: 4px; background: rgba(255, 255, 255, 0.15);
  border-radius: 2px; outline: none; cursor: pointer;
}
.volume input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px;
  background: #fff; border-radius: 50%;
}
.volume input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; background: #fff; border-radius: 50%; border: none;
}

/* ===== 侧栏（桌面分栏 / 移动抽屉 共用） ===== */
.backdrop { display: none; }            /* 桌面不需要遮罩 */
.sheet-grab, .sheet-close { display: none; }  /* 抓手与关闭按钮只在移动端出现 */
.side { display: flex; flex-direction: column; overflow: hidden; }
.tabs {
  display: flex; align-items: center;
  padding: 12px 16px 0; gap: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.tab {
  flex: 1; padding: 10px; font-size: 14px;
  color: rgba(255, 255, 255, 0.55);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tab:hover { color: rgba(255, 255, 255, 0.85); }
.tab.active { color: #fff; border-bottom-color: #5eead4; }
.tab-panel { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.list {
  flex: 1; overflow-y: auto; padding: 8px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.list::-webkit-scrollbar { width: 6px; }
.list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
.list::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
.list .placeholder {
  text-align: center; padding: 40px 20px;
  color: rgba(255, 255, 255, 0.35); font-size: 13px;
}

.song-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  transition: background 0.15s;
}
.song-item:hover { background: rgba(255, 255, 255, 0.06); }
.song-item.active {
  background: rgba(94, 234, 212, 0.1);
  border: 1px solid rgba(94, 234, 212, 0.3);
}
.song-item .num {
  font-size: 13px; color: rgba(255, 255, 255, 0.4);
  width: 22px; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.song-item .info { flex: 1; min-width: 0; }
.song-item .name {
  font-size: 14px; color: #fff; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.song-item .sub {
  font-size: 12px; color: rgba(255, 255, 255, 0.5);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.song-item .play-icon {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255, 255, 255, 0.6); flex-shrink: 0;
  opacity: 0; transition: opacity 0.15s;
}

.song-item .actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.song-item .add-history-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.06);
  opacity: 1;
  transition: all 0.15s;
}

.song-item .delete-history-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 120, 120, 0.75);
  background: rgba(255, 80, 80, 0.08);
  opacity: 0;
  transition: all 0.15s;
  flex-shrink: 0;
}

.song-item:hover .delete-history-btn,
.song-item.active .delete-history-btn {
  opacity: 1;
}

.song-item .delete-history-btn:hover {
  color: #fff;
  background: rgba(255, 80, 80, 0.28);
}

.song-item:hover .add-history-btn {
  opacity: 1;
}

.song-item .add-history-btn:hover {
  color: #0a0e1a;
  background: linear-gradient(135deg, #5eead4, #38bdf8);
}

.song-item.active .add-history-btn {
  opacity: 1;
}

.song-item:hover .play-icon { opacity: 1; }
.song-item.active .play-icon { opacity: 1; color: #5eead4; }

.clear-btn {
  margin: 8px 16px 16px; padding: 8px; font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px; transition: all 0.15s;
}
.clear-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

/* ===== 加载状态 ===== */
.loading-item { display: flex; justify-content: center; align-items: center; padding: 40px 0; }
.spinner {
  width: 24px; height: 24px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: #5eead4; border-radius: 50%;
  animation: rotate 0.8s linear infinite;
}
@keyframes rotate { to { transform: rotate(360deg); } }

/* ===== 底部 ===== */
.foot {
  text-align: center; font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  display: flex; align-items: center; justify-content: center;
}

/* ===== Toast ===== */
.toast {
  position: fixed; top: 20px; left: 50%;
  transform: translateX(-50%) translateY(-80px);
  padding: 10px 20px;
  background: rgba(20, 20, 30, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px; font-size: 13px; z-index: 1000;
  opacity: 0; transition: all 0.3s ease;
  pointer-events: none;
  backdrop-filter: blur(10px);
  max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
 *  响应式：≤ 768px 切换为手机布局
 *  侧栏从右侧分栏变为底部抽屉，控制行内联模式/歌单按钮
 * ============================================================ */
@media (max-width: 768px) {
  .app {
    height: 100vh; height: 100dvh;       /* 动态视口，避开地址栏跳动 */
    display: flex; flex-direction: column;
    max-width: none;
    padding: calc(env(safe-area-inset-top) + 12px) 18px
             calc(env(safe-area-inset-bottom) + 16px);
    gap: 8px;
  }

  /* 顶部：隐藏文字 logo 与搜索按钮文字，回车即搜 */
  .topbar { gap: 12px; }
  .logo-text { display: none; }
  .logo-icon { width: 38px; height: 38px; }
  .search { max-width: none; padding: 0 16px; height: 44px; }
  .search button { display: none; }
  .search input { font-size: 15px; }

  /* 内容区改为纵向铺满 */
  .content { display: flex; flex-direction: column; flex: 1; min-height: 0; }

  /* 当前播放占满整屏并垂直居中 */
  .now-playing {
    flex: 1; justify-content: center;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px 20px;
  }
  .cover-wrap { width: min(64vw, 260px); height: auto; aspect-ratio: 1/1; margin-bottom: 22px; }
  .needle { height: 70px; }
  .song-title { font-size: 20px; }
  .player { max-width: 460px; margin-top: 20px; }

  /* 进度条加粗、手柄常显 */
  .progress { height: 6px; }
  .progress-handle { width: 16px; height: 16px; opacity: 1; }

  /* 控制行：模式 + 上/播/下 + 歌单，加大触控目标 */
  .controls { gap: 14px; margin-top: 22px; }
  .ctrl-extra { display: flex; align-items: center; justify-content: center; }
  .ctrl-btn { width: 52px; height: 52px; }
  .play-btn { width: 66px; height: 66px; }
  .mode-btn.ctrl-extra, .list-btn {
    min-width: 48px; height: 40px; padding: 0 10px; border-radius: 14px;
    background: rgba(255, 255, 255, 0.08); color: rgba(255, 255, 255, 0.8);
  }
  
  /* 顺序播放按钮、列表按钮往中间收一点 */
#modeBtn {
  transform: translateX(8px);
}

#openSheet {
  transform: translateX(-8px);
}
  
  .mode-btn.ctrl-extra:active, .list-btn:active { background: rgba(255, 255, 255, 0.16); }

  /* 桌面底部行（音量+模式）在手机隐藏 */
  .bottom-row { display: none; }

  /* 遮罩 */
  .backdrop {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
  }
  .backdrop.show { opacity: 1; visibility: visible; }

  /* 侧栏 → 底部抽屉 */
  .side {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    height: 72vh; height: 72dvh;
    border-radius: 22px 22px 0 0;
    background: rgba(18, 22, 34, 0.96);
    border: none;
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    padding-bottom: env(safe-area-inset-bottom);
    will-change: transform;
  }
  /* 渐变顶部边线 */
  .side::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(94,234,212,0.5) 30%, rgba(56,189,248,0.5) 70%, transparent 100%);
    border-radius: 22px 22px 0 0;
  }
  .side.show { transform: translateY(0); }

  .sheet-grab { display: flex; justify-content: center; padding: 10px 0 4px; touch-action: none; }
  .sheet-grab span { width: 40px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.25); }
  .tabs { padding: 4px 12px 0; }
  .tab { padding: 12px 0; font-size: 15px; }
  .sheet-close {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; font-size: 16px;
    color: rgba(255, 255, 255, 0.5); flex-shrink: 0;
  }
  .song-item { padding: 13px 12px; }
  .song-item .name { font-size: 15px; }
  .song-item .play-icon { display: none; }   /* 触屏无 hover，省略 */
  .clear-btn { padding: 12px; font-size: 14px; }

  .foot { display: none; }                    /* 手机端隐藏页脚省空间 */
}

/* 横屏小高度：缩小封面避免溢出 */
@media (max-width: 768px) and (orientation: landscape) and (max-height: 500px) {
  .cover-wrap { width: min(34vh, 150px); margin-bottom: 10px; }
  .controls { margin-top: 12px; }
  .player { margin-top: 10px; }
  .song-item .add-history-btn {
  opacity: 1;
  width: 32px;
  height: 32px;
}

}
/* 手机端固定显示添加按钮 */
@media (max-width: 768px) {
  .song-item .actions {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .song-item .add-history-btn {
    opacity: 1 !important;
    visibility: visible;
    display: flex;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
  }
}
/* 拖动进度条时取消动画，避免进度条延迟 */
.progress.seeking .progress-fill,
.progress.seeking .progress-handle {
  transition: none !important;
}
@media (max-width: 768px) {
  .song-item .delete-history-btn {
    opacity: 1 !important;
    visibility: visible;
    display: flex;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
  }
}