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

:root {
    --primary: #0A7CFF;
    --primary-light: #38BDF8;
    --bg: linear-gradient(160deg, #E0F0FF 0%, #B3DAFF 40%, #87CEEB 100%);
    --bg-solid: #E0F0FF;
    --surface: rgba(255, 255, 255, 0.55);
    --surface-solid: #FFFFFF;
    --glass: rgba(255, 255, 255, 0.45);
    --glass-border: rgba(255, 255, 255, 0.6);
    --text: #0A2463;
    --text-muted: #5A7BA6;
    --danger: #EF4444;
    --success: #10B981;
    --radius: 20px;
    --transition: 0.3s ease;
}

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

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

/* Screens */
.screen { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 32px; }
.screen.active { display: flex; }

/* Idle screen */
#screen-idle { background: var(--bg); }
#avatar-idle-container {
    width: 200px; height: 200px; border-radius: 50%; overflow: hidden;
    background: var(--surface-solid);
    border: 4px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 8px 40px rgba(10, 36, 99, 0.15), 0 0 0 8px rgba(10, 124, 255, 0.1);
}
#avatar-idle-img { width: 100%; height: 100%; object-fit: cover; }
.idle-prompt { text-align: center; }
.idle-prompt h2 { font-size: 1.8rem; margin-bottom: 8px; color: var(--text); text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5); }
.idle-prompt p { color: var(--text-muted); font-size: 1.1rem; }

/* Language selector */
.language-selector { display: flex; gap: 12px; }
.lang-btn {
    background: var(--glass); border: 2px solid var(--glass-border);
    color: var(--text); padding: 10px 18px; border-radius: 14px;
    font-size: 1rem; cursor: pointer;
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
    box-shadow: 0 2px 8px rgba(10, 36, 99, 0.06);
}
.lang-btn:hover { border-color: var(--primary-light); background: rgba(255, 255, 255, 0.7); }
.lang-btn.active {
    border-color: var(--primary); background: rgba(10, 124, 255, 0.12);
    box-shadow: 0 2px 12px rgba(10, 124, 255, 0.15);
}

/* Dialog screen */
#screen-dialog { background: var(--bg); gap: 12px; justify-content: flex-start; padding-top: 16px; }
#avatar-video-container {
    position: relative; width: auto; max-width: 90vw; max-height: 50vh;
    border-radius: var(--radius); overflow: hidden;
    background: var(--surface-solid); flex-shrink: 0;
    box-shadow: 0 8px 40px rgba(10, 36, 99, 0.15);
    border: 1px solid var(--glass-border);
}
#avatar-video { width: 100%; height: 100%; object-fit: contain; display: block; }

/* Fullscreen button */
.btn-fullscreen {
    position: absolute; top: 12px; left: 12px; width: 44px; height: 44px;
    border-radius: 12px; border: none;
    background: rgba(255, 255, 255, 0.4); color: var(--text);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    z-index: 10; transition: background var(--transition);
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 8px rgba(10, 36, 99, 0.1);
}
.btn-fullscreen:hover { background: rgba(255, 255, 255, 0.7); }

/* Fullscreen mode */
#avatar-video-container:fullscreen { max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; border-radius: 0; display: flex; align-items: center; justify-content: center; background: #000; }
#avatar-video-container:-webkit-full-screen { max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; border-radius: 0; display: flex; align-items: center; justify-content: center; background: #000; }

/* Demo timer */
#demo-timer {
    position: absolute; top: 12px; left: 56px;
    background: rgba(255, 255, 255, 0.5); color: var(--text);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    font-size: 0.85rem; padding: 4px 12px; border-radius: 8px;
    font-variant-numeric: tabular-nums; z-index: 10;
    border: 1px solid var(--glass-border);
}
#demo-timer.demo-timer-warning { color: var(--danger); background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.3); }

/* Demo limit screen */
#screen-demo-limit { background: var(--bg); }
.demo-limit-content { text-align: center; }
.demo-limit-icon { font-size: 4rem; margin-bottom: 16px; }
.demo-limit-content h2 { font-size: 1.8rem; margin-bottom: 8px; color: var(--text); }
.demo-limit-content p { color: var(--text-muted); font-size: 1.1rem; }

