:root {
    --primary: #6C5CE7;
    --primary-dark: #5A4BD1;
    --bg: #0F0E17;
    --surface: #1A1928;
    --surface-light: #232136;
    --text: #FFFFFE;
    --text-muted: #94A1B2;
    --accent: #FF6B6B;
    --success: #00D68F;
    --border: rgba(255,255,255,0.06);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.avatar-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: linear-gradient(135deg, #0F0E17 0%, #1A1928 100%);
    min-width: 0;
}

.avatar-video-wrapper {
    position: relative;
    width: 100%;
    max-width: 800px;
    aspect-ratio: 16/9;
    border-radius: 20px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

#videoPlayer {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#audioPlayer {
    display: none;
}

.avatar-status {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 500;
}

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

.status-dot.connected {
    background: var(--success);
    box-shadow: 0 0 8px rgba(0,214,143,0.5);
    animation: pulse 2s infinite;
}

.status-dot.speaking {
    background: var(--accent);
    box-shadow: 0 0 8px rgba(255,107,107,0.5);
    animation: pulse 0.8s infinite;
}

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

.controls-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    padding: 12px 24px;
    background: var(--surface);
    border-radius: 100px;
    border: 1px solid var(--border);
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--accent);
}

.btn-danger:hover:not(:disabled) {
    background: #e55a5a;
    transform: translateY(-1px);
}

.btn-icon {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    background: var(--surface-light);
    border: 1px solid var(--border);
}

.btn-icon:hover:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
}

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

.btn-icon svg {
    width: 20px;
    height: 20px;
}

.chat-panel {
    width: 380px;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-left: 1px solid var(--border);
}

.chat-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.chat-header-info h2 {
    font-size: 16px;
    font-weight: 600;
}

.chat-header-info span {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--surface-light) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 4px;
}

.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: messageIn 0.2s ease-out;
}

@keyframes messageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    align-self: flex-end;
    background: var(--primary);
    border-bottom-right-radius: 4px;
}

.message.assistant {
    align-self: flex-start;
    background: var(--surface-light);
    border-bottom-left-radius: 4px;
}

.message .sender {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    opacity: 0.7;
}

.chat-input-area {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

.chat-input-area input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-area input:focus {
    border-color: var(--primary);
}

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

.chat-input-area button {
    width: 44px;
    height: 44px;
    background: var(--primary);
    border: none;
    border-radius: 12px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-input-area button:hover {
    background: var(--primary-dark);
}

.chat-input-area button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.welcome-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(15,14,23,0.9);
    backdrop-filter: blur(20px);
    z-index: 10;
    transition: opacity 0.5s;
}

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

.welcome-logo {
    width: 80px;
    height: 80px;
    border-radius: 24px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 24px;
    box-shadow: 0 10px 40px rgba(108,92,231,0.4);
}

.welcome-overlay h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.welcome-overlay p {
    color: var(--text-muted);
    font-size: 15px;
    margin-bottom: 32px;
    text-align: center;
    max-width: 400px;
    line-height: 1.6;
}

.loading-spinner {
    display: none;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: var(--text);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-spinner.active { display: block; }

@keyframes spin { to { transform: rotate(360deg); } }

.mic-indicator {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--accent);
    font-weight: 500;
}

.mic-indicator.active {
    display: flex;
}

.mic-wave {
    display: flex;
    gap: 2px;
    align-items: center;
    height: 16px;
}

.mic-wave span {
    width: 3px;
    background: var(--accent);
    border-radius: 2px;
    animation: wave 0.5s ease-in-out infinite alternate;
}

.mic-wave span:nth-child(1) { height: 4px; animation-delay: 0s; }
.mic-wave span:nth-child(2) { height: 10px; animation-delay: 0.1s; }
.mic-wave span:nth-child(3) { height: 16px; animation-delay: 0.2s; }
.mic-wave span:nth-child(4) { height: 10px; animation-delay: 0.3s; }
.mic-wave span:nth-child(5) { height: 4px; animation-delay: 0.4s; }

@keyframes wave {
    from { transform: scaleY(0.5); }
    to { transform: scaleY(1); }
}

@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
    }
    .avatar-panel {
        flex: none;
        height: 50vh;
    }
    .chat-panel {
        width: 100%;
        flex: 1;
        border-left: none;
        border-top: 1px solid var(--border);
    }
    .avatar-video-wrapper {
        max-width: 100%;
        border-radius: 0;
    }
    .controls-bar {
        margin-top: 12px;
    }
}

@media (max-width: 600px) {
    .controls-bar {
        padding: 8px 16px;
        gap: 8px;
    }
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    .chat-panel {
        width: 100%;
    }
}
