:root {
    --bg-color: #121214;
    --text-color: #e4e4e7;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --panel-bg: #1f1f22;
    --border-color: #333338;
    --seekbar-track: #3f3f46;
    --seekbar-progress: #3b82f6;
    --seekbar-thumb: #e4e4e7;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

.header {
    width: 100%;
    padding: 1.5rem 0;
    text-align: center;
    background: linear-gradient(180deg, #1f1f24, #121214);
    border-bottom: 1px solid var(--border-color);
}

h1 { margin: 0; font-size: 2rem; font-weight: 600; letter-spacing: -0.02em; }

/* ─── Controls ────────────────────────────────────── */

.controls {
    margin: 2rem 0 0.75rem 0;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    background: var(--panel-bg);
    padding: 1rem 2rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    flex-wrap: wrap;
    justify-content: center;
}

.btn, button {
    background-color: var(--accent-color);
    color: white;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn:hover, button:hover:not(:disabled) {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

button:disabled {
    background-color: #4b5563;
    color: #9ca3af;
    cursor: not-allowed;
}

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

input[type="number"] {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem;
    width: 100px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* ─── Playback Controls ──────────────────────────── */

.playback-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: calc(100% - 4rem);
    max-width: calc(1400px - 4rem);
    padding: 0.75rem 1.5rem;
    box-sizing: border-box;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 1.25rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.play-pause-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent-color);
    transition: all 0.2s ease;
}

.play-pause-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: scale(1.1);
    box-shadow: 0 0 16px rgba(59, 130, 246, 0.4);
}

.play-pause-btn:disabled {
    background: #4b5563;
    transform: none;
    box-shadow: none;
}

.time-label {
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.85rem;
    color: #a1a1aa;
    min-width: 42px;
    text-align: center;
    user-select: none;
}

.seekbar-wrapper {
    flex: 1;
    position: relative;
    height: 28px;
    display: flex;
    align-items: center;
}

.seek-bar {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--seekbar-track);
    outline: none;
    cursor: pointer;
    position: relative;
    z-index: 2;
    margin: 0;
}

.seek-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--seekbar-thumb);
    cursor: pointer;
    box-shadow: 0 0 6px rgba(0,0,0,0.5);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.seek-bar::-webkit-slider-thumb:hover {
    transform: scale(1.25);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
}

.seek-bar::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--seekbar-thumb);
    border: none;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(0,0,0,0.5);
}

.seekbar-progress {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 6px;
    border-radius: 3px;
    background: var(--seekbar-progress);
    pointer-events: none;
    z-index: 1;
    width: 0%;
    transition: width 0.05s linear;
}

/* ─── Buffering Indicator ────────────────────────── */

.buffering-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent-color);
    font-weight: 600;
    padding: 0.6rem 1.5rem;
    margin: 0 auto 0.75rem auto;
    border-radius: 8px;
    border: 1px solid rgba(59, 130, 246, 0.2);
    font-size: 0.9rem;
}

.buffering-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(59, 130, 246, 0.3);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ─── Comparison Panels ──────────────────────────── */

.comparison-container {
    display: flex;
    gap: 2rem;
    width: 100%;
    max-width: 1400px;
    justify-content: center;
    padding: 0 2rem 2rem 2rem;
    box-sizing: border-box;
}

.panel {
    background: var(--panel-bg);
    padding: 1.5rem;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    flex: 1;
}

.panel h2 { 
    margin: 0 0 1rem 0; 
    color: #f4f4f5; 
    font-weight: 500; 
    font-size: 1.25rem;
}

.codec-label {
    font-size: 0.85rem;
    font-weight: 400;
    color: #71717a;
}

canvas {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: contain;
    background: #000;
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}

.stats {
    margin-top: 1rem;
    width: 100%;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9rem;
    color: #10b981;
    box-sizing: border-box;
}

/* ─── Responsive ─────────────────────────────────── */

@media (max-width: 900px) {
    .comparison-container {
        flex-direction: column;
        gap: 1rem;
    }
    .controls {
        flex-direction: column;
        gap: 0.75rem;
    }
}
