/* ── profile.css ── */
/* ── Public Profile Header ── */
.public-profile {
    padding: 5px 5px;
    margin: 10px 9px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    position: sticky;
    top: 10px;
    z-index: 100;
    /* Dense tint, no blur: sticky pill re-filtered on every profile scroll
       frame (same swap the sidebar got). */
    background: rgba(15, 15, 15, 0.9);
    border: 1px solid var(--border);
    border-radius: 14px;
    flex-shrink: 0;
    container-type: inline-size;
}

/* ── Profile inline expansion ── */

/* The pill is embedded in the dashboard panel now (#panelPrivate) — when a
   section opens or an app activates, the panel itself is hidden/muted, so no
   per-state hide rule is needed for the pill. */

/* Mobile: name + username centered in toolbar between back and edit buttons */
.profile-open-header {
    position: absolute;
    top: 10px;
    left: 90px;
    right: 90px;
    height: 40px;
    z-index: 101;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.desktop.profile-open .profile-open-header {
    opacity: 1;
}

/* Desktop: same centered layout as mobile */

.profile-open-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.profile-open-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.profile-open-username {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: center;
}

/* Stat row: hidden on mobile (stats shown flanking avatar), visible on desktop */
.profile-open-stat-row {
    display: none;
    flex-shrink: 0;
}

/* Big clickable stat cards — hidden by default, shown on desktop or in overlay */
.profile-open-stat-card {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
    min-width: 80px;
    font-family: inherit;
    color: inherit;
}

.profile-open-stat-card:hover {
    background: rgba(255, 255, 255, 0.1);
}

.profile-open-stat-card-num {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
}

.profile-open-stat-card-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

[data-theme="light"] .profile-open-stat-card {
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .profile-open-stat-card:hover {
    background: rgba(0, 0, 0, 0.08);
}

/* Desktop: no stat cards in header, body stats always visible (same as mobile) */

.profile-open-username:empty {
    display: none;
}

/* Universal back/close button — mobile-only counterpart to the desktop #homeCloseHint.
   Visible whenever any overlay is open (profile, PageStack layer, sidebar profile).
   Hidden on desktop via @media rule in app.css where the X on the right replaces it.
   Position + entrance animation live here; visual style is shared with .app-toolbar-back.
   z-index sits ABOVE the PageStack overlay (z-index: 200) so it stays tappable even
   when an "all apps" overlay (or edit-profile, or any other layer) is pushed. */
.back-btn {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 250;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.75);
    transition:
        opacity 0.25s ease,
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        background 0.15s;
}

/* back-btn lives BEFORE #desktop in the DOM (so its z-index isn't trapped in
   #desktop's stacking context), which means the general-sibling combinator
   `~` can't reach it from `.desktop`. :has() steps around that — show the
   back-btn whenever any section is open inside .desktop. */
body:has(.desktop.section-open) .back-btn,
body.page-stack-open .back-btn,
body.sidebar-profile-open .back-btn {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.public-profile-stats {
    overflow: hidden;
    max-width: 240px;
}

/* Hide the fixed header name — it's now in scrollable content */
.desktop.profile-open .profile-open-header {
    display: none;
}

/* Desktop tabs — instant switch */
.desktop-tabs {
    transition: none;
}

.desktop.profile-open .desktop-tabs {
    opacity: 0;
    pointer-events: none;
}

/* Desktop panels — instant switch */
.desktop-panels {
    transition: none;
}

.desktop.profile-open .desktop-panels {
    opacity: 0;
    pointer-events: none;
}

/* Profile uses the shared .section-panel + .section-right-gutter chrome
   (see app.css). Layout/positioning + global-X coordination live entirely
   on the generic .desktop.section-open rules now. */

/* Scrollable profile top: avatar + name + stats */
.profile-content-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 0 8px;
}

/* Wrapper exists so the edit-badge button can anchor to the avatar's top-right
   corner via position:absolute. Inline-block keeps it sized to the avatar
   (instead of stretching across the centered .profile-content-top column). */
.profile-content-avatar-wrap {
    position: relative;
    display: inline-block;
    margin-bottom: 14px;
}

.profile-content-avatar {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    transform: scale(1);
    transform-origin: center;
    transition: transform 0.22s ease;
}

img.profile-content-avatar {
    cursor: zoom-in;
}

@media (hover: hover) {
    .profile-content-avatar:hover {
        transform: scale(1.1);
    }
}

.profile-content-avatar-init {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 600;
    color: var(--text);
    background: var(--bg-tertiary);
}

.profile-content-name {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}

.profile-content-username {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 8px;
}

[data-theme="light"] .profile-content-username {
    color: rgba(0, 0, 0, 0.8);
}

/* Minimal state for a user blocked by the current viewer. No normal profile
   section is rendered alongside this container: identity, notice, Unblock. */
.profile-blocked-state {
    width: min(100%, 420px);
    min-height: 520px;
    margin: 0 auto;
    padding: 42px 24px 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

.profile-blocked-avatar {
    display: block;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.profile-blocked-avatar-init {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    font-size: 36px;
    font-weight: 600;
}

.profile-blocked-name {
    margin-top: 16px;
    color: var(--text);
    font-size: 20px;
    font-weight: 650;
    line-height: 1.25;
    text-align: center;
}

.profile-blocked-notice {
    width: min(100%, 320px);
    margin-top: 32px;
    padding: 13px 18px;
    border: 1px solid rgba(239, 68, 68, 0.18);
    border-radius: 12px;
    background: rgba(239, 68, 68, 0.08);
    color: var(--red, #ef4444);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    box-sizing: border-box;
}

.profile-blocked-unblock {
    min-width: 180px;
    margin-top: 14px;
    padding: 12px 28px;
    border: none;
    border-radius: 24px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
}

.profile-blocked-unblock:hover {
    transform: translateY(-1px);
}

.profile-blocked-unblock:disabled {
    opacity: 0.55;
    cursor: default;
    transform: none;
}

.profile-content-stats {
    display: flex;
    gap: 20px;
    margin-top: 16px;
}

/* Stats in content — shown on all screen sizes (pill stats are hidden when profile opens) */
.profile-inline-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

/* Avatar zone row: stats flank the avatar gap (centered layout) */
.profile-avatar-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    height: 117px;
    gap: 30px;
    margin-bottom: 38px;
}

.profile-avatar-gap {
    width: 117px;
    height: 117px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-stat {
    text-align: center;
    cursor: pointer;
    padding: 26px 14px;
    border-radius: 8px;
    transition: background 0.15s;
}

.profile-avatar-row .profile-stat {
    flex: 1 1 0;
}

.profile-stat:hover {
    background: rgba(255, 255, 255, 0.06);
}

.profile-stat-num {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.profile-stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 2px;
}

/* Follow button / email shown below pill */
.profile-inline-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* Profile CTA — pill-shaped, sized as a primary action. Both the Follow and
   Following states look like real buttons; the difference is filled vs
   outlined, not active vs disabled. min-width keeps the row stable when the
   label flips between "Follow" and "Following". */
.profile-inline-header .follow-btn,
.profile-inline-header .profile-message-btn {
    padding: 11px 32px;
    font-size: 14px;
    font-weight: 600;
    border: 1.5px solid transparent;
    border-radius: 24px;
    min-width: 160px;
    line-height: 1.2;
}

/* "Following" state inherits the standard gray .follow-btn.following look from
   app.css — no override here, no border. */

/* Combined profile action panel: stats on the left, vertical divider, follow
   CTA on the right. Single centered row on desktop. On narrow screens the
   @media rule below stacks the two halves into rows and hides the divider. */
.profile-action-panel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: min(100%, 344px);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--floating-panel-bg);
    -webkit-backdrop-filter: blur(22px) saturate(145%);
    backdrop-filter: blur(22px) saturate(145%);
    box-shadow: 0 4px 24px var(--shadow-color);
    margin: 26px auto 24px;
    transition: width 0.25s ease;
}

.profile-action-panel.has-actions {
    width: min(100%, 500px);
}

.profile-action-stats {
    position: relative;
    display: flex;
    gap: 0;
    align-items: center;
    width: 100%;
    min-width: 0;
}

.profile-action-panel.has-actions .profile-action-stats {
    flex: 1 1 auto;
}

.profile-action-stats::after {
    content: '';
    position: absolute;
    top: 22%;
    bottom: 22%;
    left: 50%;
    width: 1px;
    pointer-events: none;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.28) 25%, rgba(255, 255, 255, 0.28) 75%, transparent);
}

