/* Profile Page Styles */

.profile-app {
    display: flex;
    flex-direction: column;
}

/* Desktop: fixed viewport, inner scroll */
@media (min-width: 769px) {
    body:has(.profile-app) {
        overflow: hidden;
    }
    .profile-app {
        height: 100vh;
        overflow: hidden;
    }
    .profile-scroll-container {
        flex: 1;
        overflow-y: auto;
    }
}

/* Mobile: body scrolls naturally (Safari bar minimization, no double scrollbar) */
@media (max-width: 768px) {
    body:has(.profile-app):not(.scroll-locked) {
        overflow: visible !important;
        height: auto !important;
    }
    .profile-app {
        height: auto;
        overflow: visible;
    }
    .profile-scroll-container {
        overflow-y: visible;
    }
}

.profile-app .header {
    max-width: none;
}

.profile-app .header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: none;
    /* Matches .profile-main padding so logo + right-side user menu align with
       the outermost cards/content in the grid below. */
    padding: 0 clamp(16px, 1.25vw, 32px);
    height: 100%;
    position: relative;
}

.profile-app .header-left {
    z-index: 2;
    /* Explicit override — base .header-left in style.css has padding-left: 2rem
       which would otherwise push the logo past our aligned card edge. */
    padding-left: 0;
}

.profile-app .header-right {
    z-index: 2;
}

.profile-app .header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}

.profile-main {
    flex: 1;
    padding: 2rem clamp(16px, 1.25vw, 32px);
    margin: 0 auto;
    width: 100%;
    /* max-width removed so the masonry grid can fill wide monitors. Profile
       header + tabs keep their centered feel via their own max-widths below. */
}

/* Keep the profile header card and tab bar visually contained (same look as
   before), but let .profile-section (which holds the grid) stretch wider. */
.profile-card {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

/* .profile-tabs is fit-content width (see line ~362). To keep its left edge
   aligned with the centered profile-card above, push it right by the same
   amount the card gets centered by. For viewports ≤ 1200px the max() clamps
   to 0 so tabs stay flush left like before. */
.profile-tabs {
    margin-left: max(0px, calc(50% - 600px));
}

.profile-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
    position: relative;
}

@media (min-width: 769px) {
    .profile-card > .profile-header .profile-actions {
        position: absolute;
        top: 2rem;
        right: 2rem;
        margin-top: 0;
    }
}

.profile-header {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
}

.profile-avatar-container {
    position: relative;
    flex-shrink: 0;
}

.profile-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    color: var(--text-secondary);
}

.avatar-edit-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: all 0.15s ease;
}

.avatar-edit-btn:hover {
    background: rgba(0, 0, 0, 0.85);
    transform: scale(1.05);
}

.avatar-edit-btn svg {
    width: 14px;
    height: 14px;
}

/* Avatar menu dropdown */
.avatar-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
    min-width: 160px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

.avatar-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 0.8125rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.15s ease;
    white-space: nowrap;
}

.avatar-menu-item:hover {
    background: var(--bg-tertiary);
}

.avatar-menu-item.danger {
    color: var(--error);
}

.avatar-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.avatar-menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Avatar loading spinner */
.avatar-loading {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: avatar-spin 0.8s linear infinite;
}

@keyframes avatar-spin {
    to { transform: rotate(360deg); }
}

/* Avatar menu backdrop for mobile */
.avatar-menu-backdrop {
    display: none;
}

@media (max-width: 640px) {
    .avatar-menu-backdrop {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
}

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

.profile-name {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.25rem 0;
    letter-spacing: -0.02em;
}

.profile-username {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0 0 0.75rem 0;
}

.profile-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.profile-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.profile-actions-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
}

.profile-follow-pills {
    display: flex;
    gap: 0.5rem;
}

.follow-pill {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-full, 20px);
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.follow-pill:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
    color: var(--text);
}

.follow-pill-static {
    cursor: default;
}

.follow-pill-static:hover {
    background: var(--bg-secondary);
    border-color: var(--border);
    color: var(--text-secondary);
}

.follow-pill-count {
    font-weight: 600;
    color: var(--text);
}

.profile-edit-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

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

.profile-stats {
    display: flex;
    gap: 2rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

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

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.profile-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 1.5rem;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius-lg);
    width: fit-content;
}

.profile-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.profile-tab:hover {
    color: var(--text);
    background: var(--bg-active);
}

.profile-tab.active {
    background: var(--bg-active);
    color: var(--text);
    font-weight: 600;
}

[data-theme="dark"] .profile-tab:hover {
    background: var(--bg-hover);
}

[data-theme="dark"] .profile-tab.active {
    background: var(--bg-hover);
}

.profile-tab svg {
    width: 16px;
    height: 16px;
}

.profile-section {
    display: none;
}

.profile-section.active {
    display: block;
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    /* KEEP — see the note on discover.css .discover-grid. Removing this
       regressed discover scroll (Layerize ~12.6% -> ~55%): the promoted layer
       makes nested-container scrolling composite on the GPU instead of
       re-layerizing revealed content each frame. */
    will-change: transform;
}

