/* Profile Background – volle Viewport-Fläche; App-Chrome (Nav, Chat, …) wird auf body.page-profile höher gesetzt (s. unten). */
.profile-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(180deg, #f8f9fa 0%, #ffffff 100%);
    overflow-y: auto;
    z-index: 999998;
    pointer-events: auto;
}

/* Keep top bar and nav above the scrollable profile content */
.settings-controls-container .settings-top-left {
    z-index: 999999 !important;
}

/* Ensure nav island stays above profile content */
.left-nav-cluster {
    z-index: 999999 !important;
}

/*
 * profile.php: .profile-background (999998) liegt über den Standard-z-Index-Werten von
 * Chat (~2000), Mobile-Top/Bottom-Nav (~10002) und .settings-controls-container (1000 als Kontext).
 * Damit Verhalten wie auf index/persons/stories: Chrome und Chat klickbar und sichtbar.
 */
body.page-profile .settings-controls-container {
    z-index: 999999 !important;
}

body.page-profile .mobile-bottom-nav {
    z-index: 1000000 !important;
}

@media (max-width: 1024px) {
    body.page-profile .mobile-top-nav {
        z-index: 1000000 !important;
    }

    body.page-profile.chat-overlay-open .mobile-top-nav-row,
    body.page-profile.chat-overlay-open #mobile-bottom-nav {
        z-index: 1000100 !important;
    }
}

body.page-profile .chat-popup {
    z-index: 1000010 !important;
}

body.page-profile .chat-popup.kinma-chat-popup-clone {
    z-index: 1000011 !important;
}

body.page-profile .chat-popup.kinma-chat-popup-instance-active {
    z-index: 1000012 !important;
}

body.page-profile .kinma-chat-float-window {
    z-index: 1000013 !important;
}

body.page-profile #floatingCallVideoWindow,
body.page-profile #floatingCallVideoDockTab {
    z-index: 1000014 !important;
}

body.page-profile .call-status-bar {
    z-index: 1000015 !important;
}

body.page-profile .feedback-highlight-overlay,
body.page-profile .feedback-highlight-overlay-top,
body.page-profile .feedback-highlight-overlay-bottom,
body.page-profile .feedback-highlight-overlay-left,
body.page-profile .feedback-highlight-overlay-right {
    z-index: 1000020 !important;
}

/* Profile Selector Bar - Inside settings-logo-group (andernfalls leer) / linke Nav auf profile.php */
.settings-logo-group .profile-selector-bar-new {
    position: relative;
    top: auto;
    left: auto;
    z-index: auto;
    max-width: 600px;
    flex: 0 0 auto;
    margin-left: auto;
    align-self: stretch;
    display: flex;
    align-items: center;
}

/*
 * Profil-URL-Suche: außerhalb .left-nav-cluster, fix positioniert rechts neben Kinma (nur Desktop).
 */
body.page-profile .profile-page-url-search-host {
    position: fixed;
    left: calc(24px + env(safe-area-inset-left, 0px) + 52px + 12px);
    top: calc(12px + env(safe-area-inset-top, 0px));
    z-index: 999999;
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    gap: 0;
    min-height: 52px;
    max-width: min(380px, calc(100vw - 200px));
    box-sizing: border-box;
    overflow: visible;
}

/* Per JS (.profile-page-url-search-host--elevated), zuverlässiger als :has() — über linker Nav */
body.page-profile .profile-page-url-search-host.profile-page-url-search-host--elevated {
    z-index: 1000020 !important;
}

body.page-profile .profile-page-url-search-host .left-nav-profile-url-selector.profile-selector-bar-new {
    margin-left: 0;
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 52px;
    min-height: 52px;
    max-height: 52px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    background: #ffffff;
    border-radius: 9999px;
    box-shadow: none;
    border: 1px solid rgba(148, 163, 184, 0.5);
    /* Kein horizontales Padding hier: sonst wirkt die Zeile breiter als das Dropdown
       (Dropdown ist an .profile-selector-container-new ausgerichtet, innerhalb des Paddings). */
    padding: 0;
    overflow: visible;
}

body.page-profile .profile-page-url-search-host .profile-selector-container-new {
    position: relative;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    height: 100%;
    min-height: 0;
    align-items: center;
    align-self: stretch;
}

/* Volle Breite wie die äußere Pill – unabhängig von .search-active { max-width: 500px } */
body.page-profile .profile-page-url-search-host .profile-selector-container-new.search-active {
    max-width: none;
    width: 100%;
    flex: 1 1 auto;
}

body.page-profile .profile-page-url-search-host .left-nav-profile-url-selector .profile-url-display {
    padding: 0 14px 0 16px;
    min-height: 0;
    align-items: center;
    border-radius: 0;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
}

body.page-profile .profile-page-url-search-host .profile-url-prefix-new,
body.page-profile .profile-page-url-search-host .profile-url-current {
    line-height: 1.25;
}

body.page-profile .profile-page-url-search-host .profile-url-input-new {
    line-height: 1.25;
    max-height: 44px;
}

body.page-profile .profile-page-url-search-host .left-nav-profile-url-selector .profile-selector-dropdown-new {
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    min-width: 0;
    box-sizing: border-box;
    z-index: 10010;
    background: #ffffff;
    /* Eine durchgehende Kontur mit der Suchzeile (kein schmaleres „Unterteil“) */
    border: 1px solid rgba(148, 163, 184, 0.5);
    border-top: none;
    border-radius: 0 0 26px 26px;
    box-shadow: none;
    margin-top: 0;
}

body.page-profile .profile-page-url-search-host.profile-page-url-search-host--elevated .profile-selector-dropdown-new {
    z-index: 100030;
}

body.page-profile .profile-page-url-search-host .left-nav-profile-url-selector.profile-url-dropdown-open {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: none;
}

body.page-profile .profile-page-url-search-host .left-nav-profile-url-selector.profile-url-dropdown-open .profile-selector-dropdown-new {
    box-shadow: 0 14px 36px rgba(26, 26, 26, 0.14);
}

.profile-selector-container-new:has(.profile-selector-self-inline-avatar) {
    gap: 8px;
}

.profile-selector-self-inline-avatar {
    flex-shrink: 0;
}

.profile-selector-container-new {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
    transition: all 0.3s ease;
    box-shadow: none;
    height: 100%;
    align-self: stretch;
}

/* Suchzeile + Dropdown: gleiche nutzbare Breite wie die äußere Pill (.profile-selector-bar-new) */
.profile-selector-bar-new > .profile-selector-container-new {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
}

.profile-selector-container-new:hover {
    border-color: transparent;
    box-shadow: none;
}

.profile-selector-container-new.search-active {
    max-width: 500px;
    border-color: transparent;
    box-shadow: none;
}

