body {
    font-family: 'Noto Sans', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #212529; /* Dark background for dark mode */
    color: #f8f9fa; /* Light text for dark mode */
}

h1, h2 {
    color: #f8f9fa; /* White color for titles */
}

/* Ensure h3 in single-conversion-results is white */
#single-conversion-results h3 {
    color: #f8f9fa;
}

/* Channel-based layout styles */
.channel-box {
    background-color: #2b2b2b;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.channel-header {
    border-bottom: 1px solid #444;
    padding-bottom: 8px;
    margin-bottom: 16px;
}

.channel-title {
    color: #f8f9fa;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.channel-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.waveform-row {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.waveform-track-group {
    flex: 1;
    position: relative; /* Enable absolute positioning for children */
}

.waveform-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

.waveform-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allow clicks to pass through to image */
    z-index: 10; /* Ensure it appears on top */
    border-radius: 4px;
}

.waveform-label {
    color: #adb5bd;
    font-size: 0.9rem;
    margin-bottom: 4px;
    font-weight: 500;
}

.channel-controls {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 20px;
    padding: 12px;
    background-color: #1a1a1a;
    border-radius: 6px;
}

.blend-control, .gain-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.control-label {
    color: #f8f9fa;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0;
    text-align: center;
}

.enable-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.enable-btn {
    width: 60px;
    height: 32px;
    border: 2px solid #ffc107;
    border-radius: 4px;
    background-color: #ffc107;
    color: #000;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.enable-btn:hover {
    background-color: #ffca2c;
    border-color: #ffca2c;
}

.enable-btn[data-enabled="false"] {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
}

.enable-btn[data-enabled="false"]:hover {
    background-color: #c82333;
    border-color: #c82333;
}

.enable-btn .btn-text {
    font-size: 0.85rem;
    font-weight: 600;
}

.knob-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 60px;
    max-width: 60px;
}

.knob-container canvas {
    width: 60px !important;
    height: 60px !important;
    display: block;
}

.knob-input {
    width: 50px;
    height: 24px;
    background-color: #343a40;
    color: #f8f9fa;
    border: 1px solid #495057;
    border-radius: 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 4px;
}

.knob-input:focus {
    background-color: #495057;
    border-color: #86b7fe;
    outline: none;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
}

.master-controls-box {
    background-color: #2b2b2b;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.master-controls-header {
    border-bottom: 1px solid #444;
    padding-bottom: 8px;
    margin-bottom: 16px;
}

.master-controls-title {
    color: #f8f9fa;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.master-controls-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
}

.playback-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.master-settings {
    display: flex;
    align-items: center;
    gap: 16px;
}

.action-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
    .waveform-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .master-controls-content {
        flex-direction: column;
        gap: 16px;
    }
    
    .channel-content {
        gap: 12px;
    }
}

.logo-img {
    height: 60px; /* Increased by 50% from 40px */
    margin-right: 10px;
}

.navbar-brand {
    font-size: 1.5rem; /* Increased by 25% from Bootstrap's default 1.2rem */
}

.navbar-header-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    width: 100%;
    position: relative;
}

.navbar-title {
    text-align: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60px; /* Match logo height */
}

.matchering-link {
    color: #007bff !important; /* Bootstrap primary blue */
    text-decoration: none;
    padding: 0 8px; /* Add spacing around the link */
    transition: color 0.2s ease;
}

.matchering-link:hover {
    color: #0056b3 !important; /* Darker blue on hover */
    text-decoration: underline;
}

/* Custom styles for status messages to fit dark theme */
.status-message {
    margin-top: 10px;
    padding: 10px;
    border-radius: 4px;
}

.status-message.success {
    background-color: #198754;
    color: #fff;
    border-color: #198754;
}

.status-message.error {
    background-color: #dc3545;
    color: #fff;
    border-color: #dc3545;
}

/* Waveform container adjustments for dark mode */
.waveform-container {
    margin-top: 20px;
    border: 1px solid #495057;
    background-color: #343a40;
    position: relative;
    height: 220px; /* Fixed height to prevent size jumps */
    display: flex; /* Use flexbox to stack waveform groups */
    flex-direction: column;
}

