:root {
  --bg: var(--tg-theme-bg-color, #0f1115);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #1a1d24);
  --text: var(--tg-theme-text-color, #f1f2f5);
  --hint: var(--tg-theme-hint-color, #8b91a0);
  --accent: var(--tg-theme-button-color, #2ea6ff);
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --danger: #ef4444;
  --panel-soft: rgba(127,127,127,.10);
}

/* 浏览器直接打开（无 Telegram 主题变量注入）时，跟随系统深浅色 */
@media (prefers-color-scheme: light) {
  :root {
    --bg: var(--tg-theme-bg-color, #f4f3ee);
    --bg-secondary: var(--tg-theme-secondary-bg-color, #ffffff);
    --text: var(--tg-theme-text-color, #1a1b1c);
    --hint: var(--tg-theme-hint-color, #6b7280);
    --accent: var(--tg-theme-button-color, #0e86d4);
    --panel-soft: rgba(0,0,0,.05);
  }
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
}
.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  padding: 4px 16px 0;
}

/* ---- 当前播放 ---- */
.now-playing {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 2px 16px;
  flex-shrink: 0;
}
.cover {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-secondary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-fallback { font-size: 26px; color: var(--hint); }
.meta { flex: 1; min-width: 0; }
.title {
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.artist {
  font-size: 13px;
  color: var(--hint);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mode-btn {
  background: var(--bg-secondary);
  border: none;
  color: var(--hint);
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 10px;
  cursor: pointer;
  flex-shrink: 0;
}
.mode-btn:active { transform: scale(.95); }
.mode-btn.on { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.share-btn {
  background: none;
  border: none;
  color: var(--hint);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.share-btn:active { background: var(--bg-secondary); transform: scale(.94); }
.share-btn svg { transform: translateY(3px); }

/* ---- 歌词面板 ---- */
.lyric-panel {
  background: var(--bg-secondary);
  border-radius: 14px;
  margin: 0 0 10px;
  overflow: hidden;
  flex-shrink: 0;
}
.lyric-scroll {
  max-height: 190px;
  overflow-y: auto;
  padding: 14px 18px 16px;
  scroll-behavior: smooth;
}
.lyric-line {
  font-size: 14px;
  line-height: 2.1;
  color: var(--hint);
  text-align: center;
  padding: 3px 0;
  transition: color .25s ease, transform .25s ease, font-weight .25s ease;
}
.lyric-line.active {
  color: var(--text);
  font-weight: 700;
  transform: scale(1.18);
  text-shadow: 0 1px 8px rgba(0,0,0,.35);
}
.lyric-empty {
  color: var(--hint);
  font-size: 13px;
  text-align: center;
  padding: 24px 0;
}

/* ---- 进度条 ---- */
.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 2px 4px;
  flex-shrink: 0;
}
.time { font-size: 11px; color: var(--hint); font-variant-numeric: tabular-nums; }
.progress {
  flex: 1;
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
  touch-action: none;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0;
}
.progress-thumb {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  left: 0;
  display: none;
}
.progress.dragging .progress-thumb { display: block; }

/* ---- 控制条（经典图标：无背景、黑色，播放时主题色） ---- */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  padding: 18px 0 22px;
  flex-shrink: 0;
}
.ctrl-btn {
  background: none;
  border: none;
  color: #000;
  cursor: pointer;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .2s, transform .15s;
}
.ctrl-btn:active { transform: scale(.9); }
.ctrl-btn.prev svg { transform: scaleX(-1); }
/* 播放键：比两侧更大 */
.ctrl-btn.play { width: 66px; height: 66px; }
/* 播放键：经典播放/暂停切换，播放时主题色 */
.ctrl-btn.play .ic-pause { display: none; }
.ctrl-btn.play.playing .ic-pause { display: block; }
.ctrl-btn.play.playing .ic-tri { display: none; }
.ctrl-btn.play.playing { color: var(--accent); }

/* 深色模式：播放器按钮变浅色（避免黑色按钮在深色背景上看不到） */
body.dark .ctrl-btn { color: #e8e8e8; }
body.dark .ctrl-btn.play.playing { color: var(--accent); }

/* ---- 内容区 ---- */
.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
  min-height: 0;
}

/* ---- 曲库排序栏（固定不随滚动） ---- */
.sortbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding: 4px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sort-group {
  display: flex;
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 2px;
  flex-shrink: 0;
}
.sort-group button {
  border: none;
  background: none;
  color: var(--hint);
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 8px;
  cursor: pointer;
}
.sort-group button.on { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.search {
  flex: 1;
  min-width: 0;
  background: var(--bg-secondary);
  border: none;
  color: var(--text);
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 10px;
  outline: none;
}
.search::placeholder { color: rgba(139,145,160,.5); }
.icon-btn {
  background: var(--bg-secondary);
  border: none;
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 15px;
  flex-shrink: 0;
}
.icon-btn.on { background: var(--accent); color: var(--accent-text); }
.list-count { font-size: 11px; color: var(--hint); padding: 0 4px 8px; text-align: right; }
.load-more {
  text-align: center;
  font-size: 11px;
  color: var(--hint);
  opacity: .7;
  padding: 12px 0 4px;
}

/* ---- 歌曲列表 ---- */
ul.song-list { list-style: none; }
ul.song-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 6px;
  border-radius: 12px;
  cursor: pointer;
}
ul.song-list li:active { background: var(--bg-secondary); }
/* 正在播放的歌曲：深灰色背景，与其他歌曲区分 */
ul.song-list li.active { background: rgba(127,127,127,.22); }
.track-cover {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-secondary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: var(--hint);
}
.track-cover img { width: 100%; height: 100%; object-fit: cover; }
.track-info { flex: 1; min-width: 0; }
.track-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-artist {
  font-size: 12px;
  color: var(--hint);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-dur { font-size: 11px; color: var(--hint); font-variant-numeric: tabular-nums; flex-shrink: 0; }

.lrc-badge {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: 1px;
}
/* 热度信号：四级，缩小，置于时长前 */
.heat {
  font-size: 9px;
  color: var(--accent);
  letter-spacing: .5px;
  flex-shrink: 0;
  margin-right: 4px;
  opacity: .9;
}

.track-mgr { display: flex; gap: 5px; flex-shrink: 0; margin-left: 4px; }
.mgr-btn {
  background: var(--bg-secondary);
  border: none;
  color: var(--text);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mgr-btn:active { transform: scale(.9); }
.mgr-btn.del { background: rgba(239, 68, 68, .18); color: var(--danger); }

.add-play-btn {
  background: rgba(46, 166, 255, .16);
  border: none;
  color: var(--accent);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.add-play-btn:active { transform: scale(.9); }
.add-play-btn.rm {
  background: none;
  color: var(--hint);
  font-size: 14px;
}

/* ---- 我的歌单（单列折叠，浅色背景） ---- */
.list-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px 10px;
}
.list-title { font-size: 14px; font-weight: 600; flex: 1; }
ul.playlist-list { list-style: none; }
.playlist-item {
  border-radius: 14px;
  margin-bottom: 8px;
  overflow: hidden;
  background: var(--panel-soft);
}
.playlist-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  cursor: pointer;
}
.playlist-head .pl-arrow {
  font-size: 20px;
  color: var(--text);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s;
  flex-shrink: 0;
}
.playlist-item.open .pl-arrow { transform: rotate(90deg); }
.playlist-head .pl-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.playlist-head .pl-count { font-size: 12px; color: var(--hint); flex-shrink: 0; }
.playlist-head .del {
  background: none;
  border: none;
  color: #b0b6c2;
  font-size: 16px;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.playlist-head .del:active { background: rgba(127,127,127,.15); }
.playlist-head .pl-share {
  background: none;
  border: none;
  color: #b0b6c2;
  font-size: 15px;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.playlist-head .pl-share:active { background: rgba(127,127,127,.15); }
.playlist-head .pl-share svg { transform: translateY(3px); }

/* ---- 分享歌单展示区（别人分享的歌单，显示完整歌曲列表） ---- */
.shared-section {
  background: rgba(46, 166, 255, .08);
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 14px;
}
.shared-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px 10px;
}
.shared-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  word-break: break-all;
}
.shared-add {
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 9px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
.shared-add:active { transform: scale(.95); }

/* ---- 分享面板里的歌曲列表 ---- */
.share-song-list {
  max-height: 140px;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 10px;
}
.share-song-row {
  font-size: 12px;
  color: var(--text);
  padding: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.share-song-more {
  font-size: 11px;
  color: var(--hint);
  padding: 2px 0;
}
.pl-body { display: none; }
.playlist-item.open .pl-body { display: block; padding: 0 6px 8px; }
.pl-empty { font-size: 12px; color: var(--hint); text-align: center; padding: 14px 0; }

/* ---- 宝盒：曲库工具（查重） ---- */
.box-func {
  width: 100%;
  text-align: left;
  background: var(--bg-secondary);
  border: none;
  color: var(--text);
  font-size: 14px;
  padding: 13px 14px;
  border-radius: 12px;
  cursor: pointer;
  margin-bottom: 12px;
}
.box-func:active { transform: scale(.98); }
.dup-group {
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.dup-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  word-break: break-all;
}
.dup-title span:first-child { flex: 1; }
.dup-cnt {
  font-size: 11px;
  color: var(--accent);
  flex-shrink: 0;
}
.dup-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
}
.dup-name {
  flex: 1;
  font-size: 12px;
  color: var(--hint);
}
.dup-del {
  background: rgba(239, 68, 68, .16);
  border: none;
  color: var(--danger);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.dup-del:active { transform: scale(.94); }

/* ---- 数据统计面板 ---- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.stats-card {
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 12px;
}
.stats-k { font-size: 11px; color: var(--hint); margin-bottom: 4px; }
.stats-v { font-size: 15px; font-weight: 700; }
.stats-today {
  background: rgba(46, 166, 255, .12);
  color: var(--text);
  font-size: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}
.stats-subhead { font-size: 12px; color: var(--hint); margin-bottom: 8px; }
.stats-day {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.stats-date { width: 34px; font-size: 11px; color: var(--hint); flex-shrink: 0; }
.stats-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
}
.stats-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}
.stats-info { width: 116px; font-size: 10px; color: var(--hint); text-align: right; flex-shrink: 0; white-space: nowrap; }
.stats-note {
  margin-top: 10px;
  font-size: 10px;
  color: var(--hint);
  opacity: .75;
  line-height: 1.7;
  white-space: pre-line;
}

/* ---- 宝盒：底部频道（灰色小字横排） ---- */
.box-wrap {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.chan-foot {
  margin-top: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 20px 0 8px;
}
.chan-sep {
  font-size: 12px;
  color: var(--hint);
  opacity: .4;
}
.chan-foot-item {
  font-size: 12px;
  color: var(--hint);
  opacity: .72;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.chan-foot-item:active { opacity: 1; }

/* ---- 空状态 ---- */
.empty {
  text-align: center;
  color: var(--hint);
  font-size: 13px;
  line-height: 1.9;
  padding: 36px 0;
}

/* ---- 底部导航（回归上一版） ---- */
.tabbar {
  display: flex;
  border-top: 1px solid var(--bg-secondary);
  padding: 8px 0 14px;
  flex-shrink: 0;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--hint);
  font-size: 14px;
  padding: 8px 0;
  cursor: pointer;
  text-align: center;
}
.tab.active { color: var(--accent); font-weight: 600; }

/* ---- 弹窗 ---- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99;
}
.modal {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 18px;
  width: 82%;
  max-width: 320px;
  max-height: 78vh;
  overflow-y: auto;
}
.modal h3 { font-size: 15px; margin-bottom: 12px; }
.modal input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--bg-secondary);
  color: var(--text);
  font-size: 14px;
  padding: 9px 12px;
  border-radius: 10px;
  outline: none;
  margin-bottom: 12px;
}
.modal-pl {
  padding: 11px 12px;
  background: var(--bg);
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
}
.modal-pl .n { flex: 1; }
.modal-pl .c { font-size: 12px; color: var(--hint); }
.modal-pl:active { background: var(--bg-secondary); }
.modal-newbtn {
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  background: var(--bg);
  color: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.modal-actions button {
  border: none;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
}
.modal-actions .ok { background: var(--accent); color: var(--accent-text); }
.modal-actions .cancel { background: var(--bg); color: var(--hint); }
