:root {
    --primary: #ff477e;
    --primary-hover: #ff0a54;
    --bg-color: #f3f4f6;
    /* Super vibrant gradient */
    --bg-gradient: linear-gradient(120deg, #fccb90 0%, #d57eeb 100%);
    
    /* Refined Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.55);
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-shadow: 0 15px 45px -10px rgba(255, 10, 84, 0.25), inset 0 0 0 2px rgba(255, 255, 255, 0.4);
    
    /* Text */
    --text-main: #1e293b;
    --text-muted: #475569;
    
    /* Chat Bubbles */
    --ai-msg-bg: rgba(255, 255, 255, 0.95);
    --user-msg-bg: linear-gradient(135deg, #ff477e 0%, #ff0a54 100%);
    --user-msg-text: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-main);
    overflow: hidden;
    position: relative;
    /* Add a fun animated background pattern */
    background-image: radial-gradient(rgba(255, 255, 255, 0.3) 2px, transparent 2px);
    background-size: 30px 30px;
    animation: movePattern 20s linear infinite;
}

@keyframes movePattern {
    0% { background-position: 0 0; }
    100% { background-position: 100px 100px; }
}

/* Animated Background Decorations */
.bg-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    animation: float 10s ease-in-out infinite alternate;
}

.bg-shape-1 {
    width: 600px;
    height: 600px;
    background: #ffeb3b;
    top: -15%;
    left: -15%;
    opacity: 0.6;
}

.bg-shape-2 {
    width: 700px;
    height: 700px;
    background: #00f2fe;
    bottom: -20%;
    right: -15%;
    opacity: 0.5;
    animation-delay: -3s;
}

.bg-shape-3 {
    width: 500px;
    height: 500px;
    background: #ff0844;
    top: 40%;
    left: 40%;
    opacity: 0.4;
    animation-duration: 15s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1) rotate(0deg); }
    50% { transform: translate(50px, 80px) scale(1.1) rotate(10deg); }
    100% { transform: translate(-30px, 40px) scale(0.9) rotate(-10deg); }
}

/* Floating Emojis */
#floating-elements {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.floating-emoji {
    position: absolute;
    font-size: 2rem;
    animation: floatEmoji 15s linear infinite;
    opacity: 0.7;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

@keyframes floatEmoji {
    0% { transform: translateY(110vh) rotate(0deg) scale(0.8); opacity: 0; }
    10% { opacity: 0.8; }
    90% { opacity: 0.8; }
    100% { transform: translateY(-10vh) rotate(360deg) scale(1.2); opacity: 0; }
}

/* Glassmorphism Utilities */
.glass-effect {
    background: var(--glass-bg);
    backdrop-filter: blur(28px) saturate(200%);
    -webkit-backdrop-filter: blur(28px) saturate(200%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    width: 90%;
    max-width: 420px;
    padding: 2.5rem 2rem;
    border-radius: 30px;
    text-align: center;
    transform: translateY(50px) scale(0.8) rotate(-5deg);
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
    background: rgba(255, 255, 255, 0.9);
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1) rotate(0deg);
}

.close-modal-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    padding: 0;
    background: #f1f5f9;
    border-radius: 50%;
    color: var(--text-muted);
}

.close-modal-btn:hover {
    background: #fee2e2;
    color: #ef4444;
    transform: rotate(90deg) scale(1.1);
}

.modal-icon {
    font-size: 64px;
    background: linear-gradient(135deg, #ff0844 0%, #ffb199 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
    animation: pulseIcon 2s infinite;
}

@keyframes pulseIcon {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.modal-content h2 {
    margin-bottom: 0.75rem;
    font-size: 1.6rem;
    font-weight: 800;
}

.modal-content p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.modal-content input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    font-size: 1rem;
    margin-bottom: 1.5rem;
    outline: none;
    transition: all 0.3s;
    background: rgba(255, 255, 255, 0.9);
}

.modal-content input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(255, 71, 126, 0.2);
    transform: translateY(-2px);
}

.btn-primary {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #ff477e 0%, #ff0a54 100%);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 8px 20px rgba(255, 10, 84, 0.4);
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 25px rgba(255, 10, 84, 0.5);
}

.btn-primary:active {
    transform: scale(0.95);
}