.waveform-track-group {
    position: relative;
    flex-grow: 1; /* Each group takes equal height */
    display: flex;
    flex-direction: column;
}

.waveform-label {
    position: relative; /* Keep relative to flow */
    z-index: 1; /* Bring text to front */
    padding: 5px; /* Add some padding for readability */
    color: #f8f9fa; /* Ensure text is white */
    background-color: rgba(33, 37, 41, 0.5); /* Semi-transparent dark background (more transparent) */
    border-radius: 4px;
    text-align: center;
    margin-bottom: -10px; /* Adjust to pull label closer to waveform */
}

canvas {
    position: relative; /* Change to relative to flow with label */
    top: 0;
    left: 0;
    width: 100%;
    height: 120px; /* Increased height for better combined waveform visibility */
}

/* Override canvas sizing for knob canvases to prevent stretching */
canvas[id*="blend-knob"] {
    width: 60px !important;
    height: 60px !important;
}

/* Adjustments for Bootstrap form elements */
.form-label {
    color: #f8f9fa;
}

.form-control, .form-select {
    background-color: #343a40;
    color: #f8f9fa;
    border-color: #495057;
}

.form-control:focus, .form-select:focus {
    background-color: #343a40;
    color: #f8f9fa;
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Progress bar adjustments */
.progress {
    background-color: #495057;
}

.progress-bar {
    background-color: #0d6efd;
}

/* Tab styling */
.nav-tabs {
    border-bottom: none; /* Remove default Bootstrap bottom border */
}

.nav-tabs .nav-item {
    margin: 0; /* Remove all margins from nav items */
    padding: 0; /* Remove all paddings from nav items */
    flex-grow: 1; /* Make all nav items grow equally */
}

.nav-tabs .nav-link {
    color: #adb5bd; /* Inactive tab labels light grey */
    background-color: #343a40; /* Dark background for inactive tabs */
    border: 1px solid #495057; /* Border color for inactive tabs */
    border-bottom-color: transparent; /* Hide bottom border */
    border-top-left-radius: 0.5rem; /* Increased rounded top-left corner */
    border-top-right-radius: 0.5rem; /* Increased rounded top-right corner */
    margin: 0; /* Ensure no gap between tabs */
    text-align: center; /* Center text in tabs */
    display: block; /* Ensure it fills the nav-item */
    padding: 0.5rem 1rem; /* Standard Bootstrap padding for links */
}

.nav-tabs .nav-item:not(:first-child) .nav-link {
    border-left: none; /* Remove left border for all but the first tab to prevent double borders */
}

.nav-tabs .nav-link.active {
    color: #f8f9fa; /* Active tab label white */
    background-color: #212529; /* Dark background for active tab content */
    border-color: #495057;
    border-bottom-color: transparent; /* Hide bottom border to blend with content */
}

.nav-tabs .nav-link:hover {
    border-color: #6c757d; /* Slightly lighter border on hover */
}

.tab-content {
    background-color: #212529; /* Match body background for content area */
    border: 1px solid #495057;
    border-top: 1px solid #495057; /* Add top border for the line */
    padding: 20px;
    border-radius: 0 0 8px 8px;
    margin-top: -1px; /* Pull content up to hide border under active tab */
}

.tab-pane.fade {
    transition: opacity 0.15s linear; /* Faster transition for tab panes */
}

/* Style for radio button labels */
.form-check-inline .form-check-input {
    /* Hide the default radio button visually */
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.form-check-inline .radio-button-label {
    background-color: #343a40; /* Default background for unselected */
    color: #f8f9fa; /* Ensure text is readable */
    padding: 0.5rem 1rem; /* Padding to encompass content */
    border-radius: 0.5rem; /* Rounded corners matching tab labels */
    border: 1px solid #495057;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: inline-block; /* Make it behave like a block for padding/border */
}

.form-check-inline .form-check-input:checked + .radio-button-label {
    background-color: #6c757d; /* Light grey background when selected */
    border-color: #86b7fe; /* Highlight border */
}

.form-check-inline .radio-button-label:hover {
    background-color: #495057; /* Slightly lighter on hover */
}

/* Playback button styling */
.playback-button {
    background-color: #343a40; /* Default background for unselected */
    color: #f8f9fa; /* Ensure text is readable */
    padding: 0.5rem 1rem; /* Padding to encompass content */
    border-radius: 0.5rem; /* Rounded corners matching tab labels */
    border: 1px solid #495057;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.playback-button:hover {
    background-color: #495057; /* Slightly lighter on hover */
}

.playback-button.playback-active {
    background-color: #6c757d; /* Light grey background when active */
    border-color: #86b7fe; /* Highlight border */
}

/* Playback line styling */
.playback-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    background-color: #dc3545; /* Red line */
    z-index: 2; /* Ensure it's above waveforms */
}

#process-file-button,
#separate-stems-button,
#start-batch-button,
#create-preset-button {
    background-color: #343a40; /* Default background for unselected */
    color: #f8f9fa; /* Ensure text is readable */
    padding: 0.5rem 1rem; /* Padding to encompass content */
    border-radius: 0.5rem; /* Rounded corners matching tab labels */
    border: 1px solid #495057;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

#process-file-button:hover,
#separate-stems-button:hover,
#start-batch-button:hover,
#create-preset-button:hover {
    background-color: #495057; /* Slightly lighter on hover */
}

