/* MLP Music — 与 PonyChat 主站设计语言统一 */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-deep: #0f172a;
  --bg-elevated: #1e293b;
  --surface: rgba(30, 41, 59, 0.72);
  --surface-hover: rgba(51, 65, 85, 0.88);
  --stroke: rgba(148, 163, 184, 0.12);
  --stroke-strong: rgba(167, 139, 250, 0.4);
  --text: #e0f2fe;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-from: #a78bfa;
  --accent-to: #22d3ee;
  --accent-mid: #c4b5fd;
  --brand-gradient: linear-gradient(135deg, #a78bfa 0%, #22d3ee 100%);
  --shadow-glow: 0 0 80px rgba(167, 139, 250, 0.2);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-display: "Outfit", system-ui, sans-serif;
  --font-body: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --player-h: 80px;
  --header-h: 58px;
  --sidebar-w: 220px;
}

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── 背景层 ── */
.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(167,139,250,.18), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(34,211,238,.10), transparent),
    radial-gradient(ellipse 50% 35% at 0% 80%, rgba(167,139,250,.08), transparent);
}


/* ── 顶栏 ── */
.top {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px 0 12px;
  background: rgba(15,23,42,.88);
  border-bottom: 1px solid var(--stroke);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-img {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: block;
  object-fit: contain;
  box-shadow: 0 6px 24px rgba(167,139,250,.4);
  animation: float 5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  .logo-img { animation: none; }
}

.brand-text {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.03em;
  color: #e0f2fe;
}

.tabs {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.tab {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.875rem;
  font-family: var(--font-body);
  font-weight: 500;
  min-height: 36px;
  display: flex; align-items: center;
  transition: background .15s, color .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}

.tab.active {
  background: rgba(167,139,250,.15);
  border-color: var(--stroke-strong);
  color: var(--accent-mid);
}

.tab:not(.active):hover { background: rgba(148,163,184,.08); color: var(--text); }

.search-wrap { flex: 1; min-width: 0; }

.search {
  width: 100%;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(15,23,42,.6);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color .2s, background .2s;
}
.search::placeholder { color: var(--text-dim); }
.search:focus { border-color: var(--stroke-strong); background: rgba(30,41,59,.7); }

/* 移动端汉堡按钮（显示/隐藏侧边栏） */
.btn-menu {
  display: none;
  width: 40px; height: 40px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.05);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  align-items: center; justify-content: center;
  font-size: 18px;
  -webkit-tap-highlight-color: transparent;
}

/* 移动端搜索图标按钮（桌面隐藏） */
.btn-search-icon {
  display: none;
  width: 40px; height: 40px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.05);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

/* ── 整体布局 ── */
.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100dvh - var(--header-h));
  margin-top: var(--header-h);
  padding-bottom: var(--player-h);
}

/* ── 侧边栏 ── */
.sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100dvh - var(--header-h) - var(--player-h));
  overflow-y: auto;
  padding: 16px 12px;
  border-right: 1px solid var(--stroke);
  background: rgba(15,23,42,.5);
  scrollbar-width: thin;
  scrollbar-color: rgba(167,139,250,.25) transparent;
}

.sidebar-title {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 4px 6px 10px;
}

.album-filter { list-style: none; }

.album-filter li { margin-bottom: 2px; }

.album-filter button {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .84rem;
  font-family: var(--font-body);
  line-height: 1.35;
  min-height: 36px;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}

.album-filter button:hover,
.album-filter button.active {
  background: rgba(167,139,250,.12);
  color: var(--accent-mid);
}

.album-filter .badge {
  float: right;
  font-size: .7rem;
  color: var(--text-dim);
  background: rgba(148,163,184,.1);
  border-radius: 999px;
  padding: 1px 7px;
  line-height: 1.5;
  margin-top: 1px;
}

.album-filter li.extras-item {
  margin-bottom: 0;
}

.album-filter li.extras-item button {
  padding-left: 18px;
  font-size: .78rem;
  color: var(--text-dim);
  min-height: 30px;
}

