/* Profile Page Styles */

/* Scoped to #profile-screen so it wins over the older shared profile rules in styles.css. */
#profile-screen .profile-content {
    flex: 1;
    overflow-y: auto;
    margin: 0 0 0 var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: none;
    padding: 0 clamp(16px, 3vw, 40px) 48px;
    scrollbar-width: none;
}

#profile-screen .profile-content::-webkit-scrollbar {
    width: 0;
    height: 0;
}

/* Identity rail on the left, timeline on the right. The top gap lives here, not on the
   scroll container, because sticky offsets are measured inside the container's padding. */
#profile-screen .profile-layout {
    display: grid;
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
    align-items: start;
    gap: clamp(20px, 2.6vw, 36px);
    max-width: 1140px;
    min-height: 0;
    margin: 0 auto;
    padding-top: 28px;
}

#profile-screen .profile-rail {
    position: sticky;
    top: 28px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: calc(100dvh - 56px);
    overflow-y: auto;
    scrollbar-width: none;
    border-radius: 28px;
}

#profile-screen .profile-rail::-webkit-scrollbar {
    width: 0;
}

#profile-screen .profile-main {
    width: 100%;
    max-width: 680px;
    min-width: 0;
    min-height: 0;
}

/* ---- Identity card ---- */
#profile-screen .profile-header {
    position: relative;
    flex-shrink: 0;
    width: auto;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border-primary);
    border-radius: 28px;
    background: var(--surface-card);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    isolation: isolate;
}

#profile-screen .profile-cover {
    position: relative;
    height: 148px;
    border: 0;
    overflow: hidden;
    background:
        radial-gradient(120% 100% at 0% 0%, rgba(var(--brand-rgb), 0.95) 0%, transparent 62%),
        radial-gradient(90% 130% at 100% 0%, color-mix(in srgb, var(--brand-orange-light) 75%, transparent) 0%, transparent 58%),
        radial-gradient(70% 90% at 55% 115%, color-mix(in srgb, var(--brand-orange-deep) 85%, transparent) 0%, transparent 70%),
        var(--bg-tertiary);
    background-size: 170% 170%, 150% 150%, 140% 140%, auto;
    animation: profile-aurora 24s ease-in-out infinite alternate;
}

/* Topographic contour lines, faded into the card. */
#profile-screen .profile-cover::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, transparent 45%, var(--bg-secondary) 100%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 150' preserveAspectRatio='xMidYMid slice' fill='none' stroke='white' stroke-opacity='0.26' stroke-width='1'%3E%3Cpath d='M-20 132C60 92 120 152 200 112S340 52 420 92'/%3E%3Cpath d='M-20 112C60 72 130 132 210 94S340 34 420 72'/%3E%3Cpath d='M-20 92C70 52 140 112 220 76S340 16 420 52'/%3E%3Cpath d='M-20 72C70 32 150 92 230 58S340-2 420 32'/%3E%3Cellipse cx='318' cy='34' rx='26' ry='15'/%3E%3Cellipse cx='318' cy='34' rx='48' ry='29'/%3E%3Cellipse cx='318' cy='34' rx='72' ry='45'/%3E%3C/svg%3E") center / cover no-repeat;
}

/* Film grain keeps the gradient from banding. */
#profile-screen .profile-cover::after {
    content: "";
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.18;
    mix-blend-mode: overlay;
    pointer-events: none;
}

@keyframes profile-aurora {
    0% { background-position: 0% 0%, 100% 0%, 50% 100%, 0 0; }
    100% { background-position: 35% 25%, 65% 35%, 40% 70%, 0 0; }
}

#profile-screen .profile-header-actions {
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

#profile-screen .profile-header-dropdown {
    margin-left: auto;
}

#profile-screen .profile-back-btn,
#profile-screen .profile-settings-btn {
    width: 34px;
    height: 34px;
    color: #fff;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

