:root {
    --bg: #000;
    --surface: #121212;
    --elevated: #1a1a1a;
    --primary: #66bb6a;
    --primary-hover: #5aab5e;
    --text-on-primary: #121212;
    --secondary-button-bg: #374151;
    --secondary-button-text: #F3F4F6;
    --text: #f5f5f5;
    --text-muted: #a8a8a8;
    --border: #262626;
    --nav-w: 244px;
    --rail-w: 320px;
    --feed-w: 630px;
    --danger: #ed4956;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button {
    appearance: none;
    -webkit-appearance: none;
}
img { max-width: 100%; }

.app {
    min-height: 100vh;
}

.nav {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--nav-w);
    padding: 28px 12px 20px;
    border-right: 1px solid var(--border);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    z-index: 20;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px 28px;
    text-decoration: none;
}
.brand img {
    width: 32px;
    height: 32px;
    border-radius: 9px;
}
.brand span {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 22px;
    letter-spacing: -0.04em;
}
.nav-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    text-decoration: none;
    text-align: left;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
}
.nav-item:hover { background: #1a1a1a; }
.nav-item.active { font-weight: 700; }
.nav-item svg { width: 24px; height: 24px; flex-shrink: 0; }
.nav-spacer { flex: 1; }

.shell {
    margin-left: var(--nav-w);
    display: flex;
    justify-content: center;
    gap: 48px;
    padding: 28px 28px 96px;
    min-height: 100vh;
}
.center {
    width: min(var(--feed-w), 100%);
}
.center.wide {
    width: min(935px, 100%);
}

.tabs {
    display: flex;
    justify-content: center;
    gap: 40px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}
.tab {
    appearance: none;
    background: none;
    border: 0;
    padding: 12px 0;
    margin-bottom: -1px;
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
}
.tab.active {
    color: var(--text);
    border-bottom: 1px solid var(--text);
}

.search {
    position: relative;
    margin-bottom: 20px;
}
.search input {
    width: 100%;
    border: 0;
    border-radius: 12px;
    background: #262626;
    padding: 12px 16px 12px 42px;
    outline: none;
}
.search svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 48px 20px;
}
.profile-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 8px 4px 12px;
    text-align: center;
    text-decoration: none;
    color: inherit;
}
.profile-card .avatar,
.avatar {
    width: 86px;
    height: 86px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface);
    border: 1px solid var(--border);
}
.avatar.sm { width: 32px; height: 32px; }
.avatar.md { width: 44px; height: 44px; }
.avatar.lg { width: 150px; height: 150px; }
.avatar.placeholder,
.ph {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-muted);
    background: #1f1f1f;
}
.profile-card .avatar {
    margin: 0;
}
.profile-card .name {
    margin: 0;
    font-weight: 700;
    font-size: 14px;
    line-height: 1.2;
}
.profile-card .role-badge {
    margin: 0;
}
.profile-card .meta {
    margin: 0;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.2;
}
.profile-card .btn {
    margin: 0;
}
.role-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.role-badge.creator { background: rgba(102, 187, 106, 0.18); color: var(--primary); }
.role-badge.caller { background: rgba(167, 139, 250, 0.16); color: #c4b5fd; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    border: 0;
    cursor: pointer;
}
.btn-primary {
    background: var(--primary);
    color: var(--text-on-primary);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost {
    background: var(--secondary-button-bg);
    color: var(--secondary-button-text);
}
.btn-sm { padding: 7px 16px; font-size: 13px; }
.btn-md { padding: 9px 18px; font-size: 14px; }
.name-row .btn,
.desktop-actions .btn,
.actions-row .btn {
    padding: 4px 12px;
    font-size: 13px;
    line-height: 1.2;
    border-radius: 7px;
}

.feed {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.post-card {
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    overflow: hidden;
}
.post-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    text-decoration: none;
}
.post-head .who { font-weight: 700; font-size: 14px; }
.post-head .when { color: var(--text-muted); font-size: 13px; }
.post-media {
    position: relative;
    display: block;
    background: #111;
    overflow: hidden;
}
.post-media img {
    width: 100%;
    max-height: 680px;
    object-fit: contain;
    display: block;
}
.post-thumbs {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px 0;
}
.post-thumbs button {
    width: 56px;
    height: 56px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    background: #111;
    cursor: pointer;
}
.post-thumbs button.on { border-color: #fff; }
.post-thumbs img {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
    display: block;
}
.post-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px 0;
    color: var(--text);
}
.post-actions button {
    appearance: none;
    -webkit-appearance: none;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    background: transparent;
    background-color: transparent;
    box-shadow: none;
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.post-actions svg {
    width: 24px;
    height: 24px;
    display: block;
    flex-shrink: 0;
    overflow: visible;
}
.post-body { padding: 8px 14px 16px; }
.post-likes { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.post-caption { font-size: 14px; line-height: 1.45; }
.post-caption strong { margin-right: 6px; }
.mention { color: #66BB6A; font-weight: 700; text-decoration: none; }

.rail {
    width: var(--rail-w);
    padding-top: 8px;
    flex-shrink: 0;
}
.rail h3 {
    margin: 28px 0 16px;
    font-size: 14px;
    color: var(--text-muted);
}
.suggest {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    text-decoration: none;
}
.suggest .who { font-weight: 700; font-size: 14px; }
.suggest .meta { color: var(--text-muted); font-size: 12px; }
.suggest .grow { flex: 1; min-width: 0; }
.suggest .who, .suggest .meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.app-cta {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
}
.app-cta img { width: 44px; height: 44px; border-radius: 12px; }
.app-cta strong { display: block; }
.app-cta span { color: var(--text-muted); font-size: 13px; }

.page-back {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 6px;
    width: max-content;
    max-width: 100%;
    height: auto;
    margin: 0 0 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}
.page-back-icon {
    display: block;
    width: 22px;
    height: 22px;
    max-width: 22px;
    max-height: 22px;
    flex: 0 0 22px;
    overflow: hidden;
}
.page-back:hover { color: var(--text); }
.profile-head {
    display: grid;
    grid-template-columns: 168px 1fr;
    gap: 48px;
    align-items: center;
    margin-bottom: 36px;
}
.name-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}
.name-extras {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}
.desktop-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    width: 100%;
    margin: -6px 0 18px;
}
.desktop-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 8px 12px;
}
.profile-title {
    margin: 0;
    font-size: 20px;
    font-weight: 400;
}
.ticker { color: var(--text-muted); }
.profile-metrics {
    margin: 0 0 16px;
}
.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.btn-trade { display: none; }
.stats li {
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.stats strong { font-weight: 700; }
.stats span { color: var(--text-muted); }
.bio {
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.5;
    max-width: 42ch;
}
.actions-row {
    display: none;
    flex-wrap: nowrap;
    gap: 8px;
    margin-top: 16px;
}
.posts-tab {
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
    margin-bottom: 4px;
}
.posts-tab span {
    padding: 16px 8px;
    font-size: 12px;
    letter-spacing: 0.08em;
    font-weight: 600;
    border-top: 1px solid var(--text);
    margin-top: -1px;
}
.media-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}
.tile {
    position: relative;
    aspect-ratio: 3 / 4;
    background: #111;
    overflow: hidden;
    border: 0;
    padding: 0;
    cursor: pointer;
}
.tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.carousel {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 13px;
    height: 13px;
    border: 2px solid #fff;
    box-shadow: 4px -4px 0 0 #fff;
}

.state {
    color: var(--text-muted);
    text-align: center;
    padding: 48px 16px;
}
.bottom {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 56px;
    border-top: 1px solid var(--border);
    background: rgba(0,0,0,0.92);
    backdrop-filter: blur(16px);
    z-index: 20;
}
.bottom a, .bottom button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 0;
    color: var(--text);
    text-decoration: none;
}
.bottom svg { width: 24px; height: 24px; }

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.86);
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.lightbox[hidden] { display: none; }
.lightbox-card {
    width: min(920px, 100%);
    max-height: 90vh;
    background: #000;
    border: 1px solid var(--border);
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
    overflow: hidden;
}
.lightbox-media {
    position: relative;
    min-height: 420px;
    max-height: 90vh;
    background: #000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.lightbox-stage {
    position: relative;
    flex: 1;
    min-height: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.lightbox-stage img,
.lightbox-card img#lb-image {
    width: 100%;
    height: 100%;
    max-height: calc(90vh - 88px);
    object-fit: contain;
    background: #000;
    display: block;
}
.lb-thumbs {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px 12px;
    background: #0a0a0a;
    border-top: 1px solid var(--border);
}
.lb-thumbs[hidden] { display: none; }
.lb-thumbs button {
    width: 56px;
    height: 56px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    background: #111;
    cursor: pointer;
}
.lb-thumbs button.on { border-color: #fff; }
.lb-thumbs img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.lightbox-meta {
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.lb-author {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 14px;
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
}
.lb-author .avatar { flex-shrink: 0; }
.lightbox-meta .bio {
    margin: 0 0 16px;
    max-width: none;
}
.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: 0;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    z-index: 2;
}
.lb-nav,
.media-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 0;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.lb-nav svg,
.media-nav svg {
    width: 18px;
    height: 18px;
    display: block;
}
.lb-nav[hidden],
.media-nav[hidden] { display: none; }
.lb-nav.prev,
.media-nav.prev { left: 10px; }
.lb-nav.next,
.media-nav.next { right: 10px; }
.lb-dots,
.media-dots {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 12px;
    display: flex;
    justify-content: center;
    gap: 6px;
    pointer-events: none;
}
.lb-dots span,
.media-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.45);
}
.lb-dots span.on,
.media-dots span.on { background: #fff; }

.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0,0,0,0.72);
}
.auth-modal[hidden] { display: none; }
.auth-card {
    width: min(420px, 100%);
    background: #141416;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 32px 28px 28px;
    text-align: center;
}
.auth-card img.logo {
    width: 96px;
    height: 96px;
    object-fit: contain;
    margin: 0 auto 12px;
    display: block;
}
.auth-card h2 {
    margin: 0 0 4px;
    font-size: 24px;
}
.auth-card .powered {
    color: var(--text-muted);
    font-size: 12px;
    margin: 0 0 20px;
}
.auth-card .hint {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0 0 16px;
    line-height: 1.45;
}
.auth-card .err {
    color: #f87171;
    font-size: 13px;
    margin: 0 0 12px;
}
.auth-card input {
    width: 100%;
    height: 50px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #1a1a1a;
    padding: 0 16px;
    margin-bottom: 12px;
    outline: none;
}
.auth-methods {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}
.auth-methods .btn,
.auth-card .btn {
    width: 100%;
    height: 48px;
    border-radius: 24px;
}
.btn-apple {
    background: #fff;
    color: #000;
}
.auth-close {
    margin-top: 12px;
    background: none;
    border: 0;
    color: var(--text-muted);
    cursor: pointer;
}

