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

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo i {
    font-size: 2.5rem;
    color: #ffd700;
}

.logo h1 {
    font-size: 3rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    font-weight: 300;
}

.main-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.voice-section {
    text-align: center;
}

.voice-controls {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 20px;
}

.voice-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.voice-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.voice-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.voice-btn.stop {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.voice-btn.stop:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
}

.status-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.status {
    font-size: 1.1rem;
    font-weight: 500;
    color: #666;
}

.listening-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4CAF50;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.listening-indicator.active {
    opacity: 1;
    animation: pulse 1.5s infinite;
}

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

.speaking-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #667eea;
    font-weight: 500;
    margin-top: 10px;
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 15px;
    border-radius: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.sound-wave {
    display: flex;
    align-items: center;
    gap: 2px;
}

.sound-wave::before,
.sound-wave::after {
    content: '';
    width: 3px;
    height: 20px;
    background: #667eea;
    border-radius: 2px;
    animation: soundWave 1s infinite;
}

.sound-wave::after {
    animation-delay: 0.5s;
}

@keyframes soundWave {
    0%, 100% { height: 10px; }
    50% { height: 25px; }
}

.conversation-section {
    flex: 1;
    min-height: 300px;
}

.messages-container {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    min-height: 300px;
    max-height: 400px;
    overflow-y: auto;
    border: 2px solid #e9ecef;
}

.welcome-message {
    text-align: center;
    color: #666;
    padding: 40px 20px;
}

.welcome-message i {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 15px;
}

.message {
    margin-bottom: 15px;
    padding: 15px;
    border-radius: 15px;
    max-width: 80%;
    word-wrap: break-word;
}

.message.user {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
    text-align: right;
}

.message.assistant {
    background: #e9ecef;
    color: #333;
    margin-right: auto;
}

.message-header {
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 0.9rem;
    opacity: 0.8;
}

.message-content {
    line-height: 1.5;
}

.settings-section {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
}

.setting-item label {
    font-weight: 500;
    color: #555;
}

.setting-item select,
.setting-item input[type="range"] {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.setting-item select:focus,
.setting-item input[type="range"]:focus {
    outline: none;
    border-color: #667eea;
}

#rateValue,
#pitchValue {
    font-weight: 500;
    color: #667eea;
    text-align: center;
}

.voice-hint {
    color: #666;
    font-style: italic;
    margin-top: 5px;
    display: block;
}

.conversation-controls {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    border: 2px solid #e9ecef;
}

.conversation-controls h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2rem;
    text-align: center;
}

.control-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.control-btn {
    background: white;
    border: 2px solid #e9ecef;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.control-btn.clear {
    border-color: #ff6b6b;
    color: #ff6b6b;
}

.control-btn.clear:hover {
    background: #ff6b6b;
    color: white;
}

.control-btn.export {
    border-color: #4CAF50;
    color: #4CAF50;
}

.control-btn.export:hover {
    background: #4CAF50;
    color: white;
}

.control-btn.info {
    border-color: #667eea;
    color: #667eea;
}

.control-btn.info:hover {
    background: #667eea;
    color: white;
}

.history-info {
    text-align: center;
    color: #666;
    font-style: italic;
}

.history-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.history-modal.active {
    display: flex;
}

.history-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.history-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.history-close:hover {
    color: #333;
}

.history-item {
    margin-bottom: 15px;
    padding: 15px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.history-item.user {
    background: #f0f4ff;
    border-left-color: #667eea;
}

.history-item.assistant {
    background: #f8f9fa;
    border-left-color: #4CAF50;
}

.history-item-header {
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}

.history-item-content {
    color: #666;
    line-height: 1.5;
}

.history-item-time {
    font-size: 0.8rem;
    color: #999;
    margin-top: 5px;
}

.api-key-section {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    margin-top: 20px;
    backdrop-filter: blur(10px);
}

.api-key-input {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.api-key-input label {
    color: white;
    font-weight: 500;
    min-width: 200px;
}

.api-key-input input {
    flex: 1;
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    min-width: 250px;
}

.save-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease;
}

.save-btn:hover {
    background: #45a049;
}

.api-status {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ffd700;
    font-weight: 500;
}

.api-status.connected {
    color: #4CAF50;
}

.api-status.connected i {
    color: #4CAF50;
}

.api-info {
    margin-top: 10px;
    text-align: center;
}

.api-info small {
    color: #ffd700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.4;
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 10px 15px;
    border-radius: 8px;
    margin: 10px 0;
    border-left: 4px solid #c62828;
}

.success-message {
    background: #e8f5e8;
    color: #2e7d32;
    padding: 10px 15px;
    border-radius: 8px;
    margin: 10px 0;
    border-left: 4px solid #2e7d32;
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .logo h1 {
        font-size: 2.5rem;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .voice-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .settings-section {
        flex-direction: column;
        align-items: center;
    }
    
    .api-key-input {
        flex-direction: column;
        align-items: stretch;
    }
    
    .api-key-input input {
        min-width: auto;
    }
    
    .control-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .control-btn {
        width: 100%;
        max-width: 200px;
    }
    
    .history-content {
        margin: 20px;
        max-width: calc(100% - 40px);
    }
}