#profile-screen .profile-back-btn:hover,
#profile-screen .profile-settings-btn:hover,
#profile-screen .profile-settings-btn[aria-expanded="true"] {
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    border-color: rgba(255, 255, 255, 0.3);
}

#profile-screen .profile-identity {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin: -56px 0 0;
    padding: 0 22px 20px;
    text-align: left;
}

/* Organic blob avatar with a theme-coloured ring that follows its shape. */
#profile-screen .profile-avatar-large {
    width: 108px;
    height: 108px;
    margin: 0 0 14px;
    border: 0;
    border-radius: 44% 56% 52% 48% / 50% 44% 56% 50%;
    box-shadow:
        0 0 0 4px var(--bg-secondary),
        0 0 0 6px rgba(var(--brand-rgb), 0.85),
        0 18px 40px -12px rgba(var(--brand-rgb), 0.55);
    animation: profile-blob 16s ease-in-out infinite;
}

#profile-screen .profile-avatar-large .profile-avatar-img {
    border-radius: inherit;
}

@keyframes profile-blob {
    0%, 100% { border-radius: 44% 56% 52% 48% / 50% 44% 56% 50%; }
    33% { border-radius: 56% 44% 46% 54% / 44% 56% 46% 54%; }
    66% { border-radius: 48% 52% 58% 42% / 56% 48% 52% 44%; }
}

/* Until JS applies the real user, avoid a placeholder @username flash. */
#profile-screen .profile-identity--pending .profile-username {
    visibility: hidden;
}

#profile-screen .profile-identity--pending .profile-avatar-large {
    animation: profile-identity-shimmer 1.1s ease-in-out infinite;
}

@keyframes profile-identity-shimmer {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 0.9; }
}

#profile-screen .profile-identity-copy {
    width: 100%;
    min-width: 0;
    padding: 0;
}

#profile-screen .profile-display-name {
    margin: 0 0 4px;
    font-size: clamp(26px, 2.2vw, 32px);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.04em;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

#profile-screen .profile-username {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: 0;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

/* No display name: the handle becomes the headline. */
#profile-screen .profile-identity-copy:has(.profile-display-name[style*="none"]) .profile-username {
    font-size: clamp(24px, 2vw, 30px);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.04em;
    color: var(--text-primary);
}

#profile-screen .profile-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

#profile-screen .profile-chips:not(:has(> :not([hidden]))) {
    display: none;
}

#profile-screen .profile-sns,
#profile-screen .profile-sns-get {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    height: 28px;
    padding: 0 12px 0 10px;
    border-radius: var(--radius-full);
    font: inherit;
    font-size: 12.5px;
    font-weight: 700;
    text-decoration: none;
    transition: background var(--transition-base), border-color var(--transition-base), color var(--transition-base);
}

#profile-screen .profile-sns {
    color: var(--text-primary);
    background: rgba(var(--brand-rgb), 0.12);
    border: 1px solid rgba(var(--brand-rgb), 0.38);
}

#profile-screen .profile-sns:hover {
    background: rgba(var(--brand-rgb), 0.2);
}

#profile-screen .profile-sns svg {
    flex-shrink: 0;
    color: var(--brand-orange);
}

#profile-screen .profile-sns-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Registered so the conic border angle can animate. */
@property --sns-angle {
    syntax: "<angle>";
    inherits: false;
    initial-value: 0deg;
}

#profile-screen .profile-sns-get {
    position: relative;
    height: 32px;
    padding: 0 12px 0 11px;
    overflow: hidden;
    color: var(--text-primary);
    border: 1.5px solid transparent;
    background:
        linear-gradient(rgba(var(--brand-rgb), 0.1), rgba(var(--brand-rgb), 0.1)) padding-box,
        linear-gradient(var(--bg-secondary), var(--bg-secondary)) padding-box,
        conic-gradient(
            from var(--sns-angle),
            rgba(var(--brand-rgb), 0.18) 0deg,
            var(--brand-orange-light) 50deg,
            #fff 80deg,
            var(--brand-orange) 120deg,
            rgba(var(--brand-rgb), 0.18) 190deg,
            rgba(var(--brand-rgb), 0.18) 360deg
        ) border-box;
    box-shadow: 0 8px 22px -12px rgba(var(--brand-rgb), 0.9);
    cursor: pointer;
    animation: profile-sns-orbit 3.6s linear infinite;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