.profile-url-display {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 8px 12px;
    min-width: 0;
    gap: 6px;
    background: transparent;
    border-radius: 8px;
    cursor: text;
    user-select: none;
}

.profile-url-display:hover {
    background: rgba(0, 0, 0, 0.02);
}

.profile-selector-container-new.search-active .profile-url-current {
    display: none;
}

.profile-url-prefix-new {
    font-size: 12px;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
    color: #6b7280;
    white-space: nowrap;
    user-select: none;
    font-weight: 500;
}

.profile-url-current {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.profile-url-input-new {
    flex: 0 1 auto;
    padding: 0;
    border: none;
    font-size: 13px;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
    color: #1a1a1a;
    background: transparent;
    outline: none;
    min-width: 100px;
    font-weight: 600;
    display: none;
    margin: 0;
    width: auto;
}

.profile-selector-container-new.search-active .profile-url-input-new {
    display: inline-block !important;
    background: transparent;
}

.profile-url-input-new::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

.profile-selector-container-new.search-active .profile-url-input-new {
    display: block !important;
    background: transparent;
}

.profile-selector-dropdown-new {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-top: none;
    border-radius: 0 0 26px 26px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    box-shadow: 0 8px 22px rgba(26, 26, 26, 0.1);
    animation: dropdownFadeIn 0.2s ease;
    margin-top: 0;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile: Desktop-Pfadzeile im Header ausblenden (Familienwechsel über Bottom-Nav); #profile-url-input bleibt im DOM */
@media (max-width: 1024px) {
    .settings-logo-group .profile-url-display {
        display: none !important;
    }

    body:not(.profile-mobile-nav-search-open) .settings-logo-group .profile-selector-bar-new {
        flex: 0 0 0 !important;
        min-width: 0 !important;
        max-width: 0 !important;
        width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
    }

    .left-nav-cluster .left-nav-profile-url-selector,
    body.page-profile .profile-page-url-search-host {
        display: none !important;
    }

    .profile-edit-button-banner {
        display: none !important;
    }
}

.profile-selector-item-new {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: none;
}

.profile-selector-item-new:first-child {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.profile-selector-item-new:last-child {
    border-bottom: none;
    border-bottom-left-radius: 26px;
    border-bottom-right-radius: 26px;
}

.profile-selector-item-new:hover {
    background: rgba(0, 0, 0, 0.03);
    transform: translateX(2px);
}

.profile-selector-avatar-new {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #667eea; /* Default, will be overridden by inline style */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    flex-shrink: 0;
}

.profile-selector-avatar-new img {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    object-fit: cover;
}

.profile-selector-avatar-new span {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

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

.profile-selector-name-new {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-selector-id-new {
    font-size: 11px;
    color: #6b7280;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
}

/* Profile Content - New Layout */
.profile-content-new {
    margin-left: 0;
    padding-left: 0;
    padding-right: 0;
    padding-top: 0;
    padding-bottom: 0;
    min-height: 100vh;
    background: #ffffff;
    position: relative;
    width: 100%;
    max-width: 100%;
    pointer-events: auto;
}

/* Profil: Banner-Höhe + Avatar — eine Variable für Banner, Geo-SVG und Überlappung */
body.page-profile {
    --profile-banner-h: 500px;
    --profile-avatar-size: 200px;
    --profile-avatar-border: 4px;
    --country-badge-size: 52px;
    /* Picture column height (matches --pp-stack-h; coat enlarges wrapper, avatar stays vertically centered) */
    --profile-picture-stack-h: var(--profile-avatar-size);
}

body.page-profile:has(.profile-picture-wrapper-vertical--has-coat) {
    --profile-picture-stack-h: calc(var(--profile-avatar-size) * 1.4);
}

/* Avatar + name: unten am Banner ausrichten (Höhe folgt --profile-banner-h) */
.profile-identity-overlap {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: calc(var(--profile-banner-h) - var(--profile-avatar-size));
    z-index: 12;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: min(100%, 320px);
    pointer-events: none;
    overflow: visible;
}

/* Profil: Kreisunterkante auf Banner-/Content-Kante; bei Wappen folgt der höhere Wrapper (--profile-picture-stack-h) */
body.page-profile .profile-identity-overlap {
    top: calc(
        var(--profile-banner-h) - var(--profile-avatar-size) / 2 - var(--profile-picture-stack-h) / 2
    );
}

.profile-identity-overlap .profile-picture-wrapper-vertical,
.profile-identity-overlap .profile-name-vertical {
    pointer-events: auto;
}

/* Full-width structured menu below banner */
.profile-menu-surface {
    position: relative;
    z-index: 4;
    width: 100%;
    max-width: 100%;
    margin-top: -110px;
    padding: 175px 20px 56px;
    background: #ffffff;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -12px 40px rgba(26, 26, 26, 0.06);
    box-sizing: border-box;
}

.profile-menu-inner {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    box-sizing: border-box;
}

.profile-menu-session-row--after-actions {
    margin-top: 16px;
    margin-bottom: 0;
}

.profile-menu-section {
    width: 100%;
    margin: 0 0 20px 0;
    padding: 22px 24px 26px;
    background: #fafafa;
    border: 1px solid #e8ecf1;
    border-radius: 16px;
    box-sizing: border-box;
}

.profile-menu-section--contents {
    background: #ffffff;
}

.profile-menu-section--account {
    background: #fafafa;
    margin-bottom: 0;
}

.profile-menu-section-heading {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #64748b;
    margin: 0 0 16px 0;
    padding: 0;
}

.profile-menu-section-lead {
    font-size: 14px;
    color: #64748b;
    margin: -8px 0 20px 0;
    line-height: 1.45;
}

.profile-menu-section--contents .profile-menu-section-heading {
    margin-bottom: 6px;
}

/* Messages */
.error-message,
.success-message {
    margin: 20px;
    padding: 16px 20px;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 8px;
}

.error-message {
    background: #fff5f5;
    border: 1px solid #fecaca;
    color: #c53030;
}

.success-message {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #16a34a;
}

/* Profile Banner - Redesigned with Country Outline */
.profile-banner-container-new {
    position: relative;
    width: 100%;
    margin-bottom: 0;
    overflow: hidden;
}

.profile-banner-new {
    width: 100%;
    height: var(--profile-banner-h);
    min-height: 220px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); /* Default fallback - will be overridden by JavaScript inline styles */
    position: relative;
    overflow: hidden; /* Geo-SVG an Banner begrenzen */
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Country Outline Inside Banner - Direct, no white box */
.profile-country-outline-banner {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1400px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-sizing: border-box;
    pointer-events: none;
}

.profile-country-outline-banner svg {
    width: 100%;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    display: block;
    margin: 0;
    flex: 1 1 auto;
    opacity: 1;
}

.profile-country-outline-banner svg path {
    /* stroke-width is set dynamically in JavaScript to always be 5px */
    fill: #ffffff !important;
    stroke: #ffffff !important;
    fill-opacity: 1 !important;
    stroke-opacity: 1 !important;
}

/* Country Outline as Large Background Element */
.profile-banner-country-outline {
    display: none; /* Hide old country outline */
}

/* Edit Profile Button - Top Right of Banner */
.profile-edit-button-banner {
    position: absolute;
    top: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: #ffffff;
    backdrop-filter: none;
    border: 2px solid #e8ecf1;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
}

.profile-edit-button-banner:hover {
    background: #ffffff;
    border-color: #d1d9e6;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    color: #6366f1;
}

.profile-edit-button-banner svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Desktop: nur Stift-Icon im Kreis */
@media (min-width: 1025px) {
    .profile-edit-button-banner {
        width: 48px;
        height: 48px;
        min-width: 48px;
        padding: 0;
        border-radius: 50%;
        gap: 0;
    }

    .profile-edit-button-banner__label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
}

/* Legacy: wizard / old full-viewport header (profile page now uses .profile-menu-surface) */
.profile-header-section-vertical {
    position: relative;
    min-height: 100vh;
    padding: 120px 64px 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
    background: #ffffff;
    border-radius: 0;
    box-shadow: none;
    margin-top: -100px;
    z-index: 2;
    width: 100%;
    box-sizing: border-box;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Profile picture sits inside .profile-identity-overlap (no absolute here — keeps name directly below) */
.profile-picture-wrapper-vertical {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Stack height: avatar, or 1.4× avatar when coat (coat = 40% larger than circle) */
    --pp-stack-h: var(--profile-avatar-size);
    --kinma-avatar-size: var(--profile-avatar-size);
    --kinma-presence-dot-scale: 0.16;
    --kinma-presence-dot-offset: calc(var(--profile-avatar-border) + 2px);
    width: var(--pp-stack-h);
    height: var(--pp-stack-h);
    flex-shrink: 0;
    overflow: visible;
}

/* Presence auf Profilseite (gleiche Farben/Proportion wie Chat) */
body.page-profile .profile-picture-presence-dot {
    display: block;
}

/* Space for flag badge half that sits below the avatar (does not shrink the avatar stack) */
.profile-picture-wrapper-vertical:has(.country-symbol-badge) {
    margin-bottom: calc(var(--country-badge-size) / 2);
}

/* Coat of arms (Wappen): 40% larger than profile circle diameter (1.4×) */
.profile-picture-wrapper-vertical--has-coat {
    --pp-stack-h: var(--profile-picture-stack-h);
    width: var(--pp-stack-h);
    height: var(--pp-stack-h);
}

.profile-coat-of-arms {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: var(--profile-picture-stack-h);
    height: var(--profile-picture-stack-h);
    max-width: 100%;
    max-height: 100%;
    z-index: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.profile-coat-of-arms img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 6px 14px rgba(26, 26, 26, 0.18));
}

.profile-picture-circle {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: #667eea; /* Default, will be overridden by inline style */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 72px;
    font-weight: 700;
    color: #ffffff;
    border: 6px solid #ffffff;
    overflow: hidden; /* Keep avatar clipped to circle */
    transition: border-color 0.2s ease, transform 0.2s ease;
    box-shadow: none;
    position: relative;
    z-index: 1;
}

/* Mit hochgeladenem Foto: weißer Ring wie die Kartenfläche. Ohne Foto: Inline-Farbe aus Herkunftsland (getProfilePictureColor). */
body.page-profile .profile-picture-circle--has-photo,
body.page-register .profile-preview-wizard .profile-picture-circle--has-photo {
    background: #ffffff !important;
    border-color: #ffffff !important;
}

body.page-profile .profile-picture-circle--has-photo span,
body.page-register .profile-preview-wizard .profile-picture-circle--has-photo span {
    color: #1a1a1a;
}

body.page-profile .profile-picture-circle {
    box-sizing: border-box;
    width: var(--profile-avatar-size);
    height: var(--profile-avatar-size);
    border-width: var(--profile-avatar-border);
}

/*
 * Country symbol: bottom center; horizontal midline on bottom of avatar ring.
 * bottom + translateX avoids mismatch with top/50% when coat enlarges the wrapper:
 * circle bottom sits at (pp-stack-h − avatar) / 2 above the wrapper’s bottom edge.
 */
.country-symbol-badge {
    position: absolute;
    left: 50%;
    bottom: calc(
        (var(--pp-stack-h) - var(--profile-avatar-size)) / 2 - var(--country-badge-size) / 2
    );
    top: auto;
    transform: translateX(-50%);
    width: var(--country-badge-size);
    height: var(--country-badge-size);
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.country-symbol-badge:hover {
    transform: translateX(-50%) scale(1.05);
}

.country-symbol-badge img {
    width: 95%;
    height: 95%;
    object-fit: contain;
    padding: 0;
}

.profile-picture-circle:hover {
    transform: none;
}

.profile-picture-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-picture-circle span {
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Profile Name - Below */
.profile-name-vertical {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    position: relative;
    width: 100%;
}

.profile-name-with-dropdown {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    width: 100%;
    max-width: 100%;
    gap: 0;
    box-sizing: border-box;
}

.profile-name-balance {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    pointer-events: none;
}

.profile-name-with-dropdown .profile-name-new-vertical {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
    max-width: 100%;
}

.profile-name-with-dropdown .name-history-toggle {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
}

.profile-name-new-vertical {
    font-size: clamp(1.75rem, 4.8vw, 2.35rem);
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.02em;
    text-align: center;
}

/* Profile Metadata - Vertical */
.profile-metadata-vertical {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    align-items: stretch;
}

.profile-metadata-vertical .profile-meta-item-new {
    justify-content: center;
    text-align: center;
}

/* Profile Header Section - Modern Redesign (Old - keep for compatibility) */
.profile-header-section {
    position: relative;
    padding: 50px 80px 60px;
    display: grid;
    grid-template-columns: 280px 1fr 400px;
    gap: 60px;
    align-items: start;
    margin-top: -150px;
    z-index: 2;
    background: #ffffff;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    display: none; /* Hide old layout */
}

/* Person-erstellen-Vorschau: Header mit Name/Initialen anzeigen; kein Fullscreen-Overlay, damit Wizard sichtbar bleibt */
.profile-preview-wizard .profile-header-section {
    display: grid !important;
}

/* Vorschau im Wizard: volle Breite des Formular-Containers, im normalen Dokumentfluss (kein fixed Overlay) */
.profile-preview-wizard .profile-background {
    position: relative !important;
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    min-height: 400px;
    z-index: 0 !important;
    overflow: visible;
}

/* Profile Picture - Left Column */
.profile-picture-wrapper-new {
    position: relative;
}

.profile-picture-large-new {
    width: 280px;
    height: 280px;
    border-radius: 24px;
    background: linear-gradient(135deg, #e0e0e0 0%, #d0d0d0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 100px;
    font-weight: 700;
    color: #9ca3af;
    border: 5px solid #ffffff;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    position: relative;
}

.profile-picture-large-new:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16);
}

.profile-picture-large-new img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-picture-large-new span {
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Profile Info - Center Column */
.profile-info-section-new {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-top: 20px;
}

/* Profile Name Wrapper with Dropdown */
.profile-name-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.name-history-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: auto;
    height: auto;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
    color: #64748b;
    -webkit-tap-highlight-color: transparent;
}

.name-history-toggle:hover {
    color: #1a1a1a;
    background: transparent;
}

.name-history-toggle:active {
    color: #1a1a1a;
}

.name-history-toggle:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.name-history-toggle svg {
    width: 16px;
    height: 16px;
    transition: transform 0.22s ease;
}

.name-history-toggle.active svg {
    transform: rotate(180deg);
}

/* Namensverlauf: kein Popup — Panel direkt unter der Namenszeile (wie aufgeklappter Abschnitt) */
.name-history-inline-panel,
.name-history-dropdown {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    width: 100%;
    max-width: min(520px, 100%);
    margin: 16px auto 0;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 8px 24px rgba(26, 26, 26, 0.06);
    z-index: 1;
    max-height: min(420px, 55vh);
    overflow: hidden;
    display: none;
    flex-direction: column;
    box-sizing: border-box;
}

.name-history-inline-panel.is-open {
    animation: name-history-panel-in 0.22s ease-out;
}

/* Im Dokumentfluss unter dem Kopfbereich: kein „Popup“ über dem Inhalt */
.name-history-inline-panel.name-history-in-body-flow {
    position: static !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 0 22px 0 !important;
    z-index: auto !important;
    box-shadow: none;
    border: 1px solid #e8ecf1;
    background: #f8fafc;
    border-radius: 14px;
}

.name-history-inline-panel.name-history-in-body-flow.is-open {
    animation: name-history-in-body-in 0.2s ease-out;
}

@keyframes name-history-in-body-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes name-history-panel-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.name-history-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid #f3f4f6;
}

.name-history-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.name-history-content {
    padding: 8px 0;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    max-height: none;
}

.name-history-footer {
    padding: 16px 24px 20px;
    border-top: 1px solid #f3f4f6;
    background: #fafafa;
}

.name-change-request-btn {
    width: 100%;
    padding: 12px 20px;
    background: #1a1a1a;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.2px;
}

.name-change-request-btn:hover {
    background: #1f2937;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(17, 24, 39, 0.2);
}

.name-change-request-btn:active {
    background: #1a1a1a;
    transform: translateY(0);
}

/* Name Change Request Modal */
.name-change-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.name-change-modal {
    background: #ffffff;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.name-change-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.name-change-modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #1a1a1a;
}

.name-change-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.name-change-modal-close:hover {
    background: #f3f4f6;
    color: #1a1a1a;
}

.name-change-modal-body {
    padding: 24px;
}

.name-change-modal-info {
    margin: 0 0 20px 0;
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
}

.name-change-modal-body .form-group {
    margin-bottom: 20px;
}

.name-change-modal-body .form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
}

.name-change-modal-body .form-group input,
.name-change-modal-body .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.name-change-modal-body .form-group input:focus,
.name-change-modal-body .form-group textarea:focus {
    outline: none;
    border-color: #1a1a1a;
}

.name-change-modal-body .form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.name-change-modal-body .form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    margin-bottom: 0;
}

.name-change-modal-body .btn-cancel,
.name-change-modal-body .btn-submit {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.name-change-modal-body .btn-cancel {
    background: #f3f4f6;
    color: #1a1a1a;
}

.name-change-modal-body .btn-cancel:hover {
    background: #e5e7eb;
}

.name-change-modal-body .btn-submit {
    background: #1a1a1a;
    color: #ffffff;
}

.name-change-modal-body .btn-submit:hover {
    background: #1f2937;
}

.name-change-modal-body .btn-submit:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.name-history-loading {
    padding: 32px 24px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
}

.name-history-item {
    padding: 16px 24px;
    margin: 0;
    background: transparent;
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.15s ease;
    position: relative;
}

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

.name-history-item:hover {
    background: #fafafa;
}

.name-history-item:first-child {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.name-history-item:first-child::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #1a1a1a;
    border-radius: 0 2px 2px 0;
}

.name-history-item-name {
    font-size: 16px;
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 6px;
    line-height: 1.4;
}

.name-history-item:first-child .name-history-item-name {
    font-weight: 600;
    color: #1a1a1a;
}

.name-history-item-date {
    font-size: 12px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
}

.name-history-item-date svg {
    width: 12px;
    height: 12px;
    opacity: 0.6;
}

.name-history-empty {
    padding: 48px 24px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
    line-height: 1.6;
}

.profile-name-new {
    font-size: 56px;
    font-weight: 800;
    color: #1a1a1a;
    margin: 0;
    line-height: 1.1;
    letter-spacing: -1.5px;
    background: linear-gradient(135deg, #1a1a1a 0%, #4b5563 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.profile-metadata-new {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.profile-meta-item-new {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    color: #6b7280;
    padding: 10px 16px;
    background: #f9fafb;
    border-radius: 10px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.profile-meta-item-new:hover {
    background: #f3f4f6;
    border-color: #e5e7eb;
    transform: translateX(4px);
}

.profile-meta-item-new .meta-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.8;
    color: #6366f1;
    transition: all 0.2s ease;
}

.profile-meta-item-new:hover .meta-icon {
    opacity: 1;
    color: #4f46e5;
}

.profile-meta-item-new span {
    position: relative;
}

/* Country Section - Right Column with Prominent Outline */
.profile-country-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 32px;
    background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
    border: 2px solid #e5e7eb;
    border-radius: 20px;
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}

.profile-country-section:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    border-color: #d1d5db;
}

.profile-country-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 2px solid #f3f4f6;
}

.profile-country-header .meta-icon {
    width: 24px;
    height: 24px;
    color: #6366f1;
    transition: color 0.2s ease;
}

.profile-country-name {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: -0.3px;
}

.profile-country-outline-container {
    width: 100%;
    height: 300px;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border-radius: 16px;
    padding: 20px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.04);
}

.profile-country-outline-container:hover {
    border-color: #d1d5db;
    box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.06);
}

