/* 千昱音乐工作室 —— 简洁主题，支持浅色/深色 */
:root {
  --bg: #f4f6fb; --card: #ffffff; --surface: #ffffff; --soft: #f4f6fb;
  --line: #e3e8f0; --text: #1f2937;
  --mute: #8a94a6; --accent: #6d5efc; --accent-d: #5a4ce0;
  --green: #16a34a; --amber: #d97706; --red: #dc2626; --blue: #2563eb;
  --radius: 12px;
  color-scheme: light;
}
/* 深色主题：只覆盖颜色变量，其余样式靠变量自动跟随 */
[data-theme="dark"] {
  --bg: #0e1116; --card: #181c24; --surface: #181c24; --soft: #222834;
  --line: #2b313d; --text: #e6e9ef;
  --mute: #8b93a3; --accent: #7c8fff; --accent-d: #9aa9ff;
  --green: #34d399; --amber: #fbbf24; --red: #f87171; --blue: #60a5fa;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--mute); }
.small { font-size: 12px; }
.center { text-align: center; padding: 60px 20px; }
.err-text { color: var(--red); font-size: 12px; }

/* 输入控件 */
input, select, textarea, button {
  font-family: inherit; font-size: 14px;
}
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--text);
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(109,94,252,.12);
}
input[type=range] { padding: 0; }
input[type=checkbox] { width: auto; }

button {
  cursor: pointer; padding: 8px 16px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  transition: all .15s;
}
button:hover { background: var(--soft); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-d); }
button.primary:disabled { opacity: .6; cursor: not-allowed; }
button.ghost { background: transparent; }
button.danger { color: var(--red); }
button.small { padding: 4px 10px; font-size: 12px; }
button.block { width: 100%; }
button.big { padding: 13px; font-size: 16px; }
.btn { display: inline-block; padding: 5px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); }
.btn.small { padding: 4px 10px; font-size: 12px; }

/* 布局骨架 */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px; flex-shrink: 0;
}
.brand { font-size: 17px; font-weight: 700; padding: 8px 10px 18px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 9px; color: var(--text); font-weight: 500;
}
.nav-item:hover { background: var(--soft); }
.nav-item.active { background: rgba(109,94,252,.12); color: var(--accent-d); }
.nav-item .ico { width: 20px; text-align: center; }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 12px; }
.who { padding: 4px 10px 10px; }
.who .name { font-weight: 600; }
.who .role { font-size: 12px; color: var(--mute); }
.content { flex: 1; padding: 24px 28px; overflow-x: hidden; }

