/* Shared Write / Automation Rec blink — one timeline so both stay in phase */
@property --kb-rec-blink {
    syntax: '<number>';
    inherits: true;
    initial-value: 1;
}
@keyframes kb-rec-blink {
    0%, 45% { --kb-rec-blink: 1; }
    55%, 100% { --kb-rec-blink: 0.15; }
}
html {
    animation: kb-rec-blink 1s step-end infinite;
}

    body {
        margin: 0;
        padding: 20px;
        background: url('https://img.freepik.com/free-vector/wood-vector-texture-template-pattern-seamless-material-hardwood-floor-natural-light-parquet-vector-illustration_1284-47074.jpg');
        font-family: 'Michroma', sans-serif;
        color: #fff;
    }
    .container {
        max-width: 1200px;
        margin: 0 auto;
    }
    h1 {
        text-align: center;
        margin: 0 0 10px 0;
        font-size: 50px;
        font-style: italic;
        color: #000;
        letter-spacing: 25px;
    }
    
    /* Add responsive styles for mobile */
    @media (max-width: 768px) {
        body {
            padding: 10px;
        }
        h1 {
            font-size: 26px;
            letter-spacing: 10px;
            text-align: center;
            width: 100%;
            overflow-x: hidden;
            white-space: normal;
            margin: 10px 0;
            padding: 0 5px;
            box-sizing: border-box;
        }
        .synth-container {
            grid-template-columns: 1fr !important;
        }
        .header-grid {
            grid-template-columns: 1fr !important;
        }
        .midi-buttons-container {
            flex-direction: column;
            gap: 10px;
        }
        .button-grid {
            grid-template-columns: 1fr !important;
        }
        .button-grid {
            flex-direction: column !important;
            align-items: center !important;
            gap: 10px !important;
        }
        #midiDeviceSelector, #midiOutputSelector {
            flex-direction: column;
        }
        /* Hide the original start/stop button on mobile */
        .section .sequencer-controls #startStop {
            display: none !important;
        }
        /* Show mobile start/stop button only on mobile */
        .mobile-start-stop-container {
            display: flex !important;
            justify-content: center !important;
            margin: 15px 0 !important;
        }
    }
    
    /* Hide mobile start/stop on desktop by default */
    .mobile-start-stop-container {
        display: none;
    }
    
    /* Improved touch targets */
    .touch-target {
        min-width: 44px !important;
        min-height: 44px !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        touch-action: manipulation !important;
    }
    
    /* Mobile Swipe Navigation */
    @media (max-width: 768px) {
        .synth-container {
            display: flex !important;
            flex-wrap: nowrap !important;
            overflow-x: hidden !important;
            scroll-snap-type: x mandatory !important;
            scroll-behavior: smooth !important;
            -webkit-overflow-scrolling: touch !important;
            width: 100% !important;
            position: relative !important;
            max-width: 100% !important;
            margin: 0 !important;
            padding: 0 !important;
            box-sizing: border-box !important;
            left: 0 !important;
        }
        
        /* Fix container width for mobile */
        .container {
            padding: 10px !important;
            width: 100% !important;
            max-width: 100% !important;
            box-sizing: border-box !important;
            overflow-x: hidden !important;
        }
        
        .section {
            flex: 0 0 100% !important;
            width: 100% !important;
            min-width: 100% !important;
            max-width: 100% !important;
            scroll-snap-align: start !important;
            scroll-snap-stop: always !important;
            padding: 10px !important;
            box-sizing: border-box !important;
        }
        
        .swipe-dots {
            display: flex !important;
            justify-content: center !important;
            margin: 15px 0 !important;
            align-items: center !important;
        }
        
        .swipe-dot {
            width: 10px !important;
            height: 10px !important;
            border-radius: 50% !important;
            background-color: #666 !important;
            margin: 0 5px !important;
            cursor: pointer !important;
            box-shadow: 0 0 2px rgba(255, 255, 255, 0.5) !important;
            transition: transform 0.2s ease !important;
        }
        
        .swipe-dot:hover, .swipe-dot:active {
            transform: scale(1.2) !important;
        }
        
        .swipe-dot.active {
            background-color: #00ff00 !important;
        }
        
        .swipe-arrow {
            width: 20px !important;
            height: 20px !important;
            color: #888 !important;
            display: flex !important;
            justify-content: center !important;
            align-items: center !important;
            cursor: pointer !important;
            margin: 0 10px !important;
            font-weight: bold !important;
            font-size: 18px !important;
            user-select: none !important;
            transition: color 0.2s ease !important;
        }
        
        .swipe-arrow:hover {
            color: #aaa !important;
        }
        
        .swipe-arrow:active {
            color: #00ff00 !important;
        }
        
        .swipe-arrow-left {
            margin-right: 5px !important;
        }
        
        .swipe-arrow-right {
            margin-left: 5px !important;
        }
    }
    #oscilloscope,
    #kbOscilloscope {
        display: block;
        width: 100%;
        height: 100%;
        background: #000;
        margin: 0;
        position: absolute;
        top: 0;
        left: 0;
    }
    
    /* Add new border overlay style */
    .oscilloscope-border {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 20; /* Higher than other elements */
        pointer-events: none; /* Allow clicks to pass through */
        background: url('internal-oscilloscope-border.svg') no-repeat center center;
        background-size: 100% 100%;
        opacity: 0.85; /* Make it more visible */
    }
    
    /* Oscilloscope container */
    .oscilloscope-container {
        position: relative;
        width: 400px;
        height: 170px;
        margin: 0 auto 20px;
        clip-path: polygon(21% 0, 79% 0, 100% 50%, 79% 100%, 21% 100%, 0% 50%);            
        background: #000;
        overflow: hidden; /* Ensure content is clipped to container shape */
    }
    
    @media (max-width: 768px) {
        .oscilloscope-container {
            width: 350px; /* Reduce width to fit mobile screens */
            height: 150px; /* Adjust height proportionally */
            transform: translateZ(0); /* Force hardware acceleration */
            -webkit-transform: translateZ(0); /* For Safari */
            margin: 0 auto 20px;
            /* Adjust clip-path for smaller dimensions */
            clip-path: polygon(74px 0px, 276px 0px, 350px 75px, 276px 150px, 74px 150px, 0px 75px);
        }
        
        /* Fix container width for mobile */
        .container {
            width: 100% !important;
            padding: 10px !important;
            max-width: 100% !important;
            box-sizing: border-box !important;
            overflow-x: hidden !important;
        }
        
        /* Don't use 100% dimensions for the oscilloscope itself on mobile */
        #oscilloscope,
        #kbOscilloscope {
            width: 350px !important; /* Match container dimensions exactly */
            height: 150px !important;
            transform: translateZ(0); /* Force hardware acceleration */
            -webkit-transform: translateZ(0); /* For Safari */
        }
        
        /* Ensure SVG border scales correctly on mobile */
        .oscilloscope-border {
            width: 350px !important;
            height: 150px !important;
            background-size: 350px 150px !important;
            transform: translateZ(0); /* Force hardware acceleration */
            -webkit-transform: translateZ(0); /* For Safari */
        }
        
        /* Ensure logo overlay also matches exact dimensions */
        #logo-overlay,
        #kb-logo-overlay {
            width: 350px !important;
            height: 150px !important;
            transform: translateZ(0); /* Force hardware acceleration */
            -webkit-transform: translateZ(0); /* For Safari */
        }
    }
    
    /* Logo overlay container */
    #logo-overlay,
    #kb-logo-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 10;
        background: #000;
        opacity: 0; /* Start invisible */
        animation: fadeIn 1.5s ease-in-out forwards, powerGlitch 15s infinite linear;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    #logo-overlay::before,
    #kb-logo-overlay::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: url('assets/oscilloscope-glass.jpg');
        background-size: cover;
        background-position: center;
        opacity: 0.25; /* 25% opacity */
        z-index: -1;
    }
    
    #logo-overlay.hidden,
    #kb-logo-overlay.hidden {
        animation: fadeOut 0.5s ease-in-out forwards;
    }
    
    /* Add glow flicker animation */
    .glow-flicker {
        animation: glowFlicker 4s infinite;
    }

    @keyframes glowFlicker {
        0%, 100% { filter: drop-shadow(0 0 5px #00ff00) drop-shadow(0 0 10px rgba(0, 255, 0, 0.7)); }
        5% { filter: drop-shadow(0 0 3px #00ff00) drop-shadow(0 0 7px rgba(0, 255, 0, 0.5)); }
        7% { filter: drop-shadow(0 0 8px #00ff00) drop-shadow(0 0 12px rgba(0, 255, 0, 0.8)); }
        10% { filter: drop-shadow(0 0 5px #00ff00) drop-shadow(0 0 10px rgba(0, 255, 0, 0.7)); }
        50% { filter: drop-shadow(0 0 5px #00ff00) drop-shadow(0 0 10px rgba(0, 255, 0, 0.7)); }
        52% { filter: drop-shadow(0 0 3px #00ff00) drop-shadow(0 0 7px rgba(0, 255, 0, 0.5)); }
        54% { filter: drop-shadow(0 0 6px #00ff00) drop-shadow(0 0 11px rgba(0, 255, 0, 0.7)); }
        56% { filter: drop-shadow(0 0 5px #00ff00) drop-shadow(0 0 10px rgba(0, 255, 0, 0.7)); }
        85% { filter: drop-shadow(0 0 5px #00ff00) drop-shadow(0 0 10px rgba(0, 255, 0, 0.7)); }
        87% { filter: drop-shadow(0 0 2px #00ff00) drop-shadow(0 0 5px rgba(0, 255, 0, 0.4)); }
        89% { filter: drop-shadow(0 0 7px #00ff00) drop-shadow(0 0 13px rgba(0, 255, 0, 0.8)); }
        91% { filter: drop-shadow(0 0 5px #00ff00) drop-shadow(0 0 10px rgba(0, 255, 0, 0.7)); }
    }

    #logo-overlay svg,
    #kb-logo-overlay svg {
        width: 80%;
        max-width: 230px;
        height: auto;
        /* Remove static filter since we're using animation */
        /* filter: drop-shadow(0 0 5px #00ff00) drop-shadow(0 0 10px rgba(0, 255, 0, 0.7)); */
        transform: none; /* Remove vertical adjustment */
        filter: drop-shadow(0 0 5px #00ff00) drop-shadow(0 0 10px rgba(0, 255, 0, 0.7));
        animation: glowFlicker 4s infinite;
    }
    
    /* CRT scanlines effect */
    .scanlines {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(to bottom, 
            transparent 0%, 
            rgba(0, 0, 0, 0.2) 50%, 
            transparent 51%, 
            transparent 100%);
        background-size: 100% 4px;
        z-index: 11;
        pointer-events: none;
        mix-blend-mode: overlay;
    }
    
    /* CRT flicker animation */
    .flicker {
        animation: flicker 0.15s infinite alternate;
    }
    
    /* Enhanced logo flicker animation */
    .logo-flicker {
        animation: logoFlicker 3s infinite;
    }
    
    @keyframes flicker {
        0% { opacity: 0.97; }
        100% { opacity: 1; }
    }
    
    @keyframes logoFlicker {
        0%, 100% { opacity: 1; filter: brightness(1); }
        5% { opacity: 0.9; filter: brightness(0.9); }
        7% { opacity: 1; filter: brightness(1.05); }
        9% { opacity: 0.95; filter: brightness(0.85); }
        11% { opacity: 1; filter: brightness(1); }
        40% { opacity: 1; filter: brightness(1); }
        42% { opacity: 0.9; filter: brightness(0.95); }
        44% { opacity: 1; filter: brightness(1); }
        80% { opacity: 1; filter: brightness(1); }
        83% { opacity: 0.95; filter: brightness(0.9); }
        87% { opacity: 1; filter: brightness(1.05); }
        90% { opacity: 0.98; filter: brightness(0.95); }
        92% { opacity: 1; filter: brightness(1); }
    }
    
    /* VHS static noise texture */
    .vhs-static {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMDAiIGhlaWdodD0iMzAwIj48ZmlsdGVyIGlkPSJhIiB4PSIwIiB5PSIwIj48ZmVUdXJidWxlbmNlIHR5cGU9ImZyYWN0YWxOb2lzZSIgYmFzZUZyZXF1ZW5jeT0iLjc1IiBzdGl0Y2hUaWxlcz0ic3RpdGNoIi8+PGZlQ29sb3JNYXRyaXggdHlwZT0ic2F0dXJhdGUiIHZhbHVlcz0iMCIvPjwvZmlsdGVyPjxyZWN0IHdpZHRoPSIzMDAiIGhlaWdodD0iMzAwIiBmaWx0ZXI9InVybCgjYSkiIG9wYWNpdHk9Ii4wNSIvPjwvc3ZnPg==');
        opacity: 0.3;
        mix-blend-mode: overlay;
        pointer-events: none;
        z-index: 12;
    }
    
    /* Random glitch effect */
    .glitch-container {
        position: relative;
        width: 100%;
        height: 100%;
        overflow: hidden;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .glitch {
        position: relative;
        width: 100%;
        height: 100%;
        animation: glitch 3s infinite;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    /* Animations */
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    @keyframes fadeOut {
        from { opacity: 1; }
        to { opacity: 0; }
    }
    
    @keyframes glitch {
        0%, 100% { transform: translate(0); }
        5% { transform: translate(-0.5px, 0.5px); }
        10% { transform: translate(1px, -1px); }
        15% { transform: translate(-1px); }
        20% { transform: none; }
        95% { transform: none; }
        96% { transform: translate(1px); }
        97% { transform: translate(-0.5px); }
        98% { transform: translate(1px, 1px); }
        99% { transform: translate(-1px, -1px); }
    }
    .synth-container {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
    .section {
        display: flex;
        flex-direction: column;
        gap: 10px;
        background: rgba(0, 0, 0, 0.7);
        padding: 15px;
        border-radius: 10px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    }
    .section h2 {
        margin: 0 0 10px 0;
        text-align: center;
        color: #ccc;
    }
    .control {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 5px;
        width: 100%;
    }
    input[type="range"] {
        width: 100px;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        background: linear-gradient(to bottom, #666 0%, #000 30%, #000 70%, #222 100%);
        border: 2px solid #555;
        border-radius: 5px;
        height: 6px;
        cursor: pointer;
        box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.8), inset 0 -2px 4px rgba(255, 255, 255, 0.2), 0 1px 3px rgba(0, 0, 0, 0.5);
    }
    
    /* Webkit (Chrome/Safari) Track Styling */
    input[type="range"]::-webkit-slider-track {
        -webkit-appearance: none;
        appearance: none;
        height: 6px;
        background: transparent;
        border: none;
        border-radius: 5px;
    }
    
    /* Webkit (Chrome/Safari) Thumb Styling */
    input[type="range"]::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: linear-gradient(135deg, #eee 0%, #ccc 25%, #999 75%, #666 100%);
        border: 2px solid #555;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6), inset 0 1px 2px rgba(255, 255, 255, 0.3), inset 0 -1px 2px rgba(0, 0, 0, 0.4);
        cursor: pointer;
        transition: all 0.2s ease-out;
        margin-top: -5px;
    }
    
    input[type="range"]::-webkit-slider-thumb:hover {
        box-shadow: 0 0 15px rgba(0, 255, 0, 0.3);
        transform: scale(1.05);
    }
    
    input[type="range"]::-webkit-slider-thumb:active {
        transform: scale(1.1);
        box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
    }
    
    /* Firefox Track Styling */
    input[type="range"]::-moz-range-track {
        height: 6px;
        background: transparent;
        border: none;
        border-radius: 5px;
    }
    
    /* Firefox Thumb Styling */
    input[type="range"]::-moz-range-thumb {
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: linear-gradient(135deg, #eee 0%, #ccc 25%, #999 75%, #666 100%);
        border: 2px solid #555;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6), inset 0 1px 2px rgba(255, 255, 255, 0.3), inset 0 -1px 2px rgba(0, 0, 0, 0.4);
        cursor: pointer;
        transition: all 0.2s ease-out;
    }
    
    input[type="range"]::-moz-range-thumb:hover {
        box-shadow: 0 0 15px rgba(0, 255, 0, 0.3);
        transform: scale(1.05);
    }
    
    input[type="range"]::-moz-range-thumb:active {
        transform: scale(1.1);
        box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
    }
    
    /* Edge/IE Track Styling */
    input[type="range"]::-ms-track {
        height: 6px;
        background: transparent;
        border-color: transparent;
        color: transparent;
    }
    
    input[type="range"]::-ms-fill-lower {
        background: #000;
        border: 2px solid #555;
        border-radius: 5px;
    }
    
    input[type="range"]::-ms-fill-upper {
        background: #000;
        border: 2px solid #555;
        border-radius: 5px;
    }
    
    /* Edge/IE Thumb Styling */
    input[type="range"]::-ms-thumb {
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: linear-gradient(135deg, #eee 0%, #ccc 25%, #999 75%, #666 100%);
        border: 2px solid #555;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6), inset 0 1px 2px rgba(255, 255, 255, 0.3), inset 0 -1px 2px rgba(0, 0, 0, 0.4);
        cursor: pointer;
        transition: all 0.2s ease-out;
    }
    
    input[type="range"]::-ms-thumb:hover {
        box-shadow: 0 0 15px rgba(0, 255, 0, 0.3);
        transform: scale(1.05);
    }
    
    input[type="range"]::-ms-thumb:active {
        transform: scale(1.1);
        box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
    }
    
    /* Focus state for accessibility */
    input[type="range"]:focus {
        outline: none;
    }
    
    input[type="range"]:focus::-webkit-slider-thumb {
        outline: 2px solid #00ff00;
        outline-offset: 2px;
    }
    
    input[type="range"]:focus::-moz-range-thumb {
        outline: 2px solid #00ff00;
        outline-offset: 2px;
    }
    
    input[type="range"]:focus::-ms-thumb {
        outline: 2px solid #00ff00;
        outline-offset: 2px;
    }
    
    /* MIDI Mapping Mode - Override green colors with cyan for slider thumbs */
    .midi-mapping-active input[type="range"]::-webkit-slider-thumb:hover {
        box-shadow: 0 0 15px rgba(0, 255, 255, 0.3); /* Cyan instead of green */
    }
    
    .midi-mapping-active input[type="range"]::-webkit-slider-thumb:active {
        box-shadow: 0 0 20px rgba(0, 255, 255, 0.5); /* Cyan instead of green */
    }
    
    .midi-mapping-active input[type="range"]::-moz-range-thumb:hover {
        box-shadow: 0 0 15px rgba(0, 255, 255, 0.3); /* Cyan instead of green */
    }
    
    .midi-mapping-active input[type="range"]::-moz-range-thumb:active {
        box-shadow: 0 0 20px rgba(0, 255, 255, 0.5); /* Cyan instead of green */
    }
    
    .midi-mapping-active input[type="range"]::-ms-thumb:hover {
        box-shadow: 0 0 15px rgba(0, 255, 255, 0.3); /* Cyan instead of green */
    }
    
    .midi-mapping-active input[type="range"]::-ms-thumb:active {
        box-shadow: 0 0 20px rgba(0, 255, 255, 0.5); /* Cyan instead of green */
    }
    
    /* Focus state also changes to cyan in MIDI mode */
    .midi-mapping-active input[type="range"]:focus::-webkit-slider-thumb {
        outline: 2px solid #00ffff;
    }
    
    .midi-mapping-active input[type="range"]:focus::-moz-range-thumb {
        outline: 2px solid #00ffff;
    }
    
    .midi-mapping-active input[type="range"]:focus::-ms-thumb {
        outline: 2px solid #00ffff;
    }
    .control label {
        font-size: 14px;
    }
    .control span {
        font-size: 10px;
    }
    .sequencer-controls {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
        margin-bottom: 10px;
    }
    button.pushable {
        background: linear-gradient(to bottom, #666, #333);
        border-radius: 8px;
        border: none;
        padding: 0;
        cursor: pointer;
        position: relative;
        display: inline-block;
        width: auto;
    }
    button.pushable .front {
        display: block;
        padding: 5px 10px;
        border-radius: 8px;
        background: linear-gradient(to bottom, #ccc, #999);
        color: #000;
        font-family: 'Michroma', sans-serif;
        transform: translateY(-4px);
        transition: transform 0.2s ease-out;
        white-space: nowrap;
    }
    #startStop.pushable {
        background: linear-gradient(to bottom, #1a1a1a, #000);
    }
    #startStop.pushable .front {
        padding: 10px 20px;
        font-size: 20px;
        background: linear-gradient(to bottom, #333, #000);
        color: #fff;
    }
    
    /* Mobile Start/Stop button styling - exactly match the original button */
    #mobileStartStop.pushable {
        background: linear-gradient(to bottom, #1a1a1a, #000);
        width: auto;
    }
    #mobileStartStop.pushable .front {
        padding: 10px 20px;
        font-size: 20px;
        background: linear-gradient(to bottom, #333, #000);
        color: #fff;
    }
    #mobileStartStop.start .front {
        color: #00ff00;
    }
    #mobileStartStop.stop .front {
        color: #ff0000;
    }
    
    button.pushable:hover .front {
        transform: translateY(-6px);
    }
    button.pushable:active .front {
        transform: translateY(-2px);
    }
    #startStop.start .front {
        color: #00ff00;
    }
    #startStop.stop .front {
        color: #ff0000;
    }
    .osc-toggle.off .front, .step-toggle.off .front, .noise-toggle.off .front, .filter-env-toggle.off .front {
        color: #ff0000;
    }
    .chorus-toggle.off .front {
        color: #ff0000;
    }
    #steps {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        min-width: 300px; /* Ensure minimum container width */
    }
    .sequencer-step {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 5px;
        padding: 8px 5px;
        margin: 0; /* Reset fieldset default margin */
        position: relative;
        max-width: calc(50% - 10px); /* Ensure at least 2 steps per row by limiting width to 50% minus gap */
        min-width: 120px; /* Minimum width for each step */
        box-sizing: border-box;
        border: 2px solid #555;  /* Match fieldset.control-group boxes */
        border-radius: 5px;
    }
    .sequencer-step legend {
        color: #aaa;        /* Match fieldset.control-group legend */
        padding: 0 5px;     /* Padding on left/right creates the border gap */
        font-size: 12px;
        font-weight: normal;
        display: block;
        width: fit-content;
        margin: 0 auto;     /* Center on the border line */
    }
    .sequencer-step.hidden {
        display: none;
    }
    .sequencer-step.active::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 65px;
        height: 65px;
        background: rgb(255, 0, 0);
        box-shadow: 0 0 10px 5px #ff0000;
        border-radius: 50%;
        transition: opacity 0.1s;
        opacity: 0.75;
        z-index: -1;
    }
    .sequencer-step:not(.active)::after {
        opacity: 0;
    }
    select {
        font-family: 'Michroma', sans-serif;
        background: #333;
        color: #00ff00;  /* Changed from #fff to #00ff00 */
        border: 1px solid #808080;  /* Changed from #fff to #808080 to match visualizers */
        padding: 5px;
        border-radius: 4px;
    }
    
    /* Exception rule for MIDI selects */
    #midiInputSelect, #midiOutputSelect, #midiOutputChannel, #midiBaseNote {
        color: #fff;
        border: 1px solid #00ff00;
    }
    .control button.pushable {
        min-width: 80px;
        max-width: 120px;
    }
    /* MIDI Mapping Styles */
    #midiMapping.pushable {
        background: linear-gradient(to bottom, #666, #333);
    }
    #midiMapping.pushable .front {
        padding: 5px 10px;
        background: linear-gradient(to bottom, #ccc, #999);
        color: #000;
    }
    #midiMapping.active .front {
        color: #00ffff;
        background: linear-gradient(to bottom, #ccc, #999);
    }
    .midi-highlight {
        box-shadow: 0 0 10px 5px rgba(0, 255, 255, 0.7);
        border-radius: 5px;
        transition: box-shadow 0.3s ease;
        position: relative;
        z-index: 2;
    }
    .midi-highlight::after {
        content: "Mapping...";
        position: absolute;
        top: -20px;
        left: 50%;
        transform: translateX(-50%);
        background: #00ffff;
        color: #000;
        padding: 2px 5px;
        border-radius: 3px;
        font-size: 10px;
        white-space: nowrap;
        z-index: 3;
    }
    .midi-mapped {
        box-shadow: 0 0 10px 5px rgba(0, 255, 0, 0.7);
        border-radius: 5px;
        transition: box-shadow 0.3s ease;
        position: relative;
        z-index: 2;
    }
    .midi-mapped::after {
        content: "Mapped!";
        position: absolute;
        top: -20px;
        left: 50%;
        transform: translateX(-50%);
        background: #00ff00;
        color: #000;
        padding: 2px 5px;
        border-radius: 3px;
        font-size: 10px;
        white-space: nowrap;
        z-index: 3;
    }
    .midi-mapping-active .control:hover {
        outline: 2px dashed rgba(0, 255, 255, 0.5);
        cursor: pointer;
    }
    /* Send MIDI Styles */
    #sendMidi.pushable {
        background: linear-gradient(to bottom, #666, #333);
    }
    #sendMidi.pushable .front {
        padding: 5px 10px;
        background: linear-gradient(to bottom, #ccc, #999);
        color: #000;
    }
    #sendMidi.active .front {
        color: #00ff00;
        background: linear-gradient(to bottom, #ccc, #999);
    }
    /* MIDI buttons container */
    .midi-buttons-container {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 20px;
        margin: 0 auto 25px;
        width: 100%;
        max-width: 500px;
    }
    
    /* XY Pad — base styles (keyboard fullscreen panel) */
    .xy-pad-container {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
        padding: 0;
        background: transparent;
        border-radius: 0;
        box-shadow: none;
        box-sizing: border-box;
    }

    .xy-pad-wrapper {
        position: relative;
        width: 280px;
        max-width: 100%;
        height: 280px;
        max-height: min(280px, 100vw - 48px);
        aspect-ratio: 1;
        margin: 0 auto;
        border: 1px solid #00aa00;
        border-radius: 3px;
        background: #111;
        overflow: hidden;
    }

    #xyPad {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: #000;
        touch-action: none;
    }

    .xy-pointer {
        position: absolute;
        width: 14px;
        height: 14px;
        border-radius: 50%;
        background: #00ff00;
        border: none;
        transform: translate(-50%, -50%);
        pointer-events: none;
        box-shadow: 0 0 6px rgba(0, 255, 0, 0.55);
        transition: box-shadow 0.1s;
    }

    .xy-controls {
        display: flex;
        justify-content: space-between;
        gap: 8px;
        margin-top: 8px;
        width: 100%;
        box-sizing: border-box;
    }

    .xy-select-group {
        display: flex;
        flex-direction: column;
        gap: 4px;
        width: 48%;
        min-width: 0;
        flex: 0 0 48%;
        max-width: 48%;
    }

    .xy-select-group label {
        margin: 0;
        font-family: 'Michroma', sans-serif;
        font-size: 7px;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: #00aa00;
        line-height: 1;
    }

    .xy-select {
        font-family: 'Michroma', sans-serif;
        font-size: 11px;
        height: 25px;
        padding: 0 8px;
        color: #00ff00;
        background: #111;
        border: 1px solid #00aa00;
        border-radius: 3px;
        width: 100%;
        box-sizing: border-box;
        line-height: 1;
    }

    .xy-select:focus-visible {
        outline: 1px solid #00ff00;
        outline-offset: 1px;
    }

    .xy-select optgroup {
        color: #00aa00;
        background: #111;
        font-style: normal;
    }
    .header-grid {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        margin-bottom: 25px;
    }
    
    @media (max-width: 768px) {
        .header-grid {
            display: flex;
            justify-content: center;
            margin-bottom: 25px;
        }
        
        /* Hide the empty columns on mobile */
        .header-grid > div:empty {
            display: none;
        }
    }
    
    /* Mobile Start/Stop button container */
    .mobile-start-stop-container {
        margin: 0 auto 25px;
        text-align: center;
    }
    
    .swipe-dots {
        margin: 15px 0 25px;
    }

    /* Power glitch effect - rare but noticeable CRT power issues */
    .power-glitch {
        animation: powerGlitch 15s infinite linear;
    }

    @keyframes powerGlitch {
        0%, 95%, 100% { opacity: 1; }
        95.5% { opacity: 0.2; }
        95.7% { opacity: 0.8; }
        95.9% { opacity: 0.4; }
        96.1% { opacity: 1; }
        98.1% { opacity: 1; }
        98.2% { opacity: 0.3; }
        98.4% { opacity: 0.8; }
        98.6% { opacity: 1; }
    }

    /* New style for control grouping */
    fieldset.control-group { /* Changed from div to fieldset */
        border: 2px solid #555; /* Thicker grey border */
        border-radius: 5px;    /* Slightly rounded corners */
        padding: 15px 10px 10px 10px; /* Adjusted padding (more top padding needed for legend) */
        margin-bottom: 15px;   /* Space below the group */
        display: flex;         /* Use flexbox for alignment */
        flex-direction: column;/* Stack controls vertically */
        align-items: center;   /* Center items horizontally */
        gap: 10px;             /* Consistent gap between controls */
    }
    
    /* Style for the group title (legend) */
    fieldset.control-group legend { /* Changed from h3 to legend */
        color: #aaa;       /* Lighter grey color */
        padding: 0 5px;     /* Padding on left/right creates the border gap */
        font-size: 14px;    /* Made font smaller */
        font-weight: normal;/* Regular font weight */
        display: block;     /* Make it a block element */
        width: fit-content; /* Width based on content */
        margin: 0 auto;     /* Center horizontally */
    }
    
    /* Adjustments for controls inside a group */
    fieldset.control-group .control {
        width: 100%; /* Make controls take full width of the group */
        gap: 5px;    /* Keep original gap inside individual controls */
    }
    
    /* Specific adjustments for ADSR visualizer inside group */
    fieldset.control-group #adsrVisualizer,
    fieldset.control-group #filterAdsrVisualizer {
        margin-top: 0; /* Remove default top margin */
    }

    .filter-env-controls.hidden {
        display: none;
    }

    /* Filter Group Start */
    fieldset.control-group.filter-group {
        border: 2px solid #555; /* Thicker grey border */
        border-radius: 5px;    /* Slightly rounded corners */
        padding: 15px 10px 10px 10px; /* Adjusted padding (more top padding needed for legend) */
        margin-bottom: 15px;   /* Space below the group */
        display: flex;         /* Use flexbox for alignment */
        flex-direction: column;/* Stack controls vertically */
        align-items: center;   /* Center items horizontally */
        gap: 10px;             /* Consistent gap between controls */
    }
    
    /* Style for the group title (legend) */
    fieldset.control-group.filter-group legend { /* Changed from h3 to legend */
        color: #aaa;       /* Lighter grey color */
        padding: 0 5px;     /* Padding on left/right creates the border gap */
        font-size: 14px;    /* Made font smaller */
        font-weight: normal;/* Regular font weight */
        display: block;     /* Make it a block element */
        width: fit-content; /* Width based on content */
        margin: 0 auto;     /* Center horizontally */
    }
    
    /* Adjustments for controls inside a group */
    fieldset.control-group.filter-group .control {
        width: 100%; /* Make controls take full width of the group */
        gap: 5px;    /* Keep original gap inside individual controls */
    }

    /* Effects Group Start */
    fieldset.control-group.effects-group {
        border: 2px solid #555; /* Thicker grey border */
        border-radius: 5px;    /* Slightly rounded corners */
        padding: 15px 10px 10px 10px; /* Adjusted padding (more top padding needed for legend) */
        margin-bottom: 15px;   /* Space below the group */
        display: flex;         /* Use flexbox for alignment */
        flex-direction: column;/* Stack controls vertically */
        align-items: center;   /* Center items horizontally */
        gap: 10px;             /* Consistent gap between controls */
    }
    
    /* Style for the group title (legend) */
    fieldset.control-group.effects-group legend { /* Changed from h3 to legend */
        color: #aaa;       /* Lighter grey color */
        padding: 0 5px;     /* Padding on left/right creates the border gap */
        font-size: 14px;    /* Made font smaller */
        font-weight: normal;/* Regular font weight */
        display: block;     /* Make it a block element */
        width: fit-content; /* Width based on content */
        margin: 0 auto;     /* Center horizontally */
    }
    
    /* Adjustments for controls inside a group */
    fieldset.control-group.effects-group .control {
        width: 100%; /* Make controls take full width of the group */
        gap: 5px;    /* Keep original gap inside individual controls */
    }

    fieldset.control-group.effects-group > fieldset.control-group {
        width: 100%;
        margin-bottom: 0;
        box-sizing: border-box;
    }

    fieldset.control-group.effects-distortion-group,
    fieldset.control-group.effects-chorus-group,
    fieldset.control-group.effects-delay-group {
        border: 2px solid #555;
        border-radius: 5px;
        padding: 15px 10px 10px 10px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    fieldset.control-group.effects-distortion-group legend,
    fieldset.control-group.effects-chorus-group legend,
    fieldset.control-group.effects-delay-group legend {
        color: #aaa;
        padding: 0 5px;
        font-size: 14px;
        font-weight: normal;
        display: block;
        width: fit-content;
        margin: 0 auto;
    }

    fieldset.control-group.effects-distortion-group .control,
    fieldset.control-group.effects-chorus-group .control,
    fieldset.control-group.effects-delay-group .control {
        width: 100%;
        gap: 5px;
    }

    /* Master Volume Group Start */
    fieldset.control-group.master-volume-group {
        border: 2px solid #555; /* Thicker grey border */
        border-radius: 5px;    /* Slightly rounded corners */
        padding: 15px 10px 10px 10px; /* Adjusted padding (more top padding needed for legend) */
        margin-bottom: 15px;   /* Space below the group */
        display: flex;         /* Use flexbox for alignment */
        flex-direction: column;/* Stack controls vertically */
        align-items: center;   /* Center items horizontally */
        gap: 10px;             /* Consistent gap between controls */
    }
    
    /* Style for the group title (legend) */
    fieldset.control-group.master-volume-group legend {
        color: #aaa;       /* Lighter grey color */
        padding: 0 5px;     /* Padding on left/right creates the border gap */
        font-size: 14px;    /* Made font smaller */
        font-weight: normal;/* Regular font weight */
        display: block;     /* Make it a block element */
        width: fit-content; /* Width based on content */
        margin: 0 auto;     /* Center horizontally */
    }
    
    /* Adjustments for controls inside a group */
    fieldset.control-group.master-volume-group .control {
        width: 100%; /* Make controls take full width of the group */
        gap: 5px;    /* Keep original gap inside individual controls */
    }

    /* Compressor Group Start */
    fieldset.control-group.compressor-group {
        border: 2px solid #555;
        border-radius: 5px;
        padding: 15px 10px 10px 10px;
        margin-bottom: 15px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    fieldset.control-group.compressor-group legend {
        color: #aaa;
        padding: 0 5px;
        font-size: 14px;
        font-weight: normal;
        display: block;
        width: fit-content;
        margin: 0 auto;
    }

    fieldset.control-group.compressor-group .control {
        width: 100%;
        gap: 5px;
    }

    /* Tuning Group Start */
    fieldset.control-group.tuning-group {
        border: 2px solid #555; /* Thicker grey border */
        border-radius: 5px;    /* Slightly rounded corners */
        padding: 15px 10px 10px 10px; /* Adjusted padding (more top padding needed for legend) */
        margin-bottom: 15px;   /* Space below the group */
        display: flex;         /* Use flexbox for alignment */
        flex-direction: column;/* Stack controls vertically */
        align-items: center;   /* Center items horizontally */
        gap: 10px;             /* Consistent gap between controls */
    }
    
    /* Style for the group title (legend) */
    fieldset.control-group.tuning-group legend {
        color: #aaa;       /* Lighter grey color */
        padding: 0 5px;     /* Padding on left/right creates the border gap */
        font-size: 14px;    /* Made font smaller */
        font-weight: normal;/* Regular font weight */
        display: block;     /* Make it a block element */
        width: fit-content; /* Width based on content */
        margin: 0 auto;     /* Center horizontally */
    }
    
    /* Adjustments for controls inside a group */
    fieldset.control-group.tuning-group .control {
        width: 100%; /* Make controls take full width of the group */
        gap: 5px;    /* Keep original gap inside individual controls */
    }

    /* Oscillator 1 Group Start */
    fieldset.control-group.osc1-group {
        border: 2px solid #555; /* Thicker grey border */
        border-radius: 5px;    /* Slightly rounded corners */
        padding: 15px 10px 10px 10px; /* Adjusted padding (more top padding needed for legend) */
        margin-bottom: 15px;   /* Space below the group */
        display: flex;         /* Use flexbox for alignment */
        flex-direction: column;/* Stack controls vertically */
        align-items: center;   /* Center items horizontally */
        gap: 10px;             /* Consistent gap between controls */
    }
    
    /* Style for the group title (legend) */
    fieldset.control-group.osc1-group legend {
        color: #aaa;       /* Lighter grey color */
        padding: 0 5px;     /* Padding on left/right creates the border gap */
        font-size: 14px;    /* Made font smaller */
        font-weight: normal;/* Regular font weight */
        display: block;     /* Make it a block element */
        width: fit-content; /* Width based on content */
        margin: 0 auto;     /* Center horizontally */
    }
    
    /* Adjustments for controls inside a group */
    fieldset.control-group.osc1-group .control {
        width: 100%; /* Make controls take full width of the group */
        gap: 5px;    /* Keep original gap inside individual controls */
    }

    /* Oscillator 2 Group Start */
    fieldset.control-group.osc2-group {
        border: 2px solid #555; /* Thicker grey border */
        border-radius: 5px;    /* Slightly rounded corners */
        padding: 15px 10px 10px 10px; /* Adjusted padding (more top padding needed for legend) */
        margin-bottom: 15px;   /* Space below the group */
        display: flex;         /* Use flexbox for alignment */
        flex-direction: column;/* Stack controls vertically */
        align-items: center;   /* Center items horizontally */
        gap: 10px;             /* Consistent gap between controls */
    }
    
    /* Style for the group title (legend) */
    fieldset.control-group.osc2-group legend {
        color: #aaa;       /* Lighter grey color */
        padding: 0 5px;     /* Padding on left/right creates the border gap */
        font-size: 14px;    /* Made font smaller */
        font-weight: normal;/* Regular font weight */
        display: block;     /* Make it a block element */
        width: fit-content; /* Width based on content */
        margin: 0 auto;     /* Center horizontally */
    }
    
    /* Adjustments for controls inside a group */
    fieldset.control-group.osc2-group .control {
        width: 100%; /* Make controls take full width of the group */
        gap: 5px;    /* Keep original gap inside individual controls */
    }

    /* Oscillator 3 Group Start */
    fieldset.control-group.osc3-group {
        border: 2px solid #555; /* Thicker grey border */
        border-radius: 5px;    /* Slightly rounded corners */
        padding: 15px 10px 10px 10px; /* Adjusted padding (more top padding needed for legend) */
        margin-bottom: 15px;   /* Space below the group */
        display: flex;         /* Use flexbox for alignment */
        flex-direction: column;/* Stack controls vertically */
        align-items: center;   /* Center items horizontally */
        gap: 10px;             /* Consistent gap between controls */
    }
    
    /* Style for the group title (legend) */
    fieldset.control-group.osc3-group legend {
        color: #aaa;       /* Lighter grey color */
        padding: 0 5px;     /* Padding on left/right creates the border gap */
        font-size: 14px;    /* Made font smaller */
        font-weight: normal;/* Regular font weight */
        display: block;     /* Make it a block element */
        width: fit-content; /* Width based on content */
        margin: 0 auto;     /* Center horizontally */
    }
    
    /* Adjustments for controls inside a group */
    fieldset.control-group.osc3-group .control {
        width: 100%; /* Make controls take full width of the group */
        gap: 5px;    /* Keep original gap inside individual controls */
    }

    /* Unison Group Start */
    fieldset.control-group.unison-group {
        border: 2px solid #555;
        border-radius: 5px;
        padding: 15px 10px 10px 10px;
        margin-bottom: 15px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    fieldset.control-group.unison-group legend {
        color: #aaa;
        padding: 0 5px;
        font-size: 14px;
        font-weight: normal;
        display: block;
        width: fit-content;
        margin: 0 auto;
    }

    fieldset.control-group.unison-group .control {
        width: 100%;
        gap: 5px;
    }

    fieldset.control-group.unison-group.unison-disabled {
        opacity: 0.45;
    }

    /* Phase Reset Group Start */
    fieldset.control-group.phase-reset-group {
        border: 2px solid #555;
        border-radius: 5px;
        padding: 15px 10px 10px 10px;
        margin-bottom: 15px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    fieldset.control-group.phase-reset-group legend {
        color: #aaa;
        padding: 0 5px;
        font-size: 14px;
        font-weight: normal;
        display: block;
        width: fit-content;
        margin: 0 auto;
    }

    fieldset.control-group.phase-reset-group .control {
        width: 100%;
        gap: 5px;
    }

    /* Ring Mod Group Start */
    fieldset.control-group.ring-mod-group {
        border: 2px solid #555; /* Thicker grey border */
        border-radius: 5px;    /* Slightly rounded corners */
        padding: 15px 10px 10px 10px; /* Adjusted padding (more top padding needed for legend) */
        margin-bottom: 15px;   /* Space below the group */
        display: flex;         /* Use flexbox for alignment */
        flex-direction: column;/* Stack controls vertically */
        align-items: center;   /* Center items horizontally */
        gap: 10px;             /* Consistent gap between controls */
    }
    
    /* Style for the group title (legend) */
    fieldset.control-group.ring-mod-group legend { /* Changed from h3 to legend */
        color: #aaa;       /* Lighter grey color */
        padding: 0 5px;     /* Padding on left/right creates the border gap */
        font-size: 14px;    /* Made font smaller */
        font-weight: normal;/* Regular font weight */
        display: block;     /* Make it a block element */
        width: fit-content; /* Width based on content */
        margin: 0 auto;     /* Center horizontally */
    }
    
    /* Adjustments for controls inside a group */
    fieldset.control-group.ring-mod-group .control {
        width: 100%; /* Make controls take full width of the group */
        gap: 5px;    /* Keep original gap inside individual controls */
    }

    /* Noise Group Start */
    fieldset.control-group.noise-group {
        border: 2px solid #555; /* Thicker grey border */
        border-radius: 5px;    /* Slightly rounded corners */
        padding: 15px 10px 10px 10px; /* Adjusted padding (more top padding needed for legend) */
        margin-bottom: 15px;   /* Space below the group */
        display: flex;         /* Use flexbox for alignment */
        flex-direction: column;/* Stack controls vertically */
        align-items: center;   /* Center items horizontally */
        gap: 10px;             /* Consistent gap between controls */
    }
    
    /* Style for the group title (legend) */
    fieldset.control-group.noise-group legend { /* Changed from h3 to legend */
        color: #aaa;       /* Lighter grey color */
        padding: 0 5px;     /* Padding on left/right creates the border gap */
        font-size: 14px;    /* Made font smaller */
        font-weight: normal;/* Regular font weight */
        display: block;     /* Make it a block element */
        width: fit-content; /* Width based on content */
        margin: 0 auto;     /* Center horizontally */
    }
    
    /* Adjustments for controls inside a group */
    fieldset.control-group.noise-group .control {
        width: 100%; /* Make controls take full width of the group */
        gap: 5px;    /* Keep original gap inside individual controls */
    }

    /* LFO Group Start */
    fieldset.control-group.lfo-group {
        border: 2px solid #555; /* Thicker grey border */
        border-radius: 5px;    /* Slightly rounded corners */
        padding: 15px 10px 10px 10px; /* Adjusted padding (more top padding needed for legend) */
        margin-bottom: 15px;   /* Space below the group */
        display: flex;         /* Use flexbox for alignment */
        flex-direction: column;/* Stack controls vertically */
        align-items: center;   /* Center items horizontally */
        gap: 10px;             /* Consistent gap between controls */
    }
    
    /* Style for the group title (legend) */
    fieldset.control-group.lfo-group legend { /* Changed from h3 to legend */
        color: #aaa;       /* Lighter grey color */
        padding: 0 5px;     /* Padding on left/right creates the border gap */
        font-size: 14px;    /* Made font smaller */
        font-weight: normal;/* Regular font weight */
        display: block;     /* Make it a block element */
        width: fit-content; /* Width based on content */
        margin: 0 auto;     /* Center horizontally */
    }
    
    /* Adjustments for controls inside a group */
    fieldset.control-group.lfo-group .control {
        width: 100%; /* Make controls take full width of the group */
        gap: 5px;    /* Keep original gap inside individual controls */
    }

    /* LFO Destination Group Start */
    fieldset.control-group.lfo-dest-group {
        border: 2px solid #555; /* Thicker grey border */
        border-radius: 5px;    /* Slightly rounded corners */
        padding: 15px 10px 10px 10px; /* Adjusted padding (more top padding needed for legend) */
        margin-bottom: 15px;   /* Space below the group */
        display: flex;         /* Use flexbox for alignment */
        flex-direction: column;/* Stack controls vertically */
        align-items: center;   /* Center items horizontally */
        gap: 10px;             /* Consistent gap between controls */
    }
    
    /* Style for the group title (legend) */
    fieldset.control-group.lfo-dest-group legend {
        color: #aaa;       /* Lighter grey color */
        padding: 0 5px;     /* Padding on left/right creates the border gap */
        font-size: 14px;    /* Made font smaller */
        font-weight: normal;/* Regular font weight */
        display: block;     /* Make it a block element */
        width: fit-content; /* Width based on content */
        margin: 0 auto;     /* Center horizontally */
    }
    
    /* Adjustments for controls inside a group */
    fieldset.control-group.lfo-dest-group .control {
        width: 100%; /* Make controls take full width of the group */
        gap: 5px;    /* Keep original gap inside individual controls */
    }

    /* --- Per-step microtuning (cents) slider --- */
    input[type="range"].step-fine {
        width: 80px;
        height: 4px;
    }
    input[type="range"].step-fine::-webkit-slider-thumb {
        width: 12px;
        height: 12px;
        margin-top: -4px;
    }
    input[type="range"].step-fine::-moz-range-thumb {
        width: 12px;
        height: 12px;
    }
    .step-fine-value {
        font-size: 9px;
        color: #aaa;
    }

    /* --- Per-step Accent / Slide / On-Off --- */
    .step-buttons {
        display: flex;
        flex-direction: column;
        gap: 5px;
        align-items: center;
    }
    .step-buttons-row {
        display: flex;
        gap: 5px;
        align-items: center;
        justify-content: center;
    }
    .step-slide,
    .step-accent {
        width: 58px;
    }
    .step-slide .front,
    .step-accent .front {
        font-size: 8px;
        padding: 3px 0;
        text-align: center;
        color: #00aa00;
    }
    .step-slide.off .front,
    .step-accent.off .front {
        color: #ff0000;
    }

    /* --- Scale mode (sequencer step quantization) --- */
    #scaleToggle .front {
        color: #00aa00;
    }
    #scaleToggle.off .front {
        color: #ff0000;
    }
    #scaleSelect {
        max-width: 220px;
    }

    /* --- Microtuning Full / Lock --- */
    #microtuneLockToggle .front {
        color: #00aa00;
        font-size: 11px;
        padding: 6px 10px;
    }
    #microtuneLockToggle.off .front {
        color: #000;
    }

/* --- Chromatic piano keyboard --- */
.keyboard-section {
    width: 100%;
    max-width: 960px;
    margin: 0 auto 20px;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
}
body.keyboard-stage-mode {
    overflow: hidden;
}
.keyboard-section.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    max-width: none;
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
    overflow-x: hidden;
    overflow-y: auto;
    background: #050805;
    box-shadow: none;
}
body.keyboard-stage-mode .keyboard-toolbar-top {
    display: none;
}
.keyboard-stage-scope {
    display: none;
    justify-content: center;
    width: 100%;
    margin: 0 0 12px;
}
body.keyboard-stage-mode .keyboard-stage-scope {
    display: flex;
}
.keyboard-stage-oscilloscope {
    margin-bottom: 0;
}
body.keyboard-stage-mode .keyboard-stage-oscilloscope .oscilloscope-border {
    background: #00aa00;
    background-image: none;
    -webkit-mask: url('internal-oscilloscope-border.svg') center / 100% 100% no-repeat;
    mask: url('internal-oscilloscope-border.svg') center / 100% 100% no-repeat;
}
.keyboard-section.is-fullscreen .chromatic-keyboard-wrap,
.keyboard-section.is-fullscreen .chromatic-keyboard-panel {
    min-width: 0;
    max-width: 100%;
}
.keyboard-section.is-fullscreen .chromatic-keyboard {
    height: 220px;
}
.keyboard-section.is-fullscreen .piano-key-label {
    font-size: 11px;
    padding-bottom: 8px;
}
.keyboard-section.is-fullscreen .piano-key-black {
    overflow: hidden;
}
.keyboard-section.is-fullscreen .piano-key-black .piano-key-label {
    font-size: 7px;
    padding-bottom: 3px;
    line-height: 1;
}
.keyboard-section.keyboard-off {
    background: transparent;
    box-shadow: none;
    padding: 0;
    margin-bottom: 12px;
}
.keyboard-section.keyboard-off .keyboard-toolbar {
    margin-bottom: 0;
}
.keyboard-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 12px;
    width: 100%;
}
.keyboard-toolbar-top {
    display: flex;
    justify-content: center;
    width: 100%;
}
.keyboard-controls-fieldset > legend {
    color: #00aa00;
    font-family: 'Michroma', sans-serif;
}

/*
 * Top-level keyboard fieldset titles — continuous hex outline ring.
 * Fixed px side cut (74/150) so angles match on every title width.
 *
 * Stroke is outer hex minus a PARALLEL-offset inner hex (not rectangular
 * inset). Rectangular inset pinches the tip — looks thinner at the points.
 * Slant length L = sqrt(H^2 + 4C^2) ≈ 28.1 for H=20, C=9.87.
 */
.keyboard-section .legend-hex {
    --hex-h: 20px;
    --hex-cut: 9.87px; /* 20 * 74/150 — locked; do not use % of width */
    --hex-border: 1.5px;
    --hex-slant-len: 28.1px; /* sqrt(H^2 + 4C^2) */
    --hex-stroke: #00aa00;
    --hex-bg: rgba(0, 0, 0, 0.72); /* ≈ .keyboard-section panel behind legend */
    /* Parallel offset: tip moves along +x by d*L/H; flat start by [C*(H-2d)+d*L]/H */
    --inner-tip-x: calc(var(--hex-border) * var(--hex-slant-len) / var(--hex-h));
    --inner-flat-x: calc(
        (var(--hex-cut) * (var(--hex-h) - 2 * var(--hex-border))
            + var(--hex-border) * var(--hex-slant-len))
        / var(--hex-h)
    );
    --inner-y: var(--hex-border);
    --hex-clip-outer: polygon(
        var(--hex-cut) 0%,
        calc(100% - var(--hex-cut)) 0%,
        100% 50%,
        calc(100% - var(--hex-cut)) 100%,
        var(--hex-cut) 100%,
        0% 50%
    );
    --hex-clip-inner: polygon(
        var(--inner-flat-x) var(--inner-y),
        calc(100% - var(--inner-flat-x)) var(--inner-y),
        calc(100% - var(--inner-tip-x)) 50%,
        calc(100% - var(--inner-flat-x)) calc(100% - var(--inner-y)),
        var(--inner-flat-x) calc(100% - var(--inner-y)),
        var(--inner-tip-x) 50%
    );
    position: relative;
    isolation: isolate;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: var(--hex-h);
    padding: 0 calc(var(--hex-cut) + 8px);
    box-sizing: border-box;
    width: max-content;
    min-width: calc(var(--hex-cut) * 2 + 40px);
    line-height: 1;
    font-family: 'Michroma', sans-serif;
    font-size: 10px;
    font-weight: normal;
    letter-spacing: 0.04em;
    color: #00aa00;
    border: none;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    vertical-align: middle;
}
/* Side points (50% height) sit on the fieldset border centerline */
.keyboard-section .keyboard-controls-fieldset > legend,
.keyboard-section .keyboard-steps-fieldset > .collapsible-legend,
.keyboard-section .keyboard-automation-fieldset > .collapsible-legend,
.keyboard-section .keyboard-synth-fieldset > .collapsible-legend,
.keyboard-section .keyboard-xy-fieldset > .collapsible-legend,
.keyboard-section .keyboard-transport-fieldset > legend,
.keyboard-section .keyboard-write-fieldset > legend {
    --hex-h: 20px;
    --field-border: 1px;
    padding: 0;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    /* pull legend so hex midline = top border midline */
    margin-top: calc(var(--hex-h) / -2 + var(--field-border) / 2);
    margin-bottom: calc(var(--hex-h) / -2 + var(--field-border) / 2);
    line-height: 0;
    overflow: visible;
    position: relative;
    z-index: 1;
}
.keyboard-section.is-fullscreen .legend-hex {
    --hex-bg: #050805;
}
.keyboard-section .legend-hex::before,
.keyboard-section .legend-hex::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: -1;
}
/* Outer green (stroke fill) */
.keyboard-section .legend-hex::before {
    background: var(--hex-stroke);
    clip-path: var(--hex-clip-outer);
}
/* Inner panel punch-out — parallel offset so stroke width stays even at tips */
.keyboard-section .legend-hex::after {
    background: var(--hex-bg);
    clip-path: var(--hex-clip-inner);
}
.keyboard-section .collapsible-toggle.legend-hex {
    cursor: pointer;
    margin: 0;
    font-size: 10px;
    background-color: transparent;
    -webkit-tap-highlight-color: transparent;
}
.keyboard-section .collapsible-toggle.legend-hex:hover,
.keyboard-section .collapsible-toggle.legend-hex:focus-visible {
    --hex-stroke: #00ff00;
    color: #00ff00;
    outline: none;
}
.keyboard-controls-body {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
}
.keyboard-controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding-top: 4px;
    box-sizing: border-box;
}
.keyboard-controls-scale-row {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}
.keyboard-scale-select {
    font-family: 'Michroma', sans-serif;
    font-size: 11px;
    color: #00ff00;
    background: #111;
    border: 1px solid #00aa00;
    border-radius: 3px;
    padding: 0 10px;
    height: 25px;
    min-width: 12rem;
    max-width: 18rem;
    width: auto;
    box-sizing: border-box;
    line-height: 1;
}
.keyboard-scale-select:focus-visible {
    outline: 1px solid #00ff00;
    outline-offset: 1px;
}
.keyboard-master-tune {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0 10px;
    height: 25px;
    border-radius: 3px;
    border: 1px solid #00aa00;
    background: linear-gradient(to bottom, #1a1a1a 0%, #0d0d0d 100%);
    box-shadow: inset 0 0 6px rgba(0, 255, 0, 0.15);
    box-sizing: border-box;
}
.keyboard-master-tune-label {
    font-family: 'Michroma', sans-serif;
    font-size: 11px;
    color: #00aa00;
    white-space: nowrap;
    line-height: 1;
}
.keyboard-master-tune-value {
    font-family: 'Michroma', sans-serif;
    font-size: 11px;
    color: #00ff00;
    min-width: 2.25rem;
    text-align: right;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
/* Minimal keyboard-section range — overrides the heavy default chrome sliders */
.keyboard-section input[type="range"].keyboard-master-tune-slider {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 110px;
    height: 11px;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    cursor: pointer;
}
.keyboard-section input[type="range"].keyboard-master-tune-slider:focus {
    outline: none;
}
.keyboard-section input[type="range"].keyboard-master-tune-slider::-webkit-slider-runnable-track {
    -webkit-appearance: none;
    appearance: none;
    height: 3px;
    background: #0a0f0a;
    border: 1px solid #1a3a1a;
    border-radius: 1px;
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.75);
}
.keyboard-section input[type="range"].keyboard-master-tune-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 8px;
    height: 11px;
    margin-top: -5px;
    border-radius: 1px;
    background: #00aa00;
    border: 1px solid #00ff00;
    box-shadow: none;
    cursor: pointer;
    transition: none;
}
.keyboard-section input[type="range"].keyboard-master-tune-slider::-webkit-slider-thumb:hover,
.keyboard-section input[type="range"].keyboard-master-tune-slider::-webkit-slider-thumb:active {
    background: #00ff00;
    transform: none;
    box-shadow: none;
}
.keyboard-section input[type="range"].keyboard-master-tune-slider:focus::-webkit-slider-thumb {
    background: #00ff00;
    box-shadow: none;
}
.keyboard-section input[type="range"].keyboard-master-tune-slider::-moz-range-track {
    height: 3px;
    background: #0a0f0a;
    border: 1px solid #1a3a1a;
    border-radius: 1px;
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.75);
}
.keyboard-section input[type="range"].keyboard-master-tune-slider::-moz-range-thumb {
    width: 8px;
    height: 11px;
    border-radius: 1px;
    background: #00aa00;
    border: 1px solid #00ff00;
    box-shadow: none;
    cursor: pointer;
    transition: none;
}
.keyboard-section input[type="range"].keyboard-master-tune-slider::-moz-range-thumb:hover,
.keyboard-section input[type="range"].keyboard-master-tune-slider::-moz-range-thumb:active {
    background: #00ff00;
    transform: none;
    box-shadow: none;
}
.keyboard-section input[type="range"].keyboard-master-tune-slider:focus::-moz-range-thumb {
    background: #00ff00;
    box-shadow: none;
}
.keyboard-transpose-screen {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    box-sizing: border-box;
    min-width: 11.5rem;
    height: 25px;
    padding: 0 10px;
    margin: 0;
    border-radius: 3px;
    border: 1px solid #00aa00;
    background: linear-gradient(to bottom, #1a1a1a 0%, #0d0d0d 100%);
    box-shadow: inset 0 0 6px rgba(0, 255, 0, 0.15);
    text-align: center;
}
.keyboard-transpose-screen.is-dimmed {
    opacity: 0.45;
}
.keyboard-transpose-readout {
    font-family: 'Michroma', sans-serif;
    color: #00aa00;
    font-size: 11px;
    line-height: 1;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.chromatic-keyboard-wrap {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* Every fieldset in the keyboard window — including nested groups — stays green */
.keyboard-section fieldset {
    border: 1px solid #00aa00;
    border-style: solid;
}
.keyboard-section fieldset > legend {
    color: #00aa00;
    font-family: 'Michroma', sans-serif;
}
.chromatic-keyboard-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    touch-action: pan-x;
    user-select: none;
    -webkit-user-select: none;
    -webkit-overflow-scrolling: touch;
    /* Room under the keys so the scrollbar sits clearly below the keyboard */
    padding-bottom: 14px;
    margin-top: 4px;
    scrollbar-color: #00aa00 #111;
    scrollbar-gutter: stable both-edges;
    scrollbar-width: auto;
}
.keyboard-play-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    align-items: stretch;
    width: 100%;
    padding: 0 4px;
    margin-bottom: 6px;
    box-sizing: border-box;
}

/* --- Reusable collapsible fieldset (legend + arrow) --- */
.collapsible-legend {
    padding: 0;
    margin: 0 auto;
    width: fit-content;
}
.collapsible-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0 5px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: 'Michroma', sans-serif;
    font-size: 10px;
    font-weight: normal;
    letter-spacing: 0.04em;
    color: #00aa00;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}
.collapsible-toggle:hover,
.collapsible-toggle:focus-visible {
    color: #00ff00;
    outline: none;
}
.collapsible-label {
    pointer-events: none;
}
.collapsible-arrow {
    display: inline-block;
    width: 0;
    height: 0;
    border-style: solid;
    /* Collapsed: point right ▶ */
    border-width: 4px 0 4px 6px;
    border-color: transparent transparent transparent currentColor;
    flex: 0 0 auto;
}
.collapsible-fieldset:not(.collapsed) > .collapsible-legend .collapsible-arrow {
    /* Expanded: point down ▼ */
    border-width: 6px 4px 0 4px;
    border-color: currentColor transparent transparent transparent;
}
.collapsible-panel.hidden {
    display: none;
}

/* Collapsible full-width sections under Transport / Write */
.keyboard-steps-fieldset,
.keyboard-automation-fieldset,
.keyboard-synth-fieldset,
.keyboard-xy-fieldset,
.keyboard-controls-fieldset {
    margin: 0;
    padding: 6px 6px 8px;
    border: 1px solid #00aa00;
    border-radius: 5px; /* Steps reference — keep all top fieldsets identical */
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    /* visible so hex legends on the border are not clipped away */
    overflow: visible;
}
.keyboard-steps-fieldset > .collapsible-panel,
.keyboard-automation-fieldset > .collapsible-panel,
.keyboard-synth-fieldset > .collapsible-panel,
.keyboard-xy-fieldset > .collapsible-panel {
    overflow: hidden;
    max-width: 100%;
}
.keyboard-steps-fieldset.collapsed,
.keyboard-automation-fieldset.collapsed,
.keyboard-synth-fieldset.collapsed,
.keyboard-xy-fieldset.collapsed {
    padding-bottom: 0;
}
.keyboard-automation-panel {
    padding-top: 6px;
}
.keyboard-automation-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
}
#kbAutomationRecord.pushable.keyboard-automation-btn,
#kbAutomationClear.pushable.keyboard-automation-btn {
    background: linear-gradient(to bottom, #1a1a1a, #000);
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    margin: 0;
}
#kbAutomationRecord.pushable.keyboard-automation-btn .front,
#kbAutomationClear.pushable.keyboard-automation-btn .front {
    box-sizing: border-box;
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to bottom, #333, #000);
    font-family: 'Michroma', sans-serif;
    font-size: 9px;
    letter-spacing: 0.04em;
    line-height: 1;
    color: #00ff00;
}
#kbAutomationRecord.pushable.keyboard-automation-btn .kb-auto-rec-label {
    display: none;
    color: #00ff00;
    font-size: 9px;
    letter-spacing: 0.04em;
}
#kbAutomationRecord.pushable.keyboard-automation-btn .kb-auto-rec-dot {
    display: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ff00ff;
    box-shadow: 0 0 6px rgba(255, 0, 255, 0.65);
    pointer-events: none;
    opacity: var(--kb-rec-blink);
}
#kbAutomationRecord.pushable.keyboard-automation-btn.off .kb-auto-rec-label {
    display: inline;
}
#kbAutomationRecord.pushable.keyboard-automation-btn.off .kb-auto-rec-dot {
    display: none;
}
#kbAutomationRecord.pushable.keyboard-automation-btn:not(.off) .kb-auto-rec-label,
#kbAutomationRecord.pushable.keyboard-automation-btn.active .kb-auto-rec-label {
    display: none;
}
#kbAutomationRecord.pushable.keyboard-automation-btn:not(.off) .kb-auto-rec-dot,
#kbAutomationRecord.pushable.keyboard-automation-btn.active .kb-auto-rec-dot {
    display: block;
}
#kbAutomationClear.pushable.keyboard-automation-btn .front {
    color: #00ff00;
}
#kbAutomationClear.pushable.keyboard-automation-btn:active .front {
    color: #ff0000;
}

/* Automation record mode — magenta parallel to MIDI cyan */
.automation-highlight {
    box-shadow: 0 0 10px 5px rgba(255, 0, 255, 0.7);
    border-radius: 5px;
    transition: box-shadow 0.3s ease;
    position: relative;
    z-index: 2;
}
.automation-highlight::after {
    content: "Recording...";
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff00ff;
    color: #000;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 10px;
    white-space: nowrap;
    z-index: 3;
}
.automation-mode-active .control:hover,
.automation-mode-active .synth-knob:hover,
.automation-mode-active .keyboard-pitch-bend:hover,
.automation-mode-active .keyboard-master-tune:hover {
    outline: 2px dashed rgba(255, 0, 255, 0.5);
    cursor: pointer;
}
/* XY pad dot — magenta ring while Rec armed (outline avoids fighting green glow) */
.automation-mode-active .xy-pointer {
    outline: 2px solid #ff00ff;
    outline-offset: 2px;
}

/* Persistent param status: magenta = automation (TL), cyan = MIDI mapped (TR) */
.param-status-host {
    position: relative;
}
.param-status-dot {
    position: absolute;
    top: 2px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 4;
    display: none;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.85);
}
.param-status-dot--auto {
    left: 2px;
    background: #ff00ff;
    box-shadow: 0 0 5px rgba(255, 0, 255, 0.75);
}
.param-status-dot--midi {
    right: 2px;
    background: #00ffff;
    box-shadow: 0 0 5px rgba(0, 255, 255, 0.75);
}
.param-status-host.has-automation > .param-status-dot--auto {
    display: block;
}
.param-status-host.has-midi > .param-status-dot--midi {
    display: block;
}
/* Sequencer / step-record UI — never show automation hover */
.automation-mode-active .keyboard-transport-fieldset .synth-knob:hover,
.automation-mode-active .keyboard-write-fieldset .synth-knob:hover,
.automation-mode-active .keyboard-steps-fieldset .synth-knob:hover,
.automation-mode-active .keyboard-steps-fieldset .keyboard-step:hover,
.automation-mode-active .sequencer-controls .control:hover,
.automation-mode-active .sequencer-step:hover,
.automation-mode-active .sequencer-step .control:hover {
    outline: none;
    cursor: inherit;
}
/* XY Pad collapsible — fullscreen keyboard only */
.keyboard-xy-fieldset {
    display: none;
}
.keyboard-section.is-fullscreen .keyboard-xy-fieldset:not([hidden]) {
    display: block;
}
.keyboard-xy-panel {
    padding-top: 4px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
}
.keyboard-xy-panel.hidden {
    display: none;
}
.keyboard-xy-pad-field {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}
.keyboard-synth-panel {
    padding-top: 4px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}
.keyboard-synth-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: 1fr;
    gap: 6px;
    width: 100%;
    min-width: 0;
    align-items: stretch;
    overflow: hidden;
}
.keyboard-synth-col--oscs {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    height: 100%;
}
.keyboard-synth-col-stack--2,
.keyboard-synth-col-stack--3 {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    height: 100%;
    align-self: stretch;
    box-sizing: border-box;
}
.keyboard-synth-col-stack--2 {
    grid-column: 2;
    grid-row: 1;
}
.keyboard-synth-col-stack--3 {
    grid-column: 3;
    grid-row: 1;
}
.keyboard-synth-col-stack--2 > .keyboard-perf-fieldset,
.keyboard-synth-col-stack--3 > .keyboard-perf-fieldset {
    flex: 1 1 0;
    min-height: 0;
    margin: 0;
}
.keyboard-synth-panel .keyboard-filter-env-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 6px 6px 8px;
    box-sizing: border-box;
    min-height: 0;
    overflow: visible;
}
.keyboard-filter-env-controls {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    min-height: 0;
    overflow: visible;
    box-sizing: border-box;
}
.keyboard-vol-env-field,
.keyboard-filter-env-field {
    margin: 0;
    padding: 6px 6px 8px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow: visible;
    flex: 1 1 auto;
}
.keyboard-vol-env-field legend,
.keyboard-filter-env-field legend {
    font-family: 'Michroma', sans-serif;
    color: #00aa00;
    font-size: 9px;
    padding: 0 4px;
    width: fit-content;
    margin: 0 auto;
}
.keyboard-vol-env-controls,
.keyboard-filter-env-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.keyboard-synth-col--effects {
    grid-column: 4;
    grid-row: 1;
    min-width: 0;
    height: 100%;
}
.keyboard-osc-group {
    margin: 0;
    padding: 6px 8px 8px;
    width: 100%;
    min-width: 0;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}
.keyboard-osc-rows {
    display: grid;
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}
.keyboard-unison-field {
    margin: 6px 0 0;
    padding: 6px 6px 8px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    flex: 0 0 auto;
}
.keyboard-phase-reset-field {
    margin: 6px 0 0;
    padding: 6px 6px 8px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.keyboard-phase-reset-field legend {
    font-family: 'Michroma', sans-serif;
    color: #00aa00;
    font-size: 9px;
    padding: 0 4px;
    width: fit-content;
    margin: 0 auto;
}
.keyboard-phase-reset-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 2px 0 0;
}
.synth-knob-dial.disabled,
.synth-knob-dial[aria-disabled="true"] {
    opacity: 0.45;
    pointer-events: none;
}
.keyboard-unison-field.unison-disabled {
    opacity: 0.45;
}
.keyboard-unison-controls {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
}
.keyboard-unison-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
}
.keyboard-unison-voices {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    min-width: 0;
    width: 100%;
}
.keyboard-unison-voices-label {
    font-family: 'Michroma', sans-serif;
    font-size: 7px;
    letter-spacing: 0.04em;
    color: #00aa00;
    text-transform: uppercase;
    line-height: 1;
}
.keyboard-unison-voices select {
    font-family: 'Michroma', sans-serif;
    font-size: 8px;
    color: #00ff00;
    background: #111;
    border: 1px solid #00aa00;
    border-radius: 3px;
    padding: 4px 6px;
    min-width: 3.25rem;
    max-width: 4.5rem;
    width: 100%;
    box-sizing: border-box;
}
.keyboard-unison-voices select:focus-visible {
    outline: 1px solid #00ff00;
    outline-offset: 1px;
}
.keyboard-unison-toggle-row {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    width: 100%;
    max-width: 96px;
}
.keyboard-synth-col {
    margin: 0;
    min-width: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}
.keyboard-synth-panel .keyboard-filter-knob-group {
    display: flex;
    flex-direction: column;
    justify-content: stretch;
    align-items: center;
    gap: 4px;
    width: 100%;
    margin: 0;
    padding: 6px 8px 8px;
    box-sizing: border-box;
    min-height: 0;
}
.keyboard-filter-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}
.keyboard-filter-cutoff-knob {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: auto;
    gap: 2px;
}
.keyboard-filter-cutoff-knob .synth-knob-label {
    font-size: 9px;
    letter-spacing: 0.02em;
}
.keyboard-filter-cutoff-knob .synth-knob-dial {
    width: 88px;
    height: 88px;
}
.keyboard-filter-cutoff-knob .synth-knob-indicator {
    top: 8px;
    height: 18px;
    transform-origin: 50% 36px;
}
.keyboard-filter-knob-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-end;
    justify-content: center;
    gap: 18px;
    width: 100%;
}
.keyboard-synth-panel .keyboard-filter-knob-group .keyboard-effects-knob {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: auto;
}
.keyboard-synth-panel .keyboard-noise-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    margin: 0;
    padding: 6px 8px 8px;
    box-sizing: border-box;
    min-height: 0;
}
.keyboard-noise-controls {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
}
.keyboard-noise-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
}
.keyboard-noise-type {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    min-width: 0;
    width: 100%;
}
.keyboard-noise-type-label {
    font-family: 'Michroma', sans-serif;
    font-size: 7px;
    letter-spacing: 0.04em;
    color: #00aa00;
    text-transform: uppercase;
    line-height: 1;
}
.keyboard-noise-type-select {
    font-family: 'Michroma', sans-serif;
    font-size: 8px;
    color: #00ff00;
    background: #111;
    border: 1px solid #00aa00;
    border-radius: 3px;
    padding: 4px 6px;
    min-width: 4.5rem;
    max-width: 5.5rem;
    width: 100%;
    box-sizing: border-box;
}
.keyboard-noise-type-select:focus-visible {
    outline: 1px solid #00ff00;
    outline-offset: 1px;
}
.keyboard-noise-toggle-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    min-width: 0;
    width: 100%;
    max-width: 96px;
}
.keyboard-synth-panel .keyboard-amp-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 6px 6px 8px;
    box-sizing: border-box;
    min-height: 0;
    overflow: visible;
}
.keyboard-amp-controls {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    min-height: 0;
    overflow: visible;
    box-sizing: border-box;
}
.keyboard-adsr-visualizer {
    display: block;
    width: 100%;
    max-width: 120px;
    height: auto;
    margin: 0 auto;
    border: 1px solid #00aa00;
    border-radius: 3px;
    background: #111;
    box-sizing: border-box;
}
.keyboard-vol-env-knob-row,
.keyboard-filter-env-knob-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: end;
    justify-items: center;
    gap: 4px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.keyboard-vol-env-knob-row .keyboard-vol-env-knob.synth-knob,
