*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    user-select: none;
    -webkit-user-select: none;
}

/* ── Header ── */

#header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
}

#header h1 {
    font-size: 0.95rem;
    font-weight: 600;
    flex: 1;
}

/* ── Buttons ── */

button {
    padding: 7px 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.15s;
}

#btn-capture            { background: #3b82f6; color: #fff; }
#btn-capture:hover      { background: #2563eb; }
#btn-capture.stop       { background: #ef4444; }
#btn-capture.stop:hover { background: #dc2626; }

#btn-project                    { background: #10b981; color: #fff; }
#btn-project:hover:not(:disabled) { background: #059669; }
#btn-project:disabled           { background: #334155; color: #64748b; cursor: not-allowed; }

/* ── Main area ── */

#main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #060d1a;
}

#placeholder {
    text-align: center;
    color: #475569;
    pointer-events: none;
    line-height: 1.8;
}

#placeholder strong { color: #7dd3fc; }

/* ── Video wrapper ── */

#video-wrapper {
    position: relative;
    display: none;
    line-height: 0;
}

video {
    display: block;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 108px);
}

/* ── Dark overlays (4 strips around the selection) ── */

.ovl {
    position: absolute;
    background: rgba(0, 0, 0, 0.65);
    pointer-events: none;
    z-index: 5;
}

/* ── Selection box ── */

#selection {
    position: absolute;
    border: 2px solid #38bdf8;
    cursor: move;
    z-index: 10;
}

/* Dimension label floating above the selection */
#sel-label {
    position: absolute;
    bottom: calc(100% + 5px);
    left: 0;
    background: #0f172a;
    color: #7dd3fc;
    font-size: 0.7rem;
    font-family: monospace;
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    border: 1px solid #1e3a5f;
}

/* ── Resize handles ── */

.handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #38bdf8;
    border-radius: 2px;
    z-index: 11;
}

.handle-nw { top: -5px;             left: -5px;            cursor: nw-resize; }
.handle-n  { top: -5px;             left: calc(50% - 5px); cursor: n-resize;  }
.handle-ne { top: -5px;             right: -5px;           cursor: ne-resize; }
.handle-e  { top: calc(50% - 5px);  right: -5px;           cursor: e-resize;  }
.handle-se { bottom: -5px;          right: -5px;           cursor: se-resize; }
.handle-s  { bottom: -5px;          left: calc(50% - 5px); cursor: s-resize;  }
.handle-sw { bottom: -5px;          left: -5px;            cursor: sw-resize; }
.handle-w  { top: calc(50% - 5px);  left: -5px;            cursor: w-resize;  }

/* ── Status bar ── */

#statusbar {
    display: flex;
    gap: 24px;
    padding: 5px 16px;
    background: #1e293b;
    border-top: 1px solid #334155;
    font-size: 0.75rem;
    color: #64748b;
    flex-shrink: 0;
}
