:root {
  color-scheme: dark;
  --bg: #14171c;
  --panel: #1c2128;
  --panel-border: #2c333d;
  --text: #e6e9ef;
  --text-dim: #9aa4b2;
  --accent: #4fc3f7;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

body {
  display: flex;
  justify-content: center;
}

.hidden { display: none !important; }
#playBtn,
#pauseBtn,
#playbackStatus {
  display: none !important;
}

/* ---------- Admin ---------- */

.admin-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 8, 12, 0.78);
}
.admin-panel {
  width: min(460px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border: 1px solid #526071;
  border-radius: 8px;
  background: #171c22;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}
.admin-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #39424e;
}
.admin-panel-head h2 {
  margin: 0;
  font-size: 18px;
}
.admin-close-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #526071;
  border-radius: 7px;
  background: #202830;
  color: #e8eef7;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.admin-close-btn:hover {
  border-color: #ff8a65;
  color: #ffb3a1;
}
.admin-settings {
  padding: 14px;
}
.admin-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid #39424e;
  border-radius: 7px;
  background: #11161c;
  color: #e6e9ef;
  font-weight: 700;
}
.admin-setting-row input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: #4fc3f7;
}

/* ---------- Dropzone ---------- */

#dropzone {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  pointer-events: none;
}
#dropzone:has(#emptyState:not(.hidden)) {
  pointer-events: auto;
}
#dropzone.dragging {
  background: rgba(79, 195, 247, 0.08);
  pointer-events: auto;
}
#dropzone.dragging::after {
  content: "";
  position: absolute;
  inset: 16px;
  border: 3px dashed var(--accent);
  border-radius: 16px;
}

#emptyState {
  text-align: center;
  padding: 48px;
  border: 2px dashed var(--panel-border);
  border-radius: 20px;
  background: var(--panel);
}
#emptyState .drop-icon { font-size: 56px; margin-bottom: 8px; }
#emptyState h1 { font-size: 22px; margin: 8px 0; font-weight: 600; }
#emptyState p { color: var(--text-dim); margin: 0; }
#emptyState code {
  background: #0f1216;
  padding: 2px 6px;
  border-radius: 4px;
}
.upload-prompt {
  display: inline-flex;
  margin-top: 18px;
  padding: 9px 16px;
  border: 1px solid #69bce8;
  border-radius: 7px;
  background: #173246;
  color: #e5f7ff;
  font-weight: 800;
}
#emptyState .empty-search {
  justify-content: center;
  margin: 18px 0 0;
}
#emptyState .empty-search input {
  max-width: none;
}

/* ---------- Error banner ---------- */

#errorBanner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #3a1c1c;
  border: 1px solid #7a3030;
  color: #ffb3b3;
  padding: 10px 18px;
  border-radius: 10px;
  z-index: 20;
  max-width: 80vw;
}

/* ---------- Layout ---------- */

#appMain {
  display: flex;
  flex-direction: column;
  width: min(100%, 1440px);
  height: 100%;
  margin-inline: auto;
  border-inline: 1px solid var(--panel-border);
}

