/* --- Design Tokens --- */
:root {
    --bg-color: #000000;
    --text-main: #FFFFFF;
    --text-dim: #888888;
    --surface: #000000;
    --surface-container: #111111;
    --surface-hover: #1A1A1A;
    --outline: #333333;
    --accent: #FFFFFF;
    --radius-lg: 24px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --font-main: 'Roboto', sans-serif;
    --font-mono: 'Space Mono', monospace;
    /* MD3 Easing - Emphasized */
    --ease-md3: cubic-bezier(0.2, 0.0, 0, 1.0);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden; /* Prevent scroll on tracking view */
    display: flex;
    justify-content: center;
}

/* --- Fixed Background --- */
.ambient-glow {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.08) 0%, rgba(0,0,0,0) 60%);
    z-index: -1; pointer-events: none;
}

.app-container {
    width: 100%; max-width: 1400px; height: 100vh;
    display: flex; flex-direction: column; padding: 1.5rem;
    position: relative; z-index: 1;
}

/* --- Header --- */
.top-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 0 1rem 0; flex: 0 0 auto;
}

.home-link { text-decoration: none; color: inherit; cursor: pointer; transition: opacity 0.2s ease; }
.home-link:hover { opacity: 0.7; }

.logo-section h1 {
    font-family: var(--font-mono); font-size: 1.1rem; font-weight: 400;
    color: var(--text-dim); letter-spacing: -0.5px; margin: 0;
}
.logo-section .highlight {
    color: var(--text-main); font-weight: 700;
    text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px;
}

.status-badge {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.75rem; font-family: var(--font-mono); color: var(--text-dim);
    border: 1px solid var(--outline); padding: 6px 12px;
    border-radius: 50px; background: rgba(0,0,0,0.5); backdrop-filter: blur(5px);
    min-width: 120px; justify-content: center;
}

.live-dot {
    width: 6px; height: 6px; background-color: #333;
    border-radius: 50%; transition: background-color 0.3s, box-shadow 0.3s;
}

.live-dot.active {
    background-color: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.9); }
}

/* --- Main Viewport (3D Context) --- */
main {
    flex: 1; overflow: hidden; display: flex; flex-direction: column;
    position: relative; /* Context for absolute children */
    border-radius: var(--radius-lg);
    background: rgba(17, 17, 17, 0.3);
    border: 1px solid var(--outline);
}

#canvas-container {
    width: 100%; height: 100%;
    z-index: 10;
}

/* HUD Panel (Latency) */
.hud-panel {
    position: absolute; bottom: 20px; right: 20px;
    background: var(--surface-container);
    border: 1px solid var(--outline);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; gap: 8px;
    font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-dim);
    z-index: 20;
}

/* Video Input (Invisible but Active) */
.input_video {
    position: fixed; top: 0; left: 0;
    width: 2px; height: 2px; opacity: 0.01;
    pointer-events: none; z-index: -10;
}

/* --- Loading Overlay (Material 3 Animated Gradient) --- */
.loading-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 50;
    display: flex; justify-content: center; align-items: center;
    transition: opacity 0.4s var(--ease-md3), visibility 0.4s;
    border-radius: var(--radius-lg);
    background: linear-gradient(-45deg, #000000, #141414, #050505, #0f0f0f);
    background-size: 400% 400%;
    animation: gradient-flow 10s ease infinite;
}

.loading-overlay.hidden {
    opacity: 0; visibility: hidden; pointer-events: none;
}

@keyframes gradient-flow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.loader-content {
    display: flex; flex-direction: column; align-items: center; gap: 20px;
    font-family: var(--font-mono); color: var(--text-dim); font-size: 0.85rem;
    letter-spacing: 1px;
}

.blink { animation: blinker 1.5s linear infinite; }
@keyframes blinker { 50% { opacity: 0.5; } }

/* SVG Spinner */
.md-spinner {
    width: 40px; height: 40px;
    animation: rotate 2s linear infinite;
    transform-origin: center;
}
.md-spinner-path {
    stroke: var(--accent);
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

@keyframes rotate { 100% { transform: rotate(360deg); } }
@keyframes dash {
    0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

/* --- Mobile Responsive Adjustments --- */
@media (max-width: 768px) {
    .top-bar {
        padding: 0.75rem 0;
        gap: 10px;
    }

    .logo-section h1 {
        font-size: 0.9rem;
    }

    .status-badge {
        font-size: 0.6rem;
        padding: 4px 8px;
        min-width: auto;
        gap: 6px;
    }

    .live-dot {
        width: 5px; height: 5px;
    }
}

/* --- Footer --- */
footer {
    margin-top: auto; padding-top: 1rem; text-align: center;
    color: var(--text-dim); font-size: 0.85rem; flex: 0 0 auto;
}
footer a { color: var(--text-dim); text-decoration: none; transition: all 0.2s ease; margin: 0 4px; }
footer a:hover { color: var(--text-main); text-decoration: underline; }