body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f0f2f5;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    overflow: hidden;
}

.screen { width: 100%; height: 100%; display: none; justify-content: center; align-items: center; }
.screen.active { display: flex; }

.selection-container {
    text-align: center;
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    max-width: 560px;
    width: 90%;
}
.selection-container h1 { margin-top: 0; margin-bottom: 20px; font-size: 1.5rem; }
.start-description { color: #555; line-height: 1.5; margin-bottom: 30px; }
#scenario-buttons { display: flex; flex-direction: column; gap: 15px; align-items: center; }
.scenario-button {
    padding: 15px 30px;
    font-size: 1.1rem;
    cursor: pointer;
    border: 1px solid #007bff;
    background-color: #fff;
    color: #007bff;
    border-radius: 8px;
    transition: background-color 0.2s, color 0.2s;
    min-width: 300px;
}
.scenario-button:hover { background-color: #007bff; color: #fff; }

.chat-container { width: 100%; max-width: 600px; height: 90vh; max-height: 800px; background-color: #ffffff; border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); display: flex; flex-direction: column; overflow: hidden; }
.chat-header { display: flex; align-items: center; padding: 0 10px; background-color: #f5f5f5; border-bottom: 1px solid #ddd; }
.back-to-menu-button { background: none; border: none; font-size: 1rem; cursor: pointer; padding: 0 15px; color: #555; }
.back-to-menu-button:hover { color: #000; }
.chat-header h1 { flex-grow: 1; text-align: center; font-size: 1.1rem; padding: 15px 0; margin: 0; }
.chat-window { flex-grow: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.message { padding: 10px 15px; border-radius: 18px; max-width: 80%; word-wrap: break-word; line-height: 1.4; }
.user-message { background-color: #007bff; color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.bot-message { background-color: #e9e9eb; color: #333; align-self: flex-start; border-bottom-left-radius: 4px; }

.finish-dialogue-button {
    margin-left: auto;
    padding: 8px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    border: 1px solid #28a745;
    background-color: #fff;
    color: #28a745;
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
    white-space: nowrap;
}
.finish-dialogue-button:hover { background-color: #28a745; color: #fff; }

.analysis-container {
    text-align: left;
    background: #fff;
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}
.analysis-container h1 { text-align: center; margin-top: 0; margin-bottom: 25px; }
#analysis-content {
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
    white-space: pre-wrap;
    line-height: 1.6;
    color: #333;
}
#back-to-menu-from-analysis {
    display: block;
    margin: 0 auto;
    padding: 15px 30px;
    font-size: 1.1rem;
    cursor: pointer;
    border: none;
    background-color: #007bff;
    color: #fff;
    border-radius: 8px;
    transition: background-color 0.2s;
}
#back-to-menu-from-analysis:hover { background-color: #0056b3; }

.voice-controls {
    padding: 15px;
    text-align: center;
    border-top: 1px solid #ddd;
    background: #fafafa;
}

#status-indicator {
    margin: 0 0 10px 0;
    color: #555;
    min-height: 20px;
    font-size: 0.9rem;
}

.voice-visualizer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    height: 40px;
    margin-bottom: 10px;
}

.viz-bar {
    width: 6px;
    height: 8px;
    background-color: #ccc;
    border-radius: 3px;
    transition: height 0.15s ease, background-color 0.3s ease;
}

.voice-visualizer.idle .viz-bar { height: 8px; background-color: #ccc; }

.voice-visualizer.connecting .viz-bar {
    background-color: #ffc107;
    animation: pulse 1.2s ease-in-out infinite;
}
.voice-visualizer.connecting .viz-bar:nth-child(1) { animation-delay: 0s; }
.voice-visualizer.connecting .viz-bar:nth-child(2) { animation-delay: 0.15s; }
.voice-visualizer.connecting .viz-bar:nth-child(3) { animation-delay: 0.3s; }
.voice-visualizer.connecting .viz-bar:nth-child(4) { animation-delay: 0.45s; }
.voice-visualizer.connecting .viz-bar:nth-child(5) { animation-delay: 0.6s; }

.voice-visualizer.user-speaking .viz-bar {
    background-color: #28a745;
    animation: speaking 0.6s ease-in-out infinite alternate;
}
.voice-visualizer.user-speaking .viz-bar:nth-child(1) { animation-delay: 0s; }
.voice-visualizer.user-speaking .viz-bar:nth-child(2) { animation-delay: 0.1s; }
.voice-visualizer.user-speaking .viz-bar:nth-child(3) { animation-delay: 0.2s; }
.voice-visualizer.user-speaking .viz-bar:nth-child(4) { animation-delay: 0.3s; }
.voice-visualizer.user-speaking .viz-bar:nth-child(5) { animation-delay: 0.4s; }

.voice-visualizer.ai-speaking .viz-bar {
    background-color: #007bff;
    animation: speaking 0.5s ease-in-out infinite alternate;
}
.voice-visualizer.ai-speaking .viz-bar:nth-child(1) { animation-delay: 0s; }
.voice-visualizer.ai-speaking .viz-bar:nth-child(2) { animation-delay: 0.08s; }
.voice-visualizer.ai-speaking .viz-bar:nth-child(3) { animation-delay: 0.16s; }
.voice-visualizer.ai-speaking .viz-bar:nth-child(4) { animation-delay: 0.24s; }
.voice-visualizer.ai-speaking .viz-bar:nth-child(5) { animation-delay: 0.32s; }

@keyframes pulse {
    0%, 100% { height: 8px; opacity: 0.4; }
    50% { height: 20px; opacity: 1; }
}

@keyframes speaking {
    0% { height: 8px; }
    100% { height: 32px; }
}

#record-button {
    min-width: 180px;
    height: 44px;
    border: none;
    border-radius: 22px;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s, transform 0.1s;
}
#record-button:active { transform: scale(0.97); }
#record-button:disabled { background-color: #ccc; cursor: not-allowed; }
#record-button.idle { background-color: #28a745; color: white; }
#record-button.idle:hover { background-color: #218838; }
#record-button.connecting { background-color: #ffc107; color: #333; }
#record-button.recording { background-color: #dc3545; color: white; }
#record-button.recording:hover { background-color: #c82333; }
