:root {
    --bg-color: #050714; /* Deep dark navy */
    --text-primary: #ffffff;
    --text-secondary: #9aa0b8;
    --glass-bg: rgba(20, 24, 44, 0.5);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    --color-pink: #ff3366; /* Neon pink */
    --color-purple: #9d4edd; /* Neon purple */
    --color-blue: #00f5d4; /* Neon cyan/blue */
    
    --nav-height: 70px;
}

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

body {
    font-family: 'Pretendard', -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    font-weight: 300;
}

#universe-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

#app-container {
    position: relative;
    z-index: 10;
    width: 100vw; height: 100vh;
    display: flex; justify-content: center;
}

.screen {
    position: absolute;
    width: 100%; max-width: 480px; height: 100%;
    display: none; flex-direction: column;
    background: transparent;
}
.screen.active { display: flex; }

/* Setup Screen */
.glass-panel {
    align-items: center; justify-content: center; padding: 40px;
    background: rgba(5, 7, 20, 0.9); z-index: 100;
}
.glass-panel h1 { font-size: 1.8rem; margin-bottom: 12px; font-weight: 500; }
.glass-panel p { color: var(--text-secondary); margin-bottom: 40px; font-size: 0.95rem; }
.custom-group { width: 100%; margin-bottom: 30px; }
.custom-group label { display: block; font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 12px; }
.custom-group input { 
    width: 100%; padding: 16px; background: rgba(255,255,255,0.05); 
    border: 1px solid var(--glass-border); color: var(--text-primary); 
    border-radius: 16px; outline: none; transition: border-color 0.3s;
}
.primary-btn { 
    width: 100%; padding: 18px; border-radius: 16px; font-size: 1rem; 
    font-weight: 500; cursor: pointer; border: none;
}
.neon-btn {
    background: linear-gradient(45deg, var(--color-pink), var(--color-purple));
    color: white; box-shadow: 0 4px 15px rgba(255, 51, 102, 0.4);
}

/* Layout */
#content-area {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    padding-bottom: var(--nav-height);
}

/* Tabs */
.tab-content { display: none; flex-direction: column; min-height: 100%; }
.tab-content.active { display: flex; }

/* Dashboard / Relationship Tab */
.dashboard-header { padding: 40px 24px 10px 24px; }
.dashboard-header h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 4px;}
.dashboard-header p { font-size: 0.8rem; color: var(--text-secondary); }

.chat-visual-area { height: 35vh; width: 100%; }

.dashboard-cards { padding: 0 20px 30px 20px; display: flex; flex-direction: column; gap: 16px; }
.glass-card {
    background: var(--glass-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border); border-radius: 20px; padding: 20px;
}
.row-card { display: flex; gap: 20px; }
.score-section { flex: 1; display: flex; flex-direction: column; justify-content: center;}
.score-section span { font-size: 0.8rem; color: var(--text-secondary); }
.score-value { font-size: 2.5rem; font-weight: 700; color: var(--color-pink); margin: 4px 0; }
.score-value span { font-size: 1.2rem; font-weight: 400; }
.score-status { font-size: 0.85rem; color: var(--text-primary); }

.stats-section { flex: 1; display: flex; flex-direction: column; gap: 12px; justify-content: center;}
.stats-section div { display: flex; flex-direction: column; }
.stats-section span { font-size: 0.75rem; color: var(--text-secondary); }
.stats-section strong { font-size: 1rem; font-weight: 500; color: var(--color-blue); }

.graph-card { padding: 20px 20px 10px 20px;}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header h3 { font-size: 1.1rem; font-weight: 500; }
.graph-filters { display: flex; gap: 12px; font-size: 0.8rem; color: var(--text-secondary); }
.graph-filters span.active { color: var(--text-primary); background: rgba(255,255,255,0.1); padding: 4px 10px; border-radius: 12px; }
#timeline-canvas { width: 100%; height: 80px; }

.advice-card h3 { font-size: 1.1rem; font-weight: 500; margin-bottom: 12px; }
.advice-text { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 20px; }
.circle-stats { display: flex; justify-content: space-around; }
.circle-stat { display: flex; flex-direction: column; align-items: center; gap: 8px; position: relative;}
.circle-stat span { font-size: 0.8rem; color: var(--text-secondary); }
.circular-chart { display: block; margin: 0 auto; max-width: 60px; max-height: 60px; }
.circle-bg { fill: none; stroke: rgba(255,255,255,0.05); stroke-width: 2.5; }
.circle { fill: none; stroke-width: 2.5; stroke-linecap: round; animation: progress 1s ease-out forwards; }
.pink .circle { stroke: var(--color-pink); }
.purple .circle { stroke: var(--color-purple); }
.blue .circle { stroke: var(--color-blue); }
.circle-text { position: absolute; top: 22px; left: 50%; transform: translate(-50%, 0); font-size: 0.9rem; font-weight: 500; }