.profile-action-stats .profile-stat {
    flex: 1 1 50%;
    padding: 18px 14px;
    border-radius: 0;
}

.profile-action-stats .profile-stat:hover {
    background: rgba(255, 255, 255, 0.075);
}

.profile-action-panel .profile-stat-label,
.profile-action-panel .profile-action-icon-label {
    color: rgba(255, 255, 255, 0.62);
}

.profile-action-panel .profile-stat-label {
    font-size: 11px;
}

[data-theme="light"] .profile-action-panel {
    border-color: rgba(255, 255, 255, 0.72);
    background: linear-gradient(135deg, rgb(254 243 244 / 35%), rgb(225 232 238 / 42%) 48%, rgb(229 243 234 / 51%)), rgb(224 242 255 / 8%);
    box-shadow:
        inset 0 0.5px 0 rgba(255, 255, 255, 0.55),
        inset 0 -1px 0 rgba(0, 0, 0, 0.035),
        0 12px 32px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .profile-action-stats::after {
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.15) 25%, rgba(0, 0, 0, 0.15) 75%, transparent);
}

[data-theme="light"] .profile-action-stats .profile-stat:hover {
    background: rgba(255, 255, 255, 0.36);
}

[data-theme="light"] .profile-action-panel .profile-stat-label,
[data-theme="light"] .profile-action-panel .profile-action-icon-label {
    color: rgba(0, 0, 0, 0.58);
}