.album-filter li.extras-item button::before {
  content: "↳ ";
  color: var(--text-dim);
  font-size: .72rem;
}

.album-filter li.extras-item button:hover,
.album-filter li.extras-item button.active {
  color: var(--text-muted);
  background: rgba(148,163,184,.08);
}

/* ── 主内容 ── */
.main {
  min-width: 0;
  padding: 20px;
}

.panel { display: none; }
.panel.active { display: block; }

/* ── 专辑网格 ── */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.album-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: linear-gradient(145deg, rgba(30,41,59,.85), rgba(15,23,42,.65));
  border: 1px solid var(--stroke);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  -webkit-tap-highlight-color: transparent;
}

.album-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(167,139,250,.2);
  border-color: var(--stroke-strong);
}

.album-card.extras-card {
  opacity: 0.75;
  border-style: dashed;
}

.album-card.extras-card:hover {
  opacity: 1;
}

.album-card.extras-card .album-card-title {
  font-size: .82rem;
}

.album-card.playing {
  border-color: var(--stroke-strong);
  box-shadow: 0 0 0 1px rgba(167,139,250,.3), 0 8px 24px rgba(167,139,250,.15);
}

.album-card.playing .album-card-meta::before {
  content: "▶ 播放中  ";
  color: var(--accent-from);
  font-weight: 600;
}

.album-cover {
  aspect-ratio: 1;
  background: linear-gradient(145deg, rgba(167,139,250,.25), rgba(34,211,238,.15));
  background-size: cover;
  background-position: center;
}

.album-card-body { padding: 10px 12px 12px; }

.album-card-title {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  margin: 0 0 4px;
}

.album-card-meta { font-size: .76rem; color: var(--text-dim); }

/* ── 曲目面板 ── */
.track-panel.hidden { display: none; }

.back {
  margin-bottom: 14px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.05);
  color: var(--text-muted);
  cursor: pointer;
  font-size: .875rem;
  font-family: var(--font-body);
  min-height: 40px;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.back:hover { background: rgba(255,255,255,.08); color: var(--text); }

#trackPanelTitle {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
  margin-bottom: 14px;
}

.track-list { list-style: none; }

.track-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--stroke);
  transition: background .12s;
}

.track-list li:hover { background: rgba(148,163,184,.06); }

.track-list li.playing {
  background: rgba(167,139,250,.1);
  border-left: 2px solid var(--accent-from);
  padding-left: 8px;
}

.track-list li.playing .track-name {
  color: var(--accent-mid);
  font-weight: 600;
}

.track-list li.playing .track-num {
  color: var(--accent-from);
}