.profile-country-outline-container {
    transition: all 0.3s ease;
    visibility: visible !important;
    opacity: 1 !important;
    margin-top: 16px;
}

.profile-country-outline-container:hover {
    border-color: #1a1a1a;
    background: #f5f5f5;
}

#country-outline-svg {
    width: 100%;
    height: 100%;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: transparent;
}

#country-outline-svg path {
    transition: all 0.3s ease;
    /* fill is set dynamically in JavaScript with flag colors */
    stroke: rgb(0, 0, 0) !important;
    stroke-opacity: 1 !important;
    opacity: 1 !important;
    /* stroke-width is set dynamically in JavaScript relative to viewBox size */
}

/* Hover effect removed - stroke-width is set dynamically */

/* Email Section - Below Country */
.profile-email-section-new {
    padding-top: 24px;
    border-top: 2px solid #f3f4f6;
    margin-top: 8px;
}

.profile-email-item-new {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    font-size: 14px;
    color: #1a1a1a;
    background: #f9fafb;
    border-radius: 10px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.profile-email-item-new:hover {
    background: #f3f4f6;
    border-color: #e5e7eb;
}

.profile-email-item-new .email-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: #6366f1;
    transition: color 0.2s ease;
}

.profile-email-item-new:hover .email-icon {
    color: #4f46e5;
}

