:root {
    /* LIGHT THEME VARIABLES (Default) */
    --bg-base: #FFFFFF;
    --bg-card: #F4F6FB;
    --bg-elevated: #FFFFFF;
    --text-main: #05081A;
    --text-muted: #3D4868;
    --border-color: rgba(123, 94, 167, 0.4);
    
    /* Cosmic Accents */
    --violet: #5a3e85;
    --violet-glow: rgba(123, 94, 167, 0.15);
    --teal: #00A38F;
    --teal-glow: rgba(0, 201, 177, 0.15);
    --gold: #D4A017;
    --danger: #ff4757;
    --success: #2ed573;
    
    --nav-bg: rgba(250, 251, 255, 0.85);
    --modal-bg: rgba(255, 255, 255, 0.95);
    
    --glass-blur: blur(12px);
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 32px;
    
    --shadow-soft: 0 10px 30px rgba(123, 94, 167, 0.08);
    --shadow-hover: 0 16px 40px rgba(123, 94, 167, 0.15);
    
    --nav-height: 80px;
    --mobile-nav-height: 70px;
}

[data-theme="dark"] {
    --bg-base: #060A1A;
    --bg-card: #0F172A;
    --bg-elevated: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(123, 94, 167, 0.3);
    
    --nav-bg: rgba(6, 10, 26, 0.85);
    --modal-bg: #0F172A;
    
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 16px 40px rgba(123, 94, 167, 0.25);
    
    --violet-glow: rgba(123, 94, 167, 0.25);
}

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

body {
    font-family: 'DM Sans', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    transition: background-color 0.4s ease, color 0.4s ease;
}

h1, h2, h3, h4, h5, .logo {
    font-family: 'Space Grotesk', sans-serif;
}

/* Background Starfield */
.starfield {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: -1;
    pointer-events: none;
}

/* Navigation */
.top-nav {
    height: var(--nav-height);
    background: var(--nav-bg);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 5%;
    position: fixed; top: 0; width: 100%;
    z-index: 1000;
}

.logo {
    font-size: 1.6rem;
    font-weight: 700;
    display: flex; align-items: center; gap: 0.5rem;
    cursor: pointer;
    color: var(--text-main);
}
.logo i { color: var(--violet); }

.nav-links { display: flex; align-items: center; gap: 1rem; }
.nav-link {
    text-decoration: none; color: var(--text-muted);
    font-weight: 600; padding: 0.5rem 1rem;
    border-radius: var(--radius-sm); transition: 0.3s;
    display: flex; align-items: center; gap: 0.4rem;
}
.nav-link:hover, .nav-link.active {
    color: var(--violet); background: var(--violet-glow);
}

.badge {
    background: var(--teal); color: white;
    padding: 0.1rem 0.6rem; border-radius: 99px; font-size: 0.8rem;
}

.theme-toggle {
    cursor: pointer; padding: 0.5rem; color: var(--text-muted);
    border-radius: 50%; transition: 0.3s; background: var(--bg-card);
}
.theme-toggle:hover { background: var(--border-color); color: var(--violet); }

.nav-user-profile {
    display: flex; align-items: center; gap: 1rem;
    border-left: 1px solid var(--border-color); padding-left: 1rem;
}
.avatar-sm {
    width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--border-color);
}
.role-indicator {
    padding: 0.3rem 0.8rem; border-radius: 99px;
    background: var(--bg-card); border: 1px solid var(--border-color);
    font-size: 0.85rem; font-weight: 600; cursor: pointer;
    color: var(--violet); transition: 0.2s;
}
.role-indicator:hover { background: var(--violet-glow); }