.menu-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #11151a;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}
.menu-bar button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.menu-bar button:hover {
  color: var(--text);
  border-color: var(--panel-border);
}
.menu-bar button:disabled {
  opacity: 0.45;
  cursor: default;
}
.midi-search {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}
.midi-search input {
  width: 210px;
  max-width: 26vw;
  background: #0f1216;
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 8px;
}
.midi-search input:focus {
  outline: none;
  border-color: var(--accent);
}
.midi-search button {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.midi-search button:hover {
  color: var(--text);
  border-color: var(--accent);
}
.print-menu-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 5px 7px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(15, 18, 22, 0.68);
}
.print-count {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 12px;
}
.print-count select {
  background: #0f1216;
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 8px;
}
.print-count select:focus {
  outline: none;
  border-color: var(--accent);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel);
  flex-shrink: 0;
}
.file-info { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.file-icon { font-size: 18px; }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar button {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.topbar button:hover { border-color: var(--accent); }
.audio-status {
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  white-space: nowrap;
}
.audio-status.ok { color: #8bd17c; border-color: #3a5a34; }
.audio-status.blocked { color: #ffb3b3; border-color: #7a3030; }

.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

.teacher-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--panel-border);
  background: #171c22;
  flex-shrink: 0;
}
.teacher-title {
  display: flex;
  align-items: baseline;
  min-width: 0;
  gap: 12px;
}
.teacher-title strong {
  color: #edf5fc;
  font-size: 20px;
}
.teacher-title #fileNameLabel {
  overflow: hidden;
  color: #9fb3c8;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.teacher-header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
.teacher-header button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid #405064;
  border-radius: 7px;
  background: #202830;
  color: #e8eef7;
  cursor: pointer;
}
.teacher-header button:hover {
  border-color: var(--accent);
}
.teacher-midi-library {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #aebdca;
  font-size: 12px;
  white-space: nowrap;
}
.teacher-header #midiLibrarySelect {
  width: clamp(150px, 18vw, 240px);
  min-height: 34px;
  margin: 0;
  padding: 6px 28px 6px 8px;
  border: 1px solid #405064;
  border-radius: 7px;
  background: #10151b;
  color: #e8eef7;
  text-overflow: ellipsis;
}
.teacher-header #removeMidiBtn:disabled {
  cursor: default;
  opacity: 0.45;
}
.teacher-layout {
  min-width: 0;
}
.teacher-layout #playbackArea {
  width: 100%;
  padding: 8px;
  gap: 8px;
}
.score-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  color: #aebdca;
  font-size: 11px;
}
.score-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.teacher-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.teacher-color.playback { background: #1f6feb; }
.teacher-color.student { background: #f97316; }
.teacher-console {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.teacher-timeline {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 100%;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(15, 18, 22, 0.55);
}
.teacher-timeline #seekBar {
  min-width: 160px;
}
.teacher-playback-controls {
  flex: 1 1 auto;
}
.teacher-lesson-controls {
  flex: 1 1 100%;
}
.teacher-settings {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 4px 6px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(15, 18, 22, 0.55);
}
.teacher-settings select {
  min-height: 30px;
  border: 1px solid #405064;
  border-radius: 6px;
  background: #10151b;
  color: #e8eef7;
}
.teacher-timeline .teacher-settings {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 0;
  border: 0;
  background: transparent;
}
.teacher-timeline .tool-select,
.teacher-timeline .tempo-joystick {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
}
.teacher-timeline .tempo-joystick {
  flex: 0 0 auto;
  grid-template-rows: none;
  justify-items: initial;
  padding: 0;
  border: 0;
  background: transparent;
}
.teacher-timeline .tempo-arrow {
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
}
.teacher-timeline #tempoValue {
  width: 42px;
  min-width: 42px;
}
.teacher-layout #keyboardScroll.sheet-mode {
  flex: 1 1 auto;
  min-height: 370px;
}
.teacher-layout #keyboardScroll.sheet-mode #notationHost {
  flex: 1 1 auto;
  min-height: 200px;
}
body.learn-song-active .teacher-header {
  display: none;
}

@media (max-width: 900px) {
  .teacher-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .teacher-header-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .score-legend {
    display: none;
  }
}

/* ---------- Track panel ---------- */

#trackPanel {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--panel-border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.library-panel {
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 10px;
}
.track-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
}
#midiLibrarySelect {
  width: calc(100% - 32px);
  margin: 0 16px;
  background: #0f1216;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 7px;
}
.track-panel-header h2 { font-size: 14px; margin: 0; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.track-panel-actions button {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  margin-left: 4px;
}
.track-panel-actions button:hover { color: var(--text); border-color: var(--accent); }

#trackList {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 16px;
}