/* Watermark */
#video-watermark { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); font-size: 0.65rem; color: rgba(10, 36, 99, 0.35); letter-spacing: 0.5px; pointer-events: none; white-space: nowrap; }

/* Status indicator */
#status-indicator {
    position: absolute; top: 12px; right: 12px; width: 14px; height: 14px;
    border-radius: 50%; background: var(--text-muted);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
}
.status-connecting { background: #F59E0B !important; box-shadow: 0 0 12px rgba(245, 158, 11, 0.4) !important; animation: pulse 1s infinite; }
.status-listening  { background: var(--success) !important; box-shadow: 0 0 12px rgba(16, 185, 129, 0.4) !important; animation: pulse 1.5s infinite; }
.status-thinking   { background: var(--primary-light) !important; box-shadow: 0 0 12px rgba(56, 189, 248, 0.4) !important; animation: pulse 0.8s infinite; }
.status-speaking   { background: var(--primary) !important; box-shadow: 0 0 12px rgba(10, 124, 255, 0.4) !important; }
.status-idle       { background: var(--text-muted) !important; }

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

/* User speech box */
#user-speech-box {
    max-width: 500px; width: 100%; min-height: 28px; text-align: center;
    font-size: 0.85rem; color: #047857;
    background: rgba(16, 185, 129, 0.1); padding: 8px 16px;
    border-radius: 12px; border: 1px solid rgba(16, 185, 129, 0.2);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
#user-speech-box:empty { display: none; }

/* Subtitles */
#subtitles {
    max-width: 600px; text-align: center; font-size: 1rem;
    background: var(--glass); padding: 10px 18px; border-radius: var(--radius);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border); color: var(--text);
    box-shadow: 0 4px 16px rgba(10, 36, 99, 0.08);
}
#subtitles:empty { display: none; }

/* Transcript log */
#transcript-log {
    max-width: 600px; width: 100%; max-height: 120px; overflow-y: auto;
    background: var(--glass); border-radius: var(--radius); padding: 10px 16px;
    font-size: 0.85rem; line-height: 1.5; display: none;
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}
#transcript-log:empty { display: none; }
.transcript-entry { margin-bottom: 4px; }
.transcript-role { font-weight: 600; }
.transcript-agent .transcript-role { color: var(--primary); }
.transcript-user .transcript-role { color: var(--success); }
.transcript-text { color: var(--text); }

/* Mic controls */
#mic-controls { display: flex; align-items: center; gap: 24px; }
.waveform { display: flex; align-items: center; gap: 3px; height: 40px; }
.waveform-bar { width: 4px; border-radius: 2px; background: var(--primary); transform-origin: bottom; animation: none; }
.waveform-bar.active { animation: wave 0.6s ease-in-out infinite alternate; }
@keyframes wave { from { transform: scaleY(0.2); } to { transform: scaleY(1); } }

/* Buttons */
.btn-mic {
    width: 72px; height: 72px; border-radius: 50%; border: none;
    background: linear-gradient(135deg, var(--primary), #38BDF8);
    color: white; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: transform var(--transition), box-shadow var(--transition);
    box-shadow: 0 6px 24px rgba(10, 124, 255, 0.35);
}
.btn-mic:hover { transform: scale(1.06); box-shadow: 0 8px 32px rgba(10, 124, 255, 0.45); }
.btn-mic.muted { background: linear-gradient(135deg, var(--danger), #F87171); box-shadow: 0 6px 24px rgba(239, 68, 68, 0.35); }
.btn-mic-large { width: 96px; height: 96px; box-shadow: 0 8px 36px rgba(10, 124, 255, 0.4); }
.btn-mic-small { width: 48px; height: 48px; box-shadow: 0 4px 16px rgba(10, 124, 255, 0.3); }
.btn-end {
    background: var(--glass); border: 1px solid var(--glass-border);
    color: var(--text-muted); border-radius: 999px; padding: 10px 28px;
    cursor: pointer; font-size: 0.9rem;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.btn-end:hover { color: var(--danger); border-color: rgba(239, 68, 68, 0.4); background: rgba(239, 68, 68, 0.08); }
