.user-menu {
    position: relative;
    display: inline-flex;
    z-index: 1102;
}

/* Header pages publiques (login, premium, etc.) */
.header .user-menu,
.header #fs-user-menu {
    z-index: 1102;
}

.user-menu-trigger {
    cursor: pointer;
    border: none;
    font: inherit;
    gap: 0.5rem;
}

.user-menu-trigger--with-name {
    padding-left: 0.5rem !important;
    padding-right: 0.65rem !important;
    min-height: 2.25rem;
    height: 2.25rem;
}

.user-menu.is-open .user-menu-trigger--with-name {
    border-color: rgba(255, 107, 53, 0.45) !important;
    background: rgba(255, 255, 255, 0.14) !important;
}

.user-menu-trigger .user-menu-chevron {
    font-size: 0.6rem;
    opacity: 0.55;
    margin-left: 0.15rem;
    transition: transform 0.2s ease;
}

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

.user-menu-dropdown {
    position: fixed;
    top: 0;
    left: 0;
    width: max-content;
    min-width: 200px;
    max-width: min(260px, calc(100vw - 16px));
    background: linear-gradient(160deg, #2a2a2a 0%, #161616 100%);
    border: 1px solid rgba(255, 107, 53, 0.22);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.2);
    padding: 0.35rem 0;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.user-menu.is-open .user-menu-dropdown:not(.is-positioning) {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.user-menu-dropdown.is-positioning {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.user-menu-item[hidden],
.user-menu-item.user-menu-toggle--hidden {
    display: none !important;
    pointer-events: none;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.6rem 1rem;
    color: #e5e7eb;
    text-decoration: none;
    font-size: 0.875rem;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}

.user-menu-item i {
    width: 1.1rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* Coffre : libellé + solde lingot sur une seule ligne */
.user-menu-item--coffre {
    flex-wrap: nowrap;
    gap: 0.5rem;
}

.user-menu-item--coffre .user-menu-item__label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-lingots-balance {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.2rem;
    margin-left: auto;
    font-size: 0.8rem;
    color: #f97316;
    font-weight: 700;
    white-space: nowrap;
    line-height: 1;
}

.user-menu-lingots-balance .lingot-icon {
    width: 0.85em;
    height: 0.85em;
    vertical-align: 0;
}

.user-menu-item:hover:not(.is-disabled) {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.user-menu-item:hover:not(.is-disabled) i {
    color: #ff6b35;
}

.user-menu-item.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.user-menu-item--danger {
    color: #fca5a5;
}

.user-menu-item--danger:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #fecaca;
}

.user-menu-item--danger i {
    color: #f87171;
}

.user-menu-item--warn {
    color: #fbbf24;
}

.user-menu-item--warn:hover:not(:disabled) {
    background: rgba(251, 191, 36, 0.1);
    color: #fde68a;
}

.user-menu-item--warn i {
    color: #f59e0b;
}

.user-menu-item--warn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.user-menu-item--restore {
    color: #86efac;
}

.user-menu-item--restore:hover:not(:disabled) {
    background: rgba(34, 197, 94, 0.12);
    color: #bbf7d0;
}

.user-menu-item--restore i {
    color: #4ade80;
}

.user-menu-item--restore:disabled {
    opacity: 0.6;
    cursor: wait;
}

.user-menu-divider {
    height: 1px;
    margin: 0.35rem 0.75rem;
    background: rgba(255, 255, 255, 0.08);
}

.user-menu-footer {
    padding: 0.5rem 1rem 0.35rem;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    line-height: 1.35;
}

.user-menu-trigger img {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s ease;
    opacity: 1;
}

.user-menu--loading .user-menu-trigger img {
    opacity: 0;
}

.user-menu.is-open .user-menu-trigger img,
.user-menu-trigger:hover img {
    border-color: #f97316;
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.35);
}

/* Pages login / premium : avatar seul, sans cadre bouton */
.user-menu--avatar-only .user-menu-trigger--avatar-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none;
    min-width: 0;
    height: auto;
    border-radius: 50%;
}

.user-menu--avatar-only .user-menu-trigger--avatar-only:hover,
.user-menu--avatar-only .user-menu-trigger--avatar-only:focus-visible {
    background: transparent !important;
    transform: none !important;
}

.user-menu--avatar-only .user-menu-trigger img {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.25);
    display: block;
}

.user-menu--avatar-only.is-open .user-menu-trigger img,
.user-menu--avatar-only .user-menu-trigger--avatar-only:hover img {
    border-color: #f97316;
    box-shadow: 0 0 14px rgba(249, 115, 22, 0.45);
}

/* Emplacement réservé — évite le saut de mise en page pendant le chargement */
.fs-user-menu-slot {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.fs-user-menu-slot[data-show-username="true"] {
    min-width: 11rem;
    min-height: 2.25rem;
}

.fs-user-menu-slot[data-show-username="false"] {
    min-width: 2.5rem;
    min-height: 2.5rem;
}

.user-menu-trigger--skeleton {
    pointer-events: none;
    cursor: default;
}

.user-menu-avatar-skeleton {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

.user-menu-avatar-skeleton--lg {
    width: 2.25rem;
    height: 2.25rem;
}

.user-menu-name-skeleton {
    display: inline-block;
    width: 5.5rem;
    height: 0.75rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.user-menu-trigger img.is-loaded {
    opacity: 1;
}

/* Pastille badge sur l’avatar (menu) — taille proportionnelle au conteneur */
.user-menu-avatar-wrap {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    container-type: size;
    container-name: fs-user-avatar;
    /* Carré aligné sur l’avatar : évite badge en rem « géant » vs mini logo */
    width: 1.5rem;
    height: 1.5rem;
    vertical-align: middle;
}

.user-menu--avatar-only .user-menu-avatar-wrap {
    width: 2.25rem;
    height: 2.25rem;
}

.user-menu-avatar-wrap img#user-profile-pic {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.user-menu-badge-overlay {
    position: absolute;
    right: -6%;
    bottom: -6%;
    box-sizing: border-box;
    /* Fallback si cqmin indisponible */
    width: 0.65rem;
    height: 0.65rem;
    font-size: 0.45rem;
    border-width: 1px;
    width: clamp(9px, 34cqmin, 14px);
    height: clamp(9px, 34cqmin, 14px);
    padding: 0;
    border-radius: 999px;
    background: linear-gradient(145deg, #1f2937, #111827);
    border: clamp(1px, 0.2cqmin, 2px) solid rgba(249, 115, 22, 0.88);
    font-size: clamp(5px, 22cqmin, 10px);
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}
.user-menu-badge-overlay[hidden] {
    display: none !important;
}

/* Mode image : on retire fond / bordure / ombre pour laisser le PNG transparent seul */
.user-menu-badge-overlay.has-image {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    /* Fallback si cqmin indisponible : ~20px sur l’avatar navbar */
    width: 20px;
    height: 20px;
    width: clamp(20px, 85cqmin, 30px);
    height: clamp(20px, 85cqmin, 30px);
    right: -28%;
    bottom: -28%;
    /* Petit contraste pour rester visible sur fond clair sans cadre */
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}

.user-menu-badge-overlay-img,
.user-menu-trigger .user-menu-badge-overlay-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    display: block;
    pointer-events: none;
}

/* Sécurité : aucun hover/open ne doit ajouter de halo sur l'image badge */
.user-menu.is-open .user-menu-trigger .user-menu-badge-overlay-img,
.user-menu-trigger:hover .user-menu-badge-overlay-img {
    border: none !important;
    box-shadow: none !important;
}
