:root {
  --bg: #fbf7f0;
  --card: #ffffff;
  --ink: #2b2633;
  --muted: #7a7285;
  --line: #e8e0d4;
  --left: #f2665b;
  --right: #2f9e9a;
  --good: #2f9e5a;
  --warn: #e0a020;
  --bad: #e5484d;
  --body: #fffaf0;
  --body-edge: #d9cdb8;
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Nunito, system-ui, sans-serif;
  font-size: 17px;
}

h1, h2, .heard-letter, .btn, .note-btn { font-family: Fredoka, Nunito, sans-serif; }

[hidden] { display: none !important; }

.top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px 28px;
  padding: 18px 32px 4px;
}
.brand { display: flex; align-items: baseline; gap: 14px; }
.top h1 { margin: 0; font-size: 30px; font-weight: 600; }
.who { margin: 0; color: var(--muted); }

.tabs { display: flex; gap: 4px; background: var(--line); padding: 4px; border-radius: 14px; }
.tab {
  border: 0;
  background: transparent;
  font-family: Fredoka, sans-serif;
  font-size: 18px;
  font-weight: 500;
  color: var(--muted);
  padding: 6px 20px;
  border-radius: 10px;
  cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / 0.08); }

.mic { display: flex; align-items: center; gap: 12px; margin-left: auto; min-width: 280px; }

.notes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 32px;
}
.note-btn {
  border: 2px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
  transition: transform 0.12s, border-color 0.12s;
}
.note-btn small { font-family: Nunito, sans-serif; font-size: 11px; color: var(--muted); }
.note-btn:hover { transform: translateY(-2px); }
.note-btn[aria-pressed="true"] {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, white);
  box-shadow: 0 3px 0 var(--c);
}

.stage {
  display: grid;
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
  gap: 24px;
  padding: 8px 32px 32px;
  align-items: start;
}
@media (max-width: 820px) {
  .stage { grid-template-columns: 1fr; padding: 8px 16px 24px; }
  .notes, .top { padding-left: 16px; padding-right: 16px; }
}

.recorder-card, .note-head, .listen {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.recorder-card { padding: 12px 12px 16px; }
#recorder, #song-recorder { width: 100%; height: auto; max-height: calc(100vh - 230px); min-height: 420px; display: block; }
.tuner-scale { display: flex; justify-content: space-between; }

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  font-size: 14px;
  color: var(--muted);
}
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.dot.left { background: var(--left); }
.dot.right { background: var(--right); }
.dot.open { border: 2px solid var(--ink); }

.info { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; min-width: 0; }

.note-head {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  align-items: center;
  padding: 16px 24px;
}
#staff { width: 100%; height: auto; }
.eyebrow {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}
#note-name { margin: 2px 0 6px; font-size: 44px; font-weight: 600; }
.finger-list { margin: 0 0 14px; color: var(--muted); }
.finger-list b { color: var(--ink); }

.btn {
  border: 0;
  background: var(--ink);
  color: white;
  font-size: 18px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 12px;
  cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--ink); border: 2px solid var(--line); }
.btn.on { background: var(--bad); }
kbd {
  font-family: Nunito, sans-serif;
  font-size: 11px;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 6px;
  opacity: 0.6;
}

.listen { padding: 20px 24px; display: grid; gap: 18px; }
.level { flex: 1; height: 10px; border-radius: 6px; background: var(--line); overflow: hidden; }
#level-bar { height: 100%; width: 0; background: var(--right); transition: width 0.06s linear; }

.heard { display: grid; grid-template-columns: 160px 1fr; gap: 24px; align-items: center; }
.heard-letter { margin: 0; font-size: 64px; font-weight: 600; line-height: 1.1; }

.tuner-track { position: relative; height: 26px; border-radius: 14px; background: var(--line); margin-top: 8px; }
.tuner-zone { position: absolute; left: 40%; width: 20%; top: 0; bottom: 0; background: color-mix(in srgb, var(--good) 30%, transparent); border-radius: 14px; }
.tuner-dot {
  position: absolute;
  top: 3px;
  left: 50%;
  width: 20px;
  height: 20px;
  margin-left: -10px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0;
  transition: left 0.08s linear, background 0.15s, opacity 0.15s;
}
.tuner-dot.show { opacity: 1; }

