/* Base styles - containers, general layout, buttons */

:root {
    --page-bg: #e9ecfb;
    --panel-bg: #ffffff;
    --panel-muted: #f4f6ff;
    --panel-border: #d6deef;
    --text-primary: #0f172a;
    --text-secondary: #4b5563;
    --shadow-strong: rgba(12, 31, 66, 0.12);
    --button-primary-bg: #4a90e2;
    --button-primary-hover: #357abd;
    --button-primary-text: #ffffff;
    --mute-button-font-size: 36px;
    --input-bg: #ffffff;
    --input-border: #d6deef;
    --accent-glow: #22c977;
    --close-button-bg: rgba(15, 23, 42, 0.08);
    --close-button-border: rgba(30, 64, 175, 0.22);
    --close-button-shadow: rgba(30, 64, 175, 0.12);
    --close-button-hover-bg: rgba(15, 23, 42, 0.16);
    --close-button-hover-border: rgba(30, 64, 175, 0.45);
    --close-button-hover-shadow: rgba(30, 64, 175, 0.22);
    --close-button-icon: var(--text-primary);
    --fingerboard-bg: #ffffff;
    --fingerboard-grid: #333333;
    --fingerboard-markers: #808080;
    --fingerboard-primary-note: #ff0000;
    --fingerboard-open-note: #333333;
}

:root.theme-dark,
html.theme-dark,
html[data-theme="dark"] {
    --page-bg: #0b1224;
    --panel-bg: #0f1c33;
    --panel-muted: #152743;
    --panel-border: #203354;
    --text-primary: #e5ebf7;
    --text-secondary: #a3b4d2;
    --shadow-strong: rgba(0, 0, 0, 0.4);
    --button-primary-bg: #5a9bff;
    --button-primary-hover: #487dcc;
    --button-primary-text: #f8fbff;
    --input-bg: #0f2038;
    --input-border: #2b4066;
    --accent-glow: #3cf5b0;
    --close-button-bg: rgba(8, 16, 32, 0.78);
    --close-button-border: rgba(125, 170, 255, 0.4);
    --close-button-shadow: rgba(56, 120, 255, 0.35);
    --close-button-hover-bg: rgba(14, 26, 48, 0.95);
    --close-button-hover-border: rgba(148, 199, 255, 0.9);
    --close-button-hover-shadow: rgba(99, 179, 255, 0.55);
    --close-button-icon: #e9f0ff;
    --fingerboard-bg: #0f1c33;
    --fingerboard-grid: #d6deef;
    --fingerboard-markers: #a3b4d2;
    --fingerboard-primary-note: #000000;
    --fingerboard-open-note: #d6deef;
}

body {
    background: var(--page-bg);
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
    font-family: Arial, sans-serif;
}

::selection {
    background: rgba(90, 180, 255, 0.35);
    color: var(--text-primary);
}

::-moz-selection {
    background: rgba(90, 180, 255, 0.35);
    color: var(--text-primary);
}

:root.theme-dark ::selection,
html.theme-dark ::selection,
html[data-theme="dark"] ::selection,
:root.theme-dark ::-moz-selection,
html.theme-dark ::-moz-selection,
html[data-theme="dark"] ::-moz-selection {
    background: rgba(90, 180, 255, 0.55);
    color: var(--text-primary);
}

/* Custom scrollbar styling - matches app theme */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--accent-glow, #3cf5b0) var(--panel-bg, rgba(11, 16, 28, 0.9));
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: var(--panel-bg, rgba(11, 16, 28, 0.9));
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(22, 249, 190, 0.95), rgba(14, 114, 243, 0.9));
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

*::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(34, 201, 119, 0.95), rgba(37, 99, 235, 0.9));
}

*::-webkit-scrollbar-corner {
    background: var(--panel-bg, rgba(11, 16, 28, 0.9));
}

button,
input,
select {
    font-family: inherit;
}

.container {
    max-width: fit-content;
    margin: 0 auto;
    padding: 0;
    padding-top: 0;
    padding-bottom: 0;
    font-family: inherit;
}

h2, h3 {
    text-align: center;
    margin-bottom: 8px;
}

h3 {
    font-weight: normal;
    color: var(--text-secondary);
}