/* Buttons */
.btn {
    padding: 0.8rem 1.8rem; border-radius: var(--radius-md);
    font-weight: 600; cursor: pointer; transition: 0.3s;
    border: none; display: inline-flex; align-items: center; gap: 0.5rem;
    font-family: inherit; font-size: 1rem; justify-content: center;
}
.btn-primary { 
    background: var(--violet); color: white; 
    box-shadow: 0 4px 15px var(--violet-glow); 
}
.btn-primary:hover { 
    transform: translateY(-2px); box-shadow: 0 8px 25px rgba(123, 94, 167, 0.4); 
    background: #6a4f94;
}
.btn-secondary { background: var(--bg-card); color: var(--text-main); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--violet-glow); border-color: var(--violet); }
.btn-lg { padding: 1.2rem 2.5rem; font-size: 1.1rem; }
.btn-block { width: 100%; }

/* Layout & Pages */
.app-container { padding-top: var(--nav-height); min-height: 100vh; }
.page { display: none; padding: 3rem 5%; max-width: 1200px; margin: 0 auto; animation: fadeUp 0.4s ease; }
.page.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.page-heading { font-size: 2.5rem; margin-bottom: 0.5rem; color: var(--text-main); }
.text-muted { color: var(--text-muted); }

/* Hero */
.hero { text-align: center; padding: 5rem 0; }
.hero-title { font-size: 4rem; line-height: 1.1; margin-bottom: 1.5rem; color: var(--text-main); }
.hero-subtitle { font-size: 1.2rem; color: var(--text-muted); max-width: 600px; margin: 0 auto 3rem; }
.hero-actions { display: flex; justify-content: center; gap: 1.5rem; }

/* Dashboard Grids & Cards */
.dashboard-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.5rem;
}
.card-glass {
    background: var(--bg-card); backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color); border-radius: var(--radius-lg);
    padding: 2rem; box-shadow: var(--shadow-soft); transition: 0.3s;
}
.card-glass:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); }

/* Swipe Interface */
.swipe-interface {
    display: flex; flex-direction: column; align-items: center;
    height: calc(100vh - var(--nav-height) - 150px);
    position: relative; padding-top: 2rem;
}
.card-stack { position: relative; width: 420px; height: 620px; max-width: 90vw; }
.swipe-card {
    position: absolute; top:0; left:0; width: 100%; height: 100%;
    background: var(--bg-elevated); border: 1px solid var(--border-color);
    border-radius: var(--radius-xl); padding: 2rem; display: flex; flex-direction: column;
    box-shadow: var(--shadow-soft); cursor: grab; user-select: none;
    background-image: radial-gradient(circle at top right, var(--violet-glow), transparent 70%);
}
.swipe-card:active { cursor: grabbing; }

.empty-card {
    width: 100%; height: 100%; border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl); display: flex; flex-direction: column;
    align-items: center; justify-content: center; color: var(--text-muted); text-align: center; padding: 2rem;
}
.empty-card i { font-size: 4rem; margin-bottom: 1rem; opacity: 0.5; }

.swipe-actions { display: flex; gap: 2rem; margin-top: 2.5rem; }
.swipe-btn {
    width: 64px; height: 64px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 1.8rem;
    border: none; cursor: pointer; transition: 0.2s; background: var(--bg-card);
    box-shadow: var(--shadow-soft);
}
.swipe-btn:hover { transform: scale(1.1); }
.btn-nope { color: var(--danger); }
.btn-save { color: var(--gold); }
.btn-like { color: var(--teal); }

.card-badge { display: inline-block; padding: 0.3rem 0.8rem; border-radius: 99px; font-size: 0.75rem; font-weight: 700; background: var(--violet-glow); color: var(--violet); margin-bottom: 0.8rem; text-transform: uppercase; letter-spacing: 1px; }
.card-title { font-size: 1.8rem; line-height: 1.25; margin-bottom: 0.8rem; }
.card-summary { color: var(--text-muted); font-size: 1.05rem; flex-grow: 1; margin-bottom: 0.5rem; }
.card-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.meta-chip { background: var(--bg-card); border: 1px solid var(--border-color); padding: 0.2rem 0.6rem; border-radius: 4px; font-size: 0.8rem; color: var(--text-muted); }
.card-footer { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border-color); padding-top: 1rem; margin-top: auto; }
.poster-info { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 0.9rem; }
.poster-info i { color: var(--gold); }

