:root {
  --bg: #F5F4F0;
  --card: #FFFFFF;
  --ink: #2B2D42;
  --muted: #6B7380;
  --line: #E6E3DC;
  --accent: #2B2D42;
  --coral: #EF8354;
  --teal: #2A9D8F;
  --amber: #B7791F;
  --purple: #7B5EA7;
  --red: #C53030;
  --soft: #EFEDE8;
  --shadow: 0 1px 2px rgba(43, 45, 66, .04), 0 8px 24px -12px rgba(43, 45, 66, .18);
  --r: 16px;
  --sans: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; margin-bottom: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--red); margin: 8px 0 0; font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; max-width: 920px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 9px; }
.brand b { display: block; font-size: 17px; }
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: -2px; }

main { max-width: 920px; margin: 0 auto; padding: 0 14px 60px; display: grid; gap: 14px; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; }
.step { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.num { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.tips ul { margin: 6px 0 0; padding-left: 18px; }
.tips li { margin: 4px 0; }

.btn { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 9px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background .15s; }
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #3d4060; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; border-radius: 9px; font-size: 13px; }

/* record */
.rec-wrap { display: flex; align-items: center; gap: 18px; }
.rec { width: 78px; height: 78px; border-radius: 50%; border: 0; background: #fff; box-shadow: 0 0 0 3px var(--line) inset; cursor: pointer; display: grid; place-items: center; flex: none; }
.rec .dot { width: 46px; height: 46px; border-radius: 50%; background: #E0443E; transition: all .2s; }
.rec.on .dot { border-radius: 8px; width: 30px; height: 30px; }
.rec.on { box-shadow: 0 0 0 3px #E0443E inset; animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 3px #E0443E inset, 0 0 0 0 rgba(224, 68, 62, .4); } 100% { box-shadow: 0 0 0 3px #E0443E inset, 0 0 0 14px rgba(224, 68, 62, 0); } }
.rec-info { flex: 1; min-width: 0; }
.live-note { font-size: 28px; font-weight: 600; letter-spacing: -.02em; min-height: 36px; font-variant-numeric: tabular-nums; }
.live-note small { font-size: 14px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.meter { height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; margin: 6px 0; }
.meter div { height: 100%; width: 0; background: var(--teal); transition: width .08s; }
.or { margin-top: 14px; }
.progress { margin-top: 12px; display: flex; align-items: center; gap: 10px; }
.progress .bar { flex: 1; height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; }
.progress .bar div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* melody */
.summary { font-size: 14px; }
.summary b { font-size: 16px; }
.key-pick select { margin-left: 4px; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.roll-wrap { margin: 12px 0; }
#roll { width: 100%; height: 280px; display: block; border-radius: 12px; background: #FBFAF7; border: 1px solid var(--line); touch-action: manipulation; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.note-tools { display: flex; align-items: center; gap: 6px; background: var(--soft); border-radius: 12px; padding: 8px 10px; margin-bottom: 10px; }
.note-tools b { min-width: 70px; }

/* harmony */
.panel { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.panel:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 14px; }
.chip:has(:checked) { background: var(--accent); color: #fff; border-color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chips button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 11px; font-size: 13px; cursor: pointer; }
.chips button:hover { background: var(--soft); }
.ask { display: flex; gap: 8px; align-items: stretch; }
.ask textarea { flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; resize: vertical; min-height: 54px; }
.ask textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.reply { margin-top: 10px; background: var(--soft); border-radius: 12px; padding: 10px 12px; font-size: 14px; white-space: pre-wrap; }
.reply.err { color: var(--red); background: #FBE9E7; }
.reply.wait::before { content: ""; display: inline-block; width: 12px; height: 12px; border: 2px solid var(--muted); border-right-color: transparent; border-radius: 50%; margin-right: 8px; vertical-align: -2px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.parts { display: grid; gap: 6px; margin: 10px 0 12px; }
.part { display: grid; grid-template-columns: 14px 1fr auto auto 110px auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; }
.part .sw { width: 14px; height: 14px; border-radius: 4px; }
.part .nm b { display: block; }
.part .nm small { color: var(--muted); font-size: 12px; }
.part .tg { border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-size: 12px; font-weight: 600; }
.part .tg.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.part input[type=range] { width: 110px; }
.part.off { opacity: .5; }
.downloads { margin-top: 10px; }
#timbre { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; margin-left: 4px; }

@media (max-width: 600px) {
  .top { padding: 12px 14px; }
  .top .btn { padding: 7px 10px; font-size: 13px; }
  .card { padding: 14px; }
  .part { grid-template-columns: 12px 1fr auto auto; grid-template-rows: auto auto; }
  .part input[type=range] { grid-column: 2 / span 2; width: 100%; }
  .part .dl { grid-column: 4; grid-row: 2; }
  .ask { flex-direction: column; }
  #roll { height: 240px; }
}

.credit { text-align: center; padding: 8px 0 0; }
.credit a { color: var(--muted); }
#voice-status.err { color: var(--red); }
