:root {
    --bg: #0a0a0f;
    --surface: #13131a;
    --surface-hover: #1a1a24;
    --border: #2a2a3a;
    --text: #e8e8f0;
    --text-muted: #8888a0;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --radius: 12px;
    --transition: 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app {
    width: 100%;
    max-width: 440px;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.25rem;
}

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.logo-icon {
    font-size: 1.5rem;
    color: var(--accent);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.status-badge .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background var(--transition);
}

.status-badge.connected .dot { background: var(--success); }
.status-badge.connected .text { color: var(--success); }
.status-badge.processing .dot { background: var(--warning); animation: pulse 1s infinite; }
.status-badge.processing .text { color: var(--warning); }
.status-badge.error .dot { background: var(--error); }
.status-badge.error .text { color: var(--error); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Main - Video */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: center;
}

.video-container {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-placeholder {
    text-align: center;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.avatar-silhouette {
    width: 80px;
    height: 80px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.video-placeholder p {
    font-size: 0.9rem;
    font-weight: 500;
}

.video-placeholder .hint {
    font-size: 0.75rem;
    opacity: 0.6;
}

#avatarVideo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
    border-radius: var(--radius);
}

#avatarVideo.active {
    display: block;
}

/* Pipeline Status */
.pipeline-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s, transform 0.3s;
}

.pipeline-status.visible {
    opacity: 1;
    transform: translateY(0);
}

.step {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: transparent;
    transition: all var(--transition);
}

.step.active {
    background: var(--accent-glow);
    color: var(--accent);
}

.step.done {
    color: var(--success);
}

.step-arrow {
    color: var(--text-muted);
    opacity: 0.4;
    font-size: 0.75rem;
}

/* Footer - Chat Input */
footer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-input {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--transition);
}

.chat-input:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.chat-input input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.9rem;
    padding: 0.5rem;
    outline: none;
}

.chat-input input::placeholder {
    color: var(--text-muted);
}

.chat-input button {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.chat-input button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 12px var(--accent-glow);
}

.chat-input button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.chat-input button svg {
    width: 18px;
    height: 18px;
}

.footnote {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.6;
}

/* Responsive */
@media (max-width: 600px) {
    .app {
        padding: 1rem;
        gap: 1rem;
    }

    .video-container {
        aspect-ratio: 4 / 3;
    }
}

@media (min-width: 768px) {
    .app {
        min-height: auto;
        height: 100dvh;
        max-height: 100dvh;
    }
}

/* Loading spinner for button */
.chat-input button.loading svg {
    display: none;
}

.chat-input button.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
/* Auth Gate */
.auth-gate {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0a0f;
    z-index: 9999;
}
.auth-card {
    background: #13131a;
    border: 1px solid #2a2a3a;
    border-radius: 16px;
    padding: 3rem 2.5rem;
    text-align: center;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin-bottom: 1.2rem;
}
.auth-logo .logo-icon {
    font-size: 2rem;
    color: #7c6df0;
}
.auth-logo h1 {
    font-size: 1.6rem;
    color: #fff;
    margin: 0;
}
.auth-desc {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.auth-form input {
    background: #1a1a24;
    border: 1px solid #2a2a3a;
    border-radius: 10px;
    padding: 0.85rem 1.1rem;
    font-size: 1rem;
    color: #fff;
    text-align: center;
    letter-spacing: 2px;
    outline: none;
    transition: border-color 0.2s;
}
.auth-form input:focus {
    border-color: #7c6df0;
}
.auth-btn {
    background: linear-gradient(135deg, #7c6df0, #5a4fd4);
    border: none;
    border-radius: 10px;
    padding: 0.85rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}
.auth-btn:hover { opacity: 0.9; }
.auth-btn:active { transform: scale(0.98); }
.auth-error {
    color: #f06060;
    font-size: 0.85rem;
    margin-top: 0.8rem;
    min-height: 1.2em;
}

/* AI Response */
.ai-response {
    background: #1a1a2e;
    border: 1px solid #2a2a4a;
    border-radius: 10px;
    padding: 0.8rem 1.2rem;
    margin-bottom: 1rem;
}
.ai-label {
    color: #7c6df0;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 0.3rem 0;
}
.ai-text {
    color: #e0e0e0;
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.4;
}