/* Light sweep on hover. */
#profile-screen .profile-sns-get::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.22) 50%, transparent 70%);
    transform: translateX(-120%);
    pointer-events: none;
}

#profile-screen .profile-sns-get:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 26px -10px rgba(var(--brand-rgb), 1);
}

#profile-screen .profile-sns-get:hover::after {
    transform: translateX(120%);
    transition: transform 0.7s ease;
}

#profile-screen .profile-sns-get:active {
    transform: translateY(0);
}

#profile-screen .profile-sns-get:focus-visible {
    outline: 2px solid rgba(var(--brand-rgb), 0.6);
    outline-offset: 2px;
}

#profile-screen .profile-sns-get-icon {
    flex-shrink: 0;
    color: var(--brand-orange-light);
    transition: transform 0.5s ease;
}

#profile-screen .profile-sns-get:hover .profile-sns-get-icon {
    transform: rotate(90deg) scale(1.1);
}

#profile-screen .profile-sns-get-tld {
    background: linear-gradient(90deg, var(--brand-orange-light), var(--brand-orange));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 800;
}

#profile-screen .profile-sns-get-arrow {
    flex-shrink: 0;
    margin-left: -1px;
    opacity: 0.55;
    transition: transform var(--transition-base), opacity var(--transition-base);
}

#profile-screen .profile-sns-get:hover .profile-sns-get-arrow {
    opacity: 1;
    transform: translateX(2px);
}

@keyframes profile-sns-orbit {
    to { --sns-angle: 360deg; }
}

#profile-screen .profile-bio {
    max-width: none;
    margin: 14px 0 0;
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--text-primary);
    white-space: pre-line;
    overflow-wrap: anywhere;
}

#profile-screen .profile-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px 14px;
    margin: 12px 0 0;
    padding: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

#profile-screen .profile-meta:not(:has(> [style*="inline-flex"])) {
    display: none;
}

#profile-screen .profile-link,
#profile-screen .profile-location {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    color: var(--text-secondary);
    text-decoration: none;
}

#profile-screen .profile-meta svg {
    width: 15px;
    height: 15px;
    margin: 0;
    flex-shrink: 0;
}

#profile-screen .profile-link:hover {
    color: var(--brand-orange);
    text-decoration: none;
}

#profile-screen .profile-link .link-text {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#profile-screen .profile-actions {
    display: flex;
    gap: 8px;
    width: 100%;
    margin: 18px 0 0;
    padding: 0;
}

#profile-screen .profile-actions:not(:has(> :not([hidden]))) {
    display: none;
}

#profile-screen .btn-follow-profile,
#profile-screen .btn-edit-profile {
    flex: 1;
    width: auto;
    max-width: none;
    min-width: 0;
    height: 42px;
    margin: 0;
    padding: 0 18px;
    font-size: 14px;
    font-weight: 700;
}

/* ---- Stats ledger ---- */
#profile-screen .profile-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-top: 1px solid var(--border-primary);
}

#profile-screen .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    margin: 0;
    padding: 14px 6px 16px;
    border: 0;
    border-radius: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: center;
}

#profile-screen .stat-item + .stat-item {
    border-left: 1px solid var(--border-primary);
}

#profile-screen .stat-item--interactive {
    cursor: pointer;
    transition: background var(--transition-base);
}

#profile-screen .stat-item--interactive:hover {
    background: var(--surface-btn);
}