.keyboard-filter-env-knob-row .keyboard-filter-env-knob.synth-knob {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    flex: none;
    gap: 1px;
}
.keyboard-vol-env-knob .synth-knob-label,
.keyboard-filter-env-knob .synth-knob-label {
    font-size: 7px;
}
.keyboard-vol-env-knob .synth-knob-dial,
.keyboard-filter-env-knob .synth-knob-dial {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}
.keyboard-vol-env-knob .synth-knob-indicator,
.keyboard-filter-env-knob .synth-knob-indicator {
    top: 4px;
    height: 8px;
    transform-origin: 50% 12px;
}
.keyboard-filter-env-toggle-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    max-width: 96px;
    margin: 12px auto 0;
}
.keyboard-volume-field {
    margin: 0;
    padding: 6px 6px 8px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.keyboard-volume-field legend {
    font-family: 'Michroma', sans-serif;
    color: #00aa00;
    font-size: 9px;
    padding: 0 4px;
    width: fit-content;
    margin: 0 auto;
}
.keyboard-synth-panel {
    --kb-toggle-width: 46px; /* matches one Chorus I/II button in a 96px row */
}

/* All synth-panel On/Off toggles share Chorus I/II width */
.keyboard-synth-panel .kb-chorus-toggle,
.keyboard-synth-panel .kb-osc-toggle,
.keyboard-synth-panel .kb-noise-toggle,
.keyboard-synth-panel .keyboard-noise-toggle-row .kb-step-btn,
.keyboard-synth-panel .kb-filter-env-toggle,
.keyboard-synth-panel .keyboard-unison-toggle-row .kb-step-btn,
.keyboard-synth-panel .keyboard-effects-comp-toggle-row .kb-step-btn,
.keyboard-synth-panel .keyboard-effects-ringmod-toggle-row .kb-step-btn,
.keyboard-synth-panel .keyboard-effects-dist-toggle-row .kb-step-btn,
.keyboard-synth-panel .keyboard-effects-delay-toggle-row .kb-step-btn,
.keyboard-synth-panel .keyboard-phase-reset-controls .kb-step-btn {
    flex: 0 0 var(--kb-toggle-width);
    width: var(--kb-toggle-width);
    min-width: var(--kb-toggle-width);
    max-width: var(--kb-toggle-width);
    padding: 4px 10px;
    box-sizing: border-box;
}

.keyboard-synth-panel .keyboard-effects-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 6px 8px 8px;
    box-sizing: border-box;
    min-height: 0;
}
/* Desktop: Effects stays open — no collapse chrome */
@media (min-width: 769px) {
    .keyboard-synth-panel .keyboard-effects-group.collapsible-fieldset > .collapsible-legend .collapsible-arrow {
        display: none;
    }
    .keyboard-synth-panel .keyboard-effects-group.collapsible-fieldset > .collapsible-legend .collapsible-toggle {
        cursor: default;
        pointer-events: none;
    }
}
.keyboard-synth-panel .keyboard-effects-group .synth-knob {
    width: auto;
}
.keyboard-effects-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}
.keyboard-effects-dist-field,
.keyboard-effects-ringmod-field,
.keyboard-effects-chorus-field,
.keyboard-effects-delay-field,
.keyboard-effects-comp-field {
    margin: 0;
    padding: 6px 8px 8px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.keyboard-effects-dist-field legend,
.keyboard-effects-ringmod-field legend,
.keyboard-effects-chorus-field legend,
.keyboard-effects-delay-field legend,
.keyboard-effects-comp-field legend {
    font-family: 'Michroma', sans-serif;
    color: #00aa00;
    font-size: 9px;
    padding: 0 4px;
    width: fit-content;
    margin: 0 auto;
}
.keyboard-effects-chorus-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    width: 100%;
}
.keyboard-effects-ringmod-controls,
.keyboard-effects-dist-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    width: 100%;
}
.keyboard-effects-chorus-toggles {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    max-width: 96px;
}
.keyboard-effects-delay-controls {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
}
.keyboard-effects-delay-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
}
.keyboard-effects-delay-toggle-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 96px;
}
.keyboard-effects-delay-time {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    min-width: 0;
    width: 100%;
}
.keyboard-effects-delay-time-label {
    font-family: 'Michroma', sans-serif;
    font-size: 7px;
    letter-spacing: 0.04em;
    color: #00aa00;
    text-transform: uppercase;
    line-height: 1;
}
.keyboard-effects-comp-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    width: 100%;
}
.keyboard-effects-comp-toggle-row,
.keyboard-effects-ringmod-toggle-row,
.keyboard-effects-dist-toggle-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 96px;
}
.keyboard-delay-time-select {
    font-family: 'Michroma', sans-serif;
    font-size: 8px;
    color: #00ff00;
    background: #111;
    border: 1px solid #00aa00;
    border-radius: 3px;
    padding: 4px 6px;
    min-width: 3.25rem;
    max-width: 4.5rem;
    width: 100%;
    box-sizing: border-box;
    align-self: center;
    margin-bottom: 0;
}
.keyboard-delay-time-select:disabled {
    opacity: 0.45;
}
.keyboard-delay-time-select:focus-visible {
    outline: 1px solid #00ff00;
    outline-offset: 1px;
}
.keyboard-effects-knob .synth-knob-dial-wrap {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
}
.keyboard-effects-knob .synth-knob-dial {
    width: 40px;
    height: 40px;
}
.keyboard-effects-knob.synth-knob--stepped .synth-knob-dial-wrap {
    --tick-radius: 18px;
}
.keyboard-effects-knob .synth-knob-label {
    font-size: 7px;
}
.keyboard-osc-field {
    margin: 0;
    padding: 6px 8px 8px;
    border: 1px solid #00aa00;
    border-radius: 4px;
    min-width: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
}
.keyboard-osc-field legend {
    font-family: 'Michroma', sans-serif;
    color: #00aa00;
    font-size: 9px;
    padding: 0 4px;
    width: fit-content;
    margin: 0 auto;
}
.keyboard-osc-controls {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    align-items: center;
    justify-items: center;
    gap: 4px;
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}
.keyboard-osc-knob-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    width: 100%;
    min-width: 0;
}
.keyboard-osc-toggle-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 96px;
    min-width: 0;
    grid-row: 4;
}
.keyboard-osc-knob {
    width: auto;
    gap: 1px;
}
.keyboard-osc-knob .synth-knob-label {
    font-size: 7px;
}
.keyboard-osc-knob .synth-knob-value {
    font-size: 8px;
    min-height: 0;
    line-height: 1;
}
.keyboard-osc-knob .synth-knob-dial-wrap {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
}
.keyboard-osc-knob .synth-knob-dial {
    width: 40px;
    height: 40px;
}
.keyboard-osc-knob .synth-knob-indicator {
    width: 2px;
    height: 10px;
    top: 4px;
    transform-origin: 50% 16px;
}
.keyboard-osc-wave {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: center;
    gap: 2px;
    width: 100%;
    min-width: 0;
    margin-bottom: 0;
    padding: 2px;
    border: 1px solid #00aa00;
    border-radius: 3px;
    background: #111;
    box-sizing: border-box;
    overflow: hidden;
}
.keyboard-osc-wave-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    height: 22px;
    margin: 0;
    padding: 2px;
    border: 1px solid transparent;
    border-radius: 2px;
    background: transparent;
    color: #00aa00;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}
