:root {
    --bg-dark: #000000;
    --bg-gradient: radial-gradient(circle at 50% 0%, #1a1b26 0%, #000000 100%);
    --primary: #4f46e5;
    /* Indigo 600 */
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --surface-glass: rgba(20, 20, 25, 0.7);
    --surface-border: rgba(255, 255, 255, 0.08);
    --text-main: #ffffff;
    --text-secondary: #94a3b8;
    --success: #10b981;
    --font-stack: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --radius-lg: 24px;
    --radius-bubble: 18px;
    --header-height: 70px;
    --input-area-height: auto;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    height: 100%;
    width: 100%;
    font-family: var(--font-stack);
    background: var(--bg-dark);
    background-image: var(--bg-gradient);
    color: var(--text-main);
    overflow: hidden;
    /* Prevent body scroll, container handles it */
}

/* Abstract Background (Subtle) */
body::before {
    content: '';
    position: absolute;
    top: -20%;
    left: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, rgba(79, 70, 229, 0.15) 0%, transparent 70%);
    filter: blur(80px);
    z-index: -1;
    animation: pulse 10s ease-in-out infinite alternate;
}

body::after {
    content: '';
    position: absolute;
    bottom: -10%;
    right: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.1) 0%, transparent 70%);
    filter: blur(80px);
    z-index: -1;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    100% {
        transform: scale(1.1);
        opacity: 0.7;
    }
}

/* Main Layout */
.app-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    height: 100dvh;
    /* Mobile viewport fix */
    padding: 20px;
}

/* Chat Shell */
.glass-shell {
    width: 100%;
    max-width: 480px;
    /* Mobile focused max-width */
    height: 100%;
    max-height: 850px;
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

/* Header */
.main-header {
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--surface-border);
    background: rgba(20, 20, 25, 0.4);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: var(--primary-gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.brand-text h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.brand-text p {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lang-select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--surface-border);
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-select option {
    background: #1a1b26;
    /* Dark background for options */
    color: #ffffff;
    /* White text */
    padding: 10px;
}

.lang-select:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: background 0.3s;
}

.status-dot.connected {
    background: var(--success);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

/* Chat History */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.chat-history::-webkit-scrollbar {
    width: 4px;
}

.chat-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.message {
    display: flex;
    width: 100%;
    opacity: 0;
    animation: fadeIn 0.3s forwards ease-out;
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius-bubble);
    font-size: 15px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.message.user .bubble {
    background: var(--primary-gradient);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.message.assistant .bubble {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--surface-border);
}

/* Typing Indicator */
.typing-dots::after {
    content: '...';
    animation: typing 1.5s infinite;
    letter-spacing: 2px;
    font-weight: 700;
}

@keyframes typing {
    0% {
        opacity: 0.2;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.2;
    }
}

/* Control Area */
.chat-controls {
    padding: 16px 20px;
    background: rgba(10, 10, 15, 0.6);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--surface-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Visualizer */
.mini-player {
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.bar {
    width: 4px;
    height: 6px;
    background: var(--primary);
    border-radius: 2px;
    transition: height 0.1s;
}

.bar.animating {
    animation: equalize 0.5s infinite alternate;
}

@keyframes equalize {
    0% {
        height: 6px;
        opacity: 0.5;
    }

    100% {
        height: 24px;
        opacity: 1;
    }
}

/* Input Area */
.input-group {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--surface-border);
    border-radius: 24px;
    padding: 8px 8px 8px 16px;
    transition: border-color 0.2s;
}

.input-group:focus-within {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-family: inherit;
    font-size: 15px;
    resize: none;
    max-height: 100px;
    padding: 10px 0;
    line-height: 1.4;
}

textarea:focus {
    outline: none;
}

textarea::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* Buttons */
.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    background: transparent;
    color: var(--text-secondary);
}

.icon-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

.icon-btn.active {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    animation: glow-pulse 2s infinite;
}

@keyframes glow-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--primary-gradient);
    color: white;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.send-btn:hover {
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Mobile Adaptations */
@media (max-width: 600px) {
    .app-container {
        padding: 0;
    }

    .glass-shell {
        border-radius: 0;
        border: none;
        max-width: 100%;
    }

    .bubble {
        font-size: 16px;
        /* Larger text on mobile */
    }
}