.profile-action-divider {
    width: 1px;
    height: 56%;
    min-height: 42px;
    flex-shrink: 0;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.28) 25%, rgba(255, 255, 255, 0.28) 75%, transparent);
}

[data-theme="light"] .profile-action-divider {
    background: rgba(0, 0, 0, 0.14);
}

.profile-action-buttons,
.profile-win-actions {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.profile-action-buttons {
    align-self: stretch;
    flex: 0 0 132px;
    gap: 0;
    transition: flex-basis 0.25s ease;
}

.profile-action-buttons .follow-btn,
.profile-action-buttons .profile-message-btn,
.profile-win-actions .follow-btn,
.profile-win-actions .profile-message-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.profile-message-btn {
    flex-shrink: 0;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.profile-message-btn:hover {
    border-color: var(--border-hover);
    background: var(--bg-secondary);
}

/* Apply the same enlarged pill styling to the follow-btn here as in
   .profile-inline-header — they're the same primary CTA, just relocated. */
.profile-action-panel .follow-btn:not(.profile-action-icon),
.profile-action-panel .profile-message-btn:not(.profile-action-icon) {
    padding: 8px 32px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 24px;
    min-width: 160px;
    line-height: 1.2;
}

.profile-action-panel .follow-btn {
    border: none;
}

.profile-action-panel .profile-action-icon {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 0 1 66px;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    overflow: hidden;
    transition: flex-basis 0.25s ease, background 0.15s, color 0.15s;
}

.profile-action-panel .profile-action-icon + .profile-action-icon {
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.profile-action-panel .profile-action-icon:hover {
    background: rgba(255, 255, 255, 0.075);
}

.profile-action-panel .profile-action-icon svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.profile-action-icon-label {
    display: block;
    max-width: 0;
    max-height: 0;
    margin-top: 0;
    overflow: hidden;
    opacity: 0;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.1;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    transform: translateY(4px);
    transition: max-width 0.25s ease, max-height 0.25s ease, margin-top 0.25s ease, opacity 0.18s ease, transform 0.25s ease;
}

@media (hover: hover) {
    .profile-action-panel .profile-action-icon:hover {
        flex-basis: 130px;
    }

    .profile-action-buttons:has(.profile-action-icon:hover) {
        flex-basis: 196px;
    }

    .profile-action-panel .profile-action-icon:hover svg {
        transform: translateY(-2px) scale(0.94);
    }

    .profile-action-panel .profile-action-icon:hover .profile-action-icon-label {
        max-width: 130px;
        max-height: 13px;
        margin-top: 5px;
        opacity: 1;
        transform: translateY(0);
    }
}

[data-theme="light"] .profile-action-panel .profile-action-icon + .profile-action-icon {
    border-left-color: rgba(0, 0, 0, 0.09);
}

[data-theme="light"] .profile-action-panel .profile-action-icon:hover {
    background: rgba(255, 255, 255, 0.36);
}

.profile-action-panel .profile-action-icon.following:hover {
    background: var(--accent);
    color: #fff;
}

.profile-action-panel .profile-action-icon.following:hover .profile-action-icon-label {
    color: rgba(255, 255, 255, 0.86);
}

@media (max-width: 799px) {
    .profile-action-panel.has-actions {
        width: min(100%, 410px);
    }
    .profile-action-buttons {
        flex-basis: 124px;
    }
}

/* "Edit profile" badge — circular icon button anchored at the top-right of the avatar.
   Border matches page background so the badge reads as a separate chip on top of the photo. */
.profile-edit-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid var(--bg-primary);
    background: var(--text);
    color: var(--bg-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.profile-edit-btn:hover {
    transform: scale(1.08);
}

.profile-edit-btn:active {
    transform: scale(0.95);
}

/* ── Profile Menu (dropdown) ── */
.profile-settings-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 12px;
    align-self: stretch;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    font-size: 13px;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}

.profile-settings-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.profile-settings-label {
    display: inline;
}

@container (max-width: 450px) {
    .profile-settings-label {
        display: none;
    }

    .profile-settings-btn {
        padding: 6px;
    }
}

.profile-menu-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    max-width: 40px;
    transition:
        background 0.15s,
        color 0.15s,
        opacity 0.2s ease,
        max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        padding 0.3s ease;
}

.profile-menu-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.profile-dropdown {
    display: none;
    min-width: 160px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-hover);
    border-radius: 12px;
    padding: 4px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    z-index: 2000;
}

.profile-dropdown.open {
    display: block;
}

.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    border-radius: 8px;
    transition:
        background 0.15s,
        color 0.15s;
}