#profile-screen .stat-item--interactive:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px rgba(var(--brand-rgb), 0.5);
}

#profile-screen .stat-number {
    display: block;
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

#profile-screen .stat-label {
    display: block;
    margin: 0;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

/* ---- Creator rewards ---- */
#profile-screen .profile-rewards {
    position: relative;
    flex-shrink: 0;
    padding: 18px;
    border: 1px solid rgba(var(--brand-rgb), 0.28);
    border-radius: 24px;
    background:
        radial-gradient(120% 80% at 100% 0%, rgba(var(--brand-rgb), 0.16), transparent 60%),
        var(--surface-card);
    overflow: hidden;
}

#profile-screen .profile-rewards-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 14px;
}

#profile-screen .profile-rewards-title {
    margin: 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

#profile-screen .profile-rewards-tag {
    padding: 3px 9px;
    border-radius: var(--radius-full);
    background: rgba(var(--brand-rgb), 0.16);
    color: var(--brand-orange-light);
    font-size: 11px;
    font-weight: 700;
}

#profile-screen .profile-rewards-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

#profile-screen .profile-rewards-stats > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

#profile-screen .profile-rewards-value {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

#profile-screen .profile-rewards-label {
    font-size: 11px;
    color: var(--text-secondary);
}

#profile-screen .profile-rewards-bar {
    height: 4px;
    margin: 16px 0 10px;
    border-radius: var(--radius-full);
    background: var(--surface-btn);
    overflow: hidden;
}

#profile-screen .profile-rewards-bar span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand-orange-deep), var(--brand-orange-light));
    transition: width 0.6s ease;
}

#profile-screen .profile-rewards-note {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* ---- Collection shelf ---- */
#profile-screen .profile-side {
    position: static;
    flex: none;
    width: auto;
    margin: 0;
}

#profile-screen .profile-side .panel-card {
    padding: 18px;
    border-radius: 24px;
}

#profile-screen .profile-side .panel-card-title {
    margin: 0 0 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

#profile-screen .portfolio-nft-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 8px;
}

#profile-screen .portfolio-nft-item,
#profile-screen a.portfolio-nft-item:hover {
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: none;
}

#profile-screen .portfolio-nft-image {
    margin-bottom: 6px;
    border-radius: 14px;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

#profile-screen a.portfolio-nft-item:hover .portfolio-nft-image {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px -10px rgba(var(--brand-rgb), 0.6);
}

#profile-screen .portfolio-nft-name {
    font-size: 11.5px;
    color: var(--text-secondary);
}

/* ---- Timeline ---- */
#profile-screen .profile-main-head {
    position: sticky;
    top: -12px;
    z-index: 5;
    display: flex;
    align-items: center;
    margin: -28px 0 0;
    padding: 28px 0 16px;
    background: linear-gradient(180deg, var(--bg-primary) 72%, transparent);
}

#profile-screen .profile-tabs {
    display: inline-flex;
    gap: 4px;
    margin: 0;
    padding: 4px;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    background: var(--surface-btn);
}

#profile-screen .tab-btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border: 0;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition-base), color var(--transition-base);
}

#profile-screen .tab-btn:hover {
    color: var(--text-primary);
    background: var(--surface-btn);
}

#profile-screen .tab-btn.active {
    color: var(--bg-primary);
    background: var(--text-primary);
}

#profile-screen .tab-btn:focus {
    outline: none;
}

#profile-screen .tab-btn:focus-visible {
    box-shadow: 0 0 0 2px rgba(var(--brand-rgb), 0.55);
}

#profile-screen .tab-btn svg {
    width: 15px;
    height: 15px;
}

#profile-screen .profile-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 0 0 32px;
}

#profile-screen .grid-post {
    border: 1px solid var(--border-primary);
    border-radius: 24px;
    background: var(--surface-card);
    box-shadow: none;
    transition: border-color var(--transition-base), transform var(--transition-base);
}

