:root {
    --background-color: #121212;
    --surface-color: #1e1e1e;
    --primary-color: #bb86fc;
    --primary-variant-color: #3700b3;
    --secondary-color: #03dac6;
    --on-surface-color: #ffffff;
    --on-surface-secondary-color: #b3b3b3;
    --slider-track-color: #333;
    --border-radius: 12px;
}

#video-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    overflow: hidden;
}

#video-background video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.4); /* Darken video to make UI text more readable */
}

#visualizer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    filter: blur(0px);
    opacity: 0.5;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    background-color: var(--background-color);
    color: var(--on-surface-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
}

#app {
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

header h1 {
    margin: 0;
    font-size: 2rem;
    color: var(--on-surface-color);
}

header p {
    color: var(--on-surface-secondary-color);
    margin-top: 0.5rem;
}

.card {
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    transition: all 0.3s ease;
}

.hidden {
    display: none !important;
}

#upload-box {
    border: 2px dashed var(--slider-track-color);
    cursor: pointer;
}

#upload-box:hover {
    border-color: var(--primary-color);
    background-color: #2a2a2a;
}

#upload-box.dragging {
    border-color: var(--secondary-color);
    background-color: #2a2a2a;
    transform: scale(1.02);
}

#upload-box img {
    margin-bottom: 1rem;
    filter: grayscale(1) brightness(2);
}

#upload-box p {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.button {
    background-color: var(--primary-color);
    color: #000;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.button.secondary {
    background-color: var(--surface-color);
    color: var(--on-surface-secondary-color);
    border: 1px solid var(--slider-track-color);
}

.button.secondary:hover:not(:disabled) {
    background-color: #2a2a2a;
    border-color: var(--primary-color);
    color: var(--on-surface-color);
}

.button:hover:not(:disabled) {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
}

.button:disabled {
    background-color: #333;
    color: #777;
    cursor: not-allowed;
    transform: none;
}

.icon-button {
    padding: 12px;
    border-radius: 50%;
}

.icon-button img {
    width: 20px;
    height: 20px;
    display: block;
}

#player-box {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

#file-info {
    color: var(--on-surface-secondary-color);
    font-size: 0.9rem;
    margin: -1rem 0 0; /* Adjust positioning */
    min-height: 1.2em; /* Prevent layout shift */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#media-player video,
#media-player audio {
    width: 100%;
    border-radius: 8px;
    display: block;
}

#controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

#presets {
    grid-column: 1 / -1; /* Span full width */
    text-align: left;
}

.preset-buttons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

#presets .preset-button {
    padding: 8px 16px;
    font-size: 0.9rem;
}

#presets .preset-button.active {
    background-color: var(--primary-color);
    color: #000;
    border-color: var(--primary-color);
}

.noUi-target[disabled] .noUi-connect {
    background: #555;
}

.noUi-target[disabled] .noUi-handle {
    background: #777;
    cursor: not-allowed;
}

.control-group {
    text-align: left;
}

.control-group label {
    display: block;
    margin-bottom: 10px;
    color: var(--on-surface-secondary-color);
}

.control-group span {
    float: right;
    color: var(--on-surface-color);
    font-weight: bold;
}

.volume-toggle-container {
    margin-top: 10px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.volume-toggle-container label {
    margin-bottom: 0;
    cursor: pointer;
    user-select: none;
}

.volume-toggle-container input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--primary-color);
}

#actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.download-notice {
    font-size: 0.8rem;
    color: var(--on-surface-secondary-color);
    margin-top: 1rem;
}

/* noUiSlider custom styles */
.noUi-target {
    background: var(--slider-track-color);
    border-radius: 4px;
    border: none;
    box-shadow: none;
    height: 8px;
}

.noUi-connect {
    background: var(--primary-color);
}

.noUi-horizontal .noUi-handle {
    width: 20px;
    height: 20px;
    right: -10px;
    top: -6px;
    border-radius: 50%;
    border: none;
    background: var(--on-surface-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
    cursor: grab;
}

.noUi-handle:focus {
    outline: none;
}

.noUi-handle::after, .noUi-handle::before {
    display: none;
}

/* Spinner animation */
.spinner {
    width: 18px;
    height: 18px;
    border: 3px solid rgba(0, 0, 0, 0.3);
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

footer {
    color: var(--on-surface-secondary-color);
    font-size: 0.9rem;
}

footer .credit {
    margin-top: 0.5em;
    font-size: 0.8rem;
}