.profile-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.profile-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.profile-empty h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.profile-empty p {
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.settings-form {
    max-width: 480px;
}

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

.settings-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.settings-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: all var(--transition);
}

.settings-input:hover {
    border-color: var(--border-strong);
}

.settings-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-alpha);
}

.settings-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

.settings-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-hover) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-md);
}

.skeleton-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
}

.skeleton-text {
    height: 1.25rem;
    margin-bottom: 0.5rem;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.collection-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    will-change: scroll-position;
}

.collection-option {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 10px 14px 10px 11px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    text-align: left;
    flex-shrink: 0;
    contain: layout style;
}

.collection-option:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.collection-option-preview {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.collection-option-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-placeholder {
    color: var(--text-muted);
    font-size: 1.25rem;
}

.collection-option-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.collection-option-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.collection-option-studio {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.collection-loading,
.collection-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.collection-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    flex: 1;
    justify-content: center;
}

.profile-bio {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin: 0.5rem 0 0.75rem 0;
    line-height: 1.5;
    max-width: 400px;
    word-wrap: break-word;
}

.card-likes {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text);
}

.card-likes svg {
    color: #ff6b6b;
}

.card-user-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.card-user-link:hover {
    opacity: 0.8;
}

.detail-user-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 12px;
}

.detail-user-link:hover {
    opacity: 0.8;
}

.toast-undo {
    background: transparent;
    border: 1px solid currentColor;
    color: inherit;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    margin-left: 12px;
}

.toast-undo:hover {
    background: rgba(255, 255, 255, 0.1);
}

.delete-overlay-btn {
    background: rgba(239, 68, 68, 0.9) !important;
    color: white !important;
}

.delete-overlay-btn:hover {
    background: rgba(220, 38, 38, 1) !important;
}

.detail-cta {
    display: flex;
    gap: 12px;
    margin-top: auto;
}

.detail-cta .action-btn {
    flex: 0 0 auto;
}

.detail-cta .btn-primary {
    flex: 1;
}

.user-menu {
    position: relative;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.625rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition);
}

.user-btn:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    overflow: hidden;
}

.user-avatar svg {
    width: 100%;
    height: 100%;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-name {
    font-size: 0.8125rem;
    font-weight: 500;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chevron {
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.user-menu.open .user-chevron {
    transform: rotate(180deg);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem + 2.5px);
    right: 0;
    min-width: 180px;
    /* Matches the navigation bar's frosted glass recipe (theme-adaptive). */
    background: var(--header-glass-bg);
    backdrop-filter: blur(28px) saturate(200%);
    -webkit-backdrop-filter: blur(28px) saturate(200%);
    border: 1px solid var(--header-glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.15s ease;
    will-change: backdrop-filter;
}

.user-menu.open .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-info {
    padding: 0.625rem 0.875rem;
}

.user-name-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-email {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.8125rem;
    color: var(--text);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background var(--transition);
    text-align: left;
    text-decoration: none;
}

.dropdown-item:hover {
    /* Nav-bar-style theme-adaptive hover. */
    background: var(--bg-hover);
    color: var(--text);
}

.dropdown-item svg {
    color: var(--text-secondary);
}

.follow-btn {
    padding: 0.625rem 1.5rem;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-full, 20px);
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.follow-btn:hover {
    opacity: 0.9;
}

.follow-btn.following {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.follow-btn.following:hover {
    border-color: #e74c3c;
    color: #e74c3c;
}

.follow-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.follows-modal-content {
    max-width: 400px;
    width: 100%;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

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

.follows-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius-md);
}

.follows-tab {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.follows-tab:hover {
    color: var(--text);
}

.follows-tab.active {
    background: var(--bg-elevated);
    color: var(--text);
}

.follows-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.follows-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.follows-item:last-child {
    border-bottom: none;
}

.follows-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    flex-shrink: 0;
}

.follows-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.follows-avatar svg {
    width: 100%;
    height: 100%;
}

.follows-info {
    flex: 1;
}

.follows-username {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}

.follows-username:hover {
    text-decoration: underline;
}

.follows-action-btn {
    padding: 6px 14px;
    border-radius: var(--radius-full, 20px);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.follows-action-btn.unfollow {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text);
}

.follows-action-btn.unfollow:hover {
    border-color: #e74c3c;
    color: #e74c3c;
}

.follows-action-btn.follow {
    background: var(--text);
    color: var(--bg);
    border: none;
}

.follows-action-btn.follow:hover {
    opacity: 0.85;
}

.follows-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

#detail-avatar svg {
    width: 100%;
    height: 100%;
}

.profile-name-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.follow-btn-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: var(--radius-full, 20px);
    cursor: pointer;
    transition: all var(--transition);
    background: var(--text);
    color: var(--bg);
    border: none;
    white-space: nowrap;
}

.follow-btn-inline:hover {
    opacity: 0.85;
}

.follow-btn-inline.following {
    background: var(--bg-secondary);
    color: var(--text);
    border: 1px solid var(--border);
}

.follow-btn-inline.following:hover {
    border-color: #e74c3c;
    color: #e74c3c;
}

.follow-btn-inline.hidden {
    display: none;
}

.profile-bio-wrapper {
    max-width: 400px;
    margin: 0.5rem 0 0.75rem 0;
}

.profile-bio-wrapper .profile-bio {
    display: inline;
    margin: 0;
}

.edit-bio-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    vertical-align: middle;
    margin-left: 0.375rem;
}

