/* ============================================================
   ACE 音乐站 - 全局样式（浅色主题，布局对齐 sunoai.cn 风格）
   ============================================================ */
:root {
  --primary: #7c5cff;
  --primary-deep: #5b3df5;
  --primary-grad: linear-gradient(135deg, #7c5cff 0%, #b84dff 100%);
  --accent: #ff5c72;
  --bg: #f6f7fb;
  --card: #ffffff;
  --line: #e8e9f0;
  --text: #23252e;
  --text-2: #6b6e7e;
  --text-3: #9a9db0;
  --ok: #18a058;
  --warn: #e6a23c;
  --err: #e5484d;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(35, 37, 46, 0.06);
  --shadow-lg: 0 10px 40px rgba(35, 37, 46, 0.14);
  --topbar-h: 60px;
  --sidebar-w: 208px;
  --player-h: 76px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: 14px; outline: none; }
.hidden { display: none !important; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: #fff; border-bottom: 1px solid var(--line); z-index: 100;
}
.topbar-inner {
  max-width: 1440px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 18px; padding: 0 20px;
}
.logo { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 800; }
.logo-icon { font-size: 24px; }
.logo-text em { font-style: normal; background: var(--primary-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.search-box {
  flex: 1; max-width: 420px; display: flex;
  border: 2px solid var(--primary); border-radius: 999px; overflow: hidden; background: #fafaff;
}
.search-box input { flex: 1; border: none; background: transparent; padding: 8px 16px; }
.search-box button {
  background: var(--primary-grad); color: #fff; padding: 0 20px; font-size: 14px;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.top-link { color: var(--text-2); font-size: 14px; padding: 6px 8px; border-radius: 8px; }
.top-link:hover { background: #f1f2f8; color: var(--text); }
.engine-badge { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: #f0f1f6; color: var(--text-3); }
.engine-badge.online { background: #e8f7ef; color: var(--ok); }
.engine-badge.mock { background: #fff6e8; color: var(--warn); }
.engine-badge.offline { background: #fdecec; color: var(--err); }

.user-area { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; background: var(--primary-grad); cursor: pointer; flex: none;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 10px; padding: 8px 18px; font-size: 14px; transition: all .15s;
}
.btn-primary { background: var(--primary-grad); color: #fff; box-shadow: 0 4px 14px rgba(124, 92, 255, .35); }
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-ghost { border: 1px solid var(--line); background: #fff; color: var(--text-2); }
.btn-ghost:hover { color: var(--primary); border-color: var(--primary); }
.btn-danger { color: var(--err); border: 1px solid #f5c6c8; background: #fff; }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.credit-chip {
  font-size: 12px; color: var(--primary-deep); background: #f0ecff; border-radius: 999px; padding: 4px 12px;
}

/* ---------------- 布局 ---------------- */
.layout { display: flex; padding-top: var(--topbar-h); min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: #fbfbfe; border-right: 1px solid var(--line);
  padding: 14px 10px calc(var(--player-h) + 20px); position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h)); overflow-y: auto;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px;
  color: var(--text-2); font-size: 14px; margin-bottom: 2px;
}
.nav-item:hover { background: #f0f1f8; color: var(--text); }
.nav-item.active { background: var(--primary-grad); color: #fff; box-shadow: 0 4px 12px rgba(124, 92, 255, .3); }
.nav-item.sub { padding: 8px 14px 8px 24px; font-size: 13px; }
.nav-ico { width: 20px; text-align: center; }
.nav-group { margin: 8px 0 4px; }
.nav-group-title { font-size: 12px; color: var(--text-3); padding: 6px 14px; }

.main {
  flex: 1; min-width: 0; padding: 22px 26px calc(var(--player-h) + 30px);
  max-width: 1240px; margin: 0 auto; width: 100%;
}

/* ---------------- 通用组件 ---------------- */
.section { margin-bottom: 30px; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-title { font-size: 19px; font-weight: 700; }
.section-more { color: var(--text-3); font-size: 13px; cursor: pointer; }
.section-more:hover { color: var(--primary); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 16px; border-radius: 999px; background: #fff; border: 1px solid var(--line);
  color: var(--text-2); font-size: 13px; cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { padding: 10px 18px; color: var(--text-2); font-size: 14px; border-bottom: 2px solid transparent; cursor: pointer; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.empty {
  text-align: center; color: var(--text-3); padding: 46px 0; background: #fff;
  border-radius: var(--radius); border: 1px dashed var(--line);
}
.spinner {
  width: 18px; height: 18px; border: 2px solid #ddd; border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { text-align: center; padding: 40px; color: var(--text-3); }

/* ---------------- 作品卡片 ---------------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.work-card {
  background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  cursor: pointer; transition: transform .15s, box-shadow .15s; position: relative;
}
.work-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.work-cover { position: relative; aspect-ratio: 1; overflow: hidden; }
.work-cover img, .work-cover canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.play-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(20, 18, 40, .0); transition: background .15s; opacity: 0;
}
.work-card:hover .play-overlay { opacity: 1; background: rgba(20, 18, 40, .35); }
.play-overlay .pbtn {
  width: 46px; height: 46px; border-radius: 50%; background: var(--primary-grad); color: #fff; font-size: 18px;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.badge {
  position: absolute; top: 8px; left: 8px; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: rgba(124, 92, 255, .92); color: #fff;
}
.badge.private { background: rgba(120, 122, 140, .92); }
.badge.rank { background: rgba(255, 92, 114, .92); }
.work-info { padding: 10px 12px 12px; }
.work-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.work-tags {
  font-size: 12px; color: var(--text-3); margin-top: 4px; height: 32px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.work-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--text-3); }
.work-meta .author { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work-stats { display: flex; gap: 10px; }
.stat-ico { cursor: pointer; user-select: none; }
.stat-ico.on { color: var(--accent); }
.work-duration { position: absolute; right: 8px; bottom: 8px; font-size: 11px; color: #fff; background: rgba(0,0,0,.45); padding: 1px 6px; border-radius: 4px; }
.card-generating { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; aspect-ratio: 1; color: var(--text-3); font-size: 13px; }
.card-failed { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; aspect-ratio: 1; color: var(--err); font-size: 13px; background: #fff7f7; }

/* 横向滚动列表 */
.hscroll { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
.hscroll > * { flex: 0 0 190px; scroll-snap-align: start; }
.hscroll::-webkit-scrollbar { height: 6px; }
.hscroll::-webkit-scrollbar-thumb { background: #d9dae6; border-radius: 3px; }

/* ---------------- 首页 Hero ---------------- */
.hero {
  background: var(--primary-grad); border-radius: 18px; padding: 42px 36px 38px; color: #fff;
  position: relative; overflow: hidden; margin-bottom: 30px;
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 260px; height: 260px;
  border-radius: 50%; background: rgba(255, 255, 255, .12);
}
.hero h1 { font-size: 26px; font-weight: 800; }
.hero h1 em { font-style: normal; opacity: .9; font-weight: 400; font-size: 18px; margin-left: 8px; }
.hero-stats { margin-top: 10px; font-size: 13px; opacity: .88; }
.hero-stats b { font-size: 16px; margin: 0 2px; }
.hero-input { display: flex; margin-top: 22px; background: #fff; border-radius: 14px; padding: 6px; max-width: 720px; position: relative; z-index: 1; }
.hero-input input { flex: 1; border: none; padding: 12px 16px; font-size: 15px; color: var(--text); background: transparent; }
.hero-input button { background: var(--primary-grad); color: #fff; border-radius: 10px; padding: 0 28px; font-size: 15px; }
.hero-tips { margin-top: 12px; font-size: 12px; opacity: .8; }

/* ---------------- 达人卡 ---------------- */
.creator-row { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.creator-card {
  flex: 0 0 250px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; display: flex; gap: 12px; align-items: flex-start; position: relative;
}
.creator-rank {
  position: absolute; top: -6px; left: -6px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.creator-card .avatar { width: 46px; height: 46px; font-size: 17px; }
.creator-name { font-weight: 700; font-size: 14px; cursor: pointer; }
.creator-name:hover { color: var(--primary); }
.creator-bio { font-size: 12px; color: var(--text-3); margin: 4px 0 8px; height: 32px; overflow: hidden; }
.creator-stats { display: flex; gap: 12px; font-size: 12px; color: var(--text-2); }
.creator-stats b { color: var(--text); }

/* ---------------- 创作页 ---------------- */
.create-layout { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
.create-panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.panel-label { font-size: 13px; color: var(--text-2); margin: 16px 0 8px; display: flex; align-items: center; justify-content: space-between; }
.panel-label:first-child { margin-top: 0; }
.mode-switch { display: flex; background: #f0f1f6; border-radius: 10px; padding: 3px; }
.mode-switch button { flex: 1; padding: 8px 0; border-radius: 8px; font-size: 13px; color: var(--text-2); }
.mode-switch button.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
textarea, .ipt, select.ipt {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  background: #fafafc; color: var(--text); resize: vertical;
}
textarea:focus, .ipt:focus { border-color: var(--primary); background: #fff; }
.char-count { font-size: 12px; color: var(--text-3); }
.switch-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--text-2); }
.toggle { position: relative; width: 42px; height: 24px; background: #d9dae6; border-radius: 999px; transition: background .2s; flex: none; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: left .2s; }
.toggle.on { background: var(--primary); }
.toggle.on::after { left: 21px; }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.meta-grid .full { grid-column: 1 / -1; }
.ai-btn {
  border: 1px dashed var(--primary); color: var(--primary); background: #f7f4ff;
  border-radius: 8px; padding: 4px 12px; font-size: 12px;
}
.ai-btn:hover { background: #efe9ff; }
.ai-btn:disabled { opacity: .5; cursor: wait; }
.privacy-row { display: flex; gap: 8px; }
.privacy-row .chip { flex: 1; text-align: center; }
.generate-bar {
  margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.generate-btn { width: 100%; padding: 13px 0; font-size: 16px; font-weight: 700; border-radius: 12px; }
.cost-tip { text-align: center; font-size: 12px; color: var(--text-3); }
.notice { font-size: 12px; color: var(--warn); background: #fff8ec; border-radius: 8px; padding: 8px 12px; }

/* 右侧任务/作品列表 */
.result-panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px; min-height: 400px; }
.result-empty { text-align: center; color: var(--text-3); padding: 90px 0; }
.result-empty .big { font-size: 44px; margin-bottom: 12px; }

/* ---------------- 播放器 ---------------- */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--player-h); z-index: 120;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 0 22px;
}
.player-cover { width: 48px; height: 48px; border-radius: 10px; overflow: hidden; flex: none; box-shadow: var(--shadow); }
.player-cover canvas, .player-cover img { width: 100%; height: 100%; display: block; }
.player-meta { width: 160px; flex: none; overflow: hidden; }
.player-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-author { font-size: 12px; color: var(--text-3); margin-top: 3px; cursor: pointer; }
.player-controls { display: flex; align-items: center; gap: 6px; }
.pl-btn { width: 34px; height: 34px; border-radius: 50%; color: var(--text-2); font-size: 15px; display: flex; align-items: center; justify-content: center; }
.pl-btn:hover { background: #f0f1f6; }
.pl-btn.main { width: 44px; height: 44px; background: var(--primary-grad); color: #fff; font-size: 17px; }
.player-progress { flex: 1; display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-3); }
.player-progress input { flex: 1; accent-color: var(--primary); height: 4px; cursor: pointer; }
.player-extra { display: flex; gap: 4px; }

/* 歌词/队列面板 */
.lyrics-panel, .queue-panel {
  position: fixed; right: 14px; bottom: calc(var(--player-h) + 12px); width: 400px; max-height: 55vh;
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); z-index: 130;
  display: flex; flex-direction: column; overflow: hidden;
}
.lyrics-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
.lyrics-head button { color: var(--text-3); }
.lyrics-body { padding: 16px 20px 24px; overflow-y: auto; font-size: 14px; }
.lyrics-body .lrcline { padding: 7px 4px; color: var(--text-3); transition: all .2s; border-radius: 6px; }
.lyrics-body .lrcline.active { color: var(--primary); font-weight: 700; font-size: 15px; }
.lyrics-body .lrcline.tag { font-size: 12px; color: #c3c5d4; }
.lyrics-body .plain { white-space: pre-wrap; line-height: 1.9; color: var(--text-2); }
.queue-body { overflow-y: auto; }
.queue-item { display: flex; align-items: center; gap: 10px; padding: 9px 16px; cursor: pointer; font-size: 13px; }
.queue-item:hover { background: #f7f7fd; }
.queue-item.playing { color: var(--primary); font-weight: 600; }
.queue-item .q-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(24, 24, 38, .5); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 860px; max-height: 88vh;
  overflow-y: auto; box-shadow: var(--shadow-lg); animation: pop .18s ease;
}
.modal.small { max-width: 400px; padding: 26px; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.work-detail { display: grid; grid-template-columns: 320px 1fr; gap: 24px; padding: 26px; }
.detail-cover { position: relative; }
.detail-cover canvas { width: 100%; aspect-ratio: 1; border-radius: 14px; display: block; }
.detail-cover .play-overlay { opacity: 1; background: rgba(0,0,0,0); }
.detail-cover .pbtn { width: 62px; height: 62px; font-size: 26px; position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); }
.detail-cover .pbtn:hover { transform: translate(-50%,-50%) scale(1.06); }
.detail-title { font-size: 20px; font-weight: 800; }
.detail-author { margin-top: 6px; font-size: 13px; color: var(--text-2); }
.detail-author b { cursor: pointer; color: var(--primary); }
.detail-tags { margin-top: 10px; font-size: 13px; color: var(--text-3); line-height: 1.7; }
.detail-metas { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.meta-pill { font-size: 12px; background: #f0f1f6; color: var(--text-2); padding: 4px 12px; border-radius: 999px; }
.detail-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.detail-lyrics { margin-top: 18px; max-height: 260px; overflow-y: auto; background: #fafafc; border-radius: 10px; padding: 14px 16px; }
.detail-close { position: sticky; top: 0; float: right; margin: 12px 12px 0 0; z-index: 5; width: 32px; height: 32px; border-radius: 50%; background: #f0f1f6; color: var(--text-2); }

/* 登录弹窗 */
.auth-tabs { display: flex; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.auth-tabs .tab { flex: 1; text-align: center; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form .ipt { background: #fff; }
.auth-tip { font-size: 12px; color: var(--text-3); text-align: center; }

/* 创作者弹窗作品列表 */
.creator-works { padding: 20px 26px 26px; }
.creator-head { display: flex; align-items: center; gap: 14px; padding: 20px 26px 12px; }
.creator-head .avatar { width: 56px; height: 56px; font-size: 20px; }

/* ---------------- 工具箱 ---------------- */
.tool-layout { max-width: 880px; }
.upload-box {
  border: 2px dashed #d5d7e4; border-radius: 14px; padding: 34px; text-align: center;
  color: var(--text-3); cursor: pointer; transition: all .15s; background: #fff;
}
.upload-box:hover, .upload-box.drag { border-color: var(--primary); background: #f8f6ff; }
.upload-box .big { font-size: 36px; }
.upload-done { display: flex; align-items: center; gap: 10px; background: #eef9f2; color: var(--ok); border-radius: 10px; padding: 12px 16px; }
.tool-form { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.job-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; border-radius: 10px; box-shadow: var(--shadow); margin-bottom: 10px; font-size: 13px; }
.job-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrc-editor textarea { min-height: 320px; font-family: Consolas, monospace; font-size: 13px; line-height: 1.8; }

/* ---------------- toast ---------------- */
#toast-root { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #23252e; color: #fff; padding: 10px 22px; border-radius: 10px; font-size: 14px;
  box-shadow: var(--shadow-lg); animation: fadein .2s ease; max-width: 80vw;
}
.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }
@keyframes fadein { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
  .create-layout { grid-template-columns: 1fr; }
  .work-detail { grid-template-columns: 1fr; }
  .detail-cover { max-width: 320px; }
  .sidebar { display: none; }
}
