:root {
    --bg-dark: #0f111a;
    --text-light: #e2e8f0;
    --text-muted: #94a3b8;
    --primary: #ec4899;
    --primary-glow: rgba(236, 72, 153, 0.4);
    --secondary: #8b5cf6;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --user-msg-bg: rgba(236, 72, 153, 0.2);
    --ai-msg-bg: rgba(30, 41, 59, 0.8);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-light);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    transition: background-color 2s ease;
}

/* Dynamic Animated Background Elements */
.background-elements {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

#particle-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    overflow: hidden;
}

.particle {
    position: absolute;
    top: -10vh;
    opacity: 0.8;
    user-select: none;
    animation: fall linear forwards;
}

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

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.6;
    animation: float 20s infinite ease-in-out alternate;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: var(--primary);
    top: -100px;
    left: -100px;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: var(--secondary);
    bottom: -200px;
    right: -100px;
    animation-delay: -5s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: #3b82f6;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -10s;
    opacity: 0.3;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.1); }
}

/* Glassmorphism Container */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.app-layout {
    width: 95%;
    max-width: 1100px;
    height: 85vh;
    display: flex;
    gap: 30px;
    align-items: stretch;
}

.character-display {
    flex: 1;
    min-width: 0;
    max-width: 450px;
    display: none; /* Hide on very small screens, show on medium+ */
    justify-content: center;
    align-items: center;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
}

@media (min-width: 768px) {
    .character-display {
        display: flex;
    }
}

.fullbody-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.chat-container {
    flex: 1;
    max-width: 500px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    margin: 0 auto;
}

/* Header */
.chat-header {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(15, 17, 26, 0.4);
}

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

.avatar-container {
    position: relative;
}

.avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    background: white;
    box-shadow: 0 0 15px var(--primary-glow);
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background-color: #fbbf24; /* Yellow for loading */
    border-radius: 50%;
    border: 2px solid var(--bg-dark);
    transition: background-color 0.3s ease;
}

.status-dot.ready { background-color: #10b981; } /* Green for ready */
.status-dot.typing { background-color: #3b82f6; 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 6px rgba(59, 130, 246, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

.profile-text h1 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.profile-text p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Action Buttons */
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    color: var(--primary);
    background: rgba(236, 72, 153, 0.1);
}

/* Progress Bar */
.progress-container {
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: height 0.3s, opacity 0.3s, padding 0.3s;
}

.progress-container.hidden {
    height: 0;
    opacity: 0;
    padding: 0;
    overflow: hidden;
    border: none;
}

.progress-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--secondary), var(--primary));
    border-radius: 3px;
    transition: width 0.1s ease;
}

#progress-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
}

/* Chat History */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Custom Scrollbar */
.chat-history::-webkit-scrollbar { width: 6px; }
.chat-history::-webkit-scrollbar-track { background: transparent; }
.chat-history::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }
.chat-history::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* Messages */
.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    animation: fadeIn 0.3s ease-out forwards;
    word-wrap: break-word;
}

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

.msg-user {
    align-self: flex-end;
    background: var(--user-msg-bg);
    border: 1px solid rgba(236, 72, 153, 0.3);
    border-bottom-right-radius: 4px;
}

.msg-ai {
    align-self: flex-start;
    background: var(--ai-msg-bg);
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 4px;
}

/* Input Area */
.chat-input-container {
    padding: 20px 24px;
    display: flex;
    gap: 12px;
    background: rgba(15, 17, 26, 0.6);
    border-top: 1px solid var(--glass-border);
}

#chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 12px 20px;
    color: var(--text-light);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.action-dropdown {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 0 15px;
    color: var(--text-light);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.action-dropdown:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.action-dropdown:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-dropdown option {
    background: var(--bg-dark);
    color: var(--text-light);
}

#chat-input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 10px var(--primary-glow);
}

#chat-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#mic-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

#mic-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

#mic-btn.recording {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-color: #ef4444;
    animation: mic-pulse 1.5s infinite;
}

@keyframes mic-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); }
}

#mic-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#send-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

#send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 0 15px var(--primary-glow);
}

#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--text-muted);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    width: 90%;
    max-width: 400px;
    padding: 30px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal h2 { font-size: 1.5rem; color: #f87171; }
.modal p { color: var(--text-light); font-size: 0.9rem; line-height: 1.5; }

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
}

.btn.secondary:hover { background: rgba(255, 255, 255, 0.2); }

.btn.danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn.danger:hover { background: rgba(239, 68, 68, 0.4); }

/* Setup Screen */
.setup-screen {
    position: absolute;
    top: 73px; /* Below header */
    left: 0;
    width: 100%;
    height: calc(100% - 73px);
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    text-align: center;
    transition: opacity 0.4s ease;
}

.setup-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.setup-content {
    background: rgba(0, 0, 0, 0.4);
    padding: 32px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    max-width: 400px;
}

.setup-content.hidden {
    display: none;
}

.setup-content h2 {
    color: var(--primary);
    margin-bottom: 16px;
}

.setup-content p {
    margin-bottom: 24px;
    line-height: 1.5;
}

.action-btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 14px 24px;
    font-size: 1.1rem;
    width: 100%;
    box-shadow: 0 4px 15px var(--primary-glow);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.2s;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.error-list {
    text-align: left;
    margin-top: 16px;
    color: #fca5a5;
    padding-left: 20px;
}

.error-list li {
    margin-bottom: 8px;
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