.controls {
    text-align: center;
    margin-bottom: 8px;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    overflow: visible;
}

#diagramControls {
    overflow: visible;
    position: relative;
}

.controls button:not(.speedButton):not(.waveButton):not(.sampleButton):not(.note-toggle):not(.fret-count-button):not(.playback-button),
.controls select,
.controls input {
    margin: 0 3px;
    padding: 5px 5px;
}

.diagram-container {
    text-align: center;
    margin: 4px auto;
    padding: 12px;
    background: var(--panel-bg);
    border-radius: 8px;
    box-shadow: 0 12px 32px var(--shadow-strong);
    border: 1px solid var(--panel-border);
    transition: all 0.3s ease;
    position: relative;
    overflow: visible;
    min-height: fit-content;
    width: fit-content;
    min-width: 316px;
    margin-bottom: 4.5em;
    padding-bottom: calc(2em - 10px);
    margin-top: -3.35em;
    padding-top: 9px;
}

/* Counter-rotate button contents when container is rotated */
.diagram-container.rotated-90 .canvas-overlay-button {
    transform: rotate(-90deg);
}

.diagram-container.rotated-270 .canvas-overlay-button {
    transform: rotate(90deg);
}

.diagram-container.rotated-180 .canvas-overlay-button {
    transform: rotate(-180deg);
}

/* Reposition handles to visual top corners when rotated - flush with new top edge */

/* At 90° (horizontal): visual top = physical left edge, buttons above/below at corners */
.diagram-container.rotated-90 .rotation-handle-tl {
    top: -32px;
    left: 0;
    right: auto;
    bottom: auto;
}

.diagram-container.rotated-90 .rotation-handle-tr {
    top: auto;
    left: 0;
    right: auto;
    bottom: -32px;
}

/* At 270° (horizontal): visual top = physical right edge, buttons above/below at corners */
.diagram-container.rotated-270 .rotation-handle-tl {
    top: -32px;
    left: auto;
    right: 0;
    bottom: auto;
}

.diagram-container.rotated-270 .rotation-handle-tr {
    top: auto;
    left: auto;
    right: 0;
    bottom: -32px;
}

/* Rotation handles for diagram container - Oracle style */
.rotation-handle {
    --handle-scale: 1;
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--page-bg) 85%, black 15%);
    border: 2px solid color-mix(in srgb, var(--page-bg) 70%, black 30%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0.7;
}

.rotation-handle:hover {
    border-color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
    opacity: 1;
}

.rotation-handle:active {
    --handle-scale: 0.95;
}

/* Position handles flush with top, fully outside the container */
.rotation-handle-tl {
    top: 0;
    left: -32px;
    transform: rotate(-90deg) scale(var(--handle-scale)); /* Always tilted left */
}

.rotation-handle-tr {
    top: 0;
    right: -32px;
    transform: rotate(90deg) scale(var(--handle-scale)); /* Always tilted right */
}

/* Rotation icons - circular reload arrows (different from undo/redo) */
.rotation-handle-tl::before {
    content: '↺';
    font-size: 18px;
    color: color-mix(in srgb, var(--text-primary) 50%, transparent 50%);
    line-height: 1;
    display: inline-block;
    transform: rotate(-45deg);
    transition: color 0.2s ease;
}

.rotation-handle-tr::before {
    content: '↻';
    font-size: 18px;
    color: color-mix(in srgb, var(--text-primary) 50%, transparent 50%);
    line-height: 1;
    display: inline-block;
    transform: rotate(45deg);
    transition: color 0.2s ease;
}

.diagram-container.rotated-90 .rotation-handle-tl::before {
    content: '↻';
    transform: rotate(-225deg);
}

.diagram-container.rotated-90 .rotation-handle-tr::before {
    content: '↺';
    transform: rotate(-315deg);
}

.diagram-container.rotated-270 .rotation-handle-tl::before {
    content: '↺';
    transform: rotate(-315deg);
}

.diagram-container.rotated-270 .rotation-handle-tr::before {
    content: '↻';
    transform: rotate(-225deg);
}

.rotation-handle:hover::before {
    color: #ffffff;
}

/* Dark theme - uses same color-mix, so no override needed */

/* Hover state works across all themes */

#canvasWrapper canvas {
    margin: 0 auto;
}