.track-num {
  flex-shrink: 0;
  width: 2rem;
  text-align: right;
  font-size: .8rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.track-name { flex: 1; min-width: 0; font-size: .9rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.track-actions {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
}

.track-actions button,
.track-actions a {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--stroke-strong);
  background: rgba(167,139,250,.1);
  color: var(--accent-mid);
  cursor: pointer;
  font-size: .78rem;
  font-family: var(--font-body);
  text-decoration: none;
  min-height: 32px;
  display: flex; align-items: center;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.track-actions button:hover,
.track-actions a:hover { background: rgba(167,139,250,.2); }

/* ── 乐谱面板 ── */
.scores-split {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  min-height: 60vh;
}

.score-list {
  list-style: none;
  overflow-y: auto;
  max-height: calc(100dvh - var(--header-h) - var(--player-h) - 48px);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(30,41,59,.85), rgba(15,23,42,.65));
  scrollbar-width: thin;
  scrollbar-color: rgba(167,139,250,.2) transparent;
}

.score-list li {
  padding: 10px 14px;
  border-bottom: 1px solid var(--stroke);
  cursor: pointer;
  font-size: .84rem;
  color: var(--text-muted);
  line-height: 1.35;
  min-height: 44px;
  display: flex; align-items: center;
  transition: background .12s, color .12s;
  -webkit-tap-highlight-color: transparent;
}
.score-list li:hover { background: rgba(167,139,250,.08); color: var(--text); }
.score-list li.active { background: rgba(167,139,250,.14); color: var(--accent-mid); }

.pdf-wrap {
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(30,41,59,.85), rgba(15,23,42,.65));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.pdf-hint {
  padding: 24px;
  font-size: .84rem;
  color: var(--text-dim);
  text-align: center;
}

.pdf-frame {
  flex: 1;
  width: 100%;
  min-height: calc(100dvh - var(--header-h) - var(--player-h) - 48px);
  border: none;
  background: #fff;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── 播放器 ── */
.player {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--player-h);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  padding-bottom: max(0px, env(safe-area-inset-bottom, 0px));
  background: rgba(15,23,42,.92);
  border-top: 1px solid var(--stroke);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.player-art {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: var(--brand-gradient);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.player-meta {
  min-width: 0;
  flex: 0 1 180px;
}

.player-title {
  font-weight: 600;
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.player-sub {
  font-size: .75rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.06);
  color: var(--text);
  cursor: pointer;
  font-size: .95rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.btn-icon:hover { background: rgba(255,255,255,.1); border-color: rgba(148,163,184,.3); }

.btn-icon.primary {
  background: var(--brand-gradient);
  border: none;
  width: 42px; height: 42px;
  box-shadow: 0 4px 16px rgba(167,139,250,.35);
}

.player-progress {
  flex: 1;
  min-width: 80px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.player-progress input[type="range"],
.player-vol input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent-from) 0%,
    var(--accent-from) var(--fill, 0%),
    rgba(148,163,184,.18) var(--fill, 0%),
    rgba(148,163,184,.18) 100%
  );
  outline: none;
  cursor: pointer;
}

.player-progress input[type="range"]::-webkit-slider-thumb,
.player-vol input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--brand-gradient);
  box-shadow: 0 0 6px rgba(167,139,250,.5);
  cursor: pointer;
}

