/* ═══════════════════════════════════════════════════
   Shadow Capture Studio — 2026
   ═══════════════════════════════════════════════════ */

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

:root {
    --bg-0: #09090b;
    --bg-1: #111318;
    --bg-2: #1a1d28;
    --bg-3: #242836;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99,102,241,.22);
    --accent-glow-strong: rgba(99,102,241,.45);
    --red: #ef4444;
    --red-glow: rgba(239,68,68,.3);
    --green: #22c55e;
    --green-dim: rgba(34,197,94,.12);
    --text-1: #f4f4f5;
    --text-2: #a1a1aa;
    --text-3: #52525b;
    --border: #27272a;
    --border-light: #3f3f46;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --ease: cubic-bezier(.4,0,.2,1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-0);
    color: var(--text-1);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.studio {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ─── Header ─────────────────────────────────────── */

.studio-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .65rem 1.25rem;
    background: var(--bg-1);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.studio-logo {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -.02em;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.studio-status {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .75rem;
    color: var(--text-3);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

#systemStatus { font-weight: 500; }

/* ─── Main Layout ────────────────────────────────── */

.studio-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* ─── Capture Column ─────────────────────────────── */

.capture-col {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.camera-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
}

.camera-viewport {
    position: relative;
}

/* View toggle — overlaid on camera */
.view-toggle {
    position: absolute;
    top: .6rem;
    right: .6rem;
    z-index: 20;
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: 8px;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,.08);
}

.view-btn {
    padding: .3rem .65rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: rgba(255,255,255,.55);
    font-size: .72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms var(--ease);
    letter-spacing: .01em;
}

.view-btn:hover { color: rgba(255,255,255,.85); }

.view-btn.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px var(--accent-glow);
}

/* Video container */
.video-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
}

.video-container.recording {
    box-shadow: inset 0 0 0 3px var(--red), 0 0 30px var(--red-glow);
}

#webcam,
#overlayCanvas,
#skeletonBackCanvas,
#head3dCanvas,
#skeletonFrontCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#webcam { z-index: 1; }
#overlayCanvas { z-index: 2; }
#skeletonBackCanvas { z-index: 2; background: #000; }
#head3dCanvas { z-index: 3; pointer-events: none; }
#skeletonFrontCanvas { z-index: 4; pointer-events: none; }

/* Recording badge */
.rec-badge {
    position: absolute;
    top: .6rem;
    left: .6rem;
    background: rgba(185,28,28,.92);
    padding: .3rem .7rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: .4rem;
    z-index: 10;
    font-weight: 600;
    font-size: .78rem;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 12px rgba(185,28,28,.5);
}

.rec-dot {
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    animation: blink 1s infinite;
}

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.2} }

.rec-label {
    font-size: .68rem;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.rec-time {
    font-family: 'JetBrains Mono','SF Mono','Fira Code',monospace;
    font-size: .78rem;
    min-width: 3em;
    text-align: right;
}

/* Countdown */
.countdown-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.35);
    backdrop-filter: blur(4px);
}

.countdown-num {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    font-weight: 700;
    color: #fff;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 50px var(--accent-glow-strong);
    animation: pop .45s var(--ease);
    line-height: 1;
}

@keyframes pop { 0%{transform:scale(.4);opacity:0} 60%{transform:scale(1.12)} 100%{transform:scale(1);opacity:1} }

/* Toast */
.toast-message {
    display: none;
    position: absolute;
    bottom: .6rem;
    left: 50%;
    transform: translateX(-50%);
    padding: .35rem .9rem;
    border-radius: 8px;
    z-index: 10;
    font-weight: 600;
    font-size: .8rem;
    white-space: nowrap;
    backdrop-filter: blur(8px);
    background: rgba(34,197,94,.88);
    color: #fff;
}

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