.profile-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.profile-dropdown-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
}

.public-profile-identity {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.public-profile-identity:hover {
    background: rgba(255, 255, 255, 0.06);
}

.public-profile-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    object-fit: cover;
    flex-shrink: 0;
}

.public-profile-info {
    flex: 1;
    min-width: 0;
    transition: opacity 0.15s ease;
}

.public-profile-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.public-profile-username {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.public-profile-stats {
    display: flex;
    gap: 16px;
    flex-shrink: 0;
    margin-left: auto;
}

.public-profile-stat {
    text-align: center;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.15s;
}

.public-profile-stat:hover {
    background: rgba(255, 255, 255, 0.06);
}

.public-profile-stat-num {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.public-profile-stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 6px;
}

.public-profile-social {
    font-size: 12px;
    color: var(--text);
    margin-top: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.public-profile-social span {
    cursor: pointer;
    transition: color 0.15s;
}

.public-profile-social span:hover {
    color: var(--text);
}

.public-profile-social b {
    color: var(--text);
    font-weight: 600;
}

.public-profile-plan {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex-shrink: 0;
    margin-left: auto;
    padding: 0 14px;
    align-self: stretch;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.public-profile-plan:hover {
    background: rgba(255, 255, 255, 0.06);
}

.public-profile-tokens {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    padding: 0px 0px 5px 0px;
}

.public-profile-plan-name {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ── Profile Overlay (other user profiles) ── */
.profile-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: var(--chat-w, 600px);
    z-index: 200;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media (max-width: 799px) {
    .profile-overlay {
        left: 0;
    }
}

.profile-overlay-close {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(30, 30, 30, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background 0.15s,
        transform 0.15s;
    padding: 0;
}

.profile-overlay-close:hover {
    background: rgba(50, 50, 50, 0.7);
    transform: scale(1.05);
}

.profile-overlay-close:active {
    transform: scale(0.95);
}

.profile-overlay-content {
    overflow-y: auto;
    flex: 1;
    padding-top: 12px;
}

.profile-overlay-avatar-center {
    display: flex;
    justify-content: center;
}

.profile-overlay-big-avatar {
    width: 117px !important;
    height: 117px !important;
    border-radius: 50%;
    object-fit: cover;
}

.profile-overlay-avatar-init {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    font-size: 42px;
    font-weight: 600;
    color: var(--text);
}

.profile-overlay-name-block {
    text-align: center;
    margin-bottom: 16px;
}

.profile-overlay-name-block .profile-overlay-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.profile-overlay-name-block .profile-overlay-username {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.profile-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 20px 20px 10px;
}

.profile-apps-section-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: max-content;
    max-width: calc(100% - 40px);
    margin: 4px auto 12px;
    padding: 4px 8px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.profile-apps-section {
    width: min(calc(100% - 32px), 434px);
    margin: 24px auto;
    padding: 6px 0 10px;
    overflow: hidden;
    box-sizing: border-box;
    transition: margin 0.32s ease, padding 0.32s ease;
}

@media (min-width: 800px) {
    .profile-apps-section {
        width: min(calc(100% - 32px), 506px);
    }
}

@media (min-width: 900px) {
    .profile-apps-section {
        width: min(calc(100% - 32px), 674px);
    }
}

.profile-apps-section.collapsed {
    margin-top: 8px;
    margin-bottom: 8px;
    padding-bottom: 0;
}

.profile-friends-section > .profile-section-title {
    margin: 4px auto 12px;
    text-align: center;
}

.profile-friends-section {
    width: min(calc(100% - 32px), 500px);
}

@media (min-width: 800px) {
    .profile-friends-section {
        width: min(calc(100% - 32px), 620px);
    }
}

@media (min-width: 900px) {
    .profile-friends-section {
        width: min(calc(100% - 32px), 760px);
    }
}

.profile-friends-section-content {
    padding-bottom: 14px;
}

.profile-friends-section .profile-friends-grid {
    padding-right: 34px;
}

.profile-apps-section-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .profile-apps-section-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

.profile-apps-section-chevron {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.profile-apps-section.collapsed .profile-apps-section-chevron {
    transform: rotate(-90deg);
}

.profile-apps-section > .profile-apps-block,
.profile-friends-section-content {
    overflow: hidden;
    opacity: 1;
    transform: translateY(0);
    transition: height 0.32s ease, opacity 0.2s ease, transform 0.32s ease;
}

.profile-apps-section.collapsed > .profile-apps-block,
.profile-friends-section.collapsed .profile-friends-section-content {
    height: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
}

.profile-friends-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 28px;
    padding: 12px 0px 0px 34px;
}

.profile-friend-bubble {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    width: 96px;
}

.profile-friend-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.profile-friend-avatar.pf-init {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
}

.profile-friend-avatar.profile-friend-invite-avatar {
    background: #fff;
    color: #111;
    font-size: 24px;
}

[data-theme="light"] .profile-friend-avatar.profile-friend-invite-avatar {
    background: var(--accent);
    color: #fff;
}

.profile-friend-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dim);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, var(--text-dim) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    padding: 3px 2px 0;
    line-height: 1.2;
}

[data-theme="light"] .profile-friend-name {
    font-weight: 500;
    background: linear-gradient(0deg, rgba(0, 0, 0) 0%, rgba(0, 0, 0, 0.35) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

@keyframes shimmer {
    0% {
        background-position: -200px 0;
    }

    100% {
        background-position: 200px 0;
    }
}

.shimmer {
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.04) 25%,
            rgba(255, 255, 255, 0.08) 50%,
            rgba(255, 255, 255, 0.04) 75%);
    background-size: 200px 100%;
    animation: shimmer 1.5s infinite;
}

.shimmer-line {
    border-radius: 4px;
}

.profile-win-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.profile-win-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    object-fit: cover;
    flex-shrink: 0;
}

.profile-win-info {
    flex: 1;
    min-width: 0;
}

.profile-win-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.profile-win-username {
    font-size: 12px;
    color: var(--text-muted);
}

.profile-win-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.profile-win-stat {
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}

.profile-win-stat:hover {
    background: rgba(255, 255, 255, 0.06);
}

.profile-win-stat-num {
    font-weight: 600;
    color: var(--text);
}

.profile-win-stat-label {
    color: var(--text-muted);
    font-size: 13px;
}

.profile-win-apps {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
}


/* ── Username Section ── */
/* ── Edit Profile Screen ── */

.edit-profile-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 24px;
}

.edit-profile-avatar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    margin-bottom: 28px;
}

