/* ============ 全局：Tailwind 风格白底 ============ */
:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --card: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #1a756a;
  --accent-hover: #156358;
  --accent-light: #e6f2f0;
  --accent2: #f59e0b;
  --ok: #22c55e;
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ============ 顶栏 ============ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 28px; color: var(--accent); }
.brand h1 { font-size: 18px; font-weight: 700; color: #0f172a; letter-spacing: -0.3px; }
.subtitle { color: var(--muted); font-size: 13px; font-weight: 400; }
.model-status {
  font-size: 12px; padding: 5px 14px; border-radius: 9999px;
  background: #f1f5f9; border: 1px solid var(--border); color: var(--muted);
  font-weight: 500; transition: all .2s;
}
.model-status.loaded { color: #16a34a; border-color: #bbf7d0; background: #f0fdf4; }
.model-status.loading { color: #d97706; border-color: #fde68a; background: #fffbeb; }

/* ============ 布局 ============ */
.layout {
  flex: 1; display: flex; min-height: 0;
}
.panel { overflow-y: auto; }
.input-panel {
  width: 340px; min-width: 300px; padding: 16px;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 14px;
  background: var(--panel);
}
.score-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.card {
  background: var(--card); border: 1px solid var(--border-light);
  border-radius: 10px; padding: 16px;
  box-shadow: var(--shadow-sm);
}
.card h2 { font-size: 13px; margin-bottom: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

/* ============ 上传区 ============ */
.dropzone {
  border: 2px dashed var(--border); border-radius: 10px;
  padding: 24px 16px; text-align: center; cursor: pointer;
  transition: all .2s; color: var(--muted); font-size: 14px;
  background: #fafbfc;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-light);
}
.dropzone .hint { font-size: 12px; margin-top: 6px; color: #94a3b8; }
.rec-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.rec-time { font-size: 12px; color: var(--accent2); font-weight: 500; }

/* ============ 表单 ============ */
.field { display: block; margin-bottom: 10px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
select, input[type="number"] {
  width: 100%; padding: 7px 10px; border-radius: 8px;
  background: #fff; color: var(--text);
  border: 1px solid var(--border); font-size: 13px;
  transition: border-color .15s; outline: none;
}
select:focus, input[type="number"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,117,106,.12); }
.mini-field { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }

/* ============ 按钮 ============ */
.btn {
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s; outline: none;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #f8fafc; border-color: #cbd5e1; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  font-weight: 600; width: 100%; margin-top: 10px;
  box-shadow: var(--shadow-sm);
}
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ============ 波形 / 进度 ============ */
#waveform { width: 100%; height: 80px; background: #f1f5f9; border-radius: 8px; margin-top: 8px; display: block; border: 1px solid var(--border-light); }
.progress { height: 6px; background: #f1f5f9; border-radius: 9999px; margin-top: 10px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--accent); transition: width .3s; border-radius: 9999px; }
.status { font-size: 12px; color: var(--muted); margin-top: 8px; min-height: 16px; }

/* ============ 工具栏 ============ */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.view-tabs { display: flex; gap: 4px; background: #f1f5f9; border-radius: 10px; padding: 3px; }
.tab {
  padding: 7px 20px; border-radius: 8px; border: none;
  background: transparent; color: var(--muted); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all .15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ctrl-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.export-bar { border-bottom: none; border-top: 1px solid var(--border); }
#selInfo { margin-left: auto; font-size: 12px; }

/* ============ 乐谱区域 ============ */
.score-area { flex: 1; overflow: auto; padding: 24px; background: #f1f5f9; }
#scoreContainer { min-height: 200px; }
.empty-hint { text-align: center; color: var(--muted); margin-top: 80px; line-height: 2; }
.empty-hint p:first-child { font-size: 18px; font-weight: 500; color: #94a3b8; }

/* 简谱样式（simple-notation） */
.jianpu-wrap {
  background: #fff; color: #111; border-radius: 12px; padding: 24px;
  display: inline-block; min-width: 100%;
  box-shadow: var(--shadow);
}
/* simple-notation 内部 SVG 样式适配 */
.jianpu-wrap svg { display: block; overflow: visible; }
.jianpu-wrap text[text-anchor="start"] { font-family: system-ui, "Microsoft YaHei", sans-serif; }

/* 五线谱样式（abcjs） */
.staff-wrap {
  background: #fff; border-radius: 12px; padding: 28px;
  display: inline-block; min-width: 100%; color: #111;
  box-shadow: var(--shadow);
}
.staff-wrap svg { display: block; margin: 0 auto; color: #111; }
.staff-wrap .abc-host { width: 100%; }
.staff-wrap .vf-note { cursor: pointer; }
.staff-wrap .vf-note.selected path { fill: var(--accent) !important; }
.staff-wrap .vf-note.playing path { fill: var(--danger) !important; }

/* ============ 页脚 ============ */
.footer {
  text-align: center; font-size: 12px; color: var(--muted);
  padding: 10px; border-top: 1px solid var(--border);
  background: var(--panel);
}

/* ============ 打印 ============ */
@media print {
  body { background: #fff; }
  .topbar, .input-panel, .toolbar, .footer, .model-status { display: none !important; }
  .layout { display: block; }
  .score-panel { overflow: visible; }
  .score-area { padding: 0; background: #fff; }
  #scoreContainer { min-height: 0; }
  .empty-hint { display: none; }
}