.capture-controls {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: .75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.settings-row {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.setting {
    display: flex;
    align-items: center;
    gap: .4rem;
}

.setting-label {
    font-size: .75rem;
    font-weight: 500;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.setting-val {
    display: flex;
    align-items: center;
    gap: .15rem;
}

.setting-val input[type="number"] {
    width: 3.2rem;
    padding: .3rem .4rem;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-1);
    font-size: .85rem;
    text-align: center;
    font-family: inherit;
}

.setting-val input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.setting-unit {
    font-size: .75rem;
    color: var(--text-3);
}

.mode-setting { flex: 1; display: flex; justify-content: center; }

.mode-toggle {
    display: flex;
    background: var(--bg-3);
    border-radius: 6px;
    padding: 2px;
    gap: 2px;
}

.mode-opt {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.mode-opt input { display: none; }

.mode-opt span {
    display: block;
    padding: .25rem .6rem;
    font-size: .75rem;
    font-weight: 500;
    color: var(--text-3);
    border-radius: 5px;
    transition: all 150ms var(--ease);
}

.mode-opt input:checked + span {
    background: var(--bg-1);
    color: var(--text-1);
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

/* Record button */
.record-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    padding: .7rem 1.5rem;
    border: none;
    border-radius: var(--r-sm);
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #fff;
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: .01em;
    transition: all 200ms var(--ease);
    box-shadow: 0 4px 16px var(--red-glow);
    animation: pulse-record 2.5s ease-in-out infinite;
}

.record-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(239,68,68,.45);
    animation: none;
}

@keyframes pulse-record {
    0%, 100% { box-shadow: 0 4px 16px var(--red-glow); }
    50% { box-shadow: 0 4px 24px rgba(239,68,68,.55); }
}

.record-btn-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 8px rgba(255,255,255,.5);
}

.stop-btn {
    width: 100%;
    padding: .7rem 1.5rem;
    border: 2px solid var(--red);
    border-radius: var(--r-sm);
    background: rgba(239,68,68,.12);
    color: var(--red);
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 200ms var(--ease);
}

.stop-btn:hover {
    background: rgba(239,68,68,.2);
}

/* ─── Editor Column ──────────────────────────────── */

.editor-col {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.editor-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: fadeSlideIn .35s var(--ease);
}

@keyframes fadeSlideIn {
    0% { opacity: 0; transform: translateY(12px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Editor preview */
.editor-preview { }

#previewCanvas {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    display: block;
}

/* Transport bar */
.transport {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem 0;
}

.transport-left {
    display: flex;
    gap: 2px;
}

.t-btn {
    width: 34px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-2);
    color: var(--text-2);
    font-size: .85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 150ms var(--ease);
}

.t-btn:hover:not(:disabled) { background: var(--bg-3); color: var(--text-1); }

.t-btn.t-play { color: var(--accent-light); }

.t-btn:disabled { opacity: .35; cursor: default; }

.loop-check {
    display: flex;
    align-items: center;
    gap: .3rem;
    font-size: .78rem;
    color: var(--text-3);
    cursor: pointer;
    margin-left: .25rem;
}

.loop-check input { accent-color: var(--accent); cursor: pointer; }

.transport-right {
    margin-left: auto;
    display: flex;
    align-items: baseline;
    gap: .5rem;
}

.t-time {
    font-family: 'JetBrains Mono','SF Mono',monospace;
    font-size: .8rem;
    color: var(--text-1);
    font-weight: 600;
}

.t-fps {
    font-size: .7rem;
    color: var(--text-3);
    font-family: 'JetBrains Mono','SF Mono',monospace;
}

/* ─── Visual Timeline ────────────────────────────── */

.timeline {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.timeline-track {
    position: relative;
    height: 28px;
    background: var(--bg-3);
    border-radius: 6px;
    overflow: visible;
}

.timeline-active {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--accent-glow), rgba(99,102,241,.1));
    border-radius: 6px;
    pointer-events: none;
    transition: left 100ms, width 100ms;
}

.timeline-marker {
    position: absolute;
    top: -2px;
    width: 3px;
    height: calc(100% + 4px);
    border-radius: 2px;
    z-index: 2;
    pointer-events: none;
    transition: left 100ms;
}

.tl-in { background: var(--accent); left: 0; }
.tl-out { background: var(--accent); left: 100%; }

.timeline-scrubber {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    appearance: none;
    background: transparent;
    cursor: pointer;
    z-index: 3;
}

.timeline-scrubber::-webkit-slider-thumb {
    appearance: none;
    width: 4px;
    height: 32px;
    background: #fff;
    border-radius: 2px;
    cursor: grab;
    box-shadow: 0 0 8px rgba(255,255,255,.3);
}

.timeline-scrubber::-moz-range-thumb {
    width: 4px;
    height: 32px;
    background: #fff;
    border-radius: 2px;
    cursor: grab;
    border: none;
    box-shadow: 0 0 8px rgba(255,255,255,.3);
}

.timeline-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.marker-btn {
    padding: .3rem .65rem;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: var(--bg-2);
    color: var(--text-2);
    font-size: .72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms var(--ease);
    letter-spacing: .02em;
}

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

.frame-counter {
    font-family: 'JetBrains Mono','SF Mono',monospace;
    font-size: .75rem;
    color: var(--text-3);
}

.frame-counter strong { color: var(--text-2); }

.trim-row {
    display: flex;
    gap: .4rem;
}

.trim-apply {
    flex: 1;
    padding: .35rem .75rem;
    border: none;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms var(--ease);
}

.trim-apply:hover { background: var(--accent-light); }

.trim-reset {
    padding: .35rem .75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-3);
    font-size: .78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms var(--ease);
}

.trim-reset:hover { color: var(--text-2); border-color: var(--border-light); }

/* ─── Submit Area ────────────────────────────────── */

.submit-area {
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.meta-fields {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.meta-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .4rem;
}

.meta-input {
    width: 100%;
    padding: .5rem .7rem;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-1);
    font-size: .85rem;
    font-family: inherit;
    transition: border-color 150ms var(--ease);
}

.meta-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.meta-input::placeholder { color: var(--text-3); }

.submit-btns {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .4rem;
}

.upload-btn {
    padding: .6rem 1rem;
    border: none;
    border-radius: var(--r-sm);
    background: var(--accent);
    color: #fff;
    font-size: .85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 150ms var(--ease);
    box-shadow: 0 2px 8px var(--accent-glow);
}