/* Forms */
.form-container { max-width: 750px; margin: 0 auto; background: var(--bg-card); padding: 3rem; border-radius: var(--radius-lg); border: 1px solid var(--border-color); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: flex; justify-content: space-between; margin-bottom: 0.5rem; font-weight: 600; font-size: 0.9rem; color: var(--text-main); }
input, textarea, select {
    width: 100%; padding: 1rem; background: var(--bg-elevated);
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    color: var(--text-main); font-family: inherit; font-size: 1rem; transition: 0.3s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-glow); }
.char-count { color: var(--text-muted); font-weight: normal; font-size: 0.8rem; }

/* Pills / Filters */
.pill-group { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.discover-filters { display: flex; gap: 0.8rem; overflow-x: auto; padding-bottom: 1rem; scrollbar-width: none; }
.discover-filters::-webkit-scrollbar { display: none; }
.filter-chip {
    padding: 0.5rem 1.2rem; background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 99px; white-space: nowrap; cursor: pointer; color: var(--text-muted);
    transition: 0.2s; font-size: 0.9rem; font-weight: 500;
}
.filter-chip:hover, .filter-chip.active { background: var(--violet); color: white; border-color: var(--violet); }

/* Modals */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 2000; align-items: center; justify-content: center; }
.modal.open { display: flex; }
.modal-overlay { position: absolute; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
.modal-content {
    position: relative; background: var(--modal-bg); border-radius: var(--radius-lg);
    width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto; padding: 2.5rem;
    box-shadow: 0 25px 50px rgba(0,0,0,0.2); animation: zoomIn 0.3s ease-out;
}
@keyframes zoomIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-close { position: absolute; top: 1.5rem; right: 1.5rem; background: none; border: none; font-size: 1.5rem; color: var(--text-muted); cursor: pointer; }

/* Detail Modal specific */
.detail-header { padding: 3rem; background: var(--bg-card); border-bottom: 1px solid var(--border-color); }
.detail-body { padding: 3rem; background: var(--modal-bg); }
.detail-actions { position: sticky; bottom: 0; padding: 1.5rem 3rem; background: var(--modal-bg); border-top: 1px solid var(--border-color); display: flex; gap: 1rem; }

/* Profile View */
.profile-header { text-align: center; margin-bottom: 3rem; position: relative; overflow: hidden; }
.avatar-large { width: 120px; height: 120px; border-radius: 50%; border: 4px solid var(--bg-elevated); box-shadow: var(--shadow-soft); margin: 0 auto 1rem; background: #eee; object-fit: cover;}
.username-handle { font-family: monospace; color: var(--violet); margin-bottom: 1rem; font-size: 1.1rem; }
.star-ratings { display: flex; justify-content: center; gap: 1rem; margin: 1.5rem 0; }
.star-badge { padding: 0.5rem 1rem; border-radius: 99px; font-weight: bold; background: var(--bg-card); display: flex; align-items: center; gap: 0.5rem; border: 1px solid var(--border-color); }
.profile-stats-row { display: flex; justify-content: center; gap: 3rem; margin: 2rem 0; border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); padding: 1.5rem 0; }
.stat-box { text-align: center; color: var(--text-muted); font-size: 0.9rem; }
.stat-box strong { display: block; font-size: 1.8rem; color: var(--text-main); font-family: 'Space Grotesk'; }

/* Role Selector (Onboarding) */
.role-selector { display: flex; gap: 1rem; margin-bottom: 1rem; }
.role-card { flex: 1; border: 2px solid var(--border-color); border-radius: var(--radius-md); padding: 1.5rem 1rem; text-align: center; cursor: pointer; transition: 0.2s; color: var(--text-muted); }
.role-card.active { border-color: var(--violet); background: var(--violet-glow); color: var(--violet); font-weight: bold; }
.role-card i { display: block; font-size: 2rem; margin-bottom: 0.5rem; }

/* Chat UI */
.chat-layout { display: flex; height: 600px; border: 1px solid var(--border-color); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-elevated); margin-top:2rem; }
.chat-sidebar { width: 320px; border-right: 1px solid var(--border-color); background: var(--bg-card); overflow-y: auto; }
.chat-area { flex: 1; display: flex; flex-direction: column; background: var(--bg-elevated); }
.chat-header { padding: 1.5rem; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; }
.chat-messages { flex: 1; padding: 1.5rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; }
.chat-bubble { max-width: 70%; padding: 1rem; border-radius: var(--radius-md); }
.chat-bubble.received { background: var(--bg-card); align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-bubble.sent { background: var(--violet); color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-input { padding: 1.5rem; border-top: 1px solid var(--border-color); display: flex; gap: 1rem; }

/* Progress Bars */
.star-progress-container { flex: 1; min-width: 300px; max-width: 400px; }
.progress-bar-wrap { margin-bottom: 1rem; }
.progress-label { display: flex; justify-content: space-between; font-size: 0.9rem; font-weight: 600; margin-bottom: 0.3rem;}
.progress-track { width: 100%; height: 8px; background: var(--bg-elevated); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width 0.5s ease; }
.progress-fill.yellow { background: var(--gold); }
.progress-fill.red { background: var(--danger); }
.progress-sub { font-size: 0.75rem; color: var(--text-muted); text-align: right; margin-top: 0.2rem; }
.dashboard-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 2rem; margin-bottom: 2rem; border-bottom: 1px solid var(--border-color); padding-bottom: 1.5rem;}

.ai-badge { font-size: 0.8rem; background: linear-gradient(135deg, var(--violet), var(--teal)); color: white; padding: 0.2rem 0.6rem; border-radius: 99px; vertical-align: middle; margin-left: 0.5rem; }
.how-it-works { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin-bottom: 3rem; }
.step-card { text-align: center; padding: 2rem; background: var(--bg-card); border-radius: var(--radius-lg); border: 1px solid var(--border-color); }
.step-icon { font-size: 2.5rem; color: var(--violet); margin-bottom: 1rem; }

/* Toast */
.toast {
    position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(150px);
    background: var(--bg-elevated); color: var(--text-main); border: 1px solid var(--violet); border-radius: 99px;
    padding: 0.8rem 2rem; font-weight: 600; z-index: 3000; box-shadow: var(--shadow-hover);
    transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 768px) {
    .top-nav .nav-links { display: none; }
    .bottom-nav { display: flex; position: fixed; bottom: 0; width: 100%; height: var(--mobile-nav-height); background: var(--nav-bg); backdrop-filter: var(--glass-blur); border-top: 1px solid var(--border-color); justify-content: space-around; align-items: center; z-index: 1000; }
    .bottom-nav a { color: var(--text-muted); font-size: 1.5rem; padding: 0.5rem; }
    .bottom-nav a.active { color: var(--violet); }
    .app-container { padding-bottom: var(--mobile-nav-height); }
    .hero-title { font-size: 2.5rem; }
    .dashboard-header { flex-direction: column; align-items: flex-start; }
    .how-it-works { grid-template-columns: 1fr; }
    .detail-actions { flex-direction: column; }
    .chat-layout { flex-direction: column; }
    .chat-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); max-height: 200px; }
}

/* Avatar Selection */
.avatar-grid { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px; 
    margin-top: 10px; 
    justify-content: center;
}
.avatar-option { 
    width: 45px; 
    height: 45px; 
    border-radius: 50%; 
    cursor: pointer; 
    border: 2px solid transparent; 
    transition: all 0.2s; 
    padding: 2px; 
    background: var(--bg-card); 
    box-shadow: var(--shadow-soft);
    animation: floatAvatar 3s ease-in-out infinite; 
}
.avatar-option:hover { 
    transform: scale(1.1); 
    animation: none; 
}
.avatar-option.active { 
    border-color: var(--teal); 
    background: var(--teal-glow); 
    animation: none; 
    transform: scale(1.15); 
}

/* Stagger floating */
.avatar-option:nth-child(even) { animation-delay: 1.5s; }
.avatar-option:nth-child(3n) { animation-delay: 0.7s; }

@keyframes floatAvatar {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}
