/* ── Piano ─────────────────────────────────────────────────── */
.piano-wrap {
  background: linear-gradient(180deg, #fffdf9 0%, var(--staff) 100%);
  border-radius: 22px;
  padding: 16px 14px 12px;
}

.piano {
  position: relative;
  height: 132px;
  user-select: none;
}

.piano-white-row {
  display: flex;
  height: 100%;
  gap: 2px;
}

.piano-key {
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 120ms ease, transform 100ms ease;
}

.piano-key-white {
  background: linear-gradient(180deg, #ffffff 0%, #efece3 100%);
  border: 1px solid #cfcabf;
  border-radius: 0 0 8px 8px;
  height: 100%;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
}

.piano-key-white:hover {
  background: linear-gradient(180deg, #ffffff 0%, #f7f4ee 100%);
}

.piano-key-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: #8a8474;
  pointer-events: none;
}

.piano-key-black {
  position: absolute;
  top: 0;
  height: 60%;
  background: linear-gradient(180deg, #33333a 0%, #101013 100%);
  border-radius: 0 0 6px 6px;
  z-index: 2;
  box-shadow: 0 8px 12px rgba(0, 0, 0, 0.35);
}

.piano-key-black:hover {
  background: linear-gradient(180deg, #46464e 0%, #17171a 100%);
}

.piano-key.is-root {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%) !important;
}

.piano-key.is-root .piano-key-label {
  color: #0b1220;
}

.piano-key.is-target {
  background: linear-gradient(180deg, var(--danger-strong) 0%, var(--danger) 100%) !important;
}

.piano-key.is-target .piano-key-label {
  color: #2a0a10;
}

.piano-key.is-third {
  background: linear-gradient(180deg, #6facff 0%, #4a8ef0 100%) !important;
}

.piano-key.is-third .piano-key-label {
  color: #0b1220;
}

.piano-key.is-fifth {
  background: linear-gradient(180deg, #ffc169 0%, #f0a53c 100%) !important;
}

.piano-key.is-fifth .piano-key-label {
  color: #2a1a00;
}

.finger-badge {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: #0b1220;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 3;
}

.finger-badge.badge-root {
  background: var(--accent);
}

.finger-badge.badge-third {
  background: #6facff;
}

.finger-badge.badge-fifth {
  background: #ffc169;
}

/* ── Fretboard ─────────────────────────────────────────────── */
.fretboard-wrap {
  background: linear-gradient(160deg, #43290f 0%, #241608 100%);
  border-radius: 22px;
  padding: 18px 16px 12px;
  border: 1px solid rgba(255, 214, 163, 0.14);
}

.fret-string,
.fret-markers,
.fret-numbers {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
}

.fret-cell {
  position: relative;
  height: 50px;
  border: none;
  border-right: 2px solid rgba(255, 224, 178, 0.32);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.fret-cell:last-child {
  border-right: none;
}

.fret-cell.is-nut {
  border-left: 4px solid #f4e9d8;
}

.fret-note-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  transition: background 150ms ease, transform 150ms ease;
}

.fret-cell:hover .fret-note-dot {
  background: rgba(255, 255, 255, 0.18);
}

.fret-cell.is-root .fret-note-dot {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
  transform: scale(1.08);
}

.fret-cell.is-target .fret-note-dot {
  background: linear-gradient(180deg, var(--danger-strong) 0%, var(--danger) 100%);
  transform: scale(1.08);
}

.fret-markers {
  margin-top: 6px;
}

.fret-marker-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.fret-marker-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 224, 178, 0.4);
}

.fret-numbers {
  margin-top: 4px;
}

.fret-numbers span {
  text-align: center;
  font-size: 0.72rem;
  color: rgba(255, 224, 178, 0.55);
}

.fretboard-caption {
  margin: 10px 2px 0;
  font-size: 0.78rem;
  color: rgba(255, 224, 178, 0.6);
}

/* ── Mode / difficulty toggle groups (matches .zoom-control) ── */
.mode-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 6px;
  flex-wrap: wrap;
}

.mode-toggle-label {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 6px 0 4px;
}

.mode-btn {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.mode-btn:hover,
.mode-btn:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  outline: none;
}

.mode-btn.is-active {
  background: rgba(78, 204, 163, 0.18);
  border-color: rgba(78, 204, 163, 0.5);
  color: #cffff0;
}

/* ── Distance readout ──────────────────────────────────────── */
.distance-readout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 14px 0 4px;
  font-weight: 700;
}

.distance-readout .distance-count {
  font-size: 2rem;
  color: var(--accent);
  min-width: 2.4ch;
  text-align: center;
}

.distance-readout .distance-unit {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
}

/* ── Interval reference table ─────────────────────────────── */
.interval-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.interval-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.interval-table th,
.interval-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.9rem;
}

.interval-table th {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.03);
}

.interval-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.interval-table tbody tr:last-child td {
  border-bottom: none;
}

.interval-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.78rem;
}

.interval-chip.category-perfect { background: rgba(78, 204, 163, 0.18); color: #cffff0; }
.interval-chip.category-major { background: rgba(94, 158, 255, 0.18); color: #cfe3ff; }
.interval-chip.category-minor { background: rgba(255, 176, 79, 0.18); color: #ffe2bd; }
.interval-chip.category-dissonant { background: rgba(233, 69, 96, 0.18); color: #ffd6dc; }

.table-listen-btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 140ms ease, transform 140ms ease;
}

.table-listen-btn:hover,
.table-listen-btn:focus-visible {
  background: rgba(78, 204, 163, 0.18);
  transform: translateY(-1px);
  outline: none;
}

/* ── Mastery grid (per-interval accuracy) ─────────────────── */
.mastery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
}

.mastery-cell {
  border-radius: 12px;
  padding: 8px 4px;
  text-align: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.mastery-cell .mastery-short {
  display: block;
  font-weight: 800;
  font-size: 0.85rem;
}

.mastery-cell .mastery-pct {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 2px;
}

.mastery-cell.level-strong { border-color: rgba(78, 204, 163, 0.5); background: rgba(78, 204, 163, 0.12); }
.mastery-cell.level-mid { border-color: rgba(255, 176, 79, 0.5); background: rgba(255, 176, 79, 0.1); }
.mastery-cell.level-weak { border-color: rgba(233, 69, 96, 0.5); background: rgba(233, 69, 96, 0.1); }
.mastery-cell.level-new { opacity: 0.6; }

/* ── Achievement toast ─────────────────────────────────────── */
.achievement-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: linear-gradient(135deg, #ffd76a 0%, #ff9f4a 100%);
  color: #3a2400;
  font-weight: 800;
  padding: 14px 22px;
  border-radius: var(--radius-sm);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
}

.achievement-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 760px) {
  .fret-cell {
    height: 40px;
  }

  .piano-key-label {
    font-size: 0.55rem;
  }

  .mode-toggle {
    width: 100%;
    justify-content: center;
  }
}
