:root {
    --bg-color: #000;
    --glass: rgba(10, 10, 10, 0.95); 
    --border: rgba(255, 255, 255, 0.08);
    --accent: #fff;
    --neon: #4fd1c5;
    --psy-purple: #9f7aea;
    --dosage: 0; 
}

/* --- GLOBAL RESET --- */
* { box-sizing: border-box; }

body {
    margin: 0;
    height: 100vh;
    font-family: 'Space Grotesk', sans-serif;
    color: #e0e0e0;
    background: #000;
    overflow: hidden; 
    display: flex;
    justify-content: center;
    align-items: center;
}

/* --- REACTIVE BACKGROUND --- */
#nebula-bg {
    position: fixed; inset: -10%; width: 120%; height: 120%;
    z-index: -1;
    background: linear-gradient(-45deg, #020202, #0d060d, #050d0d, #000000);
    background-size: 400% 400%;
    animation: nebula-flow 20s ease infinite;
    transform: scale(var(--audio-scale, 1)); 
    filter: brightness(var(--audio-bright, 1));
    transition: transform 0.1s linear, filter 0.1s linear;
}

/* --- INTRO OVERLAY --- */
#intro-overlay {
    position: fixed; inset: 0;
    background: #000; z-index: 9999;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    transition: opacity 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.intro-content { text-align: center; max-width: 600px; padding: 20px; }
.intro-content h1 { 
    font-size: 3rem; letter-spacing: 12px; font-weight: 700; margin: 0; 
    background: linear-gradient(to bottom, #fff, #444);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.intro-content p { letter-spacing: 4px; color: var(--neon); text-transform: uppercase; margin: 20px 0 40px 0; font-size: 0.9rem; }

#enter-btn {
    background: transparent; border: 1px solid rgba(255,255,255,0.3); color: #fff;
    padding: 20px 60px; font-family: inherit; cursor: pointer;
    text-transform: uppercase; letter-spacing: 4px; font-size: 0.8rem;
    transition: all 0.5s;
}
#enter-btn:hover { background: #fff; color: #000; box-shadow: 0 0 30px rgba(255,255,255,0.2); border-color: #fff; }

/* --- INTRO FOOTER LINKS --- */
.intro-footer {
    margin-top: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    opacity: 0;
    animation: fadeIn 3s ease-in 1s forwards; /* Delayed fade in */
}

.footer-link {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.3);
    text-decoration: none;
    letter-spacing: 2px;
    font-weight: 500;
    text-transform: uppercase;
    transition: all 0.4s ease;
}

.footer-link:hover {
    color: var(--neon);
    text-shadow: 0 0 10px var(--neon);
}

.footer-divider {
    color: rgba(255, 255, 255, 0.1);
    font-size: 0.6rem;
}

/* --- THE MONOLITH --- */
.app-wrapper {
    width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
    padding: 20px;
}

.monolith-container {
    width: 100%; 
    max-width: 900px; 
    height: 85vh;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 4px; 
    backdrop-filter: blur(8px); 
    display: flex; flex-direction: column;
    position: relative; z-index: 10;
    box-shadow: 0 50px 100px rgba(0,0,0,0.8);
    transition: border-color 1s, transform 1s;
}

header {
    padding: 25px 30px;
    border-bottom: 1px solid var(--border);
    display: flex; 
    justify-content: space-between; 
    align-items: center;
}

.header-left { 
    display: flex;             
    align-items: center;       
    gap: 12px;                 
    font-size: 0.7rem; 
    letter-spacing: 2px; 
    color: #555; 
    font-weight: 700; 
    text-transform: uppercase; 
    white-space: nowrap;       
    flex: 1;
}

.status-dot { 
    width: 8px;                
    height: 8px; 
    background: #0f0; 
    border-radius: 50%; 
    box-shadow: 0 0 8px #0f0; 
    flex-shrink: 0;            
}

/* --- CHAT AREA --- */
.chat-viewport {
    flex: 1; padding: 40px;
    overflow-y: auto;
    display: flex; flex-direction: column; gap: 25px; 
}

.msg {
    max-width: 75%; 
    line-height: 1.6;
    padding: 14px 20px; 
    border-radius: 4px;
    font-size: 0.95rem;
    position: relative;
    animation: driftIn 0.6s ease-out forwards;
}

.system { 
    color: #444; 
    text-align: center; 
    font-size: 0.7rem; 
    letter-spacing: 1px; 
    font-style: italic; 
    margin: 10px auto;
    width: 100%;
}

.user { 
    align-self: flex-end; 
    color: #000; 
    background: #fff; 
    box-shadow: 10px 10px 30px rgba(0,0,0,0.3);
    margin-left: 20%; 
}

.bot { 
    align-self: flex-start; 
    color: #fff; 
    background: rgba(255,255,255,0.12); 
    border-left: 2px solid var(--border);
    margin-right: 20%; 
}

/* --- CONTROLS --- */
.control-panel { padding: 35px; border-top: 1px solid var(--border); background: rgba(0,0,0,0.2); }
.slider-group { display: flex; align-items: center; gap: 20px; margin-bottom: 30px; }
.dosage-label { width: 60px; text-align: right; color: #fff; font-weight: 700; font-size: 0.9rem; }

input[type=range] { flex: 1; -webkit-appearance: none; height: 2px; background: #222; outline: none; }
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 40px; height: 10px; background: #fff; border-radius: 0; cursor: pointer;
}

.input-group { display: flex; gap: 15px; border: 1px solid var(--border); padding: 8px; border-radius: 40px; }
input[type=text] { flex: 1; background: transparent; border: none; padding-left: 20px; color: #fff; font-size: 1rem; font-family: inherit; outline: none; }

#send-btn {
    background: #fff; border: none; color: #000;
    width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
    transition: 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    display: flex; justify-content: center; align-items: center;
}

/* --- NEURAL FEEDBACK (TRIP STATES) --- */
body.tripping .monolith-container { 
    animation: box-breathe 8s ease-in-out infinite; 
    border-color: var(--psy-purple); 
    text-shadow: 
        calc(min(var(--dosage), 400) / 400 * 1px) 0 #ff00ff, 
        calc(min(var(--dosage), 400) / 400 * -1px) 0 #00ffff;
}

body.tripping .status-dot { background: #9f7aea; box-shadow: 0 0 10px #9f7aea; }

body.tripping .msg.bot {
    filter: drop-shadow(0 0 2px var(--psy-purple)); 
    border-left: 2px solid var(--neon);
}

/* GLITCH EFFECT */
body.glitch {
    filter: invert(1) hue-rotate(180deg);
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes nebula-flow { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

@keyframes box-breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.002); box-shadow: 0 60px 120px rgba(0,0,0,0.9); }
}

/* --- MOBILE --- */
@media (max-width: 768px) {
    .monolith-container { height: 90vh; }
    .intro-content h1 { font-size: 1.8rem; letter-spacing: 6px; }
    .chat-viewport { padding: 20px; }
    .msg { max-width: 85%; }
    .user { margin-left: 10%; }
    .bot { margin-right: 10%; }
}