/* 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;
}

.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;
}

/* 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;
}

/* 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;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    backdrop-filter: blur(10px);
}

.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;
}

.arm-all-btn,
.disarm-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);
}

.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: center;
}

.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;
}

.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-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-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);
}

/* 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 {
    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-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);
}

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

.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%;
    margin-top: 10px;
}

.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;
}

/* 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;
    }

    /* 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;
    }
}

/* 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;
}
}