.track-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.track-row:hover { background: rgba(255,255,255,0.04); }
.track-row input { flex-shrink: 0; accent-color: var(--accent); }
.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.track-label {
  flex: 1;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.track-meta {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* ---------- Playback area ---------- */

#playbackArea {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px;
  gap: 12px;
  overflow-y: auto;
}

#keyboardScroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 10px;
  background: #0f1216;
  border: 1px solid var(--panel-border);
}
.sheet-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-shrink: 0;
  padding: 7px 10px;
  background: #151a20;
  border-bottom: 1px solid var(--panel-border);
}
.display-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(104px, auto));
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  background: rgba(15, 18, 22, 0.65);
}
.display-switch button {
  min-width: 0;
  padding: 6px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #b8d6f2;
  font: inherit;
  cursor: pointer;
}
.display-switch button:hover {
  color: var(--text);
}
.display-switch button.active {
  background: var(--accent);
  color: #0f1216;
  font-weight: 800;
}
.finger-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  padding: 6px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  background: rgba(15, 18, 22, 0.65);
  color: var(--text-dim);
  font-size: 13px;
  white-space: nowrap;
}
.finger-toggle input {
  accent-color: var(--accent);
}
#notationHost {
  flex: 1 1 auto;
  min-height: 0;
  background: #fff1a8;
  border-bottom: 1px solid var(--panel-border);
  overflow: auto;
}
.notation-page {
  width: 100%;
  min-width: 620px;
  flex: 0 0 auto;
  background: #fff1a8;
}
.notation-page + .notation-page {
  border-top: 2px solid rgba(61, 53, 45, 0.28);
}
.notation-line {
  position: relative;
  min-height: 200px;
  overflow: hidden;
  background: #fff1a8;
}
#keyboardScroll.roll-mode #notationHost {
  display: none;
}
#keyboardScroll.sheet-mode #pianoRoll {
  display: none;
}
#keyboardScroll.sheet-mode {
  flex: 0 0 402px;
  min-height: 402px;
}
#keyboardScroll.sheet-mode #notationHost {
  flex: 0 0 200px;
  min-height: 200px;
}
#notationHost svg {
  display: block;
  width: 100%;
  height: 100%;
}
.notation-empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6d6258;
  font-size: 14px;
  font-weight: 600;
}
#pianoRoll {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
}