.keyboard-osc-wave-btn:hover,
.keyboard-osc-wave-btn:focus-visible {
    color: #00ff00;
    border-color: #00aa00;
    outline: none;
}
.keyboard-osc-wave-btn.active {
    color: #000;
    background: #00ff00;
    border-color: #00ff00;
    box-shadow: none;
}
.keyboard-osc-wave-icon {
    display: block;
    width: 20px;
    height: 10px;
    pointer-events: none;
}
.keyboard-steps-panel {
    display: grid;
    grid-template-columns: repeat(var(--kb-step-cols, 16), minmax(0, 1fr));
    gap: 4px;
    padding-top: 4px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    justify-items: center;
}
.keyboard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    margin: 0;
    padding: 3px 2px 4px;
    min-width: 0;
    width: 100%;
    max-width: 54px;
    box-sizing: border-box;
    border: 1px solid #00aa00;
    border-radius: 4px;
    position: relative;
}
.keyboard-step.hidden {
    display: none;
}
.keyboard-step legend {
    color: #00aa00;
    font-family: 'Michroma', sans-serif;
    font-size: 8px;
    padding: 0 2px;
    width: fit-content;
    margin: 0 auto;
}
.keyboard-step-knob {
    gap: 0;
    width: 100%;
    max-width: 100%;
    align-items: center;
    min-width: 0;
}
.keyboard-step-knob .synth-knob-value {
    font-size: 8px;
    min-height: 0;
    line-height: 1;
    margin-top: 1px;
}
/* Tiny µtune — green line + triangle thumb below (beats global range chrome) */
.keyboard-section input[type="range"].kb-step-fine {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    display: block;
    width: 28px;
    max-width: 100%;
    height: 12px;
    margin: 1px auto 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    outline: none;
    cursor: pointer;
    touch-action: none;
}
.keyboard-section input[type="range"].kb-step-fine:focus {
    outline: none;
}
.keyboard-section input[type="range"].kb-step-fine::-webkit-slider-runnable-track {
    -webkit-appearance: none;
    appearance: none;
    height: 1px;
    background: #00aa00;
    border: none;
    border-radius: 0;
    box-shadow: none;
}
.keyboard-section input[type="range"].kb-step-fine::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 8px;
    height: 6px;
    margin-top: 2px; /* sit below the green line */
    border: none;
    border-radius: 0;
    background: #00ff00;
    box-shadow: none;
    cursor: pointer;
    transition: none;
    transform: none;
    clip-path: polygon(50% 0, 0 100%, 100% 100%); /* ▲ tip up toward the line */
}
.keyboard-section input[type="range"].kb-step-fine::-webkit-slider-thumb:hover,
.keyboard-section input[type="range"].kb-step-fine::-webkit-slider-thumb:active,
.keyboard-section input[type="range"].kb-step-fine:focus::-webkit-slider-thumb {
    background: #66ff66;
    transform: none;
    box-shadow: none;
}
.keyboard-section input[type="range"].kb-step-fine::-moz-range-track {
    height: 1px;
    background: #00aa00;
    border: none;
    border-radius: 0;
    box-shadow: none;
}
.keyboard-section input[type="range"].kb-step-fine::-moz-range-thumb {
    width: 8px;
    height: 6px;
    border: none;
    border-radius: 0;
    background: #00ff00;
    box-shadow: none;
    cursor: pointer;
    transition: none;
    transform: none;
    clip-path: polygon(50% 0, 0 100%, 100% 100%);
}
.keyboard-section input[type="range"].kb-step-fine::-moz-range-thumb:hover,
.keyboard-section input[type="range"].kb-step-fine::-moz-range-thumb:active,
.keyboard-section input[type="range"].kb-step-fine:focus::-moz-range-thumb {
    background: #66ff66;
    transform: none;
    box-shadow: none;
}
.keyboard-section .kb-step-fine-value {
    display: block;
    width: 100%;
    font-family: 'Michroma', sans-serif;
    font-size: 6px;
    line-height: 1;
    color: #00aa00;
    letter-spacing: 0;
    margin-top: 3px;
    text-align: center;
    white-space: nowrap;
}
.keyboard-step-knob .synth-knob-dial-wrap {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
}
.keyboard-step-knob .synth-knob-dial {
    width: 26px;
    height: 26px;
}
.keyboard-step-knob .synth-knob-indicator {
    width: 2px;
    height: 8px;
    top: 3px;
    transform-origin: 50% 10px; /* dial radius (13) - top (3) */
}
.keyboard-step.active .keyboard-step-knob .synth-knob-dial {
    border-color: #00ff00;
    background: #00ff00;
    box-shadow: none;
}
.keyboard-step.active .keyboard-step-knob .synth-knob-indicator {
    background: #000;
    box-shadow: none;
}
.keyboard-step-buttons {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    gap: 2px;
    width: 100%;
    justify-content: center;
}
.kb-step-btn {
    flex: 1 1 calc(50% - 1px);
    min-width: 0;
    height: auto;
    padding: 3px 1px;
    margin: 0;
    border-radius: 3px;
    border: 1px solid #00aa00;
    background: linear-gradient(to bottom, #1a1a1a 0%, #0d0d0d 100%);
    box-shadow: inset 0 0 6px rgba(0, 255, 0, 0.15);
    font-family: 'Michroma', sans-serif;
    font-size: 7px;
    letter-spacing: 0;
    line-height: 1;
    color: #00aa00;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.kb-step-toggle-full {
    flex: 1 1 100%;
}
.kb-step-btn:hover,
.kb-step-btn:focus-visible {
    border-color: #00ff00;
    background: linear-gradient(to bottom, #1f2f1f 0%, #122012 100%);
}
.kb-step-btn:active,
.kb-step-btn:not(.off) {
    border-color: #00ff00;
    background: #00ff00;
    box-shadow: none;
    color: #000;
}
.kb-step-btn.off {
    color: #00aa00;
    border-color: #00aa00;
    background: linear-gradient(to bottom, #1a1a1a 0%, #0d0d0d 100%);
    box-shadow: inset 0 0 6px rgba(0, 255, 0, 0.15);
}
.kb-step-btn.off:hover,
.kb-step-btn.off:focus-visible {
    border-color: #00ff00;
    background: linear-gradient(to bottom, #1f2f1f 0%, #122012 100%);
}
.kb-step-btn:not(.off):hover,
.kb-step-btn:not(.off):focus-visible {
    border-color: #00ff00;
    background: #00ff00;
    color: #000;
}
.keyboard-toolbar-btn {
    flex: 0 0 auto;
    width: auto;
    height: 25px;
    padding: 0 10px;
    font-size: 11px;
    white-space: nowrap;
    box-sizing: border-box;
}
.keyboard-toolbar-btn:not(.off),
.keyboard-toolbar-btn:not(.off):hover,
.keyboard-toolbar-btn:not(.off):focus-visible {
    color: #000 !important;
}

/* Performance controls: 2 columns (Transport | Write), collapsible sections below */
.keyboard-filter-knobs {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 6px;
    padding: 0 4px;
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
}
.keyboard-perf-top {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    overflow: visible;
}
.keyboard-transport-fieldset,
.keyboard-write-fieldset {
    min-width: 0;
    width: 100%;
    overflow: visible;
    box-sizing: border-box;
    padding: 6px 8px 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    --kb-perf-footer-h: 22px; /* reserved under dials for Full/Lock */
}
.keyboard-tempo-div-row,
.keyboard-write-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
    width: 100%;
}
/* Bare transport buttons sit in a dial-wrap-sized slot so centers match knobs */
.keyboard-perf-btn-slot {
    position: relative;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding-bottom: var(--kb-perf-footer-h);
    box-sizing: content-box;
}
.keyboard-tempo-div-row > .synth-knob,
.keyboard-tempo-div-row > .keyboard-step-vfd-wrap {

    padding-bottom: var(--kb-perf-footer-h);
    box-sizing: content-box;
}
.keyboard-steps-collapsible-panel {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.keyboard-steps-collapsible-panel.hidden {
    display: none;
}
.keyboard-pattern-shift {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 4px 0 2px;
    box-sizing: border-box;
}
.keyboard-pattern-shift-label {
    font-family: 'Michroma', sans-serif;
    font-size: 8px;
    color: #00ff00;
    letter-spacing: 0.04em;
    line-height: 1;
    white-space: nowrap;
}
.keyboard-pattern-shift-buttons {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
/* Acc/On footprint + transport (Rev / write-nav) look */
#kbPatternShiftBack.pushable.keyboard-pattern-shift-btn,
#kbPatternShiftForward.pushable.keyboard-pattern-shift-btn {
    background: linear-gradient(to bottom, #1a1a1a, #000);
    flex: 0 0 auto;
    width: 54px;
    height: auto;
    margin: 0;
}
#kbPatternShiftBack.pushable.keyboard-pattern-shift-btn .front,
#kbPatternShiftForward.pushable.keyboard-pattern-shift-btn .front {
    box-sizing: border-box;
    width: 100%;
    min-height: 0;
    padding: 3px 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to bottom, #333, #000);
    font-family: 'Michroma', sans-serif;
    font-size: 7px;
    letter-spacing: 0;
    line-height: 1;
    color: #00ff00;
}
.pattern-shift-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 0 auto 12px;
}
.pattern-shift-control .pattern-shift-buttons {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.pattern-shift-label {
    font-family: 'Michroma', sans-serif;
    font-size: 10px;
    color: #00ff00;
    letter-spacing: 0.04em;
    line-height: 1;
    white-space: nowrap;
}
/* Acc/On size + dark transport face on main page */
#patternShiftBack.pushable,
#patternShiftForward.pushable {
    background: linear-gradient(to bottom, #1a1a1a, #000);
    width: 58px;
}
#patternShiftBack.pushable .front,
#patternShiftForward.pushable .front {
    box-sizing: border-box;
    width: 100%;
    font-size: 8px;
    padding: 3px 0;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to bottom, #333, #000);
    color: #00ff00;
}
.keyboard-write-step-select {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
    padding-bottom: var(--kb-perf-footer-h);
    box-sizing: content-box;
}
.keyboard-write-step-select-label {
    font-family: 'Michroma', sans-serif;
    font-size: 8px;
    color: #00ff00;
    letter-spacing: 0.04em;
    line-height: 1;
    height: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    white-space: nowrap;
}
.keyboard-write-step-select-btns {
    /* Match .synth-knob-dial-wrap so arrows sit with dials */
    position: relative;
    width: auto;
    height: 72px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 0 0 72px;
}
.keyboard-perf-fieldset {
    margin: 0;
    padding: 8px;
    border: 1px solid #00aa00;
    border-radius: 5px;
    box-sizing: border-box;
}
.keyboard-perf-fieldset legend {
    font-family: 'Michroma', sans-serif;
    color: #00aa00;
    padding: 0 5px;
    font-size: 10px;
    font-weight: normal;
    letter-spacing: 0.04em;
    width: fit-content;
    margin: 0 auto;
}
#kbStartStop.pushable.keyboard-start-stop {
    background: linear-gradient(to bottom, #1a1a1a, #000);
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    margin: 0;
}
#kbStartStop.pushable.keyboard-start-stop .front {
    box-sizing: border-box;
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to bottom, #333, #000);
    color: transparent;
    font-size: 0;
}
#kbStartStop .kb-transport-icon {
    display: block;
    pointer-events: none;
}
#kbStartStop.start .kb-transport-icon {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 9px 0 9px 16px;
    border-color: transparent transparent transparent #00ff00;
    margin-left: 3px;
}
#kbStartStop.stop .kb-transport-icon {
    width: 16px;
    height: 16px;
    border: none;
    background: #ff0000;
    border-radius: 1px;
    margin-left: 0;
}
#kbRev.pushable.keyboard-rev {
    background: linear-gradient(to bottom, #1a1a1a, #000);
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    margin: 0;
}
#kbRev.pushable.keyboard-rev .front {
    box-sizing: border-box;
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to bottom, #333, #000);
    font-family: 'Michroma', sans-serif;
    font-size: 9px;
    letter-spacing: 0.04em;
    line-height: 1;
    color: #00ff00;
}
#kbRev.pushable.keyboard-rev.on .front,
#kbRev.pushable.keyboard-rev:not(.off) .front {
    color: #ff0000;
}
#kbRev.pushable.keyboard-rev.off .front {
    color: #00ff00;
}
.keyboard-write-fine-knob.synth-knob {
    position: relative;
}
.keyboard-write-fine-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    flex: 0 0 auto;
}
.keyboard-write-fine-knob.is-disabled {
    opacity: 0.35;
    pointer-events: none;
}
.keyboard-write-fine-proxy {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
/* Match synth On/Off toggles; in-flow under µTUNE, inside the field */
#kbMicrotuneLock.kb-step-btn.kb-microtune-lock {
    flex: 0 0 auto;
    width: 46px;
    min-width: 46px;
    max-width: 46px;
    height: var(--kb-perf-footer-h);
    min-height: var(--kb-perf-footer-h);
    max-height: var(--kb-perf-footer-h);
    padding: 0 6px;
    box-sizing: border-box;
    font-size: 7px;
    letter-spacing: 0;
}
#kbWrite.pushable.keyboard-write,
#kbWritePrev.pushable.keyboard-write-nav,
#kbWriteNext.pushable.keyboard-write-nav,
#kbRest.pushable.keyboard-write-rest,
#kbWriteAcc.pushable.keyboard-write-arm,
#kbWriteSld.pushable.keyboard-write-arm {
    background: linear-gradient(to bottom, #1a1a1a, #000);
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    margin: 0;
}
#kbWritePrev.pushable.keyboard-write-nav,
#kbWriteNext.pushable.keyboard-write-nav {
    align-self: auto;
}
#kbWrite.pushable.keyboard-write {
    width: 72px;
    flex: 0 0 72px;
}
#kbWrite.pushable.keyboard-write .front,
#kbWritePrev.pushable.keyboard-write-nav .front,
#kbWriteNext.pushable.keyboard-write-nav .front,
#kbRest.pushable.keyboard-write-rest .front,
#kbWriteAcc.pushable.keyboard-write-arm .front,
#kbWriteSld.pushable.keyboard-write-arm .front {
    box-sizing: border-box;
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to bottom, #333, #000);
    font-family: 'Michroma', sans-serif;
    font-size: 9px;
    letter-spacing: 0.04em;
    line-height: 1;
    color: #00ff00;
}
#kbWrite.pushable.keyboard-write .front {
    width: 72px;
}
#kbWrite.pushable.keyboard-write .kb-write-label {
    display: none;
    color: #00ff00;
    font-size: 9px;
    letter-spacing: 0.04em;
}
#kbWrite.pushable.keyboard-write .kb-write-rec {
    display: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ff0000;
    pointer-events: none;
    opacity: var(--kb-rec-blink);
}
#kbWrite.pushable.keyboard-write.off .kb-write-label {
    display: inline;
}
#kbWrite.pushable.keyboard-write.off .kb-write-rec {
    display: none;
}
#kbWrite.pushable.keyboard-write.on .kb-write-label,
#kbWrite.pushable.keyboard-write:not(.off) .kb-write-label {
    display: none;
}
#kbWrite.pushable.keyboard-write.on .kb-write-rec,
#kbWrite.pushable.keyboard-write:not(.off) .kb-write-rec {
    display: block;
}
#kbWritePrev.pushable.keyboard-write-nav:disabled,
#kbWriteNext.pushable.keyboard-write-nav:disabled,
#kbRest.pushable.keyboard-write-rest:disabled,
#kbWriteAcc.pushable.keyboard-write-arm:disabled,
#kbWriteSld.pushable.keyboard-write-arm:disabled {
    opacity: 0.35;
    cursor: default;
}
#kbWriteAcc.pushable.keyboard-write-arm.on .front,
#kbWriteAcc.pushable.keyboard-write-arm:not(.off) .front,
#kbWriteSld.pushable.keyboard-write-arm.on .front,
#kbWriteSld.pushable.keyboard-write-arm:not(.off) .front {
    color: #ff0000;
}
#kbWriteAcc.pushable.keyboard-write-arm.off .front,
#kbWriteSld.pushable.keyboard-write-arm.off .front {
    color: #00ff00;
}
#kbRest.pushable.keyboard-write-rest.on .front,
#kbRest.pushable.keyboard-write-rest:not(.off) .front {
    color: #ff0000;
}
#kbRest.pushable.keyboard-write-rest.off .front {
    color: #00ff00;
}
.keyboard-step.write-cursor {
    outline: 1px solid rgba(255, 51, 51, var(--kb-rec-blink));
    outline-offset: 1px;
    box-shadow: 0 0 6px rgba(255, 0, 0, calc(0.35 * var(--kb-rec-blink)));
}
.sequencer-step.write-cursor {
    outline: 1px solid rgba(255, 51, 51, var(--kb-rec-blink));
    outline-offset: 2px;
}
body.write-mode-on .keyboard-step {
    cursor: pointer;
}
.keyboard-step-vfd-wrap {
    flex: 0 0 auto;
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.keyboard-step-vfd-bezel {
    /* Match .synth-knob-dial-wrap so the 44px VFD centers with the dials */
    position: relative;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 72px;
}
.keyboard-step-vfd-label {
    font-family: 'Michroma', sans-serif;
    font-size: 8px;
    letter-spacing: 0.04em;
    color: #00ff00;
    line-height: 1;
    height: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.keyboard-step-vfd {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    height: 44px;
    padding: 4px 10px;
    box-sizing: border-box;
    border: 1px solid #1a3a1a;
    border-radius: 2px;
    overflow: hidden;
    background: #0a0f0a;
    box-shadow:
        inset 0 0 10px rgba(0, 0, 0, 0.65),
        0 0 0 1px #050805;
}
/* Glass tint only along the very bottom edge, behind the digits */
.keyboard-step-vfd::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 6px;
    background: linear-gradient(to top, rgba(0, 35, 0, 0.55), transparent);
    pointer-events: none;
    z-index: 0;
}
.keyboard-step-vfd-digits {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    pointer-events: none;
}
/* 16-segment digit (Wikipedia naming):
   a1 a2 | b c | d1 d2 | e f | g1 g2 | h i j | k l m
   https://commons.wikimedia.org/wiki/File:16SegmentDisplayASCII.svg */
.sixteen-seg {
    position: relative;
    width: 22px;
    height: 34px;
    --seg-on: #00ff66;
    --seg-off: rgba(0, 48, 0, 0.55);
    --seg-glow: 0 0 4px rgba(0, 255, 102, 0.9), 0 0 8px rgba(0, 200, 60, 0.4);
    --seg-w: 2.5px;
}
.keyboard-step-vfd-digits.lit .sixteen-seg .seg {
    /* Keep unused segments nearly invisible so they don't veil lit bars */
    background: rgba(0, 40, 0, 0.32);
}
.sixteen-seg .seg {
    position: absolute;
    background: var(--seg-off);
    box-shadow: none;
    border-radius: 0.5px;
    z-index: 0;
    transition: background 0.06s ease, box-shadow 0.06s ease;
}
/* Split horizontals: a1/a2 top, g1/g2 mid, d1/d2 bottom */
.sixteen-seg .seg.a1,
.sixteen-seg .seg.a2,
.sixteen-seg .seg.g1,
.sixteen-seg .seg.g2,
.sixteen-seg .seg.d1,
.sixteen-seg .seg.d2 {
    height: var(--seg-w);
    width: calc(50% - 3.5px);
}
.sixteen-seg .seg.a1,
.sixteen-seg .seg.g1,
.sixteen-seg .seg.d1 { left: 2.5px; }
.sixteen-seg .seg.a2,
.sixteen-seg .seg.g2,
.sixteen-seg .seg.d2 { right: 2.5px; }
.sixteen-seg .seg.a1,
.sixteen-seg .seg.a2 { top: 0; }
.sixteen-seg .seg.g1,
.sixteen-seg .seg.g2 { top: 50%; margin-top: calc(var(--seg-w) / -2); }
.sixteen-seg .seg.d1,
.sixteen-seg .seg.d2 { bottom: 0; }
/* Outer verticals b/c (right), f/e (left) */
.sixteen-seg .seg.b,
.sixteen-seg .seg.c,
.sixteen-seg .seg.e,
.sixteen-seg .seg.f {
    width: var(--seg-w);
}
.sixteen-seg .seg.b,
.sixteen-seg .seg.f {
    top: calc(var(--seg-w) + 0.5px);
    height: calc(50% - var(--seg-w) - 2px);
}
.sixteen-seg .seg.c,
.sixteen-seg .seg.e {
    bottom: calc(var(--seg-w) + 0.5px);
    height: calc(50% - var(--seg-w) - 2px);
}
.sixteen-seg .seg.b,
.sixteen-seg .seg.c { right: 0; }
.sixteen-seg .seg.e,
.sixteen-seg .seg.f { left: 0; }
/* Center verticals: i (upper mid), l (lower mid) */
.sixteen-seg .seg.i,
.sixteen-seg .seg.l {
    width: var(--seg-w);
    left: 50%;
    margin-left: calc(var(--seg-w) / -2);
}
.sixteen-seg .seg.i {
    top: calc(var(--seg-w) + 0.5px);
    height: calc(50% - var(--seg-w) - 2px);
}
.sixteen-seg .seg.l {
    bottom: calc(var(--seg-w) + 0.5px);
    height: calc(50% - var(--seg-w) - 2px);
}
/* Diagonals from corners toward center (h UL, j UR, k LL, m LR).
   Upper pair: origin at bottom (center). Lower pair: origin at top (center).
   CSS positive rotate is clockwise. */
.sixteen-seg .seg.h,
.sixteen-seg .seg.j,
.sixteen-seg .seg.k,
.sixteen-seg .seg.m {
    width: var(--seg-w);
    height: 42%;
    left: 50%;
    margin-left: calc(var(--seg-w) / -2);
}
.sixteen-seg .seg.h,
.sixteen-seg .seg.j {
    top: calc(var(--seg-w) + 1px);
    transform-origin: center bottom;
}
.sixteen-seg .seg.k,
.sixteen-seg .seg.m {
    bottom: calc(var(--seg-w) + 1px);
    top: auto;
    transform-origin: center top;
}
/* UL: top leans left; UR: top leans right */
.sixteen-seg .seg.h { transform: translateX(-5px) rotate(-38deg); }
.sixteen-seg .seg.j { transform: translateX(5px) rotate(38deg); }
/* LL: bottom leans left; LR: bottom leans right */
.sixteen-seg .seg.k { transform: translateX(-5px) rotate(38deg); }
.sixteen-seg .seg.m { transform: translateX(5px) rotate(-38deg); }

/* Decimal point (bottom-right of each digit cell) */
.sixteen-seg .seg.dp {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    left: auto;
    right: -1px;
    bottom: -1px;
    top: auto;
    margin: 0;
    transform: none;
}

/* Lit segments are toggled via JS (.on) from vfd-charset.js */
.keyboard-step-vfd-digits.lit .sixteen-seg .seg {
    background: rgba(0, 40, 0, 0.32);
}
.keyboard-step-vfd-digits.lit .sixteen-seg .seg.on {
    background: var(--seg-on);
    box-shadow: var(--seg-glow);
    z-index: 2;
}

/* Idle (not lit): keep a faint ghost grid only */
.keyboard-step-vfd-digits:not(.lit) .sixteen-seg .seg {
    background: var(--seg-off);
}
.keyboard-filter-knob-group {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}
.keyboard-filter-knob-group .synth-knob {
    width: auto;
}
.keyboard-pitch-bend {
    grid-column: span 1;
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin: 0;
    --bend: 0;
}
.keyboard-pitch-bend-track {
    position: relative;
    height: 44px;
    border: 1px solid #00aa00;
    border-radius: 5px; /* match Steps / other keyboard fieldsets */
    background: linear-gradient(to bottom, #1a1a1a 0%, #0d0d0d 100%);
    box-shadow: inset 0 0 8px rgba(0, 255, 0, 0.15);
    cursor: ew-resize;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
}
.keyboard-pitch-bend:hover .keyboard-pitch-bend-track,
.keyboard-pitch-bend:focus-visible .keyboard-pitch-bend-track {
    border-color: #00ff00;
    background: linear-gradient(to bottom, #1f2f1f 0%, #122012 100%);
}
.keyboard-pitch-bend.active .keyboard-pitch-bend-track {
    border-color: #00ff00;
    background: linear-gradient(to bottom, #004400 0%, #002200 100%);
    box-shadow: inset 0 0 12px rgba(0, 255, 0, 0.35);
}
.keyboard-pitch-bend-center {
    position: absolute;
    left: 50%;
    top: 6px;
    bottom: 6px;
    width: 1px;
    margin-left: -0.5px;
    background: rgba(0, 255, 0, 0.35);
    pointer-events: none;
}
.keyboard-pitch-bend-thumb {
    position: absolute;
    top: 4px;
    bottom: 4px;
    width: 10px;
    margin-left: -5px;
    left: calc(50% + var(--bend) * 50%);
    border: 1px solid #00ff00;
    background: linear-gradient(to bottom, #00cc00, #006600);
    box-shadow: 0 0 6px rgba(0, 255, 0, 0.45);
    pointer-events: none;
}
.keyboard-pitch-bend .synth-knob-label {
    align-self: center;
}
.synth-knob {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: 0 0 auto;
    width: 72px;
}
.synth-knob-value--spacer {
    visibility: hidden;
}
.synth-knob-dial-wrap {
    position: relative;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 72px;
    --tick-radius: 30px;
}
.synth-knob-ticks {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
}
.synth-knob-tick {
    position: absolute;
    left: 50%;
    top: 50%;
    font-family: 'Michroma', sans-serif;
    font-size: 6px;
    color: #00cc00;
    letter-spacing: 0.02em;
    line-height: 1;
    white-space: nowrap;
    transform: translate(-50%, -50%) rotate(var(--tick-angle)) translateY(calc(-1 * var(--tick-radius))) rotate(calc(-1 * var(--tick-angle)));
    opacity: 0.85;
}
.synth-knob-dial {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid #00aa00;
    background: linear-gradient(to bottom, #1a1a1a 0%, #0d0d0d 100%);
    box-shadow: inset 0 0 8px rgba(0, 255, 0, 0.15);
    cursor: ns-resize;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.synth-knob-dial:hover,
.synth-knob-dial:focus-visible {
    border-color: #00ff00;
    background: linear-gradient(to bottom, #1f2f1f 0%, #122012 100%);
}
.synth-knob-dial.active {
    border-color: #00ff00;
    background: linear-gradient(to bottom, #004400 0%, #002200 100%);
    box-shadow: inset 0 0 12px rgba(0, 255, 0, 0.35);
}
.synth-knob-indicator {
    position: absolute;
    left: 50%;
    top: 5px;
    width: 2px;
    height: 12px;
    margin-left: -1px;
    background: #00ff00;
    border-radius: 1px;
    transform-origin: 50% 17px; /* dial radius (22) - top offset (5) */
    transform: rotate(var(--knob-angle, -135deg));
    pointer-events: none;
    box-shadow: 0 0 4px rgba(0, 255, 0, 0.6);
}
.synth-knob-label {
    font-family: 'Michroma', sans-serif;
    font-size: 8px;
    color: #00ff00;
    letter-spacing: 0.04em;
    line-height: 1;
    pointer-events: none;
    height: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.synth-knob-value {
    font-family: 'Michroma', sans-serif;
    font-size: 7px;
    color: #00cc00;
    letter-spacing: 0.02em;
    line-height: 1;
    pointer-events: none;
    min-width: 2em;
    text-align: center;
    font-variant-numeric: tabular-nums;
    opacity: 0.9;
    height: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chromatic-keyboard-panel::-webkit-scrollbar {
    height: 14px;
}
.chromatic-keyboard-panel::-webkit-scrollbar-track {
    background: #111;
    border: 1px solid #333;
    border-radius: 7px;
    margin: 0 18%;
}
.chromatic-keyboard-panel::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #00cc00, #006600);
    border-radius: 7px;
    border: 2px solid #111;
    min-width: 24px;
}
.chromatic-keyboard-panel::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #00ff00, #00aa00);
}
.chromatic-keyboard {
    --white-count: 52;
    --white-key-width: 36px;
    position: relative;
    height: 160px;
    touch-action: manipulation;
    margin: 0 auto 6px;
}
.piano-white-layer {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
}
.piano-black-layer {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}
.piano-key {
    border: 1px solid #333;
    margin: 0;
    padding: 0;
    font-family: 'Michroma', sans-serif;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    box-sizing: border-box;
    border-radius: 0 0 4px 4px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.piano-key-white {
    flex: 0 0 var(--white-key-width);
    width: var(--white-key-width);
    height: 100%;
    background: linear-gradient(to bottom, #1a1a1a 0%, #0d0d0d 100%);
    border-color: #00aa00;
    color: #00ff00;
}
.piano-key-white:hover {
    background: linear-gradient(to bottom, #1f2f1f 0%, #122012 100%);
    border-color: #00ff00;
}
.piano-key-black {
    position: absolute;
    top: 0;
    height: 58%;
    background: linear-gradient(to bottom, #050505 0%, #111 100%);
    border-color: #00aa00;
    color: #00cc00;
    pointer-events: auto;
    z-index: 3;
}
.piano-key-black:hover {
    background: linear-gradient(to bottom, #0a1a0a 0%, #152515 100%);
    border-color: #00ff00;
}
.piano-key.active,
.piano-key.latched {
    background: linear-gradient(to bottom, #004400 0%, #002200 100%) !important;
    border-color: #00ff00 !important;
    box-shadow: inset 0 0 12px rgba(0, 255, 0, 0.35);
}
.piano-key.key-root:not(.active):not(.latched) {
    border-color: #00ffff;
    box-shadow: inset 0 0 8px rgba(0, 255, 255, 0.2);
}
.piano-key-label {
    font-size: 9px;
    padding-bottom: 6px;
    pointer-events: none;
    line-height: 1;
    white-space: nowrap;
}
.piano-key-black .piano-key-label {
    font-size: 7px;
    padding-bottom: 4px;
    color: #88ff88;
}
.piano-key.active .piano-key-label,
.piano-key.latched .piano-key-label {
    color: #ccffcc;
    font-weight: bold;
}
#keyboardVisibilityToggle.off .front {
    color: #ff0000;
}
#keyboardVisibilityToggle .front {
    font-size: 11px;
    padding: 6px 10px;
}

@media (max-width: 768px) {
    .keyboard-section {
        max-width: 100%;
        margin-bottom: 15px;
        padding: 10px;
    }
    .chromatic-keyboard {
        height: 120px;
    }
    .piano-key-label {
        font-size: 7px;
        padding-bottom: 4px;
    }
    .piano-key-black .piano-key-label {
        font-size: 6px;
    }
    .keyboard-transpose-screen {
        margin-left: 0;
    }
    .keyboard-filter-knobs {
        gap: 8px;
        margin-bottom: 4px;
    }
    .keyboard-steps-fieldset,
    .keyboard-automation-fieldset,
    .keyboard-synth-fieldset,
    .keyboard-xy-fieldset {
        margin: 0;
        padding: 4px 6px 6px;
    }
    .keyboard-synth-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px;
    }
    /* Flatten wrappers so sections share one 2-col grid */
    .keyboard-synth-col--oscs,
    .keyboard-osc-rows,
    .keyboard-synth-col-stack--2,
    .keyboard-synth-col-stack--3,
    .keyboard-synth-panel .keyboard-amp-group,
    .keyboard-amp-controls {
        display: contents;
    }
    .keyboard-osc-group > legend {
        grid-column: 1 / -1;
        width: fit-content;
        margin: 0 auto;
    }
    .keyboard-amp-group > legend {
        display: none;
    }
    .keyboard-osc-field[data-osc="0"] {
        grid-column: 1;
        grid-row: 2;
    }
    .keyboard-osc-field[data-osc="1"] {
        grid-column: 2;
        grid-row: 2;
    }
    .keyboard-osc-field[data-osc="2"] {
        grid-column: 1;
        grid-row: 3;
    }
    .keyboard-synth-panel .keyboard-noise-group {
        grid-column: 2;
        grid-row: 3;
        height: auto;
        align-self: stretch;
        padding: 3px 3px 5px;
    }
    .keyboard-unison-field {
        grid-column: 1 / -1;
        grid-row: 4;
        height: auto;
        align-self: stretch;
        margin: 0;
        padding: 4px 6px 6px;
    }
    .keyboard-unison-controls {
        gap: 8px;
    }
    .keyboard-unison-voices-label {
        font-size: 6px;
        color: #00aa00;
    }
    .keyboard-unison-voices select {
        min-width: 0;
        max-width: 4rem;
        font-size: 8px;
        color: #00ff00;
        border-color: #00aa00;
    }
    .keyboard-phase-reset-field {
        grid-column: 1 / -1;
        grid-row: 5;
        height: auto;
        align-self: stretch;
        margin: 0;
        padding: 4px 6px 6px;
    }
    .keyboard-phase-reset-field legend {
        font-size: 7px;
    }
    .keyboard-filter-knob-group {
        grid-column: 1;
        grid-row: 6;
        height: auto;
        align-self: stretch;
        padding: 4px 4px 6px;
    }
    .keyboard-synth-panel .keyboard-filter-env-group {
        grid-column: 2;
        grid-row: 6;
        height: auto;
        align-self: stretch;
        padding: 4px 4px 6px;
    }
    .keyboard-vol-env-field {
        grid-column: 1;
        grid-row: 7;
        height: auto;
        align-self: stretch;
        padding: 4px 3px 6px;
    }
    .keyboard-volume-field {
        grid-column: 2;
        grid-row: 7;
        height: auto;
        align-self: stretch;
        padding: 4px 4px 6px;
        justify-content: center;
    }
    .keyboard-synth-panel .keyboard-effects-group {
        grid-column: 1 / -1;
        grid-row: 8;
        display: flex;
        flex-direction: column;
        height: auto;
        width: 100%;
        min-width: 0;
        padding: 4px 6px 6px;
        box-sizing: border-box;
    }
    .keyboard-synth-panel .keyboard-effects-group > .collapsible-legend .collapsible-toggle {
        font-size: 8px;
    }
    .keyboard-synth-panel .keyboard-effects-group.collapsed {
        padding-bottom: 4px;
    }
    .keyboard-synth-panel .keyboard-effects-controls {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px;
        width: 100%;
        min-width: 0;
        align-items: stretch;
    }
    .keyboard-synth-panel .keyboard-effects-controls.collapsible-panel.hidden {
        display: none;
    }
    .keyboard-synth-panel .keyboard-effects-ringmod-field {
        grid-column: 1;
        grid-row: 1;
        height: auto;
        align-self: stretch;
    }
    .keyboard-synth-panel .keyboard-effects-dist-field {
        grid-column: 2;
        grid-row: 1;
        height: auto;
        align-self: stretch;
    }
    .keyboard-synth-panel .keyboard-effects-chorus-field {
        grid-column: 1;
        grid-row: 2;
        height: auto;
        align-self: stretch;
    }
    .keyboard-synth-panel .keyboard-effects-delay-field {
        grid-column: 2;
        grid-row: 2;
        height: auto;
        align-self: stretch;
    }
    .keyboard-synth-panel .keyboard-effects-comp-field {
        grid-column: 1 / -1;
        grid-row: 3;
        height: auto;
        align-self: stretch;
    }
    .keyboard-effects-dist-field,
    .keyboard-effects-ringmod-field,
    .keyboard-effects-chorus-field,
    .keyboard-effects-delay-field,
    .keyboard-effects-comp-field {
        padding: 4px 4px 6px;
    }
    .keyboard-effects-dist-field legend,
    .keyboard-effects-ringmod-field legend,
    .keyboard-effects-chorus-field legend,
    .keyboard-effects-delay-field legend,
    .keyboard-effects-comp-field legend {
        font-size: 7px;
    }
    .keyboard-effects-delay-controls {
        gap: 8px;
    }
    .keyboard-effects-delay-time-label {
        font-size: 6px;
    }
    .keyboard-delay-time-select {
        min-width: 0;
        max-width: 4rem;
        font-size: 8px;
    }
    .keyboard-vol-env-field legend,
    .keyboard-volume-field legend {
        font-size: 7px;
    }
    .keyboard-vol-env-knob .synth-knob-dial {
        width: 28px;
        height: 28px;
    }
    .keyboard-vol-env-knob .synth-knob-indicator {
        height: 7px;
        transform-origin: 50% 10px;
    }
    .keyboard-filter-cutoff-knob .synth-knob-dial {
        width: 56px;
        height: 56px;
    }
    .keyboard-filter-cutoff-knob .synth-knob-indicator {
        top: 5px;
        height: 12px;
        transform-origin: 50% 23px;
    }
    .keyboard-filter-knob-row {
        gap: 8px;
    }
    .keyboard-adsr-visualizer {
        width: 100%;
        max-width: 120px;
        height: 40px;
    }
    .keyboard-filter-env-knob .synth-knob-dial {
        width: 28px;
        height: 28px;
    }
    .keyboard-filter-env-knob .synth-knob-indicator {
        height: 7px;
        transform-origin: 50% 10px;
    }
    .keyboard-filter-env-field {
        padding: 4px 3px 6px;
    }
    .keyboard-filter-env-field legend {
        font-size: 7px;
    }
    .kb-step-btn.kb-filter-env-toggle {
        font-size: 6px;
    }
    .keyboard-noise-controls {
        gap: 8px;
    }
    .keyboard-noise-type-label {
        font-size: 6px;
        color: #00aa00;
    }
    .keyboard-noise-type-select {
        min-width: 0;
        max-width: 4.5rem;
        font-size: 8px;
        color: #00ff00;
        border-color: #00aa00;
    }
    .kb-step-btn.kb-noise-toggle {
        font-size: 6px;
    }
    .keyboard-steps-panel {
        grid-template-columns: repeat(var(--kb-step-cols-mobile, 8), minmax(0, 1fr));
        gap: 4px;
        justify-items: center;
    }
    .keyboard-step {
        width: 100%;
        max-width: 48px;
        padding: 3px 2px 4px;
        gap: 3px;
    }
    .keyboard-step-knob .synth-knob-dial-wrap {
        width: 28px;
        height: 28px;
        flex: 0 0 28px;
    }
    .keyboard-step-knob .synth-knob-dial {
        width: 24px;
        height: 24px;
    }
    .kb-step-btn {
        font-size: 6px;
        padding: 2px 1px;
    }
    .keyboard-section input[type="range"].kb-step-fine {
        width: 24px;
        height: 11px;
    }
    .keyboard-section input[type="range"].kb-step-fine::-webkit-slider-thumb {
        width: 7px;
        height: 5px;
        margin-top: 2px;
    }
    .keyboard-section input[type="range"].kb-step-fine::-moz-range-thumb {
        width: 7px;
        height: 5px;
    }
    .keyboard-section .kb-step-fine-value {
        font-size: 5px;
    }
    .keyboard-filter-knobs {
        gap: 6px;
    }
    .keyboard-perf-top {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .keyboard-transport-fieldset,
    .keyboard-write-fieldset {
        width: 100%;
    }
    .keyboard-step-vfd {
        min-width: 56px;
        height: 36px;
        padding: 3px 6px;
    }
    .keyboard-step-vfd-label {
        font-size: 7px;
        height: 7px;
    }
    .sixteen-seg {
        width: 16px;
        height: 26px;
        --seg-w: 2px;
    }
    .keyboard-tempo-div-row {
        gap: 6px;
    }
    #kbStartStop.pushable.keyboard-start-stop,
    #kbRev.pushable.keyboard-rev,
    #kbWrite.pushable.keyboard-write,
    #kbWritePrev.pushable.keyboard-write-nav,
    #kbWriteNext.pushable.keyboard-write-nav,
    #kbRest.pushable.keyboard-write-rest,
    #kbWriteAcc.pushable.keyboard-write-arm,
    #kbWriteSld.pushable.keyboard-write-arm {
        width: 36px;
        height: 36px;
        flex-basis: 36px;
        margin: 0;
    }
    #kbWrite.pushable.keyboard-write {
        width: 58px;
        flex-basis: 58px;
    }
    .keyboard-perf-btn-slot {
        height: 60px;
    }
    .keyboard-transport-fieldset,
    .keyboard-write-fieldset {
        --kb-perf-footer-h: 20px;
    }
    #kbStartStop.pushable.keyboard-start-stop .front,
    #kbRev.pushable.keyboard-rev .front,
    #kbWrite.pushable.keyboard-write .front,
    #kbWritePrev.pushable.keyboard-write-nav .front,
    #kbWriteNext.pushable.keyboard-write-nav .front,
    #kbRest.pushable.keyboard-write-rest .front,
    #kbWriteAcc.pushable.keyboard-write-arm .front,
    #kbWriteSld.pushable.keyboard-write-arm .front {
        width: 36px;
        height: 36px;
    }
    #kbWrite.pushable.keyboard-write .front {
        width: 58px;
    }
    #kbRev.pushable.keyboard-rev .front,
    #kbWrite.pushable.keyboard-write .kb-write-label,
    #kbWritePrev.pushable.keyboard-write-nav .front,
    #kbWriteNext.pushable.keyboard-write-nav .front,
    #kbRest.pushable.keyboard-write-rest .front,
    #kbWriteAcc.pushable.keyboard-write-arm .front,
    #kbWriteSld.pushable.keyboard-write-arm .front {
        font-size: 8px;
    }
    #kbWrite.pushable.keyboard-write .kb-write-rec {
        width: 14px;
        height: 14px;
    }
    #kbStartStop.start .kb-transport-icon {
        border-width: 7px 0 7px 12px;
    }
    #kbStartStop.stop .kb-transport-icon {
        width: 14px;
        height: 14px;
    }
    .synth-knob {
        width: 60px;
    }
    .keyboard-filter-knob-group .synth-knob {
        width: auto;
    }
    .keyboard-osc-field {
        padding: 3px 3px 5px;
        height: auto;
        min-height: 0;
        align-self: stretch;
    }
    .keyboard-osc-field legend {
        font-size: 7px;
        padding: 0 2px;
    }
    .keyboard-osc-controls {
        gap: 3px;
    }
    .keyboard-osc-knob-row {
        gap: 2px;
    }
    .keyboard-osc-knob .synth-knob-dial-wrap {
        width: 32px;
        height: 32px;
        flex: 0 0 32px;
    }
    .keyboard-osc-knob .synth-knob-dial {
        width: 28px;
        height: 28px;
    }
    .keyboard-osc-knob .synth-knob-indicator {
        height: 7px;
        transform-origin: 50% 10px;
    }
    .keyboard-osc-knob .synth-knob-label {
        font-size: 6px;
    }
    .keyboard-osc-knob .synth-knob-value {
        font-size: 6px;
    }
    .keyboard-osc-wave {
        padding: 1px;
        gap: 1px;
    }
    .keyboard-osc-wave-btn {
        height: 18px;
        padding: 1px;
    }
    .keyboard-osc-wave-icon {
        width: 14px;
        height: 7px;
    }
    .kb-step-btn.kb-osc-toggle {
        font-size: 6px;
    }
    .synth-knob-dial-wrap {
        width: 60px;
        height: 60px;
        flex-basis: 60px;
        --tick-radius: 25px;
    }
    .keyboard-write-step-select-btns {
        height: 60px;
        flex-basis: 60px;
    }
    .keyboard-step-vfd-bezel {
        width: 60px;
        height: 60px;
        flex-basis: 60px;
    }
    .synth-knob-tick {
        font-size: 5px;
    }
    .keyboard-play-row {
        gap: 6px;
        padding: 0 4px;
        margin-bottom: 4px;
    }
    .keyboard-pitch-bend-track {
        height: 36px;
    }
    .synth-knob-dial {
        width: 36px;
        height: 36px;
    }
    .synth-knob-indicator {
        top: 4px;
        height: 10px;
        transform-origin: 50% 14px;
    }
    .synth-knob-label {
        font-size: 7px;
        height: 7px;
    }
    .synth-knob-value {
        font-size: 6px;
        height: 7px;
    }
}

/* —— Computer keyboard (Ableton home-row / Model M keycaps) —— */
.computer-keyboard-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 8px 16px;
    margin-top: 4px;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}
.computer-keyboard-board {
    --ckb-key-size: 48px;
    --ckb-gap: 6px;
    --ckb-travel: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: max-content;
    max-width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    padding: 14px 16px 16px;
    background: #050505;
    border: 1px solid #00aa00;
    border-radius: 10px;
    box-shadow:
        inset 0 0 0 1px rgba(0, 170, 0, 0.15),
        0 0 12px rgba(0, 170, 0, 0.12);
}
.keyboard-section.is-fullscreen .computer-keyboard-board {
    --ckb-key-size: 56px;
    --ckb-gap: 7px;
}
.ckb-row {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: var(--ckb-gap);
}
.ckb-row-sharps {
    padding-left: calc(var(--ckb-key-size) / 2 + var(--ckb-gap) / 2);
    margin-bottom: 2px;
}
.ckb-spacer {
    flex: 0 0 var(--ckb-key-size);
    width: var(--ckb-key-size);
    height: 1px;
    visibility: hidden;
    pointer-events: none;
}
.ckb-key.pushable {
    flex: 0 0 var(--ckb-key-size);
    width: var(--ckb-key-size);
    height: calc(var(--ckb-key-size) + var(--ckb-travel));
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 5px;
    background: linear-gradient(to bottom, #333, #111);
    cursor: pointer;
    position: relative;
    display: inline-block;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.ckb-key.pushable .front {
    box-sizing: border-box;
    width: var(--ckb-key-size);
    height: var(--ckb-key-size);
    padding: 4px 2px;
    border-radius: 5px;
    border: 1px solid #00aa00;
    background: linear-gradient(to bottom, #2a2a2a 0%, #161616 55%, #0e0e0e 100%);
    color: #00ff00;
    font-family: 'Michroma', sans-serif;
    transform: translateY(calc(-1 * var(--ckb-travel)));
    transition: transform 0.12s ease-out, background 0.12s ease-out, border-color 0.12s ease-out;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    white-space: nowrap;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 -2px 0 rgba(0, 0, 0, 0.45);
}
.ckb-key.pushable:hover .front {
    border-color: #00ff00;
    background: linear-gradient(to bottom, #303830 0%, #1a221a 55%, #101610 100%);
}
.ckb-key.pushable:active .front,
.ckb-key.pushable.is-down .front {
    transform: translateY(-1px);
    background: linear-gradient(to bottom, #004400 0%, #002200 100%);
    border-color: #00ff00;
    box-shadow: inset 0 0 10px rgba(0, 255, 0, 0.3);
}
.ckb-letter {
    font-size: 11px;
    line-height: 1;
    color: #00ffff;
}
.ckb-note {
    font-size: 7px;
    line-height: 1;
    color: #00aa00;
}
.ckb-key.is-down .ckb-note,
.ckb-key:active .ckb-note {
    color: #ccffcc;
}
.ckb-key.ckb-out-of-scale {
    cursor: default;
    opacity: 0.35;
}
.ckb-key.ckb-out-of-scale:hover .front {
    border-color: #00aa00;
    background: linear-gradient(to bottom, #2a2a2a 0%, #161616 55%, #0e0e0e 100%);
}
.ckb-key.ckb-out-of-scale:active .front,
.ckb-key.ckb-out-of-scale.is-down .front {
    transform: translateY(calc(-1 * var(--ckb-travel)));
    background: linear-gradient(to bottom, #2a2a2a 0%, #161616 55%, #0e0e0e 100%);
    border-color: #00aa00;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 -2px 0 rgba(0, 0, 0, 0.45);
}
.ckb-key.ckb-octave.pushable {
    flex: 0 0 calc(var(--ckb-key-size) * 1.35);
    width: calc(var(--ckb-key-size) * 1.35);
}
.ckb-key.ckb-octave.pushable .front {
    width: 100%;
    gap: 1px;
    padding: 3px 2px;
}
.ckb-key.ckb-octave .ckb-letter {
    font-size: 9px;
    color: #66ffff;
    opacity: 0.85;
}
.ckb-key.ckb-octave .ckb-oct-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 2px;
    line-height: 1;
}
.ckb-key.ckb-octave .ckb-oct-label {
    font-size: 9px;
    line-height: 1;
    color: #00ff00;
    letter-spacing: 0.04em;
}
.ckb-key.ckb-octave .ckb-oct-dir {
    display: block;
    width: 0;
    height: 0;
    flex: 0 0 auto;
    border-style: solid;
}
.ckb-key.ckb-octave .ckb-oct-dir-up {
    border-width: 0 5px 8px 5px;
    border-color: transparent transparent #00ff00 transparent;
}
.ckb-key.ckb-octave .ckb-oct-dir-down {
    border-width: 8px 5px 0 5px;
    border-color: #00ff00 transparent transparent transparent;
}
.ckb-key.ckb-octave.is-down .ckb-oct-dir-up,
.ckb-key.ckb-octave:active .ckb-oct-dir-up {
    border-bottom-color: #ccffcc;
}
.ckb-key.ckb-octave.is-down .ckb-oct-dir-down,
.ckb-key.ckb-octave:active .ckb-oct-dir-down {
    border-top-color: #ccffcc;
}
.ckb-key.ckb-octave.is-down .ckb-oct-label,
.ckb-key.ckb-octave:active .ckb-oct-label {
    color: #ccffcc;
}
.ckb-key.ckb-space.pushable {
    flex: 1 1 auto;
    width: auto;
    min-width: calc(var(--ckb-key-size) * 4 + var(--ckb-gap) * 3);
    max-width: calc(var(--ckb-key-size) * 6 + var(--ckb-gap) * 5);
}
.ckb-key.ckb-space.pushable .front {
    width: 100%;
    height: var(--ckb-key-size);
}
.ckb-transport-icon {
    display: block;
    pointer-events: none;
}
#ckbSpace.start .ckb-transport-icon,
.ckb-space.start .ckb-transport-icon {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 9px 0 9px 16px;
    border-color: transparent transparent transparent #00ff00;
    margin-left: 3px;
    background: none;
    border-radius: 0;
}
#ckbSpace.stop .ckb-transport-icon,
.ckb-space.stop .ckb-transport-icon {
    width: 16px;
    height: 16px;
    border-style: none;
    border-width: 0;
    border-color: transparent;
    background: #ff0000;
    border-radius: 1px;
    margin-left: 0;
}
.ckb-row-mods {
    width: 100%;
    justify-content: flex-start;
    margin-top: 4px;
}
.ckb-row-mods .ckb-space {
    margin-left: var(--ckb-gap);
}

@media (max-width: 768px) {
    .computer-keyboard-board {
        --ckb-key-size: 40px;
        --ckb-gap: 4px;
        --ckb-travel: 3px;
    }
    .ckb-letter {
        font-size: 9px;
    }
    .ckb-note {
        font-size: 6px;
    }
    .ckb-space.start .ckb-transport-icon {
        border-width: 7px 0 7px 12px;
    }
    .ckb-space.stop .ckb-transport-icon {
        width: 12px;
        height: 12px;
    }
}