canvas {
    border: none;
    background: var(--fingerboard-bg, white);
    display: block;
    margin: 40px auto 0 auto;
}

html.theme-dark #FingerboardCanvas {
    border-radius: 15px;
}

#downloadBtn {
    display: block;
    margin: 0px auto;
    padding: 10px 20px;
    background: #4CAF50;
    color: #ffffff;
    border: 2px solid #ffffff7d;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
    position: relative;
    z-index: 10;
    margin-top: -20px;
}

#downloadBtn:hover {
    background: #45a049;
}

.piano-download-wrapper {
    margin-top: 2em;
}

button {
    background-color: var(--button-primary-bg);
    color: var(--button-primary-text);
    border: 2px solid transparent; /* Add transparent border to prevent size changes */
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

button:hover {
    background-color: var(--button-primary-hover);
    /* Removed transform to prevent jiggle */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

button:disabled {
    background-color: #cccccc;
    color: #888888;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.7;
}

button.active {
    background-color: #2c7d59;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.7); /* Border already accounted for */
    font-weight: bold;
}

#muteButton {
    margin-left: 4px;
}

.mute-button {
    background-color: var(--button-primary-bg);
    color: var(--button-primary-text);
    border: 2px solid transparent; /* Consistent border handling */
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: var(--mute-button-font-size);
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.mute-button:hover {
    background-color: var(--button-primary-hover);
}

select {
    padding: 6px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background-color: var(--input-bg);
    color: var(--text-primary);
    font-size: 14px;
}

/* Control groups for organized toolbar sections */
.control-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    margin: 0 6px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.control-group.history-actions button {
    margin: 0 2px;
}

.control-group.instrument-config {
    background: rgba(58, 54, 96, 0.28);
    overflow: visible;
    position: relative;
    padding: 3px 8px;
    border-radius: 8px;
    border: 1px solid rgba(150, 140, 210, 0.35);
}

.control-group.instrument-config button,
.control-group.instrument-config select {
    margin: 0 2px;
}

.control-group.utility-actions {
    background: rgba(58, 54, 96, 0.28);
    padding: 3px 8px;
    border-radius: 8px;
    border: 1px solid rgba(150, 140, 210, 0.35);
}

.control-group.utility-actions button {
    height: 28px;
    padding: 0 10px;
    line-height: 1.1;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Config label styling - matches .preference-label for uniformity */
.config-label {
    font-size: 10px;
    font-weight: 600;
    color: rgba(150, 180, 220, 0.85);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 6px;
    white-space: nowrap;
}

/* Fret count dropdown */
.fret-count-select {
    background: linear-gradient(180deg, #f9fbff 0%, #dfe7f7 100%);
    border: 2px solid rgba(120, 150, 200, 0.6);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 28px 4px 10px;
    height: 29px;
    min-width: 60px;
    color: #2f3f56;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    position: relative;
    z-index: 10;
}

.fret-count-select.is-hidden {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}

.fret-count-dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.fret-count-trigger {
    background: linear-gradient(180deg, #2a2b47 0%, #202443 100%);
    border: 1px solid rgba(155, 165, 230, 0.6);
    border-radius: 8px;
    color: rgba(235, 231, 255, 0.7);
    font-size: 14px;
    font-weight: 600;
    padding: 4px 26px 4px 10px;
    height: 28px;
    min-width: 62px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.fret-count-trigger::after {
    content: "";
    position: absolute;
    right: 8px;
    top: 50%;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 6px solid rgba(235, 230, 255, 0.8);
    transform: translateY(-35%);
}

.fret-count-trigger:hover {
    border-color: rgba(120, 170, 255, 0.9);
    box-shadow: 0 4px 10px rgba(70, 130, 255, 0.25);
    color: rgba(235, 231, 255, 1);
}

.fret-count-trigger:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(90, 160, 255, 0.35);
}

.fret-count-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: rgba(30, 30, 52, 0.98);
    border: 1px solid rgba(140, 150, 220, 0.45);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 14px 26px rgba(18, 14, 32, 0.45);
    display: none;
    z-index: 20;
    min-width: 78px;
}

.fret-count-menu.open {
    display: grid;
    gap: 4px;
}

.fret-count-option {
    background: rgba(44, 44, 72, 0.85);
    border: 1px solid transparent;
    border-radius: 6px;
    color: #ebe7ff;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    text-align: left;
    cursor: pointer;
}

.fret-count-option:hover {
    border-color: rgba(140, 170, 255, 0.75);
    background: rgba(66, 70, 120, 0.8);
}

.fret-count-option.active {
    background: rgba(118, 114, 255, 0.35);
    border-color: rgba(160, 170, 255, 0.9);
}

.fret-count-select:hover {
    border-color: rgba(90, 160, 255, 0.9);
    box-shadow: 0 4px 10px rgba(70, 130, 255, 0.2);
}

.fret-count-select:focus {
    border-color: rgba(90, 160, 255, 1);
    box-shadow: 0 0 0 3px rgba(90, 160, 255, 0.25);
}

/* Help button styling */
.help-button {
    background: linear-gradient(135deg, #4a4f8d 0%, #3a3f78 100%) !important;
    color: rgba(235, 231, 255, 0.85) !important;
    border: 1px solid rgba(140, 150, 220, 0.35) !important;
    height: 28px;
    padding: 0 10px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.help-button:hover {
    background: linear-gradient(135deg, #5a63b0 0%, #4953a0 100%) !important;
    border-color: rgba(150, 170, 255, 0.7) !important;
    color: rgba(235, 231, 255, 0.95) !important;
    box-shadow: 0 0 8px rgba(120, 150, 255, 0.35);
}

/* Note preference toggle */
.note-preference {
    display: inline-flex;
    align-items: center;
    margin: 0 6px;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(58, 54, 96, 0.28);
    border-radius: 8px;
    border: 1px solid rgba(150, 140, 210, 0.35);
}

.preference-label {
    font-size: 14px;
    font-weight: 600;
    color: rgba(200, 190, 230, 0.85);
    margin-right: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.note-toggle {
    background: linear-gradient(135deg, #4a4f8d 0%, #3a3f78 100%);
    border: 1px solid rgba(140, 150, 220, 0.35);
    margin: 0 2px;
    padding: 0 10px;
    width: 32px;
    height: 28px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    color: rgba(235, 231, 255, 0.7);
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.note-toggle:not(.active) {
    background: linear-gradient(135deg, #4a4f8d 0%, #3a3f78 100%);
    border-color: rgba(120, 130, 200, 0.3);
}

.note-toggle:first-child {
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
}

.note-toggle:last-child {
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
}

.note-toggle:hover {
    background: linear-gradient(135deg, #5a63b0 0%, #4953a0 100%);
    color: rgba(235, 231, 255, 0.95);
    border-color: rgba(150, 170, 255, 0.7);
}

.note-toggle.active {
    background: linear-gradient(135deg, #6a7bff 0%, #4e63e6 100%);
    border-color: rgba(170, 190, 255, 0.9);
    color: white;
    box-shadow: 0 0 12px rgba(120, 150, 255, 0.55), 0 2px 6px rgba(0, 0, 0, 0.35);
}

#neutralToggle {
    width: auto;
    min-width: 46px;
    padding: 0 8px;
    font-size: 11px;
    letter-spacing: 0.3px;
    border-radius: 6px;
}

#neutralToggle .direction-arrows {
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    margin-left: 4px;
    position: relative;
    top: 1px;
}

#autoLabelToggle:not(.canvas-overlay-button) {
    background-color: #34495e;
    border: 2px solid transparent;
    padding: 6px 12px;
    height: 30px;
    font-size: 13px;
    line-height: 1.1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-weight: 600;
}

#autoLabelToggle:not(.canvas-overlay-button):hover {
    background-color: #2c3e50;
    border-color: rgba(0, 230, 118, 0.3);
    box-shadow: 0 0 8px rgba(0, 230, 118, 0.2);
}

#undoActionButton, #redoActionButton {
    background: linear-gradient(180deg, #3e4272 0%, #2f3563 100%);
    border: 1px solid rgba(140, 150, 220, 0.45);
    border-radius: 6px;
    font-size: 13px;
    min-width: 60px;
    padding: 6px 10px;
    height: 29px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 2px;
    color: rgba(235, 231, 255, 0.85);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 10px rgba(20, 24, 46, 0.35);
    transition: all 0.2s ease;
}

#undoActionButton:hover:not(:disabled), #redoActionButton:hover:not(:disabled) {
    background: linear-gradient(180deg, #4a5090 0%, #3b4490 100%);
    border-color: rgba(150, 170, 255, 0.75);
    color: rgba(235, 231, 255, 1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 6px 14px rgba(30, 40, 90, 0.4);
}

#undoActionButton:disabled, #redoActionButton:disabled {
    background: linear-gradient(180deg, #2c304f 0%, #24284a 100%);
    border-color: rgba(90, 100, 160, 0.45);
    color: rgba(200, 198, 230, 0.45);
    box-shadow: none;
    cursor: not-allowed;
}

/* Flash animation for undo/redo button feedback */
@keyframes actionFlash {
    0% {
        background: linear-gradient(180deg, #6f78ff 0%, #5866e6 100%);
        border-color: rgba(150, 190, 255, 0.9);
        box-shadow: 0 0 12px rgba(120, 150, 255, 0.5), 0 0 20px rgba(120, 150, 255, 0.35);
        transform: scale(1.05);
    }
    100% {
        background: linear-gradient(180deg, #3e4272 0%, #2f3563 100%);
        border-color: rgba(140, 150, 220, 0.45);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 10px rgba(20, 24, 46, 0.35);
        transform: scale(1);
    }
}

#undoActionButton.action-flash,
#redoActionButton.action-flash {
    animation: actionFlash 0.4s ease-out;
}

#clearBoardButton {
    background-color: #e74c3c;
    border: 2px solid rgba(180, 60, 50, 0.6);
    border-radius: 6px;
    padding: 0 10px;
    font-size: 13px;
    height: 29px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-weight: 600;
    color: white;
    box-shadow: 0 4px 10px rgba(180, 60, 50, 0.18);
}

#clearBoardButton:hover:not(:disabled) {
    background-color: #c0392b;
    border-color: rgba(0, 230, 118, 0.3);
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.3), 0 0 4px rgba(0, 230, 118, 0.15);
}

#clearBoardButton:disabled {
    background: linear-gradient(180deg, #2c304f 0%, #24284a 100%);
    border: 1px solid rgba(90, 100, 160, 0.45);
    color: rgba(200, 198, 230, 0.45);
    font-weight: 500;
    box-shadow: none;
    cursor: not-allowed;
}

#undoButton {
    background-color: #f39c12;
    border: 2px solid transparent; /* Prevent size changes */
    margin-right: 5px;
}

#undoButton:hover:not(:disabled) {
    background-color: #e67e22;
}

#helpButton {
    background-color: #3498db;
    border: 2px solid transparent;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 14px;
    height: 28px;
    line-height: 1.1;
    min-width: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

#helpButton:hover {
    background-color: #2980b9;
    border-color: rgba(0, 230, 118, 0.3);
    box-shadow: 0 0 8px rgba(52, 152, 219, 0.3), 0 0 4px rgba(0, 230, 118, 0.15);
}

/* Zoom indicator */
#zoomIndicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    transition: opacity 0.5s ease-in-out;
}

.chord-indicator {
    display: none !important;
    position: fixed;
    top: 10.9em;
    left: 12px;
    width: auto;
    min-width: max-content;
    padding: 8px 12px;
    gap: 6px;
    cursor: default;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-color: #81c784;
    color: #2e7d32;
    transition: box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    z-index: 100;
    height: auto;
    align-items: flex-start;
}

.playback-control-dock {
    position: sticky;
    top: 52px;
    left: 0;
    right: 0;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    pointer-events: none;
    background: transparent;
    z-index: 200;
}

.playback-control-dock > * {
    pointer-events: auto;
}

.playback-control-dock .chord-indicator {
    position: static;
    top: auto;
    left: auto;
    flex-shrink: 0;
}

.chord-indicator.visible {
    display: flex !important;
}

/* Prep Window Controls (top-right, opposite of chord indicator) */
.prep-window-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

.prep-status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #aaa;
    user-select: none;
}

.prep-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.prep-status-dot.synced {
    background-color: #4ecf4e;
    box-shadow: 0 0 6px rgba(78, 207, 78, 0.5);
}

.prep-status-dot.dirty {
    background-color: #f0a030;
    box-shadow: 0 0 6px rgba(240, 160, 48, 0.5);
    animation: prep-pulse 1.5s ease-in-out infinite;
}

@keyframes prep-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.prep-push-btn {
    padding: 6px 14px;
    border: 1px solid #555;
    border-radius: 6px;
    background: #333;
    color: #888;
    font-size: 12px;
    font-weight: 600;
    cursor: not-allowed;
    transition: all 0.2s ease;
    user-select: none;
    white-space: nowrap;
}

.prep-push-btn:disabled {
    opacity: 0.5;
}

.prep-push-btn.has-edits {
    background: #2a6b2a;
    border-color: #4ecf4e;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(78, 207, 78, 0.3);
}

.prep-push-btn.has-edits:hover {
    background: #3a8b3a;
    box-shadow: 0 0 12px rgba(78, 207, 78, 0.5);
}

.prep-push-btn.pushed-flash {
    background: #4ecf4e;
    color: #000;
    border-color: #4ecf4e;
}

.prep-pull-btn {
    padding: 6px 10px;
    border: 1px solid #444;
    border-radius: 6px;
    background: #2a2a2a;
    color: #aaa;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    white-space: nowrap;
}

.prep-pull-btn:hover {
    background: #3a3a3a;
    border-color: #666;
    color: #ddd;
}

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

.chord-indicator .indicator-emoji {
    font-size: 18px;
    line-height: 1;
}

.chord-indicator .indicator-label {
    font-size: 14px;
    font-weight: 600;
    white-space: normal;
    font-family: Arial, sans-serif;
    display: block;
}

.detective-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detective-label.detective-label-inline {
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
    white-space: nowrap;
}

.detective-prefix {
    font-size: 13px;
    font-weight: 700;
}

.detective-label.fragment .detective-prefix {
    font-weight: 400;
}

.detective-inline-group {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    white-space: nowrap;
}

.detective-inline-sep {
    opacity: 0.6;
}

.detective-label.inline {
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
    white-space: nowrap;
}

.detective-label.inline .detective-line {
    flex-wrap: nowrap;
    white-space: nowrap;
}

.detective-line {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
}

.detective-token {
    display: inline-flex;
    align-items: baseline;
    letter-spacing: 0.01em;
    transition: opacity 0.2s ease;
}

.detective-token.root {
    text-shadow: 0 2px 6px rgba(34, 197, 94, 0.45);
}

.detective-accidental {
    font-size: 0.7em;
    line-height: 1;
    position: relative;
    top: -0.15em;
    margin-right: -1px;
}

.detective-inline-degrees.has-accidentals,
.detective-line-degrees.has-accidentals {
    gap: 0;
}

.scale-parent-info {
    position: relative;
    display: none;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.65);
    color: #1f2937;
    font-size: 12px;
    margin-left: 6px;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.scale-parent-info.visible {
    display: inline-flex;
}

.scale-parent-info .scale-parent-tooltip {
    position: absolute;
    bottom: 130%;
    right: -6px;
    transform: translateY(8px);
    background: rgba(12, 20, 35, 0.95);
    color: #f8fafc;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}

.scale-parent-info:hover .scale-parent-tooltip,
.scale-parent-info:focus-visible .scale-parent-tooltip {
    opacity: 1;
    transform: translateY(0);
}

.detective-options {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 12px;
    display: none;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
    color: #e2e8f0;
    pointer-events: auto;
    z-index: 210;
}

.detective-options.visible {
    display: flex;
}

.detective-panel {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.88);
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.4);
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

/* Both panels light up together when hovering the container */
.detective-options:hover .detective-panel,
.detective-options.dragging .detective-panel,
.detective-options.root-assigned .detective-panel {
    opacity: 1;
}

/* Success message styling */
.detective-root-success {
    font-size: 11px;
    font-weight: 600;
    color: rgba(34, 197, 94, 0.95);
    margin-left: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.detective-options.root-assigned .detective-root-success {
    opacity: 1;
}

.detective-panel-options {
    justify-content: space-between;
}

.detective-panel-root {
    justify-content: flex-start;
}

.detective-options-header {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(226, 232, 240, 0.85);
}

.detective-options-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}

.detective-toggle {
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(30, 41, 59, 0.9);
    color: #e2e8f0;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.detective-toggle.active {
    border-color: rgba(34, 197, 94, 0.8);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.detective-root-pad {
    display: flex;
    align-items: center;
    gap: 6px;
}

.detective-root-title {
    font-size: 11px;
    font-weight: 600;
}

#detectiveRootCanvas {
    width: 52px;
    height: 52px;
    margin: 0 auto !important;
    border-radius: 12px;
    border: 1px solid rgba(226, 232, 240, 0.2);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    cursor: grab;
}

#detectiveRootCanvas.dragging {
    cursor: grabbing;
    outline: 2px solid rgba(59, 130, 246, 0.6);
}

.detective-root-hint {
    font-size: 10px;
    color: rgba(226, 232, 240, 0.7);
}

html.theme-dark .chord-indicator .indicator-label,
:root.theme-dark .chord-indicator .indicator-label,
html[data-theme="dark"] .chord-indicator .indicator-label {
    font-weight: 500;
}

.chord-indicator:hover {
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.35), 0 0 0 2px rgba(76, 175, 80, 0.25);
    border-color: #4caf50;
    background: linear-gradient(135deg, #e0f4e4 0%, #c0e2c3 100%);
}

html.theme-dark .chord-indicator,
:root.theme-dark .chord-indicator,
html[data-theme="dark"] .chord-indicator {
    background: linear-gradient(135deg, #113321 0%, #0c2819 100%);
    border-color: rgba(34, 201, 119, 0.75);
    color: #d8f6e6;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

html.theme-dark .chord-indicator:hover,
:root.theme-dark .chord-indicator:hover,
html[data-theme="dark"] .chord-indicator:hover {
    border-color: rgba(34, 201, 119, 0.95);
    box-shadow:
      0 0 0 3px rgba(34, 201, 119, 0.28),
      0 12px 28px rgba(0, 0, 0, 0.4),
      0 0 18px rgba(34, 201, 119, 0.45);
    background: linear-gradient(135deg, #15432a 0%, #0f3522 100%);
    color: #e7f4ff;
}

.audio-unlock {
    position: absolute;
    top: 12px;
    left: 120px;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(255, 243, 205, 0.95);
    color: #7a5c00;
    border: 1px solid #f1c40f;
    font-size: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    pointer-events: none;
}

.audio-unlock.hidden {
    display: none;
}

#pianoSvgContainer {
    padding: 20px;
    padding-top: 30px !important;
    overflow-x: auto;
    background: var(--panel-muted);
    border-radius: 10px;
    min-height: 240px;
    border: 1px solid transparent;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: center;
    justify-self: center;
    padding-left: 36px;
    padding-right: 0px;
}

#pianoSvgContainer:focus,
#pianoSvgContainer:focus-visible {
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
#settingsButton, .utility-button {
    background: linear-gradient(135deg, #4a4f8d 0%, #3a3f78 100%);
    padding: 0 10px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid rgba(140, 150, 220, 0.35);
    border-radius: 6px;
    color: rgba(235, 231, 255, 0.85);
    cursor: pointer;
    height: 28px;
    line-height: 1.1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.change-instrument-button {
    background: linear-gradient(135deg, #4a4f8d 0%, #3a3f78 100%);
    width: 90px;
}

#settingsButton:hover, .utility-button:hover {
    background: linear-gradient(135deg, #5a63b0 0%, #4953a0 100%);
    border-color: rgba(150, 170, 255, 0.7);
    color: rgba(235, 231, 255, 0.95);
    box-shadow: 0 0 8px rgba(120, 150, 255, 0.35);
}

.change-instrument-button:hover {
    background: linear-gradient(135deg, #5a63b0 0%, #4953a0 100%);
    border-color: rgba(150, 170, 255, 0.7);
    box-shadow: 0 0 8px rgba(120, 150, 255, 0.35);
}

.logout-button {
    background-color: #7c3aed;
    width: 90px;
}

.logout-button:hover {
    background-color: #6d28d9;
    border-color: rgba(167, 139, 250, 0.4);
    box-shadow: 0 0 8px rgba(124, 58, 237, 0.3), 0 0 4px rgba(167, 139, 250, 0.15);
}
