/* 默认浅色，html[data-theme="dark"] 切到深色 */
:root {
  --bg: #f4f6fa;
  --bg-glow: #e4ebfb;
  --topbar: rgba(255, 255, 255, .86);
  --surface: #ffffff;
  --surface-2: #f3f5fa;
  --surface-3: #e8ebf3;
  --border: #dde2ec;
  --border-strong: #c7cede;
  --text: #1a1f2b;
  --muted: #6c7488;
  --accent: #5b6cff;
  --accent-2: #3d8bfd;
  --danger: #d93a4a;
  --ok: #16a34a;
  --shadow: 0 12px 30px rgba(22, 32, 60, .13);
  --radius: 12px;
}

html[data-theme="dark"] {
  --bg: #0e1016;
  --bg-glow: #1b1f34;
  --topbar: rgba(14, 16, 22, .84);
  --surface: #171a23;
  --surface-2: #1e2230;
  --surface-3: #262b3b;
  --border: #2b3141;
  --border-strong: #3a4257;
  --text: #e7eaf3;
  --muted: #8b93a9;
  --accent: #6d7cff;
  --accent-2: #4f9dff;
  --danger: #ef5f6b;
  --ok: #34d399;
  --shadow: 0 18px 40px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

/* 作者样式里的 display 会盖掉 hidden 属性，这里统一兜底 */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

/* 不显示网页滚动条（仍可滚动），内层列表自己给一条细的 */
html {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar { width: 0; height: 0; }

/* 不写 appearance:none 的话，Chrome 会用原生按钮外观盖掉自定义背景，
   按下时变成浅灰底 + 白字，整个按钮就看不见了 */
button {
  appearance: none;
  -webkit-appearance: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body {
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 15% -10%, var(--bg-glow) 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--text);
  font: 15px/1.55 "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  padding-bottom: 40px;
}

button, input, a { font: inherit; color: inherit; }

svg.icon, .icon-btn svg, .to-top svg, .search-icon, .brand-mark, .file-icon {
  width: 18px;
  height: 18px;
  flex: none;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 24px;
  background: var(--topbar);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-right: auto;
}

.brand-mark { width: 22px; height: 22px; color: var(--accent); }

.brand-name {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: .2px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s, color .18s;
}

.tab:hover { color: var(--text); }

.tab.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  transition: background .18s, color .18s;
}

.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* 浅色显示月亮（点了变深色），深色显示太阳 */
html[data-theme="light"] .icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: none; }

/* ---------- 页面 ---------- */
.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 24px;
}

.view { display: none; }
.view.is-active { display: block; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1 1 260px;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 11px 16px 11px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 108, 255, .16);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s, border-color .18s, opacity .18s;
}

.btn:hover:not(:disabled) { background: var(--surface-3); border-color: var(--border-strong); }

.btn:disabled { opacity: .5; cursor: default; }

.btn-primary {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.btn-primary:hover:not(:disabled),
.btn-primary:active:not(:disabled),
.btn-primary:focus:not(:disabled) {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  filter: brightness(1.08);
}

.btn-sm { padding: 7px 14px; font-size: 13px; }

/* 开关 */
.switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

/* 文件管理工具栏里把开关和刷新按钮推到右边 */
#view-files .switch { margin-left: auto; }

.switch input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.switch-track {
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  transition: background .18s, border-color .18s;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .18s;
}

.switch input:checked + .switch-track {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

.switch input:checked + .switch-track::after { transform: translateX(16px); }

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.link-btn {
  border: 0;
  background: none;
  color: var(--muted);
  padding: 0;
  cursor: pointer;
  font-size: 12px;
}

.link-btn:hover { color: var(--text); text-decoration: underline; }

.status {
  margin: 8px 2px;
  color: var(--muted);
  font-size: 13px;
}

/* 没有内容时不占位置 */
.status:empty { display: none; }

.status.is-error { color: var(--danger); }

.sentinel {
  padding: 18px 2px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- 歌曲列表 ---------- */
.song-list, .file-list, .task-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.song-list, .file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* 和卡片之间的间距保持一致（状态文字为空时不占位，直接就是这段距离） */
  margin-top: 8px;
}

.song {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .18s, box-shadow .18s;
}

.song:hover {
  border-color: var(--border-strong);
  box-shadow: 0 4px 16px rgba(22, 32, 60, .07);
}

.song-index {
  width: 22px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  flex: none;
}

.song-cover-link {
  flex: none;
  display: block;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-3);
}

.song-cover-link.is-default { cursor: default; }

.song-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .2s;
}

.song-cover-link:not(.is-default):hover .song-cover { transform: scale(1.08); }

.song-main { flex: 1 1 200px; min-width: 0; }

/* 点歌名 = 复制歌词 */
.song-name {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song-name:hover:not(:disabled) { color: var(--accent); text-decoration: underline; }

.song-name:disabled { cursor: default; opacity: .6; }

/* 点歌手/专辑 = 打开歌词接口 */
.song-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song-meta:hover { color: var(--accent); text-decoration: underline; }

.song-brs {
  flex: 0 1 700px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 4px;
}

.br-btn {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  padding: 7px 6px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 12.5px;
  white-space: nowrap;
  transition: border-color .18s, background .18s, opacity .18s;
}

.br-btn:hover:not(:disabled) { background: var(--surface-3); border-color: var(--accent); }

.br-btn:disabled { cursor: default; }

.br-btn.is-queued { opacity: .55; }

.br-fmt { font-weight: 600; text-transform: uppercase; }

.br-size { color: var(--muted); font-size: 11.5px; }

/* ---------- 文件列表 ---------- */
.file {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.file-icon { color: var(--accent); }

.file-main { flex: 1 1 auto; min-width: 0; }

.file-name {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.file-actions { display: flex; gap: 8px; flex: none; }

.btn-danger { color: var(--danger); }

.btn-danger:hover:not(:disabled) { background: var(--surface-3); border-color: var(--danger); }

/* ---------- 右下角：任务面板 + 回到顶部 ---------- */
.dock {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

.dock > * { pointer-events: auto; }

.tasks {
  width: min(340px, calc(100vw - 48px));
  max-height: 46vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tasks-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.tasks-title { font-size: 13px; font-weight: 600; }

.task-list {
  overflow-y: auto;
  scrollbar-width: thin;
}

.task-list::-webkit-scrollbar { width: 6px; }

.task-list::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

.task {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.task:last-child { border-bottom: 0; }

.task-main { flex: 1 1 auto; min-width: 0; }

.task-name {
  margin: 0;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-bar {
  height: 3px;
  margin-top: 6px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}

.task-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .3s;
}

.task-status {
  flex: none;
  font-size: 12px;
  color: var(--muted);
}

.task-status.is-done { color: var(--ok); }
.task-status.is-failed { color: var(--danger); }

.to-top {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: color .18s, transform .18s;
}

.to-top:hover { color: var(--accent); transform: translateY(-2px); }

/* ---------- 提示 ---------- */
.toasts {
  position: fixed;
  top: 74px;
  right: 24px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: 320px;
  animation: toast-in .2s ease-out;
  transition: opacity .3s, transform .3s;
}

.toast.is-out { opacity: 0; transform: translateX(12px); }

.toast-ok { border-color: var(--ok); }
.toast-error { border-color: var(--danger); }
.toast-warn { border-color: #e0a020; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .page { padding: 16px; }
  .song-index { display: none; }
  .dock { right: 16px; bottom: 16px; }
  .toasts { right: 16px; left: 16px; }
  .toast { max-width: none; }
}
