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

:root {
    --primary: #4285f4;
    --primary-dark: #3367d6;
    --primary-light: #8ab4f8;
    --success: #34a853;
    --danger: #ea4335;
    --warning: #fbbc04;
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-input: #16213e;
    --text: #e8e8e8;
    --text-muted: #8888aa;
    --border: #2a2a4a;
    --user-bubble: #1a3a5c;
    --model-bubble: #2a1a3c;
    --glow: rgba(66, 133, 244, 0.3);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    background-image: 
        radial-gradient(ellipse at 20% 50%, rgba(66, 133, 244, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(234, 67, 53, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(52, 168, 83, 0.06) 0%, transparent 50%);
}

.container {
    max-width: 700px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

header {
    text-align: center;
    padding: 20px 0 10px;
}

header h1 {
    font-size: 1.8rem;
    background: linear-gradient(135deg, var(--primary), var(--success), var(--warning));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.api-section, .model-section, .voice-section, .language-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 18px;
}

.api-section label, .model-section label, .voice-section label, .language-section label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.api-input-group {
    display: flex;
    gap: 8px;
}

.api-input-group input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.3s;
}

.api-input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--glow);
}

.btn-small {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    color: var(--text);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.btn-small:hover {
    background: var(--border);
}

.hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.hint a {
    color: var(--primary-light);
    text-decoration: none;
}

.hint a:hover {
    text-decoration: underline;
}

select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.3s;
}

select:focus {
    border-color: var(--primary);
}

.chat-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    min-height: 300px;
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.welcome-message {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    line-height: 1.8;
}

.chat-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
    word-wrap: break-word;
}

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

.chat-bubble.user {
    align-self: flex-end;
    background: var(--user-bubble);
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(66, 133, 244, 0.3);
}

.chat-bubble.model {
    align-self: flex-start;
    background: var(--model-bubble);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.chat-bubble .sender {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 600;
}

.chat-bubble.user .sender {
    color: var(--primary-light);
}

.chat-bubble.model .sender {
    color: #c084fc;
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
}

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

.status-dot.ready {
    background: var(--success);
    box-shadow: 0 0 8px rgba(52, 168, 83, 0.5);
}

.status-dot.recording {
    background: var(--danger);
    box-shadow: 0 0 8px rgba(234, 67, 53, 0.5);
    animation: pulse 1s infinite;
}

.status-dot.connecting {
    background: var(--warning);
    box-shadow: 0 0 8px rgba(251, 188, 4, 0.5);
    animation: pulse 0.5s infinite;
}

.status-dot.speaking {
    background: #c084fc;
    box-shadow: 0 0 8px rgba(192, 132, 252, 0.5);
    animation: pulse 0.8s infinite;
}

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

.controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.mic-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px var(--glow);
}

.mic-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--glow);
}

.mic-btn:active:not(:disabled) {
    transform: translateY(0);
}

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

.mic-btn.recording {
    background: linear-gradient(135deg, var(--danger), #c62828);
    box-shadow: 0 4px 15px rgba(234, 67, 53, 0.4);
    animation: micPulse 1.5s infinite;
}

@keyframes micPulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(234, 67, 53, 0.4); }
    50% { box-shadow: 0 4px 30px rgba(234, 67, 53, 0.7); }
}

.mic-icon {
    width: 24px;
    height: 24px;
}

.stop-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.stop-btn:hover:not(:disabled) {
    background: #c62828;
}

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

.stop-icon {
    width: 20px;
    height: 20px;
}

.clear-btn {
    padding: 14px 20px;
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 50px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
}

.clear-btn:hover {
    background: var(--border);
    color: var(--text);
}

.audio-visualizer {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    display: none;
}

.audio-visualizer.active {
    display: block;
}

#audioVisualizer canvas {
    width: 100%;
    height: 80px;
    border-radius: 8px;
}

.transcript-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.transcript-section h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.transcript {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.9rem;
    line-height: 1.6;
}

.user-transcript {
    background: rgba(66, 133, 244, 0.1);
    border-left: 3px solid var(--primary);
}

.model-transcript {
    background: rgba(192, 132, 252, 0.1);
    border-left: 3px solid #c084fc;
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    .controls {
        flex-direction: column;
    }

    .mic-btn, .stop-btn, .clear-btn {
        width: 100%;
        justify-content: center;
    }

    .chat-container {
        min-height: 250px;
        max-height: 300px;
    }
}
