/* ---------- CSS Variables & Theming ---------- */
:root {
    /* Color Palette */
    --bg-base: #050508;
    --bg-gradient-start: #0a0b12;
    --bg-gradient-end: #030305;
    
    --text-main: #ffffff;
    --text-muted: #8a91a6;
    
    /* Neon Sci-Fi Accents */
    --gemini-blue: #00e5ff;
    --gemini-glow: rgba(0, 229, 255, 0.6);
    --gemini-bg: rgba(0, 229, 255, 0.1);
    
    --eleven-amber: #ffaa00;
    --eleven-glow: rgba(255, 170, 0, 0.6);
    --eleven-bg: rgba(255, 170, 0, 0.1);
    
    --system-green: #00ff88;
    --system-red: #ff3366;
    
    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.15);
    
    /* Animation Timings */
    --transition-fast: 0.15s ease;
    --transition-smooth: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ---------- Global Reset & Base ---------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    width: 100%;
    height: 100vh;
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    overflow: hidden;
    overscroll-behavior-y: none;
}

/* Background Mesh / Deep Space Vibe */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at 50% 30%, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    z-index: -2;
}

/* Optional subtle grid overlay for sci-fi feel */
body::after {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        linear-gradient(var(--glass-border) 1px, transparent 1px),
        linear-gradient(90deg, var(--glass-border) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.15;
    z-index: -1;
    pointer-events: none;
}

/* ---------- Layout Wrapper ---------- */
#app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Mobile browser support */
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

/* ---------- Glassmorphism Utilities ---------- */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* ---------- Header & Status ---------- */
.glass-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2rem;
    background: linear-gradient(180deg, rgba(10, 11, 18, 0.8) 0%, rgba(10, 11, 18, 0) 100%);
    border-bottom: 1px solid var(--glass-border);
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 36px;
    height: 36px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--gemini-blue);
    font-size: 1.1rem;
    box-shadow: 0 0 15px var(--gemini-glow);
}

.brand-name {
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    background: linear-gradient(90deg, #fff, var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--glass-bg);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot.connected { background-color: var(--system-green); box-shadow: 0 0 8px var(--system-green); }
.dot.disconnected { background-color: var(--text-muted); }
.dot.error { background-color: var(--system-red); box-shadow: 0 0 8px var(--system-red); }

.status-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---------- Main Content Layout ---------- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* ---------- Audio Visualizer (Orb) ---------- */
.visualizer-container {
    flex: 0 0 40%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

.neural-orb {
    position: relative;
    width: 160px;
    height: 160px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.1s cubic-bezier(0.1, 2, 0.5, 1); /* Snappy bounce on audio */
    transform-origin: center center;
    will-change: transform;
}

/* Inner glowing core */
.neural-orb .core {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff 0%, var(--gemini-blue) 40%, transparent 80%);
    box-shadow: 0 0 40px var(--gemini-glow), inset 0 0 20px #fff;
    animation: core-pulse 3s infinite alternate ease-in-out;
}

/* Rotating holographic rings */
.neural-orb .ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid transparent;
}

.ring-gemini {
    width: 140px;
    height: 140px;
    border-top: 2px solid var(--gemini-blue);
    border-right: 2px solid var(--gemini-blue);
    box-shadow: 0 0 20px var(--gemini-bg);
    animation: spin-right 8s linear infinite;
}

.ring-eleven {
    width: 160px;
    height: 160px;
    border-bottom: 2px solid var(--eleven-amber);
    border-left: 2px solid var(--eleven-amber);
    box-shadow: 0 0 20px var(--eleven-bg);
    animation: spin-left 12s linear infinite;
}

.ai-status {
    margin-top: 2.5rem;
    font-size: 0.9rem;
    font-weight: 300;
    color: var(--gemini-blue);
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 0 8px var(--gemini-glow);
    animation: opacity-pulse 2s infinite;
}

/* ---------- Transcript & Chat Feed ---------- */
.transcript-container {
    flex: 1;
    margin: 0 1.5rem 1rem 1.5rem;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    /* Soft gradient fade at top and bottom for text overflow */
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 5%, black 95%, transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 5%, black 95%, transparent 100%);
}

.chat-feed {
    flex: 1;
    padding: 1.5rem 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

/* Custom Scrollbar for Chat */
.chat-feed::-webkit-scrollbar { width: 6px; }
.chat-feed::-webkit-scrollbar-track { background: transparent; }
.chat-feed::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}
.chat-feed::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* System Notice */
.system-notice {
    text-align: center;
    margin: 0.5rem 0;
}

.system-notice span {
    display: inline-block;
    padding: 0.4rem 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    letter-spacing: 0.5px;
}

.system-notice i { margin-right: 0.4rem; }

/* Message Wrappers */
.message-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    animation: message-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    opacity: 0;
    transform: translateY(20px);
}

.message-wrapper.remote { justify-content: flex-start; }
.message-wrapper.local { justify-content: flex-end; }

/* Avatars */
.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
    flex-shrink: 0;
    background: var(--bg-base);
}

