/* ==================================================================
   音乐分轨 /split/ —— 与 /analyze/ /studio/ 同一套深色 DAW 语言
   注意：本页不引入任何外部字体（Google Fonts 会被 COEP 拦），
        字體栈全部走系统字体，加载更快也更稳。
   ================================================================== */

:root {
  --bg: #0d0d13;
  --panel: #15151f;
  --panel-2: #1c1c28;
  --line: #2a2a3a;
  --line-soft: #23232f;
  --txt: #e9e9f2;
  --txt-2: #b9b9cc;
  --muted: #8585a0;
  --brand: #7b6cf6;
  --brand-2: #5b4bd6;
  --pink: #e0398a;
  --grad: linear-gradient(135deg, #7b6cf6 0%, #e0398a 100%);
  --ok: #3ecf8e;
  --warn: #f5a524;
  --danger: #f2555a;
  --radius: 12px;
  --font: "Inter", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI",
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

/* 必须放前面：.btn/.filebar 这些类都写了 display，会盖掉 UA 的 [hidden]{display:none}，
   結果 JS 設 el.hidden = true 完全沒作用（取消按鈕跑完不消失就是這個坑）。 */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--txt);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.55;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.3; letter-spacing: -0.01em; }
p { margin: 0; }
button { font-family: inherit; }
a { color: var(--brand); }

/* ---------------- topbar ---------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px;
  background: rgba(21, 21, 31, .9);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px);
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--txt-2);
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  text-decoration: none;
  transition: color .18s, border-color .18s, background .18s;
  flex: 0 0 auto;
}
.back:hover { color: var(--txt); border-color: var(--brand); background: var(--panel-2); }

.topbar-title { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; }
/* min-width:0 不能省：h1 是 flex 子项，没有它 ellipsis 不生效，长标题会把整条顶栏撑宽 */
.topbar-title h1 {
  font-size: 16px; font-weight: 600; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.badge {
  font-size: 10px; font-weight: 700; letter-spacing: .12em;
  padding: 4px 8px; border-radius: 6px;
  background: var(--grad); color: #fff; flex: 0 0 auto;
}

.topbar-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.lang-switch {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
}
.lang-btn {
  background: transparent; border: 0; color: var(--muted);
  font-size: 12px; font-weight: 600; padding: 5px 11px;
  border-radius: 999px; cursor: pointer; transition: color .16s, background .16s;
}
.lang-btn:hover { color: var(--txt); }
.lang-btn.active { background: var(--brand); color: #fff; }

/* ---------------- 布局 ---------------- */

.wrap {
  max-width: 1180px; margin: 0 auto; padding: 18px 22px 56px;
  display: flex; flex-direction: column; gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.panel-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.panel-head h2 { font-size: 15px; font-weight: 600; }
.panel-head .sub { font-size: 12.5px; color: var(--muted); min-width: 0; }

.hint { font-size: 12.5px; color: var(--muted); }

/* ---------------- 上传区 ---------------- */

.drop {
  border: 1px dashed var(--line);
  background: var(--panel);
  transition: border-color .18s, background .18s;
}
.drop.over { border-color: var(--brand); background: var(--panel-2); }

.drop-head { display: flex; gap: 14px; align-items: flex-start; }
.drop-ic {
  width: 44px; height: 44px; flex: 0 0 auto; border-radius: 10px;
  display: grid; place-items: center; color: #fff; background: var(--grad);
}
.drop-head h2 { font-size: 16px; }
.drop-head p { margin-top: 4px; max-width: 62ch; }

.drop-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13.5px; font-weight: 500; padding: 9px 16px;
  border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--txt); cursor: pointer;
  transition: border-color .16s, background .16s, opacity .16s;
  min-width: 0;
}
.btn:hover { border-color: var(--brand); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-danger { color: var(--danger); }

.demos { margin-top: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.demo-chip {
  font-size: 12.5px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--txt-2);
  cursor: pointer; transition: border-color .16s, color .16s;
}
.demo-chip:hover { border-color: var(--brand); color: var(--txt); }

/* 已选文件信息条 */
.filebar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 14px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2);
}
.filebar .fname {
  font-size: 13px; font-weight: 500; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 160px;
}
.filebar .fmeta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.filebar .fx {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 2px 4px; flex: 0 0 auto;
}
.filebar .fx:hover { color: var(--danger); }

