:root {
  --bg: #0f1216;
  --panel: #171b21;
  --line: #262c35;
  --text: #e7ebf0;
  --muted: #8b95a5;
  --low: #4ea1ff;
  --mid: #e7ebf0;
  --high: #ff7a59;
  --sharp: #ffd166;
  --out: #ff4d6d;
  --accent: #5bd18a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.top { padding: 24px 24px 8px; }
.top h1 { margin: 0 0 4px; font-size: 26px; }
.sub { margin: 0; color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
  padding: 16px 24px 24px;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.panel h2 {
  font-size: 15px;
  margin: 18px 0 10px;
  color: var(--muted);
  font-weight: 600;
}
.panel h2:first-child { margin-top: 0; }

.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tab {
  flex: 1;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}
.tab.active { color: var(--text); border-color: var(--accent); }

.drop {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  text-align: center;
  padding: 22px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
}
.drop strong { color: var(--text); }
.drop.over { border-color: var(--accent); background: rgba(91, 209, 138, 0.08); }

textarea, select, input[type="text"], input:not([type]) {
  width: 100%;
  background: #0f1216;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  flex-wrap: wrap;
}
.row label { color: var(--muted); font-size: 14px; }
.row input[type="range"] { flex: 1; min-width: 100px; }
.row output { min-width: 28px; text-align: right; font-variant-numeric: tabular-nums; }

.btn {
  background: var(--accent);
  color: #0b1a10;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 500;
  margin-top: 0;
}
#record { margin-top: 8px; }
.btn:hover { filter: brightness(1.1); }

.keys { display: grid; gap: 8px; font-size: 14px; }
.keys div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.keys input { width: 150px; padding: 4px 8px; }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid;
}
.tag.low { color: var(--low); border-color: var(--low); }
.tag.mid { color: var(--mid); border-color: var(--muted); }
.tag.high { color: var(--high); border-color: var(--high); }
.tag.sharp { color: var(--sharp); border-color: var(--sharp); }

.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }

.score-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.score-head h2 { margin: 0; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.speed { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.speed input { width: 90px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin: 12px 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.low { background: var(--low); }
.dot.mid { background: var(--mid); }
.dot.high { background: var(--high); }
.dot.sharp { background: var(--sharp); }
.dot.out { background: var(--out); }

.stats { color: var(--muted); font-size: 13px; margin-bottom: 8px; min-height: 20px; }
.stats b { color: var(--text); }

.score {
  background: #0f1216;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  min-height: 200px;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
}
.empty { color: var(--muted); text-align: center; margin: 60px 0; }

.bar {
  display: inline-flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 12px 12px 10px;
  margin: 0 8px 12px 0;
  border-left: 2px solid var(--line);
  vertical-align: top;
}

.note {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 26px;
  padding: 14px 4px 14px;
  border-radius: 6px;
  font-size: 22px;
  line-height: 1;
  color: var(--mid);
}
.note.low { color: var(--low); }
.note.high { color: var(--high); }
.note.out { color: var(--out); text-decoration: line-through; }
.note.playing { background: rgba(91, 209, 138, 0.22); }

.note .num { font-weight: 600; }
.note .sharp { position: absolute; left: -2px; top: 14px; font-size: 13px; color: var(--sharp); }
.note .oct { position: absolute; left: 50%; transform: translateX(-50%); font-size: 18px; line-height: 1; font-weight: 700; }
.note.low .oct { bottom: 0; }
.note.high .oct { top: 0; }

.rest { color: var(--muted); }

.text-out {
  margin-top: 12px;
  background: #0f1216;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  white-space: pre-wrap;
  font-size: 14px;
  color: var(--text);
}

.foot { color: var(--muted); font-size: 12px; padding: 0 24px 24px; }
