/* Piano-specific styles */

:root {
    --piano-dot-border-width: 2px;
}

/* Unified background across all control rows (diagram + playback + memory) */
body:not(.string-generator) .controls {
    background-color: var(--panel-muted);
}

body:not(.string-generator) #memoryControls {
    margin-bottom: 0;
    padding-bottom: 6px;
}

.piano-diagram-container {
    padding-top: 4em;
    margin-top: 0.1em;
}

/* Preference confirmation message */
.preference-confirmation {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: none;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 10px;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 2px solid #81c784;
    color: #2e7d32;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.preference-confirmation.show {
    display: flex;
    opacity: 1;
}

.preference-confirmation.fade-out {
    opacity: 0;
}

.preference-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    box-shadow: 0 0 6px rgba(76, 175, 80, 0.7);
}

.preference-emoji {
    font-size: 16px;
    line-height: 1;
}

.preference-label {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.note-preference {
    position: relative;
    display: inline-flex;
    align-items: center;
}

#pianoSvgContainer {
    position: relative;
    overflow: hidden;
    min-width: 1000px;
    min-height: 200px;
}

#pianoSvgStage {
    position: relative;
    width: 100%;
    min-width: 1000px;
    min-height: 200px;
}

#pianoSvg {
    position: relative;
    z-index: 1;
}

#pianoDotsSvg {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 6;
    pointer-events: none;
}

.dot-hitbox {
    pointer-events: all;
}

.piano-confetti-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    background: transparent;
    margin: 0;
}

.piano-lightning-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 4;
    background: transparent;
    margin: 0;
}

.piano-flame-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    background: transparent;
    margin: 0;
}


.preference-hint {
    position: absolute;
    top: 42px;
    left: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
}

.preference-toggle {
    background: rgba(46, 61, 98, 0.92);
    color: #e8f0ff;
    border-radius: 6px;
    padding: 7px 12px;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.preference-toggle.show {
    opacity: 1;
    transform: translateY(0);
}

.preference-tip {
    background: rgba(46, 61, 98, 0.92);
    color: #e8f0ff;
    border: 1px solid rgba(232, 240, 255, 0.2);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 15px;
    font-weight: 500;
    width: max-content;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.preference-tip.show {
    opacity: 1;
    transform: translateY(0);
}

.piano-drag-shadow {
    fill: rgba(90, 180, 255, 0.3);
    stroke: rgba(30, 130, 255, 1);
    stroke-width: 4.5px;
    stroke-dasharray: 5 3;
    pointer-events: none;
    filter: drop-shadow(0 8px 18px rgba(20, 50, 90, 0.55))
            drop-shadow(0 0 10px rgba(90, 170, 255, 0.35));
}

/* Glowing pulse animation for selection ring */
@keyframes pianoSelectionGlow {
    0%, 100% {
        filter: drop-shadow(0 0 8px rgba(70, 130, 255, 0.5))
                drop-shadow(0 0 12px rgba(70, 130, 255, 0.25));
        opacity: 0.95;
    }
    50% {
        filter: drop-shadow(0 0 12px rgba(100, 160, 255, 0.7))
                drop-shadow(0 0 18px rgba(100, 160, 255, 0.4));
        opacity: 1;
    }
}

.piano-selection-ring {
    fill: rgba(120, 180, 255, 0.35);
    stroke: rgba(150, 210, 255, 0.95);
    stroke-width: 4px;
    stroke-dasharray: 0;
    pointer-events: none;
    mix-blend-mode: screen;
    animation: pianoSelectionGlow 2.5s ease-in-out infinite;
}

/* Glowing pulse animation for selected dots (BLUE) */
@keyframes pianoDotGlow {
    0%, 100% {
        filter: drop-shadow(0 0 6px rgba(90, 150, 255, 0.6))
                drop-shadow(0 0 10px rgba(90, 150, 255, 0.3));
    }
    50% {
        filter: drop-shadow(0 0 10px rgba(110, 170, 255, 0.85))
                drop-shadow(0 0 14px rgba(110, 170, 255, 0.45));
    }
}

/* Glowing pulse animation for MIDI held dots (GREEN) */
@keyframes pianoMidiHeldGlow {
    0%, 100% {
        filter: drop-shadow(0 0 6px rgba(0, 168, 112, 0.7))
                drop-shadow(0 0 11px rgba(0, 168, 112, 0.4));
    }
    50% {
        filter: drop-shadow(0 0 10px rgba(0, 168, 112, 0.95))
                drop-shadow(0 0 15px rgba(0, 168, 112, 0.6));
    }
}

/* Apply blue glow to selected dots (but NOT MIDI held dots) */
.piano-dot-selected:not(.piano-dot-midi-held) circle:not(.dot-hitbox) {
    animation: pianoDotGlow 2.5s ease-in-out infinite;
}

/* Apply GREEN glow to MIDI held dots */
.piano-dot-midi-held circle:not(.dot-hitbox) {
    animation: pianoMidiHeldGlow 2.5s ease-in-out infinite;
}

.piano-pitch-bend-ghost {
    fill: rgba(255, 255, 255, 0.25);
    stroke: rgba(255, 120, 80, 0.6);
    stroke-width: 3px;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.2));
}

