/* VISUALIZER CONTAINER */
#visualizer-container { 
    position: relative; 
    width: 100%; 
    min-width: 300px;
    max-width: 100%;
    margin-bottom: 0;
    margin-top: 5px;
    box-sizing: border-box;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#visualizer {
    width: 100%; 
    height: 340px;
    display: block;
    margin-top: 0;
    padding-top: 55px;
    border-radius: 0;
    border: none;
}

/* File Navigation */
.visualizer-file-navigation {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    width: 100%;
    flex-shrink: 0;
    z-index: var(--z-dropdown);
}

/* LCD / Toggle View */
#toggleView {
    position: relative;
    left: auto;
    transform: none;
    top: auto;
    background: rgba(17, 17, 17, 0.2);
    border: 1px solid rgba(80, 80, 90, 0.3);
    padding: 6px 12px;
    border-radius: 3px;
    z-index: var(--z-dropdown);
    width: auto;
    min-width: 300px;
    max-width: calc(100% - 80px);
    font-family: "Noto Sans", monospace;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.visualizer-file-box-wrapper {
    display: flex;
    align-items: center;
    border: none;
    border-radius: 0;
    overflow: hidden;
}

.visualizer-file-box {
    position: relative;
    left: auto;
    transform: none;
    top: auto;
    background: transparent;
    border: none;
    padding: 4px 10px;
    border-radius: 0;
    z-index: var(--z-dropdown);
    width: auto;
    min-width: 300px;
    max-width: calc(100% - 80px);
    font-family: "JetBrains Mono", "SF Mono", "Roboto Mono", Menlo, Monaco, "Courier New", monospace;
    font-size: 10px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.visualizer-file-box:focus {
    outline: none;
}

.visualizer-file-box * {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.visualizer-file-box:hover {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.9);
}

/* LCD Elements */
.lcd-element {
    font-family: 'Courier New', Courier, monospace;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 11px;
    color: #b3b3b3;
    font-weight: bold;
    cursor: pointer;
    -webkit-font-smoothing: antialiased;
    text-shadow: 0 0 3px rgba(179, 179, 179, 0.35);
}

.lcd-filename {
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    text-align: left;
    flex: 1;
    max-width: 130px;
    color: #b3b3b3;
    text-shadow: 0 0 3px rgba(179, 179, 179, 0.35);
}

.lcd-filename:hover {
    color: #c6c6c6;
    text-shadow: 0 0 5px rgba(179, 179, 179, 0.55);
}

.lcd-filename-inner {
    display: inline-block;
}

.lcd-filename.scrolling .lcd-filename-inner {
    padding-left: 100%;
    animation: lcd-scroll 10s linear infinite;
}

@keyframes lcd-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

.lcd-filename.scrolling:hover .lcd-filename-inner {
    animation-play-state: paused;
}

/* Morph/Snap Toggle */
.morph-toggle.mode-button {
    font-size: 9px;
    padding: 2px 6px;
    margin: 0 4px;
    flex: 0 0 auto;
    position: relative;
    z-index: 11;
    background: var(--control-bg);
    border: none;
    border-radius: 2px;
    color: var(--text-secondary);
    font-weight: 500;
}

.morph-toggle.mode-button:hover {
    transform: translateY(-1px);
}

.morph-toggle.mode-button.active {
    background: var(--text-secondary);
    color: #181820;
    font-weight: bold;
    box-shadow: 0 0 8px var(--text-secondary);
}

/* Mode Toggle */
.mode-toggle {
    position: relative;
    font-weight: 700;
    text-align: center;
    flex: 0 0 auto;
    color: #b3b3b3;
    text-shadow: 0 0 3px rgba(179, 179, 179, 0.35);
}

.mode-toggle.mode3d {
    color: #c6c6c6;
    font-weight: 700;
    text-shadow: 0 0 5px rgba(179, 179, 179, 0.55);
}

/* MIDI Status in LCD */
.lcd-midi-status {
    position: relative;
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
}

.lcd-midi-status::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 1px;
    background-color: #777;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2);
}

.lcd-midi-status.connected {
    color: #5a5a5a;
    font-weight: 700;
}

.lcd-midi-status.connected::before {
    background-color: #5a5a5a;
    box-shadow: 0 0 0 1px rgba(90,90,90,0.3);
}

/* BPM & PB Controls Wrapper - Now a row container */
.visualizer-row-3-controls-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 25px;
    margin-top: 12px;
}