/* Tree Button Section */
.profile-tree-section-new {
    padding-top: 24px;
    border-top: 2px solid #f3f4f6;
    margin-top: 8px;
}

.profile-tree-button-new {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.profile-tree-button-new:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.profile-tree-button-new:active {
    transform: translateY(0);
}

.profile-tree-button-new:hover {
    background: #1a1a1a;
    color: #ffffff;
    border-color: #1a1a1a;
}

.profile-tree-button-new svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Content Section - Second "slide" (viewport height), full width */
.profile-content-section-new {
    min-height: 100vh;
    padding: 80px 64px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
    width: 100%;
    max-width: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    box-sizing: border-box;
}

.content-header {
    width: 100%;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
    margin-bottom: 40px;
}

.content-title-big {
    font-size: 28px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 6px 0;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.content-title-big::after {
    display: none;
}

.content-subtitle {
    font-size: 15px;
    color: #64748b;
    margin: 0;
    font-weight: 400;
}

.content-items-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    align-items: stretch;
}

.content-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    align-items: stretch;
}

/* Large Content Items - minimal, no boxes, presentation style */
.content-item-large {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 20px;
    padding: 20px 0;
    background: transparent;
    border: none;
    border-radius: 0;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: opacity 0.2s ease, background 0.15s ease;
    text-align: left;
    position: relative;
    overflow: visible;
    box-shadow: none;
    width: 100%;
    max-width: none;
}

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

