/* ==========================================================================
   Pinned Piano & Scale Preview (Top-Right of Board)
   ========================================================================== */

.board-pinned-piano {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px 9px;
  background: 
    linear-gradient(90deg, rgba(30, 20, 12, 0.4) 0%, transparent 6%, transparent 94%, rgba(30, 20, 12, 0.4) 100%),
    linear-gradient(180deg, #4c3526 0%, #3a261a 40%, #291a11 100%);
  border: 1px solid #5d3d29;
  border-top-color: #825638;
  border-bottom-color: #170d08;
  border-radius: 8px;
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.5),
    0 4px 16px rgba(0, 0, 0, 0.22);
  pointer-events: auto;
  user-select: none;
  cursor: grab;
  touch-action: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.board-pinned-piano:hover {
  border-color: #936240;
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.5),
    0 6px 20px rgba(0, 0, 0, 0.28);
}

.board-pinned-piano.is-dragging {
  cursor: grabbing !important;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35) !important;
  z-index: 50 !important;
  transition: none !important;
}

[data-theme="dark"] .board-pinned-piano {
  background: 
    linear-gradient(90deg, rgba(16, 10, 6, 0.6) 0%, transparent 6%, transparent 94%, rgba(16, 10, 6, 0.6) 100%),
    linear-gradient(180deg, #322115 0%, #24160e 45%, #180d08 100%);
  border-color: #422818;
  border-top-color: #5c3922;
  border-bottom-color: #0b0604;
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.6),
    0 4px 20px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .board-pinned-piano:hover {
  border-color: #6e462c;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .board-pinned-piano.is-dragging {
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.7) !important;
}

.pinned-piano-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  cursor: grab;
}

.board-pinned-piano.is-dragging .pinned-piano-header {
  cursor: grabbing !important;
}

.pinned-piano-scale-info {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 1.5px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.15s ease, transform 0.1s ease;
  max-width: 115px;
  overflow: hidden;
  white-space: nowrap;
}

.pinned-piano-scale-info:hover {
  background: rgba(234, 88, 12, 0.22);
  border-color: rgba(234, 88, 12, 0.35);
}

.pinned-piano-scale-info:active,
.pinned-piano-scale-info.playing {
  transform: scale(0.96);
  background: rgba(234, 88, 12, 0.32) !important;
  color: #ff8a4c !important;
}

.pinned-scale-badge {
  display: inline-flex;
  align-items: center;
  gap: 3.5px;
  font-family: var(--font-main);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: #f6eedf;
  line-height: 1.2;
}

.pinned-scale-root-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  border-radius: 3px;
  padding: 0 1px;
}

.pinned-scale-root-wrap:hover .pinned-scale-root {
  color: #fb923c;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pinned-scale-root {
  display: inline-block;
  font-weight: 600;
  color: #fcebd2;
  flex-shrink: 0;
  transition: color 0.15s ease;
}

.pinned-scale-root-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  z-index: 3;
}

.pinned-scale-type-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  border-radius: 3px;
  padding: 0 1px;
}

.pinned-scale-type-wrap:hover .pinned-scale-type {
  color: #fb923c;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pinned-scale-type-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  z-index: 3;
}

.pinned-scale-type-slot {
  position: relative;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  height: 1.25em;
  line-height: 1.25em;
  vertical-align: middle;
  transition: width 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.pinned-scale-type {
  display: inline-block;
  white-space: nowrap;
  line-height: 1.25em;
  will-change: transform, opacity;
  color: #e5d8c3;
}

[data-theme="dark"] .pinned-scale-badge {
  color: #f6eedf;
}

.pinned-piano-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.btn-pinned-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #d8c7b0;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

.btn-pinned-action svg {
  width: 11px;
  height: 11px;
}

.btn-pinned-action:hover {
  background: rgba(234, 88, 12, 0.22);
  color: #fb923c;
  border-color: rgba(234, 88, 12, 0.35);
}

.btn-pinned-action:active {
  transform: scale(0.92);
}

.btn-pinned-action.active {
  color: #fb923c;
}

[data-theme="dark"] .btn-pinned-action {
  color: var(--graphite-light);
}

[data-theme="dark"] .btn-pinned-action:hover {
  background: rgba(234, 88, 12, 0.18);
  color: #f97316;
  border-color: rgba(234, 88, 12, 0.4);
}

.pinned-piano-knobs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 176px;
  padding: 3px 4px 4px;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
  box-sizing: border-box;
}

.synth-knob {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  cursor: ns-resize;
  user-select: none;
  touch-action: none;
  border-radius: 3px;
  padding: 1px 0;
  transition: background 0.12s ease;
}

