/* ── Piano App Layout ──────────────────────────────────────────────── */

.piano-app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem 5rem;
}

/* ── Controls Bar ──────────────────────────────────────────────────── */

.piano-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.mode-btns { display: flex; gap: 0.5rem; }

.mode-btn {
  padding: 0.42rem 1.3rem;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: transparent;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, color 0.16s;
}
.mode-btn:hover  { border-color: var(--blue-accent); color: var(--blue-accent); }
.mode-btn.active { background: var(--blue-accent); border-color: var(--blue-accent); color: var(--bg-0); }

/* ── Status Strip ──────────────────────────────────────────────────── */

.piano-status {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-3);
}

.ps-item   { display: flex; align-items: center; gap: 0.35rem; }
.ps-label  { color: var(--text-4); text-transform: uppercase; font-size: 0.68rem; letter-spacing: .05em; }
.ps-val    { color: var(--text-1); min-width: 4rem; }
.ps-val.active { color: var(--teal); }

/* ── Volume ────────────────────────────────────────────────────────── */

.vol-control  { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.vol-label    { font-size: 0.75rem; color: var(--text-3); font-family: var(--font-mono); }

#vol-slider {
  -webkit-appearance: none; appearance: none;
  width: 88px; height: 3px;
  border-radius: 2px;
  background: var(--border-h);
  outline: none; cursor: pointer;
}
#vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--blue-accent);
  cursor: pointer;
}
#vol-slider::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--blue-accent);
  border: none; cursor: pointer;
}

/* ── Piano Roll ────────────────────────────────────────────────────── */

.roll-wrap {
  border-radius: var(--r);
  background: var(--bg-1);
  border: 1px solid var(--border);
  margin-bottom: 0.6rem;
  overflow: hidden;
  height: 200px;
}

#piano-roll {
  display: block;
  width: 100%;
  height: 200px;
}

/* ── Piano Wrap (scrollable) ───────────────────────────────────────── */

.piano-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 14px 16px 26px;
  border-radius: var(--r);
  background: var(--bg-2);
  border: 1px solid var(--border);
  margin-bottom: 0.75rem;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}
.piano-wrap::-webkit-scrollbar        { height: 4px; }
.piano-wrap::-webkit-scrollbar-track  { background: var(--bg-1); }
.piano-wrap::-webkit-scrollbar-thumb  { background: var(--blue-accent); border-radius: 2px; }

#piano-keys { display: block; }

/* ── Keys ──────────────────────────────────────────────────────────── */

.pk {
  position: absolute;
  top: 0;
  transition: background 0.04s, box-shadow 0.04s;
  cursor: pointer;
}