.content-item-large::before {
    display: none;
}

.content-item-large:hover {
    border-color: transparent;
    transform: none;
    box-shadow: none;
    opacity: 1;
    background: #f8fafc;
}

.content-item-large:hover::before {
    transform: none;
}

.content-item-icon-large {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: 0;
    transition: color 0.2s ease;
    position: relative;
    z-index: 1;
    border: none;
}

.content-item-large:hover .content-item-icon-large {
    background: transparent;
    border-color: transparent;
    transform: none;
}

.content-item-icon-large svg {
    width: 28px;
    height: 28px;
    color: #64748b;
    transition: color 0.2s ease;
}

.content-item-large:hover .content-item-icon-large svg {
    color: #1a1a1a;
    transform: none;
}

.content-item-text-large {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    position: relative;
    z-index: 1;
    align-items: flex-start;
}

.content-item-title-large {
    font-size: 17px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.4;
    letter-spacing: -0.01em;
    transition: color 0.2s ease;
}

.content-item-large:hover .content-item-title-large {
    color: #1a1a1a;
}

.content-item-desc-large {
    font-size: 14px;
    color: #64748b;
    font-weight: 400;
    transition: color 0.2s ease;
    line-height: 1.5;
}

.content-item-large:hover .content-item-desc-large {
    color: #64748b;
}

/* Portraits Large - compact in row layout */
.portraits-icon-wrapper-large {
    position: relative;
    width: 48px;
    height: 48px;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.portraits-icon-stack-large {
    position: relative;
    width: 48px;
    height: 40px;
}

.portrait-preview-large {
    position: absolute;
    width: 28px;
    height: 36px;
    background-size: cover;
    background-position: center;
    background-color: #e2e8f0;
    border: 1px solid #ffffff;
    border-radius: 2px;
    transition: all 0.2s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.portrait-preview-1-large {
    left: 0;
    z-index: 3;
}

.portrait-preview-2-large {
    left: 10px;
    z-index: 2;
    opacity: 0.9;
}

.portrait-preview-3-large {
    left: 20px;
    z-index: 1;
    opacity: 0.8;
}

.content-item-large:hover .portrait-preview-1-large {
    transform: translateX(-3px) translateY(-3px) rotate(-2deg);
}

.content-item-large:hover .portrait-preview-2-large {
    transform: translateX(-1px) translateY(-2px) rotate(1deg);
}

.content-item-large:hover .portrait-preview-3-large {
    transform: translateX(3px) translateY(-3px) rotate(2deg);
}

.portraits-folder-icon-large {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 18px;
    height: 18px;
    color: #94a3b8;
    z-index: 4;
}

.content-item-large:hover .portraits-folder-icon-large {
    color: #1a1a1a;
}

/* Compact Content Items */
.content-items-grid-compact {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    max-width: 1200px;
}

.content-item-compact {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 32px 24px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    position: relative;
    min-height: 180px;
}

.content-item-compact:hover {
    border-color: #1a1a1a;
}

.content-item-icon-compact {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 12px;
    transition: all 0.2s;
}

.content-item-compact:hover .content-item-icon-compact {
    background: #1a1a1a;
}

.content-item-compact:hover .content-item-icon-compact svg {
    color: #ffffff;
}

.content-item-icon-compact svg {
    color: #666;
    transition: color 0.2s;
}

.content-item-text-compact {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.content-item-title-compact {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
}

.content-item-desc-compact {
    font-size: 14px;
    color: #666;
}

/* Portraits Compact */
.portraits-icon-stack-compact {
    position: relative;
    width: 80px;
    height: 80px;
}

.portrait-preview-compact {
    position: absolute;
    width: 48px;
    height: 64px;
    background-size: cover;
    background-position: center;
    background-color: #e0e0e0;
    border: 2px solid #ffffff;
    border-radius: 2px;
    transition: all 0.2s;
}

.portrait-preview-1-compact {
    left: 0;
    z-index: 3;
}

.portrait-preview-2-compact {
    left: 16px;
    z-index: 2;
    opacity: 0.9;
}

.portrait-preview-3-compact {
    left: 32px;
    z-index: 1;
    opacity: 0.8;
}

.content-item-compact:hover .portrait-preview-1-compact {
    transform: translateX(-3px) translateY(-3px) rotate(-2deg);
}

.content-item-compact:hover .portrait-preview-2-compact {
    transform: translateX(-1px) translateY(-2px) rotate(1deg);
}

.content-item-compact:hover .portrait-preview-3-compact {
    transform: translateX(3px) translateY(-3px) rotate(2deg);
}

#open-portraits-btn:hover .content-item-icon-compact {
    background: #f5f5f5;
}

/* Profile Submenu System */
.profile-submenu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: none;
    animation: fadeIn 0.2s ease-out;
}

.profile-submenu-overlay.active {
    display: block;
}

.profile-submenu-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    display: none;
    overflow-y: auto;
    background: #ffffff;
    animation: slideInFromRight 0.3s ease-out;
}

