/* Orbit - Modern Social Platform Styles */
:root {
    --orbit-primary: #6366f1;
    --orbit-primary-dark: #4f46e5;
    --orbit-secondary: #8b5cf6;
    --orbit-accent: #ec4899;
    --orbit-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    --orbit-radius: 12px;
    --orbit-radius-sm: 8px;
    --sidebar-width: 240px;
    --bottom-nav-height: 56px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"], :root {
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --bg-tertiary: #f4f4f5;
    --text-primary: #18181b;
    --text-secondary: #71717a;
    --text-muted: #a1a1aa;
    --border-color: #e4e4e7;
    --card-bg: #ffffff;
    --hover-bg: #f4f4f5;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

[data-theme="dark"] {
    --bg-primary: #0f0f12;
    --bg-secondary: #18181b;
    --bg-tertiary: #27272a;
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --border-color: #3f3f46;
    --card-bg: #18181b;
    --hover-bg: #27272a;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

@media (prefers-color-scheme: dark) {
    [data-theme="system"] {
        --bg-primary: #0f0f12;
        --bg-secondary: #18181b;
        --bg-tertiary: #27272a;
        --text-primary: #fafafa;
        --text-secondary: #a1a1aa;
        --text-muted: #71717a;
        --border-color: #3f3f46;
        --card-bg: #18181b;
        --hover-bg: #27272a;
        --shadow: 0 1px 3px rgba(0,0,0,0.3);
        --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
    }
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--orbit-primary); text-decoration: none; }
a:hover { color: var(--orbit-primary-dark); }

/* Layout */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem 1.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}
.sidebar-logo i { font-size: 2rem; background: var(--orbit-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.sidebar-nav { list-style: none; padding: 0; margin: 0; flex: 1; }
.sidebar-nav li { margin-bottom: 0.25rem; }
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--orbit-radius-sm);
    color: var(--text-primary);
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}
.sidebar-nav .nav-link:hover { background: var(--hover-bg); }
.sidebar-nav .nav-link.active { font-weight: 700; }
.sidebar-nav .nav-link i { font-size: 1.35rem; }
.nav-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }

.sidebar-admin {
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.main-content {
    flex: 1;
    margin-left: 0;
    padding-bottom: calc(var(--bottom-nav-height) + 1rem);
}
.main-content.with-sidebar { margin-left: var(--sidebar-width); }
@media (max-width: 991px) { .main-content.with-sidebar { margin-left: 0; } }

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    padding: 0 0.5rem;
}
.bottom-nav a {
    color: var(--text-secondary);
    font-size: 1.25rem;
    padding: 0.35rem;
    transition: var(--transition);
}
.bottom-nav a.active, .bottom-nav a:hover { color: var(--text-primary); }
.bottom-nav .create-btn {
    background: var(--orbit-gradient);
    color: #fff !important;
    width: 40px; height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}
.nav-avatar-sm { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 2px solid transparent; }
.bottom-nav a.active .nav-avatar-sm { border-color: var(--orbit-primary); }