.time { font-size: .72rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.player-vol {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex: 0 0 110px;
}

.vol-icon { font-size: .85rem; color: var(--text-dim); }

.btn-dl {
  flex-shrink: 0;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(167,139,250,.15);
  border: 1px solid var(--stroke-strong);
  color: var(--accent-mid);
  text-decoration: none;
  font-size: .78rem;
  font-family: var(--font-body);
  font-weight: 500;
  white-space: nowrap;
  min-height: 34px;
  display: flex; align-items: center;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn-dl:hover { background: rgba(167,139,250,.25); }

.hidden { display: none !important; }

/* ── 遮罩层（移动端侧边栏） ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: var(--header-h);
  bottom: var(--player-h);
  /* left 在 open 时由媒体查询设置，只覆盖主内容区 */
  right: 0;
  background: rgba(8, 12, 24, 0.65);
  z-index: 25;
  /* 不用 backdrop-filter，避免模糊到侧边栏内容 */
}

/* ──────── 响应式断点 ──────── */

/* 平板（1024px 以下）：收窄侧栏 */
@media (max-width: 1024px) {
  :root { --sidebar-w: 180px; }
  .brand-text { display: none; }
  .player-vol { flex: 0 0 90px; }
}

/* ────── 手机 / 小平板（≤768px）────── */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 240px;
    --player-h: 64px;
  }

  /* ── 顶栏 ── */
  .top { gap: 8px; padding: 0 10px 0 8px; }
  .btn-menu { display: flex; }
  .brand-text { display: block; }

  /* 搜索框换为图标，图标展开后再显示输入框 */
  .search-wrap { display: none; }
  .btn-search-icon { display: flex; }

  /* 搜索展开态：顶栏加 search-active 类后显示搜索框、隐藏图标 */
  .top.search-active .search-wrap {
    display: flex;
    flex: 1;
    min-width: 0;
  }
  .top.search-active .btn-search-icon { display: none; }
  .top.search-active .tabs { display: none; }

  /* ── 侧边栏抽屉 ── */
  .shell { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: var(--player-h);
    width: var(--sidebar-w);
    z-index: 28;
    transform: translateX(-100%);
    transition: transform .25s ease;
    height: auto;
    background: rgba(13,19,36,.98);
    border-right: 1px solid var(--stroke-strong);
    backdrop-filter: none;
  }

  .sidebar.open { transform: translateX(0); }

  /* 遮罩只盖主内容（侧边栏右侧） */
  .sidebar-overlay.open {
    display: block;
    left: var(--sidebar-w);  /* 关键：从侧边栏右边缘开始 */
  }

  /* ── 乐谱面板 ── */
  .scores-split { grid-template-columns: 1fr; gap: 10px; }
  .score-list { max-height: 50vh; }
  .pdf-wrap { display: none; }  /* 手机不内嵌预览，点击新窗口 */

  /* 手机乐谱点击提示 */
  .score-list li::after {
    content: "↗";
    font-size: .75rem;
    color: var(--text-dim);
    margin-left: auto;
    padding-left: 8px;
    flex-shrink: 0;
  }

  /* ── 曲目列表：整行可点击，精简操作 ── */
  .track-list li { cursor: pointer; }
  .track-list li:active { background: rgba(167,139,250,.1); }

  /* 移动端隐藏"播放"文字按钮，只留下载图标 */
  .track-actions .btn-play-text { display: none; }
  .track-actions a {
    padding: 6px 10px;
    font-size: 0;        /* 隐藏文字 */
    min-width: 34px;
    justify-content: center;
  }
  .track-actions a::before { content: "↓"; font-size: .85rem; }

  /* ── 播放器：进度条全宽置顶 ── */
  .player {
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    padding: 0 0 max(0px, env(safe-area-inset-bottom, 0px)) 0;
  }

  /* 进度条移到最顶部，全宽，视觉高度 3px */
  .player-progress {
    order: -1;
    flex: 0 0 100%;
    width: 100%;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    gap: 0;
    padding: 0;
    height: 3px;
    overflow: visible;
    cursor: pointer;
  }

  .player-progress input[type="range"] {
    flex: 1;
    width: 100%;
    height: 3px;
    border-radius: 0;
    background: linear-gradient(
      to right,
      var(--accent-from) 0%,
      var(--accent-from) var(--fill, 0%),
      rgba(148,163,184,.2) var(--fill, 0%),
      rgba(148,163,184,.2) 100%
    );
  }

  /* 正常时不显示拖拽点，touch 时出现 */
  .player-progress input[type="range"]::-webkit-slider-thumb {
    width: 0;
    height: 0;
    background: var(--accent-from);
    box-shadow: none;
    transition: width .12s, height .12s;
  }
  .player-progress input[type="range"]:active::-webkit-slider-thumb {
    width: 14px;
    height: 14px;
    box-shadow: 0 0 8px rgba(167,139,250,.6);
  }

  .time { display: none; }

  /* 第二行：封面 + 曲名 + 控制按钮 */
  .player-art {
    order: 1;
    width: 40px; height: 40px;
    border-radius: 8px;
    flex-shrink: 0;
    margin: 0 8px 0 12px;
  }

  .player-meta {
    order: 2;
    flex: 1;
    min-width: 0;
  }

  .player-controls {
    order: 3;
    gap: 4px;
    margin-right: 10px;
    flex-shrink: 0;
  }

  .btn-icon { width: 36px; height: 36px; font-size: .9rem; }
  .btn-icon.primary { width: 44px; height: 44px; font-size: 1rem; }

  .player-vol { display: none; }
  .btn-dl { display: none; }

  /* ── 专辑网格 ── */
  .main { padding: 14px 12px; }
  .album-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
}

/* ── 极窄手机（≤380px） ── */
@media (max-width: 380px) {
  .logo-img { width: 26px; height: 26px; border-radius: 8px; }
  .album-grid { grid-template-columns: repeat(2, 1fr); }
}