.edit-profile-avatar-ring {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    cursor: pointer;
    overflow: hidden;
    flex-shrink: 0;
}

.edit-profile-avatar-ring:hover .edit-profile-avatar-overlay {
    opacity: 1;
}

.edit-profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.edit-profile-avatar-empty {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 600;
    color: var(--text-secondary);
}

.edit-profile-avatar-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    color: #fff;
}

.edit-profile-avatar-hint {
    font-size: 12px;
    color: var(--text-muted);
    min-height: 16px;
}

.edit-profile-avatar-hint.saving {
    color: var(--text-secondary);
}

.edit-profile-avatar-hint.saved {
    color: #4ade80;
}

.edit-profile-avatar-hint.error {
    color: #f87171;
}

/* Edit profile form is rendered inside .section-panel-body, but the form
   itself reads better as a narrow centered column rather than spanning the
   full 800px panel column. */
#editProfileBody {
    max-width: 480px;
    margin: 0 auto;
}

.edit-profile-section {
    margin-bottom: 22px;
}

.edit-profile-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.edit-profile-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.edit-profile-input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 15px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
}

.edit-profile-input:focus {
    border-color: var(--accent);
}

.edit-profile-save-btn {
    padding: 14px 22px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s;
}

.edit-profile-save-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.edit-profile-field-status {
    font-size: 12px;
    min-height: 16px;
    margin-top: 4px;
    color: var(--text-muted);
}

