/* DiffSinger Editor - dark DAW theme */
:root {
  --bg-0: #12141a;
  --bg-1: #181b22;
  --bg-2: #20242e;
  --bg-3: #2a2f3b;
  --line: #343a48;
  --line-soft: #262b36;
  --text: #e6e9f0;
  --text-dim: #9aa3b2;
  --accent: #5b8cff;
  --accent-2: #7c5cff;
  --good: #3ddc97;
  --warn: #f7b955;
  --bad: #ff5c74;
  --note: #5b8cff;
  --note-selected: #ffd166;
  --note-border: #9db8ff;
  --playhead: #ff5c74;
  --radius: 6px;
  --toolbar-h: 52px;
  --transport-h: 44px;
  --status-h: 26px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 13px;
  user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ---------- toolbar ---------- */
#toolbar {
  height: var(--toolbar-h);
  min-height: var(--toolbar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  font-weight: 600;
  letter-spacing: .3px;
  white-space: nowrap;
}
.brand-text { display: none; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.brand-mark svg {
  display: block;
  width: 15px;
  height: 15px;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}
.tool-group.grow { flex: 1; min-width: 0; }
.grow { flex: 1; }

.btn {
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: #343b4a; border-color: #4a5264; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #4f7df0, #6a5cf0); border-color: #6d8bf5; }
.btn-primary:hover { background: linear-gradient(135deg, #5d8bfa, #7868fa); }
.btn-icon {
  width: 30px;
  min-width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.btn-icon svg {
  display: block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#btn-play .icon-play path,
#btn-stop svg rect {
  fill: currentColor;
  stroke: none;
}
#btn-play .icon-pause { display: none; }
#btn-play.playing .icon-play { display: none; }
#btn-play.playing .icon-pause { display: block; }
.btn-play { width: 30px; min-width: 30px; }
.btn-play.playing { background: #3a2b32; border-color: var(--bad); color: #ffb3bf; }
#btn-stop { width: 30px; min-width: 30px; }
#btn-reverb.active { color: var(--accent); border-color: var(--accent); }

.field {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
}
.select, .input {
  height: 30px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-0);
  color: var(--text);
  padding: 0 8px;
  font-size: 12px;
  outline: none;
}
.select { max-width: 190px; }
.input-num { width: 68px; }
.input:focus, .select:focus { border-color: var(--accent); }

.account {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(91, 140, 255, .12);
  border: 1px solid rgba(91, 140, 255, .35);
  color: #b9c9ff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #555c6b;
  box-shadow: 0 0 0 3px rgba(255,255,255,.03);
}
.dot.on { background: var(--good); box-shadow: 0 0 8px rgba(61,220,151,.7); }

/* ---------- progress ---------- */
.progress {
  position: relative;
  flex: 1;
  min-width: 130px;
  max-width: 420px;
  height: 22px;
  border-radius: 999px;
  background: var(--bg-0);
  border: 1px solid var(--line);
  overflow: hidden;
}
.progress-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, #4f7df0, #7c5cff);
  transition: width .18s ease;
}
.progress.error .progress-bar { background: var(--bad); }
.progress-text {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 11px;
  color: #dfe5ff;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
  padding: 0 10px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------- transport ---------- */
#transport {
  height: var(--transport-h);
  min-height: var(--transport-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.time-display {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  color: #cfe0ff;
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 8px;
  min-width: 96px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.divider { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.project-name { color: #c7d2e8; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--text-dim); font-size: 12px; }

/* 参数曲线选择：单图标 + 弹出菜单，不占用左侧标尺宽度 */
.param-head {
  position: absolute;
  left: 8px;
  top: 0;
  z-index: 3;
  width: 0;
  height: 0;
  max-width: none;
  padding: 0;
  border: 0;
  background: transparent;
}
.param-title-hit {
  position: absolute;
  left: 0;
  top: 0;
  width: 64px;
  height: 30px;
  z-index: 2;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 0 0 6px 0;
}
.param-title-hit:hover { background: rgba(91, 140, 255, .06); }
.param-title-hit:focus-visible { outline: 1px solid rgba(91, 140, 255, .5); outline-offset: -1px; }
.param-native { display: none; }
.param-menu {
  position: fixed;
  left: 8px;
  top: 40px;
  z-index: 1200;
  min-width: 176px;
  max-height: 156px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(15, 19, 29, .98);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
}
.param-menu[hidden] { display: none; }
.param-menu-item {
  width: 100%;
  padding: 6px 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.param-menu-item:hover { background: rgba(91, 140, 255, .14); }
.param-menu-item.active {
  color: var(--accent);
  background: rgba(91, 140, 255, .18);
}

/* ---------- editor ---------- */
#editor {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-0);
}
#pianoroll-container {
  flex: 1;
  min-height: 120px;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
#paramlane-container {
  height: 190px;
  min-height: 120px;
  position: relative;
  overflow: hidden;
  background: #151821;
}
#pianoroll, #paramlane {
  display: block;
  width: 100%;
  height: 100%;
  cursor: default;
}
.param-clear {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 3;
  background: rgba(20, 25, 36, 0.86);
  backdrop-filter: blur(4px);
}

/* 伴奏波形轨（仅一条；再次拖入会替换） */
.audiolane {
  flex: 0 0 92px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  background: #121620;
  border-top: 1px solid var(--line-soft, #262b36);
  position: relative;
}
.audiolane.dragover {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
}
.audiolane-head {
  height: 24px;
  min-height: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line-soft, #262b36);
}
.audiolane-title {
  width: 54px;
  flex: 0 0 54px;
  font-size: 11px;
  color: var(--text-dim);
}
.accomp-gain {
  width: 90px;
  accent-color: var(--accent);
}
.accomp-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}
#audiolane {
  display: block;
  width: 100%;
  flex: 1;
  min-height: 0;
  cursor: grab;
}
#audiolane.dragging {
  cursor: grabbing;
}
.btn-small {
  padding: 1px 7px;
  font-size: 12px;
  line-height: 16px;
}

/* 横向滚动条：与时间轴内容宽度同步，只改变 view.scrollX */
.hscroll {
  flex: 0 0 15px;
  min-height: 15px;
  display: flex;
  align-items: center;
  padding: 0 10px 0 64px;
  background: var(--bg-1);
  border-top: 1px solid var(--line-soft, #262b36);
  user-select: none;
}
.hscroll-track {
  position: relative;
  width: 100%;
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
  touch-action: none;
  outline: none;
}
.hscroll-track:hover {
  background: rgba(255, 255, 255, 0.085);
}
.hscroll-track:focus-visible {
  box-shadow: 0 0 0 1px var(--accent), 0 0 0 3px rgba(91, 140, 255, 0.22);
}
.hscroll-thumb {
  position: absolute;
  left: 0;
  top: 2px;
  height: 8px;
  min-width: 32px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(120, 160, 255, 0.85), rgba(91, 140, 255, 0.95));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  cursor: grab;
  transition: background 0.12s ease;
}
.hscroll-thumb:hover,
.hscroll-track.is-dragging .hscroll-thumb {
  background: linear-gradient(90deg, rgba(150, 185, 255, 0.95), rgba(120, 160, 255, 1));
}
.hscroll-track.is-dragging .hscroll-thumb {
  cursor: grabbing;
}
.hscroll-track.is-disabled {
  opacity: 0.38;
  cursor: default;
}
.hscroll-track.is-disabled .hscroll-thumb {
  cursor: default;
  background: rgba(255, 255, 255, 0.22);
}
#btn-reverb.active {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(91, 140, 255, 0.25) inset;
}
.reverb-level {
  width: 82px;
  accent-color: var(--accent);
  opacity: 0.95;
}
.reverb-level:disabled {
  opacity: 0.35;
}

/* ---------- statusbar ---------- */
#statusbar {
  height: var(--status-h);
  min-height: var(--status-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  background: var(--bg-1);
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-dim);
  overflow: hidden;
  white-space: nowrap;
}

/* ---------- floating lyric editor ---------- */
.floating {
  position: fixed;
  z-index: 50;
  background: var(--bg-2);
  border: 1px solid #4a5264;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.55);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
}
.floating-label { font-size: 11px; color: var(--text-dim); }
.floating .input { width: 100%; }
.floating-hint { font-size: 10px; color: #6f7a8c; }

/* ---------- overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(8, 10, 15, .62);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.overlay[hidden] { display: none; }
.overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px 30px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 60px rgba(0,0,0,.6);
  min-width: 260px;
}
.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.12);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.overlay-progress {
  width: 240px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  overflow: hidden;
}
.overlay-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #7aa2ff);
  transition: width 180ms ease-out;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toast ---------- */
.toast-container {
  position: fixed;
  right: 16px;
  bottom: 42px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: min(460px, calc(100vw - 32px));
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 220px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
  font-size: 12px;
  line-height: 1.45;
  animation: toast-in .18s ease;
  cursor: pointer;
  word-break: break-word;
}
.toast-icon { flex: 0 0 auto; line-height: 1.45; opacity: .9; }
.toast-message { flex: 1; }
.toast.success { border-left-color: var(--good); }
.toast.success .toast-icon { color: var(--good); }
.toast.warn { border-left-color: var(--warn); }
.toast.warn .toast-icon { color: var(--warn); }
.toast.error { border-left-color: var(--bad); }
.toast.error .toast-icon { color: var(--bad); }
.toast-out { opacity: 0; transform: translateY(6px); transition: opacity .16s ease, transform .16s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- canvas / editor 细节 ---------- */
#pianoroll, #paramlane { outline: none; touch-action: none; }
#pianoroll:focus-visible, #paramlane:focus-visible { box-shadow: inset 0 0 0 1px rgba(91,140,255,.45); }
.hint { opacity: .7; }
#paramlane-container { border-top: 1px solid var(--line-soft, #262b36); }

/* 参数面板顶部小标签 */
.statusbar .grow { flex: 1; }

[hidden] { display: none !important; }

/* small screens */
@media (max-width: 1100px) {
  #toolbar { gap: 6px; padding: 0 6px; }
  .tool-group { gap: 3px; }
  .brand-mark { width: 24px; height: 24px; }
  .progress { min-width: 84px; max-width: 190px; }
  .account { padding: 4px 7px; font-size: 11px; }
  #transport { gap: 5px; padding: 0 6px; }
  .reverb-level { width: 64px; }
  .project-name { max-width: 140px; }
  #statusbar .hint { display: none; }
}

@media (max-width: 850px) {
  #toolbar { gap: 5px; }
  .field > span { display: none; }
  #sel-model { max-width: 108px; }
  .input-num { width: 58px; }
  .progress { min-width: 64px; max-width: 120px; }
  .progress-text { display: none; }
  #time-display { min-width: 84px; font-size: 12px; padding: 3px 6px; }
  .project-name { max-width: 100px; }
  #playhead-info { display: none; }
}

@media (max-width: 650px) {
  .brand-mark { width: 22px; height: 22px; }
  #toolbar { gap: 4px; }
  .btn-icon { width: 28px; min-width: 28px; height: 28px; }
  #btn-play, #btn-stop { width: 28px; min-width: 28px; }
  #sel-model { max-width: 92px; }
  .reverb-level { width: 52px; }
  #zoom-info { display: none; }
  .param-clear { padding: 1px 5px; }
}