.avatar.blue-glow {
    border: 1px solid var(--gemini-blue);
    color: var(--gemini-blue);
    box-shadow: 0 0 12px var(--gemini-bg);
}

.avatar.amber-glow {
    border: 1px solid var(--eleven-amber);
    color: var(--eleven-amber);
    box-shadow: 0 0 12px var(--eleven-bg);
}

/* Message Bubbles */
.message-bubble {
    position: relative;
    max-width: 75%;
    padding: 1rem 1.25rem;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    font-weight: 300;
}

/* Remote Bubble Styling (AI / Other Person) */
.remote .message-bubble {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.1) 0%, rgba(0, 0, 0, 0.4) 100%);
    border: 1px solid rgba(0, 229, 255, 0.2);
    border-bottom-left-radius: 4px;
    color: #e0fbfc;
}

/* Local Bubble Styling (You) */
.local .message-bubble {
    background: linear-gradient(135deg, rgba(255, 170, 0, 0.1) 0%, rgba(0, 0, 0, 0.4) 100%);
    border: 1px solid rgba(255, 170, 0, 0.2);
    border-bottom-right-radius: 4px;
    color: #fff6e5;
}

/* Language Tags inside bubbles */
.lang-tag {
    position: absolute;
    top: -10px;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: var(--bg-base);
    letter-spacing: 1px;
}

.remote .lang-tag {
    left: 15px;
    color: var(--gemini-blue);
    border: 1px solid var(--gemini-blue);
}

.local .lang-tag {
    right: 15px;
    color: var(--eleven-amber);
    border: 1px solid var(--eleven-amber);
}

/* ---------- Bottom Control Footer ---------- */
.control-footer {
    padding: 1rem 2rem 2rem 2rem;
    display: flex;
    justify-content: center;
    z-index: 10;
}

.control-dock {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    width: 100%;
    max-width: 400px;
}

/* Dock Buttons (Secondary) */
.dock-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    transition: var(--transition-fast);
    display: flex;
    justify-content: center;
    align-items: center;
}

.dock-btn:hover {
    color: var(--text-main);
    background: var(--glass-highlight);
}

/* Mic Wrapper & Main Button */
.mic-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mic-btn {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    z-index: 2;
    transition: var(--transition-smooth);
}

.mic-btn.idle {
    background: linear-gradient(135deg, #2a2d3a 0%, #1a1c23 100%);
    color: var(--text-main);
    border: 2px solid var(--glass-border);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.mic-btn.idle:hover {
    transform: scale(1.05);
    border-color: var(--text-muted);
}

.mic-btn.active {
    background: var(--eleven-amber);
    color: #000;
    box-shadow: 0 0 20px var(--eleven-glow);
    animation: mic-throb 1.5s infinite alternate;
}

/* The underlying glow effect when recording */
.mic-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--eleven-amber);
    opacity: 0;
    z-index: 1;
    pointer-events: none;
}

.mic-btn.active ~ .mic-glow {
    animation: ripple 1.5s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
}

/* ---------- Animations ---------- */
@keyframes pulse {
    0% { opacity: 0.4; }
    100% { opacity: 1; }
}

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

@keyframes core-pulse {
    0% { transform: scale(0.9); opacity: 0.8; }
    100% { transform: scale(1.1); opacity: 1; }
}

@keyframes spin-right {
    0% { transform: rotate(0deg) rotateX(10deg) rotateY(10deg); }
    100% { transform: rotate(360deg) rotateX(10deg) rotateY(10deg); }
}

@keyframes spin-left {
    0% { transform: rotate(360deg) rotateX(-15deg) rotateY(-15deg); }
    100% { transform: rotate(0deg) rotateX(-15deg) rotateY(-15deg); }
}

@keyframes message-pop {
    0% { opacity: 0; transform: translateY(20px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes mic-throb {
    0% { transform: scale(1); box-shadow: 0 0 15px var(--eleven-glow); }
    100% { transform: scale(1.1); box-shadow: 0 0 30px var(--eleven-glow), 0 0 10px #fff; }
}

@keyframes ripple {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
    100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

/* ---------- Responsive Design (Mobile First adjustments) ---------- */
@media (max-width: 768px) {
    .glass-header {
        padding: 1rem 1.25rem;
    }
    
    .brand-name {
        font-size: 1.1rem;
    }
    
    .status-text {
        display: none; /* Hide text on mobile, keep dot */
    }
    
    .visualizer-container {
        flex: 0 0 35%;
    }
    
    .neural-orb {
        width: 130px;
        height: 130px;
    }
    
    .ring-gemini { width: 110px; height: 110px; }
    .ring-eleven { width: 130px; height: 130px; }
    
    .transcript-container {
        margin: 0 1rem 1rem 1rem;
    }
    
    .message-bubble {
        max-width: 85%;
        padding: 0.85rem 1rem;
        font-size: 0.9rem;
    }
    
    .control-footer {
        padding: 0.5rem 1rem 1.5rem 1rem;
    }
    
    .mic-btn {
        width: 56px;
        height: 56px;
        font-size: 1.25rem;
    }
    
    .mic-glow {
        width: 56px;
        height: 56px;
    }
}
```