.profile-submenu-container.active {
    display: block;
}

@keyframes slideInFromRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.profile-submenu-header {
    position: sticky;
    top: 0;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    padding: 20px 60px;
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 10;
}

.profile-submenu-back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    cursor: pointer;
    transition: all 0.2s;
}

.profile-submenu-back-btn:hover {
    background: #1a1a1a;
    color: #ffffff;
    border-color: #1a1a1a;
}

.profile-submenu-title {
    font-size: 32px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
    letter-spacing: -0.5px;
}

.profile-submenu-content {
    padding: 60px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Relationships Styles */
.profile-relationships-container {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.profile-relationship-group {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 24px;
}

.profile-relationship-group-title {
    font-size: 24px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.profile-relationship-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.profile-relationship-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.profile-relationship-item:hover {
    background: #1a1a1a;
    border-color: #1a1a1a;
    color: #ffffff;
}

.profile-relationship-name {
    font-size: 16px;
    font-weight: 500;
    color: inherit;
}

.profile-relationship-type {
    font-size: 14px;
    color: inherit;
    opacity: 0.7;
}

.profile-relationship-item:hover .profile-relationship-type {
    opacity: 1;
}

/* Chapter list styles for story book sidebar (when opened from profile) */
.story-book-chapter-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    flex: 1;
    overflow-y: auto;
    background: #ffffff;
}

.story-book-chapter-item {
    padding: 18px 24px;
    background: #ffffff;
    border: none;
    border-bottom: 1px solid rgba(26, 26, 26, 0.08);
    border-radius: 0;
    cursor: pointer;
    transition: background 0.15s ease, padding-left 0.15s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: 'Georgia', 'Times New Roman', serif;
}

.story-book-chapter-item:first-child {
    border-top: 1px solid rgba(26, 26, 26, 0.08);
}

.story-book-chapter-item:hover {
    background: #f8f9fa;
    padding-left: 28px;
}

.story-book-chapter-item.active {
    background: #f8f9fa;
    border-left: 3px solid #1a1a1a;
    padding-left: 28px;
    color: #1a1a1a;
}

.story-book-chapter-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #1a1a1a;
}

.chapter-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-wrap: anywhere;
}

.chapter-item-number {
    font-size: 11px;
    font-weight: 600;
    color: rgba(26, 26, 26, 0.4);
    letter-spacing: 0.6px;
    text-transform: uppercase;
    font-family: 'Georgia', 'Times New Roman', serif;
    margin-bottom: 1px;
}

.story-book-chapter-item.active .chapter-item-number {
    color: rgba(26, 26, 26, 0.6);
    font-weight: 600;
}

.chapter-item-title {
    font-size: 16px;
    font-weight: 400;
    color: #1a1a1a;
    line-height: 1.4;
    font-family: 'Georgia', 'Times New Roman', serif;
    letter-spacing: 0.1px;
    overflow-wrap: anywhere;
    word-break: normal;
}

.story-book-chapter-item.active .chapter-item-title {
    font-weight: 600;
    color: #1a1a1a;
}

.chapter-item-date {
    font-size: 11px;
    color: rgba(26, 26, 26, 0.4);
    opacity: 1;
    font-style: italic;
    font-family: 'Georgia', 'Times New Roman', serif;
    margin-top: 1px;
}

.story-book-chapter-item.active .chapter-item-date {
    color: rgba(26, 26, 26, 0.55);
}

.chapter-item-preview {
    flex: 0 0 auto;
    max-width: 200px;
    margin-left: 16px;
    font-size: 12px;
    color: rgba(26, 26, 26, 0.4);
    line-height: 1.4;
    font-family: 'Georgia', 'Times New Roman', serif;
    text-align: right;
    display: block;
    opacity: 1;
}

.chapter-item-preview:empty {
    display: none;
}

.chapter-item-preview strong {
    font-weight: 700;
    color: #1a1a1a;
    background: rgba(26, 26, 26, 0.08);
    padding: 1px 3px;
    border-radius: 2px;
}

/* Profile Content View (for showing specific content) */
.profile-content-view {
    padding: 60px;
    background: #ffffff;
    min-height: calc(100vh - 400px);
}

.profile-content-view-header {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 1px solid #e0e0e0;
}

.profile-content-back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    cursor: pointer;
    transition: all 0.2s;
}

.profile-content-back-btn:hover {
    background: #1a1a1a;
    color: #ffffff;
    border-color: #1a1a1a;
}

.profile-content-view-title {
    font-size: 36px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
    letter-spacing: -0.5px;
}

.profile-content-view-body {
    width: 100%;
}

/* Stories Grid */
.profile-stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 32px 24px;
    padding: 20px 0;
}

.profile-story-book {
    display: flex;
    flex-direction: column;
    gap: 16px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.profile-story-book:hover {
    transform: translateY(-4px);
}

.profile-story-cover {
    width: 200px;
    height: 280px;
    position: relative;
    background: #f5f5f5;
    border-radius: 0 8px 8px 0;
    overflow: hidden;
    border-left: 12px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
    color: #1a1a1a;
}

.profile-story-cover-title {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    line-height: 1.3;
}

.profile-story-cover-date {
    font-size: 14px;
    margin-top: 12px;
    opacity: 0.7;
}

.profile-story-info {
    text-align: center;
}

.profile-story-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.profile-story-meta {
    font-size: 13px;
    color: #666;
}

/* Story View (Opened) */
.profile-story-view {
    max-width: 900px;
    margin: 0 auto;
}

.profile-story-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid #e0e0e0;
}

.profile-story-header h3 {
    font-size: 32px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 12px 0;
}

.profile-story-date {
    font-size: 16px;
    color: #666;
}

.profile-story-content {
    line-height: 1.8;
    font-size: 16px;
    color: #1a1a1a;
}