.edit-profile-field-status.saved {
    color: #4ade80;
}

.edit-profile-field-status.invalid {
    color: #f87171;
}

/* username-section inside edit screen — no extra border boxing needed */
.edit-profile-section .username-section {
    margin-bottom: 0;
    background: transparent;
    border: none;
    padding: 0;
}

.username-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 20px;
    transition: border-color 0.2s;
}

.username-section:focus-within {
    border-color: var(--border-hover);
}

.username-section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.username-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.username-display-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
}

.username-display-empty {
    font-size: 14px;
    color: var(--text-muted);
    font-style: italic;
    cursor: text;
    transition: color 0.15s;
}

.username-display-empty:hover {
    color: var(--text-dim);
}

.username-claim-btn,
.username-change-btn {
    /* Match .edit-profile-save-btn sizing so the two buttons read as a pair. */
    padding: 14px 22px;
    border-radius: 12px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
    white-space: nowrap;
}

.username-claim-btn:hover,
.username-change-btn:hover {
    background: var(--accent);
    color: #fff;
}

.username-locked-hint {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.username-edit-form {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: usernameSlideDown 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes usernameSlideDown {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.username-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.username-prefix {
    font-size: 16px;
    color: var(--text-dim);
    font-weight: 500;
    flex-shrink: 0;
    user-select: none;
}

.username-input {
    flex: 1;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    min-width: 0;
}

.username-input:focus {
    border-color: var(--accent);
}

.username-input.error {
    border-color: var(--red);
    animation: usernameShake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.username-input.success {
    border-color: var(--green);
}

@keyframes usernameShake {

    0%,
    100% {
        transform: translateX(0);
    }

    15% {
        transform: translateX(-6px);
    }

    35% {
        transform: translateX(6px);
    }

    55% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }

    90% {
        transform: translateX(-2px);
    }
}

.username-status {
    font-size: 12px;
    min-height: 16px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s;
    padding-left: 2px;
}

.username-status.available {
    color: var(--green);
}

.username-status.taken {
    color: var(--red);
}

.username-status.checking {
    color: var(--text-muted);
}

.username-status.hint {
    color: var(--text-muted);
}

.username-status.invalid {
    color: var(--orange);
}

.username-actions {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.username-save-btn {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: #000;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition:
        filter 0.15s,
        opacity 0.15s,
        background 0.2s;
}

.username-save-btn:hover:not(:disabled) {
    filter: brightness(1.12);
}

.username-save-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.username-save-btn.saving {
    background: var(--bg-secondary);
    color: var(--text-muted);
    border: 1px solid var(--border);
    cursor: wait;
    font-weight: 400;
}

.username-save-btn.saved {
    background: var(--green);
    color: #000;
}

.username-cancel-btn {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.username-cancel-btn:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

/* Light theme — only for .back-btn (it sits over the dashboard background, which IS
   theme-colored). .app-toolbar-back is excluded: it floats over app content where
   the dashboard theme doesn't apply, so it stays dark like .app-toolbar-action. */
[data-theme="light"] .back-btn {
    background: rgba(255, 255, 255, 0.85);
    border-color: var(--border);
    color: var(--text-muted);
}
/* Wrap in (hover: hover) so iOS/touch devices don't get a sticky-hover after tap. */
@media (hover: hover) {
    [data-theme="light"] .back-btn:hover {
        background: #fff;
        color: var(--text);
    }
}

/* ── Profile actions (three-dot ⋯).
   Mobile (<900px): no close X on the right side (mobile uses .back-btn at top-left),
   so the actions button takes the top-right corner itself — right:24px matches the
   spot the close X occupies on desktop.
   Desktop (≥900px): the close X lives in .section-right-gutter-x at viewport right:24px,
   so we shift to right:70px to sit 46px to its left.
   Shown for any authenticated open profile: own profile gets Delete, another
   profile gets Report. Anonymous visitors are suppressed globally in app.css.
   Hidden as soon as a chat overlay or PageStack covers the profile. */
.profile-actions-btn {
    display: none;
    position: fixed;
    /* Mobile: mirror .back-btn (top:10px, left:10px) on the right edge —
       same 40x40 size, same border + glassy backdrop. Desktop overrides
       right offset below. */
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(30, 30, 30, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    align-items: center;
    justify-content: center;
    z-index: 1200;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s, color 0.2s;
}
[data-theme="light"] .profile-actions-btn {
    background: rgba(255, 255, 255, 0.85);
    border-color: var(--border);
    color: var(--text-muted);
}
.desktop.profile-open ~ .profile-actions-btn {
    display: flex;
}
.profile-actions-btn[hidden] {
    display: none !important;
}
body.chat-open .profile-actions-btn,
body.page-stack-open .profile-actions-btn {
    display: none !important;
}
/* Match .back-btn hover (only on devices that actually hover) and active states. */
@media (hover: hover) {
    .profile-actions-btn:hover {
        background: rgba(50, 50, 50, 0.7);
        transform: scale(1.05);
    }
    [data-theme="light"] .profile-actions-btn:hover {
        background: #fff;
        color: var(--text);
    }
}
.profile-actions-btn:active,
.profile-actions-btn.active {
    transform: scale(0.95);
}

/* Dropdown anchors at the button's right edge on both layouts so the menu
   appears directly under the trigger. */
.profile-actions-dropdown {
    display: none;
    position: fixed;
    top: 72px;
    right: 24px;
    min-width: 180px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 4px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
    z-index: 1201;
}

/* Desktop ≥900px: button sits next to the close X in .section-right-gutter-x —
   smaller, flatter look matching the gutter X (no glassy backdrop or shadow).
   Dropdown follows so it stays anchored under it. */
@media (min-width: 900px) {
    .profile-actions-btn {
        top: 20px;
        right: 70px;
        width: 36px;
        height: 36px;
        border: none;
        background: rgba(255, 255, 255, 0.1);
        color: rgba(255, 255, 255, 0.6);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        box-shadow: none;
    }
    [data-theme="light"] .profile-actions-btn {
        background: rgba(0, 0, 0, 0.06);
        border-color: transparent;
        color: rgba(0, 0, 0, 0.35);
    }
    .profile-actions-btn:hover,
    .profile-actions-btn.active {
        transform: scale(1.1);
        background: rgba(255, 255, 255, 0.18);
        color: #fff;
    }
    [data-theme="light"] .profile-actions-btn:hover,
    [data-theme="light"] .profile-actions-btn.active {
        background: rgba(0, 0, 0, 0.1);
        color: rgba(0, 0, 0, 0.6);
    }
    .profile-actions-dropdown {
        right: 70px;
    }
}
.profile-actions-dropdown.open {
    display: block;
}
.profile-actions-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
    text-align: left;
}
.profile-actions-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}
.profile-actions-item.danger {
    color: var(--red, #ef4444);
}
.profile-actions-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}
.profile-actions-item[hidden] {
    display: none;
}

/* Report user modal styles live in /static/report-modal.css and are lazy-
   loaded by app.js's loadModule('report-modal') the first time the modal
   opens. The HTML in app.html stays inert (display:none default) until then. */

/* Profile ordering is available only on grids owned by the signed-in user. */
[data-profile-apps-owner] > .desktop-icon {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.profile-apps-dragging > .desktop-icon { cursor: grabbing; }
.profile-app-drag-source { opacity: 0.25; }
.profile-apps-saving { opacity: 0.65; cursor: progress; }
.profile-apps-saving > .desktop-icon { cursor: progress; }

.desktop-icon.profile-app-drag-ghost {
    position: fixed;
    z-index: 10050;
    margin: 0;
    pointer-events: none;
    transform: scale(1.06);
    transition: none;
    opacity: 0.95;
    filter: drop-shadow(0 10px 20px rgb(0 0 0 / 25%));
}

@media (max-width: 899px) {
    .back-btn,
    .profile-actions-btn {
        top: calc(10px + env(safe-area-inset-top, 0px));
    }
    .profile-actions-dropdown {
        top: calc(72px + env(safe-area-inset-top, 0px));
    }
}
