/* ==================================================================
   参考曲分析 —— 与 /studio/ 同一套深色 DAW 语言
   ================================================================== */

: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;
  --radius: 12px;
  --font: "Inter", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

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; }

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

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 22px;
  background: rgba(21, 21, 31, .86);
  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; }
.topbar-title h1 { font-size: 16px; font-weight: 600; 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;
}

.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 48px;
  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: 10px;
  margin-bottom: 10px;
}
.panel-head h2 { font-size: 15px; font-weight: 600; }
.tag {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
}

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

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

.drop { border-style: dashed; border-color: #33334a; }
.drop.over { border-color: var(--brand); background: #171727; }

.drop-head { display: flex; gap: 14px; align-items: flex-start; }
.drop-ic {
  width: 46px; height: 46px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--brand);
}
.drop h2 { font-size: 15px; margin-bottom: 4px; }

.drop-actions { display: flex; align-items: center; gap: 12px; margin: 14px 0 4px; flex-wrap: wrap; }
.file-types { color: var(--muted); font-size: 12px; }

.demos { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.demo-label { color: var(--muted); font-size: 12px; display: block; margin-bottom: 8px; }
.demo-chips { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--txt-2);
  font-size: 12.5px;
  cursor: pointer;
  transition: color .16s, border-color .16s, background .16s;
}
.chip:hover { color: var(--txt); border-color: var(--brand); background: #20203a; }
.chip b { font-weight: 600; color: var(--txt); }
.chip.on { border-color: var(--brand); background: #20203a; color: var(--txt); }

.progress { margin-top: 14px; }
.progress .bar { height: 6px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .25s ease; }
.progress .stage { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }

.err { margin-top: 12px; color: #ff8a8a; font-size: 13px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--txt);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .16s, border-color .16s, opacity .16s;
}
.btn:hover { background: #26263a; border-color: #3a3a52; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--grad); border-color: transparent; color: #fff; }
.btn-primary:hover { filter: brightness(1.08); background: var(--grad); }
.btn-outline { background: transparent; }
.btn-play { background: var(--brand); border-color: transparent; color: #fff; min-width: 92px; }
.btn-stop { min-width: 78px; }

/* ---------------- 概览卡 ---------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 980px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
}
.stat .k { font-size: 11.5px; color: var(--muted); display: block; }
.stat .v { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; display: block; }
.stat .sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.stat .conf { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); }
.conf-hi { color: var(--ok); border-color: rgba(62, 207, 142, .35); }
.conf-mid { color: var(--warn); border-color: rgba(245, 165, 36, .35); }
.conf-lo { color: #ff8a8a; border-color: rgba(255, 138, 138, .35); }

/* ---------------- transport ---------------- */

.transport {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.readout { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 11px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); }
.readout .k { font-size: 11px; color: var(--muted); }
.readout .v { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--txt-2); cursor: pointer; }
.chk input { accent-color: var(--brand); }

.canvas-box { position: relative; border-radius: 10px; overflow: hidden; background: #101018; border: 1px solid var(--line-soft); }
#wave { display: block; width: 100%; cursor: pointer; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 8px; border-radius: 3px; display: inline-block; }
.sw-sec { background: rgba(123, 108, 246, .35); border: 1px solid rgba(123, 108, 246, .8); }
.sw-bar { background: #4b4b66; }
.sw-beat { background: #33334a; }
.sw-head { background: var(--pink); }

/* ---------------- 和弦 ---------------- */

.chord-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
@media (max-width: 900px) { .chord-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.chord-cell {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.chord-cell:hover { border-color: var(--brand); background: #20203a; }
.chord-cell.cur { border-color: var(--pink); background: #2a1a2a; }
.chord-cell .bar-no { font-size: 10px; color: var(--muted); }
.chord-cell .rn { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.chord-cell .nm { font-size: 12px; color: var(--txt-2); }
.chord-cell .q { font-size: 10px; color: var(--muted); }

/* ---------------- 段落 ---------------- */

.sec-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.sec-row {
  display: grid;
  grid-template-columns: 34px 1fr 92px 120px;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  padding: 9px 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.sec-row:hover { border-color: var(--brand); }
.sec-row.cur { border-color: var(--pink); background: #2a1a2a; }
.sec-row .g { font-weight: 700; font-size: 14px; text-align: center; border-radius: 6px; padding: 2px 0; }
.sec-row .name { font-weight: 600; font-size: 13.5px; }
.sec-row .meta { font-size: 12px; color: var(--muted); }
.sec-row .meters { display: flex; flex-direction: column; gap: 3px; }
.sec-row .meter { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--muted); }
.sec-row .meter i { display: block; height: 5px; border-radius: 999px; background: var(--grad); min-width: 2px; }
.sec-row .meter span { width: 30px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- 表格 ---------------- */

.table-scroll { overflow-x: auto; margin-top: 10px; }
.tb { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 620px; }
.tb th, .tb td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); }
.tb th { color: var(--muted); font-weight: 600; font-size: 12px; }
.tb td { color: var(--txt-2); }
.tb tr:last-child td { border-bottom: 0; }

/* ---------------- 导出 ---------------- */

.export-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.code {
  margin: 12px 0 0;
  padding: 12px 14px;
  background: #101018;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  font-size: 12px;
  color: var(--txt-2);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 190px;
  overflow-y: auto;
}

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

.note-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .note-grid { grid-template-columns: minmax(0, 1fr); } }
.note-card { border: 1px solid var(--line); border-radius: 10px; padding: 13px 14px; background: var(--panel-2); }
.note-card h4 { font-size: 13px; margin-bottom: 5px; }
.note-card p { font-size: 12.5px; color: var(--muted); }
.note-card.warn { border-color: rgba(245, 165, 36, .35); }

/* ---------------- 词汇气泡 ---------------- */

.has-tip { cursor: help; }
.has-tip::after {
  content: "?";
  display: inline-block;
  margin-left: 4px;
  font-size: 9px;
  vertical-align: super;
  color: var(--brand);
  opacity: .85;
}
.glossary-tip {
  position: fixed;
  z-index: 90;
  max-width: 320px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #23233a;
  border: 1px solid #3a3a55;
  color: var(--txt);
  font-size: 12.5px;
  line-height: 1.55;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
  opacity: 0;
  transition: opacity .14s;
  pointer-events: none;
}
.glossary-tip.show { opacity: 1; }

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  background: #26263c;
  border: 1px solid var(--line);
  color: var(--txt);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 80;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
