/* Material 3 (Google) 设计语言 */

:root {
  --primary: #0b57d0;
  --on-primary: #ffffff;
  --primary-container: #d3e3fd;
  --on-primary-container: #041e49;
  --primary-hover: #e8f0fe;

  --surface: #ffffff;
  --surface-page: #f8fafd;
  --surface-container: #f0f4f9;
  --surface-container-high: #e9eef6;

  --on-surface: #1f1f1f;
  --on-surface-variant: #444746;
  --on-surface-muted: #5f6368;

  --outline: #747775;
  --outline-variant: #c4c7c5;
  --divider: #e1e3e1;
  --hairline: #e3e6ea;

  --green: #146c2e;
  --green-bg: #e6f4ea;
  --amber: #b06000;
  --amber-bg: #fef7e0;
  --error: #b3261e;

  --state-hover: rgba(68, 71, 70, 0.08);
  --state-press: rgba(68, 71, 70, 0.12);

  --shadow-1: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
  --shadow-2: 0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);

  --font: "Google Sans", "Roboto", "Helvetica Neue", "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--on-surface);
  background: var(--surface-page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

input,
textarea {
  font-family: inherit;
}

::selection {
  background: #d3e3fd;
}

code {
  background: var(--surface-container);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  color: #b3261e;
  font-family: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------------- 顶栏 ---------------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px 0 24px;
  background: var(--surface-page);
  border-bottom: 1px solid var(--hairline);
}

.appbar-lead {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.app-logo {
  color: var(--primary);
  display: flex;
  align-items: center;
}

.app-title {
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--on-surface);
  white-space: nowrap;
}

.appbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------------- 按钮 ---------------- */

.btn-filled,
.btn-text {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 24px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  white-space: nowrap;
  transition: box-shadow 0.15s ease, background-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-filled {
  background: var(--primary);
  color: var(--on-primary);
}

.btn-text {
  background: transparent;
  color: var(--primary);
  padding: 0 12px;
}

.btn-text.has-icon {
  padding: 0 14px 0 12px;
}

.btn-text.has-icon svg {
  opacity: 0.9;
}

/* 状态层（Material state layer） */
.btn-filled::before,
.btn-text::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: currentColor;
  opacity: 0;
  transition: opacity 0.12s ease;
  pointer-events: none;
}

.btn-filled:hover::before {
  opacity: 0.08;
}
.btn-filled:active::before {
  opacity: 0.12;
}
.btn-text:hover::before {
  opacity: 0.08;
}
.btn-text:active::before {
  opacity: 0.12;
}
.btn-filled:hover {
  box-shadow: var(--shadow-1);
}

.btn-filled:disabled,
.btn-text:disabled {
  opacity: 0.38;
  cursor: default;
  box-shadow: none;
}
.btn-filled:disabled::before,
.btn-text:disabled::before {
  opacity: 0;
}

.btn-filled:focus-visible,
.btn-text:focus-visible,
.chip:focus-visible,
.icon-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* 文字链接（示例歌单） */
.link-btn {
  color: var(--primary);
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color 0.12s;
}
.link-btn:hover {
  background: var(--primary-hover);
}

/* ---------------- 主体 ---------------- */

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px 56px;
}

/* 搜索 */
.search-wrap {
  max-width: 760px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 8px 0 18px;
  background: var(--surface-container-high);
  border-radius: 28px;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.search-field:focus-within {
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.search-lead {
  color: var(--on-surface-variant);
  flex: none;
}

.search-field input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: var(--on-surface);
}

.search-field input::placeholder {
  color: var(--on-surface-muted);
}

.sample-row {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 10px;
  padding-left: 10px;
}

.sample-label {
  font-size: 13px;
  color: var(--on-surface-muted);
  margin-right: 6px;
}

/* 音质筛选 */
.filter-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.filter-label {
  font-size: 13px;
  color: var(--on-surface-variant);
  margin-right: 2px;
}

.filter-divider {
  width: 1px;
  height: 20px;
  background: var(--outline-variant);
  margin: 0 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--outline-variant);
  background: transparent;
  font-size: 13px;
  color: var(--on-surface-variant);
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.chip:hover {
  background: var(--state-hover);
}

.chip.active,
.chip.on {
  background: var(--primary-container);
  border-color: transparent;
  color: var(--on-primary-container);
  font-weight: 500;
}

.chip.active::before,
.chip.on::before {
  content: "";
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E")
    center / 16px 16px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E")
    center / 16px 16px no-repeat;
  flex: none;
}

.account-state {
  font-size: 12px;
  color: var(--on-surface-muted);
  background: var(--surface-container);
  padding: 4px 10px;
  border-radius: 8px;
  margin-left: 4px;
}

.account-state.on {
  color: var(--green);
  background: var(--green-bg);
}

/* ---------------- 歌单卡片 ---------------- */

.card {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  overflow: hidden;
}

.pl-head {
  display: flex;
  gap: 20px;
  padding: 24px;
  border-bottom: 1px solid var(--divider);
}

.pl-cover {
  width: 96px;
  height: 96px;
  flex: none;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-container);
}