.synth-knob:hover {
  background: rgba(255, 255, 255, 0.06);
}

.synth-knob:active {
  background: rgba(234, 88, 12, 0.18);
}

.knob-dial-wrap {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.knob-dial {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #5a4233, #22150e 70%, #150c07 100%);
  border: 1px solid #734f36;
  box-shadow: 
    0 1px 3px rgba(0, 0, 0, 0.5),
    inset 0 1px 1px rgba(255, 255, 255, 0.22),
    inset 0 -1px 2px rgba(0, 0, 0, 0.7);
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  will-change: transform;
  pointer-events: none;
}

[data-theme="dark"] .knob-dial {
  background: radial-gradient(circle at 35% 35%, #422d20, #180e09 70%, #0d0604 100%);
  border-color: #553521;
}

.knob-pointer {
  width: 2px;
  height: 5px;
  background: #ea580c;
  border-radius: 1px;
  margin-top: 2px;
  box-shadow: 0 0 3px rgba(234, 88, 12, 0.9);
}

.knob-val {
  font-family: var(--font-mono);
  font-size: 0.54rem;
  font-weight: 600;
  color: #ffb076;
  line-height: 1;
  margin-top: 2px;
  letter-spacing: -0.02em;
  pointer-events: none;
}

.knob-label {
  font-family: var(--font-main);
  font-size: 0.48rem;
  font-weight: 700;
  color: #b59f8a;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 1px;
  pointer-events: none;
}

.btn-synth-sustain {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 2px 5px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  height: 34px;
  margin-left: 2px;
}

.btn-synth-sustain:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn-synth-sustain .sus-lamp {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  margin-bottom: 2px;
  transition: all 0.15s ease;
}

.btn-synth-sustain.active .sus-lamp {
  background: #ea580c;
  box-shadow: 0 0 6px #ea580c;
}

.btn-synth-sustain .sus-label {
  font-family: var(--font-main);
  font-size: 0.46rem;
  font-weight: 700;
  color: #b59f8a;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
}

.btn-synth-sustain.active .sus-label {
  color: #ea580c;
}

.btn-synth-sustain .sus-key {
  font-family: var(--font-mono);
  font-size: 0.42rem;
  color: #8c7664;
  line-height: 1;
  margin-top: 1px;
}

.pinned-key-hint {
  font-family: var(--font-mono);
  font-size: 0.50rem;
  font-weight: 600;
  color: var(--graphite-light);
  line-height: 1;
  margin-bottom: 2px;
  pointer-events: none;
  opacity: 0.8;
}

.pinned-key-black .pinned-key-hint {
  color: #c4b5a5;
  font-size: 0.44rem;
  margin-bottom: 3px;
}

.pinned-piano-keys-wrapper {
  display: flex;
  position: relative;
  width: 176px;
  height: 42px;
  user-select: none;
  touch-action: manipulation;
}

.pinned-piano-octave {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
}

.pinned-key-white {
  flex: 1;
  height: 100%;
  background: #ffffff;
  border: 1px solid var(--paper-border-focus);
  border-radius: 0 0 3px 3px;
  position: relative;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: background 0.1s ease, transform 0.06s ease;
  margin-right: -1px;
  padding-bottom: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.pinned-key-white:hover {
  background: #faf8f5;
}

.pinned-key-white.active {
  background: #fdfaf4;
}

.pinned-key-white.root {
  background: #fff8f3;
  border-bottom: 2px solid #ea580c;
}

.pinned-key-white.pressed,
.pinned-key-white:active {
  background: #f0ebe1;
  transform: translateY(1px);
}

.pinned-key-black {
  position: absolute;
  top: 0;
  width: 13px;
  height: 25px;
  background: #23211f;
  border-radius: 0 0 2px 2px;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: background 0.1s ease, transform 0.06s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 2px;
}

.pinned-key-black:hover {
  background: #35322e;
}

.pinned-key-black.active {
  background: #2a2724;
}

.pinned-key-black.root {
  background: #332117;
  border-bottom: 2px solid #ea580c;
}

.pinned-key-black.pressed,
.pinned-key-black:active {
  background: #151413;
  transform: translateY(1px);
}

.pinned-key-dot-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 11px;
  height: 11px;
  margin-bottom: 2px;
  pointer-events: none;
}

.pinned-key-shortcut-letter {
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 700;
  line-height: 1;
  color: var(--graphite-dark, #23211f);
  z-index: 2;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  user-select: none;
  transform: translateY(-0.2px);
}

.pinned-key-white .pinned-key-shortcut-letter {
  color: #23211f;
}

.pinned-key-white.root .pinned-key-shortcut-letter {
  color: #ea580c;
  font-weight: 800;
}

.pinned-key-black .pinned-key-shortcut-letter {
  color: #ffffff;
}

.pinned-key-black.root .pinned-key-shortcut-letter {
  color: #f97316;
  font-weight: 800;
}

[data-theme="dark"] .pinned-key-white .pinned-key-shortcut-letter {
  color: #23211f;
}

[data-theme="dark"] .pinned-key-white.root .pinned-key-shortcut-letter {
  color: #ea580c;
}

[data-theme="dark"] .pinned-key-black .pinned-key-shortcut-letter {
  color: #f0ede6;
}

[data-theme="dark"] .pinned-key-black.root .pinned-key-shortcut-letter {
  color: #f97316;
}

.pinned-key-dot {
  width: 3.6px;
  height: 3.6px;
  border-radius: 50%;
  background: #23211f;
  z-index: 2;
  transition: transform 0.15s ease;
}

.pinned-key-white .pinned-key-dot,
.pinned-key-white.active .pinned-key-dot {
  background: #23211f;
}

.pinned-key-white.root .pinned-key-dot {
  background: #ea580c;
  width: 4.2px;
  height: 4.2px;
}

.pinned-key-black .pinned-key-dot,
.pinned-key-black.active .pinned-key-dot {
  background: #ffffff;
}

.pinned-key-black.root .pinned-key-dot {
  background: #f97316;
  width: 4.2px;
  height: 4.2px;
}

.pinned-key-voicing-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10.5px;
  height: 10.5px;
  border-radius: 50%;
  border: 1.3px solid var(--ring-color);
  box-sizing: border-box;
  z-index: 1;
  pointer-events: none;
  opacity: 0.92;
  transition: all 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.pinned-key-voicing-ring.active-voice {
  border-width: 1.6px;
  opacity: 1;
  box-shadow: 0 0 5px var(--ring-color);
  transform: translate(-50%, -50%) scale(1.15);
}

.pinned-key-voicing-ring.ring-outer {
  width: 13.5px;
  height: 13.5px;
  border-width: 1.3px;
}

.pinned-key-voicing-ring.ring-outer.active-voice {
  border-width: 1.6px;
  box-shadow: 0 0 5px var(--ring-color);
  transform: translate(-50%, -50%) scale(1.12);
}

.pinned-key-dot.offscale {
  opacity: 0.35;
}

.pinned-key-white .pinned-key-dot.offscale {
  background: #23211f !important;
}

.pinned-key-black .pinned-key-dot.offscale {
  background: #ffffff !important;
}

/* Dark mode for pinned piano keys */
[data-theme="dark"] .pinned-key-white {
  background: #ded9cd;
  border-color: rgba(50, 48, 45, 0.6);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .pinned-key-white:hover {
  background: #ebe6da;
}

[data-theme="dark"] .pinned-key-white.active {
  background: #e8e3d6;
}

[data-theme="dark"] .pinned-key-white.root {
  background: #f4eae0;
  border-bottom: 2px solid #f97316;
}

[data-theme="dark"] .pinned-key-white.pressed,
[data-theme="dark"] .pinned-key-white:active {
  background: #c5bfb2;
}

[data-theme="dark"] .pinned-key-black {
  background: #1a1816;
  border: 1px solid rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .pinned-key-black:hover {
  background: #252320;
}

[data-theme="dark"] .pinned-key-black.active {
  background: #22201d;
}

[data-theme="dark"] .pinned-key-black.root {
  background: #2d1e15;
  border-bottom: 2px solid #f97316;
}

/* Ensure scale dots remain consistently black on white keys and white on black keys in dark theme */
[data-theme="dark"] .pinned-key-white .pinned-key-dot,
[data-theme="dark"] .pinned-key-white.active .pinned-key-dot {
  background: #23211f;
}

[data-theme="dark"] .pinned-key-white.root .pinned-key-dot {
  background: #ea580c;
}

[data-theme="dark"] .pinned-key-black .pinned-key-dot,
[data-theme="dark"] .pinned-key-black.active .pinned-key-dot {
  background: #ffffff;
}

[data-theme="dark"] .pinned-key-black.root .pinned-key-dot {
  background: #f97316;
}

[data-theme="dark"] .pinned-key-white .pinned-key-dot.offscale {
  background: #23211f !important;
  opacity: 0.35;
}

[data-theme="dark"] .pinned-key-black .pinned-key-dot.offscale {
  background: #ffffff !important;
  opacity: 0.35;
}