#profile-screen .grid-post:hover {
    border-color: var(--border-hover);
    background: var(--surface-card);
    transform: translateY(-1px);
}

#profile-screen .grid-post-media-wrap {
    --grid-post-media-radius: 16px;
    width: calc(100% - 20px);
    margin: 10px auto 0;
}

#profile-screen .grid-post-thought-text {
    font-size: 16px;
    line-height: 1.55;
}

#profile-screen .grid-post-footer {
    padding: 10px 18px 14px;
    border-top: 0;
    font-size: 13px;
}

#profile-screen .profile-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 56px 24px;
    border: 1px dashed var(--border-hover);
    border-radius: 24px;
    color: var(--text-secondary);
    font-size: 14px;
    text-align: center;
}

#profile-screen .profile-empty strong {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 700;
}

@media (max-width: 1080px) {
    #profile-screen .profile-layout {
        grid-template-columns: minmax(0, 1fr);
        max-width: 640px;
    }

    #profile-screen .profile-rail {
        position: static;
        max-height: none;
        overflow: visible;
    }

    #profile-screen .profile-main {
        max-width: none;
    }

    #profile-screen .profile-main-head {
        top: 0;
        margin-top: 0;
        padding-top: 12px;
    }

    #profile-screen .portfolio-nft-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    #profile-screen .profile-content {
        margin-left: 80px;
        width: calc(100% - 80px);
    }
}

@media (max-width: 640px) {
    #profile-screen .profile-content {
        margin-left: 0;
        width: 100%;
        padding: 0 12px 96px;
    }

    #profile-screen .profile-layout {
        padding-top: 12px;
    }

    #profile-screen .portfolio-nft-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    #profile-screen .profile-cover,
    #profile-screen .profile-avatar-large,
    #profile-screen .profile-sns-get {
        animation: none;
    }

    #profile-screen .grid-post:hover {
        transform: none;
    }
}

.profile-portfolio-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.portfolio-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.portfolio-summary-item {
    min-width: 0;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle, #2a2a2a);
}