@media (max-width: 1260px) {
    .rail { display: none; }
}
@media (max-width: 768px) {
    .nav { display: none; }
    .shell {
        margin-left: 0;
        padding: 16px 12px 88px;
    }
    .profile-page {
        position: relative;
        padding: 44px 8px 0;
        margin-bottom: 8px;
    }
    .page-back {
        position: absolute;
        top: 2px;
        left: 0;
        z-index: 1;
        justify-content: center;
        margin: 0;
        color: var(--primary);
        width: 40px;
        max-width: 40px;
        height: 40px;
    }
    .page-back-icon {
        display: block;
        width: 22px;
        height: 22px;
        max-width: 22px;
        max-height: 22px;
        flex: 0 0 22px;
    }
    .page-back-label { display: none; }
    .profile-head {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 16px 24px;
        margin-bottom: 20px;
    }
    .profile-main {
        display: contents;
    }
    .name-row {
        position: absolute;
        top: 2px;
        left: 48px;
        right: 48px;
        z-index: 1;
        justify-content: center;
        margin: 0;
        min-width: 0;
    }
    .profile-title {
        font-size: 18px;
        font-weight: 700;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .name-extras { display: none; }
    .desktop-actions { display: none; }
    .profile-avatar { flex: 0 0 88px; }
    .avatar.lg { width: 88px; height: 88px; }
    .profile-metrics {
        flex: 1 1 0;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin: 0;
    }
    .stats {
        flex: 0 0 auto;
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: space-around;
        gap: 0;
        margin: 0;
        min-width: 0;
        width: 100%;
    }
    .btn-trade:not([hidden]) {
        display: flex;
        width: 100%;
        height: 28px;
        padding: 0 12px;
        font-size: 12px;
        font-weight: 700;
        border-radius: 8px;
    }
    .stats li {
        flex: 1;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        min-width: 0;
    }
    .stats strong {
        font-size: 16px;
        line-height: 1.2;
    }
    .stats span {
        font-size: 12px;
        line-height: 1.2;
    }
    .bio {
        flex: 1 1 100%;
        max-width: none;
        margin: 0;
        color: var(--text-muted);
        line-height: 20px;
    }
    .actions-row {
        flex: 1 1 100%;
        display: flex;
        margin: 0;
    }
    .actions-row .btn {
        flex: 1 1 0;
        height: 32px;
        padding: 0 12px;
        font-size: 12px;
        font-weight: 700;
        border-radius: 8px;
    }
    .profile-grid { grid-template-columns: repeat(2, 1fr); gap: 40px 16px; }
    .bottom { display: flex; }
    .lightbox-card { grid-template-columns: 1fr; }
    .lightbox-media { min-height: 280px; }
    .lightbox-stage { min-height: 220px; }
    .name-row .desktop-only { display: none; }
}