.feedback {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--bg);
  min-height: 62px;
}
.feedback.good { background: color-mix(in srgb, var(--good) 15%, white); color: #1d6b3d; }
.feedback.warn { background: color-mix(in srgb, var(--warn) 18%, white); color: #7a5400; }
.feedback.bad { background: color-mix(in srgb, var(--bad) 12%, white); color: #9b2226; }

.hold-track { height: 14px; border-radius: 8px; background: var(--line); overflow: hidden; margin-top: 8px; }
#hold-bar { height: 100%; width: 0; background: var(--good); }
.stars { display: flex; gap: 6px; margin-top: 10px; min-height: 30px; flex-wrap: wrap; }
.stars svg { width: 28px; height: 28px; }
.stars svg.new { animation: pop 0.5s ease-out; }
@keyframes pop { 0% { transform: scale(0.2) rotate(-30deg); } 70% { transform: scale(1.3); } 100% { transform: scale(1); } }

.mic-details { font-size: 14px; color: var(--muted); }
.mic-details summary { cursor: pointer; }
.mic-details dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 10px 0 0; }
.mic-details dd { margin: 0; font-variant-numeric: tabular-nums; color: var(--ink); }

/* Recorder drawing */
.hole { stroke: var(--ink); stroke-width: 2.5; fill: white; transition: fill 0.2s; }
.hole.left { fill: var(--left); stroke: color-mix(in srgb, var(--left) 70%, black); }
.hole.right { fill: var(--right); stroke: color-mix(in srgb, var(--right) 70%, black); }
.half-fill.left { fill: var(--left); }
.hint-ring { fill: none; stroke-width: 4; stroke-dasharray: 6 5; animation: spin 1.2s linear infinite, pulse 1s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
.hint-ring.cover { stroke: var(--bad); }
.hint-ring.lift { stroke: var(--warn); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { from { opacity: 0.5; } to { opacity: 1; } }
.hole-label { font-size: 15px; fill: var(--muted); font-family: Nunito, sans-serif; }
.hole-label b, .hole-num { font-weight: 700; }
.hole-label.on.left { fill: var(--left); }
.hole-label.on.right { fill: var(--right); }
.hint-label { font-size: 14px; font-weight: 700; font-family: Nunito, sans-serif; }
.hint-label.cover { fill: var(--bad); }
.hint-label.lift { fill: #b07d00; }

/* Songs */
.song-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 18px 32px 32px;
}
.song-card {
  text-align: left;
  border: 2px solid var(--line);
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  display: grid;
  gap: 10px;
  transition: transform 0.12s, border-color 0.12s;
}
.song-card:hover { transform: translateY(-2px); border-color: var(--ink); }
.song-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.song-card h3 { margin: 0; font-family: Fredoka, sans-serif; font-weight: 600; font-size: 22px; }
.badge { background: #fde68a; color: #7a5400; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.song-card-meta { margin: 0; color: var(--muted); font-size: 15px; }
.note-dots { display: flex; gap: 6px; flex-wrap: wrap; }
.note-dots span {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 18%, white);
  color: color-mix(in srgb, var(--c) 75%, black);
  border: 2px solid var(--c);
  font-family: Fredoka, sans-serif; font-weight: 600; font-size: 14px;
}
.note-dots span.fresh { box-shadow: 0 0 0 3px #fde68a; }
.star-row { display: flex; gap: 4px; }
.star-row svg { width: 22px; height: 22px; }

.song-now-line { margin: 4px 8px 0; font-family: Fredoka, sans-serif; font-size: 34px; font-weight: 600; text-align: center; }
.song-next { font-family: Nunito, sans-serif; font-size: 16px; font-weight: 600; color: var(--muted); }

.player-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px 18px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 20px;
}
.player-head h2 { margin: 0; font-size: 28px; font-weight: 600; flex: 1; }
.player-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.small { font-size: 15px; padding: 6px 12px; }

.track-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 12px; }
.track { position: relative; display: flex; gap: 6px; overflow-x: auto; padding: 10px 4px 14px; scrollbar-width: thin; }
.tnote {
  flex: 0 0 calc(34px + var(--beats) * 22px);
  display: grid; justify-items: center; gap: 6px;
  transition: transform 0.15s, opacity 0.2s;
}
.tnote.phrase-end { margin-right: 18px; }
.tnote .tl {
  width: 100%; height: 52px; border-radius: 12px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 16%, white);
  border: 2px solid color-mix(in srgb, var(--c) 55%, white);
  color: color-mix(in srgb, var(--c) 75%, black);
  font-family: Fredoka, sans-serif; font-weight: 600; font-size: 22px;
}
.tnote .ly { font-size: 14px; color: var(--muted); white-space: nowrap; }
.tnote.done { opacity: 0.4; }
.tnote.done .tl { background: color-mix(in srgb, var(--good) 15%, white); border-color: var(--good); }
.tnote.now, .tnote.demo { transform: translateY(-6px); }
.tnote.now .tl, .tnote.demo .tl { background: var(--c); border-color: var(--c); color: white; box-shadow: 0 4px 0 color-mix(in srgb, var(--c) 60%, black); }
.tnote.now .ly, .tnote.demo .ly { color: var(--ink); font-weight: 700; }
.track-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; }

.song-done {
  background: color-mix(in srgb, #fde68a 45%, white);
  border: 2px solid #f5b301; border-radius: var(--radius);
  padding: 20px 24px; display: grid; gap: 8px; justify-items: start;
}
.song-done h2 { margin: 0; font-size: 30px; }
.song-done p { margin: 0; }
#done-stars .star-row svg { width: 40px; height: 40px; animation: pop 0.5s ease-out both; }
#done-stars .star-row svg:nth-child(2) { animation-delay: 0.15s; }
#done-stars .star-row svg:nth-child(3) { animation-delay: 0.3s; }
.tip { margin: 0; color: var(--muted); font-size: 14px; }