.learn-song-history {
  flex: 0 0 auto;
  min-height: 118px;
  max-height: 180px;
  padding: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #10151b;
  color: var(--text);
}
.learn-song-history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.learn-song-history-head strong {
  font-size: 16px;
}
.learn-song-history-head span {
  color: #9fb3c8;
  font-size: 12px;
}
.learn-song-history-empty {
  display: flex;
  min-height: 80px;
  align-items: center;
  justify-content: center;
  border: 1px dashed #44515f;
  border-radius: 7px;
  color: #9fb3c8;
  font-weight: 600;
}
.learn-song-parts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.learn-song-part {
  min-width: 0;
  padding: 5px;
  border: 1px solid #536274;
  border-radius: 7px;
  background: #f8fafc;
  color: #152233;
}
.learn-song-part-head {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 3px;
  font-size: 10px;
  font-weight: 800;
}
.learn-song-part-number {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #2f9ce0;
  color: #fff;
}
.learn-song-part-score {
  margin-left: auto;
  color: #315b3b;
  font-size: 9px;
  white-space: nowrap;
}
.learn-song-part .print-keyboard {
  position: relative;
  width: 100%;
  height: 51px;
  overflow: hidden;
}
.learn-song-part .print-key {
  position: absolute;
  top: 0;
  border: 1px solid #777;
  text-align: center;
  font-size: 5px;
  overflow: hidden;
}
.learn-song-part .print-key.white {
  height: 51px;
  background: #fff;
  z-index: 1;
}
.learn-song-part .print-key.black {
  height: 31px;
  background: #111827;
  border-color: #000;
  z-index: 2;
}
.learn-song-part .print-key.white.on.right {
  background: #fecaca;
  border-color: #dc2626;
  box-shadow: inset 0 0 0 999px #fecaca;
}
.learn-song-part .print-key.white.on.left {
  background: #bfdbfe;
  border-color: #2563eb;
  box-shadow: inset 0 0 0 999px #bfdbfe;
}
.learn-song-part .print-key.black.on.right {
  background: #ef7777;
  border-color: #dc2626;
  box-shadow: inset 0 0 0 999px #ef7777;
}
.learn-song-part .print-key.black.on.left {
  background: #2563eb;
  border-color: #2563eb;
  box-shadow: inset 0 0 0 999px #2563eb;
}
.learn-song-part .print-key span {
  position: absolute;
  right: 0;
  bottom: 1px;
  left: 0;
  color: #596675;
}
.learn-song-part-notes {
  margin-top: 3px;
  color: #425466;
  font-size: 8px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

@media (max-width: 1200px) {
  .learn-song-parts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .learn-song-parts {
    grid-template-columns: 1fr;
  }
}

body.learn-song-active .menu-bar,
body.learn-song-active .topbar,
body.learn-song-active #trackPanel {
  display: none;
}
body.learn-song-active #playbackArea {
  padding: 8px;
  gap: 6px;
  overflow: hidden;
}
body.learn-song-active .transport {
  order: 1;
  flex: 0 0 auto;
  gap: 0;
  margin-top: auto;
}
body.learn-song-active .transport > :not(.drill-controls) {
  display: none;
}
body.learn-song-active .transport > .teacher-timeline {
  display: flex;
  flex: 0 0 auto;
  width: auto;
  padding: 3px 6px;
}
body.learn-song-active .teacher-timeline > :not(.teacher-settings),
body.learn-song-active .teacher-settings > .sound-tool-select {
  display: none;
}
body.learn-song-active .teacher-timeline .teacher-settings {
  display: flex;
  margin: 0;
}
body.learn-song-active .drill-controls {
  width: 100%;
  padding: 4px 6px;
}
body.learn-song-active .drill-controls > * {
  display: none;
}
body.learn-song-active .drill-controls > #learnSongBtn,
body.learn-song-active .drill-controls > #repeatLearnBtn,
body.learn-song-active .drill-controls > #learnSoundOutputSwitch,
body.learn-song-active .drill-controls > .learn-part-nav,
body.learn-song-active .drill-controls > #drillPhase {
  display: inline-flex;
}
body.learn-song-active .learn-part-nav {
  align-items: center;
  gap: 2px;
}
body.learn-song-active .learn-part-nav > button {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 6px;
  font-size: 11px;
}
body.learn-song-active .drill-controls > #drillTimer {
  display: block;
}
body.learn-song-active .drill-controls > #drillStatus,
body.learn-song-active .drill-controls > #drillScore {
  display: inline;
}
body.learn-song-active #keyboardScroll {
  order: 0;
}
body.learn-song-active #keyboardScroll #pianoContainer {
  margin-top: auto;
  border-top: 2px solid #405064;
  box-shadow: 0 -5px 12px rgba(0, 0, 0, 0.28);
}

