/* 下载中心（download-center.mjs）与专辑 / 歌单页的下载对话框（views/download-dialog.mjs）。
   下载中心与播放条同样是悬浮卡片，叠在播放条上方（右对齐）；展开后在其上方列出各下载任务 */
.dl-dock {
  --dl-bottom: max(14px, env(safe-area-inset-bottom));
  position: fixed; left: calc(50% + var(--nav-w) / 2); bottom: var(--dl-bottom); z-index: 10;
  width: min(1040px, calc(100% - var(--nav-w) - 24px)); transform: translateX(-50%); pointer-events: none;
}
.dl-dock[hidden] { display: none; }
body.has-player .dl-dock { bottom: calc(var(--dl-bottom) + var(--player-height, 72px) + 8px); }
body.lyrics-open .dl-dock { display: none; }
body.has-downloads { padding-bottom: calc(var(--downloads-height, 52px) + 32px + env(safe-area-inset-bottom)); }
body.has-downloads.has-player { padding-bottom: calc(var(--player-height, 110px) + var(--downloads-height, 52px) + 40px + env(safe-area-inset-bottom)); }
.dlc-bar {
  position: relative; display: flex; align-items: center; gap: 4px; margin-left: auto; width: min(420px, 100%); overflow: hidden;
  border: 1px solid var(--line); border-radius: 14px; pointer-events: auto;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(18px); box-shadow: var(--shadow);
}
.dlc-bar-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 8px 6px 9px 10px;
  border: 0; background: none; color: var(--text); text-align: left;
}
.dl-ring { position: relative; flex: 0 0 34px; width: 34px; height: 34px; }
.dl-ring > svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.dl-ring circle { fill: none; stroke-width: 3; }
.dl-ring-track { stroke: var(--surface-3); }
.dl-ring-fill { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset .3s ease; }
.dl-dock:not(.is-busy) .dl-ring-fill { stroke: var(--ok); }
.dl-dock.has-failed .dl-ring-fill { stroke: var(--warn); }
.dl-ring-icon { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text); }
.dl-ring-icon svg { width: 16px; height: 16px; }
.dl-dock.is-busy .dl-ring-icon svg { animation: dl-bob 1.6s ease-in-out infinite; }
@keyframes dl-bob { 50% { transform: translateY(2px); } }
.dlc-bar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dlc-bar-title, .dlc-bar-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlc-bar-title { font-size: 13px; font-weight: 700; }
.dlc-bar-sub { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.dlc-bar-chevron { flex: 0 0 18px; width: 18px; height: 18px; color: var(--muted); transition: transform .15s ease; }
.dl-dock.is-open .dlc-bar-chevron { transform: rotate(180deg); }
.dlc-bar-track { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; }
.dlc-bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }
.dl-dock:not(.is-busy) .dlc-bar-fill { background: var(--ok); }
.dl-dock.has-failed .dlc-bar-fill { background: var(--warn); }
.dl-icon-btn {
  flex: 0 0 auto; width: 32px; height: 32px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 8px; background: none; color: var(--muted);
}
.dl-icon-btn:hover { color: var(--text); background: var(--surface-3); }
.dl-icon-btn svg { width: 17px; height: 17px; }
.dl-icon-btn[hidden] { display: none; }
.dlc-bar-hide { margin-right: 6px; }