.portfolio-summary-label {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.portfolio-summary-value {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.portfolio-summary-note {
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 11px;
}

.portfolio-pnl--positive {
    color: #4caf50;
}

.portfolio-pnl--negative {
    color: #ff6b6b;
}

.portfolio-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.portfolio-section-title {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.portfolio-list {
    display: grid;
    gap: 10px;
}

.portfolio-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle, #2a2a2a);
}

.portfolio-item-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.portfolio-item-media {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    overflow: hidden;
    flex: 0 0 auto;
    background: rgba(255, 255, 255, 0.04);
}

.portfolio-item-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.portfolio-item-badge {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 800;
    background: linear-gradient(135deg, #ff7a4d, #f15a24);
    color: white;
}

.portfolio-item-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.portfolio-item-meta {
    font-size: 11px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}

.portfolio-item-balance {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.portfolio-nft-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 10px;
}

.portfolio-nft-item {
    padding: 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle, #2a2a2a);
    color: inherit;
    text-decoration: none;
    display: block;
}

a.portfolio-nft-item:hover {
    border-color: var(--border-hover, rgba(255, 255, 255, 0.12));
    background: rgba(255, 255, 255, 0.05);
}

.portfolio-nft-solscan {
    margin-top: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.portfolio-nft-image {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 10px;
    background: linear-gradient(135deg, #ff7a4d, #f15a24);
    overflow: hidden;
    margin-bottom: 8px;
}

.portfolio-nft-image img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.portfolio-nft-image:empty,
.portfolio-nft-image--fallback {
    background: linear-gradient(135deg, #ff7a4d, #f15a24);
}

.portfolio-nft-name {
    font-size: 12px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portfolio-empty-group,
.portfolio-state {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

/* Profile feed (single column — scrolls like a timeline) */
.profile-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 10px 0 28px;
    background: transparent;
}

.grid-post {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    cursor: pointer;
    transition: background 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015));
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-sm);
}

.grid-post-author {
    padding: 12px 14px 0;
}

.grid-post-author-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    max-width: 100%;
}

.grid-post-author-link:hover {
    color: var(--brand-orange);
}

.grid-post-author-link:focus-visible {
    outline: 2px solid var(--focus-outline);
    outline-offset: 2px;
    border-radius: 8px;
}

.grid-post-author-avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    flex-shrink: 0;
    border: 2px solid rgba(var(--brand-rgb), 0.35);
    overflow: hidden;
}

.grid-post-author-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.grid-post--thought {
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.grid-post--media {
    padding: 0;
}

/* Inset + rounded corners — same language as main feed `.post-image` */
.grid-post-media-wrap {
    position: relative;
    --grid-post-media-radius: 24px;
    width: calc(100% - 28px);
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    margin-top: 4px;
    margin-bottom: 4px;
    line-height: 0;
    border-radius: var(--grid-post-media-radius);
    overflow: hidden;
    background: transparent;
    box-sizing: border-box;
}

.grid-post-img {
    width: 100%;
    max-height: min(72vh, 520px);
    height: auto;
    object-fit: cover;
    display: block;
    position: static;
    inset: auto;
}

.grid-post-video {
    width: 100%;
    max-height: min(72vh, 520px);
    object-fit: cover;
}

.grid-post-media-wrap .grid-post-img,
.grid-post-media-wrap .grid-post-video {
    border-radius: inherit;
}

.grid-post-thought-body {
    padding: 16px 18px 12px;
}

.grid-post-thought-text {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    word-break: break-word;
}

.grid-post-thought-text .mention-link {
    color: var(--brand-orange);
}

.grid-post-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.grid-post--thought .grid-post-footer {
    padding-top: 8px;
    border-top: none;
    padding-left: 18px;
    padding-right: 18px;
    padding-bottom: 16px;
    color: var(--text-secondary);
}

.grid-post-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
}

.grid-post:hover {
    background: rgba(255, 255, 255, 0.03);
}

.grid-post:focus {
    outline: 2px solid var(--focus-outline);
    outline-offset: 2px;
    z-index: 1;
}

.grid-post-overlay {
    display: none;
}

.grid-post-thought-snippet {
    /* legacy class — no longer used for layout */
    display: none;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .grid-post,
    .tab-btn,
    .btn-edit-profile {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .profile-avatar-large,
    .grid-post {
        border: 2px solid var(--text-primary);
    }
    
    .tab-btn.active {
        border-bottom-width: 3px;
    }
}


/* Single post page (post.html) */
#post-page-screen .app-header {
    justify-content: space-between;
    gap: 12px;
}

.post-page-header-spacer {
    width: 40px;
    flex-shrink: 0;
}

#post-page-screen .post-page-feed {
    flex: 1;
    min-height: 0;
}

/* Profile header: leave (other profiles) + settings */
#profile-screen .app-header {
    justify-content: flex-start;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    min-height: 70px;
    box-sizing: border-box;
    padding: 12px 20px;
    overflow: visible;
}

@media (max-width: 480px) {
    #profile-screen .app-header {
        padding: max(12px, var(--safe-top)) 16px 12px;
    }
}

#profile-screen .settings-dropdown {
    flex-shrink: 0;
}

/* Search area between Leave and Settings — pill is half the width of this region, centered */
#profile-screen .app-header .profile-header-search-slot.feed-search-wrap {
    flex: 1;
    min-width: 0;
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0 6px;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 30;
    background: transparent;
    overflow: visible;
}

/* Shorter search *pill* (track height only — same text size as the feed) */
#profile-screen .app-header .profile-header-search-slot .feed-search {
    width: 50%;
    max-width: 50%;
    min-width: 0;
    box-sizing: border-box;
    padding: 2px 8px 2px 10px;
    gap: 5px;
    align-items: center;
}