.page { max-width: 760px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-head h2 { margin: 0; font-size: 20px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.form-card { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 13px; color: var(--mute); font-weight: 500; }
.field.check { flex-direction: row; align-items: center; gap: 8px; padding-top: 22px; }
.row { display: flex; gap: 14px; align-items: flex-end; }
.row .field { flex: 1; }
.row.sliders .field b { color: var(--accent); }

/* 模式切换段 */
.seg { display: inline-flex; background: var(--soft); border-radius: 10px; padding: 3px; gap: 3px; align-self: flex-start; }
.seg button { border: none; background: transparent; padding: 7px 16px; border-radius: 8px; font-weight: 600; color: var(--mute); }
.seg button.on { background: var(--surface); color: var(--accent-d); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* 配额徽标 */
.quota-badge { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 13px; }
.quota-badge b { color: var(--green); font-size: 15px; }
.quota-badge b.low { color: var(--red); }
.low { color: var(--red); }

/* 作品卡片 */
.song-list { display: flex; flex-direction: column; gap: 14px; }
.song-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.song-head { display: flex; align-items: center; gap: 14px; }
.cover { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.cover.sm { width: 44px; height: 44px; }
.cover.placeholder { display: flex; align-items: center; justify-content: center;
  background: var(--soft); font-size: 26px; }
.song-meta { flex: 1; min-width: 0; }
.song-title { font-weight: 600; font-size: 15px; }
.song-sub { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.clips { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.clip-row { display: flex; align-items: center; gap: 10px; }
.clip-label { font-size: 12px; color: var(--mute); width: 90px; flex-shrink: 0; }
.clip-row audio { height: 36px; flex: 1; }

/* 状态徽标 */
.badge { font-size: 11px; padding: 2px 9px; border-radius: 999px; font-weight: 600; }
.badge.completed { background: rgba(22,163,74,.12); color: var(--green); }
.badge.failed { background: rgba(220,38,38,.12); color: var(--red); }
.badge.pending, .badge.submitting, .badge.downloading, .badge.queued {
  background: rgba(37,99,235,.12); color: var(--blue); }

/* spinner */
.spinner { width: 13px; height: 13px; border: 2px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%; display: inline-block;
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 表格（用户管理） */
.table { width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { background: var(--soft); font-size: 12px; color: var(--mute); font-weight: 600; }
.table tr.disabled { opacity: .55; }
.table .ops { display: flex; gap: 4px; flex-wrap: wrap; }

/* 后台作品列表 */
.admin-songs { display: flex; flex-direction: column; gap: 8px; }
.admin-song { display: flex; align-items: center; gap: 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.admin-song.deleted { opacity: .6; background: var(--soft); }
.as-meta { flex: 1; min-width: 0; }
.as-title { font-weight: 600; }
.admin-song .ops { display: flex; gap: 6px; }

/* 登录页 */
.login-wrap { width: 100%; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#6d5efc11,#2563eb11); }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 38px 34px; width: 360px; text-align: center; box-shadow: 0 12px 40px rgba(31,41,55,.08); }
.login-logo { font-size: 44px; }
.login-card h1 { margin: 6px 0 2px; font-size: 22px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 22px; }
.login-hint { margin-top: 18px; font-size: 12px; }

/* toast */
#toast-area { position: fixed; top: 18px; right: 18px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 24px rgba(31,41,55,.12);
  max-width: 340px; animation: slideIn .2s; }
.toast.ok { border-left-color: var(--green); }
.toast.warn { border-left-color: var(--amber); }
.toast.err { border-left-color: var(--red); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 640px) {
  .sidebar { width: 64px; }
  .brand, .who, .nav-item span:not(.ico) { display: none; }
  .row { flex-direction: column; align-items: stretch; }
}

/* ───────── 概览 Dashboard ───────── */
.dash-card { margin-bottom: 16px; }
.dash-title { margin: 0 0 16px; font-size: 15px; }
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px;
}
.stat {
  background: var(--soft); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 12px; text-align: center;
}
.stat-num { font-size: 22px; font-weight: 700; color: var(--accent-d); word-break: break-word; }
.stat-label { font-size: 12px; color: var(--mute); margin-top: 4px; }
.usage-bar-wrap { margin-top: 16px; }
.usage-bar-label { font-size: 13px; color: var(--mute); margin-bottom: 6px; }
.usage-bar-label b { color: var(--green); }
.usage-bar-label b.warn { color: var(--red); }
.usage-bar { height: 10px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.usage-fill { height: 100%; background: var(--green); border-radius: 999px; transition: width .3s; }
.usage-fill.warn { background: var(--red); }

/* ───────── 扁平图标 / 主题切换 ───────── */
.nav-item .ico { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; }
.nav-item .ico svg { display: block; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo { display: inline-flex; color: var(--accent); }
.brand-logo svg { width: 22px; height: 22px; }
.theme-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; margin-bottom: 10px; color: var(--text); cursor: pointer;
}
.theme-toggle:hover { background: var(--soft); }
.theme-toggle svg { width: 18px; height: 18px; }
.tt-label { font-size: 13px; }
.logout-btn { display: flex; align-items: center; justify-content: center; gap: 8px; }
.logout-btn svg { width: 16px; height: 16px; }

/* ───────── 作品卡片增强：操作/详情/标记 ───────── */
.song-actions { display: flex; gap: 4px; flex-wrap: wrap; align-self: flex-start; }
.mini-stars { color: #f5a623; font-size: 13px; }
.tag-chip { background: rgba(109,94,252,.12); color: var(--accent-d); font-size: 11px;
  padding: 1px 8px; border-radius: 999px; }
.tag-chip.removable { cursor: pointer; }
.tag-chip.removable:hover { background: rgba(220,38,38,.15); color: var(--red); }
.detail-box { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
table.kv { width: 100%; font-size: 13px; }
table.kv td { padding: 3px 6px; vertical-align: top; }
table.kv td:first-child { color: var(--mute); width: 100px; white-space: nowrap; }
.detail-text { font-size: 13px; margin-top: 8px; }
.lyrics-detail { margin-top: 8px; }
.lyrics-detail summary { cursor: pointer; color: var(--mute); font-size: 13px; }
.lyrics-detail pre { background: var(--soft); padding: 10px; border-radius: 8px;
  white-space: pre-wrap; font-size: 12px; margin-top: 6px; max-height: 260px; overflow: auto; }
.mark-box { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px; }
.mark-row { display: flex; align-items: center; gap: 10px; }
.mark-label { width: 44px; color: var(--mute); font-size: 13px; flex-shrink: 0; }
.stars { display: flex; gap: 2px; }
.star { cursor: pointer; font-size: 20px; color: var(--line); line-height: 1; }
.star.on { color: #f5a623; }
.tag-edit { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; }
.tag-input { width: 120px; padding: 4px 8px; }
.note-edit { display: flex; gap: 8px; flex: 1; }
.note-edit input { flex: 1; }

/* ───────── 创作页：历史/纯音乐/库入口 ───────── */
.head-right { display: flex; align-items: center; gap: 10px; }
.field-head { display: flex; align-items: center; justify-content: space-between; }
.link-btn { background: none; border: none; color: var(--accent); font-size: 12px; padding: 0; cursor: pointer; }
.history-pop { background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  margin: 4px 0; max-height: 220px; overflow: auto; }
.history-item { padding: 8px 12px; font-size: 12px; cursor: pointer; border-bottom: 1px solid var(--line); color: var(--mute); }
.history-item:hover { background: var(--soft); color: var(--text); }
.field.check.standalone { padding-top: 0; }

/* ───────── 筛选条 ───────── */
.filter-bar { display: flex; gap: 12px; align-items: flex-end; padding: 14px 16px; margin-bottom: 14px; }
.filter-bar .field { flex: 0 0 auto; }
.filter-bar .field.grow { flex: 1; }
.page.wide { max-width: 980px; }

/* ───────── 后台所有作品：作者条 ───────── */
.admin-song-wrap { margin-bottom: 4px; }
.admin-song-wrap.deleted { opacity: .65; }
.author-bar { display: flex; align-items: center; gap: 10px; padding: 0 4px 4px; }
.author-name { font-weight: 600; font-size: 13px; }
.author-bar .grow { flex: 1; }

/* ───────── 创作库 ───────── */
.lib-group { margin-bottom: 22px; }
.lib-cat { font-size: 14px; margin: 0 0 10px; color: var(--accent-d); }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.lib-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.lib-title { font-weight: 600; }
.lib-desc { margin: 4px 0; }
.lib-summary { color: var(--mute); margin-bottom: 10px; }
.lib-actions { display: flex; gap: 6px; flex-wrap: wrap; }
