:root {
    --glass-surface: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.1);
    --neon-accent: #00f2ff;
    --text-main: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", sans-serif; }

body {
    background: #000; color: var(--text-main); height: 100vh; overflow: hidden; display: flex; flex-direction: column;
}

/* --- BACKGROUNDS --- */
#bgLayer { position: absolute; inset: 0; z-index: -3; transition: background 0.5s ease; background-size: cover; background-position: center; }
.bg-ultra { background: radial-gradient(circle at 50% 50%, #1a0b2e, #000000); }
.bg-ultra::after { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: conic-gradient(from 0deg, transparent, rgba(0, 242, 255, 0.1), transparent, rgba(255, 0, 255, 0.1), transparent); animation: spin 30s linear infinite; }
.bg-sunset { background: linear-gradient(to bottom, #2c3e50, #fd746c, #ff9068); }
.bg-matrix { background: #000; background-image: linear-gradient(0deg, transparent 24%, rgba(0, 255, 0, .2) 25%, rgba(0, 255, 0, .2) 26%, transparent 27%, transparent 74%, rgba(0, 255, 0, .2) 75%, rgba(0, 255, 0, .2) 76%, transparent 77%, transparent), linear-gradient(90deg, transparent 24%, rgba(0, 255, 0, .2) 25%, rgba(0, 255, 0, .2) 26%, transparent 27%, transparent 74%, rgba(0, 255, 0, .2) 75%, rgba(0, 255, 0, .2) 76%, transparent 77%, transparent); background-size: 50px 50px; }
.noise-overlay { position: absolute; inset: 0; z-index: -2; opacity: 0.03; background: url('https://grainy-gradients.vercel.app/noise.svg'); pointer-events: none; }
.vignette { position: absolute; inset: 0; z-index: -1; background: radial-gradient(circle, transparent 50%, black 120%); pointer-events: none; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* --- PARTICLE CANVAS (NEW) --- */
#particleCanvas {
    position: absolute; inset: 0; z-index: 0; pointer-events: none;
}

/* --- SIDEBARS (SHARED) --- */
.left-sidebar, .right-sidebar {
    position: fixed; top: 80px; bottom: 100px; width: 280px;
    background: rgba(10, 10, 10, 0.8); backdrop-filter: blur(40px);
    padding: 20px; display: flex; flex-direction: column; gap: 20px;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 20; box-shadow: 0 0 30px rgba(0,0,0,0.5);
}

/* LEFT DRAWER SPECIFIC */
.left-sidebar {
    left: 0; border-right: 1px solid var(--glass-border); border-radius: 0 20px 20px 0;
    transform: translateX(-100%); /* Hidden by default */
}
.left-sidebar.open { transform: translateX(0); }

/* RIGHT DRAWER SPECIFIC */
.right-sidebar {
    right: 0; border-left: 1px solid var(--glass-border); border-radius: 20px 0 0 20px;
    transform: translateX(100%); /* Hidden by default */
}
.right-sidebar.open { transform: translateX(0); }

.sidebar-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--glass-border); padding-bottom: 10px; }
.sidebar-header button { background: none; border: none; color: white; cursor: pointer; }

.widget-box { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.widget-title { font-size: 12px; color: var(--neon-accent); letter-spacing: 1px; font-weight: bold; }

/* --- WIDGETS --- */
.clock-card { text-align: center; padding: 15px; }
#clockTime { font-size: 32px; font-weight: 200; letter-spacing: 2px; }
#clockDate { font-size: 10px; opacity: 0.7; letter-spacing: 1px; color: var(--neon-accent); }

.stat-card { padding: 15px; display: flex; flex-direction: column; gap: 10px; }
.stat-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.bar-bg { flex: 1; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; }
.bar-fill { height: 100%; background: var(--neon-accent); border-radius: 2px; box-shadow: 0 0 5px var(--neon-accent); }

#notepad {
    width: 100%; height: 100%; background: rgba(0,0,0,0.3); border: 1px solid var(--glass-border);
    color: white; resize: none; outline: none; font-size: 13px; line-height: 1.5; padding: 10px; border-radius: 10px;
}

/* --- AMBIENT CORE --- */
.ambient-controls { display: flex; align-items: center; gap: 15px; background: rgba(0,0,0,0.3); padding: 10px; border-radius: 10px; border: 1px solid var(--glass-border); }
.visualizer { display: flex; gap: 3px; height: 20px; align-items: flex-end; }
.bar { width: 4px; background: var(--neon-accent); height: 5px; border-radius: 2px; transition: height 0.1s; }
.playing .bar { animation: bounce 0.5s infinite alternate; }
.playing .bar:nth-child(2) { animation-delay: 0.1s; }
.playing .bar:nth-child(3) { animation-delay: 0.2s; }
.playing .bar:nth-child(4) { animation-delay: 0.3s; }
@keyframes bounce { 0% { height: 5px; opacity: 0.5; } 100% { height: 20px; opacity: 1; } }
.small-btn { font-size: 10px; padding: 5px 10px; height: auto; }

/* --- HEADER & CONTROLS --- */
header { padding: 20px; display: flex; justify-content: space-between; align-items: center; z-index: 10; position: relative; }
.header-controls { display: flex; gap: 10px; }
.island { background: rgba(0,0,0,0.5); border: 1px solid var(--glass-border); padding: 10px 24px; border-radius: 50px; display: flex; align-items: center; gap: 12px; backdrop-filter: blur(30px); position: absolute; left: 50%; transform: translateX(-50%); }
.status-light { width: 6px; height: 6px; background: var(--neon-accent); border-radius: 50%; box-shadow: 0 0 10px var(--neon-accent); }
.title { font-size: 13px; font-weight: 600; letter-spacing: 1px; }

/* --- CHAT --- */
main { flex: 1; overflow-y: auto; padding: 20px; padding-bottom: 120px; display: flex; flex-direction: column; gap: 20px; z-index: 5; }
.message { display: flex; flex-direction: column; max-width: 85%; animation: slideUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); }
.user { align-self: flex-end; align-items: flex-end; }
.bot { align-self: flex-start; }

/* --- GLASS COMPONENTS --- */
.glass-card { background: var(--glass-surface); backdrop-filter: blur(40px); border: 1px solid var(--glass-border); box-shadow: inset 0 1px 0 0 var(--glass-highlight); padding: 18px 24px; border-radius: 24px; font-size: 16px; line-height: 1.6; }
.user .glass-card { background: rgba(0, 242, 255, 0.1); border-color: rgba(0, 242, 255, 0.2); text-align: right; }
.glass-btn { background: var(--glass-surface); border: 1px solid var(--glass-border); color: white; cursor: pointer; border-radius: 12px; transition: all 0.2s; backdrop-filter: blur(20px); }
.glass-btn:hover { background: var(--glass-highlight); transform: scale(1.05); }
.icon-only { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }

/* --- DOCK --- */
footer { position: fixed; bottom: 30px; left: 0; right: 0; display: flex; justify-content: center; z-index: 100; }
.dock { width: 90%; max-width: 600px; background: rgba(10, 10, 10, 0.7); backdrop-filter: blur(50px); border: 1px solid var(--glass-border); border-radius: 40px; padding: 8px; display: flex; align-items: center; gap: 10px; }
input { flex: 1; background: transparent; border: none; padding: 12px 15px; color: white; font-size: 16px; outline: none; }

/* --- MODALS --- */
.modal { position: fixed; inset: 20px; z-index: 200; background: #000; border: 1px solid var(--glass-border); border-radius: 24px; display: flex; flex-direction: column; box-shadow: 0 0 100px rgba(0,0,0,0.9); }
.hidden { display: none; }
.modal-header { padding: 20px; border-bottom: 1px solid var(--glass-border); display: flex; justify-content: space-between; background: #0a0a0a; border-radius: 24px 24px 0 0; }
.modal-header button { background: none; border: none; color: white; cursor: pointer; font-size: 18px; }
.modal-body { padding: 20px; color: white; }
iframe { flex: 1; border: none; background: white; border-radius: 0 0 24px 24px; }
#gameOverlay { display: none; position: fixed; inset: 0; z-index: 9999; background: black; flex-direction: column; }
#gameOverlay.active { display: flex; }
.game-bar { height: 50px; background: #111; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid #333; }
.game-bar button { background: #ff3b30; color: white; border: none; padding: 5px 15px; border-radius: 6px; cursor: pointer; font-weight: bold; }

/* --- EXTRAS --- */
pre { background: #0a0a0a; padding: 15px; border-radius: 12px; overflow-x: auto; margin-top: 10px; border: 1px solid var(--glass-border); }
code { font-family: monospace; color: var(--neon-accent); }
.run-btn { margin-top: 10px; background: var(--neon-accent); border: none; padding: 8px 16px; border-radius: 8px; color: black; font-weight: bold; cursor: pointer; }
.bg-grid { display: flex; gap: 10px; margin-top: 10px; }
.bg-option { width: 60px; height: 60px; border-radius: 12px; border: 1px solid var(--glass-border); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 10px; }
.system-controls { display: flex; gap: 10px; margin-top: 10px; }

@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