#profile-screen .app-header .profile-header-search-slot .feed-search-icon {
    width: 14px;
    height: 14px;
}

#profile-screen .app-header .profile-header-search-slot .feed-search-input {
    padding: 1px 0;
}

#profile-screen .app-header .profile-header-search-slot .search-results {
    width: 50%;
    max-width: min(50%, calc(100vw - 48px));
    box-sizing: border-box;
    left: 50%;
    transform: translateX(-50%);
}

.profile-header-leading {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-shrink: 0;
    min-width: 0;
}

.profile-leave-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    white-space: nowrap;
    flex-shrink: 0;
    margin: 0;
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.profile-leave-btn:hover {
    border-color: var(--brand-red);
    color: var(--brand-red);
}

.profile-leave-btn:focus-visible {
    outline: 2px solid var(--brand-red);
    outline-offset: 2px;
}

.profile-leave-btn svg {
    flex-shrink: 0;
}

/* Settings Dropdown */
.settings-dropdown {
    position: relative;
}

.settings-btn {
    padding: 8px;
}

/* .dropdown-menu / .dropdown-item live in styles.css. The old rules here hid
   the menu with opacity/visibility and revealed it via a .show class, which the
   current markup no longer uses — it toggles the `hidden` attribute instead. */

.dropdown-item:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: -2px;
    background: var(--bg-hover);
}

/* Light theme: variables + feed/camera/nav — see styles.css */

/* Edit Profile Styles */
.header-title {
    font-size: 18px;
    font-weight: 900;
    color: var(--text-primary);
}

.text-btn {
    background: none;
    border: none;
    color: var(--brand-red);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    padding: 8px 12px;
    transition: all 0.2s ease;
}

.text-btn:hover {
    opacity: 0.8;
}

.text-btn:focus {
    outline: 2px solid var(--focus-outline);
    outline-offset: 2px;
    border-radius: 6px;
}

.edit-profile-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 20px 40px;
    /* Hide scrollbar but keep scrolling enabled. */
    scrollbar-width: none;
}

.edit-profile-content::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.edit-form {
    max-width: 600px;
    margin: 0 auto;
}

.edit-section {
    margin-bottom: 28px;
}

.edit-label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.edit-input,
.edit-textarea {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-dark);
    border: 2px solid var(--border-subtle);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s ease;
    font-family: inherit;
}

.edit-input:focus,
.edit-textarea:focus {
    outline: none;
    border-color: var(--focus-outline);
    background: var(--input-focus-bg);
}

.edit-textarea {
    resize: vertical;
    min-height: 100px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-prefix {
    position: absolute;
    left: 16px;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 600;
    pointer-events: none;
}

.input-wrapper .edit-input {
    padding-left: 32px;
}

.input-hint {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.textarea-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}

.char-counter {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Avatar Edit */
.avatar-edit-container {
    display: flex;
    align-items: center;
    gap: 20px;
}

.avatar-edit-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    position: relative;
}

.avatar-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
}

.btn-remove-avatar {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    padding: 4px 0;
    font-family: inherit;
}

.btn-remove-avatar:hover {
    color: var(--brand-red);
}

.btn-remove-avatar:focus {
    outline: 2px solid var(--focus-outline);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Toggle Switch */
.toggle-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--surface-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
}

.toggle-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toggle-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.toggle-description {
    font-size: 13px;
    color: var(--text-secondary);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.22);
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--brand-red);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 2px var(--focus-outline);
}

/* Full-bleed profile grid on phones / tablets (matches main feed) */
@media (max-width: 959px) {
    .grid-post-media-wrap {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
        --grid-post-media-radius: 0px;
    }

    .btn-edit-profile,
    .btn-follow-profile {
        max-width: none;
    }
}