#pianoContainer {
  position: relative;
  flex-shrink: 0;
  margin-top: 4px;
  touch-action: none;
  user-select: none;
}
.live-method-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 8;
  overflow: visible;
  pointer-events: none;
}
.live-method-label {
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.key {
  position: absolute;
  top: 0;
  border-radius: 0 0 5px 5px;
  --active-color: #4fc3f7;
  transition: background 0.06s ease;
}
.mute-marker {
  display: none;
  position: absolute;
  top: 5px;
  left: 50%;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(255,255,255,0.75);
  border-radius: 3px;
  background: rgba(15,18,22,0.7);
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 4;
}
#pianoContainer.mute-mode .mute-marker {
  display: block;
}
.key.muted .mute-marker {
  background: #ff6b6b;
  border-color: #ffb3b3;
}
.key.muted .mute-marker::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 1px;
  width: 4px;
  height: 7px;
  border: solid #1a0d0d;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.key.white {
  background: linear-gradient(to bottom, #f5f5f5, #e2e2e2);
  border: 1px solid #999;
  border-top: none;
  z-index: 1;
}
.key.white.active {
  background: var(--active-color);
  box-shadow: inset 0 -6px 10px rgba(0,0,0,0.25);
}
.key.white.muted {
  background: linear-gradient(to bottom, #b9b9b9, #8d8d8d);
  color: #333;
}
.key.black {
  background: linear-gradient(to bottom, #333, #000);
  border: 1px solid #000;
  z-index: 2;
}
.key.black.active {
  background: var(--active-color);
  box-shadow: inset 0 -6px 10px rgba(0,0,0,0.4);
}
.key.step-required {
  outline: 3px solid #ffd166;
  outline-offset: -4px;
  box-shadow: inset 0 0 0 999px rgba(255, 209, 102, 0.32), inset 0 -6px 10px rgba(0,0,0,0.25);
}
.key.step-hit.active {
  outline-color: #4fc3f7;
  box-shadow: inset 0 0 0 999px rgba(79, 195, 247, 0.46), inset 0 -6px 10px rgba(0,0,0,0.25);
}
.key.step-wrong {
  outline: 3px solid #ff6b6b;
  outline-offset: -4px;
  box-shadow: inset 0 0 0 999px rgba(255, 107, 107, 0.42), inset 0 -6px 10px rgba(0,0,0,0.25);
}
.key.black.muted {
  background: linear-gradient(to bottom, #666, #383838);
}
.key.muted::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 50%;
  height: 2px;
  background: #ff6b6b;
  transform: rotate(-22deg);
}
.key-label {
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 9px;
  color: #888;
  pointer-events: none;
}

/* ---------- Transport ---------- */

.transport {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.transport-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}
.transport-btn:hover { border-color: var(--accent); color: var(--accent); }
.playback-status {
  min-width: 118px;
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
}
.playback-status.paused { color: #ffd54f; }
.playback-status.playing { color: #8bd17c; }
#seekBar { flex: 1; accent-color: var(--accent); }
#curTime, #totalTime {
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  font-size: 13px;
  min-width: 34px;
  text-align: center;
}
.volume-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
}
.volume-label input { accent-color: var(--accent); width: 80px; }
.tool-select {
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1;
}
.tool-select span {
  padding-left: 2px;
}
.house-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1 1 100%;
  min-width: 0;
  max-width: 100%;
  padding: 4px;
  flex-wrap: wrap;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(15, 18, 22, 0.55);
}
.house-controls > button {
  min-height: 40px;
  padding: 5px 7px;
  font-size: 12px;
}
.barline-playback-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  max-width: 100%;
  min-width: 0;
}
.drill-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(15, 18, 22, 0.55);
  color: var(--text-dim);
  font-size: 11px;
  white-space: nowrap;
}
.learn-sound-output {
  display: none;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid #405064;
  border-radius: 7px;
  background: #11161c;
}
.learn-sound-output > button {
  min-width: 94px;
  min-height: 28px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #aebdca;
  font-size: 11px;
  font-weight: 800;
}
.learn-sound-output > button.active {
  border-color: #62b8ff;
  background: #234d70;
  color: #f5fbff;
  box-shadow: inset 0 0 0 1px rgba(126, 200, 255, 0.25);
}
.midi-in-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 8px;
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  background: #11161c;
  color: #8793a2;
  font-size: 11px;
  font-weight: 800;
}
.midi-in-led {
  width: 10px;
  height: 10px;
  border: 1px solid #4b5563;
  border-radius: 50%;
  background: #252b33;
}
.midi-in-indicator.connected {
  color: #b7f4c8;
  border-color: #3f6e50;
}
.midi-in-indicator.connected .midi-in-led {
  border-color: #34d058;
  background: #238636;
  box-shadow: 0 0 5px rgba(52, 208, 88, 0.55);
}
.midi-in-indicator.activity .midi-in-led {
  background: #7cff9b;
  box-shadow: 0 0 10px rgba(124, 255, 155, 0.95);
}
#drillStatus {
  min-width: 180px;
  font-size: 15px;
  font-weight: 750;
  line-height: 1.25;
  white-space: normal;
}
#drillScore {
  color: #b7f4c8;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
  white-space: normal;
}
.drill-timer {
  position: relative;
  flex: 1 1 220px;
  min-width: 140px;
  max-width: 360px;
  height: 18px;
  overflow: hidden;
  border: 1px solid #6e7481;
  border-radius: 999px;
  background: #30343b;
}
.drill-timer-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #35ff70, #ffe450, #ff4c4c);
  transform: scaleX(1);
  transform-origin: left center;
  transition: transform 100ms linear;
}
.drill-timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #111820;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.65);
}
.drill-phase {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: #10151b;
  color: var(--text-dim);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.drill-phase.listen {
  border-color: #4fc3f7;
  color: #dff6ff;
  background: #17324a;
}
.drill-phase.repeat {
  border-color: #ffd166;
  color: #fff2c4;
  background: #4a3417;
}
.drill-phase.result {
  border-color: #8ff0b5;
  color: #d9ffe4;
  background: #15351f;
}
.loop-label,
.mute-label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
  font-size: 13px;
  white-space: nowrap;
}
.loop-label input,
.mute-label input { accent-color: var(--accent); }
.piano-mute-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(15, 18, 22, 0.55);
}
.transport button:not(.transport-btn) {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 5px 8px;
  cursor: pointer;
  white-space: nowrap;
}
.transport button:not(.transport-btn):hover {
  border-color: var(--accent);
  color: var(--accent);
}
#playHouseBtn,
#stepTrainerBtn {
  flex: 0 1 112px;
  width: 112px;
  min-width: 88px;
  min-height: 40px;
  padding: 5px 7px;
  font-size: 14px;
  line-height: 1.1;
  text-align: center;
}
#playHouseBtn {
  margin-left: 0;
  background: #4d2a86;
  border-color: #9d7cff;
  color: #f3edff;
  font-weight: 700;
}
#playChordBtn {
  flex: 0 1 92px;
  width: 92px;
  min-width: 78px;
  min-height: 40px;
  padding: 5px 7px;
  background: #31512a;
  border-color: #9adf86;
  color: #efffe9;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.05;
  text-align: center;
}
#playQuarterBarBtn {
  flex: 0 1 98px;
  width: 98px;
  min-width: 84px;
  min-height: 40px;
  padding: 5px 7px;
  background: #284664;
  border-color: #73b8ef;
  color: #e7f5ff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.05;
  text-align: center;
}
.quarter-arrow-btn {
  flex: 0 1 38px;
  width: 38px;
  min-width: 34px;
  min-height: 40px;
  padding: 4px 0;
  border-radius: 8px;
  background: #102c3f;
  border-color: #72c8ff;
  color: #e8f7ff;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
}
#playFromBarlineBtn {
  flex: 0 1 155px;
  width: 155px;
  min-width: 132px;
  min-height: 40px;
  padding: 5px 8px;
  font-size: 13px;
  line-height: 1.1;
  background: #23435c;
  border-color: #72c8ff;
  color: #e8f7ff;
  font-weight: 700;
  text-align: center;
}
#goToStartBtn {
  flex: 0 0 40px;
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 4px 0;
  background: #29313b;
  border-color: #7f91a5;
  color: #eef4fb;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.05;
  text-align: center;
}
#testBarlineBtn {
  background: #4a3417;
  border-color: #ffd166;
  color: #fff2c4;
  font-weight: 700;
}
#learnSongBtn {
  background: #283f68;
  border-color: #82b5ff;
  color: #eef6ff;
  font-weight: 800;
}
#previousLearnPartBtn,
#repeatLearnBtn,
#skipLearnPartBtn {
  background: #27374b;
  border-color: #8fc5ff;
  color: #eef7ff;
  font-weight: 800;
}
#repeatLearnBtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #243f64;
  border-color: #8fc5ff;
  white-space: nowrap;
}
#repeatLearnBtn .shortcut-hint {
  padding: 2px 5px;
  border: 1px solid rgba(255,255,255,0.32);
  border-radius: 4px;
  background: rgba(0,0,0,0.22);
  color: #dbeeff;
  font-size: 10px;
  line-height: 1;
}
.learn-part-nav {
  display: none;
}
#previousLearnPartBtn {
  background: #313843;
  border-color: #aebdca;
}
#skipLearnPartBtn {
  background: #31512a;
  border-color: #9adf86;
  color: #efffea;
}
#stepTrainerBtn {
  background: #1e3a2a;
  border-color: #8ff0b5;
  color: #e4ffec;
  font-weight: 700;
}
#playStepBtn,
#backStepBtn,
#nextStepBtn {
  background: #1f5fbf;
  border-color: #8fc0ff;
  color: #ffffff;
  font-weight: 700;
  min-height: 40px;
  padding: 4px 7px;
  font-size: 12px;
}
#backStepBtn {
  background: #4d3f1f;
  border-color: #ffd166;
}
#nextStepBtn {
  background: #31512a;
  border-color: #9adf86;
}
#playStepBtn:disabled,
#backStepBtn:disabled,
#nextStepBtn:disabled,
#nextChordArrowBtn:disabled {
  background: #243044;
  border-color: #526071;
  color: #b9c7d9;
  opacity: 0.78;
  cursor: default;
}
.drill-controls button {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 12px;
}
.drill-controls #testBarlineBtn {
  flex: 0 0 auto;
  width: auto;
  min-width: 66px;
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12px;
}
.drill-controls #learnSongBtn {
  flex: 0 0 auto;
  width: auto;
  min-width: 92px;
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12px;
}
.midi-input-mute-label {
  padding: 4px 7px;
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  background: #151a20;
}
.house-controls .barline-stop-btn {
  flex: 0 0 62px;
  min-height: 40px;
  padding: 5px 8px;
  background: #412226;
  border-color: #d7737a;
  color: #ffd5d8;
  font-size: 13px;
  font-weight: 800;
}
#playHouseBtn:hover {
  background: #6236a7;
  border-color: #c0a7ff;
  color: white;
}
#playHouseBtn:disabled {
  background: var(--panel);
  border-color: var(--panel-border);
  color: var(--text-dim);
  font-weight: 400;
  opacity: 0.55;
}
#playChordBtn:disabled {
  background: var(--panel);
  border-color: var(--panel-border);
  color: var(--text-dim);
  opacity: 0.55;
}
#playQuarterBarBtn:disabled {
  background: var(--panel);
  border-color: var(--panel-border);
  color: var(--text-dim);
  opacity: 0.55;
}
.transport button.house-active {
  background: #35c46f;
  border-color: #8ff0b5;
  color: #06160c;
  box-shadow: 0 0 0 2px rgba(53, 196, 111, 0.3), 0 0 18px rgba(53, 196, 111, 0.28);
}
.transport button.mode-active {
  position: relative;
  transform: translateY(1px);
  box-shadow:
    0 0 0 3px #ff4d4d,
    inset 0 2px 12px rgba(0, 0, 0, 0.28),
    0 0 20px rgba(255, 77, 77, 0.34);
}
.transport button.mode-active::after {
  content: '';
  position: absolute;
  inset: -7px;
  border: 2px solid #ff4d4d;
  border-radius: 13px;
  pointer-events: none;
}
#soundSelect,
#houseSelect {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 6px;
}
.tempo-joystick {
  display: grid;
  grid-template-rows: auto 22px 24px 22px;
  justify-items: center;
  flex: 0 0 54px;
  padding: 3px 4px 4px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(15, 18, 22, 0.72);
}
.tempo-title {
  color: var(--text-dim);
  font-size: 10px;
  line-height: 12px;
}
.transport .tempo-arrow {
  width: 42px;
  min-height: 22px;
  padding: 0;
  border-radius: 5px;
  background: #173246;
  border-color: #5ca8d3;
  color: #dff5ff;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}
.transport .tempo-arrow:disabled {
  background: #202830;
  border-color: #394550;
  color: #697580;
  cursor: default;
}
#tempoValue {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
#houseSelect {
  max-width: 130px;
  min-height: 40px;
  padding: 4px 6px;
  font-size: 12px;
}