/* ---------------- 设置 ---------------- */

.settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12px; color: var(--muted); }
.field select, .field input {
  font: inherit; font-size: 13px; color: var(--txt); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px;
  min-width: 0; width: 100%;
}
.field .note { font-size: 11.5px; color: var(--muted); }

.runbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.runbar .grow { flex: 1 1 auto; min-width: 0; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 11.5px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: var(--panel-2);
  white-space: nowrap;
}
.chip.ok { color: var(--ok); border-color: rgba(62, 207, 142, .4); }
.chip.warn { color: var(--warn); border-color: rgba(245, 165, 36, .4); }

/* ---------------- 进度 ---------------- */

.progress { margin-top: 16px; }
.progress .bar { height: 8px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.progress .bar > i {
  display: block; height: 100%; width: 0;
  background: var(--grad); transition: width .2s ease;
}
.progress.indet .bar > i { width: 35% !important; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(340%); }
}
.progress .row {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin-top: 8px; font-size: 12.5px; color: var(--muted);
}
.progress .row .pct { font-variant-numeric: tabular-nums; color: var(--txt-2); font-weight: 600; }
.progress .row .eta { flex: 1 1 auto; min-width: 0; }

.err {
  margin-top: 12px; padding: 10px 12px; border-radius: 10px;
  background: rgba(242, 85, 90, .12); border: 1px solid rgba(242, 85, 90, .35);
  color: #ffb4b7; font-size: 12.5px; white-space: pre-wrap; word-break: break-word;
}

/* ---------------- 结果 ---------------- */

.stems { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }

.stem {
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel-2); padding: 14px; min-width: 0;
}
.stem-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.stem-head h3 { font-size: 14px; font-weight: 600; flex: 1 1 auto; min-width: 0; }
.stem-head .tag {
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); flex: 0 0 auto;
}
.stem canvas {
  display: block; width: 100%; height: 56px; border-radius: 8px;
  background: #101018; margin-bottom: 10px;
}
.stem audio { width: 100%; display: block; margin-bottom: 10px; }
.stem-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
}
.stem-foot .grow { flex: 1 1 auto; min-width: 0; }
.link-btn {
  background: none; border: 0; padding: 0; font-size: 12.5px;
  color: var(--brand); cursor: pointer; font-weight: 500;
}
.link-btn:hover { text-decoration: underline; }

.stats { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 12.5px; }
.stats th, .stats td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line-soft); }
.stats th { color: var(--muted); font-weight: 500; font-size: 12px; }
.stats td.n { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- 说明区 ---------------- */

.notes { font-size: 12.5px; color: var(--muted); }
.notes h3 { font-size: 13px; color: var(--txt); margin-bottom: 6px; }
.notes ul { margin: 6px 0 0; padding-left: 18px; }
.notes li { margin-bottom: 4px; }
.notes .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.notes code {
  font-family: var(--mono); font-size: 11.5px;
  background: var(--panel-2); padding: 1px 5px; border-radius: 4px;
}

.log {
  margin-top: 14px; max-height: 220px; overflow: auto;
  background: #101018; border: 1px solid var(--line-soft); border-radius: 10px;
  padding: 12px; font-family: var(--mono); font-size: 11.5px; line-height: 1.65;
  color: var(--txt-2); white-space: pre-wrap; word-break: break-word;
}

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

@media (max-width: 860px) {
  .settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 360px 及以下的窄屏：三列改单列，否则 select 会被自身最小内容宽度撑破 */
@media (max-width: 520px) {
  .wrap { padding: 14px 14px 44px; }
  .topbar { padding: 10px 14px; gap: 10px; }
  .settings { grid-template-columns: 1fr; }
  .panel { padding: 14px; }
  .back span { display: none; }
  .drop-head { gap: 10px; }
  .stems { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
  .topbar-title .badge { display: none; }
}