.modal-footer {
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

.modal-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 1000px;
    height: 92vh;
    border-radius: 36px;
    display: flex;
    flex-direction: column;
    margin: 20px;
    position: relative;
    z-index: 10;
    animation: appEntrance 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes appEntrance {
    0% { transform: scale(0.8) translateY(100px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Header */
.chat-header {
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.4);
    border-radius: 36px 36px 0 0;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.avatar {
    width: 52px;
    height: 52px;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 28px;
    box-shadow: 0 8px 15px rgba(0,0,0,0.15);
    transform: rotate(-10deg);
    animation: jiggleAvatar 5s infinite;
}

@keyframes jiggleAvatar {
    0%, 100% { transform: rotate(-10deg) scale(1); }
    50% { transform: rotate(10deg) scale(1.1); }
}

.bg-gradient {
    background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
}

.header-text h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    text-shadow: 0 2px 4px rgba(255,255,255,0.8);
}

.header-text .status {
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-text .status::before {
    content: '';
    display: block;
    width: 10px;
    height: 10px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.8);
    animation: statusPulse 1.5s infinite;
}

@keyframes statusPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.icon-btn {
    background: rgba(255,255,255,0.6);
    border: 2px solid rgba(255,255,255,0.8);
    color: var(--text-muted);
    cursor: pointer;
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.icon-btn:hover {
    background: white;
    color: var(--primary);
    transform: translateY(-4px) scale(1.1) rotate(5deg);
    box-shadow: 0 8px 15px rgba(255, 71, 126, 0.2);
}

/* Chat Area */
.chat-area {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
    scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar {
    width: 10px;
}
.chat-area::-webkit-scrollbar-track {
    background: transparent;
}
.chat-area::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #fccb90, #d57eeb);
    border-radius: 10px;
    border: 3px solid rgba(255,255,255,0.5);
    background-clip: padding-box;
}

.message-wrapper {
    display: flex;
    gap: 16px;
    max-width: 85%;
    animation: messagePop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) both;
}

.message-wrapper:hover .avatar {
    transform: scale(1.1) rotate(10deg);
}

@keyframes messagePop {
    from { opacity: 0; transform: translateY(30px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-message {
    align-self: flex-start;
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-avatar {
    background: linear-gradient(135deg, #00c6fb 0%, #005bea 100%);
    width: 44px;
    height: 44px;
    border-radius: 16px;
    flex-shrink: 0;
    transition: all 0.3s;
    box-shadow: 0 6px 15px rgba(0, 198, 251, 0.3);
}

.user-avatar {
    background: linear-gradient(135deg, #ff0844 0%, #ffb199 100%);
    width: 44px;
    height: 44px;
    border-radius: 16px;
    flex-shrink: 0;
    transition: all 0.3s;
    box-shadow: 0 6px 15px rgba(255, 8, 68, 0.3);
}

.message-content {
    padding: 18px 24px;
    font-size: 1.05rem;
    line-height: 1.6;
    border: 2px solid rgba(255,255,255,0.6);
    transition: all 0.3s;
}

.message-wrapper:hover .message-content {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.ai-message .message-content {
    background: var(--ai-msg-bg);
    border-radius: 28px 28px 28px 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.05);
    color: var(--text-main);
}

.user-message .message-content {
    background: var(--user-msg-bg);
    color: var(--user-msg-text);
    border-radius: 28px 28px 8px 28px;
    box-shadow: 0 10px 30px rgba(255, 10, 84, 0.3);
    border: none;
}

/* Markdown Styles */
.ai-message .message-content p { margin-bottom: 0.85rem; }
.ai-message .message-content p:last-child { margin-bottom: 0; }
.ai-message .message-content strong { font-weight: 800; color: #0f172a; }
.ai-message .message-content ul, .ai-message .message-content ol { margin-left: 1.5rem; margin-bottom: 0.85rem; }
.ai-message .message-content li { margin-bottom: 4px; }
.ai-message .message-content pre {
    background: #0f172a;
    color: #f8fafc;
    padding: 16px;
    border-radius: 16px;
    overflow-x: auto;
    margin: 1rem 0;
    font-family: 'Fira Code', monospace;
    box-shadow: inset 0 4px 8px rgba(0,0,0,0.3);
    border: 1px solid #334155;
}
.ai-message .message-content code {
    background: #f1f5f9;
    color: #e11d48;
    padding: 4px 8px;
    border-radius: 8px;
    font-family: 'Fira Code', monospace;
    font-size: 0.9em;
    font-weight: 600;
}
.ai-message .message-content pre code {
    background: transparent;
    color: #38bdf8;
    padding: 0;
    font-weight: normal;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 8px;
    padding: 16px 20px !important;
}

.dot {
    width: 10px;
    height: 10px;
    background: linear-gradient(135deg, #00c6fb 0%, #005bea 100%);
    border-radius: 50%;
    animation: bounce 1.2s infinite cubic-bezier(0.455, 0.03, 0.515, 0.955) both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

/* Input Area */
.input-area {
    padding: 0 30px 30px 30px;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    padding: 12px 16px;
    border-radius: 30px;
    gap: 12px;
    background: rgba(255,255,255,0.9);
    border: 3px solid rgba(255,255,255,0.8);
    box-shadow: 0 10px 40px rgba(0,0,0,0.08);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.input-wrapper:focus-within {
    background: #ffffff;
    box-shadow: 0 15px 50px rgba(255, 71, 126, 0.2);
    border-color: rgba(255, 71, 126, 0.4);
    transform: translateY(-4px) scale(1.01);
}

#userInput {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 8px;
    font-size: 1.1rem;
    font-weight: 500;
    resize: none;
    outline: none;
    max-height: 150px;
    min-height: 48px;
    line-height: 1.5;
    color: var(--text-main);
}

#userInput::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.send-btn {
    background: linear-gradient(135deg, #ff477e 0%, #ff0a54 100%);
    color: white;
    border-radius: 24px;
    width: 52px;
    height: 52px;
    border: none;
    margin-bottom: 2px;
    box-shadow: 0 6px 15px rgba(255, 10, 84, 0.4);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.send-btn:hover:not(:disabled) {
    transform: translateY(-4px) scale(1.15) rotate(-10deg);
    box-shadow: 0 10px 25px rgba(255, 10, 84, 0.6);
}

.send-btn:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }
    .chat-header {
        border-radius: 0;
    }
    .message-wrapper {
        max-width: 95%;
    }
    .input-area {
        padding: 0 16px 16px 16px;
    }
}