/* Knob styling */
#blend-knob {
    cursor: grab;
    border-radius: 50%;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: box-shadow 0.2s ease;
}

#blend-knob:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

#blend-knob:active {
    cursor: grabbing;
}

/* Limiter button styling */
.limiter-btn {
    background-color: #343a40; /* Same as playback buttons */
    color: #f8f9fa; /* Same as playback buttons */
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid #495057;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    font-weight: 500;
    min-width: 140px; /* Fixed width to accommodate both states */
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.limiter-btn:hover {
    background-color: #495057; /* Same hover as playback buttons */
}

.limiter-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #f8f9fa;
}

.limiter-text {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.4rem;
    border-radius: 0.3rem;
    min-width: 85px; /* Increased width to fit "BYPASSED" */
    text-align: center;
    transition: all 0.2s ease-in-out;
    white-space: nowrap; /* Prevent text wrapping */
}

.limiter-btn.limiter-on .limiter-text {
    background-color: #ffc107; /* Yellow background for ON state */
    color: #212529; /* Dark text */
}

.limiter-btn.limiter-bypassed .limiter-text {
    background-color: #dc3545; /* Red background for BYPASSED state */
    color: #fff; /* White text */
}

/* Stem waveform styling */
.stem-section {
    margin-bottom: 20px;
    border: 1px solid #495057;
    border-radius: 8px;
    background-color: #2c3136;
    padding: 15px;
}

.stem-section:last-child {
    margin-bottom: 0;
}

.stem-header {
    margin-bottom: 10px;
    text-align: center;
}

.stem-header .waveform-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: #f8f9fa;
    background-color: rgba(33, 37, 41, 0.7);
    padding: 8px 15px;
    border-radius: 6px;
    margin-bottom: 0;
}

.waveform-sublabel {
    font-size: 0.9rem;
    color: #adb5bd;
    text-align: center;
    margin-bottom: 5px;
    font-weight: 500;
}

/* Adjust stem waveform container */
#stem-waveform-container {
    height: auto; /* Auto height for stem sections */
    flex-direction: column;
    gap: 0;
}

/* Stem waveform track groups */
#stem-waveform-container .waveform-track-group {
    height: 80px; /* Smaller height for stem waveforms */
    margin-bottom: 10px;
}

#stem-waveform-container .waveform-track-group:last-child {
    margin-bottom: 0;
}

#stem-waveform-container canvas {
    height: 60px; /* Smaller canvas height for stems */
}