.profile-story-text {
    margin-bottom: 24px;
}

.profile-story-text p {
    margin-bottom: 16px;
}

/* Calendar Events */
.profile-calendar-events {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.profile-calendar-event {
    display: flex;
    gap: 20px;
    padding: 20px;
    background: #f8f8f8;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    transition: all 0.2s;
}

.profile-calendar-event:hover {
    background: #f0f0f0;
    border-color: #1a1a1a;
}

.profile-calendar-event-date {
    flex-shrink: 0;
    text-align: center;
    min-width: 80px;
}

.profile-calendar-event-day {
    font-size: 32px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1;
}

.profile-calendar-event-month {
    font-size: 14px;
    color: #666;
    text-transform: uppercase;
    margin-top: 4px;
}

.profile-calendar-event-content {
    flex: 1;
}

.profile-calendar-event-title {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.profile-calendar-event-desc {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
}

/* Spinner */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #1a1a1a;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Photo Gallery Section */
.profile-photo-gallery-section {
    padding: 60px;
    background: #ffffff;
    border-top: 1px solid #f0f0f0;
}

.photo-gallery-title {
    font-size: 36px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 32px 0;
    letter-spacing: -0.5px;
}

.photo-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    max-width: 1400px;
}

.photo-gallery-item {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 Aspect Ratio */
    background: #f5f5f5;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.photo-gallery-item:hover {
    transform: scale(1.02);
}

.photo-gallery-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.photo-gallery-item:hover img {
    transform: scale(1.05);
}

.photo-gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    transition: background 0.2s;
    opacity: 0;
}

.photo-gallery-item:hover .photo-gallery-overlay {
    background: rgba(0, 0, 0, 0.3);
    opacity: 1;
}

.photo-gallery-loading,
.photo-gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 16px;
}

/* Photo Viewer Modal (Mobile-style) */
.photo-viewer-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.photo-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.photo-viewer-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s;
}

.photo-viewer-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.photo-viewer-counter {
    color: #ffffff;
    font-size: 16px;
    font-weight: 500;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
}

.photo-viewer-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    touch-action: pan-y pinch-zoom;
}

.photo-viewer-image-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.photo-viewer-image-wrapper img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.photo-viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
    opacity: 0;
    animation: fadeInNav 0.3s ease-out 0.2s forwards;
}

@keyframes fadeInNav {
    to {
        opacity: 1;
    }
}

.photo-viewer-modal:hover .photo-viewer-nav {
    opacity: 1;
}

.photo-viewer-prev {
    left: 20px;
}

.photo-viewer-next {
    right: 20px;
}

.photo-viewer-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.photo-viewer-nav:active {
    transform: translateY(-50%) scale(0.95);
}

/* Responsive Photo Gallery */
/* Profile Actions - Third "slide" (viewport height), full width */
.profile-actions {
    min-height: 100vh;
    padding: 48px 64px;
    display: flex;
    flex-direction: row;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    border-top: 1px solid #f1f5f9;
    background: #ffffff;
    width: 100%;
    max-width: none;
    margin: 0;
    box-sizing: border-box;
}

.profile-actions--in-menu {
    min-height: 0;
    padding: 0;
    border-top: none;
    background: transparent;
    justify-content: flex-start;
}

/* Kein display:contents — bricht Formular-Submit in Safari/Chrome */
.profile-action-form {
    display: block;
    margin: 0;
    padding: 0;
    width: auto;
}

.profile-menu-section .error-message,
.profile-menu-section .success-message {
    margin: 0 0 16px 0;
    width: 100%;
}

.profile-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    width: auto;
    min-width: auto;
    justify-content: center;
    box-shadow: none;
    white-space: nowrap;
}

.profile-action-btn:hover {
    background: #f1f5f9;
    border-color: transparent;
    color: #1a1a1a;
    transform: none;
    box-shadow: none;
}

.profile-action-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.8;
}

.profile-action-btn:hover svg {
    opacity: 1;
}

.profile-action-edit {
    color: #6b7280;
    border-color: #e5e7eb;
    background: transparent;
}

.profile-action-edit:hover {
    background: transparent;
    color: #1a1a1a;
    border-color: #d1d5db;
}

.profile-action-logout {
    color: #6b7280;
}

.profile-action-logout:hover {
    background: transparent;
    border-color: #d1d5db;
    color: #1a1a1a;
}

.profile-action-leave {
    color: #6b7280;
    border-color: #e5e7eb;
    background: transparent;
}

.profile-action-leave:hover {
    background: transparent;
    border-color: #d1d5db;
    color: #1a1a1a;
}

.profile-action-delete {
    color: #6b7280;
    border-color: #e5e7eb;
}

.profile-action-delete:hover {
    background: transparent;
    border-color: #d1d5db;
    color: #1a1a1a;
}

.profile-action-portraits {
    display: none; /* Hidden by default, shown via JS */
}

.error-message,
.success-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.error-message {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fee2e2;
}

.success-message {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

/* Bottom Actions Section */
.profile-bottom-actions {
    padding: 80px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    border-top: 1px solid #f3f4f6;
    justify-content: center;
    align-items: center;
    background: #ffffff;
}

.bottom-action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 28px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    color: #1a1a1a;
    cursor: pointer;
    transition: all 0.2s;
}

.bottom-action-btn:hover {
    background: #1a1a1a;
    border-color: #1a1a1a;
    color: #ffffff;
}

.bottom-action-btn svg {
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}

.bottom-action-btn:hover svg {
    transform: scale(1.05);
}

.bottom-action-delete {
    color: #dc2626;
    border-color: #fee2e2;
    background: #ffffff;
}

.bottom-action-delete:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #ffffff;
}

/* Delete Account Section */
.delete-account-section {
    margin-top: 24px;
    padding: 24px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #fee2e2;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.delete-account-content h3 {
    font-size: 18px;
    font-weight: 600;
    color: #dc2626;
    margin: 0 0 12px 0;
}

.delete-account-content p {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin: 0 0 12px 0;
}

.delete-warning {
    font-weight: 500;
    color: #991b1b !important;
}

.delete-warning strong {
    font-weight: 700;
    color: #dc2626;
    font-family: 'Courier New', monospace;
    background: #fee2e2;
    padding: 2px 6px;
    border-radius: 4px;
}

.delete-account-content input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #fee2e2;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    transition: all 0.2s;
    background: #ffffff;
    margin-bottom: 20px;
    color: #1a1a1a;
}

.delete-account-content input[type="text"]:focus {
    outline: none;
    border-color: #dc2626;
}