/* Buttons */
.btn-orbit {
    background: var(--orbit-gradient);
    border: none;
    color: #fff;
    font-weight: 600;
    border-radius: var(--orbit-radius-sm);
    padding: 0.625rem 1.25rem;
    transition: var(--transition);
}
.btn-orbit:hover { opacity: 0.9; color: #fff; transform: translateY(-1px); }
.btn-outline-orbit {
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    border-radius: var(--orbit-radius-sm);
    font-weight: 500;
}
.btn-outline-orbit:hover { background: var(--hover-bg); color: var(--text-primary); }
.btn-icon { background: none; border: none; color: var(--text-primary); font-size: 1.25rem; padding: 0.25rem; cursor: pointer; }
.btn-action { background: none; border: none; font-size: 1.5rem; color: var(--text-primary); padding: 0.25rem; cursor: pointer; transition: var(--transition); }
.btn-action:hover { transform: scale(1.1); }
.btn-action.liked { color: #ef4444; animation: likePop 0.3s ease; }
.btn-action.saved { color: var(--text-primary); }

@keyframes likePop { 0%,100% { transform: scale(1); } 50% { transform: scale(1.3); } }

.badge-unread {
    position: absolute;
    top: 8px; right: 12px;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 700;
}

.verified-badge { color: #3b82f6; font-size: 0.9em; margin-left: 2px; vertical-align: middle; }
.verified-badge i { filter: drop-shadow(0 0 2px rgba(59,130,246,0.4)); }

/* Auth */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg-secondary);
}
.auth-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo i { font-size: 3rem; background: var(--orbit-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.auth-logo h1 { font-size: 1.75rem; margin: 0.5rem 0 0.25rem; }
.auth-logo p { color: var(--text-secondary); margin: 0; font-size: 0.9rem; }
.auth-form .form-control { background: var(--bg-tertiary); border-color: var(--border-color); color: var(--text-primary); }
.auth-form .form-control:focus { background: var(--bg-tertiary); border-color: var(--orbit-primary); color: var(--text-primary); box-shadow: 0 0 0 0.2rem rgba(99,102,241,0.15); }
.auth-links { text-align: center; margin-top: 1rem; }
.auth-divider { display: flex; align-items: center; gap: 1rem; margin: 1.5rem 0; color: var(--text-muted); font-size: 0.8rem; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border-color); }
.auth-switch { text-align: center; color: var(--text-secondary); margin: 0; }
.animate-in { animation: fadeInUp 0.4s ease; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* Feed - Instagram style */
.ig-home { background: #000; min-height: 100vh; }
.ig-mobile-header {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.65rem 1rem; background: #000; border-bottom: 1px solid #262626;
}
.ig-header-btn { color: #fff; font-size: 1.45rem; padding: 0.25rem; }
.ig-logo {
    font-size: 1.35rem; font-weight: 700; letter-spacing: -0.5px;
    background: var(--orbit-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    text-decoration: none;
}

.feed-container {
    max-width: 935px;
    margin: 0 auto;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}
@media (min-width: 992px) {
    .ig-home { background: var(--bg-primary); }
    .feed-container { padding: 1.5rem 1rem; gap: 1.5rem; }
}
@media (min-width: 1200px) {
    .feed-container { grid-template-columns: 1fr 320px; }
}

.stories-bar {
    grid-column: 1 / -1;
    background: #000;
    border: none;
    border-bottom: 1px solid #262626;
    border-radius: 0;
    padding: 0.75rem 0 0.75rem 0.75rem;
    overflow: hidden;
}
@media (min-width: 992px) {
    .stories-bar { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--orbit-radius); padding: 1rem; }
}
.stories-scroll { display: flex; gap: 0.85rem; overflow-x: auto; scrollbar-width: none; }
.stories-scroll::-webkit-scrollbar { display: none; }
.story-item { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; min-width: 68px; max-width: 68px; text-align: center; color: #fff; font-size: 0.68rem; }
@media (min-width: 992px) { .story-item { color: var(--text-primary); font-size: 0.75rem; } }
.story-label {
    display: block; max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    line-height: 1.2;
}
.story-ring {
    width: 66px; height: 66px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    position: relative;
}
.story-ring.viewed { background: #363636; }
.story-ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid #000; }
@media (min-width: 992px) { .story-ring img { border-color: var(--bg-primary); } }
.story-add .add-icon {
    position: absolute; bottom: 0; right: 0;
    background: #0095f6; color: #fff;
    width: 22px; height: 22px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; border: 2px solid #000;
}

.feed-posts { display: flex; flex-direction: column; gap: 0; }
.ig-feed-posts .post-card { border-radius: 0; border-left: none; border-right: none; margin-bottom: 0; }
@media (min-width: 992px) {
    .ig-feed-posts .post-card { border-radius: var(--orbit-radius); border: 1px solid var(--border-color); margin-bottom: 1.5rem; }
    .feed-posts { gap: 1.5rem; }
}

.post-header-actions { display: flex; align-items: center; gap: 0.5rem; }
.btn-follow-post {
    background: #0095f6; color: #fff; border: none; border-radius: 8px;
    padding: 0.35rem 0.85rem; font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
.btn-follow-post:hover { background: #1877f2; color: #fff; }
.post-suggested-label { color: #a8a8a8 !important; font-size: 0.72rem !important; display: block; }

.ig-bottom-nav { background: #000 !important; border-top-color: #262626 !important; }
.ig-bottom-nav a { color: #fff !important; }
.ig-bottom-nav a.active { color: #fff !important; }
.ig-bottom-nav .create-btn { background: transparent !important; border: 1px solid #fff; color: #fff !important; }

@media (max-width: 991px) {
    .ig-home .ig-post-card { background: #000; border-color: #262626; color: #fff; }
    .ig-home .post-author { color: #fff; }
    .ig-home .post-time, .ig-home .view-comments { color: #a8a8a8; }
    .ig-home .btn-icon { color: #fff; }
    .ig-home .main-content.with-sidebar { padding-bottom: calc(var(--bottom-nav-height) + 0.5rem); }
}

/* Post Card */
.post-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--orbit-radius);
    overflow: hidden;
    animation: fadeInUp 0.3s ease;
}
.post-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
}
.post-author { display: flex; align-items: center; gap: 0.75rem; color: var(--text-primary); }
.post-author img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.post-author strong { display: block; font-size: 0.875rem; }
.post-author small { color: var(--text-secondary); font-size: 0.75rem; }

.post-media { position: relative; background: #000; aspect-ratio: 1; }
.post-media img, .post-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-slide { display: none; }
.media-slide.active { display: block; }
.carousel-prev, .carousel-next {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,0.9); border: none;
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 2;
}
.carousel-prev { left: 8px; }
.carousel-next { right: 8px; }
.carousel-dots { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; }
.carousel-dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.5); }
.carousel-dots span.active { background: #fff; }

.post-actions { display: flex; justify-content: space-between; padding: 0.5rem 1rem; }
.actions-left { display: flex; gap: 1rem; }
.post-likes { padding: 0 1rem; font-size: 0.875rem; }
.post-caption { padding: 0.25rem 1rem 0.5rem; font-size: 0.875rem; }
.post-caption .hashtag { color: var(--orbit-primary); font-weight: 500; }
.view-comments { display: block; padding: 0 1rem; color: var(--text-muted); font-size: 0.875rem; margin-bottom: 0.25rem; }
.post-time { display: block; padding: 0 1rem 1rem; color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; }

/* Suggested */
.feed-sidebar { position: sticky; top: 1.5rem; height: fit-content; }
.suggested-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--orbit-radius); padding: 1rem; }
.suggested-header { display: flex; justify-content: space-between; margin-bottom: 1rem; font-size: 0.875rem; color: var(--text-secondary); }
.suggested-user { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0; }
.suggested-user a { display: flex; align-items: center; gap: 0.75rem; flex: 1; color: var(--text-primary); }
.suggested-user img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.suggested-user strong { display: block; font-size: 0.875rem; }
.suggested-user small { color: var(--text-secondary); font-size: 0.75rem; }
.btn-follow-sm { background: none; border: none; color: var(--orbit-primary); font-weight: 600; font-size: 0.8rem; cursor: pointer; }

/* Profile — Instagram style */
.profile-page.ig-profile { max-width: 935px; margin: 0 auto; padding-bottom: 1rem; }
.profile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.65rem 1rem; border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 20; background: var(--bg-primary);
}
.profile-topbar-btn {
    background: none; border: none; color: var(--text-primary);
    font-size: 1.35rem; width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    text-decoration: none; padding: 0; cursor: pointer;
}
.profile-topbar-user {
    display: flex; align-items: center; gap: 0.25rem;
    font-weight: 600; font-size: 1rem;
}
.profile-topbar-user .verified-badge { font-size: 0.85rem; }
.profile-menu .dropdown-item { display: flex; align-items: center; gap: 0.65rem; font-size: 0.9rem; }
.profile-menu .dropdown-item i { width: 1.1rem; }

.profile-identity { padding: 1rem 1rem 0.5rem; }
.profile-identity-row {
    display: flex; align-items: center; gap: 1.75rem; margin-bottom: 0.85rem;
}
.profile-avatar-col { position: relative; flex-shrink: 0; }
.profile-avatar-ring {
    width: 86px; height: 86px; border-radius: 50%; padding: 2px;
    background: var(--border-color); display: flex; align-items: center; justify-content: center;
}
.profile-avatar-ring.has-story {
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
}
.profile-avatar {
    width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--bg-primary); background: var(--bg-tertiary);
}
.profile-avatar-col .avatar-edit {
    position: absolute; bottom: 0; right: 0;
    background: rgba(0,0,0,0.55); color: #fff; border: none; border-radius: 50%;
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 0.75rem;
}
.profile-stats-col { flex: 1; display: flex; justify-content: space-around; align-items: center; min-width: 0; }
.profile-stat {
    display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
    font-size: 0.8rem; color: var(--text-primary); min-width: 0;
}
.profile-stat strong { font-size: 1.05rem; font-weight: 700; line-height: 1.1; }
.profile-stat span { color: var(--text-secondary); font-size: 0.78rem; }
.profile-stat-btn {
    background: none; border: none; padding: 0; cursor: pointer; color: inherit;
}

.profile-bio-block { margin-bottom: 0.85rem; }
.profile-display-name { display: block; font-size: 0.9rem; margin-bottom: 0.15rem; }
.profile-bio-text { margin: 0; font-size: 0.875rem; line-height: 1.45; color: var(--text-primary); white-space: pre-wrap; }
.profile-link {
    display: inline-block; margin-top: 0.25rem; font-size: 0.875rem;
    font-weight: 600; color: #385898; text-decoration: none;
}
[data-theme="dark"] .profile-link { color: #e0f1ff; }

.profile-cta-row { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.profile-cta-btn {
    flex: 1; border: none; border-radius: 8px; padding: 0.45rem 0.75rem;
    background: var(--bg-tertiary); color: var(--text-primary);
    font-size: 0.82rem; font-weight: 600; text-align: center;
    text-decoration: none; cursor: pointer; line-height: 1.2;
}
.profile-cta-btn:hover { background: var(--border-color); color: var(--text-primary); }
.profile-cta-primary { background: var(--orbit-primary); color: #fff; }
.profile-cta-primary:hover { opacity: 0.92; color: #fff; }

.profile-dashboard {
    display: block; padding: 0.75rem 0.85rem; border-radius: 10px;
    background: var(--bg-tertiary); text-decoration: none; color: inherit; margin-bottom: 0.75rem;
}
.profile-dashboard strong { display: block; font-size: 0.85rem; margin-bottom: 0.15rem; }
.profile-dashboard span { font-size: 0.78rem; color: var(--text-secondary); display: flex; align-items: center; gap: 0.35rem; }

.profile-highlights {
    display: flex; gap: 1rem; overflow-x: auto; padding: 0.5rem 1rem 0.85rem;
    scrollbar-width: none;
}
.profile-highlights::-webkit-scrollbar { display: none; }
.highlight-chip {
    flex: 0 0 auto; width: 68px; text-align: center; background: none; border: none; padding: 0; color: inherit;
}
.highlight-ring {
    width: 64px; height: 64px; border-radius: 50%; padding: 2px;
    border: 1px solid var(--border-color); display: flex; align-items: center; justify-content: center;
    overflow: hidden; margin: 0 auto 0.35rem;
}
.highlight-ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.highlight-ring-new { border-style: dashed; color: var(--text-secondary); font-size: 1.25rem; }
.highlight-chip small {
    display: block; font-size: 0.68rem; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.profile-tabs {
    display: flex; border-top: 1px solid var(--border-color);
    justify-content: center; margin-top: 0.25rem;
}
.profile-tabs button {
    flex: 1; max-width: 120px; background: none; border: none;
    border-top: 1px solid transparent; margin-top: -1px;
    padding: 0.85rem 0.5rem; color: var(--text-muted);
    font-size: 1.15rem; cursor: pointer; display: inline-flex;
    align-items: center; justify-content: center;
}
.profile-tabs button.active {
    color: var(--text-primary); border-top-color: var(--text-primary);
}
.profile-tab-panel { min-height: 180px; }
.profile-empty-tab {
    text-align: center; padding: 3rem 1.5rem 2rem; color: var(--text-secondary);
}
.profile-empty-icon {
    width: 88px; height: 88px; border-radius: 50%; border: 2px solid var(--text-primary);
    display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem;
    font-size: 2rem; color: var(--text-primary);
}
.profile-empty-tab h3 { font-size: 1.35rem; color: var(--text-primary); margin-bottom: 0.35rem; }
.profile-empty-tab p { font-size: 0.875rem; margin-bottom: 1rem; }
.profile-archive-note {
    font-size: 0.8rem; color: var(--text-secondary); padding: 0.85rem 1rem 0.25rem; margin: 0;
}

.profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.grid-item { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--bg-tertiary); display: block; }
.grid-item img, .grid-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid-badge {
    position: absolute; color: #fff; font-size: 0.95rem;
    text-shadow: 0 1px 4px rgba(0,0,0,0.65); pointer-events: none; z-index: 2;
}
.grid-badge-play { top: 8px; right: 8px; font-size: 1rem; }
.grid-badge-carousel { top: 8px; right: 8px; }
.grid-views {
    position: absolute; left: 8px; bottom: 8px; color: #fff; font-size: 0.75rem;
    font-weight: 600; display: flex; align-items: center; gap: 0.2rem;
    text-shadow: 0 1px 4px rgba(0,0,0,0.65); pointer-events: none; z-index: 2;
}
.grid-overlay {
    position: absolute; inset: 0; background: rgba(0,0,0,0.35);
    display: flex; align-items: center; justify-content: center; gap: 1rem;
    opacity: 0; transition: var(--transition); color: #fff; font-weight: 600; font-size: 0.9rem;
}
.grid-item:hover .grid-overlay { opacity: 1; }
.grid-overlay span { display: inline-flex; align-items: center; gap: 0.3rem; }

.profile-private { text-align: center; padding: 4rem 2rem; }
.profile-avatar-lg { width: 96px; height: 96px; border-radius: 50%; margin-bottom: 1rem; }
.profile-section-title { font-size: 0.875rem; color: var(--text-secondary); padding: 0.75rem 1rem 0.5rem; margin: 0; text-transform: uppercase; letter-spacing: 0.05em; }
.archive-item { cursor: pointer; }

@media (min-width: 768px) {
    .profile-avatar-ring { width: 150px; height: 150px; }
    .profile-identity-row { gap: 2.5rem; align-items: flex-start; }
    .profile-stats-col { justify-content: flex-start; gap: 2.5rem; padding-top: 1rem; }
    .profile-stat { align-items: flex-start; }
    .profile-stat strong { font-size: 1.15rem; }
    .profile-cta-row { max-width: 420px; }
    .profile-highlights { padding-left: 0.25rem; }
}

/* Followers / Following — Instagram style */
.connections-page {
    max-width: 600px; margin: 0 auto; min-height: calc(100vh - var(--bottom-nav-height));
    background: var(--bg-primary);
}
.connections-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.65rem 0.85rem; border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 30; background: var(--bg-primary);
}
.connections-topbar-btn {
    width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-primary); text-decoration: none; background: none; border: none;
    font-size: 1.35rem; padding: 0;
}
.connections-topbar-title { font-weight: 600; font-size: 1rem; }
.connections-tabs {
    display: flex; overflow-x: auto; scrollbar-width: none;
    border-bottom: 1px solid var(--border-color);
}
.connections-tabs::-webkit-scrollbar { display: none; }
.connections-tab {
    flex: 1; min-width: max-content; padding: 0.85rem 1rem;
    text-align: center; font-size: 0.82rem; color: var(--text-secondary);
    text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap;
}
.connections-tab.active {
    color: var(--text-primary); font-weight: 600; border-bottom-color: var(--text-primary);
}
.connections-sort {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 1rem; font-size: 0.82rem; color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}
.connections-sort strong { color: var(--text-primary); font-weight: 600; }
.connections-sort-btn {
    background: none; border: none; color: var(--text-primary);
    font-size: 1rem; padding: 0.25rem; cursor: pointer;
}
.connections-list { padding-bottom: 1rem; }
.connections-empty { text-align: center; padding: 3rem 1.5rem; color: var(--text-secondary); }
.connection-row {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.65rem 1rem; min-height: 64px;
}
.connection-user {
    display: flex; align-items: center; gap: 0.75rem; flex: 1; min-width: 0;
    text-decoration: none; color: inherit;
}
.connection-avatar-ring {
    width: 54px; height: 54px; border-radius: 50%; padding: 2px;
    background: var(--border-color); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.connection-avatar-ring.has-story {
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
}
.connection-avatar-ring img {
    width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--bg-primary); background: var(--bg-tertiary);
}
.connection-meta { min-width: 0; }
.connection-meta strong {
    display: flex; align-items: center; gap: 0.15rem;
    font-size: 0.875rem; font-weight: 600; line-height: 1.2;
}
.connection-meta span {
    display: block; font-size: 0.82rem; color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.connection-activity {
    display: block; font-size: 0.75rem; color: #0095f6; margin-top: 0.1rem;
}
[data-theme="dark"] .connection-activity { color: #71c4ff; }
.connection-actions {
    display: flex; align-items: center; gap: 0.35rem; flex-shrink: 0;
}
.connection-btn {
    border: none; border-radius: 8px; padding: 0.38rem 0.85rem;
    font-size: 0.78rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.connection-btn-follow {
    background: #0095f6; color: #fff;
}
.connection-btn-follow:hover { background: #0086db; color: #fff; }
.connection-btn-message {
    background: var(--bg-tertiary); color: var(--text-primary);
}
.connection-btn-message:hover { background: var(--border-color); }
.connection-more-btn, .connection-remove-btn {
    background: none; border: none; color: var(--text-muted);
    font-size: 1rem; padding: 0.35rem; cursor: pointer; line-height: 1;
}
.connection-remove-btn { font-size: 0.85rem; }
.connection-more .dropdown-menu { font-size: 0.875rem; }

/* Explore */
.explore-page { max-width: 975px; margin: 0 auto; padding: 1.5rem 1rem; }
.search-bar-top { margin-bottom: 1.5rem; }
.search-bar-top form { position: relative; }
.search-bar-top i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-bar-top input {
    width: 100%; padding: 0.75rem 1rem 0.75rem 2.75rem;
    background: var(--bg-tertiary); border: 1px solid var(--border-color);
    border-radius: var(--orbit-radius-sm); color: var(--text-primary);
}
.explore-section { margin-bottom: 2rem; }
.explore-section h3 { font-size: 1rem; margin-bottom: 1rem; }
.explore-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.reels-scroll { display: flex; gap: 0.75rem; overflow-x: auto; }
.reel-thumb { position: relative; min-width: 120px; height: 200px; border-radius: var(--orbit-radius-sm); overflow: hidden; }
.reel-thumb video { width: 100%; height: 100%; object-fit: cover; }
.reel-thumb span { position: absolute; bottom: 8px; left: 8px; color: #fff; font-size: 0.75rem; font-weight: 600; }
.creators-row { display: flex; gap: 1rem; overflow-x: auto; }
.creator-card { text-align: center; min-width: 100px; color: var(--text-primary); }
.creator-card img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; margin-bottom: 0.5rem; }

/* Reels */
.reels-page {
    height: calc(100vh - var(--bottom-nav-height));
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    background: #000;
}
.reel-item {
    height: calc(100vh - var(--bottom-nav-height));
    scroll-snap-align: start;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.reel-item video { max-height: 100%; max-width: 100%; object-fit: contain; }
.reel-overlay { position: absolute; inset: 0; pointer-events: none; }
.reel-sidebar {
    position: absolute; right: 8px; bottom: 100px;
    display: flex; flex-direction: column; align-items: center;
    gap: 1.25rem; pointer-events: all; z-index: 5;
}
.reel-action {
    background: none; border: none; color: #fff;
    display: flex; flex-direction: column; align-items: center;
    gap: 0.2rem; font-size: 1.65rem; cursor: pointer;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6); padding: 0;
    min-width: 48px;
}
.reel-profile-link { display: block; width: 36px; height: 36px; border-radius: 8px; overflow: hidden; border: 2px solid #fff; }
.reel-profile-link img { width: 100%; height: 100%; object-fit: cover; }
.reels-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; gap: 1rem; }
.chat-float-btn {
    position: fixed; bottom: calc(var(--bottom-nav-height) + 16px); right: 16px;
    width: 52px; height: 52px; border-radius: 50%;
    background: var(--orbit-gradient); color: #fff;
    display: none; align-items: center; justify-content: center;
    font-size: 1.4rem; box-shadow: var(--shadow-lg); z-index: 90;
}
@media (max-width: 991px) { .chat-float-btn { display: flex; } }
.reel-action span { font-size: 0.75rem; font-weight: 600; }
.reel-action.liked { color: #ef4444; }
.reel-info { position: absolute; bottom: 24px; left: 12px; right: 80px; color: #fff; pointer-events: all; }
.reel-author { display: flex; align-items: center; gap: 0.5rem; color: #fff; margin-bottom: 0.5rem; }
.reel-author img { width: 36px; height: 36px; border-radius: 50%; border: 2px solid #fff; }
.reel-caption { font-size: 0.875rem; margin: 0; text-shadow: 0 1px 4px rgba(0,0,0,0.5); }

.reel-comments-panel {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--card-bg); border-radius: 16px 16px 0 0;
    max-height: 60vh; z-index: 200;
    display: flex; flex-direction: column;
}
.reel-comments-panel .panel-header { display: flex; justify-content: space-between; padding: 1rem; border-bottom: 1px solid var(--border-color); }
.reel-comments-panel .panel-body { flex: 1; overflow-y: auto; padding: 1rem; }
.reel-comments-panel .panel-footer { padding: 1rem; border-top: 1px solid var(--border-color); }
.reel-comments-panel .panel-footer input { width: 100%; padding: 0.75rem; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: 24px; color: var(--text-primary); }

/* Messages */
.messages-page { display: flex; height: calc(100vh - var(--bottom-nav-height)); max-width: 935px; margin: 0 auto; border: 1px solid var(--border-color); background: var(--bg-primary); }
.messages-sidebar { width: 350px; border-right: 1px solid var(--border-color); display: flex; flex-direction: column; background: var(--bg-primary); }
.messages-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem; border-bottom: 1px solid var(--border-color); }
.messages-header h2 { font-size: 1.1rem; margin: 0; display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.conversations-list { flex: 1; overflow-y: auto; }
.conv-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.875rem 1rem; cursor: pointer; transition: var(--transition); }
.conv-item:hover, .conv-item.active { background: var(--hover-bg); }
.conv-avatar { position: relative; flex-shrink: 0; }
.conv-avatar img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }
.online-dot { position: absolute; bottom: 2px; right: 2px; width: 12px; height: 12px; background: #22c55e; border-radius: 50%; border: 2px solid var(--bg-primary); }
.conv-info { flex: 1; min-width: 0; }
.conv-info strong { display: flex; align-items: center; gap: 0.15rem; font-size: 0.875rem; flex-wrap: wrap; }
.conv-info p { margin: 0; color: var(--text-secondary); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-badge { background: var(--orbit-primary); color: #fff; font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; font-weight: 700; flex-shrink: 0; }
.messages-chat { flex: 1; display: flex; flex-direction: column; position: relative; overflow: hidden; background: #0f1117; }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-secondary); background: var(--bg-primary); position: relative; z-index: 1; }
.messages-chat.active .chat-empty { background: rgba(15, 17, 23, 0.92); color: rgba(255, 255, 255, 0.75); }
.chat-empty i { font-size: 4rem; margin-bottom: 1rem; }

.chat-window { flex: 1; display: flex; flex-direction: column; min-height: 0; height: 100%; max-height: 100%; position: relative; z-index: 1; }
.chat-header {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.08); background: rgba(15,17,23,0.92); backdrop-filter: blur(12px);
    position: relative; z-index: 2;
}
.chat-back { background: none; border: none; color: #fff; font-size: 1.35rem; padding: 0.25rem; display: none; }
.chat-header-user { display: flex; align-items: center; gap: 0.75rem; color: #fff; text-decoration: none; flex: 1; min-width: 0; }
.chat-header-user:hover { color: #fff; opacity: 0.9; }
.chat-header-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.chat-header-meta { min-width: 0; }
.chat-header-meta strong { display: flex; align-items: center; gap: 0.2rem; font-size: 0.95rem; line-height: 1.2; }
.chat-header-sub { display: block; color: rgba(255,255,255,0.55); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-actions { display: flex; align-items: center; gap: 0.35rem; margin-left: auto; }
.chat-header-actions button { background: none; border: none; color: rgba(255,255,255,0.85); font-size: 1.15rem; padding: 0.35rem; border-radius: 50%; }
.chat-header-actions a { color: rgba(255,255,255,0.85); font-size: 1.15rem; padding: 0.35rem; border-radius: 50%; display: inline-flex; }
.chat-header-actions a:hover { background: rgba(255,255,255,0.08); color: #fff; }

.chat-messages {
    flex: 1; overflow-y: auto; padding: 1rem 0.85rem 1.25rem;
    display: flex; flex-direction: column; gap: 0.35rem; position: relative; z-index: 1;
}
.chat-row { display: flex; align-items: flex-end; gap: 0.5rem; max-width: 100%; width: 100%; }
.chat-row.sent { justify-content: flex-end; }
.chat-row.received { justify-content: flex-start; }
.chat-msg-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; margin-bottom: 2px; }
.chat-bubble {
    width: fit-content;
    max-width: 100%;
    min-width: 3rem;
    padding: 0.7rem 0.95rem; border-radius: 22px;
    font-size: 0.9rem; line-height: 1.45; word-break: normal; overflow-wrap: break-word;
}
.chat-bubble a { color: inherit; text-decoration: underline; }
.chat-bubble.sent {
    background: rgba(55, 55, 65, 0.92); color: #fff;
    border-bottom-right-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.chat-bubble.received {
    background: linear-gradient(135deg, #7c3aed 0%, #6366f1 55%, #5b21b6 100%);
    color: #fff; border-bottom-left-radius: 6px;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.25);
}

.chat-composer {
    display: flex; flex-direction: column; gap: 0.35rem;
    padding: 0.65rem 0.85rem max(0.75rem, env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255,255,255,0.08);
    background: rgba(15,17,23,0.98);
    flex-shrink: 0;
    position: relative;
    z-index: 5;
}
.chat-composer-row { display: flex; align-items: center; gap: 0.45rem; width: 100%; }
.chat-reply-bar {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem;
    background: rgba(255,255,255,0.06); border-radius: 12px; border-left: 3px solid #818cf8;
}
.chat-reply-preview { flex: 1; min-width: 0; }
.chat-reply-preview strong { display: block; font-size: 0.75rem; color: #818cf8; }
.chat-reply-preview span { display: block; font-size: 0.8rem; color: rgba(255,255,255,0.65); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-reply-cancel { background: none; border: none; color: rgba(255,255,255,0.6); font-size: 1rem; padding: 0.15rem; }
.chat-bubble-wrap { position: relative; max-width: min(78%, 420px); width: fit-content; flex-shrink: 0; }
.chat-row-media .chat-bubble-wrap { max-width: min(72%, 280px); }
.chat-row.selected .chat-bubble-wrap { outline: 2px solid rgba(129,140,248,0.55); outline-offset: 2px; border-radius: 22px; }
.chat-reply-quote {
    font-size: 0.75rem; opacity: 0.85; margin-bottom: 0.35rem; padding-bottom: 0.35rem;
    border-bottom: 1px solid rgba(255,255,255,0.15); line-height: 1.3;
}
.chat-reply-quote strong { display: block; font-size: 0.7rem; margin-bottom: 0.1rem; }
.chat-reply-quote span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.chat-reactions { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.25rem; }
.chat-reaction-chip {
    background: rgba(30,30,40,0.92); border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px; padding: 0.15rem 0.45rem; font-size: 0.85rem; cursor: pointer; color: #fff;
    display: inline-flex; align-items: center; gap: 0.15rem;
}
.chat-reaction-chip small { font-size: 0.65rem; opacity: 0.8; }
.chat-emoji-picker {
    position: fixed; z-index: 3000; display: flex; gap: 0.25rem; padding: 0.4rem 0.5rem;
    background: rgba(25,25,35,0.96); border-radius: 24px; border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.chat-emoji-picker button {
    background: none; border: none; font-size: 1.35rem; padding: 0.2rem 0.35rem; cursor: pointer;
    border-radius: 50%; transition: transform 0.15s;
}
.chat-emoji-picker button:hover { transform: scale(1.2); background: rgba(255,255,255,0.08); }
.reels-page.reels-loading::after {
    content: ''; position: fixed; bottom: 72px; left: 50%; transform: translateX(-50%);
    width: 28px; height: 28px; border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; z-index: 10;
}
@keyframes spin { to { transform: translateX(-50%) rotate(360deg); } }
.chat-composer-btn {
    background: none; border: none; color: rgba(255,255,255,0.75); font-size: 1.2rem;
    padding: 0.25rem; flex-shrink: 0;
}
.chat-composer-btn:hover { color: #fff; }
.chat-composer input {
    flex: 1; padding: 0.7rem 1rem; border: 1px solid rgba(255,255,255,0.12);
    border-radius: 24px; background: rgba(255,255,255,0.08); color: #fff; font-size: 0.9rem;
}
.chat-composer input::placeholder { color: rgba(255,255,255,0.45); }
.chat-composer input:focus { outline: none; border-color: rgba(99,102,241,0.6); background: rgba(255,255,255,0.1); }
.chat-send-btn {
    background: none; border: none; color: #818cf8; font-size: 1.15rem; padding: 0.25rem; flex-shrink: 0;
}
.chat-media-bubble { border-radius: 16px; overflow: hidden; max-width: min(240px, 72vw); background: #111; }
.chat-media-image { display: block; width: 100%; max-height: 320px; object-fit: cover; }
.chat-media-video { display: block; width: 100%; max-height: 320px; background: #000; }

/* Share sheet (Reel DM) */
.share-sheet { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: flex-end; }
.share-sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.share-sheet-panel {
    position: relative; width: 100%; max-height: 75vh; background: #1a1a1a;
    border-radius: 16px 16px 0 0; padding: 0.75rem 1rem 1.25rem; z-index: 1;
    display: flex; flex-direction: column;
}
.share-sheet-handle { width: 40px; height: 4px; background: #444; border-radius: 2px; margin: 0 auto 0.75rem; }
.share-sheet-search {
    display: flex; align-items: center; gap: 0.5rem; background: #262626;
    border-radius: 12px; padding: 0.5rem 0.75rem; margin-bottom: 1rem;
}
.share-sheet-search i { color: #888; }
.share-sheet-search input {
    flex: 1; background: transparent; border: none; color: #fff; font-size: 0.9rem;
}
.share-sheet-search input:focus { outline: none; }
.share-sheet-group { background: none; border: none; color: #fff; font-size: 1.2rem; }
.share-sheet-users {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem 0.75rem;
    overflow-y: auto; max-height: 45vh; padding-bottom: 0.5rem;
}
.share-user-chip {
    background: none; border: none; color: #fff; display: flex; flex-direction: column;
    align-items: center; gap: 0.35rem; cursor: pointer; padding: 0.25rem;
}
.share-user-chip img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }
.share-user-chip span {
    font-size: 0.72rem; max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.share-sheet-actions {
    display: flex; gap: 1rem; padding-top: 0.75rem; border-top: 1px solid #333; margin-top: 0.5rem;
}
.share-sheet-actions button {
    background: #262626; border: none; color: #fff; border-radius: 12px;
    padding: 0.65rem 1rem; font-size: 0.85rem; display: flex; align-items: center; gap: 0.5rem;
}

/* Chat reel preview */
.chat-row-media { align-items: flex-end; }
.chat-reel-card {
    display: block; position: relative; width: 200px; height: 280px; border-radius: 16px;
    overflow: hidden; background: #111; text-decoration: none; color: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}
.chat-reel-card video { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-reel-play {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.15); font-size: 2.5rem; color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.chat-reel-author {
    position: absolute; top: 8px; left: 8px; right: 8px;
    display: flex; align-items: center; gap: 0.35rem; font-size: 0.75rem; font-weight: 600;
}
.chat-reel-author img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.chat-reel-author span { display: flex; align-items: center; gap: 0.1rem; text-shadow: 0 1px 4px rgba(0,0,0,0.8); }
.chat-row.sent .chat-reel-card { margin-left: auto; }
.chat-sent-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: 100%;
    max-width: 100%;
}
.chat-row-media .chat-sent-wrap { max-width: 100%; }
.chat-seen-status {
    font-size: 0.68rem;
    color: rgba(255,255,255,0.42);
    margin-top: 0.25rem;
    padding-right: 0.35rem;
    letter-spacing: 0.01em;
}

/* Messages page */
body.chat-active .bottom-nav,
body.chat-active .chat-float-btn { display: none !important; }
body.page-messages .main-content { padding-bottom: calc(var(--bottom-nav-height) + 0.5rem); }
body.chat-active .main-content { padding-bottom: 0 !important; }
body.chat-active { overscroll-behavior: none; }
body.page-messages .messages-page {
    height: calc(100dvh - var(--bottom-nav-height));
    max-height: calc(100dvh - var(--bottom-nav-height));
}
body.chat-active .messages-page {
    height: 100dvh;
    max-height: 100dvh;
}
.messages-mobile-header { border-bottom: 1px solid var(--border-color); }
.chat-e2e-note {
    text-align: center; font-size: 0.68rem; color: rgba(255,255,255,0.45);
    padding: 0 0.25rem 0.15rem; margin: 0;
}

.chat-theme-picker {
    position: absolute; top: 58px; right: 0.75rem; z-index: 5;
    background: rgba(20,22,30,0.98); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px; padding: 0.75rem; min-width: 210px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.35);
}
.chat-theme-picker h5 { color: #fff; font-size: 0.8rem; margin: 0 0 0.6rem; }
.chat-theme-picker-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45rem; }
.chat-theme-picker-grid button {
    border: 2px solid transparent; border-radius: 10px; padding: 0.35rem; background: rgba(255,255,255,0.05);
    cursor: pointer;
}
.chat-theme-picker-grid button.active { border-color: #818cf8; }
.chat-theme-picker-grid span { display: block; height: 34px; border-radius: 8px; margin-bottom: 0.25rem; }

.chat-theme-selector { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.65rem; }
.chat-theme-btn {
    border: 2px solid transparent; border-radius: 12px; padding: 0.65rem 0.5rem;
    background: var(--bg-tertiary); color: var(--text-primary); cursor: pointer; font-size: 0.8rem;
}
.chat-theme-btn.active { border-color: var(--orbit-primary); }
.chat-theme-preview { display: block; height: 48px; border-radius: 8px; margin-bottom: 0.45rem; }

/* Chat background themes */
.messages-chat::before {
    content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
}
.chat-theme-default::before { background: linear-gradient(180deg, #12141c 0%, #0f1117 100%); }
.chat-theme-minimal::before { background: #18181b; }
.chat-theme-hearts::before {
    background:
        radial-gradient(circle at 15% 20%, rgba(236,72,153,0.35) 0%, transparent 22%),
        radial-gradient(circle at 78% 12%, rgba(244,114,182,0.28) 0%, transparent 20%),
        radial-gradient(circle at 62% 72%, rgba(219,39,119,0.22) 0%, transparent 24%),
        radial-gradient(circle at 28% 78%, rgba(236,72,153,0.18) 0%, transparent 18%),
        linear-gradient(180deg, #0b1020 0%, #12091a 100%);
}
.chat-theme-aurora::before {
    background:
        radial-gradient(circle at 20% 30%, rgba(124,58,237,0.35) 0%, transparent 40%),
        radial-gradient(circle at 80% 20%, rgba(99,102,241,0.3) 0%, transparent 35%),
        radial-gradient(circle at 50% 80%, rgba(168,85,247,0.25) 0%, transparent 40%),
        linear-gradient(180deg, #0f0a1a 0%, #12131f 100%);
}
.chat-theme-ocean::before {
    background:
        radial-gradient(circle at 70% 20%, rgba(14,165,233,0.25) 0%, transparent 35%),
        radial-gradient(circle at 20% 70%, rgba(59,130,246,0.22) 0%, transparent 30%),
        linear-gradient(180deg, #071018 0%, #0c1829 100%);
}
.chat-theme-sunset::before {
    background:
        radial-gradient(circle at 25% 25%, rgba(251,146,60,0.28) 0%, transparent 30%),
        radial-gradient(circle at 75% 35%, rgba(244,63,94,0.25) 0%, transparent 32%),
        linear-gradient(180deg, #1a0f14 0%, #120d18 100%);
}

.chat-theme-preview-default { background: linear-gradient(135deg, #12141c, #0f1117); }
.chat-theme-preview-hearts { background: linear-gradient(135deg, #ec4899 0%, #0b1020 70%); }
.chat-theme-preview-aurora { background: linear-gradient(135deg, #7c3aed, #312e81); }
.chat-theme-preview-ocean { background: linear-gradient(135deg, #0ea5e9, #071018); }
.chat-theme-preview-sunset { background: linear-gradient(135deg, #fb923c, #1a0f14); }
.chat-theme-preview-minimal { background: #27272a; }

@media (max-width: 991px) {
    .messages-chat.active {
        position: fixed; inset: 0; z-index: 500;
        width: 100%; max-width: none;
        height: 100dvh;
        max-height: 100dvh;
        flex-direction: column;
    }
    body.page-messages .messages-chat.active,
    body.chat-active .messages-chat.active {
        bottom: 0;
    }
    .messages-sidebar.hidden-mobile { display: none; }
    .chat-back { display: inline-flex; align-items: center; }
    .messages-page { border: none; }
}

/* Notifications */
.notifications-page { max-width: 600px; margin: 0 auto; padding: 1.5rem 1rem; }
.notifications-page h2 { font-size: 1.25rem; margin-bottom: 1.5rem; }
.notif-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.875rem; border-radius: var(--orbit-radius-sm); transition: var(--transition); }
.notif-item.unread { background: var(--hover-bg); }
.notif-item img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.notif-content p { margin: 0; font-size: 0.875rem; }
.notif-content time { color: var(--text-muted); font-size: 0.75rem; }

/* Create */
.create-page { max-width: 600px; margin: 0 auto; padding: 1.5rem 1rem; }
.create-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--orbit-radius); padding: 1.5rem; }
.create-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.create-tabs button {
    flex: 1; padding: 0.75rem; background: var(--bg-tertiary); border: none;
    border-radius: var(--orbit-radius-sm); color: var(--text-secondary); cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 0.5rem; font-weight: 500;
}
.create-tabs button.active { background: var(--orbit-primary); color: #fff; }
.upload-zone {
    border: 2px dashed var(--border-color); border-radius: var(--orbit-radius);
    padding: 3rem 2rem; text-align: center; cursor: pointer; transition: var(--transition);
}
.upload-zone:hover { border-color: var(--orbit-primary); background: var(--hover-bg); }
.upload-zone i { font-size: 3rem; color: var(--orbit-primary); margin-bottom: 1rem; display: block; }
.upload-zone p { margin: 0 0 0.25rem; font-weight: 600; }
.upload-zone span { color: var(--text-secondary); font-size: 0.875rem; }
.preview-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-top: 1rem; }
.preview-grid img, .preview-grid video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--orbit-radius-sm); }

/* Settings */
.settings-page { max-width: 600px; margin: 0 auto; padding: 1.5rem 1rem; }
.settings-tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; }
.settings-tabs button {
    padding: 0.5rem 1rem; background: var(--bg-tertiary); border: none;
    border-radius: 20px; color: var(--text-secondary); cursor: pointer; font-size: 0.875rem;
}
.settings-tabs button.active { background: var(--orbit-primary); color: #fff; }
.blocked-list { display: flex; flex-direction: column; gap: 0.25rem; }
.blocked-item {
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
    padding: 0.75rem; border-radius: var(--orbit-radius-sm); background: var(--bg-tertiary);
}
.blocked-user { display: flex; align-items: center; gap: 0.75rem; color: var(--text-primary); flex: 1; min-width: 0; }
.blocked-user img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.blocked-user strong { display: flex; align-items: center; gap: 0.15rem; font-size: 0.875rem; }
.blocked-user span { display: block; color: var(--text-secondary); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.settings-panel .form-control, .settings-panel .form-select { background: var(--bg-tertiary); border-color: var(--border-color); color: var(--text-primary); }
.theme-selector { display: flex; gap: 0.75rem; }
.theme-btn {
    flex: 1; padding: 1rem; background: var(--bg-tertiary); border: 2px solid transparent;
    border-radius: var(--orbit-radius-sm); color: var(--text-primary); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
}
.theme-btn.active { border-color: var(--orbit-primary); }

/* Search */
.search-page { max-width: 600px; margin: 0 auto; padding: 1.5rem 1rem; }
.search-form { position: relative; margin-bottom: 1.5rem; }
.search-form i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-form input { width: 100%; padding: 0.75rem 1rem 0.75rem 2.75rem; background: var(--bg-tertiary); border: 1px solid var(--border-color); border-radius: var(--orbit-radius-sm); color: var(--text-primary); }
.search-result-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem; border-radius: var(--orbit-radius-sm); color: var(--text-primary); }
.search-result-item:hover { background: var(--hover-bg); }
.search-result-item img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.search-result-item span { display: block; color: var(--text-secondary); font-size: 0.875rem; }
.search-section-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.75rem; padding: 0 0.75rem; color: var(--text-primary); }
.search-suggestions { margin-top: 0.5rem; }
.story-item span { display: flex; align-items: center; justify-content: center; gap: 0.1rem; flex-wrap: wrap; }
.follow-back-item { justify-content: space-between; }
.follow-back-item > a { color: var(--text-primary); min-width: 0; }
.follow-back-section { padding: 0 0.25rem; }

/* Comments */
.post-detail-page { max-width: 935px; margin: 0 auto; padding: 1.5rem 1rem; }
.comments-section { margin-top: 1rem; }
.comment-item { display: flex; gap: 0.75rem; padding: 0.75rem 0; }
.comment-item img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.comment-item strong, .comment-body strong { display: flex; align-items: center; gap: 0.15rem; flex-wrap: wrap; }
.comment-body p { margin: 0.125rem 0; font-size: 0.875rem; }
.comment-actions { display: flex; gap: 1rem; font-size: 0.75rem; color: var(--text-muted); }
.comment-actions button { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0; }
.comment-reply { display: flex; gap: 0.5rem; margin-top: 0.5rem; margin-left: 0.5rem; }
.comment-reply img { width: 24px; height: 24px; border-radius: 50%; }
.comment-form { display: flex; align-items: center; gap: 0.75rem; padding: 1rem 0; border-top: 1px solid var(--border-color); }
.comment-form img { width: 32px; height: 32px; border-radius: 50%; }
.comment-form input { flex: 1; border: none; background: transparent; color: var(--text-primary); outline: none; }

/* Story Viewer */
.story-viewer { position: fixed; inset: 0; background: #000; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.story-viewer-inner { position: relative; max-width: 420px; width: 100%; height: 100%; max-height: 100vh; background: #111; }
.story-progress {
    display: flex; gap: 4px; padding: 10px 10px 0; position: absolute; top: 0; left: 0; right: 0; z-index: 4;
}
.story-progress-seg { flex: 1; height: 3px; background: rgba(255,255,255,0.35); border-radius: 2px; overflow: hidden; }
.story-progress-fill { display: block; height: 100%; width: 0; background: #fff; border-radius: 2px; }
.story-progress-fill.done { width: 100%; }
.story-top-bar {
    position: absolute; top: 18px; left: 10px; right: 48px; z-index: 5;
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.story-nav-zones {
    position: absolute; inset: 0; z-index: 3;
    display: flex; pointer-events: none;
}
.story-nav-prev, .story-nav-next {
    flex: 1; height: 100%; border: none; background: transparent;
    cursor: pointer; pointer-events: auto; padding: 0; margin: 0;
    -webkit-tap-highlight-color: transparent;
}
.story-nav-prev { flex: 0 0 35%; max-width: 35%; }
.story-nav-next { flex: 0 0 65%; max-width: 65%; }
.story-nav-prev:active, .story-nav-next:active { background: rgba(255,255,255,0.04); }
.story-user-info { display: flex; align-items: center; gap: 0.6rem; color: #fff; text-decoration: none; min-width: 0; }
.story-user-info img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.story-user-info strong { display: flex; align-items: center; gap: 0.15rem; font-size: 0.85rem; }
.story-user-info span { display: block; font-size: 0.7rem; opacity: 0.75; }
.story-views-btn {
    background: rgba(0,0,0,0.45); border: none; color: #fff; border-radius: 16px;
    padding: 0.25rem 0.65rem; font-size: 0.75rem; white-space: nowrap;
}
.story-close { position: absolute; top: 20px; right: 12px; background: none; border: none; color: #fff; font-size: 1.5rem; z-index: 5; cursor: pointer; }
.story-content { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: relative; }
.story-content img, .story-content video { width: 100%; height: 100%; object-fit: cover; }
.story-bottom-bar {
    position: absolute; bottom: 0; left: 0; right: 0; z-index: 4;
    padding: 0.75rem; background: linear-gradient(transparent, rgba(0,0,0,0.65));
}
.story-reply-form { display: flex; align-items: center; gap: 0.5rem; }
.story-reply-form input {
    flex: 1; background: transparent; border: 1px solid rgba(255,255,255,0.5);
    border-radius: 24px; padding: 0.6rem 1rem; color: #fff; font-size: 0.875rem;
}
.story-reply-form input::placeholder { color: rgba(255,255,255,0.7); }
.story-like-btn, .story-comment-btn, .story-send-btn {
    background: none; border: none; color: #fff; font-size: 1.25rem; padding: 0.25rem;
}
.story-like-btn.liked { color: #ef4444; }
.story-comments-sheet {
    position: absolute; bottom: 0; left: 0; right: 0; max-height: 55%;
    background: #1a1a1a; border-radius: 16px 16px 0 0; z-index: 6;
    display: flex; flex-direction: column;
}
.story-comments-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem; border-bottom: 1px solid #333; color: #fff; }
.story-comments-header h4 { margin: 0; font-size: 0.95rem; }
.story-comments-header button { background: none; border: none; color: #fff; }
.story-comments-list { flex: 1; overflow-y: auto; padding: 0.75rem; }
.story-comment-item { display: flex; gap: 0.6rem; margin-bottom: 0.75rem; color: #fff; }
.story-comment-item img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.story-comment-item strong { display: flex; align-items: center; gap: 0.15rem; font-size: 0.85rem; }
.story-comment-item p { margin: 0.15rem 0 0; font-size: 0.85rem; }
.story-comments-form { display: flex; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid #333; }
.story-comments-form input { flex: 1; background: #262626; border: none; border-radius: 8px; padding: 0.6rem; color: #fff; }
.story-comments-form button { background: #0095f6; color: #fff; border: none; border-radius: 8px; padding: 0 1rem; font-weight: 600; }
.story-heart-pop {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-size: 5rem; color: #ef4444; pointer-events: none; z-index: 3;
    animation: storyHeartPop 0.8s ease forwards;
}
@keyframes storyHeartPop {
    0% { transform: scale(0); opacity: 0; }
    40% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 0; }
}
.story-overlay-text {
    position: absolute; top: 45%; left: 50%; transform: translate(-50%, -50%);
    color: #fff; font-size: 1.5rem; font-weight: 700; text-align: center;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8); max-width: 85%; z-index: 2; pointer-events: none;
}
.story-caption-label {
    position: absolute; bottom: 80px; left: 12px; right: 12px; color: #fff;
    font-size: 0.85rem; text-shadow: 0 1px 4px rgba(0,0,0,0.8); z-index: 2;
}

/* Story Editor (Instagram-style) */
body.story-editor-open { overflow: hidden; }
.story-editor {
    position: fixed; inset: 0; z-index: 2500; background: #000;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.story-editor-stage {
    position: relative; width: 100%; max-width: 420px; height: 100%; max-height: 100vh;
    background: #111; overflow: hidden;
}
.story-editor-media { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.story-editor-media img, .story-editor-media video { width: 100%; height: 100%; object-fit: cover; }
.story-editor-overlay-text {
    position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%);
    color: #fff; font-size: 1.75rem; font-weight: 700; text-align: center;
    text-shadow: 0 2px 10px rgba(0,0,0,0.85); max-width: 88%; z-index: 2;
}
.story-editor-music-label {
    position: absolute; bottom: 120px; left: 12px; right: 12px;
    background: rgba(0,0,0,0.55); color: #fff; padding: 8px 12px; border-radius: 8px;
    font-size: 0.8rem; display: flex; align-items: center; gap: 8px; z-index: 2;
}
.story-editor-close {
    position: absolute; top: 16px; left: 16px; z-index: 5;
    background: none; border: none; color: #fff; font-size: 1.5rem; padding: 0.25rem;
}
.story-editor-tools {
    position: absolute; top: 50%; right: 12px; transform: translateY(-50%);
    display: flex; flex-direction: column; gap: 1rem; z-index: 5;
}
.story-editor-tools button {
    width: 44px; height: 44px; border-radius: 50%; border: none;
    background: rgba(255,255,255,0.15); color: #fff; font-size: 1.15rem;
    display: flex; align-items: center; justify-content: center; backdrop-filter: blur(8px);
}
.story-editor-tools button:hover { background: rgba(255,255,255,0.25); }
.story-editor-panel {
    position: absolute; bottom: 90px; left: 12px; right: 60px; z-index: 5;
    background: rgba(20,20,28,0.96); border-radius: 16px; padding: 1rem;
    border: 1px solid rgba(255,255,255,0.1); color: #fff;
}
.story-editor-panel h5 { font-size: 0.95rem; margin: 0 0 0.75rem; display: flex; align-items: center; gap: 0.4rem; }
.story-editor-panel .form-control { background: #262626; border-color: #444; color: #fff; }
.story-editor-upload-btn {
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.75rem; background: #363636; border-radius: 10px; cursor: pointer; font-size: 0.875rem;
}
.story-editor-panel-hint { margin: 0.5rem 0 0; font-size: 0.75rem; color: rgba(255,255,255,0.55); }
.story-editor-bottom {
    position: absolute; bottom: 0; left: 0; right: 0; z-index: 5;
    padding: 0.75rem 1rem 1.25rem; display: flex; align-items: center; gap: 0.75rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.85));
    max-width: 420px; margin: 0 auto; width: 100%;
}
.story-editor-bottom input {
    flex: 1; background: transparent; border: 1px solid rgba(255,255,255,0.35);
    border-radius: 24px; padding: 0.65rem 1rem; color: #fff; font-size: 0.875rem;
}
.story-editor-bottom input::placeholder { color: rgba(255,255,255,0.6); }
.story-editor-bottom input:focus { outline: none; border-color: rgba(255,255,255,0.6); }
.story-editor-share {
    display: flex; align-items: center; gap: 0.5rem; background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25); border-radius: 24px; color: #fff;
    padding: 0.4rem 0.85rem 0.4rem 0.4rem; font-size: 0.8rem; font-weight: 600; white-space: nowrap;
}
.story-editor-share img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.story-upload-zone { cursor: pointer; }

/* Empty & Error */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-secondary); }
.empty-state i { font-size: 3rem; margin-bottom: 1rem; display: block; }
.error-page { text-align: center; padding: 4rem 2rem; }
.error-page i { font-size: 4rem; color: var(--orbit-primary); }

/* Toast */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; }
.orbit-toast {
    background: var(--card-bg); border: 1px solid var(--border-color);
    padding: 0.875rem 1.25rem; border-radius: var(--orbit-radius-sm);
    box-shadow: var(--shadow-lg); animation: fadeInUp 0.3s ease;
    font-size: 0.875rem; max-width: 320px;
}
.orbit-toast.success { border-left: 3px solid #22c55e; }
.orbit-toast.error { border-left: 3px solid #ef4444; }

.chat-security-card { background: var(--bg-tertiary); border-radius: var(--orbit-radius); padding: 1.5rem; text-align: center; }
.chat-security-card i { font-size: 2.5rem; color: #22c55e; }
.chat-security-card p { color: var(--text-secondary); font-size: 0.875rem; }
.saved-page { max-width: 600px; margin: 0 auto; padding: 1.5rem 1rem; }
.saved-page h2 { font-size: 1.25rem; margin-bottom: 1.5rem; display: flex; align-items: center; gap: 0.5rem; }
.story-music-label { position: absolute; bottom: 60px; left: 12px; right: 12px; background: rgba(0,0,0,0.6); color: #fff; padding: 8px 12px; border-radius: 8px; font-size: 0.8rem; display: flex; align-items: center; gap: 8px; }
.story-mentions { position: absolute; top: 48px; left: 12px; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,0.8); font-weight: 600; }
.d-none { display: none !important; }
.hashtag { color: var(--orbit-primary); font-weight: 500; }
.text-muted { color: var(--text-muted) !important; }

@media (max-width: 768px) {
    .profile-grid, .explore-grid { gap: 2px; }
    .messages-page { flex-direction: column; }
    .messages-sidebar { width: 100%; height: 100%; }
    .messages-chat { display: none; }
    .messages-chat.active { display: flex; position: fixed; inset: 0; z-index: 500; background: var(--bg-primary); }
}
