/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Login Screen */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.login-screen.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    z-index: -1 !important;
    pointer-events: none !important;
}

.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.login-input {
    background-color: #ffffff;
    border: none;
    border-radius: 5px;
    padding: 15px 20px;
    font-size: 1.2em;
    color: #000000;
    width: 300px;
    outline: none;
}

.login-input:focus {
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.login-submit-btn {
    background-color: #ffffff;
    border: none;
    border-radius: 5px;
    padding: 15px 40px;
    font-size: 1.2em;
    font-weight: bold;
    color: #000000;
    cursor: pointer;
    transition: all 0.2s ease;
}

.login-submit-btn:hover {
    background-color: #e0e0e0;
    transform: scale(1.05);
}

.login-submit-btn:active {
    transform: scale(0.95);
}

/* App Hidden State */
.app-hidden {
    display: none;
}

.app-visible {
    display: block;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    overflow-x: hidden;
    position: relative;
    /* Ensure app is visible when app-visible class is applied */
    background: transparent; /* Ensure no black background */
    /* Ensure app container doesn't create stacking context issues */
    z-index: auto;
    isolation: auto;
}

#app.app-visible {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Fixed Top Controls Container */
.fixed-top-controls {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1240px; /* 1200px + 40px padding */
    z-index: 1000;
    background: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
    /* Ensure fixed controls don't extend beyond their content */
    height: auto;
    max-height: none;
    overflow: visible;
    /* Ensure it doesn't create a stacking context that hides content below */
    isolation: isolate;
}

/* VR Toggle Button */
.vr-toggle-btn {
    background-color: #4a90e2;
    border: none;
    border-radius: 5px;
    padding: 10px 20px;
    font-size: 0.9em;
    font-weight: bold;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 15px;
}

.vr-toggle-btn:hover {
    background-color: #357abd;
    transform: scale(1.05);
}

.vr-toggle-btn:active {
    transform: scale(0.95);
}

.vr-toggle-btn.vr-active {
    background-color: #e74c3c;
}

.vr-toggle-btn.vr-active:hover {
    background-color: #c0392b;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    gap: 20px;
}

.app-header h1 {
    flex: 1;
}

.app-header .status-indicator {
    flex-shrink: 0;
}

.app-header h1 {
    font-size: 2.5em;
    font-weight: 300;
    letter-spacing: 2px;
}

.tempo-display {
    font-size: 2em;
    font-weight: bold;
    color: #4CAF50;
}

.status-indicator {
    font-weight: 500;
    font-size: 0.9em;
    padding: 5px 15px;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.status-indicator.not_initialized {
    color: #FF6B6B;
}

.status-indicator.ready {
    color: #4CAF50;
    background: rgba(76, 175, 80, 0.2);
}

.status-indicator.initializing {
    color: #FFA726;
    background: rgba(255, 167, 38, 0.2);
}

.status-indicator.error {
    color: #FF6B6B;
    background: rgba(255, 107, 107, 0.2);
}

.init-audio-btn {
    background: rgba(76, 175, 80, 0.8);
    border: none;
    border-radius: 5px;
    padding: 10px 20px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.init-audio-btn:hover {
    background: rgba(76, 175, 80, 1);
}

.init-audio-btn:disabled {
    background: rgba(128, 128, 128, 0.5);
    cursor: not-allowed;
}

/* Accordion Panels */
.accordion-panels-container {
    position: relative;
    margin-bottom: 5px;
}

/* Fixed top controls spacing */
.fixed-top-controls .accordion-panels-container {
    margin-bottom: 0;
}

.fixed-top-controls .pane-toggle-controls {
    margin-bottom: 0;
    margin-top: 0;
}

/* Main content area - add padding for fixed header */
main.app-main {
    padding-top: 200px; /* Will be adjusted dynamically via JavaScript */
    position: relative;
    z-index: 1; /* Lower than fixed controls (1000) since fixed is positioned separately */
    min-height: calc(100vh - 200px);
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: transparent; /* Ensure no black background */
    /* Ensure content is not positioned off-screen */
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
}

.accordion-panel {
    position: relative;
    margin-bottom: 3px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Reduce spacing for accordion panels inside fixed-top-controls */
.fixed-top-controls .accordion-panel {
    margin-bottom: 2px;
}

.accordion-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    min-height: 35px;
    max-height: 35px;
    cursor: pointer;
    /* Ensure header doesn't add extra height */
    box-sizing: border-box;
}

.accordion-panel-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.accordion-panel-controls-expanded {
    display: flex;
    align-items: center;
    gap: 5px;
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 5;
}

.accordion-panel-name {
    font-weight: 500;
    font-size: 0.95em;
    color: #fff;
    flex: 1;
}

.accordion-panel-content {
    padding: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease, display 0s linear 0.3s;
    max-height: 5000px;
    opacity: 1;
    display: block;
}

.accordion-panel.collapsed .accordion-panel-content {
    /* Completely remove from layout flow using display: none */
    display: none !important;
    /* Keep these as fallback in case display: none doesn't work */
    max-height: 0 !important;
    padding: 0 !important;
    opacity: 0;
    overflow: hidden !important;
    margin: 0 !important;
    border: none !important;
    /* Disable all transitions when collapsed to prevent height calculation issues */
    transition: none !important;
    /* Ensure content doesn't contribute to layout */
    visibility: hidden !important;
    /* Force height to 0 to prevent any content from contributing */
    height: 0 !important;
    min-height: 0 !important;
    /* Ensure all children also don't contribute */
    pointer-events: none !important;
}

.accordion-panel.collapsed {
    min-height: 35px;
    max-height: 35px;
    overflow: hidden;
    /* Ensure no extra spacing contributes to height */
    padding: 0;
    margin-top: 0;
}

/* Ensure collapsed panels inside fixed-top-controls have no extra spacing */
.fixed-top-controls .accordion-panel.collapsed {
    margin-bottom: 2px;
}

.accordion-toggle-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 5px;
    padding: 4px 8px;
    color: #fff;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 30px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.accordion-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.accordion-panel.expanded {
    position: relative;
}

.accordion-panel.expanded .accordion-panel-header .accordion-panel-controls {
    display: none;
}

.accordion-panel.collapsed .accordion-panel-content .accordion-panel-controls-expanded {
    display: none;
}

.accordion-panel.expanded .accordion-panel-content .accordion-panel-controls-expanded {
    display: flex;
}

.accordion-toggle-all-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 5px;
    padding: 4px 8px;
    color: #fff;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 30px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.accordion-toggle-all-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Ensure header inside accordion has proper spacing */
.accordion-panel-content .app-header {
    margin-bottom: 0;
    padding: 20px;
}

/* Ensure primary tempo controls have proper spacing */
.accordion-panel-content .primary-tempo-controls-container {
    margin-bottom: 0;
}

/* Ensure source tabs have proper spacing */
.accordion-panel-content .source-tabs {
    margin-bottom: 0;
}

/* Tempo Controls */
.tempo-controls {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.manual-tempo {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.manual-tempo label {
    font-weight: 500;
}

#tempo-input {
    padding: 10px;
    border: none;
    border-radius: 5px;
    font-size: 1.2em;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    width: 120px;
}

.tap-tempo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.tap-button {
    width: 80px;
    height: 80px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(45deg, #FF6B6B, #FF8E8E);
    color: white;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.tap-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.tap-button:active {
    transform: scale(0.95);
}

.tap-button.active {
    background: linear-gradient(45deg, #4CAF50, #66BB6A);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.tap-status {
    font-size: 0.9em;
    color: #ccc;
    text-align: center;
}

/* Primary Tempo Controls Container */
.primary-tempo-controls-container {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    min-width: 0;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.playback-control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.primary-tempo-controls-container .playback-status {
    font-size: 0.9em;
    color: #ccc;
    text-align: center;
}

.primary-tempo-controls-container .play-pause-btn {
    flex-shrink: 0;
}

.primary-tempo-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
    min-width: 0;
}

.action-buttons-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex-shrink: 0;
    min-width: 0;
}

.arm-all-btn,
.disarm-all-btn,
.expand-all-btn,
.collapse-all-btn {
    border: none;
    border-radius: 5px;
    padding: 8px 16px;
    color: white;
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.arm-all-btn {
    background: rgba(76, 175, 80, 0.8);
}

.arm-all-btn:hover {
    background: rgba(76, 175, 80, 1);
}

.disarm-all-btn {
    background: rgba(244, 67, 54, 0.8);
}

.disarm-all-btn:hover {
    background: rgba(244, 67, 54, 1);
}

.expand-all-btn {
    background: rgba(33, 150, 243, 0.8);
}

.expand-all-btn:hover {
    background: rgba(33, 150, 243, 1);
}

.collapse-all-btn {
    background: rgba(156, 39, 176, 0.8);
}

.collapse-all-btn:hover {
    background: rgba(156, 39, 176, 1);
}

.primary-tempo-controls .manual-tempo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.primary-tempo-controls .manual-tempo label {
    font-size: 0.9em;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.primary-tempo-controls .manual-tempo input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 6px 8px;
    color: white;
    width: 70px;
    font-size: 0.9em;
}

.primary-tempo-controls .manual-tempo input:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.3);
}

.primary-tempo-controls .tap-tempo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.primary-tempo-controls .tap-button {
    background: rgba(76, 175, 80, 0.8);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: white;
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.primary-tempo-controls .tap-button:hover {
    background: rgba(76, 175, 80, 1);
    transform: scale(1.05);
}

.primary-tempo-controls .tap-button.active {
    background: rgba(255, 193, 7, 0.9);
    animation: pulse 0.5s ease-in-out;
}

.primary-tempo-controls .tap-status {
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
}

.primary-tempo-controls .tempo-display {
    font-size: 1em;
    font-weight: bold;
    color: #4CAF50;
    min-width: 80px;
    text-align: center;
}

/* Break Toggle */
.break-toggle-wrapper {
    display: flex;
    align-items: center;
    margin-right: 10px;
}

.break-toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.9);
    user-select: none;
}

.break-toggle {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

/* Playback controls */

.play-pause-btn {
    width: 80px;
    height: 40px;
    border: none;
    border-radius: 5px;
    background: rgba(76, 175, 80, 0.8);
    color: white;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.play-pause-btn:hover:not(:disabled) {
    background: rgba(76, 175, 80, 1);
}

.play-pause-btn:disabled {
    background: rgba(128, 128, 128, 0.5);
    cursor: not-allowed;
}

.play-pause-btn.playing {
    background: rgba(244, 67, 54, 0.8);
}

.play-pause-btn.playing:hover:not(:disabled) {
    background: rgba(244, 67, 54, 1);
}

.playback-status {
    font-size: 0.9em;
    color: #ccc;
    text-align: center;
}

/* Row-level Tempo Controls */
.tempo-sequencer-scope .row-tempo-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: none !important;
}

.tempo-sequencer-scope .row-tempo-controls .manual-tempo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tempo-sequencer-scope .row-tempo-controls .manual-tempo label {
    font-size: 0.9em;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.tempo-sequencer-scope .row-tempo-controls .manual-tempo input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 6px 8px;
    color: white;
    width: 70px;
    font-size: 0.9em;
}

.tempo-sequencer-scope .row-tempo-controls .manual-tempo input:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.3);
}

.tempo-sequencer-scope .row-tempo-controls .tap-tempo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.tempo-sequencer-scope .row-tempo-controls .tap-button {
    background: rgba(76, 175, 80, 0.8);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: white;
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tempo-sequencer-scope .row-tempo-controls .tap-button:hover {
    background: rgba(76, 175, 80, 1);
    transform: scale(1.05);
}

.tempo-sequencer-scope .row-tempo-controls .tap-button.active {
    background: rgba(255, 193, 7, 0.9);
    animation: pulse 0.5s ease-in-out;
}

.tempo-sequencer-scope .row-tempo-controls .tap-status {
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
}

.tempo-sequencer-scope .row-tempo-controls .tempo-display {
    font-size: 1em;
    font-weight: bold;
    color: #4CAF50;
    min-width: 80px;
    text-align: center;
}

/* Tempo Sequencer Scope - Isolated container for event rows */
.tempo-sequencer-scope {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Universal border removal for ALL elements within tempo-sequencer-scope */
.tempo-sequencer-scope * {
    border: none !important;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    border-bottom: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Re-apply borders only where needed (inputs, buttons, etc.) */
.tempo-sequencer-scope input[type="text"],
.tempo-sequencer-scope input[type="number"],
.tempo-sequencer-scope select,
.tempo-sequencer-scope button {
    border: initial;
    outline: initial;
}

/* But ensure duplication-controls borders are removed */
.tempo-sequencer-scope .duplication-controls {
    border: none !important;
}

/* Event Rows */
.tempo-sequencer-scope .event-rows {
    margin-bottom: 30px;
}

.tempo-sequencer-scope .event-row {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
    backdrop-filter: blur(10px);
    border: none !important;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    border-bottom: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.tempo-sequencer-scope .row-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.tempo-sequencer-scope .row-title {
    font-size: 1.2em;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tempo-sequencer-scope .row-button-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.tempo-sequencer-scope .row-tempo-section {
    display: flex;
    justify-content: center;
    margin: 5px 0;
}

.tempo-sequencer-scope .row-grouped-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* Legacy support - keep for compatibility */
.tempo-sequencer-scope .row-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    min-width: 300px;
    justify-content: flex-end;
}

/* Time Signature and Row Note */
.tempo-sequencer-scope .row-music-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tempo-sequencer-scope .time-signature {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tempo-sequencer-scope .time-signature label,
.tempo-sequencer-scope .row-note label {
    font-size: 0.9em;
    color: #ccc;
}

.tempo-sequencer-scope .time-signature .slash {
    opacity: 0.7;
}

.tempo-sequencer-scope .timesig-x {
    width: 60px;
}

.tempo-sequencer-scope .timesig-x,
.tempo-sequencer-scope .timesig-y,
.tempo-sequencer-scope .row-note-select,
.tempo-sequencer-scope .offset-note-select,
.tempo-sequencer-scope .source-select,
.tempo-sequencer-scope .source-type-select,
.tempo-sequencer-scope .form-select,
.tempo-sequencer-scope .event-row select,
.tempo-sequencer-scope .child-event-row select {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    border-radius: 3px;
    border: none;
    padding: 4px 6px;
}

.offset-nudge {
    display: flex;
    align-items: center;
    gap: 6px;
}

.offset-left,
.offset-right {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 3px;
    padding: 2px 6px;
    cursor: pointer;
}

/* Ensure offset-input matches freq-input size */
.freq-input,
.offset-input {
    width: 120px;
}

.octave-controls {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.octave-arrow-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 3px;
    padding: 2px 4px;
    cursor: pointer;
    font-size: 0.75em;
    line-height: 1;
    min-width: 20px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
}

.octave-arrow-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.octave-arrow-btn:active:not(:disabled) {
    background: rgba(255, 255, 255, 0.4);
}

.octave-arrow-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tempo-scale {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: flex-start;
    min-width: 60px;
    position: relative;
}

.tempo-scale label {
    font-size: 0.9em;
    color: #ccc;
}

.tempo-scale input {
    width: 60px;
    padding: 5px;
    border: none;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
}

.percentage-sign {
    font-size: 0.8em;
    color: #ccc;
    margin-left: 2px;
}

/* Frequency offset controls */
.frequency-offset-controls {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: flex-start;
    min-width: 60px;
}

.frequency-offset-enable-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    color: #ccc;
    cursor: pointer;
}

.frequency-offset-enable-label input[type="checkbox"] {
    cursor: pointer;
}

.frequency-offset-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-start;
    position: relative;
    width: 100%;
}

.octave-controls-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.octave-label {
    font-size: 0.85em;
    color: #ccc;
}

.octave-arrows {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.octave-arrow-up,
.octave-arrow-down {
    width: 24px;
    height: 20px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    font-size: 0.8em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.octave-arrow-up:hover,
.octave-arrow-down:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.octave-arrow-up:active,
.octave-arrow-down:active {
    background: rgba(255, 255, 255, 0.3);
}

.frequency-offset-cascade {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.frequency-offset-cascade:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.frequency-offset-cascade:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.frequency-offset-cascade.active {
    background: rgba(76, 175, 80, 0.3);
    border-color: rgba(76, 175, 80, 0.6);
    color: #4CAF50;
}

.frequency-offset-input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: flex-start;
    min-width: 60px;
    flex-shrink: 0;
}

.frequency-offset-input-group label {
    font-size: 0.9em;
    color: #ccc;
}

.frequency-offset-input {
    width: 60px;
    padding: 5px;
    border: none;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
}

.frequency-offset-input:disabled {
    background: rgba(255, 255, 255, 0.3);
    color: #999;
    cursor: not-allowed;
}

/* Responsive: move frequency offset controls below tempo scale when space is constrained */
@media (max-width: 1200px) {
    .row-grouped-controls,
    .child-row-grouped-controls {
        flex-wrap: wrap;
    }
    
    .frequency-offset-controls {
        width: 100%;
        margin-top: 10px;
    }
}

.tempo-sequencer-scope .events-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.tempo-sequencer-scope .event-item {
    background: transparent !important;
    border-radius: 0 !important;
    padding: 15px;
    max-width: 100%;
    width: 100%;
    border: none !important;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    border-bottom: none !important;
    outline: none !important;
    box-shadow: none !important;
    transition: all 0.2s ease;
    display: block;
}

.tempo-sequencer-scope .event-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    position: relative;
    min-height: 50px;
}

.tempo-sequencer-scope .event-item:hover {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.tempo-sequencer-scope .event-item.active {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: rgba(76, 175, 80, 0.2);
}

.tempo-sequencer-scope .event-item.triggering {
    /* Pulse effect moved to arm button only */
}

.tempo-sequencer-scope .arm-event-btn {
    background: rgba(244, 67, 54, 0.8);
    border: none;
    border-radius: 5px;
    padding: 8px 12px;
    color: white;
    font-size: 0.8em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
    flex-shrink: 0;
}

.tempo-sequencer-scope .arm-event-btn:hover {
    background: rgba(244, 67, 54, 1);
}

.tempo-sequencer-scope .arm-event-btn.armed {
    background: rgba(76, 175, 80, 0.8);
}

.tempo-sequencer-scope .arm-event-btn.armed:hover {
    background: rgba(76, 175, 80, 1);
}

.tempo-sequencer-scope .arm-event-btn.triggering {
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.8);
    background: rgba(255, 107, 107, 0.9);
}

/* Event Arm Controls */
.tempo-sequencer-scope .event-arm-controls {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 100px;
    flex-shrink: 0;
}

.tempo-sequencer-scope .disarm-child-toggle-btn {
    background: rgba(255, 152, 0, 0.8);
    border: none;
    border-radius: 5px;
    padding: 6px 10px;
    color: white;
    font-size: 0.7em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.tempo-sequencer-scope .disarm-child-toggle-btn:hover {
    background: rgba(255, 152, 0, 1);
}

.tempo-sequencer-scope .disarm-child-toggle-btn.active {
    background: rgba(76, 175, 80, 0.8);
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
}

.tempo-sequencer-scope .disarm-child-toggle-btn.active:hover {
    background: rgba(76, 175, 80, 1);
}

.tempo-sequencer-scope .arm-all-children-btn {
    background: rgba(33, 150, 243, 0.8);
    border: none;
    border-radius: 5px;
    padding: 6px 10px;
    color: white;
    font-size: 0.7em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.tempo-sequencer-scope .arm-all-children-btn:hover {
    background: rgba(33, 150, 243, 1);
}

.tempo-sequencer-scope .event-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.tempo-sequencer-scope .sample-select {
    width: 100%;
    max-width: 100%;
    padding: 8px;
    border: none;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tempo-sequencer-scope .offset-control {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.tempo-sequencer-scope .offset-control label {
    font-size: 0.9em;
    color: #ccc;
}

.tempo-sequencer-scope .offset-control input {
    width: 100%;
    max-width: 100%;
    padding: 5px;
    border: none;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
}

.tempo-sequencer-scope .add-event-btn {
    background: rgba(76, 175, 80, 0.8);
    border: none;
    border-radius: 5px;
    padding: 10px 15px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tempo-sequencer-scope .add-event-btn:hover {
    background: rgba(76, 175, 80, 1);
}

.tempo-sequencer-scope .remove-row-btn {
    background: rgba(244, 67, 54, 0.8);
    border: none;
    border-radius: 5px;
    padding: 8px 12px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tempo-sequencer-scope .remove-row-btn:hover {
    background: rgba(244, 67, 54, 1);
}

.tempo-sequencer-scope .remove-event-btn {
    background: rgba(244, 67, 54, 0.8);
    border: none;
    border-radius: 5px;
    padding: 6px 12px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    position: absolute;
    bottom: 0;
    right: 0;
    font-size: 0.85em;
    margin-left: auto;
}

.tempo-sequencer-scope .remove-event-btn:hover {
    background: rgba(244, 67, 54, 1);
}

/* Sample Browser */
.sample-browser {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 20px;
    backdrop-filter: blur(10px);
}


.sample-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.sample-item {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sample-item:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.2);
}

.sample-item.selected {
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.2);
}

.sample-item-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
}

.sample-name {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.sample-name-full {
    white-space: normal;
    text-overflow: clip;
    word-wrap: break-word;
}

/* Sample expanded controls */
.sample-item-expanded {
    display: none;
    width: 100%;
    margin-top: 10px;
}

.sample-item.selected .sample-item-expanded {
    display: block;
}

.sample-controls-row {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
}

.analyze-sample-btn {
    background: rgba(33, 150, 243, 0.8);
    border: none;
    border-radius: 5px;
    padding: 6px 10px;
    color: white;
    font-size: 0.7em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: auto;
    white-space: nowrap;
}

.analyze-sample-btn:hover {
    background: rgba(33, 150, 243, 1);
}

.self-actualize-btn {
    background: rgba(156, 39, 176, 0.8);
    border: none;
    border-radius: 5px;
    padding: 6px 10px;
    color: white;
    font-size: 0.7em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: auto;
    white-space: nowrap;
}

.self-actualize-btn:hover {
    background: rgba(156, 39, 176, 1);
}

.refresh-btn {
    background: rgba(33, 150, 243, 0.8);
    border: none;
    border-radius: 5px;
    padding: 10px 20px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    background: rgba(33, 150, 243, 1);
}

/* Add Row Button */
.tempo-sequencer-scope .add-row-btn {
    width: 100%;
    background: rgba(156, 39, 176, 0.8);
    border: none;
    border-radius: 10px;
    padding: 20px;
    color: white;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 20px;
}

.tempo-sequencer-scope .add-row-btn:hover {
    background: rgba(156, 39, 176, 1);
}

/* Split button containers */
.tempo-sequencer-scope .split-add-row-container,
.tempo-sequencer-scope .split-add-child-row-container {
    display: flex;
    gap: 0;
    width: 100%;
}

.tempo-sequencer-scope .split-btn-left,
.tempo-sequencer-scope .split-btn-middle,
.tempo-sequencer-scope .split-btn-right {
    flex: 1;
    border-radius: 0;
}

.tempo-sequencer-scope .split-btn-left {
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
    border-right: 1px solid rgba(255, 255, 255, 0.3);
}

.tempo-sequencer-scope .split-btn-middle {
    border-right: 1px solid rgba(255, 255, 255, 0.3);
}

.tempo-sequencer-scope .split-btn-right {
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
    background: rgba(255, 152, 0, 0.8);
}

.tempo-sequencer-scope .split-btn-right:hover {
    background: rgba(255, 152, 0, 1);
}

/* Snap buttons */
.tempo-sequencer-scope .snap-row-btn,
.tempo-sequencer-scope .snap-row-with-children-btn,
.tempo-sequencer-scope .snap-child-row-btn,
.tempo-sequencer-scope .snap-child-row-with-children-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 3px;
    padding: 2px 6px;
    cursor: pointer;
    margin-left: 4px;
    font-size: 0.9em;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tempo-sequencer-scope .snap-row-btn:hover,
.tempo-sequencer-scope .snap-row-with-children-btn:hover,
.tempo-sequencer-scope .snap-child-row-btn:hover,
.tempo-sequencer-scope .snap-child-row-with-children-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

/* MIDI In snap button */
.midi-in-snap-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 3px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 0.9em;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.midi-in-snap-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Export buttons */
.tempo-sequencer-scope .export-row-btn,
.tempo-sequencer-scope .export-child-row-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 3px;
    padding: 2px 6px;
    cursor: pointer;
    margin-left: 4px;
    font-size: 0.9em;
}

.tempo-sequencer-scope .export-row-btn:hover,
.tempo-sequencer-scope .export-child-row-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Missing source highlighting */
.tempo-sequencer-scope .missing-source {
    border: 2px solid #ff4444 !important;
    background: rgba(255, 68, 68, 0.1) !important;
}

.tempo-sequencer-scope .missing-source-input {
    border: 2px solid #ff4444 !important;
    background: rgba(255, 68, 68, 0.2) !important;
}

/* Sequence export modal */
.sequence-export-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sequence-export-modal {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    border-radius: 10px;
    padding: 30px;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.sequence-export-modal .modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
}

.sequence-export-modal .export-confirm-btn,
.sequence-export-modal .export-cancel-btn {
    background: rgba(76, 175, 80, 0.8);
    border: none;
    border-radius: 5px;
    padding: 10px 20px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sequence-export-modal .export-confirm-btn:hover {
    background: rgba(76, 175, 80, 1);
}

.sequence-export-modal .export-cancel-btn {
    background: rgba(158, 158, 158, 0.8);
}

.sequence-export-modal .export-cancel-btn:hover {
    background: rgba(158, 158, 158, 1);
}

/* Child Tempo Panel Styles */
.tempo-sequencer-scope .child-tempo-toggle-btn {
    position: relative;
    background: rgba(156, 39, 176, 0.8);
    border: none;
    border-radius: 5px;
    padding: 8px 12px;
    color: white;
    font-size: 0.8em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
    flex-shrink: 0;
}

.tempo-sequencer-scope .child-tempo-toggle-btn.active {
    background: rgba(156, 39, 176, 1);
    box-shadow: 0 0 10px rgba(156, 39, 176, 0.5);
}

.tempo-sequencer-scope .child-tempo-asterisk {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 0.9em;
    font-weight: bold;
    color: #ffeb3b;
    display: none;
    line-height: 1;
}

.tempo-sequencer-scope .child-tempo-panel {
    margin-top: 10px;
    margin-left: 0 !important;
    padding-left: 0 !important;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    background: transparent !important;
    border-radius: 0 !important;
    padding: 15px;
    position: relative;
    border: none !important;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    border-bottom: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Fix left padding when child-tempo-panel is direct child of event-item or child-event-item */
.tempo-sequencer-scope .event-item > .child-tempo-panel,
.tempo-sequencer-scope .child-event-item > .child-tempo-panel {
    margin-left: -15px !important;
    margin-right: -15px !important;
    width: calc(100% + 30px) !important;
    border: none !important;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    border-bottom: none !important;
}

.tempo-sequencer-scope .child-tempo-header h4 {
    font-size: 1.2em;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.tempo-sequencer-scope .child-rows-container {
    margin-bottom: 15px;
}

.tempo-sequencer-scope .child-event-row {
    background: transparent !important;
    border-radius: 0 !important;
    padding: 15px;
    padding-left: 0 !important;
    margin-bottom: 10px;
    margin-left: 0 !important;
    position: relative;
    border: none !important;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    border-bottom: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.tempo-sequencer-scope .child-row-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}

.tempo-sequencer-scope .child-row-title {
    font-size: 1em;
    font-weight: 500;
    color: #E1BEE7;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tempo-sequencer-scope .child-row-button-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.tempo-sequencer-scope .child-row-grouped-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* Inline name edit */
.tempo-sequencer-scope .edit-row-name,
.tempo-sequencer-scope .edit-child-row-name {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 3px;
    padding: 2px 6px;
    cursor: pointer;
}

.tempo-sequencer-scope .row-name-input,
.tempo-sequencer-scope .child-row-name-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    color: #fff;
    padding: 4px 6px;
    min-width: 140px;
}

/* Row color picker */
.tempo-sequencer-scope .row-color-label {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tempo-sequencer-scope .row-color-label:hover {
    background: rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.5);
}

.tempo-sequencer-scope .row-color-text {
    font-size: 0.85em;
    color: #fff;
    white-space: nowrap;
}

.tempo-sequencer-scope .row-color-picker {
    width: 28px;
    height: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    cursor: pointer;
    background: transparent;
    padding: 0;
    margin: 0;
}

.tempo-sequencer-scope .row-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.tempo-sequencer-scope .row-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.tempo-sequencer-scope .child-row-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Child event items inherit from parent event items */
.tempo-sequencer-scope .child-event-item {
    margin-bottom: 8px;
    margin-left: 0 !important;
    background: transparent !important;
    border-radius: 0 !important;
    padding: 15px;
    padding-left: 0 !important;
    position: relative;
    border: none !important;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    border-bottom: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Nested selectors to ensure rules apply at any nesting depth */
.tempo-sequencer-scope .child-tempo-panel .child-tempo-panel,
.tempo-sequencer-scope .child-tempo-panel .child-event-row,
.tempo-sequencer-scope .child-tempo-panel .child-event-item,
.tempo-sequencer-scope .child-event-row .child-tempo-panel,
.tempo-sequencer-scope .child-event-row .child-event-row,
.tempo-sequencer-scope .child-event-row .child-event-item,
.tempo-sequencer-scope .child-event-item .child-tempo-panel,
.tempo-sequencer-scope .child-event-item .child-event-row,
.tempo-sequencer-scope .child-event-item .child-event-item,
.tempo-sequencer-scope .event-item .child-tempo-panel,
.tempo-sequencer-scope .event-item .child-event-row,
.tempo-sequencer-scope .event-item .child-event-item {
    margin-left: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    background: transparent !important;
    border-radius: 0 !important;
    border: none !important;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
    outline: none !important;
}

.tempo-sequencer-scope .child-event-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    position: relative;
    min-height: 50px;
}

.tempo-sequencer-scope .child-tempo-controls {
    display: flex;
    justify-content: center;
    margin-top: 10px;
}

.tempo-sequencer-scope .add-child-row-btn {
    background: rgba(156, 39, 176, 0.8);
    border: none;
    border-radius: 5px;
    padding: 8px 15px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9em;
}

.tempo-sequencer-scope .add-child-row-btn:hover {
    background: rgba(156, 39, 176, 1);
}

.tempo-sequencer-scope .remove-child-row-btn {
    background: rgba(244, 67, 54, 0.8);
    border: none;
    border-radius: 5px;
    padding: 6px 10px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8em;
}

.tempo-sequencer-scope .remove-child-row-btn:hover {
    background: rgba(244, 67, 54, 1);
}

/* Sound Generator Panel */
.sound-generator-panel {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 20px;
    backdrop-filter: blur(10px);
    margin-bottom: 30px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    gap: 15px;
}

.sound-generator-panel h3,
.sample-browser h3 {
    margin: 0;
    color: #4CAF50;
}

.generator-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.generator-item {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.generator-item:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.2);
}

.generator-item.selected {
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.2);
    position: relative;
}

.generator-item-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    position: relative;
    z-index: 2;
}

.generator-name {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.generator-name-full {
    white-space: normal;
    text-overflow: clip;
    word-wrap: break-word;
}

.generator-item-buttons {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.edit-generator-btn,
.delete-generator-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    padding: 5px 10px;
    color: white;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s ease;
}

.edit-generator-btn:hover {
    background: rgba(76, 175, 80, 0.6);
    border-color: #4CAF50;
}

.delete-generator-btn:hover {
    background: rgba(244, 67, 54, 0.6);
    border-color: #f44336;
}

/* Generator expanded controls */
.generator-item-expanded {
    display: none;
    width: 100%;
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 10px;
    z-index: 10;
    background: rgba(76, 175, 80, 0.25);
    border: 2px solid #4CAF50;
    border-radius: 5px;
    padding: 10px;
    box-sizing: border-box;
}

.generator-item.selected .generator-item-expanded {
    display: block;
}

.generator-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
}

.disarm-all-container {
    flex: 0 0 auto;
}

.dupe-generator-container {
    flex: 0 0 auto;
}

.disarm-all-toggle-btn,
.disarm-channel-toggle-btn {
    background: rgba(255, 152, 0, 0.8);
    border: none;
    border-radius: 5px;
    padding: 6px 10px;
    color: white;
    font-size: 0.7em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: auto;
    white-space: nowrap;
}

.disarm-all-toggle-btn:hover,
.disarm-channel-toggle-btn:hover {
    background: rgba(255, 152, 0, 1);
}

.dupe-generator-btn {
    background: #4CAF50;
    border: none;
    border-radius: 5px;
    padding: 6px 10px;
    color: white;
    font-size: 0.7em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: auto;
    white-space: nowrap;
}

.dupe-generator-btn:hover {
    background: rgba(76, 175, 80, 0.9);
}

.disarm-all-toggle-btn.active,
.disarm-channel-toggle-btn.active {
    background: rgba(76, 175, 80, 0.8);
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
}

.disarm-all-toggle-btn.active:hover,
.disarm-channel-toggle-btn.active:hover {
    background: rgba(76, 175, 80, 1);
}

.channel-toggles-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: flex-end;
    flex: 0 0 auto;
}

.create-generator-btn {
    background: rgba(156, 39, 176, 0.8);
    border: none;
    border-radius: 5px;
    padding: 10px 20px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.create-generator-btn:hover {
    background: rgba(156, 39, 176, 1);
}

.choose-btn {
    background: rgba(156, 39, 176, 0.8);
    border: none;
    border-radius: 5px;
    padding: 10px 20px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.choose-btn:hover {
    background: rgba(156, 39, 176, 1);
}

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

/* Sound Generator Modal */
.sound-generator-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.sound-generator-modal-overlay[style*="display: flex"] {
    display: flex !important;
}

.sound-generator-modal {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    border-radius: 10px;
    padding: 30px;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    color: #4CAF50;
}

.close-modal-btn {
    background: none;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
}

.close-modal-btn:hover {
    color: #FF6B6B;
}

.modal-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Align Shred toggle and Import/Export actions on one line */
.sound-generator-modal .shred-and-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.sound-generator-modal .shred-and-actions .inline-actions {
    display: inline-flex;
    gap: 8px;
}

.form-group label {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.form-input,
.form-select {
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1em;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.3);
}

.form-select option {
    background: #ffffff;
    color: #333;
}

.form-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#envelope-offset-mode-group {
    margin-top: 15px;
    margin-bottom: 15px;
}

.envelope-offset-mode-radio-group {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.envelope-offset-mode-radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #ffffff;
    font-size: 14px;
}

.envelope-offset-mode-radio-group input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #ff9800;
}

.envelope-offset-sliders-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 600px;
    max-width: 100%;
    margin-top: 10px;
}

.envelope-offset-slider-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.envelope-offset-slider-label {
    min-width: 120px;
    color: #ffffff;
    font-size: 14px;
}

.envelope-offset-slider-container {
    flex: 1;
    display: flex;
    align-items: center;
}

.envelope-offset-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.envelope-offset-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ff9800;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.envelope-offset-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ff9800;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.envelope-offset-value {
    min-width: 60px;
    color: #ffffff;
    font-size: 14px;
    text-align: right;
}

.envelope-editor-container {
    width: 100%;
    min-height: 300px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    padding: 10px;
}

.envelope-canvas {
    width: 100%;
    height: 100%;
    border-radius: 5px;
}

.envelope-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.envelope-control-btn {
    background: rgba(255, 152, 0, 0.8);
    border: none;
    border-radius: 5px;
    padding: 8px 15px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.envelope-control-btn:hover:not(:disabled) {
    background: rgba(255, 152, 0, 1);
}

.envelope-control-btn:disabled {
    background: rgba(128, 128, 128, 0.5);
    cursor: not-allowed;
}

/* Polyphonic Mode Controls */
.poly-mode-radio-group {
    display: flex;
    gap: 16px;
    align-items: center;
}

.poly-mode-radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.poly-mode-radio-group input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #4CAF50;
}

.pitch-controls-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

.pitch-control-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.pitch-control-label-column {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 60px;
}

.pitch-control-label-column label {
    margin: 0;
}

.pitch-control-label-column .add-pitch-btn {
    margin-left: 0;
    margin-top: 0;
}

.pitch-control-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.pitch-control-delete-column {
    position: absolute;
    right: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 40px;
    padding-left: 8px;
    height: 100%;
    pointer-events: none;
}

.pitch-control-delete-column .delete-pitch-btn {
    pointer-events: all;
}

.pitch-delete-spacer {
    width: 40px;
    flex-shrink: 0;
    height: 40px; /* Match typical row height */
}

.add-pitch-btn {
    background: rgba(76, 175, 80, 0.8);
    border: none;
    border-radius: 5px;
    padding: 4px 10px;
    color: white;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0;
}

.add-pitch-btn:hover:not(:disabled) {
    background: rgba(76, 175, 80, 1);
    transform: scale(1.1);
}

.add-pitch-btn:disabled {
    background: rgba(128, 128, 128, 0.5);
    cursor: not-allowed;
    transform: none;
}

.root-label {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9em;
    margin-left: 4px;
}

.delete-pitch-btn {
    background: rgba(244, 67, 54, 0.8);
    border: none;
    border-radius: 5px;
    padding: 4px 10px;
    color: white;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-pitch-btn:hover {
    background: rgba(244, 67, 54, 1);
    transform: scale(1.1);
}

.pitch-control-poly {
    margin-top: 4px;
}

.pitch-label-spacer {
    visibility: hidden;
    width: auto;
    min-width: 0;
    margin: 0;
    padding: 0;
    display: inline-block;
}

/* Match the exact width and spacing of the visible Pitch (Hz): label */
.pitch-control-inputs label[for="pitch"],
.pitch-control-inputs .pitch-label-spacer {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    padding-right: 0;
    margin-right: 0;
}

#poly-pitches-container {
    display: none;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.cancel-btn,
.save-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.2s ease;
}

.cancel-btn {
    background: rgba(244, 67, 54, 0.8);
    color: white;
}

.cancel-btn:hover {
    background: rgba(244, 67, 54, 1);
}

.save-btn {
    background: rgba(76, 175, 80, 0.8);
    color: white;
}

.save-btn:hover:not(:disabled) {
    background: rgba(76, 175, 80, 1);
}

.save-btn:disabled {
    background: rgba(128, 128, 128, 0.5);
    cursor: not-allowed;
}

/* Source Type Control */
.tempo-sequencer-scope .source-type-control {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.tempo-sequencer-scope .source-type-control label {
    font-size: 0.9em;
    color: #ccc;
}

.tempo-sequencer-scope .source-type-select {
    width: 100%;
    padding: 5px;
    border: none;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
}

.tempo-sequencer-scope .source-select {
    width: 100%;
    max-width: 100%;
    padding: 8px;
    border: none;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* MIDI Output Wrapper */
#midi-output-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

#midi-output-wrapper label {
    font-size: 0.9em;
}

#midi-output-select {
    padding: 4px 8px;
    font-size: 0.9em;
}

#audio-mute-toggle-btn,
.audio-mute-toggle-btn {
    padding: 4px 10px;
    font-size: 0.9em;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

#audio-mute-toggle-btn:hover,
.audio-mute-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

#audio-mute-toggle-btn.muted,
.audio-mute-toggle-btn.muted {
    background: rgba(244, 67, 54, 0.6);
    border-color: rgba(244, 67, 54, 0.8);
}

#audio-mute-toggle-btn.muted:hover,
.audio-mute-toggle-btn.muted:hover {
    background: rgba(244, 67, 54, 0.8);
    border-color: rgba(244, 67, 54, 1);
}

/* Responsive */
@media (max-width: 768px) {
    .tempo-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .tempo-sequencer-scope .events-container {
        flex-direction: column;
        border: none !important;
    }
    
    .sample-list,
    .generator-list {
        grid-template-columns: 1fr;
    }
    
    .tempo-sequencer-scope .child-event-item {
        flex-direction: column;
        align-items: stretch;
        border: none !important;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
        border-bottom: none !important;
    }
    
    .sound-generator-modal {
        max-width: 95%;
        padding: 20px;
    }
}

/* Phone Portrait Optimization */
@media (max-width: 480px) {
    /* Main Container */
    #app {
        padding: 10px;
        max-width: 100%;
    }

    /* Header Section */
    .app-header {
        padding: 10px;
        gap: 8px;
        margin-bottom: 15px;
        flex-direction: column;
        align-items: center;
    }

    .app-header h1 {
        font-size: 1.5em;
        margin-bottom: 5px;
    }

    .app-header .status-indicator {
        font-size: 0.85em;
        padding: 4px 12px;
    }
    
    .primary-tempo-controls-container {
        padding: 10px;
        gap: 10px;
        flex-wrap: wrap;
    }
    
    .primary-tempo-controls {
        gap: 8px;
        flex-wrap: wrap;
        margin-left: 0;
    }

    /* Section Spacing */
    .sound-generator-panel,
    .sample-browser,
    .tempo-sequencer-scope .event-rows {
        margin-bottom: 15px;
    }

    /* Sound Generator & Sample Panels */
    .sound-generator-panel,
    .sample-browser {
        padding: 12px;
    }

    .generator-list,
    .sample-list {
        gap: 6px;
        margin-bottom: 10px;
    }

    /* Event Rows */
    .tempo-sequencer-scope .event-row {
        padding: 10px;
        margin-bottom: 10px;
        border: none !important;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
        border-bottom: none !important;
    }

    .tempo-sequencer-scope .row-header {
        gap: 8px;
        margin-bottom: 10px;
    }

    .tempo-sequencer-scope .row-title {
        font-size: 1.1em;
    }

    .tempo-sequencer-scope .row-button-group {
        gap: 6px;
        flex-wrap: wrap;
    }

    .tempo-sequencer-scope .row-tempo-section {
        margin: 5px 0;
    }

    .tempo-sequencer-scope .row-grouped-controls {
        gap: 8px;
        flex-wrap: wrap;
    }

    /* Legacy support */
    .tempo-sequencer-scope .row-controls {
        min-width: unset;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: flex-start;
    }

    .tempo-sequencer-scope .row-music-controls {
        flex-wrap: wrap;
        gap: 6px;
        justify-content: flex-start;
    }

    /* Row Tempo Controls */
    .tempo-sequencer-scope .row-tempo-controls {
        padding: 8px;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
        border: none !important;
    }

    .tempo-sequencer-scope .row-tempo-controls .manual-tempo {
        gap: 5px;
    }

    .tempo-sequencer-scope .row-tempo-controls .manual-tempo input {
        padding: 4px 6px;
        width: 60px;
    }

    .tempo-sequencer-scope .row-tempo-controls .tap-button {
        width: 35px;
        height: 35px;
        font-size: 0.8em;
    }

    .tempo-sequencer-scope .row-tempo-controls .tempo-display {
        font-size: 0.9em;
        min-width: unset;
    }

    /* Tempo Scale */
    .tempo-scale {
        gap: 3px;
    }

    .tempo-scale input {
        width: 50px;
        padding: 4px;
    }

    /* Frequency Offset */
    .frequency-offset-input {
        width: 50px;
        padding: 4px;
    }

    /* Event Items */
    .tempo-sequencer-scope .events-container {
        gap: 8px;
        border: none !important;
    }

    .tempo-sequencer-scope .event-item {
        padding: 8px;
        border: none !important;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
        border-bottom: none !important;
    }

    .tempo-sequencer-scope .child-event-item {
        padding: 8px;
        border: none !important;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
        border-bottom: none !important;
    }

    .tempo-sequencer-scope .event-item-header,
    .tempo-sequencer-scope .child-event-item-header {
        min-height: 45px;
    }

    .tempo-sequencer-scope .remove-event-btn {
        bottom: 0;
        right: 0;
        padding: 5px 10px;
        font-size: 0.8em;
    }

    .tempo-sequencer-scope .event-item-header {
        gap: 6px;
    }

    .tempo-sequencer-scope .event-controls {
        gap: 6px;
    }

    .tempo-sequencer-scope .event-arm-controls {
        min-width: unset;
        gap: 4px;
    }

    .tempo-sequencer-scope .arm-event-btn {
        padding: 6px 10px;
        min-width: 70px;
        font-size: 0.8em;
    }

    .tempo-sequencer-scope .disarm-child-toggle-btn,
    .tempo-sequencer-scope .arm-all-children-btn {
        padding: 5px 8px;
        min-width: 90px;
        font-size: 0.7em;
    }

    /* Buttons */
    .play-pause-btn {
        height: 35px;
        padding: 8px 15px;
    }

    .tempo-sequencer-scope .add-event-btn,
    .tempo-sequencer-scope .remove-row-btn {
        padding: 8px 12px;
    }

    .create-generator-btn,
    .refresh-btn {
        padding: 8px 15px;
    }

    .tempo-sequencer-scope .add-row-btn {
        padding: 15px;
    }

    /* Inputs and Selects */
    .tempo-sequencer-scope .sample-select,
    .tempo-sequencer-scope .source-select {
        padding: 6px;
    }

    .tempo-sequencer-scope .time-signature,
    .tempo-sequencer-scope .row-note {
        gap: 4px;
    }

    .tempo-sequencer-scope .timesig-x,
    .tempo-sequencer-scope .timesig-y,
    .tempo-sequencer-scope .row-note-select,
    .tempo-sequencer-scope .offset-note-select,
    .tempo-sequencer-scope .source-select,
    .tempo-sequencer-scope .source-type-select {
        padding: 3px 5px;
    }

    .tempo-sequencer-scope .offset-control input {
        padding: 4px;
    }

    /* Child Tempo Panel */
    .tempo-sequencer-scope .child-tempo-panel {
        padding: 10px;
        border: none !important;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
        border-bottom: none !important;
    }

    .tempo-sequencer-scope .child-event-row {
        padding: 10px;
        margin-bottom: 8px;
        border: none !important;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
        border-bottom: none !important;
    }

    .tempo-sequencer-scope .child-row-header {
        gap: 8px;
        margin-bottom: 8px;
    }

    .tempo-sequencer-scope .child-row-button-group {
        gap: 6px;
        flex-wrap: wrap;
    }

    .tempo-sequencer-scope .child-row-grouped-controls {
        gap: 8px;
        flex-wrap: wrap;
    }

    /* Legacy support */
    .tempo-sequencer-scope .child-row-controls {
        gap: 6px;
    }

    .tempo-sequencer-scope .child-tempo-toggle-btn {
        padding: 6px 10px;
        min-width: 90px;
    }

    .tempo-sequencer-scope .add-child-row-btn {
        padding: 6px 12px;
    }

    .tempo-sequencer-scope .remove-child-row-btn {
        padding: 5px 8px;
    }

    /* Source Tabs */
    .source-tabs {
        margin-bottom: 15px;
    }

    .tabs {
        gap: 1px;
    }

    .tab {
        padding: 6px 10px;
        font-size: 0.9em;
    }

    .tab-panels {
        padding: 10px;
    }

    /* Sound Generator Modal */
    .sound-generator-modal {
        padding: 15px;
        max-width: 98%;
    }

    .modal-header {
        margin-bottom: 15px;
    }

    .modal-content {
        gap: 15px;
    }

    .form-group {
        gap: 6px;
    }

    .form-input,
    .form-select {
        padding: 6px;
    }

    .envelope-editor-container {
        padding: 8px;
    }

    .envelope-controls {
        gap: 6px;
        margin-top: 8px;
    }

    .envelope-control-btn {
        padding: 6px 12px;
    }

    .modal-footer {
        gap: 8px;
        margin-top: 15px;
    }

    .cancel-btn,
    .save-btn {
        padding: 8px 15px;
    }

    /* Playback Status */
    .playback-status {
        font-size: 0.85em;
    }

    /* MIDI Output Wrapper */
    #midi-output-wrapper {
        gap: 6px;
        margin: 6px 0;
        flex-wrap: wrap;
    }

    #midi-output-wrapper label {
        font-size: 0.85em;
    }

    #midi-output-select {
        padding: 4px 6px;
        font-size: 0.85em;
    }

    #audio-mute-toggle-btn,
    .audio-mute-toggle-btn {
        padding: 4px 8px;
        font-size: 0.85em;
        border: 1px solid rgba(255, 255, 255, 0.3);
        border-radius: 4px;
        background: rgba(255, 255, 255, 0.1);
        color: white;
        cursor: pointer;
        transition: all 0.2s ease;
        white-space: nowrap;
    }

    #audio-mute-toggle-btn:hover,
    .audio-mute-toggle-btn:hover {
        background: rgba(255, 255, 255, 0.2);
        border-color: rgba(255, 255, 255, 0.5);
    }

    #audio-mute-toggle-btn.muted,
    .audio-mute-toggle-btn.muted {
        background: rgba(244, 67, 54, 0.6);
        border-color: rgba(244, 67, 54, 0.8);
    }

    #audio-mute-toggle-btn.muted:hover,
    .audio-mute-toggle-btn.muted:hover {
        background: rgba(244, 67, 54, 0.8);
        border-color: rgba(244, 67, 54, 1);
    }
}

/* Snaps Panel */
.snaps-panel {
    padding: 15px;
}

.snaps-panel .panel-header {
    margin-bottom: 15px;
}

.snaps-panel .panel-header h3 {
    margin: 0;
    font-size: 1.2em;
    color: #fff;
}

.snaps-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.snaps-empty-message {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9em;
    text-align: center;
    padding: 20px;
}

.snap-button {
    position: relative;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    padding: 10px 15px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
}

.snap-button:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
}

.snap-button.selected {
    background: rgba(76, 175, 80, 0.3);
    border-color: rgba(76, 175, 80, 0.8);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
}

.snap-button-content {
    flex: 1;
    position: relative;
}

.snap-name {
    display: block;
    font-size: 0.95em;
}

.snap-asterisk {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 0.9em;
    font-weight: bold;
    color: #ffeb3b;
    line-height: 1;
}

/* Snips Panel */
.snips-panel {
    padding: 15px;
}

.snips-panel .panel-header {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.snips-panel .panel-header h3 {
    margin: 0;
    font-size: 1.2em;
    color: #fff;
}

.load-snip-btn {
    background: rgba(76, 175, 80, 0.6);
    border: 1px solid rgba(76, 175, 80, 0.8);
    border-radius: 5px;
    color: white;
    padding: 8px 16px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.load-snip-btn:hover {
    background: rgba(76, 175, 80, 0.8);
    border-color: rgba(76, 175, 80, 1);
}

.snips-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.snips-empty-message {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9em;
    text-align: center;
    padding: 20px;
}

.snip-button {
    position: relative;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    padding: 10px 15px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
}

.snip-button:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
}

.snip-button.selected {
    background: rgba(76, 175, 80, 0.3);
    border-color: rgba(76, 175, 80, 0.8);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
}

.snip-button-content {
    flex: 1;
    position: relative;
}

.snip-name {
    display: block;
    font-size: 0.95em;
}

.snip-name-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    color: #fff;
    padding: 4px 6px;
    font-size: 0.95em;
    min-width: 140px;
    width: 100%;
}

.snip-play-btn,
.snip-rename-btn,
.snip-save-btn,
.snip-delete-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    color: white;
    padding: 4px 8px;
    margin-left: 5px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s ease;
    min-width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.snip-play-btn:hover,
.snip-rename-btn:hover,
.snip-save-btn:hover {
    background: rgba(76, 175, 80, 0.3);
    border-color: rgba(76, 175, 80, 0.5);
}

.snip-delete-btn {
    background: rgba(244, 67, 54, 0.3);
    border-color: rgba(244, 67, 54, 0.5);
}

.snip-delete-btn:hover {
    background: rgba(244, 67, 54, 0.5);
    border-color: rgba(244, 67, 54, 0.8);
}

.snip-keep-discard-dialog {
    font-family: inherit;
}

.snap-delete-btn {
    background: rgba(244, 67, 54, 0.6);
    border: none;
    border-radius: 3px;
    color: #fff;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 1.2em;
    line-height: 1;
    transition: all 0.2s ease;
    margin-left: 10px;
}

.snap-delete-btn:hover {
    background: rgba(244, 67, 54, 0.9);
}

/* Source Tabs UI */
.source-tabs {
    margin-bottom: 20px;
}

.tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
}

.tab {
    appearance: none;
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    color: #fff;
    padding: 8px 14px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab:hover {
    background: rgba(255, 255, 255, 0.08);
}

.tab:focus-visible {
    outline: 2px solid rgba(76, 175, 80, 0.7);
    outline-offset: 2px;
}

.tab.active {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    border-bottom: 1px solid transparent;
    margin-bottom: -1px;
    position: relative;
    z-index: 2;
}

.tab-panels {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    padding: 12px;
    margin-top: -1px;
}

.is-hidden {
    display: none;
}

/* Split Pane Layout */
.split-pane-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
    min-height: 400px;
}

.left-pane,
.right-pane,
.roll-pane {
    flex: 1;
    min-width: 0;
    display: none;
}

.left-pane.active,
.right-pane.active,
.roll-pane.active {
    display: block;
}

.left-pane {
    /* Existing event rows stay in left pane */
}

.right-pane {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    backdrop-filter: blur(10px);
}

.roll-pane {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
    backdrop-filter: blur(10px);
}

/* Roll View */
.roll-view {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.roll-zoom-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 8px;
    flex-wrap: wrap;
}

.roll-zoom-container label {
    color: white;
    font-size: 0.9em;
    font-weight: 500;
}

.roll-zoom-select,
.roll-margin-select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: white;
    padding: 4px 8px;
    font-size: 0.9em;
    cursor: pointer;
}

.roll-zoom-select:hover,
.roll-margin-select:hover {
    background: rgba(255, 255, 255, 0.15);
}

.roll-record-btn,
.roll-play-snip-btn,
.roll-midi-in-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: white;
    padding: 4px 12px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.roll-record-btn:hover:not(:disabled),
.roll-play-snip-btn:hover:not(:disabled),
.roll-midi-in-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.roll-record-btn:disabled,
.roll-play-snip-btn:disabled,
.roll-midi-in-btn:disabled {
    background: rgba(128, 128, 128, 0.3);
    border-color: rgba(128, 128, 128, 0.2);
    cursor: not-allowed;
    opacity: 0.5;
}

.roll-midi-in-btn.active {
    background: rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.5);
}