.pl-info {
  flex: 1;
  min-width: 0;
}

.pl-info h2 {
  margin: 2px 0 6px;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--on-surface);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pl-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
  color: var(--on-surface-variant);
}

.dot {
  color: #9aa0a6;
}

.pl-desc {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--on-surface-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pl-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.pl-tags span {
  font-size: 12px;
  color: var(--primary);
  background: var(--primary-hover);
  padding: 2px 8px;
  border-radius: 4px;
}

/* 工具栏 */
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
  position: sticky;
  top: 64px;
  z-index: 20;
}

.toolbar .btn-text {
  font-size: 13.5px;
  height: 36px;
  padding: 0 10px;
}

.toolbar .btn-text.has-icon {
  padding: 0 12px 0 10px;
}

.toolbar .btn-filled {
  height: 36px;
  padding: 0 20px;
  font-size: 13.5px;
  margin-left: 6px;
}

.spacer {
  flex: 1;
}

.check {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px 0 8px;
  border-radius: 18px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--on-surface-variant);
  user-select: none;
  transition: background-color 0.12s;
}

.check:hover {
  background: var(--state-hover);
}

input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.check .box,
.song .cb span {
  width: 18px;
  height: 18px;
  flex: none;
  border: 2px solid var(--on-surface-variant);
  border-radius: 2px;
  position: relative;
  transition: background-color 0.12s, border-color 0.12s;
}

input[type="checkbox"]:checked + .box,
.song.selected .cb span {
  background: var(--primary);
  border-color: var(--primary);
}

input[type="checkbox"]:checked + .box::after,
.song.selected .cb span::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 0;
  width: 4px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(43deg);
}

.sel-count {
  font-size: 13px;
  color: var(--on-surface-muted);
  padding: 0 8px;
}

/* 列表 */
.list-head,
.song {
  display: grid;
  grid-template-columns: 44px 44px minmax(0, 1fr) 168px 186px 56px 48px;
  align-items: center;
  gap: 8px;
  padding: 0 24px;
}

.list-head {
  height: 40px;
  font-size: 12px;
  font-weight: 500;
  color: var(--on-surface-muted);
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
}

.song {
  height: 56px;
  font-size: 14px;
  border-bottom: 1px solid #f1f3f4;
  transition: background-color 0.1s;
}

.song:last-child {
  border-bottom: none;
}

.song:hover {
  background: #f4f6f8;
}

.song.selected {
  background: #f3f7fe;
}

.song.selected:hover {
  background: #eaf1fd;
}

.song .cb {
  display: flex;
  align-items: center;
  cursor: pointer;
  height: 100%;
}

.song .idx {
  font-size: 12px;
  color: #9aa0a6;
  font-variant-numeric: tabular-nums;
}

.song .title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.song .name {
  color: var(--on-surface);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song .artist,
.song .album {
  font-size: 13px;
  color: var(--on-surface-variant);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song .album {
  color: var(--on-surface-muted);
}

.song .dur {
  font-size: 12.5px;
  color: var(--on-surface-muted);
  font-variant-numeric: tabular-nums;
}

.song .act {
  display: flex;
  justify-content: flex-end;
}

/* 标签 */
.tag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.tag.vip {
  color: var(--amber);
  background: var(--amber-bg);
}

.tag.sq {
  color: var(--green);
  background: var(--green-bg);
}

.tag.ok {
  color: var(--green);
  background: var(--green-bg);
}

.tag.warn {
  color: var(--amber);
  background: var(--amber-bg);
}

.tag.off {
  color: var(--on-surface-muted);
  background: var(--surface-container);
}

/* 图标按钮 */
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #5f6368;
  transition: background-color 0.12s, color 0.12s;
}

.icon-btn:hover {
  background: var(--state-hover);
  color: var(--primary);
}

.icon-btn.done {
  color: var(--green);
  pointer-events: none;
}

.icon-btn.fail {
  color: #9aa0a6;
  pointer-events: none;
}

/* ---------------- 空状态 ---------------- */

.empty {
  text-align: center;
  padding: 72px 16px 48px;
  color: var(--outline-variant);
}

.empty svg {
  opacity: 0.9;
}

.empty-title {
  margin: 14px 0 4px;
  font-size: 16px;
  color: var(--on-surface);
}

.empty-sub {
  margin: 0;
  font-size: 13px;
  color: var(--on-surface-muted);
}

/* ---------------- 进度卡片 ---------------- */

.progress-card {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  width: min(400px, calc(100vw - 48px));
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  box-shadow: var(--shadow-2);
  animation: cardIn 0.2s cubic-bezier(0.2, 0, 0, 1) both;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pc-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--on-surface);
}

.pc-head .btn-text {
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
}

.pc-sub {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--on-surface-muted);
}