/* P button column - separate from aligned controls */
.poly-button-column {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* Aligned controls column - KBD/BPM/PB stack */
.aligned-controls-column {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
}

.bpm-control-container {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
}

.bpm-label {
    font-family: "Noto Sans", monospace;
    font-size: 8px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 20px;
    text-align: right;
}

/* Unified stepper box: [< display >] */
.stepper-box {
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    overflow: hidden;
}

.bpm-input {
    background: transparent;
    border: none;
    color: rgba(190, 190, 190, 0.7);
    font-family: "JetBrains Mono", "SF Mono", "Roboto Mono", Menlo, Monaco, "Courier New", monospace;
    font-size: 9px;
    font-weight: bold;
    padding: 2px 1px;
    width: 20px;
    min-width: 20px;
    max-width: 20px;
    text-align: center;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

.bpm-input:focus {
    outline: none;
    background: transparent;
}

.bpm-nav-arrow {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 14px;
    min-width: 14px;
    height: 16px;
    padding: 0;
    border-radius: 0;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.15s ease;
    outline: none;
}

.bpm-nav-arrow:hover {
    background: transparent;
    color: rgba(255, 255, 255, 0.9);
    transform: none;
}

.bpm-nav-arrow:active {
    background: transparent;
    transform: scale(0.95);
}

/* Wavetable Navigation Arrows */
.wavetable-nav-arrow {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 18px;
    height: 22px;
    padding: 0;
    border-radius: 0;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
    line-height: 1;
}

.wavetable-nav-arrow:hover {
    background: rgba(26, 26, 26, 1);
    border-color: rgba(80, 80, 90, 0.8);
    color: var(--text-secondary);
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.5);
}

.wavetable-nav-arrow:active {
    background: rgba(20, 20, 20, 1);
    transform: scale(0.95);
}

.wavetable-nav-arrow:disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
    pointer-events: none;
}

/* Row 2: AUX OSCS | Canvas | Main Controls */
.visualizer-row-2 {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0;
    width: 100%;
    flex: 1;
    min-height: 0;
    background: #0d0d0d;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}

/* Column 2: Canvas with Grid */
.visualizer-col-2 {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
    background: #0d0d0d;
    --grid-size: 30px;
    position: relative;
    min-height: 100%;
    background-image: 
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent calc(var(--grid-size) - 0.5px),
            rgba(80, 80, 90, 0.15) calc(var(--grid-size) - 0.5px),
            rgba(80, 80, 90, 0.15) calc(var(--grid-size) + 0.5px),
            transparent calc(var(--grid-size) + 0.5px),
            transparent var(--grid-size)
        ),
        repeating-linear-gradient(
            to right,
            transparent 0,
            transparent calc(var(--grid-size) - 0.5px),
            rgba(80, 80, 90, 0.15) calc(var(--grid-size) - 0.5px),
            rgba(80, 80, 90, 0.15) calc(var(--grid-size) + 0.5px),
            transparent calc(var(--grid-size) + 0.5px),
            transparent var(--grid-size)
        );
    background-size: var(--grid-size) var(--grid-size), var(--grid-size) var(--grid-size);
    background-position: 0 0, 0 0;
    background-repeat: repeat;
}

.visualizer-col-2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(80, 80, 90, 0.3);
    z-index: var(--z-base);
}

.visualizer-col-2 #visualizer {
    width: 100%;
    height: 340px;
    display: block;
    margin: 0;
    padding: 0;
    border-radius: 0 !important;
    border: none !important;
    background: transparent;
    flex-shrink: 0;
}

/* Row 3: Knobs row */
.visualizer-row-3 {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 9px;
    width: 100%;
    box-sizing: border-box;
}

.visualizer-row-3-divider {
    width: 1px;
    height: 65px;
    background: rgba(80, 80, 90, 0.3);
    flex-shrink: 0;
}

.visualizer-row-3-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin: 0;
}

/* P button - Match LFO pagination button style, in separate column */
#polyModeToggle {
    font-family: "JetBrains Mono", "SF Mono", "Roboto Mono", Menlo, Monaco, "Courier New", monospace;
    background: var(--control-bg);
    color: var(--text-secondary);
    border: none;
    border-radius: 2px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: var(--text-2xs);
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    flex-shrink: 0;
}

#polyModeToggle:hover {
    background: #3c3c45;
    transform: translateY(-1px);
}

#polyModeToggle.active {
    background: var(--text-secondary);
    color: #181820;
    font-weight: bold;
    box-shadow: 0 0 8px var(--text-secondary);
}

/* Octave buttons inside stepper-box */
.visualizer-row-3-controls #octaveDownButton,
.visualizer-row-3-controls #octaveUpButton {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 14px;
    min-width: 14px;
    height: 16px;
    padding: 0;
    margin: 0;
    border-radius: 0;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.15s ease;
    outline: none;
}

.visualizer-row-3-controls #octaveDownButton:hover,
.visualizer-row-3-controls #octaveUpButton:hover {
    background: transparent;
    color: rgba(255, 255, 255, 0.9);
    transform: none;
}

.visualizer-row-3-controls #octaveDownButton:active,
.visualizer-row-3-controls #octaveUpButton:active {
    background: transparent;
    transform: scale(0.95);
}

/* Octave display inside stepper-box */
.visualizer-row-3-controls #octaveDisplay {
    background: transparent;
    border: none;
    color: rgba(190, 190, 190, 0.7);
    font-family: "JetBrains Mono", "SF Mono", "Roboto Mono", Menlo, Monaco, "Courier New", monospace;
    font-size: 9px;
    font-weight: bold;
    padding: 2px 1px;
    border-radius: 0;
    width: 20px;
    min-width: 20px;
    max-width: 20px;
    text-align: center;
    user-select: none;
    box-sizing: border-box;
    margin: 0;
}