.roll-record-btn.recording {
    background: rgba(244, 67, 54, 0.8);
    border-color: rgba(244, 67, 54, 1);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.roll-midi-in-container {
    width: 100%;
    margin-top: 10px;
}

.roll-midi-in-wrapper {
    display: flex;
    width: 100%;
    height: 200px;
}

.roll-midi-in-left-column {
    width: 100px;
    height: 100%;
    position: relative;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 8px 0 0 8px;
}

.roll-midi-in-status-tile {
    position: absolute;
    top: 0;
    left: 0;
    padding: 8px;
    color: white;
    font-size: 0.9em;
}

.roll-midi-in-status-tile .midi-in-status-text {
    font-weight: 500;
    margin-top: 4px;
}

.roll-midi-in-status-tile .midi-in-note-count {
    margin-top: 4px;
    font-size: 0.8em;
    opacity: 0.7;
}

.roll-midi-in-status-tile label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85em;
    cursor: pointer;
    user-select: none;
}

.roll-midi-in-status-tile .midi-in-bide-toggle {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.midi-in-capture-btn,
.midi-in-play-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: white;
    padding: 4px 8px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    width: 100%;
}

.midi-in-capture-btn:hover:not(:disabled),
.midi-in-play-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.midi-in-capture-btn:disabled,
.midi-in-play-btn:disabled {
    background: rgba(128, 128, 128, 0.3);
    border-color: rgba(128, 128, 128, 0.2);
    cursor: not-allowed;
    opacity: 0.5;
}