/* Chat Tab */
#tab-chat { background: var(--bg-color); }
.chat-header { padding: 40px 20px 10px 20px; display: flex; flex-direction: column; gap: 12px; background: rgba(5,7,20,0.8); backdrop-filter: blur(10px); z-index: 10;}
.chat-header h2 { font-size: 1.5rem; font-weight: 600; }
.chat-search input { width: 100%; padding: 12px 16px; border-radius: 12px; background: rgba(255,255,255,0.05); border: none; color: white; outline: none; }
.chat-messages-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; scroll-behavior: smooth;}
.message { max-width: 75%; font-size: 0.95rem; line-height: 1.4; display: flex; flex-direction: column;}
.message.system { align-self: center; color: var(--text-secondary); font-size: 0.8rem; padding: 8px 0; }
.message.me { align-self: flex-end; }
.message.me .msg-content { background: var(--color-pink); color: white; padding: 12px 16px; border-radius: 20px 20px 4px 20px; }
.message.other { align-self: flex-start; display: flex; flex-direction: row; gap: 10px; max-width: 85%;}
.profile-pic { width: 36px; height: 36px; border-radius: 18px; background: var(--glass-bg); display: flex; align-items: center; justify-content: center; font-size: 0.8rem; color: var(--text-secondary); flex-shrink: 0;}
.message.other .msg-content { background: rgba(255,255,255,0.1); padding: 12px 16px; border-radius: 20px 20px 20px 4px; }

.chat-input-area { padding: 10px 20px 20px 20px; display: flex; gap: 12px; align-items: center; background: var(--bg-color); }
#message-input { flex: 1; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border); border-radius: 24px; padding: 14px 20px; color: var(--text-primary); font-size: 0.95rem; outline: none; }
#send-btn { background: var(--color-pink); border: none; width: 44px; height: 44px; border-radius: 22px; color: white; cursor: pointer; display: flex; justify-content: center; align-items: center; box-shadow: 0 2px 10px rgba(255,51,102,0.3);}

/* Space Tab */
#tab-space { 
    background-image: url('avatar_space_bg.png'); /* Will copy the generated image here */
    background-size: cover; background-position: center; 
    justify-content: space-between; padding: 40px 20px 20px 20px;
}
.space-header { display: flex; justify-content: flex-end; }
.user-count { background: rgba(0,0,0,0.5); backdrop-filter: blur(5px); padding: 6px 12px; border-radius: 16px; font-size: 0.8rem; display: flex; align-items: center; gap: 6px;}
.space-actions { display: flex; flex-direction: column; gap: 16px; }
.space-hint { text-align: center; font-size: 0.9rem; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
.action-buttons { display: flex; gap: 12px; }
.space-btn { flex: 1; padding: 16px; border-radius: 16px; border: 1px solid var(--glass-border); background: var(--glass-bg); backdrop-filter: blur(10px); color: white; font-weight: 500; font-size: 0.9rem; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;}
.space-btn:hover { background: rgba(255,255,255,0.1); }

/* History Tab */
.history-filters { padding: 0 24px; display: flex; gap: 12px; margin-bottom: 20px;}
.history-filters span { padding: 8px 16px; border-radius: 20px; font-size: 0.9rem; color: var(--text-secondary); background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); cursor: pointer;}
.history-filters span.active { background: var(--color-pink); color: white; border: none; }

.timeline-container { padding: 0 24px 40px 24px; position: relative; display: flex; flex-direction: column; gap: 24px; }
.timeline-line { position: absolute; left: 42px; top: 10px; bottom: 0; width: 2px; background: linear-gradient(to bottom, var(--color-pink), var(--color-purple), var(--color-blue), transparent); opacity: 0.3; }
.timeline-item { display: flex; gap: 16px; align-items: flex-start; position: relative; z-index: 1;}
.timeline-icon { width: 40px; height: 40px; border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; box-shadow: 0 0 15px currentColor; }
.timeline-content { flex: 1; background: var(--glass-bg); backdrop-filter: blur(10px); padding: 16px; border-radius: 16px; border: 1px solid var(--glass-border); }
.timeline-content h4 { font-size: 1rem; font-weight: 500; margin-bottom: 4px; color: var(--text-primary); }
.timeline-content p { font-size: 0.85rem; color: var(--text-secondary); }
.timeline-date { font-size: 0.75rem; color: var(--text-secondary); padding-top: 4px; white-space: nowrap;}

/* Bottom Nav */
.bottom-nav {
    position: absolute; bottom: 0; left: 0; width: 100%; height: var(--nav-height);
    background: rgba(5, 7, 20, 0.85); backdrop-filter: blur(15px); border-top: 1px solid var(--glass-border);
    display: flex; justify-content: space-around; align-items: center; padding-bottom: env(safe-area-inset-bottom);
}
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-secondary); cursor: pointer; transition: color 0.3s; }
.nav-item span { font-size: 0.7rem; }
.nav-item.active { color: var(--color-pink); }

