:root {
    --primary-color: #00f2ff;
    --secondary-color: #ff0055;
    --text-color: #ffffff;
    --bg-gradient: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    --bubble-user-bg: rgba(255, 255, 255, 0.1);
    --bubble-ai-bg: rgba(0, 242, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.1);
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.main-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 2rem;
    box-sizing: border-box;
}

/* --- Background Animation & Visualizer --- */
.circle-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 0;
    pointer-events: none;
}

.circle {
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 242, 255, 0.1) 0%, rgba(0, 0, 0, 0) 70%);
    box-shadow: 0 0 50px rgba(0, 242, 255, 0.2);
    animation: pulse 4s infinite ease-in-out;
}

.circle-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(0, 242, 255, 0.1);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.1);
}

.circle-ring:nth-child(2) {
    width: 400px;
    height: 400px;
    animation: rotate 10s infinite linear;
    border-top-color: transparent;
    border-left-color: transparent;
}

.circle-ring:nth-child(3) {
    width: 500px;
    height: 500px;
    animation: rotate-rev 15s infinite linear;
    border-bottom-color: transparent;
    border-right-color: transparent;
}

canvas#visualizer {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 1;
    opacity: 0.6;
    mask-image: radial-gradient(circle, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 70%);
    -webkit-mask-image: radial-gradient(circle, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 70%);
}

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

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

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

/* --- Header --- */
.header {
    z-index: 10;
    text-align: center;
    margin-top: 2rem;
}

h1 {
    font-weight: 300;
    letter-spacing: 4px;
    text-transform: uppercase;
    margin: 0;
    font-size: 2rem;
    text-shadow: 0 0 20px rgba(0, 242, 255, 0.5);
}

.status-bar {
    margin-top: 10px;
    font-size: 0.9rem;
    opacity: 0.7;
    letter-spacing: 1px;
}

/* --- Controls --- */
.controls-area {
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 20vh; /* Leave space for chat bubbles */
}

.buttons {
    display: flex;
    gap: 1.5rem;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(5px);
}

.btn.primary {
    background: rgba(0, 242, 255, 0.2);
    border: 1px solid rgba(0, 242, 255, 0.5);
    color: #fff;
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.2);
}

.btn.primary:hover {
    background: rgba(0, 242, 255, 0.4);
    box-shadow: 0 0 40px rgba(0, 242, 255, 0.4);
    transform: translateY(-2px);
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ccc;
}

.btn.secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

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

/* --- Switch --- */
.stt-switch-container {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    opacity: 0.8;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* --- Chat Bubbles --- */
.chat-overlay {
    position: absolute;
    bottom: 2rem;
    width: 100%;
    max-width: 800px;
    height: 300px; /* Area for bubbles */
    pointer-events: none; /* Let clicks pass through */
    z-index: 20;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    mask-image: linear-gradient(to bottom, transparent 0%, black 20%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 20%);
}

.chat-log {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
}

.message {
    max-width: 70%;
    padding: 12px 20px;
    border-radius: 20px;
    font-size: 1rem;
    line-height: 1.4;
    position: relative;
    animation: slideIn 0.4s ease-out forwards;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    opacity: 0; /* Start hidden for animation */
}

.message.user {
    align-self: flex-end;
    background: var(--bubble-user-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom-right-radius: 4px;
    text-align: right;
}

.message.ai {
    align-self: flex-start;
    background: var(--bubble-ai-bg);
    border: 1px solid rgba(0, 242, 255, 0.2);
    border-bottom-left-radius: 4px;
    text-align: left;
}

/* Fade out effect for older messages */
.message.fade-out {
    animation: fadeOut 0.5s ease-out forwards;
}

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

@keyframes fadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.9); }
}
