body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    background-color: #1a1a1a;
    color: #e0e0e0;
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

h1 {
    text-align: center;
    font-weight: normal;
    color: #f0f0f0;
    margin-bottom: 30px;
}

/* Controls */
#controls-container {
    background: #2a2a2a;
    border: 1px solid #444;
    padding: 15px;
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

label {
    font-size: 0.9rem;
    color: #aaa;
}

/* Tab Container */
.tab-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 200px;
}

.tabs {
    display: flex;
    gap: 2px;
    background: #333;
    padding: 2px;
    border-radius: 3px;
    border: 1px solid #555;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: #aaa;
    padding: 5px;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 2px;
    transition: background 0.2s;
}

.tab-btn:hover {
    background: #444;
}

.tab-btn.active {
    background: #444;
    color: #eee;
}

.tab-content {
    display: none;
    background: #333;
    border: 1px solid #555;
    border-radius: 3px;
    padding: 5px;
    max-height: 120px;
    overflow-y: auto;
}

.tab-content.active {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3px;
}

.algorithm-btn {
    background: #444;
    border: 1px solid #555;
    color: #eee;
    padding: 5px;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 2px;
    text-align: left;
    transition: background 0.2s;
}

.algorithm-btn:hover {
    background: #555;
}

.algorithm-btn.active {
    background: #005bb5;
    color: white;
    border-color: #004a94;
}

select,
input[type="range"] {
    cursor: pointer;
}

select {
    padding: 5px;
    border: 1px solid #555;
    border-radius: 3px;
    background: #333;
    color: #eee;
}

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

button {
    background-color: #444;
    border: 1px solid #555;
    color: #eee;
    padding: 6px 12px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    cursor: pointer;
    border-radius: 3px;
}

button:hover {
    background-color: #555;
}

button:active {
    background-color: #333;
}

button.primary-btn {
    background-color: #005bb5;
    color: white;
    border-color: #004a94;
}

button.primary-btn:hover {
    background-color: #004a94;
}

button:disabled {
    opacity: 0.5;
    cursor: default;
    background-color: #333;
    color: #777;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 5px;
}

.checkbox-wrapper input {
    margin: 0;
}

.separator {
    width: 1px;
    height: 20px;
    background: #444;
    margin: 0 5px;
}

/* Stats */
#stats-container {
    margin: 20px auto;
    max-width: 800px;
    text-align: center;
}

#stats-display {
    display: flex;
    justify-content: center;
    gap: 30px;
    font-family: monospace;
    font-size: 1.1em;
    background: #2a2a2a;
    padding: 10px;
    border: 1px solid #444;
    border-radius: 3px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-item div:first-child {
    font-size: 0.8em;
    color: #888;
    text-transform: uppercase;
}

/* Visualizer */
#visualizer-container {
    height: 500px;
    max-width: 1000px;
    margin: 0 auto;
    background-color: #222;
    border: 1px solid #444;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 10px;
    overflow: hidden;
}

.bar {
    background-color: #6495ed;
    /* Cornflower blue */
    width: 10px;
    margin: 0 1px;
    transition: height 0.1s ease;
}

/* States */
.bar.compare {
    background-color: #ffd700;
    /* Gold */
}

.bar.swap {
    background-color: #ff4500;
    /* OrangeRed */
}

.bar.sorted {
    background-color: #32cd32;
    /* LimeGreen */
}

/* Utils */
.no-transition .bar {
    transition: none !important;
}

.no-colors .bar {
    background-color: #6495ed !important;
}

.no-colors .bar.sorted {
    background-color: #32cd32 !important;
}

/* Toast */
#toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 255, 255, 0.9);
    color: #111;
    padding: 12px 24px;
    border-radius: 4px;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
}

#toast.show {
    visibility: visible;
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #controls-container {
        flex-direction: column;
        align-items: stretch;
    }

    .button-group {
        flex-wrap: wrap;
        justify-content: center;
    }

    #visualizer-container {
        height: 300px;
    }
}

/* Slider Tooltip */
.slider-tooltip {
    position: fixed;
    background-color: rgba(255, 255, 255, 0.95);
    color: #000;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    pointer-events: none;
    z-index: 2000;
    transform: translate(-50%, -150%);
    /* Moves it up above the cursor */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    display: none;
    white-space: nowrap;
    border: 1px solid #ccc;
}