.upload-btn:hover:not(:disabled) {
    background: var(--accent-light);
    box-shadow: 0 4px 16px var(--accent-glow);
    transform: translateY(-1px);
}

.upload-btn:disabled { opacity: .4; cursor: default; transform: none; }

.export-btn {
    padding: .6rem 1rem;
    border: 1px solid var(--border-light);
    border-radius: var(--r-sm);
    background: var(--bg-2);
    color: var(--text-2);
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms var(--ease);
    white-space: nowrap;
}

.export-btn:hover { border-color: var(--text-3); color: var(--text-1); }

.upload-status {
    min-height: 0;
    font-size: .8rem;
    color: var(--text-3);
    line-height: 1.4;
    transition: all 200ms var(--ease);
}

.upload-status:empty { display: none; }

.upload-status.success {
    color: var(--green);
    padding: .5rem .7rem;
    background: var(--green-dim);
    border-radius: 6px;
    border: 1px solid rgba(34,197,94,.2);
}

.upload-status.error {
    color: #f87171;
    padding: .5rem .7rem;
    background: rgba(239,68,68,.08);
    border-radius: 6px;
    border: 1px solid rgba(239,68,68,.15);
}

.upload-status.info { color: var(--text-3); }

.new-rec-btn {
    width: 100%;
    padding: .55rem 1rem;
    border: 1px dashed var(--border-light);
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-3);
    font-size: .82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms var(--ease);
}

.new-rec-btn:hover { border-color: var(--text-3); color: var(--text-2); }

/* ─── Onboarding ─────────────────────────────────── */

.onboarding {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1.5rem 0;
}

.onboarding-inner {
    max-width: 420px;
    padding: 0 1rem;
}

.onboarding h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-light);
    letter-spacing: -.02em;
    margin-bottom: .35rem;
}

.onboarding-lead {
    font-size: .88rem;
    color: var(--text-3);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.info-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 1rem 1.15rem;
    margin-bottom: .75rem;
}

.info-card h3 {
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-1);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: .6rem;
}

.info-card ul,
.info-card ol {
    color: var(--text-2);
    line-height: 1.7;
    padding-left: 1.15rem;
    font-size: .84rem;
}

.info-card li { margin-bottom: .4rem; }

.info-card a {
    color: var(--accent-light);
    text-decoration: none;
    transition: color 150ms;
}

.info-card a:hover { color: #a5b4fc; }

/* ─── Cross-link ─────────────────────────────────── */

.cross-link {
    font-size: .72rem;
    font-weight: 600;
    color: var(--accent-light);
    text-decoration: none;
    padding: .2rem .5rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    margin-right: .5rem;
    transition: all 150ms var(--ease);
}

.cross-link:hover {
    background: var(--accent-glow);
}

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

/* Tablet — stack columns */
@media (max-width: 960px) {
    .studio-body {
        grid-template-columns: 1fr;
        max-width: 640px;
    }
}

/* Phone — compact everything */
@media (max-width: 600px) {
    .studio-header { padding: .5rem .75rem; }
    .studio-logo { font-size: .88rem; }

    .studio-body {
        padding: .5rem;
        gap: .5rem;
    }

    .camera-card { border-radius: var(--r-md); }

    .view-toggle {
        top: .4rem;
        right: .4rem;
        padding: 2px;
    }

    .view-btn {
        padding: .25rem .5rem;
        font-size: .68rem;
    }

    .capture-controls {
        padding: .6rem .75rem;
        border-radius: var(--r-sm);
    }

    .settings-row {
        flex-wrap: wrap;
        gap: .5rem;
    }

    .setting-label { font-size: .68rem; }

    .record-btn {
        padding: .65rem 1rem;
        font-size: .88rem;
    }

    .editor-card {
        padding: .75rem;
        border-radius: var(--r-md);
        gap: .75rem;
    }

    .meta-row-2 { grid-template-columns: 1fr; }
    .submit-btns { grid-template-columns: 1fr; }

    .onboarding { padding: 1rem 0; }
    .onboarding h2 { font-size: 1.1rem; }
    .info-card { padding: .85rem; }
}

/* Tracking toggles (2026-07-03) — choose which trackers run; fewer = higher capture FPS */
.track-row {
    margin-top: .5rem;
    gap: .5rem;
}

.track-toggle {
    display: flex;
    background: var(--bg-3);
    border-radius: 6px;
    padding: 2px;
    gap: 2px;
}

.track-opt {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.track-opt input { display: none; }

.track-opt span {
    display: block;
    padding: .25rem .6rem;
    font-size: .75rem;
    font-weight: 500;
    color: var(--text-3);
    border-radius: 5px;
    transition: all 150ms var(--ease);
}

.track-opt input:checked + span {
    background: var(--bg-1);
    color: var(--text-1);
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

.track-locked {
    cursor: default;
}

.track-locked span {
    background: var(--bg-1);
    color: var(--text-1);
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
    opacity: .75;
}

.track-hint {
    font-size: .7rem;
    color: var(--text-3);
    margin-left: auto;
}
