/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #1a1a1e;
    --bg2:       #242428;
    --bg3:       #2e2e33;
    --border:    #3a3a42;
    --accent:    #4488ff;
    --accent2:   #2266dd;
    --red:       #ff4444;
    --green:     #44cc88;
    --text:      #e8e8ec;
    --text2:     #9898a8;
    --radius:    6px;
    --sidebar-w: 320px;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
    line-height: 1.5;
    overflow: hidden;
}

/* ─── Layout ────────────────────────────────────────────────────────────────── */
#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Left: video area */
#video-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0d0d10;
    position: relative;
    overflow: hidden;
}

#video-header {
    height: 40px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 8px;
    font-size: 12px;
    color: var(--text2);
    flex-shrink: 0;
}

#video-header .logo {
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.5px;
}

#video-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#video-player {
    max-width: 100%;
    max-height: 100%;
    display: block;
    background: #000;
}

#canvas-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    cursor: crosshair;
    pointer-events: all;
}

#video-placeholder {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text2);
    pointer-events: none;
}

#video-placeholder .icon {
    font-size: 56px;
    opacity: 0.3;
}

#video-placeholder p {
    font-size: 14px;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────────── */
#sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg2);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-section {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child { border-bottom: none; }

.section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text2);
    margin-bottom: 10px;
}

/* ─── Upload ────────────────────────────────────────────────────────────────── */
#btn-upload {
    width: 100%;
    padding: 10px;
    background: var(--bg3);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
    transition: border-color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#btn-upload:hover {
    border-color: var(--accent);
    background: var(--bg3);
    color: var(--accent);
}

/* ─── Mode tabs ─────────────────────────────────────────────────────────────── */
.tab-row {
    display: flex;
    gap: 4px;
    background: var(--bg3);
    padding: 3px;
    border-radius: var(--radius);
}

.mode-tab {
    flex: 1;
    padding: 6px 4px;
    background: transparent;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    color: var(--text2);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
}

.mode-tab.active {
    background: var(--accent);
    color: #fff;
}

.mode-tab:hover:not(.active) {
    background: var(--border);
    color: var(--text);
}

/* ─── Controls ──────────────────────────────────────────────────────────────── */
.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.control-row:last-child { margin-bottom: 0; }

.control-label {
    color: var(--text2);
    font-size: 12px;
}

select {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 5px 8px;
    font-size: 12px;
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    min-width: 90px;
}

select:focus { border-color: var(--accent); }

/* ─── Slider ────────────────────────────────────────────────────────────────── */
.slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.slider-row:last-child { margin-bottom: 0; }

input[type=range] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--bg3);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.2); }

.slider-val {
    width: 36px;
    text-align: right;
    color: var(--text2);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

/* ─── Checkbox ──────────────────────────────────────────────────────────────── */
.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.check-row:last-child { margin-bottom: 0; }

input[type=checkbox] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.check-row label { cursor: pointer; font-size: 12px; }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--radius);
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 8px;
}

.btn:last-child { margin-bottom: 0; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:not(:disabled):hover { opacity: 0.88; }
.btn:not(:disabled):active { transform: scale(0.98); }

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-success {
    background: var(--green);
    color: #111;
}

.btn-secondary {
    background: var(--bg3);
    color: var(--text);
    border: 1px solid var(--border);
}

/* ─── Progress ──────────────────────────────────────────────────────────────── */
#progress-wrap {
    display: none;
    margin-top: 10px;
}

#progress-track {
    height: 6px;
    background: var(--bg3);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}

#progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent2), var(--accent));
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s;
}

#progress-text {
    font-size: 11px;
    color: var(--text2);
    text-align: center;
}

/* ─── Status message ────────────────────────────────────────────────────────── */
.status-msg {
    font-size: 12px;
    color: var(--text2);
    padding: 8px 10px;
    background: var(--bg3);
    border-radius: var(--radius);
    border-left: 3px solid var(--accent);
    line-height: 1.4;
}

.status-msg.error {
    border-left-color: var(--red);
    color: #ff8888;
}

/* ─── Download link ─────────────────────────────────────────────────────────── */
#download-link {
    display: none;
    width: 100%;
    padding: 9px 12px;
    background: var(--green);
    color: #111;
    border-radius: var(--radius);
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    margin-top: 8px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: opacity 0.15s;
}

#download-link:hover { opacity: 0.85; }

/* ─── Video controls strip ──────────────────────────────────────────────────── */
#video-controls {
    height: 38px;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 10px;
    flex-shrink: 0;
}

#video-controls button {
    background: none;
    border: none;
    color: var(--text2);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.1s, background 0.1s;
}

#video-controls button:hover {
    color: var(--text);
    background: var(--bg3);
}

#seek-bar {
    flex: 1;
    height: 4px;
    background: var(--bg3);
    border-radius: 2px;
    cursor: pointer;
    appearance: none;
    outline: none;
}

#seek-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
}

#time-display {
    font-size: 11px;
    color: var(--text2);
    font-variant-numeric: tabular-nums;
    min-width: 80px;
    text-align: right;
}

/* ─── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text2); }

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
    #app { flex-direction: column; }
    #video-area { height: 55vh; }
    #sidebar { width: 100%; height: 45vh; flex-direction: row; flex-wrap: wrap; overflow-y: auto; }
    .sidebar-section { flex: 1; min-width: 200px; }
}