.delete-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.delete-btn-danger,
.delete-btn-cancel {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.delete-btn-danger {
    background: #dc2626;
    color: #ffffff;
    flex: 1;
    min-width: 150px;
}

.delete-btn-danger:hover {
    background: #b91c1c;
    transform: translateY(-1px);
}

.delete-btn-cancel {
    background: #ffffff;
    color: #666;
    border: 1px solid #e0e0e0;
    flex: 1;
    min-width: 100px;
}

.delete-btn-cancel:hover {
    background: #f5f5f5;
    border-color: #1a1a1a;
    color: #1a1a1a;
}

/* Story Book Back Button */
.story-book-back {
    background: #1a1a1a !important;
    color: #ffffff !important;
    border: none !important;
}

.story-book-back:hover {
    background: #1a1a1a !important;
}

/* Responsive Design */

/* Session sign-out hint (own profile only) */
.profile-session-expiry-hint {
    width: 100%;
    box-sizing: border-box;
    font-size: 13px;
    line-height: 1.45;
    color: #4b5563;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.18);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 12px;
}

/* Structured menu: content tiles use full inner width */
.profile-content-items--in-menu.content-items-grid {
    max-width: none;
    width: 100%;
    margin: 0;
}

/* ── Mobile / narrow: same structured profile menu, tuned layout (matches app ≤1024 breakpoint) ── */
@media (max-width: 1024px) {
    body.page-profile {
        --profile-banner-h: clamp(220px, 36vh, 320px);
        --profile-avatar-size: 168px;
    }

    /*
     * Desktop: .profile-background z-index 999998 (über Chat-UI) — ok.
     * Mobile: gleicher Wert liegt ÜBER .mobile-top-nav-row / .mobile-bottom-nav (10002)
     * und blendet Top-/Bottom-Islands komplett aus.
     */
    body.page-profile .profile-background {
        z-index: 0;
    }

    body.page-profile .profile-banner-new {
        height: var(--profile-banner-h);
        min-height: 220px;
        box-shadow: none;
    }

    body.page-profile .profile-identity-overlap {
        top: calc(
            var(--profile-banner-h) - var(--profile-avatar-size) / 2 - var(--profile-picture-stack-h) / 2
        );
        left: 50%;
        transform: translateX(-50%);
        width: min(100%, calc(100vw - 24px));
        max-width: 100%;
        padding: 0 max(12px, env(safe-area-inset-left, 0)) 0 max(12px, env(safe-area-inset-right, 0));
        box-sizing: border-box;
        gap: 10px;
    }

    body.page-profile .profile-picture-wrapper-vertical {
        --pp-stack-h: var(--profile-avatar-size);
        width: var(--pp-stack-h);
        height: var(--pp-stack-h);
        box-shadow: none !important;
    }

    body.page-profile .profile-picture-wrapper-vertical--has-coat {
        --pp-stack-h: var(--profile-picture-stack-h);
        width: var(--pp-stack-h);
        height: var(--pp-stack-h);
    }

    body.page-profile .profile-coat-of-arms {
        width: var(--profile-picture-stack-h);
        height: var(--profile-picture-stack-h);
    }

    body.page-profile .profile-picture-circle {
        width: var(--profile-avatar-size);
        height: var(--profile-avatar-size);
        box-shadow: none !important;
        font-size: clamp(2.5rem, 10vw, 3.25rem);
    }

    /* Name: full width, wrap long names; avoid flex-shrink hiding text */
    body.page-profile .profile-name-vertical {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    body.page-profile .profile-name-with-dropdown {
        width: 100%;
        max-width: 100%;
    }

    body.page-profile .profile-name-new-vertical {
        margin: 0 !important;
        margin-bottom: 0 !important;
        padding: 0 4px;
        box-sizing: border-box;
        font-size: clamp(1.45rem, 5.5vw, 1.95rem);
        font-weight: 700;
        line-height: 1.25;
        text-align: center;
        color: #1a1a1a !important;
        -webkit-text-fill-color: #1a1a1a;
        word-wrap: break-word;
        overflow-wrap: anywhere;
        hyphens: auto;
        min-width: 0;
        opacity: 1;
        visibility: visible;
    }

    body.page-profile .name-history-inline-panel.name-history-in-body-flow {
        max-width: 100%;
        margin: 0 0 16px 0 !important;
        max-height: min(380px, 50vh);
    }

    body.page-profile .name-history-toggle {
        min-width: 44px;
        min-height: 44px;
        padding: 0;
        background: transparent;
        border: none;
    }

    body.page-profile .name-history-toggle svg {
        width: 16px;
        height: 16px;
    }

    body.page-profile .profile-menu-surface {
        width: 100%;
        max-width: 100%;
        margin-top: calc(-1 * min(72px, var(--profile-banner-h) * 0.22));
        margin-left: 0;
        margin-right: 0;
        padding: calc(var(--profile-avatar-size) + 56px) max(12px, env(safe-area-inset-left, 0)) max(120px, calc(96px + env(safe-area-inset-bottom, 0))) max(12px, env(safe-area-inset-right, 0));
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -8px 28px rgba(26, 26, 26, 0.07);
    }

    body.page-profile .profile-menu-inner {
        max-width: none;
        width: 100%;
    }

    body.page-profile .profile-menu-section {
        padding: 16px 14px 18px;
        margin-bottom: 14px;
        border-radius: 14px;
    }

    body.page-profile .profile-menu-section-heading {
        font-size: 10px;
        letter-spacing: 0.1em;
        margin-bottom: 12px;
    }

    body.page-profile .profile-menu-section-lead {
        font-size: 13px;
        margin: -4px 0 14px 0;
    }

    body.page-profile .profile-session-expiry-hint {
        font-size: 12px;
        line-height: 1.5;
        padding: 12px 14px;
        border-radius: 12px;
    }

    /* Shortcuts: one column, list-like rows */
    body.page-profile .profile-content-items--in-menu.content-items-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    body.page-profile .profile-menu-section--contents .content-item-large {
        padding: 16px 4px;
        min-height: 56px;
        border-radius: 0;
        border-bottom: 1px solid #eef2f6;
    }

    body.page-profile .profile-menu-section--contents .content-item-large:last-child {
        border-bottom: none;
    }

    body.page-profile .content-item-icon-large {
        flex-shrink: 0;
    }

    /* Account actions: easier taps */
    body.page-profile .profile-actions--in-menu {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    body.page-profile .profile-actions--in-menu .profile-action-btn {
        width: 100%;
        justify-content: center;
        min-height: 48px;
        border-radius: 12px;
        border: 1px solid #e8ecf1;
        background: #fff;
    }

    body.page-profile .profile-background {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}

@media (max-width: 480px) {
    body.page-profile {
        --profile-avatar-size: 152px;
    }

    body.page-profile .profile-menu-surface {
        padding-top: calc(var(--profile-avatar-size) + 52px);
        border-radius: 16px 16px 0 0;
    }
}