.pc-track {
  height: 4px;
  margin-top: 12px;
  border-radius: 2px;
  background: #e1e3e1;
  overflow: hidden;
}

.pc-bar {
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: var(--primary);
  transition: width 0.2s ease;
}

.pc-pct {
  margin-top: 6px;
  font-size: 12px;
  color: var(--on-surface-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------------- 对话框 ---------------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 24px;
}

.scrim-bg {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  animation: fadeIn 0.15s ease both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.dialog {
  position: relative;
  width: min(560px, 100%);
  padding: 24px;
  background: var(--surface);
  border-radius: 28px;
  box-shadow: var(--shadow-2);
  animation: dialogIn 0.2s cubic-bezier(0.2, 0, 0, 1) both;
}

@keyframes dialogIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.dialog-title {
  margin: 0 0 14px;
  font-size: 22px;
  font-weight: 400;
  color: var(--on-surface);
}

.dialog-body p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--on-surface-variant);
}

.dialog-body textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--outline-variant);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--on-surface);
  background: var(--surface);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.dialog-body textarea:focus {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.dialog-hint {
  margin: 10px 0 0 !important;
  font-size: 12px !important;
  color: var(--on-surface-muted) !important;
}

.fail-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 10px 12px;
  max-height: 180px;
  overflow-y: auto;
  border-radius: 10px;
  background: var(--surface-container, #f1f4f9);
  font-size: 13px;
  line-height: 1.7;
  color: var(--on-surface-variant);
}

.fail-list li {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.fail-list li + li {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--hairline);
}

.fail-list .fl-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fail-list .fl-why {
  flex: none;
  font-size: 12px;
  color: var(--on-surface-muted);
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

/* ---------------- Snackbar ---------------- */

.snackbar-host {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  pointer-events: none;
}

.toast {
  background: #322f35;
  color: #f4eff4;
  font-size: 14px;
  line-height: 1.5;
  padding: 14px 16px;
  border-radius: 4px;
  box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0, 0, 0.14);
  max-width: min(420px, calc(100vw - 48px));
  animation: snackIn 0.2s cubic-bezier(0.2, 0, 0, 1) both;
}

.toast.err {
  background: #8c1d18;
  color: #f9dedc;
}

.toast.ok {
  background: #0f5223;
  color: #d7f5df;
}

@keyframes snackIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------------- 骨架屏 ---------------- */

.skeleton-row {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
  padding: 0 24px;
  border-bottom: 1px solid #f1f3f4;
}

.sk-bar {
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, #f0f2f5 25%, #f7f8fa 37%, #f0f2f5 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

.hidden {
  display: none !important;
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 1080px) {
  .list-head,
  .song {
    grid-template-columns: 44px 40px minmax(0, 1fr) 160px 56px 48px;
  }
  .col-album,
  .song .album {
    display: none;
  }
}

@media (max-width: 860px) {
  .appbar {
    padding: 0 12px 0 16px;
  }
  .page {
    padding: 20px 16px 40px;
  }
  .list-head,
  .song {
    grid-template-columns: 40px 34px minmax(0, 1fr) 56px 44px;
    padding: 0 16px;
    gap: 4px;
  }
  .col-artist,
  .song .artist {
    display: none;
  }
  .pl-head {
    padding: 16px;
    gap: 14px;
  }
  .pl-cover {
    width: 80px;
    height: 80px;
  }
  .pl-info h2 {
    font-size: 18px;
  }
  .toolbar {
    padding: 6px 10px;
    top: 64px;
  }
  .toolbar .btn-text.has-icon {
    padding: 0 8px;
  }
  .toolbar .btn-text.has-icon svg {
    display: none;
  }
  .progress-card {
    left: 16px;
    right: 16px;
    bottom: 16px;
    width: auto;
  }
  .snackbar-host {
    left: 16px;
    right: 16px;
    bottom: 16px;
    align-items: stretch;
  }
  .toast {
    max-width: none;
  }
}

@media (max-width: 560px) {
  .app-title {
    font-size: 19px;
  }
  .toolbar .spacer {
    display: none;
  }
  .toolbar .btn-filled {
    margin-left: 2px;
  }
  .appbar .btn-text span {
    display: none;
  }
  .appbar .btn-text.has-icon {
    padding: 0 8px;
    min-width: 40px;
  }
  .search-field {
    height: 52px;
    padding: 0 6px 0 14px;
    border-radius: 26px;
  }
  .search-field input {
    font-size: 15px;
  }
  .search-field .btn-filled {
    height: 40px;
    padding: 0 16px;
  }
  .filter-row {
    margin-top: 18px;
  }
  .filter-divider {
    display: none;
  }
  .song {
    grid-template-columns: 36px minmax(0, 1fr) 44px;
  }
  .song .idx,
  .song .dur,
  .col-dur,
  .list-head span:nth-child(2) {
    display: none;
  }
  .list-head {
    grid-template-columns: 36px minmax(0, 1fr) 44px;
  }
  .empty {
    padding: 56px 16px 40px;
  }
}