.midi-in-capture-btn.capturing {
    background: rgba(244, 67, 54, 0.8);
    border-color: rgba(244, 67, 54, 1);
    animation: pulse 1s ease-in-out infinite;
}

.midi-in-capture-btn.armed {
    background: rgba(251, 191, 36, 0.6);
    border-color: rgba(251, 191, 36, 0.8);
    animation: pulse 1.5s ease-in-out infinite;
}

.midi-in-play-btn.playing {
    background: rgba(59, 130, 246, 0.6);
    border-color: rgba(59, 130, 246, 0.8);
}

.midi-in-capture-status {
    margin-top: 8px;
    font-size: 0.75em;
    opacity: 0.7;
}

.roll-midi-in-roll-container {
    position: relative;
    flex: 1;
    height: 100%;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 0 8px 8px 0;
}

.roll-wrappers-container {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.roll-wrapper {
    display: flex;
    width: 100%;
    height: 600px; /* Default, will be updated dynamically */
    min-height: 160px; /* Minimum: 2 * TILE_SIZE (80px) */
    overflow-y: hidden; /* Height is determined by actual content */
}

.roll-collapsed-parent-label {
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.roll-collapsed-parent-label:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

.roll-collapsed-parent-label.active {
    background-color: rgba(59, 130, 246, 0.4) !important;
    border-color: rgba(59, 130, 246, 0.8) !important;
    font-weight: 600;
}

.roll-row-name-label {
    position: absolute;
    top: 0;
    left: 0;
    padding: 4px 8px;
    color: white;
    font-size: 0.9em;
    font-weight: 500;
    pointer-events: none;
    z-index: 10;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0 0 4px 0;
}

.roll-left-column {
    position: relative;
    width: 100px;
    height: 100%;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px 0 0 8px;
}

.roll-container {
    position: relative;
    flex: 1;
    height: 100%;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0 8px 8px 0;
}

.roll-measure-line {
    position: absolute;
    background-color: white;
    opacity: 0.5;
    will-change: transform;
}

.roll-center-line {
    position: absolute;
    background-color: rgba(255, 255, 255, 0.8);
    opacity: 1;
}

.roll-tile {
    /* Reuse canvas-tile styles */
    will-change: transform;
}

.roll-left-column-tile {
    /* Left column tiles use canvas-tile styles but are static */
    will-change: auto;
    transition: background-color 0.1s ease-in-out, box-shadow 0.1s ease-in-out, transform 0.1s ease-in-out;
}

.roll-left-column-tile.triggering {
    transform: scale(1.1) !important;
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.8) !important;
    background: rgba(255, 107, 107, 1) !important;
    animation: pulse 0.35s ease-in-out;
}

/* Wrapper for bar - handles translateX for scrolling */
.roll-note-bar-wrapper {
    position: absolute;
    will-change: transform;
    pointer-events: none;
}

.roll-note-bar {
    position: relative;
    background-color: rgba(255, 255, 255, 1);
    border-radius: 2px;
    will-change: transform;
    pointer-events: none;
    transition: background-color 0.1s ease-in-out, box-shadow 0.1s ease-in-out;
}

.roll-note-bar.triggering {
    background-color: rgba(255, 107, 107, 1);
    box-shadow: 0 0 20px rgba(255, 107, 107, 1);
    animation: pulse 0.35s ease-in-out;
    /* Note: pulse animation only scales, wrapper handles translateX */
}

/* Mobile Toggle Controls - Styled to match accordion panels */
.pane-toggle-controls {
    display: flex;
    gap: 0;
    width: 100%;
    margin-bottom: 5px;
    margin-top: 0;
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
    min-height: 35px;
}

/* Toggle controls inside right pane */
.pane-toggle-controls-right {
    margin-bottom: 15px;
    margin-top: 0;
}

.pane-toggle-controls-right.mobile-active {
    display: flex;
}

/* Style toggle buttons to match accordion panel header style but keep colors */
.pane-toggle-controls .split-btn-left {
    flex: 1;
    border: none;
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(156, 39, 176, 0.8);
    padding: 8px 12px;
    color: white;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 35px;
}

.pane-toggle-controls .split-btn-left:hover {
    background: rgba(156, 39, 176, 1);
}

.pane-toggle-controls .split-btn-middle {
    flex: 1;
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0;
    background: rgba(255, 152, 0, 0.8);
    padding: 8px 12px;
    color: white;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 35px;
}

.pane-toggle-controls .split-btn-middle:hover {
    background: rgba(255, 152, 0, 1);
}

.pane-toggle-controls .split-btn-right {
    flex: 1;
    border: none;
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
    background: rgba(76, 175, 80, 0.8);
    padding: 8px 12px;
    color: white;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 35px;
}

.pane-toggle-controls .split-btn-right:hover {
    background: rgba(76, 175, 80, 1);
}

.pane-toggle-btn.active {
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* Canvas View */
.canvas-view {
    width: 100%;
    height: 100%;
}

.canvas-view-container {
    width: 100%;
    height: 600px;
    overflow: auto;
}

.canvas-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.canvas-grid {
    position: relative;
    min-width: 800px;
    min-height: 600px;
}

/* Canvas Row Labels */
.canvas-row-label {
    font-size: 0.9em;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    padding: 2px 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-sizing: border-box;
}

.canvas-row-label-name {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    font-size: 0.85em;
    line-height: 1.2;
    margin-bottom: 2px;
}

.canvas-row-label-tempo {
    width: 100%;
    text-align: center;
    font-size: 0.75em;
    line-height: 1.2;
    opacity: 0.9;
}

.canvas-child-row-label {
    color: rgba(225, 190, 231, 0.9);
    font-size: 0.85em;
}

/* Canvas Tiles */
.canvas-tile {
    background: rgba(255, 255, 255, 1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.canvas-tile:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.canvas-tile.triggering {
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.8);
    background: rgba(255, 107, 107, 1);
    animation: pulse 0.2s ease-in-out;
}

.tile-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 4px;
    box-sizing: border-box;
    position: relative;
}

.tile-name {
    font-size: 0.7em;
    color: #333;
    font-weight: 600;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    text-align: center;
}

.tile-offset {
    font-size: 0.6em;
    color: #666;
    margin-bottom: 2px;
}

.tile-frequency {
    font-size: 0.6em;
    color: #666;
}

.tile-ellipsis {
    position: absolute;
    bottom: 4px;
    right: 4px;
    font-size: 0.7em;
    color: #333;
    font-weight: 600;
    line-height: 1;
}

/* Expanded Navigation Tile */
.canvas-tile.expanded-navigation {
    /* Height is set via inline style: TILE_SIZE + LABEL_HEIGHT (120px) */
    position: relative;
}

.canvas-tile.expanded-navigation .tile-content {
    /* Keep tile content in its original position at the bottom 80px */
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px; /* TILE_SIZE */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px;
    box-sizing: border-box;
}

.canvas-tile-navigation-arrow {
    /* Position arrow in the top 40px area (LABEL_HEIGHT) */
    position: absolute;
    left: 0;
    top: 0;
    width: 40px;
    height: 40px; /* LABEL_HEIGHT */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    color: #333;
    font-weight: bold;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    border-right: 2px solid rgba(255, 255, 255, 0.3);
    transition: all 0.2s ease;
    user-select: none;
}

.canvas-tile-navigation-arrow:hover {
    background: rgba(255, 255, 255, 0.4);
    color: #000;
    transform: scale(1.1);
}

/* Overlap Popup */
.canvas-overlap-popup {
    position: absolute;
    background: rgba(30, 60, 114, 0.95);
    border: 2px solid rgba(76, 175, 80, 0.8);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.canvas-popup-row {
    display: flex;
    gap: 2px;
    align-items: center;
}

.canvas-popup-tile {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.canvas-popup-tile:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(76, 175, 80, 0.8);
    transform: scale(1.1);
}

/* Pulse Animation - uses scale only, translateX is preserved via inline style */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* Pulse Animation - only scales (translateX handled by wrapper) */

/* Mobile Responsive */
@media (max-width: 1271px) {
    .split-pane-container {
        flex-direction: column;
    }
    
    .left-pane,
    .right-pane,
    .roll-pane {
        width: 100%;
    }
    
    .canvas-view-container {
        height: 500px;
    }
}
}