/* White keys */
.pk-w {
  background: linear-gradient(180deg, #cfe2ef 0%, #eef7fc 30%, #dff0f8 100%);
  border-left:   1px solid #6fa4c0;
  border-right:  1px solid #6fa4c0;
  border-bottom: 3px solid #4c8caa;
  border-top: none;
  border-radius: 0 0 5px 5px;
  box-shadow: inset 0 -6px 10px rgba(0,0,0,0.10);
  z-index: 1;
}
.pk-w:hover { background: linear-gradient(180deg, #bed8ea 0%, #e2f4fc 100%); }

.pk-w.pk-active {
  background: linear-gradient(180deg, #0096c7 0%, #90e0ef 100%);
  box-shadow: 0 0 16px rgba(0,180,216,0.55), inset 0 -6px 10px rgba(0,0,0,0.15);
}
.pk-w.pk-hint-t {
  background: linear-gradient(180deg, #e9c46a 0%, #ffd97d 100%);
  box-shadow: 0 0 20px rgba(233,196,106,0.65), inset 0 -6px 10px rgba(0,0,0,0.08);
  animation: hw 1.1s ease-in-out infinite;
}
.pk-w.pk-hint-b {
  background: linear-gradient(180deg, #48aad4 0%, #a8d8f0 100%);
}

/* Black keys */
.pk-b {
  background: linear-gradient(180deg, #1c3148 0%, #0d1e35 55%, #040c18 100%);
  border-left:   1px solid #000;
  border-right:  1px solid #000;
  border-bottom: 3px solid #000;
  border-top: none;
  border-radius: 0 0 4px 4px;
  box-shadow: inset -2px -3px 5px rgba(255,255,255,0.04), 2px 4px 10px rgba(0,0,0,0.65);
  z-index: 2;
}
.pk-b:hover { background: linear-gradient(180deg, #283e54 0%, #152638 100%); }

.pk-b.pk-active {
  background: linear-gradient(180deg, #00b4d8 0%, #0077b6 100%);
  box-shadow: 0 0 14px rgba(0,180,216,0.8);
}
.pk-b.pk-hint-t {
  background: linear-gradient(180deg, #f4d47a 0%, #c4880a 100%);
  box-shadow: 0 0 18px rgba(233,196,106,0.95);
  animation: hb 1.1s ease-in-out infinite;
}
.pk-b.pk-hint-b {
  background: linear-gradient(180deg, #0077b6 0%, #00497a 100%);
}

@keyframes hw {
  0%,100% { box-shadow: 0 0 14px rgba(233,196,106,0.5), inset 0 -6px 10px rgba(0,0,0,0.08); }
  50%      { box-shadow: 0 0 28px rgba(233,196,106,0.9), inset 0 -6px 10px rgba(0,0,0,0.08); }
}
@keyframes hb {
  0%,100% { box-shadow: 0 0 12px rgba(233,196,106,0.7); }
  50%      { box-shadow: 0 0 24px rgba(233,196,106,1.0); }
}

/* ── Key Labels ────────────────────────────────────────────────────── */

.pk-lbl {
  position: absolute;
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 12px;
  color: rgba(20,45,65,0.65);
  pointer-events: none;
  white-space: nowrap;
}
.pk-b .pk-lbl {
  bottom: 5px;
  color: rgba(200,225,240,0.6);
  font-size: 10px;
}

.pk-octave {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 7px;
  color: rgba(20,45,65,0.32);
  pointer-events: none;
  white-space: nowrap;
}

/* ── Piano Legend ──────────────────────────────────────────────────── */

.piano-legend {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.77rem;
  color: var(--text-3);
  margin-bottom: 1.5rem;
}

.piano-legend kbd {
  display: inline-flex;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: var(--text-2);
  margin-right: 0.25rem;
}

.piano-legend .range-note {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-4);
}

/* ── Learn Panel ───────────────────────────────────────────────────── */

#learn-panel {
  padding: 1.6rem;
}

.lp-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}

.lp-title {
  font-family: var(--font-display);
  font-size: 1.22rem;
  font-weight: 300;
  color: var(--text-1);
}

.lp-composer {
  font-size: 0.8rem;
  color: var(--text-3);
  font-family: var(--font-mono);
  margin-top: 0.15rem;
}

.lp-restart {
  padding: 0.32rem 1rem;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: transparent;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.16s, color 0.16s;
}
.lp-restart:hover { border-color: var(--gold); color: var(--gold); }

/* Progress bar */
.lp-bar-track {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 1.2rem;
}
#learn-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-accent), var(--teal));
  border-radius: 2px;
  width: 0%;
  transition: width 0.38s ease;
}

/* Step & hint */
.lp-step-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
#learn-step {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  color: var(--text-2);
  flex: 1;
}
#learn-dyn {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.3rem;
  color: var(--text-2);
  min-width: 3rem;
  text-align: right;
}

#learn-hint {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: var(--gold);
  letter-spacing: 0.03em;
  min-height: 1.6em;
  transition: color 0.2s;
}
#learn-hint.ok { color: var(--teal); }

.lp-legend {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.76rem;
  color: var(--text-4);
}
.lp-swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  margin-right: 0.3rem;
  vertical-align: middle;
}
.lp-swatch-t { background: #e9c46a; }
.lp-swatch-b { background: #48aad4; }

/* ── Sheet Music ───────────────────────────────────────────────────── */

.sheet-music {
  width: 100%;
  max-width: 520px;
  margin: 0.9rem auto 1rem;
  background: rgba(5, 14, 27, 0.55);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.6rem 1rem;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sheet-music svg {
  display: block;
  width: 100%;
  height: auto;
}

.sheet-music:empty::after {
  content: '♩';
  font-size: 2rem;
  color: var(--text-4);
  opacity: 0.4;
}

/* ── Song Selector ─────────────────────────────────────────────────── */

.song-select {
  background: var(--bg-1);
  border: 1px solid var(--border-h);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.16s;
}
.song-select:focus { border-color: var(--blue-accent); color: var(--text-1); }
