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

:root {
    --bg: #1a1a2e;
    --surface: rgba(30,30,60,0.92);
    --surface2: rgba(40,40,80,0.85);
    --text: #e0e0ff;
    --text2: #a0a0cc;
    --accent: #7c6bf5;
    --accent2: #5a4bd8;
    --danger: #f56b6b;
    --success: #6bf5a0;
    --border: rgba(124,107,245,0.3);
    --shadow: 0 4px 24px rgba(0,0,0,0.5);
    --radius: 12px;
    --radius-sm: 8px;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

#app {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#viewport {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: #000;
    touch-action: none;
}

#viewport video,
#viewport canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#camera-feed {
    z-index: 1;
}

#main-canvas {
    z-index: 2;
    pointer-events: auto;
    image-rendering: auto;
}

#grid-canvas {
    z-index: 3;
    pointer-events: none;
}

#draw-canvas {
    z-index: 4;
    cursor: crosshair;
    touch-action: none;
}

#guide-canvas {
    z-index: 5;
    pointer-events: none;
}

#transform-container {
    position: absolute;
    z-index: 2;
    pointer-events: none;
}

#transform-container img,
#transform-container canvas.layer-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.btn:active {
    transform: scale(0.96);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    font-size: 18px;
}

.btn-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-active {
    background: var(--accent);
    border-color: var(--accent);
}

input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    outline: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg);
}

input[type=range]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg);
}

select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    color: var(--text);
    font-size: 13px;
    outline: none;
}

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

.flex-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gap-sm { gap: 4px; }
.gap-md { gap: 10px; }

.text-sm { font-size: 12px; color: var(--text2); }
.text-center { text-align: center; }

.w-full { width: 100%; }

.hidden { display: none !important; }
