       :root {
    --bg-dark: #0b1120;
    --panel-dark: #111827;
    --primary-blue: #3b82f6;
    --text-white: #f3f4f6;
    --border-color: #374151;
}

/* Background Blur/Overlay */
.modal-overlay {
    position: fixed;
    /* Use inset for full coverage */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* Use dvh (Dynamic Viewport Height) for modern mobile browsers */
    height: 100vh;
    height: 100dvh; 
    width: 100vw;
    background: var(--bg-dark);
    z-index: 99999; /* Ensure it's above everything */
    display: none; 
    flex-direction: column;
}

/* Modal Content Container */
.modal-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    position: relative;
}

/* Header Styles */
.modal-header {
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.modal-title span {
    color: var(--primary-blue);
    font-weight: bold;
}

.exit-btn {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.2s;
}

.exit-btn:hover { color: #ef4444; }

/* Body Styles */
.modal-body {
    flex-grow: 1;
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ai-bubble {
    background: var(--panel-dark);
    padding: 1rem;
    border-radius: 10px;
    max-width: 80%;
    border: 1px solid var(--border-color);
    color: var(--text-white);
}

/* Footer / Input Area */
.modal-footer {
    position: relative;
    z-index: 100; /* Higher than voice overlay */
    padding: 1rem;
    background: #0f172a;
    border-top: 1px solid var(--border-color);
    /* Keeps input visible above keyboard on some mobile browsers */
    padding-bottom: env(safe-area-inset-bottom);
}

.input-container {
    display: flex;
    gap: 10px;
    max-width: 1000px;
    margin: 0 auto;
}

.chat-input {
    flex-grow: 1;
    background: #1f2937;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 12px;
    color: white;
}

.send-btn {
    background: var(--primary-blue);
    color: white;
    border: none;
    padding: 0 20px;
    border-radius: 5px;
    cursor: pointer;
}

/* Voice Overlay */
.hidden { display: none !important; }
.voice-overlay {
    text-align: center;
    padding: 20px;
    background: #1e293b;
}

.chat-content-text p {
    margin-bottom: 8px;
}
.chat-content-text p:last-child {
    margin-bottom: 0;
}
.chat-content-text ul, .chat-content-text ol {
    padding-left: 20px;
    margin-bottom: 8px;
}
.chat-content-text strong {
    color: #60a5fa; /* Light blue for bold text to make it pop */
}

.voice-overlay {
    position: absolute;
    bottom: 0; /* Align to bottom of container */
    left: 0;
    width: 100%;
    height: 0;
    background: rgba(11, 17, 32, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50; /* Lower than footer */
    overflow: hidden;
}

.voice-overlay.active {
    height: calc(100% - 70px); /* Fill page but leave header/footer visible */
    bottom: 70px; /* Offset by footer height */
}

.btn-danger {
    background: #ef4444 !important;
    animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Pulse animation for mic */
.wave-animation {
    width: 80px;
    height: 80px;
    background: var(--primary-blue);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 20px rgba(59, 130, 246, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

.typing {
    display: inline-flex;
    gap: 6px;
    padding: 10px 14px;
    background: #f1f1f1;
    border-radius: 20px;
    width: fit-content;
    margin: 10px 0;
}

.typing span {
    width: 8px;
    height: 8px;
    background: #888;
    border-radius: 50%;
    animation: breathe 1.4s infinite ease-in-out both;
}

.typing span:nth-child(1) { animation-delay: 0s; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes breathe {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.3;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.hidden {
    display: none;
}

#typingIndicator {
   /* Giving it a high order number forces it to the end of the list */
    order: 99999; 
    margin-top: 5px;
}

