: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);
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-yellow: #fbbf24;
    --accent-red: #ef4444;
    --accent-red-light: #f87171;
    --accent-red-pale: #fca5a5;
    --accent-amber: #f59e0b;
    --accent-purple: #a78bfa;
    --border-color: var(--glass-border);
}

* {
    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: var(--accent-blue);
    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;
    justify-content: center;
}

.character-display {
    flex: 1;
    min-width: 0;
    max-width: 250px;
    display: none; /* Hide on very small screens, show on medium+ */
    justify-content: center;
    align-items: flex-end;
    border-radius: 24px;
    overflow: hidden;
    position: relative;
}

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

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

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

/* 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);
    transition: transform 0.3s ease;
    position: relative;
    z-index: 10;
}

.avatar:hover {
    transform: scale(3);
    z-index: 100;
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background-color: gray;
    border-radius: 50%;
    z-index: 101;
    border: 2px solid var(--bg-dark);
    transition: background-color 0.3s ease, opacity 0.3s ease;
}

.avatar-container:hover .status-dot {
    opacity: 0;
}

.status-dot.waking { background-color: var(--accent-yellow); }
.status-dot.ready { background-color: #15803d; }
.status-dot.typing { background-color: #22c55e; animation: pulse-green 1.5s infinite; }

@keyframes pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 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);
}

.profile-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-name-row h1 {
    margin: 0;
}

/* Relationship Status Badge */
.relationship-badge {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    transition: color 0.5s;
}

/* TTS Button */
.tts-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.tts-btn:hover {
    color: var(--primary);
}

.tts-icon-visible { display: block; }
.tts-icon-hidden { display: none; }

/* 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;
}

.large-icon-btn {
    width: 64px;
    height: 64px;
    font-size: 32px; /* For emojis */
    padding: 12px;
}

.top-toolbar {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    width: 100%;
    padding: 10px 0;
    background: rgba(15, 17, 26, 0.6);
    border-bottom: 1px solid var(--glass-border);
}

.top-toolbar.hidden {
    display: none;
}

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

/* Back Link */
.back-link {
    position: absolute;
    top: 20px;
    left: 30px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 1.05rem;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--primary);
}

/* Developer Dashboard */
.dev-dashboard {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.85);
    color: var(--accent-green);
    font-family: monospace;
    font-size: 0.75rem;
    padding: 15px;
    border-radius: 8px;
    z-index: 999;
    display: none;
    white-space: pre-wrap;
    pointer-events: none;
    max-width: 350px;
    border: 1px solid var(--accent-green);
    text-align: left;
    line-height: 1.4;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

/* 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;
    position: relative;
    transition: box-shadow 0.5s ease, border-color 0.5s ease;
}

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

.msg-system {
    align-self: center;
    max-width: 90%;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 8px 16px;
    margin: 5px 0;
    color: black;
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.msg-reward {
    background: #fde047; /* Yellow */
}

.msg-penalty {
    background: #fca5a5; /* Light Red */
}