.edit-bio-btn:hover {
    color: var(--text);
}

.edit-bio-btn.visible {
    display: inline-flex;
}

.bio-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    width: 100%;
}

.bio-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 0.9375rem;
    font-family: inherit;
    line-height: 1.5;
    resize: none;
    height: 100px;
    overflow: hidden;
}

.bio-input:focus {
    outline: none;
    border-color: var(--text-muted);
}

.bio-char-counter {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.bio-char-counter.warn {
    color: #f59e0b;
}

.bio-char-counter.limit {
    color: #ef4444;
}

.bio-edit-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: space-between;
    align-items: center;
}

.btn-bio {
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

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

.btn-bio.cancel:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.btn-bio.save {
    background: var(--text);
    border: none;
    color: var(--bg);
}

.btn-bio.save:hover {
    opacity: 0.9;
}

.btn-bio:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.bio-btn-group {
    display: flex;
    gap: 0.5rem;
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .profile-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .profile-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .profile-app .header-inner {
        padding: 0 1rem;
    }
    .profile-avatar {
        width: 88px;
        height: 88px;
    }
    .avatar-edit-btn {
        width: 30px;
        height: 30px;
    }
}

@media (max-width: 640px) {
    .profile-main {
        padding: 0.75rem;
    }
    .profile-card {
        padding: 1rem;
        margin-bottom: 1rem;
        position: relative;
    }

    /* ---- Header: avatar + info side by side ---- */
    .profile-header {
        flex-direction: row;
        align-items: flex-start;
        text-align: left;
        gap: 0.75rem;
    }
    .profile-avatar {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }
    .avatar-edit-btn {
        width: 24px;
        height: 24px;
    }
    .avatar-edit-btn svg {
        width: 11px;
        height: 11px;
    }
    .avatar-menu {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        min-width: 100%;
        border-radius: 16px 16px 0 0;
        padding: 8px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
        z-index: 1000;
    }
    .avatar-menu-item {
        padding: 14px 16px;
        font-size: 1rem;
        justify-content: center;
    }
    .avatar-menu-item svg {
        width: 20px;
        height: 20px;
    }

    /* ---- Name + handle ---- */
    .profile-name {
        font-size: 1.25rem;
        margin-bottom: 0;
    }
    .profile-name-row {
        gap: 0.5rem;
    }
    .profile-username {
        font-size: 0.8125rem;
        margin: 0 0 0.25rem 0;
    }

    /* ---- Bio ---- */
    .profile-bio-wrapper {
        margin: 0.25rem 0 0.125rem 0;
    }
    .profile-bio {
        font-size: 0.8125rem;
        max-width: 100%;
    }
    .bio-input {
        font-size: 16px;
    }
    .profile-meta {
        font-size: 0.75rem;
    }

    /* ---- Actions: followers/following — below meta ---- */
    .profile-actions {
        position: static;
        flex-direction: row;
        align-items: center;
        gap: 0.375rem;
        margin: 0.5rem 0 0 0;
    }
    .profile-actions-wrapper {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
    }
    .profile-follow-pills {
        gap: 0.375rem;
    }
    .follow-pill {
        padding: 0.3rem 0.625rem;
        font-size: 0.75rem;
    }
    .profile-edit-btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }
    .follow-btn-inline {
        padding: 0.3rem 0.75rem;
        font-size: 0.75rem;
    }

    /* ---- Stats: compact strip ---- */
    .profile-stats {
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        gap: 0;
        justify-content: space-between;
    }
    .stat-item {
        flex: 1;
    }
    .stat-value {
        font-size: 1.125rem;
    }
    .stat-label {
        font-size: 0.6875rem;
    }

    /* ---- Tabs: wrap into grid rows of 3 ---- */
    .profile-tabs {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        width: 100%;
        gap: 3px;
    }
    .profile-tab {
        justify-content: center;
        text-align: center;
        padding: 0.5rem 0.375rem;
        font-size: 0.7rem;
        gap: 0.25rem;
    }
    .profile-app .discover-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    /* ---- Cards: hide tags overlay + avatar/username on mobile ---- */
    .profile-app .card-tags {
        display: none !important;
    }
    .profile-app .card-user {
        display: none;
    }
    .profile-app .card-footer {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .profile-app .discover-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    .follows-modal-content {
        width: 95vw;
        max-width: none;
        margin: 1rem;
    }
    .detail-modal-content {
        width: 100vw;
        max-width: none;
        border-radius: 0;
        max-height: 100vh;
    }
}
