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

:root {
    --bg-primary: #0f0f14;
    --bg-secondary: #1a1a24;
    --bg-tertiary: #252532;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --user-msg-bg: #3b82f6;
    --user-msg-text: #ffffff;
    --assistant-msg-bg: #2d2d3a;
    --assistant-msg-border: #3f3f5a;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --wave-gradient: linear-gradient(90deg, #6366f1, #818cf8, #6366f1);
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
    overflow: hidden;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
    flex-shrink: 0;
}

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

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.logo-icon svg {
    width: 20px;
    height: 20px;
    color: white;
}

.logo span {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.status-badge.idle {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.status-badge.idle .status-dot {
    background: var(--text-muted);
}

.status-badge.listening {
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent-light);
}

.status-badge.listening .status-dot {
    background: var(--accent);
    animation: pulse 1.5s ease-in-out infinite;
}

.status-badge.thinking {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.status-badge.thinking .status-dot {
    background: var(--warning);
    animation: pulse 0.8s ease-in-out infinite;
}

.status-badge.speaking {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.status-badge.speaking .status-dot {
    background: var(--success);
    animation: pulse 1s ease-in-out infinite;
}

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

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.messages-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) transparent;
}

.messages-wrapper::-webkit-scrollbar {
    width: 6px;
}

.messages-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.messages-wrapper::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

/* Welcome Message */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 1rem;
    animation: fadeIn 0.5s ease;
}

.welcome-icon {
    width: 64px;
    height: 64px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.welcome-icon svg {
    width: 32px;
    height: 32px;
    stroke: var(--accent);
}

.welcome-message h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.welcome-message p {
    color: var(--text-secondary);
    max-width: 300px;
}

/* Messages */
.message {
    max-width: 75%;
    padding: 1rem 1.25rem;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    animation: slideIn 0.3s ease;
    word-wrap: break-word;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.message-assistant {
    align-self: flex-start;
    background: var(--assistant-msg-bg);
    color: var(--text-primary);
    border: 1px solid var(--assistant-msg-border);
    border-bottom-left-radius: 4px;
}

/* Typing Indicator */
.typing-indicator {
    padding: 0.5rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.typing-indicator.hidden {
    display: none;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* Wave Visualizer */
.wave-visualizer {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-top: 1px solid var(--bg-tertiary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.wave-visualizer.active {
    opacity: 1;
}

#waveCanvas {
    width: 100%;
    height: 100%;
}

/* Input Area */
.input-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--bg-tertiary);
    flex-shrink: 0;
}

.mic-button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.mic-button:hover {
    background: var(--accent);
    transform: scale(1.05);
}

.mic-button.listening {
    background: var(--accent);
    animation: mic-pulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 20px var(--accent-glow);
}

@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
    50% { box-shadow: 0 0 25px 10px var(--accent-glow); }
}

.mic-icon {
    width: 22px;
    height: 22px;
    stroke: var(--accent);
    transition: all 0.3s ease;
}

.mic-button:hover .mic-icon,
.mic-button.listening .mic-icon {
    stroke: white;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

#messageInput {
    width: 100%;
    padding: 0.875rem 1.25rem;
    border: 1px solid var(--bg-tertiary);
    border-radius: 24px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s ease;
}

#messageInput:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#messageInput::placeholder {
    color: var(--text-muted);
}

#messageInput:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.send-button:hover {
    background: var(--accent-light);
    transform: scale(1.05);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.send-button svg {
    width: 20px;
    height: 20px;
    stroke: white;
}

/* Error Toast */
.error-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--error);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    animation: toastIn 0.3s ease;
    z-index: 100;
}

.error-toast.hidden {
    display: none;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Responsive */
@media (max-width: 480px) {
    .header {
        padding: 0.75rem 1rem;
    }
    
    .logo span {
        font-size: 1.1rem;
    }
    
    .messages-wrapper {
        padding: 1rem;
    }
    
    .message {
        max-width: 85%;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .input-area {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }
    
    .mic-button, .send-button {
        width: 44px;
        height: 44px;
    }
    
    #messageInput {
        padding: 0.75rem 1rem;
    }
}