/* 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: var(--accent-red);
    border-color: var(--accent-red);
    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);
}

/* Chat Footer */
.chat-footer-tip {
    background: rgba(15, 17, 26, 0.6);
    padding: 5px 24px 10px 24px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.chat-footer-actions {
    background: rgba(15, 17, 26, 0.6);
    padding: 5px 24px 15px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.action-text-example {
    color: var(--accent-purple);
    font-style: italic;
}

.tip-examples {
    font-size: 0.75rem;
    opacity: 0.8;
}

.footer-link-btn {
    background: none;
    border: none;
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
    font-family: inherit;
    transition: opacity 0.2s;
}

.footer-link-btn:hover {
    opacity: 0.7;
}

.footer-link-dev {
    color: var(--accent-green);
}

.footer-link-danger {
    color: var(--accent-red-light);
}

/* System Requirements Link */
.system-req-link {
    position: absolute;
    bottom: 20px;
    width: 100%;
    text-align: center;
    z-index: 10;
}

.system-req-anchor {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    border-bottom: 1px dashed var(--text-muted);
    transition: color 0.2s;
}

.system-req-anchor:hover {
    color: var(--primary);
}

/* 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: var(--accent-red-light); }
.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: var(--accent-red-pale);
    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);
}

/* Setup Form Elements */
.setup-form-group {
    margin: 15px 0;
}

.setup-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 5px;
}

.form-select {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    display: block;
    background: var(--bg-dark);
    color: white;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
}

.model-warning {
    font-size: 0.85rem;
    color: var(--accent-amber);
    margin-top: 8px;
    display: none;
}

.countdown-text {
    margin-top: 15px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.storage-stats {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 15px;
    display: none;
    white-space: pre-line;
}

/* VRAM Help Drawer */
.vram-help-btn {
    background: none;
    border: none;
    color: var(--accent-purple);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.85rem;
    margin-top: 8px;
}

.vram-help-content {
    display: none;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 10px;
    text-align: left;
    line-height: 1.5;
    border: 1px solid var(--border-color);
}

.vram-help-title {
    color: #fff;
}

.vram-help-note {
    color: var(--accent-red-pale);
}

.code-inline {
    background: #333;
    padding: 2px 5px;
    border-radius: 4px;
}

/* Lite Mode Section */
.lite-mode-section {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.lite-mode-description {
    font-size: 0.9rem;
    margin-top: 5px;
}

.lite-mode-btn {
    margin-top: 15px;
    width: 100%;
}

/* 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); }
}

/* Floating Score Text */
.floating-score {
    position: absolute;
    bottom: 30%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.2rem;
    font-weight: 700;
    text-shadow: 2px 2px 5px rgba(0,0,0,1);
    pointer-events: none;
    animation: floatUpSlow 4.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    z-index: 200;
    white-space: nowrap;
}

@keyframes floatUpSlow {
    0% {
        opacity: 0;
        bottom: 30%;
        transform: translate(-50%, 0) scale(0.8);
    }
    15% {
        opacity: 1;
        transform: translate(-50%, -10px) scale(1.1);
    }
    85% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        bottom: 80%;
        transform: translate(-50%, -100px) scale(1);
    }
}

/* Message Reaction Emoji */
.message-reaction {
    position: absolute;
    bottom: -10px;
    right: 10px;
    font-size: 1.2rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    padding: 3px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    z-index: 10;
    pointer-events: none;
    line-height: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
/* Scene Context Panel */
.scene-settings-panel {
    background: var(--glass-bg);
    border-bottom: 1px solid var(--glass-border);
    padding: 15px 20px;
    animation: slideDown 0.3s ease-out;
    position: absolute;
    top: 73px;
    left: 0;
    width: 100%;
    z-index: 20;
    backdrop-filter: blur(15px);
}

.scene-close-x {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #ef4444;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}
.scene-close-x:hover {
    color: #f87171;
}

.scene-panel-footer {
    display: flex;
    justify-content: center;
    margin-top: 15px;
}

.scene-close-btn {
    flex: none;
    padding: 6px 20px;
    font-size: 0.9rem;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}
.scene-close-btn:hover {
    background: #dc2626;
}

.scene-settings-panel.hidden {
    display: none !important;
}

/* Scene Display Overlay */
.scene-display-overlay {
    position: absolute;
    top: 45px;
    left: 20px;
    right: 20px;
    background: rgba(15, 17, 26, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 15px;
    color: var(--text-light);
    font-size: 0.85rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 5;
    pointer-events: auto;
}

.scene-display-title {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 4px;
}

.scene-display-overlay div:not(.scene-display-title) {
    margin-bottom: 4px;
}

#scene-display-change-btn {
    margin: 10px auto 0 auto;
    display: block;
    width: max-content;
    padding: 6px 20px;
    background: var(--primary); /* Pink theme */
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#scene-display-change-btn:hover {
    box-shadow: 0 0 10px var(--primary-glow);
    filter: brightness(1.1);
}