.piano-group-ghost-layer {
    pointer-events: none;
}

.piano-group-ghost-dot {
    fill: rgba(120, 190, 255, 0.38);
    stroke: rgba(30, 130, 255, 1);
    stroke-width: 4.5px;
    stroke-dasharray: 5 3;
    filter: drop-shadow(0 8px 16px rgba(20, 70, 140, 0.55))
            drop-shadow(0 0 10px rgba(90, 170, 255, 0.35));
}

.piano-group-ghost-line {
    stroke: rgba(60, 150, 255, 1);
    stroke-width: 7.5px;
    stroke-dasharray: 8 4;
    filter: drop-shadow(0 8px 18px rgba(25, 60, 120, 0.55))
            drop-shadow(0 0 12px rgba(90, 170, 255, 0.35));
}

.piano-dot.midi-preview-active circle:not(.dot-hitbox) {
    fill: rgba(255, 255, 255, 0.75);
    stroke: rgba(120, 150, 255, 0.9);
    stroke-width: 2px;
}

/* (Retired) pulse via CSS keyframes - kept here in case we want to re-enable */
@keyframes pianoDotPulse {
    0% { transform: scale(1); }
    35% { transform: scale(1.15); }
    60% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

.piano-midi-dot circle {
    pointer-events: none;
    filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.35));
}

div#pianoChordIndicator {
    position: absolute;
    top: 12px;
    left: 16px;
}

