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

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

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

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 2.5em;
    font-weight: 600;
    margin-bottom: 10px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9em;
    opacity: 0.9;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-dot.offline {
    background-color: #ff6b6b;
}

.status-dot.online {
    background-color: #51cf66;
}

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

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* Voice Visualizer */
.voice-visualizer {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
    text-align: center;
}

#visualizer {
    border-radius: 10px;
    background: #f8f9fa;
    width: 100%;
    max-width: 400px;
    height: 80px;
}

/* Control Section */
.control-section {
    text-align: center;
}

.talk-button {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    border: none;
    border-radius: 50px;
    width: 200px;
    height: 200px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(238, 90, 82, 0.4);
    transition: all 0.3s ease;
    color: white;
    font-weight: 600;
    position: relative;
    overflow: hidden;
    user-select: none;
}

.talk-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #ccc;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.talk-button:not(:disabled):hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(238, 90, 82, 0.5);
}

.talk-button:not(:disabled):active,
.talk-button.recording {
    transform: scale(0.95);
    background: linear-gradient(135deg, #ff5252, #d32f2f);
    animation: recordingPulse 1s infinite;
}

@keyframes recordingPulse {
    0% { box-shadow: 0 10px 30px rgba(238, 90, 82, 0.4); }
    50% { box-shadow: 0 15px 40px rgba(238, 90, 82, 0.8); }
    100% { box-shadow: 0 10px 30px rgba(238, 90, 82, 0.4); }
}

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

.microphone-icon {
    font-size: 3em;
    line-height: 1;
}

.button-text {
    font-size: 1.1em;
    font-weight: 500;
}

.button-hint {
    font-size: 0.8em;
    opacity: 0.8;
    margin-top: 5px;
}

/* Status Messages */
.status-messages {
    text-align: center;
}

.status-message {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 12px 20px;
    margin: 5px auto;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.status-message.hidden {
    display: none;
}

.status-icon {
    font-size: 1.2em;
}

/* Chat History */
.chat-history {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
    flex: 1;
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.chat-header h3 {
    color: #333;
    font-weight: 500;
}

.clear-button {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 5px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8em;
    font-weight: 500;
    transition: background 0.2s ease;
}

.clear-button:hover {
    background: #ee5a52;
}

.messages {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
}

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

.message.user {
    background: #e3f2fd;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.message.assistant {
    background: #f1f8e9;
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

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

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

.message-audio {
    margin-top: 8px;
}

.play-audio-button {
    background: #4caf50;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8em;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background 0.2s ease;
}

.play-audio-button:hover {
    background: #45a049;
}

.play-audio-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Error Display */
.error-display {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #fff;
    border: 1px solid #ff6b6b;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.2);
    z-index: 1000;
    max-width: 400px;
}

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

.error-content {
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #d32f2f;
}

.error-icon {
    font-size: 1.2em;
    flex-shrink: 0;
}

.dismiss-button {
    background: none;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    color: #999;
    margin-left: auto;
    padding: 0 5px;
}

.dismiss-button:hover {
    color: #333;
}

/* Footer */
footer {
    margin-top: 30px;
    text-align: center;
    color: white;
    opacity: 0.8;
}

.info p {
    font-size: 0.9em;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .talk-button {
        width: 150px;
        height: 150px;
    }
    
    .microphone-icon {
        font-size: 2.5em;
    }
    
    .button-text {
        font-size: 1em;
    }
    
    .message {
        max-width: 90%;
    }
    
    #visualizer {
        height: 60px;
    }
    
    .error-display {
        position: fixed;
        top: 10px;
        left: 10px;
        right: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 1.8em;
    }
    
    .talk-button {
        width: 130px;
        height: 130px;
    }
    
    .microphone-icon {
        font-size: 2em;
    }
    
    .button-text {
        font-size: 0.9em;
    }
    
    .voice-visualizer,
    .chat-history {
        padding: 15px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .talk-button,
    .status-dot,
    .status-message {
        animation: none;
        transition: none;
    }
}

/* Focus styles for accessibility */
.talk-button:focus,
.clear-button:focus,
.play-audio-button:focus,
.dismiss-button:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .message.user {
        background: #000;
        color: #fff;
    }
    
    .message.assistant {
        background: #fff;
        color: #000;
        border: 1px solid #000;
    }
}