/* Mobile Optimization */
@media (max-width: 480px) {
    .edit-profile-content {
        padding: 20px 16px;
    }
    
    .avatar-edit-container {
        flex-direction: column;
        text-align: center;
    }
}


button.profile-wallet {
    font: inherit;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    white-space: nowrap;
    background: var(--surface-btn);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-full);
    padding: 6px 12px;
    cursor: pointer;
    color: var(--text-secondary);
}

button.profile-wallet:hover {
    background: var(--surface-btn-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

button.profile-wallet:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

button.profile-wallet[hidden] {
    display: none;
}

/* Post detail (grid tap) */
.post-detail-modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: max(12px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
    box-sizing: border-box;
}

.post-detail-modal[hidden] {
    display: none !important;
}

.post-detail-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    border: none;
    cursor: pointer;
    padding: 0;
}

.post-detail-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: min(480px, 100%);
    max-height: min(92vh, 900px);
    display: flex;
    flex-direction: column;
    background: var(--bg-primary, #0a0a0a);
    border-radius: 16px;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.55);
    overflow: hidden;
}

.post-detail-top {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.post-detail-heading {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.post-detail-close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: -4px -6px -4px 0;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
}

.post-detail-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.post-detail-body {
    overflow-x: hidden;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.post-detail-body .post {
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

/* Followers / following list */
.follow-list-body {
    overflow-x: hidden;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    max-height: min(72vh, 640px);
    -webkit-overflow-scrolling: touch;
}

.follow-list-status {
    padding: 20px 16px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.follow-list-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle);
}

.follow-list-row-link {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.follow-list-row:last-child {
    border-bottom: none;
}

.follow-list-row-main {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.follow-list-name {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.follow-list-username {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.follow-list-avatar {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--brand-gradient-avatar);
}

.follow-list-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.btn-follow-list {
    flex-shrink: 0;
}

.btn-follow-list-placeholder {
    width: 76px;
    flex-shrink: 0;
}

.post-detail-comments {
    padding: 0 16px 16px;
    border-top: 1px solid var(--border-subtle);
    overflow-x: hidden;
    max-width: 100%;
    box-sizing: border-box;
}

.post-detail-comments .post-comments-list {
    overflow-x: hidden;
}

.post-detail-comments-title {
    margin: 14px 0 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sns-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: var(--surface-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
}

.sns-card .toggle-option {
    padding: 12px 0 0;
    background: none;
    border: 0;
    border-top: 1px solid var(--border-primary);
    border-radius: 0;
}

.sns-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.sns-current {
    color: var(--text-primary);
    text-decoration: none;
    word-break: break-all;
}

a.sns-current[href]:hover {
    text-decoration: underline;
}

.sns-link-form {
    display: flex;
    gap: 8px;
}

.sns-link-form .input-wrapper {
    flex: 1;
    min-width: 0;
}

.sns-link-form .input-wrapper .edit-input {
    padding-left: 16px;
    padding-right: 52px;
}

.input-suffix {
    position: absolute;
    right: 16px;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 600;
    pointer-events: none;
}

.sns-refresh-btn,
.sns-link-btn,
.sns-get-btn {
    flex-shrink: 0;
    padding: 9px 16px;
    border-radius: 999px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-primary);
    background: transparent;
    border: 1px solid var(--border-primary);
}

.sns-refresh-btn {
    padding: 6px 12px;
    font-size: 13px;
}

.sns-refresh-btn:hover,
.sns-link-btn:hover {
    border-color: var(--text-secondary);
}

.sns-get-btn {
    width: 100%;
    color: var(--bg-primary, #fff);
    background: var(--text-primary);
    border-color: var(--text-primary);
}

.sns-get-btn:hover {
    opacity: 0.88;
}

.sns-refresh-btn:disabled,
.sns-link-btn:disabled,
.sns-get-btn:disabled {
    opacity: 0.5;
    cursor: default;
}