.dl-panel {
  position: absolute; right: 0; bottom: calc(100% + 8px); width: min(480px, 100%); max-height: min(640px, 70dvh);
  display: flex; flex-direction: column; pointer-events: auto;
  border: 1px solid var(--line); border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 95%, transparent); backdrop-filter: blur(24px); box-shadow: var(--shadow);
  animation: queue-in .18s ease-out;
}
.dl-panel[hidden] { display: none; }
.dl-panel-head { display: flex; align-items: center; gap: 4px; padding: 16px 12px 8px 18px; }
.dl-panel-title { flex: 1; min-width: 0; margin: 0; font-size: 17px; font-weight: 700; }
.dl-settings, .dl-clear {
  min-height: 30px; padding: 0 8px; display: inline-flex; align-items: center; border: 0; border-radius: 7px;
  background: none; color: var(--accent); font-size: 14px; text-decoration: none;
}
.dl-settings:hover, .dl-clear:hover { background: var(--accent-soft); }
.dl-clear:disabled { color: var(--faint); background: none; cursor: default; }
.dl-empty { margin: 0; padding: 20px 24px 28px; color: var(--muted); font-size: 13px; text-align: center; }
.dl-empty[hidden] { display: none; }
.dl-jobs { margin: 0; padding: 0 8px 8px; list-style: none; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.dl-job { position: relative; padding: 8px 6px 10px; }
.dl-job + .dl-job { border-top: 1px solid var(--line); }
.dl-job-head { display: flex; align-items: center; gap: 8px; }
.dl-job-toggle { width: 24px; height: 40px; margin-right: -4px; }
.dl-job-toggle svg { width: 13px; height: 13px; transition: transform .15s ease; }
.dl-job.is-expanded .dl-job-toggle svg { transform: rotate(90deg); }
.dl-job-art { flex: 0 0 44px; width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--surface-3); }
.dl-job-art[hidden] { display: block; visibility: hidden; }
.dl-job-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.dl-job-title { overflow: hidden; color: var(--text); font-size: 14px; font-weight: 600; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.dl-job-title:hover { color: var(--accent); text-decoration: underline; }
.dl-job-sub { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
/* 状态行可换行，较长的说明（部分失败、保存位置等）也能显示完整 */
.dl-job-status { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dl-job.is-error .dl-job-status, .dl-job.is-partial .dl-job-status { color: var(--warn); }
.dl-job.is-done .dl-job-status { color: var(--ok); }
/* 下载时检测 ALAC 的总结：可换行，窄屏也显示完整 */
.dl-job-check { color: var(--ok); font-size: 12px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dl-job-check.is-bad { color: var(--error); }
.dl-job-check.is-failed { color: var(--warn); }
.dl-job-check[hidden] { display: none; }
.dl-job-actions { display: flex; align-items: center; }
.dl-job-progress { height: 3px; margin: 8px 6px 0 32px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.dl-job-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }
.dl-job.is-partial .dl-job-progress i, .dl-job.is-error .dl-job-progress i { background: var(--warn); }
.dl-job.is-done .dl-job-progress, .dl-job.is-cancelled .dl-job-progress { display: none; }
.dl-tasks { margin: 8px 0 0 26px; padding: 0; list-style: none; }
.dl-tasks[hidden] { display: none; }
.dl-task { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 4px 4px 8px; border-radius: 6px; }
.dl-task:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }
.dl-task-index { flex: 0 0 20px; color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.dl-task-main { flex: 1; min-width: 0; }
.dl-task-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.dl-task-name { flex: 1 1 auto; min-width: 0; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.dl-task-quality { flex: 0 1 auto; min-width: 0; overflow: hidden; color: var(--faint); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.dl-task-check { flex: 0 0 auto; padding: 0 5px; border-radius: 4px; background: var(--ok-soft); color: var(--ok); font-size: 11px; line-height: 16px; white-space: nowrap; }
.dl-task-check.is-bad { background: var(--error-soft); color: var(--error); font-weight: 600; }
.dl-task-check.is-failed { background: var(--warn-soft); color: var(--warn); }
.dl-task-check[hidden] { display: none; }
.dl-task-status { display: block; overflow: hidden; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.dl-task.is-error .dl-task-status { color: var(--error); }
.dl-task.is-done .dl-task-status { color: var(--ok); }
.dl-task.is-cancelled .dl-task-name, .dl-task.is-skipped .dl-task-name { color: var(--muted); }
.dl-task-progress { height: 2px; margin-top: 3px; border-radius: 1px; background: var(--surface-3); overflow: hidden; }
.dl-task-progress i { display: block; height: 100%; width: 0; background: var(--accent); }
.dl-task:not(.is-downloading):not(.is-tagging):not(.is-saving):not(.is-resolving) .dl-task-progress { display: none; }
.dl-task-actions { display: flex; }
.dl-task-actions .dl-icon-btn { width: 28px; height: 28px; }
@media (max-width: 760px) {
  .dl-dock { --dl-bottom: max(8px, env(safe-area-inset-bottom)); }
}
@media (max-width: 483px) {
  .dl-dock { width: calc(100% - 16px); }
  .dlc-bar { width: 100%; }
  .dl-panel { width: 100%; max-height: min(640px, 72dvh); }
  .dl-job-actions .dl-icon-btn { width: 40px; height: 40px; }
  /* 窄屏：歌名独占第一行，音质与检测结论换到第二行 */
  .dl-tasks { margin-left: 0; }
  .dl-task-line { flex-wrap: wrap; row-gap: 2px; }
  .dl-task-name { flex-basis: 100%; }
}

/* ---------- 下载对话框 ---------- */
.dl-dialog {
  width: min(560px, calc(100vw - 24px)); max-height: min(720px, calc(100dvh - 40px)); padding: 0;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.dl-dialog[open] { display: flex; flex-direction: column; }
.dl-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dl-dialog-head { display: flex; align-items: center; gap: 12px; padding: 18px 18px 12px; }
.dl-dialog-art { flex: 0 0 56px; width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--surface-3); }
.dl-dialog-titles { flex: 1; min-width: 0; }
.dl-dialog-title { margin: 0; overflow: hidden; font-size: 17px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.dl-dialog-sub { margin: 2px 0 0; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.dl-dialog-opts { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px 14px; padding: 4px 18px 12px; font-size: 13px; }
.dl-dialog-opts > span:nth-child(odd) { color: var(--muted); }
.dl-dialog-opts select { justify-self: start; max-width: 100%; height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--text); font: inherit; }
.dl-dialog-opts a { color: var(--accent); }
.dl-dialog-tools { display: flex; align-items: center; gap: 8px; padding: 8px 18px; border-top: 1px solid var(--line); font-size: 13px; }
.dl-dialog-count { flex: 1; color: var(--muted); }
.dl-dialog-tools button { min-height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: none; color: var(--text); font-size: 12px; }
.dl-dialog-list { flex: 1; min-height: 80px; margin: 0; padding: 4px 10px; overflow-y: auto; list-style: none; border-top: 1px solid var(--line); }
.dl-dialog-item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 8px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.dl-dialog-item:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }
.dl-dialog-item input { flex: 0 0 auto; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.dl-dialog-item.is-disabled { color: var(--faint); cursor: default; }
.dl-dialog-num { flex: 0 0 22px; color: var(--faint); font-variant-numeric: tabular-nums; text-align: right; }
.dl-dialog-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-dialog-artist { color: var(--muted); }
.dl-dialog-mv { flex: 0 0 auto; padding: 0 4px; border: 1px solid currentColor; border-radius: 3px; color: var(--muted); font-size: 10px; font-weight: 600; line-height: 14px; }
.dl-dialog-time { flex: 0 0 auto; color: var(--faint); font-variant-numeric: tabular-nums; }
.dl-dialog-disc { padding: 10px 8px 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
.dl-dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.dl-dialog-foot button { min-height: 36px; padding: 0 18px; border-radius: 10px; font-size: 14px; font-weight: 600; }
.dl-dialog-cancel { border: 1px solid var(--line-strong); background: none; color: var(--text); }
.dl-dialog-start { border: 0; background: var(--accent); color: #fff; }
.dl-dialog-start:hover { background: var(--accent-hover); }
.dl-dialog-start:disabled { opacity: .5; cursor: default; }

/* ---------- ALAC 检测对话框（沿用下载对话框的外框，见 views/alac-check-dialog.mjs） ---------- */
.ac-dialog { width: min(720px, calc(100vw - 24px)); }
.ac-head-meta { margin: 3px 0 0; color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ac-options { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; padding: 0 18px 12px; }
.ac-option { display: flex; align-items: center; gap: 7px; font-size: 13px; white-space: nowrap; cursor: pointer; }
.ac-option input { flex: 0 0 auto; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.ac-help-btn { margin-left: auto; padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; }
.ac-help-btn[aria-expanded="true"] { color: var(--text); }
.ac-help { display: grid; gap: 4px; margin: 0 18px 12px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 12px; line-height: 1.5; }
.ac-help p { margin: 0; }
.ac-help[hidden] { display: none; }
.dl-dialog-count.is-bad { color: var(--error); }
.ac-list { padding: 4px 6px; }
.ac-row + .ac-row { border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.ac-line { display: flex; align-items: center; gap: 2px; }
.ac-line > input { flex: 0 0 auto; width: 16px; height: 16px; margin: 0 0 0 8px; accent-color: var(--accent); }
.ac-item {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 4px 8px; border: 0; border-radius: 6px;
  background: none; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.ac-item:hover:not(:disabled) { background: color-mix(in srgb, var(--text) 4%, transparent); }
.ac-item:disabled { cursor: default; }
.ac-item[aria-expanded="true"] .dl-dialog-name { font-weight: 600; }
.ac-tail { display: contents; }
.ac-format { flex: 0 0 auto; color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.ac-status { flex: 0 0 auto; min-width: 72px; color: var(--muted); font-size: 12px; text-align: right; }
.ac-status.is-ok { color: var(--ok); }
.ac-status.is-bad { color: var(--error); font-weight: 600; }
.ac-flag { flex: 0 0 auto; padding: 0 6px; border-radius: 4px; background: var(--warn-soft); color: var(--warn); font-size: 11px; line-height: 18px; }
.ac-flag.is-info { background: var(--info-soft); color: var(--info); }
.ac-detail { display: grid; gap: 8px; padding: 0 8px 12px 66px; font-size: 12px; }
.ac-dialog.is-single .ac-detail { padding-left: 40px; }
.ac-ids { color: var(--faint); font-variant-numeric: tabular-nums; }
/* 每条流一张卡片 */
.ac-stream { display: grid; gap: 6px; padding: 8px 10px; border: 1px solid color-mix(in srgb, var(--line) 80%, transparent); border-radius: 8px; }
.ac-stream-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.ac-stream-src { padding: 0 6px; border-radius: 4px; background: var(--surface-3); color: var(--muted); font-size: 11px; line-height: 18px; }
.ac-stream-format { margin-left: 2px; font-weight: 600; }
.ac-stream-head .ac-status { min-width: 0; margin-left: auto; }
.ac-detail p { margin: 0; }
.ac-meta { color: var(--muted); }
.ac-soft { color: var(--faint); }
.ac-error { color: var(--error); overflow-wrap: anywhere; }
.ac-frames { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ac-frames th { padding: 4px 8px 4px 0; color: var(--faint); font-weight: 500; text-align: left; }
.ac-frames td { padding: 3px 8px 3px 0; border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.ac-frames tr.is-bad td:nth-child(3) { color: var(--error); }
.ac-hex { font-family: var(--mono); white-space: nowrap; }
.ac-analysis { display: grid; gap: 3px; margin-top: 4px; }
.ac-analysis-title { color: var(--faint); }
.ac-analysis .is-warn { color: var(--warn); }
.ac-spectrum { margin-top: 6px; }
.ac-spec-plot { position: relative; height: 96px; border-bottom: 1px solid var(--line); }
.ac-spec-plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.ac-spec-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.ac-spec-area { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: none; }
.ac-spec-floor { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 3 3; }
.ac-spec-limit { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 3; }
.ac-spec-limit.is-warn { stroke: var(--warn); }
.ac-spec-cursor { stroke: var(--text); stroke-width: 1; opacity: .4; }
.ac-spec-floor-label, .ac-spec-limit-label {
  position: absolute; color: var(--faint); font-size: 10px; line-height: 1; white-space: nowrap; pointer-events: none;
}
.ac-spec-floor-label { right: 0; transform: translateY(-120%); }
.ac-spec-limit-label { top: 0; padding-left: 4px; color: var(--muted); }
.ac-spec-tip {
  position: absolute; top: 14px; padding: 2px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2);
  color: var(--text); font-size: 11px; white-space: nowrap; pointer-events: none; transform: translateX(8px);
}
.ac-spec-tip.is-right { transform: translateX(calc(-100% - 8px)); }
.ac-spec-axis { display: flex; justify-content: space-between; padding-top: 3px; color: var(--faint); font-size: 10px; font-variant-numeric: tabular-nums; }
@media (max-width: 483px) {
  .ac-dialog .dl-dialog-foot { gap: 8px; }
  .ac-dialog .dl-dialog-foot button { flex: 1 1 auto; padding: 0 10px; font-size: 13px; white-space: nowrap; }
  .ac-detail, .ac-dialog.is-single .ac-detail { padding-left: 8px; }
  /* 窄屏：歌名独占第一行，标记与结论换到第二行 */
  .ac-item { flex-wrap: wrap; row-gap: 4px; }
  .ac-item .dl-dialog-name { flex: 1 1 calc(100% - 40px); }
  .ac-tail { display: flex; flex: 1 1 100%; align-items: center; gap: 8px; min-width: 0; }
  .ac-tail:not(:has(.ac-flag, .ac-format:not(:empty), .ac-status:not(:empty))) { display: none; }
  .ac-status { min-width: 0; margin-left: auto; white-space: nowrap; }
  .ac-flag { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ac-line { align-items: flex-start; }
  .ac-line > input { margin-top: 12px; }
}