/* Piano-specific overlay controls */
.piano-overlay-button {
    background: linear-gradient(160deg, #ffffff 0%, #e7edf5 100%);
    border: 2px solid rgba(90, 105, 130, 0.35);
    color: #2a3445;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 6px 14px rgba(20, 30, 45, 0.18);
}

.piano-overlay-button:hover {
    background: linear-gradient(160deg, #fff3d1 0%, #ffd48a 100%);
    border-color: rgba(214, 133, 22, 0.7);
    color: #7a4a06;
    box-shadow: 0 6px 14px rgba(20, 30, 45, 0.18), 0 0 0 2px rgba(214, 133, 22, 0.2);
}

.piano-overlay-button.active {
    background: linear-gradient(160deg, #f2fff7 0%, #d7f7e6 100%);
    border: 2px solid rgba(34, 201, 119, 0.9);
    color: #1f5b3b;
    box-shadow: 0 0 10px rgba(34, 201, 119, 0.35), 0 6px 14px rgba(20, 30, 45, 0.18);
}

html.theme-dark .piano-overlay-button,
:root.theme-dark .piano-overlay-button,
html[data-theme="dark"] .piano-overlay-button {
    background: linear-gradient(160deg, #0e1a2b 0%, #16253b 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    color: #e7f4ff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

html.theme-dark .piano-overlay-button:hover,
:root.theme-dark .piano-overlay-button:hover,
html[data-theme="dark"] .piano-overlay-button:hover {
    background: linear-gradient(160deg, #1b2b45 0%, #223a5c 100%);
    border-color: rgba(34, 201, 119, 0.7);
    color: #e7f4ff;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4), 0 0 0 2px rgba(34, 201, 119, 0.2);
}

html.theme-dark .piano-overlay-button.active,
:root.theme-dark .piano-overlay-button.active,
html[data-theme="dark"] .piano-overlay-button.active {
    background: linear-gradient(160deg, #0f1f33 0%, #182c46 100%);
    border: 2px solid rgba(34, 201, 119, 0.9);
    color: #e7f4ff;
    box-shadow: 0 0 10px rgba(34, 201, 119, 0.4), 0 8px 20px rgba(0, 0, 0, 0.35);
}

body.piano-labels-hidden .piano-note-label,
body.piano-labels-hidden .piano-number-label {
    opacity: 0;
    pointer-events: none;
}

.piano-label-emoji {
    font-size: 22px;
}

.piano-label-emoji.emoji-tight {
    line-height: 1;
}

/* ---- Piano Play Mode Button ---- */

.piano-play-mode-text {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    line-height: 1;
}

/* ---- Piano Chord Label Button & Area ---- */

.piano-chord-label-btn-text {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    line-height: 1;
}

.piano-chord-label-area {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 20px;
    min-width: 60px;
    outline: none;
    border-radius: 10px;
    cursor: text;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.piano-chord-label-area.focused {
    border-color: rgba(34, 201, 119, 0.5);
    box-shadow: 0 0 8px rgba(34, 201, 119, 0.2);
}

.piano-chord-label-text {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 24px;
    font-weight: 500;
    color: #212529;
    white-space: nowrap;
    user-select: none;
    line-height: 1;
}

.piano-chord-label-text.placeholder {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    color: #94a3b8;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.piano-chord-label-text .chord-root {
    font-size: 1em;
}

.piano-chord-label-text .chord-accidental {
    font-size: 0.65em;
    vertical-align: super;
    line-height: 0;
    margin-left: -1px;
}

.piano-chord-label-text .chord-quality {
    font-size: 0.8em;
    font-weight: 300;
}

.piano-chord-label-text .chord-ext {
    font-size: 0.55em;
    font-weight: 300;
    vertical-align: super;
    line-height: 0;
}

.piano-chord-label-text .chord-slash {
    font-size: 0.8em;
    font-weight: 300;
    margin: 0 1px;
}

.piano-chord-label-text .chord-bass {
    font-size: 0.85em;
}

/* Dark theme piano chord label */
html.theme-dark .piano-chord-label-area,
:root.theme-dark .piano-chord-label-area,
html[data-theme="dark"] .piano-chord-label-area {
    background: linear-gradient(135deg, #1a2b45 0%, #102035 100%);
    border-color: rgba(255, 255, 255, 0.08);
}

html.theme-dark .piano-chord-label-area.focused,
:root.theme-dark .piano-chord-label-area.focused,
html[data-theme="dark"] .piano-chord-label-area.focused {
    border-color: rgba(34, 201, 119, 0.5);
    box-shadow: 0 0 8px rgba(34, 201, 119, 0.2);
}

html.theme-dark .piano-chord-label-text,
:root.theme-dark .piano-chord-label-text,
html[data-theme="dark"] .piano-chord-label-text {
    color: #f0f6ff;
}

html.theme-dark .piano-chord-label-text.placeholder,
:root.theme-dark .piano-chord-label-text.placeholder,
html[data-theme="dark"] .piano-chord-label-text.placeholder {
    color: #5a6a7a;
}

/* User sample library modal */
.sample-library-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.sample-library-button,
.sample-library-record,
.sample-library-stop,
.sample-library-delete {
  background: #222;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  padding: 8px 12px;
}

.sample-library-button:hover,
.sample-library-record:hover,
.sample-library-stop:hover,
.sample-library-delete:hover {
  background: #2c2c2c;
}

.sample-library-delete {
  background: #3a1d1d;
  border-color: #5c2b2b;
}

.sample-library-delete:hover {
  background: #4a2020;
}

.user-sample-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.user-sample-status {
  margin-top: 12px;
  font-size: 14px;
  color: #ddd;
}

.user-sample-list {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.user-sample-item {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  color: #f0f0f0;
  font-size: 13px;
  padding: 4px 8px;
}

/* ── Keys Action Dock Button & Panel ── */
.keys-action-btn {
  position: fixed;
  right: 16px;
  bottom: 50%;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: linear-gradient(135deg, rgba(60, 80, 120, 0.85), rgba(40, 60, 100, 0.8));
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 4px 14px rgba(50, 140, 255, 0.35);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
  opacity: 0.9;
  font-family: inherit;
}
.keys-action-btn:hover {
  opacity: 1;
  border-color: rgba(166, 244, 255, 0.9);
  box-shadow: 0 0 18px rgba(144, 230, 255, 0.7);
}
.keys-action-btn.active {
  background: linear-gradient(135deg, rgba(80, 200, 255, 0.95), rgba(60, 140, 255, 0.9));
  box-shadow: 0 0 22px rgba(140, 226, 255, 0.8), 0 0 10px rgba(90, 160, 255, 0.6);
  opacity: 1;
}

.keys-action-panel {
  position: fixed;
  width: 280px;
  min-width: 220px;
  background: rgba(10, 18, 32, 0.96);
  border: 1px solid rgba(100, 140, 200, 0.25);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.keys-action-panel.hidden { display: none; }

.keys-action-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(100, 140, 200, 0.2);
  cursor: move;
  user-select: none;
}
.keys-action-header h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #e7f6ff;
  letter-spacing: 0.03em;
}
.keys-action-close {
  background: none;
  border: none;
  color: rgba(180, 210, 240, 0.6);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.2s ease;
}
.keys-action-close:hover { color: #e7f6ff; }

.keys-action-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Section labels inside panels ── */
.keys-action-body .preference-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(200, 215, 240, 0.4);
  margin-bottom: -6px;
}

/* ── Controls inside Keys panel ── */
.keys-action-body .key-range-control {
  display: flex;
  align-items: center;
  gap: 4px;
}

.keys-action-body .octave-shift-inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

.keys-action-body .config-divider {
  display: none;
}

/* ── Accidentals panel body ── */
.accidentals-action-body .note-preference {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  flex-wrap: nowrap;
}

/* ── Controls inside Sound panel ── */
.sound-action-body .volume-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sound-action-body .volume-controls label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(200, 215, 240, 0.5);
  flex-shrink: 0;
}

.sound-action-body .waveform-buttons {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.sound-action-body .waveform-mixer {
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(100, 140, 200, 0.15);
}

/* ── Controls inside Playback panel ── */
.playback-actions-body .playback-card-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(200, 215, 240, 0.4);
  margin-bottom: 4px;
  padding: 0 2px;
}

.playback-actions-body .playback-card-primary,
.playback-actions-body .playback-card-advanced {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  border: none;
  background: none;
}

.playback-actions-body .playback-card-advanced {
  padding-top: 8px;
  border-top: 1px solid rgba(150, 140, 210, 0.2);
}

.playback-actions-body .actionButton,
.playback-actions-body .playback-button {
  background: linear-gradient(135deg, #4a4f8d 0%, #3a3f78 100%);
  border: 1px solid rgba(140, 150, 220, 0.35);
  color: #d8e0f5;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.playback-actions-body .actionButton:hover,
.playback-actions-body .playback-button:hover {
  background: linear-gradient(135deg, #5a63b0 0%, #4953a0 100%);
  border-color: rgba(150, 170, 255, 0.7);
}

/* ── Controls inside Record panel ── */
.record-action-body .record-control {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.record-action-body .record-main-btn {
  flex: 1;
  min-width: 140px;
}
